forked from marmot-protocol/whitenoise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
341 lines (276 loc) Β· 11.2 KB
/
Copy pathjustfile
File metadata and controls
341 lines (276 loc) Β· 11.2 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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# Justfile for White Noise Flutter project
# Default recipe - show available commands
default:
@just --list
# Pre-commit checks: run the same checks as CI locally (quiet mode - minimal output)
precommit:
@just _run-quiet "deps-flutter" "flutter deps"
@just _run-quiet "deps-rust" "rust deps"
@just _run-quiet "l10n" "l10n generation"
@just _run-quiet "validate-locales-keys" "l10n validation"
@just _run-quiet "fix" "auto-fix"
@just _run-quiet "format" "formatting"
@just _run-quiet "lint" "linting"
@just _run-quiet "test-flutter" "flutter tests"
@just _run-quiet "test-rust" "rust tests"
@echo "β
PRECOMMIT PASSED"
# Pre-commit checks with verbose output (shows all command output)
precommit-verbose:
just deps-flutter
just deps-rust
just l10n
just validate-locales-keys
just fix
just format
just lint
just test-flutter
just test-rust
@echo ""
@echo "ββββββββββββββββββββββββββββββββββββββββ"
@echo "β
ALL PRECOMMIT CHECKS PASSED"
@echo "ββββββββββββββββββββββββββββββββββββββββ"
# Pre-commit checks without auto-fixing (for releases)
precommit-check:
just deps-flutter
just deps-rust
just l10n-check
just validate-locales-keys
just check-rust-format
just check-dart-format
just lint
just test-flutter
just test-rust
@echo "β
All pre-commit checks passed!"
# ==============================================================================
# CODE GENERATION
# ==============================================================================
# Generate Rust bridge code
generate:
@echo "π Generating flutter_rust_bridge code..."
@flutter_rust_bridge_codegen generate > /dev/null 2>&1 || flutter_rust_bridge_codegen generate
# Clean and regenerate Rust bridge code
regenerate: clean-bridge generate
# Generate localizations from ARB files
l10n:
@echo "π Generating localizations..."
flutter gen-l10n
# Validate l10n files are in sync (fails if regeneration would change anything)
l10n-check:
@echo "π Checking l10n files are up-to-date..."
flutter gen-l10n
@if ! git diff --quiet lib/l10n/generated/; then \
echo "β Generated l10n files are out of sync. Run 'just l10n' and commit."; \
git diff --name-only lib/l10n/generated/; \
exit 1; \
fi
@echo "β
L10n files are up-to-date"
# ==============================================================================
# DEPENDENCIES
# ==============================================================================
# Install/update all dependencies
deps: deps-rust deps-flutter
# Install/update Rust dependencies
deps-rust:
@echo "π¦ Installing Rust dependencies..."
cd rust && cargo fetch
# Install/update Flutter dependencies
deps-flutter:
@echo "π¦ Installing Flutter dependencies..."
@flutter pub get > /dev/null 2>&1 || flutter pub get
@cd widgetbook && (flutter pub get > /dev/null 2>&1 || flutter pub get)
# ==============================================================================
# RUST OPERATIONS
# ==============================================================================
# Build Rust library for development (debug)
build-rust-debug:
@echo "π¨ Building Rust library (debug)..."
cd rust && cargo build
# Test Rust code
test-rust:
@echo "π§ͺ Testing Rust code..."
cd rust && cargo test
# Test Rust code with minimal output (for agents/CI)
test-rust-quiet:
@cd rust && cargo test -q
# Format Rust code
format-rust:
@echo "π
Formatting Rust code..."
cd rust && cargo fmt
# Check Rust code formatting (CI-style check)
check-rust-format:
@echo "π Checking Rust code formatting..."
cd rust && cargo fmt --check
# Lint Rust code
lint-rust:
@echo "π§Ή Linting Rust code..."
cd rust && cargo clippy --package rust_lib_whitenoise -- -D warnings
# Run Rust documentation
docs-rust:
@echo "π Generating Rust documentation..."
cd rust && cargo doc --open
# ==============================================================================
# FLUTTER OPERATIONS
# ==============================================================================
# Run Flutter analyzer
analyze:
@echo "π Running Flutter analyzer..."
flutter analyze --fatal-infos
@echo "π Running Flutter analyzer (widgetbook)..."
cd widgetbook && flutter analyze --fatal-infos
# Format Dart code
format-dart:
@echo "π
Formatting Dart code..."
dart format lib/ test/ widgetbook/lib/
# Check Dart code formatting (CI-style check)
check-dart-format:
@echo "π Checking Dart code formatting..."
dart format --set-exit-if-changed lib/ test/ widgetbook/lib/
# Test Flutter code
test-flutter:
@echo "π§ͺ Testing Flutter code..."
@if [ -d "test" ]; then \
flutter test --reporter=compact && echo "β
Flutter tests passed!" || (echo "β Flutter tests failed!" && exit 1); \
else \
echo "No test directory found. Create tests in test/ directory."; \
fi
# Test Flutter code with minimal output (for agents/CI)
test-flutter-quiet:
@if [ -d "test" ]; then \
flutter test --no-pub --reporter=failures-only; \
else \
echo "No test directory found."; \
fi
coverage min="99":
@echo "π§ͺ Running Flutter tests with coverage..."
flutter test --coverage && \
./scripts/check-coverage.sh --min {{min}}
coverage-report:
@echo "π§ͺ Generating coverage report..."
flutter test --coverage && \
./scripts/check-coverage.sh && \
genhtml coverage/lcov.info -o coverage/html
@echo "π Coverage report generated at coverage/html/index.html"
validate-locales-keys:
@echo "π Validating l10n keys..."
./scripts/validate-locales-keys.sh
# ==============================================================================
# CLEANING
# ==============================================================================
# Clean generated bridge files only
clean-bridge:
@echo "π§Ή Cleaning generated bridge files..."
rm -f rust/src/frb_generated.rs
rm -rf lib/src/rust/
# Clean Flutter build cache
clean-flutter:
@echo "π§Ή Cleaning Flutter build cache..."
flutter clean
# Clean Rust build cache
clean-rust:
@echo "π§Ή Cleaning Rust build cache..."
cd rust && cargo clean
# Clean everything (bridge files + flutter + rust)
clean-all: clean-bridge clean-flutter clean-rust
@echo "β¨ All clean!"
# ==============================================================================
# WIDGETBOOK
# ==============================================================================
deps-widgetbook:
@echo "π¦ Installing Widgetbook dependencies..."
@cd widgetbook && (flutter pub get > /dev/null 2>&1 || flutter pub get)
generate-widgetbook:
@echo "π Generating Widgetbook stories..."
cd widgetbook && dart run build_runner build --delete-conflicting-outputs
widgetbook-macos: deps-widgetbook generate-widgetbook
@echo "π Running Widgetbook on macOS..."
cd widgetbook && flutter run -d macos
widgetbook-linux: deps-widgetbook generate-widgetbook
@echo "π Running Widgetbook on Linux..."
cd widgetbook && flutter run -d linux
# ==============================================================================
# FORMATTING & LINTING
# ==============================================================================
# Format all code (Rust + Dart)
format: format-rust format-dart
# Lint all code (Rust + Dart)
lint: lint-rust analyze
# Fix common issues
fix:
@echo "π§ Fixing common issues..."
cd rust && cargo fix --allow-dirty
dart fix --apply
# ==============================================================================
# BUILDING - ANDROID
# ==============================================================================
build-android:
./scripts/build_android.sh
build-android-quiet:
@./scripts/build_android.sh > /dev/null 2>&1 && echo "β
Android build complete" || { echo "β Android build failed"; false; }
# Build per-ABI split APKs (separate .apk per architecture)
build-split-apk flavor="production":
./scripts/build_android.sh && flutter build apk --flavor {{flavor}} --split-per-abi
# Build an Android App Bundle (per-ABI splitting handled by Play Store)
build-aab flavor="production":
./scripts/build_android.sh && flutter build appbundle --flavor {{flavor}}
when-apk: (build-split-apk "staging")
# Build versioned release artifacts for all platforms (APKs + IPA) into build/releases/
# Produces split APKs with .sha256 sidecar files, an IPA (macOS only), and build_info.txt
build-release:
./scripts/build_release.sh
# Android-only release artifacts
build-release-android:
./scripts/build_release.sh --android
# iOS-only release artifacts (macOS only)
build-release-ios:
./scripts/build_release.sh --ios
# ==============================================================================
# BUILDING - iOS
# ==============================================================================
# Build Rust native libraries for iOS (device + simulator)
build-ios:
./scripts/build_ios.sh
# Build Rust native libraries for iOS (quiet, for agents/CI)
build-ios-quiet:
@./scripts/build_ios.sh > /dev/null 2>&1 && echo "β
iOS build complete" || { echo "β iOS build failed"; false; }
# Build a production IPA for App Store Connect submission
build-production-ipa:
./scripts/build_ios.sh && flutter build ipa --flavor production --export-method app-store
# Build a staging IPA for App Store Connect submission
build-staging-ipa:
./scripts/build_ios.sh && flutter build ipa --flavor staging --export-method app-store
# Build a staging IPA for local device installation (development signing)
build-staging-ipa-dev:
./scripts/build_ios.sh && flutter build ipa --flavor staging --export-method development
# ==============================================================================
# RUN
# ==============================================================================
# Run the app on a connected device (staging flavor by default)
run flavor="staging":
flutter run --flavor {{flavor}}
# Run the app on a connected device (production flavor)
run-production:
flutter run --flavor production
# Build Rust libs and install on connected iOS device
# Usage: just install-ios <device> [flavor] [extra flags]
# Example: just install-ios "JG 16e Test"
# Example: just install-ios "JG 16e Test" production --release
install-ios device flavor="staging" *FLAGS="":
./scripts/build_ios.sh && flutter run --flavor {{flavor}} -d "{{device}}" {{FLAGS}}
# ==============================================================================
# HELPER RECIPES
# ==============================================================================
# Run a recipe quietly, showing only name and pass/fail status (internal use)
[private]
_run-quiet recipe label:
#!/usr/bin/env bash
TMPFILE=$(mktemp)
trap 'rm -f "$TMPFILE"' EXIT
printf "%-20s" "{{label}}..."
if just {{recipe}} > "$TMPFILE" 2>&1; then
echo "β"
else
echo "β"
echo ""
cat "$TMPFILE"
exit 1
fi