/ justfile
justfile
  1  # BitKnotsRS Development Justfile
  2  # Run `just --list` to see all available commands
  3  
  4  # Default recipe - show help
  5  default:
  6      @just --list
  7  
  8  # === BUILD COMMANDS ===
  9  
 10  # Build the project in debug mode
 11  build:
 12      cargo build
 13  
 14  # Build the project in release mode
 15  build-release:
 16      cargo build --release
 17  
 18  # Clean and rebuild
 19  rebuild:
 20      cargo clean
 21      cargo build
 22  
 23  # Check if the project compiles without building
 24  check:
 25      cargo check
 26  
 27  # === RUN COMMANDS ===
 28  
 29  # Run with default config
 30  run:
 31      cargo run
 32  
 33  # Run with custom config file
 34  run-config config_file:
 35      cargo run -- --config {{config_file}}
 36  
 37  # Run in regtest mode
 38  run-regtest:
 39      cargo run -- --network regtest
 40  
 41  # Run in testnet mode
 42  run-testnet:
 43      cargo run -- --network testnet
 44  
 45  # Run in mainnet mode
 46  run-mainnet:
 47      cargo run -- --network mainnet
 48  
 49  # Run with mainnet config file
 50  run-mainnet-config:
 51      cargo run -- --config config/mainnet.toml
 52  
 53  # Run with testnet config file
 54  run-testnet-config:
 55      cargo run -- --config config/testnet.toml
 56  
 57  # Run with regtest config file
 58  run-regtest-config:
 59      cargo run -- --config config/regtest.toml
 60  
 61  # Run with custom data directory
 62  run-datadir datadir:
 63      cargo run -- --datadir {{datadir}}
 64  
 65  # Generate default config file
 66  generate-config:
 67      cargo run -- --generate-config
 68  
 69  # Generate test config file
 70  generate-test-config:
 71      cargo run -- --config test-config.toml --generate-config
 72  
 73  # === TEST COMMANDS ===
 74  
 75  # Run all tests
 76  test:
 77      cargo test
 78  
 79  # Run tests with output
 80  test-verbose:
 81      cargo test -- --nocapture
 82  
 83  # Run only unit tests
 84  test-unit:
 85      cargo test --lib
 86  
 87  # Run tests with coverage (requires cargo-tarpaulin)
 88  test-coverage:
 89      cargo tarpaulin --out Html
 90  
 91  # Run specific test
 92  test-one test_name:
 93      cargo test {{test_name}}
 94  
 95  # === DEVELOPMENT COMMANDS ===
 96  
 97  # Run in development mode with auto-reload (requires cargo-watch)
 98  dev:
 99      cargo watch -x run
100  
101  # Watch for changes and run tests
102  watch:
103      cargo watch -x test
104  
105  # Format code
106  fmt:
107      cargo fmt
108  
109  # Run clippy linter
110  lint:
111      cargo clippy
112  
113  # Fix linting issues automatically
114  fix:
115      cargo fix --allow-dirty --allow-staged
116  
117  # Quick check (format, lint, test)
118  quick-check:
119      cargo fmt
120      cargo clippy
121      cargo test
122  
123  # Development workflow with Radicle sync
124  dev-workflow:
125      cargo fmt
126      cargo clippy
127      cargo test
128      rad sync
129  
130  # Prepare patch (format, lint, test, sync)
131  patch-prep:
132      cargo fmt
133      cargo clippy -- -D warnings
134      cargo test
135      rad sync
136      @echo "Ready to create patch with: just patch-new"
137  
138  # === DOCKER COMMANDS ===
139  
140  # Build Docker image
141  docker-build:
142      docker build -t bitknotsrs .
143  
144  # Run in Docker container
145  docker-run:
146      docker run -p 8332:8332 -p 18443:18443 -v $(pwd)/data:/app/data bitknotsrs
147  
148  # Stop Docker container
149  docker-stop:
150      docker stop $(docker ps -q --filter ancestor=bitknotsrs)
151  
152  # === API/RPC TESTING ===
153  
154  # Test API health endpoint
155  test-api-health:
156      curl -s http://localhost:8332/health | jq .
157  
158  # Test API node info
159  test-api-info:
160      curl -s http://localhost:8332/api/v1/info | jq .
161  
162  # Test API node stats
163  test-api-stats:
164      curl -s http://localhost:8332/api/v1/stats | jq .
165  
166  # Test API peers
167  test-api-peers:
168      curl -s http://localhost:8332/api/v1/peers | jq .
169  
170  # Test API mempool
171  test-api-mempool:
172      curl -s http://localhost:8332/api/v1/mempool | jq .
173  
174  # Test RPC getblockchaininfo
175  test-rpc-info:
176      curl -s -X POST http://localhost:18443 \
177          -H "Content-Type: application/json" \
178          -d '{"jsonrpc":"2.0","method":"getblockchaininfo","params":[],"id":1}' | jq .
179  
180  # Test RPC getbestblockhash
181  test-rpc-hash:
182      curl -s -X POST http://localhost:18443 \
183          -H "Content-Type: application/json" \
184          -d '{"jsonrpc":"2.0","method":"getbestblockhash","params":[],"id":1}' | jq .
185  
186  # === NETWORK-SPECIFIC API TESTING ===
187  
188  # Test mainnet API (port 8332)
189  test-api-mainnet:
190      curl -s http://localhost:8332/health | jq .
191      curl -s http://localhost:8332/api/v1/info | jq .
192  
193  # Test testnet API (port 18332)
194  test-api-testnet:
195      curl -s http://localhost:18332/health | jq .
196      curl -s http://localhost:18332/api/v1/info | jq .
197  
198  # Test regtest API (port 8332)
199  test-api-regtest:
200      curl -s http://localhost:8332/health | jq .
201      curl -s http://localhost:8332/api/v1/info | jq .
202  
203  # Test mainnet RPC (port 8333)
204  test-rpc-mainnet:
205      curl -s -X POST http://localhost:8333 \
206          -H "Content-Type: application/json" \
207          -d '{"jsonrpc":"2.0","method":"getblockchaininfo","params":[],"id":1}' | jq .
208  
209  # Test testnet RPC (port 18333)
210  test-rpc-testnet:
211      curl -s -X POST http://localhost:18333 \
212          -H "Content-Type: application/json" \
213          -d '{"jsonrpc":"2.0","method":"getblockchaininfo","params":[],"id":1}' | jq .
214  
215  # Test regtest RPC (port 18443)
216  test-rpc-regtest:
217      curl -s -X POST http://localhost:18443 \
218          -H "Content-Type: application/json" \
219          -d '{"jsonrpc":"2.0","method":"getblockchaininfo","params":[],"id":1}' | jq .
220  
221  # === RADICLE COMMANDS ===
222  
223  # List all issues
224  issues:
225      rad issue list
226  
227  # Show specific issue
228  issue id:
229      rad issue show {{id}}
230  
231  # Create new issue
232  issue-new:
233      rad issue open
234  
235  # List all patches
236  patches:
237      rad patch list
238  
239  # Show specific patch
240  patch id:
241      rad patch show {{id}}
242  
243  # Create new patch from current branch
244  patch-new:
245      rad patch open
246  
247  # Sync with Radicle network
248  sync:
249      rad sync
250  
251  # Show repository information
252  rad-info:
253      rad inspect
254  
255  # Show connected peers
256  rad-peers:
257      rad node sessions
258  
259  # Clone a Radicle repository
260  rad-clone repo_id:
261      rad clone {{repo_id}}
262  
263  # Initialize current repository for Radicle
264  rad-init:
265      rad init
266  
267  # Publish repository to Radicle network
268  rad-publish:
269      rad push
270  
271  # Show Radicle node status
272  rad-status:
273      rad node status
274  
275  # Start Radicle node
276  rad-start:
277      rad node start
278  
279  # Stop Radicle node
280  rad-stop:
281      rad node stop
282  
283  # Show Radicle identity
284  rad-id:
285      rad self
286  
287  # Search issues by keyword (case-insensitive)
288  search-issues keyword:
289      @echo "=== Searching issues for: {{keyword}} ==="
290      rad issue list | grep -i "{{keyword}}" || echo "No issues found matching '{{keyword}}'"
291  
292  # Show issue summary (titles only)
293  issues-summary:
294      @echo "=== All Issues Summary ==="
295      rad issue list | head -20
296  
297  # === ISSUE WORKSPACE COMMANDS ===
298  
299  # Create new issue draft from template
300  draft-issue name:
301      cp .issues/templates/issue-template.md .issues/drafts/{{name}}.md
302      @echo "Created issue draft: .issues/drafts/{{name}}.md"
303  
304  # Create new patch draft from template
305  draft-patch name:
306      cp .issues/templates/patch-template.md .issues/drafts/{{name}}.md
307      @echo "Created patch draft: .issues/drafts/{{name}}.md"
308  
309  # Create issue from draft
310  create-issue title draft:
311      rad issue open --title "{{title}}" --description "$(cat .issues/drafts/{{draft}}.md)"
312  
313  # Create patch from draft
314  create-patch title draft:
315      rad patch open --title "{{title}}" --description "$(cat .issues/drafts/{{draft}}.md)"
316  
317  # Clean up temporary files
318  clean-drafts:
319      rm -f .issues/drafts/*.md
320      rm -f .issues/temp/*.md
321  
322  # List current drafts
323  list-drafts:
324      @echo "=== Issue/Patch Drafts ==="
325      @ls -la .issues/drafts/ 2>/dev/null || echo "No drafts found"
326  
327  # Show issue creation checklist
328  issue-checklist:
329      @cat .issues/templates/issue-checklist.md
330  
331  # === GIT WORKFLOW COMMANDS ===
332  
333  # Check git status and show ignored files
334  git-status:
335      git status
336      @echo ""
337      @echo "=== Recently ignored files ==="
338      @git ls-files --others --ignored --exclude-standard | head -10
339  
340  # Clean git ignored files
341  git-clean:
342      git clean -fdX
343  
344  # Show what would be cleaned
345  git-clean-dry:
346      git clean -fdXn
347  
348  # === UTILITY COMMANDS ===
349  
350  # Clean build artifacts and data
351  clean:
352      cargo clean
353      rm -rf data/
354      rm -rf test_data/
355      rm -rf logs/
356  
357  # Clean only data directories
358  clean-data:
359      rm -rf data/
360      rm -rf test_data/
361  
362  # Backup data directory
363  backup:
364      tar -czf backup-$(date +%Y%m%d-%H%M%S).tar.gz data/
365  
366  # Show project statistics
367  stats:
368      @echo "=== Project Statistics ==="
369      @echo "Lines of code:"
370      @find src -name "*.rs" -exec wc -l {} + | tail -1
371      @echo ""
372      @echo "Test count:"
373      @grep -r "#\[test\]" src --include="*.rs" | wc -l
374      @echo ""
375      @echo "Dependencies:"
376      @grep "^[a-zA-Z]" Cargo.toml | grep "=" | wc -l
377  
378  # Show system requirements
379  requirements:
380      @echo "=== System Requirements ==="
381      @echo "Rust version: $(rustc --version)"
382      @echo "Cargo version: $(cargo --version)"
383      @echo "Available disk space:"
384      @df -h . | tail -1
385      @echo "Available memory:"
386      @free -h 2>/dev/null || vm_stat | head -5
387  
388  # === BENCHMARKING ===
389  
390  # Run benchmarks (requires nightly Rust)
391  bench:
392      cargo +nightly bench
393  
394  # Profile the application (requires cargo-flamegraph)
395  profile:
396      cargo flamegraph --bin bitknotsrs
397  
398  # === DATABASE COMMANDS ===
399  
400  # Initialize database with test data
401  init-db:
402      cargo run -- --config test-config.toml --generate-config
403      cargo run -- --config test-config.toml
404  
405  # Initialize mainnet database
406  init-db-mainnet:
407      cargo run -- --config config/mainnet.toml --generate-config
408      mkdir -p data/mainnet logs/mainnet
409      cargo run -- --config config/mainnet.toml
410  
411  # Initialize testnet database
412  init-db-testnet:
413      cargo run -- --config config/testnet.toml --generate-config
414      mkdir -p data/testnet logs/testnet
415      cargo run -- --config config/testnet.toml
416  
417  # Initialize regtest database
418  init-db-regtest:
419      cargo run -- --config config/regtest.toml --generate-config
420      mkdir -p data/regtest logs/regtest
421      cargo run -- --config config/regtest.toml
422  
423  # Reset database
424  reset-db:
425      rm -rf data/rocksdb/
426      rm -rf test_data/rocksdb/
427  
428  # Reset all network databases
429  reset-db-all:
430      rm -rf data/mainnet/rocksdb/
431      rm -rf data/testnet/rocksdb/
432      rm -rf data/regtest/rocksdb/
433      rm -rf test_data/rocksdb/
434  
435  # Reset mainnet database
436  reset-db-mainnet:
437      rm -rf data/mainnet/rocksdb/
438  
439  # Reset testnet database
440  reset-db-testnet:
441      rm -rf data/testnet/rocksdb/
442  
443  # Reset regtest database
444  reset-db-regtest:
445      rm -rf data/regtest/rocksdb/
446  
447  # Backup database
448  backup-db:
449      tar -czf db-backup-$(date +%Y%m%d-%H%M%S).tar.gz data/rocksdb/
450  
451  # Backup all network databases
452  backup-db-all:
453      tar -czf db-backup-all-$(date +%Y%m%d-%H%M%S).tar.gz data/
454  
455  # Backup mainnet database
456  backup-db-mainnet:
457      tar -czf db-backup-mainnet-$(date +%Y%m%d-%H%M%S).tar.gz data/mainnet/
458  
459  # Backup testnet database
460  backup-db-testnet:
461      tar -czf db-backup-testnet-$(date +%Y%m%d-%H%M%S).tar.gz data/testnet/
462  
463  # Backup regtest database
464  backup-db-regtest:
465      tar -czf db-backup-regtest-$(date +%Y%m%d-%H%M%S).tar.gz data/regtest/
466  
467  # === MONITORING ===
468  
469  # Show metrics (if metrics server is running)
470  metrics:
471      curl -s http://localhost:9090/metrics
472  
473  # Show logs (if file logging is enabled)
474  logs:
475      tail -f logs/bitknotsrs.log
476  
477  # Monitor system resources
478  monitor:
479      watch -n 1 'ps aux | grep bitknotsrs; echo ""; df -h .; echo ""; free -h'
480  
481  # === RELEASE COMMANDS ===
482  
483  # Prepare for release (format, lint, test, build)
484  release-prep:
485      cargo fmt
486      cargo clippy -- -D warnings
487      cargo test
488      cargo build --release
489  
490  # Create release build with optimizations
491  release-build:
492      RUSTFLAGS="-C target-cpu=native" cargo build --release
493  
494  # === HELP COMMANDS ===
495  
496  # Show build help
497  help-build:
498      @echo "=== Build Commands ==="
499      @echo "build          - Build in debug mode"
500      @echo "build-release  - Build in release mode"
501      @echo "rebuild        - Clean and rebuild"
502      @echo "check          - Check compilation without building"
503  
504  # Show run help
505  help-run:
506      @echo "=== Run Commands ==="
507      @echo "run                 - Run with default config"
508      @echo "run-config          - Run with custom config file"
509      @echo "run-regtest         - Run in regtest mode"
510      @echo "run-testnet         - Run in testnet mode"
511      @echo "run-mainnet         - Run in mainnet mode"
512      @echo "run-regtest-config  - Run with regtest config file"
513      @echo "run-testnet-config  - Run with testnet config file"
514      @echo "run-mainnet-config  - Run with mainnet config file"
515      @echo "run-datadir         - Run with custom data directory"
516  
517  # Show test help
518  help-test:
519      @echo "=== Test Commands ==="
520      @echo "test           - Run all tests"
521      @echo "test-verbose   - Run tests with output"
522      @echo "test-unit      - Run only unit tests"
523      @echo "test-coverage  - Run tests with coverage"
524      @echo "test-one       - Run specific test"
525  
526  # Show development help
527  help-dev:
528      @echo "=== Development Commands ==="
529      @echo "dev            - Run with auto-reload"
530      @echo "watch          - Watch and run tests"
531      @echo "fmt            - Format code"
532      @echo "lint           - Run clippy linter"
533      @echo "fix            - Fix linting issues"
534      @echo "quick-check    - Format, lint, and test"
535  
536  # Show Radicle help
537  help-rad:
538      @echo "=== Radicle Commands ==="
539      @echo "issues         - List all issues"
540      @echo "issues-summary - Show issue titles only"
541      @echo "search-issues <keyword> - Search issues by keyword"
542      @echo "issue <id>     - Show specific issue"
543      @echo "issue-new      - Create new issue"
544      @echo "patches        - List all patches"
545      @echo "patch <id>     - Show specific patch"
546      @echo "patch-new      - Create new patch from current branch"
547      @echo "sync           - Sync with Radicle network"
548      @echo "rad-info       - Show repository information"
549      @echo "rad-peers      - Show connected peers"
550      @echo "rad-status     - Show Radicle node status"
551      @echo "rad-start      - Start Radicle node"
552      @echo "rad-stop       - Stop Radicle node"
553      @echo "rad-id         - Show Radicle identity"
554      @echo ""
555      @echo "=== Issue Workspace Commands ==="
556      @echo "issue-checklist        - Show issue creation checklist"
557      @echo "draft-issue <name>     - Create issue draft from template"
558      @echo "draft-patch <name>     - Create patch draft from template"
559      @echo "create-issue <title> <draft> - Create Radicle issue from draft"
560      @echo "create-patch <title> <draft> - Create Radicle patch from draft"
561      @echo "list-drafts            - List current drafts"
562      @echo "clean-drafts           - Clean up temporary files"
563  
564  # Show all help sections
565  help-all:
566      @just help-build
567      @echo ""
568      @just help-run
569      @echo ""
570      @just help-test
571      @echo ""
572      @just help-dev
573      @echo ""
574      @just help-rad