|
| 1 | +# justfile for libtmux |
| 2 | +# https://just.systems/ |
| 3 | + |
| 4 | +set shell := ["bash", "-uc"] |
| 5 | + |
| 6 | +# File patterns |
| 7 | +py_files := "find . -type f -not -path '*/\\.*' | grep -i '.*[.]py$' 2> /dev/null" |
| 8 | +doc_files := "find . -type f -not -path '*/\\.*' | grep -i '.*[.]rst$\\|.*[.]md$\\|.*[.]css$\\|.*[.]py$\\|mkdocs\\.yml\\|CHANGES\\|TODO\\|.*conf\\.py' 2> /dev/null" |
| 9 | +all_files := "find . -type f -not -path '*/\\.*' | grep -i '.*[.]py$\\|.*[.]rst$\\|.*[.]md$\\|.*[.]css$\\|.*[.]py$\\|mkdocs\\.yml\\|CHANGES\\|TODO\\|.*conf\\.py' 2> /dev/null" |
| 10 | + |
| 11 | +# List all available commands |
| 12 | +default: |
| 13 | + @just --list |
| 14 | + |
| 15 | +# ============================================================================ |
| 16 | +# Testing |
| 17 | +# ============================================================================ |
| 18 | + |
| 19 | +# Run tests with pytest |
| 20 | +test *args: |
| 21 | + uv run py.test {{ args }} |
| 22 | + |
| 23 | +# Run tests then start continuous testing with pytest-watcher |
| 24 | +start: |
| 25 | + just test |
| 26 | + uv run ptw . |
| 27 | + |
| 28 | +# Watch files and run tests on change (requires entr) |
| 29 | +watch-test: |
| 30 | + #!/usr/bin/env bash |
| 31 | + set -euo pipefail |
| 32 | + if command -v entr > /dev/null; then |
| 33 | + ${{ all_files }} | entr -c just test |
| 34 | + else |
| 35 | + just test |
| 36 | + just _entr-warn |
| 37 | + fi |
| 38 | + |
| 39 | +# ============================================================================ |
| 40 | +# Documentation |
| 41 | +# ============================================================================ |
| 42 | + |
| 43 | +# Build documentation |
| 44 | +build-docs: |
| 45 | + just -f docs/justfile html |
| 46 | + |
| 47 | +# Watch files and rebuild docs on change |
| 48 | +watch-docs: |
| 49 | + #!/usr/bin/env bash |
| 50 | + set -euo pipefail |
| 51 | + if command -v entr > /dev/null; then |
| 52 | + ${{ doc_files }} | entr -c just build-docs |
| 53 | + else |
| 54 | + just build-docs |
| 55 | + just _entr-warn |
| 56 | + fi |
| 57 | + |
| 58 | +# Serve documentation |
| 59 | +serve-docs: |
| 60 | + just -f docs/justfile serve |
| 61 | + |
| 62 | +# Watch and serve docs simultaneously |
| 63 | +dev-docs: |
| 64 | + #!/usr/bin/env bash |
| 65 | + set -euo pipefail |
| 66 | + just watch-docs & |
| 67 | + just serve-docs |
| 68 | + |
| 69 | +# Start documentation server with auto-reload |
| 70 | +start-docs: |
| 71 | + just -f docs/justfile start |
| 72 | + |
| 73 | +# Start documentation design mode (watches static files) |
| 74 | +design-docs: |
| 75 | + just -f docs/justfile design |
| 76 | + |
| 77 | +# ============================================================================ |
| 78 | +# Linting & Formatting |
| 79 | +# ============================================================================ |
| 80 | + |
| 81 | +# Format code with ruff |
| 82 | +ruff-format: |
| 83 | + uv run ruff format . |
| 84 | + |
| 85 | +# Run ruff linter |
| 86 | +ruff: |
| 87 | + uv run ruff check . |
| 88 | + |
| 89 | +# Watch files and run ruff on change |
| 90 | +watch-ruff: |
| 91 | + #!/usr/bin/env bash |
| 92 | + set -euo pipefail |
| 93 | + if command -v entr > /dev/null; then |
| 94 | + ${{ py_files }} | entr -c just ruff |
| 95 | + else |
| 96 | + just ruff |
| 97 | + just _entr-warn |
| 98 | + fi |
| 99 | + |
| 100 | +# Run mypy type checker |
| 101 | +mypy: |
| 102 | + uv run mypy $(${{ py_files }}) |
| 103 | + |
| 104 | +# Watch files and run mypy on change |
| 105 | +watch-mypy: |
| 106 | + #!/usr/bin/env bash |
| 107 | + set -euo pipefail |
| 108 | + if command -v entr > /dev/null; then |
| 109 | + ${{ py_files }} | entr -c just mypy |
| 110 | + else |
| 111 | + just mypy |
| 112 | + just _entr-warn |
| 113 | + fi |
| 114 | + |
| 115 | +# Format markdown files with prettier |
| 116 | +format-markdown: |
| 117 | + prettier --parser=markdown -w *.md docs/*.md docs/**/*.md CHANGES |
| 118 | + |
| 119 | +# ============================================================================ |
| 120 | +# Typing |
| 121 | +# ============================================================================ |
| 122 | + |
| 123 | +# Run monkeytype to collect runtime types |
| 124 | +monkeytype-create: |
| 125 | + uv run monkeytype run $(uv run which py.test) |
| 126 | + |
| 127 | +# Apply collected monkeytype annotations |
| 128 | +monkeytype-apply: |
| 129 | + uv run monkeytype list-modules | xargs -n1 -I{} sh -c 'uv run monkeytype apply {}' |
| 130 | + |
| 131 | +# ============================================================================ |
| 132 | +# Private helpers |
| 133 | +# ============================================================================ |
| 134 | + |
| 135 | +[private] |
| 136 | +_entr-warn: |
| 137 | + @echo "----------------------------------------------------------" |
| 138 | + @echo " ! File watching functionality non-operational ! " |
| 139 | + @echo " " |
| 140 | + @echo "Install entr(1) to automatically run tasks on file change." |
| 141 | + @echo "See https://eradman.com/entrproject/ " |
| 142 | + @echo "----------------------------------------------------------" |
0 commit comments