-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
158 lines (130 loc) · 4.66 KB
/
Justfile
File metadata and controls
158 lines (130 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# MindTape development recipes
# Run all checks (clippy + tests + file size)
check:
cargo clippy --workspace --all-targets -q
cargo test --workspace -q
just check-file-size
# Run tests only
test *ARGS:
cargo test --workspace {{ ARGS }}
# Run clippy only
clippy:
cargo clippy --workspace --all-targets -q
# Auto-fix clippy warnings
clippy-fix:
cargo clippy --fix --workspace --all-targets
# Build the project
build:
cargo build --workspace -q
# Run coverage with tarpaulin
cover:
cargo tarpaulin --workspace
# Format code
fmt:
cargo fmt --all
# Format check (CI-friendly)
fmt-check:
cargo fmt --all -- --check
# Count tests across workspace
count-tests:
#!/usr/bin/env bash
cargo test --workspace 2>&1 | grep "test result:" | awk '{sum += $4} END {print sum " tests"}'
# Show top 20 files by line count
file-sizes:
#!/usr/bin/env bash
find . -type f \( -name '*.rs' -o -name '*.md' \) ! -path './target/*' -exec wc -l {} + | sort -rn | head -20
# Check for oversized files (fails if any exceed limits)
check-file-size:
#!/usr/bin/env bash
set -euo pipefail
# Thresholds
RUST_LIMIT=500
MARKDOWN_LIMIT=200
# Exception list (relative to project root)
# sqlite.rs is schema-heavy, hard to split meaningfully
# watcher/tests.rs has many integration-style scenarios
EXCEPTIONS=(
"crates/mindtape-store/src/store/sqlite.rs"
"crates/mindtape-store/src/store/sqlite_tests.rs"
"crates/mindtape-eval/src/write_tests.rs"
"src/watcher/tests.rs"
)
failed=0
# Check Rust files
while IFS= read -r file; do
lines=$(wc -l < "$file")
# Check if file is in exceptions
skip=0
for exception in "${EXCEPTIONS[@]}"; do
if [[ "$file" == "./$exception" ]]; then
skip=1
break
fi
done
if [[ $skip -eq 0 && $lines -gt $RUST_LIMIT ]]; then
echo "❌ $file: $lines lines (limit: $RUST_LIMIT)"
failed=1
fi
done < <(find . -type f -name '*.rs' ! -path './target/*')
# Check Markdown files
while IFS= read -r file; do
lines=$(wc -l < "$file")
if [[ $lines -gt $MARKDOWN_LIMIT ]]; then
echo "❌ $file: $lines lines (limit: $MARKDOWN_LIMIT)"
failed=1
fi
done < <(find . -type f -name '*.md' ! -path './target/*')
if [[ $failed -eq 1 ]]; then
echo ""
echo "Some files exceed size limits. Consider refactoring."
exit 1
else
echo "✓ All files within size limits"
fi
# Release a new version: bumps workspace version, commits, tags, and pushes
release VERSION:
#!/usr/bin/env bash
set -euo pipefail
# Validate semver format
if ! echo "{{ VERSION }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "❌ Invalid version format: {{ VERSION }} (expected: X.Y.Z)"
exit 1
fi
CURRENT=$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)"/\1/')
echo "Bumping $CURRENT → {{ VERSION }}"
# Update workspace version
sed -i '0,/^version = ".*"/s//version = "{{ VERSION }}"/' Cargo.toml
# Update inter-crate dependency versions
sed -i 's/\(mindtape-eval = { path = "[^"]*", version = \)"[^"]*"/\1"{{ VERSION }}"/' Cargo.toml crates/mindtape-store/Cargo.toml
sed -i 's/\(mindtape-store = { path = "[^"]*", version = \)"[^"]*"/\1"{{ VERSION }}"/' Cargo.toml
# Verify it compiles
cargo check --workspace -q
git add -A
git commit -m "chore: bump version to {{ VERSION }}"
git tag "v{{ VERSION }}"
echo "✓ Created commit and tag v{{ VERSION }}"
echo " Run 'git push && git push --tags' to trigger the release workflow"
# Validate that nix/install-example.nix parses correctly
check-nix-example:
nix-instantiate --parse nix/install-example.nix > /dev/null
# Install mindtape library globally for Typst (via symlink)
install-lib:
#!/usr/bin/env bash
set -euo pipefail
VERSION=$(grep '^version' lib/typst.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
TARGET_DIR="$HOME/.local/share/typst/packages/local/mindtape"
mkdir -p "$TARGET_DIR"
ln -sfn "$(pwd)/lib" "$TARGET_DIR/$VERSION"
echo "✓ Installed mindtape library to $TARGET_DIR/$VERSION"
echo " Use in Typst files: #import \"@local/mindtape:$VERSION\": due, id, tag"
# Uninstall global mindtape library
uninstall-lib:
#!/usr/bin/env bash
VERSION=$(grep '^version' lib/typst.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
TARGET="$HOME/.local/share/typst/packages/local/mindtape/$VERSION"
if [ -L "$TARGET" ]; then
rm "$TARGET"
echo "✓ Removed $TARGET"
else
echo "! No symlink found at $TARGET"
fi