-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
319 lines (263 loc) · 8.68 KB
/
justfile
File metadata and controls
319 lines (263 loc) · 8.68 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# Bleuprint Development Commands
# Run `just --list` to see all available commands
# Default recipe - show help
default:
@just --list
# === SETUP COMMANDS ===
# Install Nix (if not already installed)
install-nix:
#!/usr/bin/env bash
if ! command -v nix &> /dev/null; then
echo "Installing Nix..."
curl -L https://nixos.org/nix/install | sh -s -- --daemon
echo "Please restart your shell to use Nix"
else
echo "Nix is already installed: $(nix --version)"
fi
# Set up git hooks for code quality
setup-hooks:
@echo "Setting up git hooks..."
@./scripts/setup-git-hooks.sh
# Complete setup (install dependencies, set up hooks)
setup: install-nix setup-hooks
@echo "Setup complete! 🎉"
# === VALIDATION COMMANDS ===
# Comprehensive validation (syntax, flakes, conflicts, builds)
validate:
@echo "Running comprehensive validation..."
@./scripts/validate-all.sh
# Legacy Nix validation (kept for compatibility)
validate-nix:
@echo "Validating Nix configuration..."
@./scripts/validate-nix.sh
# Run comprehensive test suite
test:
@echo "Running comprehensive test suite..."
@./scripts/test-suite.sh
# Quick syntax check (fast)
check:
#!/usr/bin/env bash
export NIX_CONFIG="experimental-features = nix-command flakes"
echo "Quick syntax check..."
nix flake check --no-build
# === BUILD COMMANDS ===
# Build the Darwin configuration
build:
#!/usr/bin/env bash
export NIX_CONFIG="experimental-features = nix-command flakes"
echo "Building Darwin configuration..."
nix build .#darwinConfigurations.bleuprint.system
# Dry run build (check what would be built)
build-dry:
#!/usr/bin/env bash
export NIX_CONFIG="experimental-features = nix-command flakes"
echo "Dry run build..."
nix build .#darwinConfigurations.bleuprint.system --dry-run
# Show flake outputs
show:
#!/usr/bin/env bash
export NIX_CONFIG="experimental-features = nix-command flakes"
nix flake show
# === INSTALLATION COMMANDS ===
# Install the configuration (applies the Darwin configuration)
install:
@echo "Installing Bleuprint configuration..."
@./install.sh
# Quick install (bypass some checks)
install-quick:
@echo "Quick install..."
@bash install.sh --quick
# === DEVELOPMENT COMMANDS ===
# Format Nix files (requires nixpkgs-fmt)
format:
#!/usr/bin/env bash
if command -v nixpkgs-fmt &> /dev/null; then
find . -name "*.nix" -not -path "./.git/*" -exec nixpkgs-fmt {} \;
echo "Formatted Nix files"
else
echo "nixpkgs-fmt not found. Install with: nix-env -iA nixpkgs.nixpkgs-fmt"
fi
# Update flake inputs
update:
#!/usr/bin/env bash
export NIX_CONFIG="experimental-features = nix-command flakes"
echo "Updating flake inputs..."
nix flake update
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -rf result result-*
@echo "Cleaned!"
# === GIT COMMANDS ===
# Commit with conventional commit format
commit message:
@git add -A
@git commit -m "{{message}}"
# Push with validation
push:
@echo "Pushing with validation..."
@git push
# Create a new feature branch
branch name:
@git checkout -b "{{name}}"
@echo "Created and switched to branch: {{name}}"
# === CI/CD COMMANDS ===
# Simulate CI locally (comprehensive)
ci:
@echo "Simulating CI pipeline locally..."
@just validate
@just test
@just security
@echo "CI simulation complete! ✅"
# Run security checks
security:
#!/usr/bin/env bash
echo "Running security checks..."
# Check for secrets
if grep -r "password\|secret\|api[_-]key" modules/ --exclude-dir=.git | grep -v "example\|TODO"; then
echo "⚠️ Potential secrets found!"
exit 1
fi
# Check for large files
find . -type f -size +1M -not -path "./.git/*" -not -path "./result*" | head -5
echo "Security checks passed ✅"
# === DOCUMENTATION COMMANDS ===
# Generate CLI documentation
docs:
@echo "Generating CLI documentation..."
@./scripts/generate-cli-docs.sh
# Serve documentation locally (if using Jekyll)
serve-docs:
#!/usr/bin/env bash
if command -v bundle &> /dev/null; then
bundle exec jekyll serve
else
echo "Jekyll not available. Install with: gem install jekyll bundler"
fi
# === MAINTENANCE COMMANDS ===
# Fix common permissions issues
fix-perms:
@echo "Fixing permissions..."
@./scripts/fix-permissions.sh
# Run smoke tests
smoke-test:
@echo "Running smoke tests..."
@./scripts/smoke-test.sh
# Test modern tools
test-tools:
@echo "Testing modern tools..."
@./scripts/test-modern-tools.sh
# === UTILITY COMMANDS ===
# Show system information
info:
#!/usr/bin/env bash
echo "=== System Information ==="
echo "OS: $(uname -s) $(uname -r)"
echo "Architecture: $(uname -m)"
if command -v nix &> /dev/null; then
echo "Nix: $(nix --version)"
else
echo "Nix: Not installed"
fi
echo ""
echo "=== Git Information ==="
echo "Branch: $(git branch --show-current)"
echo "Commit: $(git rev-parse --short HEAD)"
echo "Status: $(git status --porcelain | wc -l) files changed"
echo ""
echo "=== Project Structure ==="
find . -maxdepth 2 -type d -not -path "./.git*" | sort
# Watch for changes and validate
watch:
#!/usr/bin/env bash
if command -v fswatch &> /dev/null; then
echo "Watching for changes..."
fswatch -o . | while read f; do
if ls *.nix modules/**/*.nix 2>/dev/null | head -1 > /dev/null; then
echo "Changes detected, validating..."
just check || echo "❌ Validation failed"
fi
done
else
echo "fswatch not found. Install with: brew install fswatch"
fi
# === TROUBLESHOOTING ===
# Debug Nix issues
debug:
#!/usr/bin/env bash
export NIX_CONFIG="experimental-features = nix-command flakes"
echo "=== Debug Information ==="
echo "Nix version: $(nix --version)"
echo "Flake check with verbose output:"
nix flake check --show-trace --verbose 2>&1 | head -50
# Reset git hooks (if they're causing issues)
reset-hooks:
@echo "Resetting git hooks..."
@rm -f .git/hooks/pre-commit .git/hooks/pre-push .git/hooks/commit-msg
@echo "Git hooks removed. Run 'just setup-hooks' to reinstall."
# Emergency bypass (disable all hooks temporarily)
bypass-hooks:
@git config core.hooksPath /dev/null
@echo "⚠️ Git hooks bypassed temporarily"
@echo "Re-enable with: git config --unset core.hooksPath"
# Re-enable hooks
enable-hooks:
@git config --unset core.hooksPath
@echo "✅ Git hooks re-enabled"
# === TEMPLATE COMMANDS ===
# Test template cleanup (simulate what happens when someone uses the template)
test-template:
#!/usr/bin/env bash
echo "🧪 Testing template cleanup simulation..."
# Create a backup
git stash push -m "Template test backup"
# Simulate template cleanup
echo "📋 Files that would be removed:"
echo "- scripts/validate-nix.sh"
echo "- scripts/test-suite.sh"
echo "- scripts/setup-git-hooks.sh"
echo "- justfile"
echo "- flake.lock"
echo "- docs/TEMPLATE_INFO.md"
echo "- docs/CONTRIBUTING.md"
echo "- .github/ISSUE_TEMPLATE/"
echo "- .github/FUNDING.yml"
echo ""
echo "📝 Files that would be created:"
echo "- FIRST_TIME_SETUP.md"
echo "- Personalized README.md"
echo "- Setup checklist issue"
echo ""
echo "🔄 Configuration updates:"
echo "- Replace 'bleuprint' with user's repo name"
echo "- Replace 'bleulabs' with user's username"
echo "- Update placeholder values in modules/home/default.nix"
# Restore backup
git stash pop
echo ""
echo "✅ Template test complete (no actual changes made)"
# Prepare repository for template use
prepare-template:
#!/usr/bin/env bash
echo "🎯 Preparing repository for template use..."
# Ensure all development files are properly marked
if [ ! -f ".templateignore" ]; then
echo "❌ .templateignore file missing"
exit 1
fi
# Check template cleanup workflow
if [ ! -f ".github/template-cleanup.yml" ]; then
echo "❌ Template cleanup workflow missing"
exit 1
fi
# Validate that template files exist
echo "✅ .templateignore exists"
echo "✅ Template cleanup workflow exists"
echo "✅ Repository metadata configured"
echo ""
echo "🚀 Repository is ready to be used as a template!"
echo ""
echo "To enable template mode on GitHub:"
echo "1. Go to repository Settings"
echo "2. Check 'Template repository' under General"
echo "3. Users can then click 'Use this template' to create their own copy"