-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathjustfile
More file actions
399 lines (328 loc) · 10.5 KB
/
justfile
File metadata and controls
399 lines (328 loc) · 10.5 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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# List available recipes
[default]
list:
@just --list
# ------------------------------------------------------------------------------
# utilities
# ------------------------------------------------------------------------------
# Run an xtask command
[group('utils')]
xtask *args:
cd rust && test -f target/debug/xtask || cargo build --package xtask -q && ./target/debug/xtask {{args}}
# Sign a PSBT and output all formats (base64, hex, binary, bbqr-gif, ur-gif)
# Requires MNEMONIC env var (set in .envrc or pass directly)
[group('utils')]
[script('bash')]
sign-psbt psbt:
set -e
if [ -z "$MNEMONIC" ]; then
echo "Error: MNEMONIC env var not set. Set it in .envrc or export it."
exit 1
fi
OUTPUT_DIR="$HOME/Downloads/signed-psbt-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$OUTPUT_DIR"
echo "Signing PSBT and outputting to: $OUTPUT_DIR"
cd rust
cargo xtask util sign-psbt --psbt "{{psbt}}" -f base64 -O "$OUTPUT_DIR/signed.base64.txt"
cargo xtask util sign-psbt --psbt "{{psbt}}" -f hex -O "$OUTPUT_DIR/signed.hex.txt"
cargo xtask util sign-psbt --psbt "{{psbt}}" -f binary -O "$OUTPUT_DIR/signed.psbt"
cargo xtask util sign-psbt --psbt "{{psbt}}" -f bbqr-gif -O "$OUTPUT_DIR/signed-bbqr.gif"
cargo xtask util sign-psbt --psbt "{{psbt}}" -f ur-gif -O "$OUTPUT_DIR/signed-ur.gif"
echo ""
echo "All formats saved to: $OUTPUT_DIR"
ls -la "$OUTPUT_DIR"
open "$OUTPUT_DIR"
[private]
alias sp := sign-psbt
# ------------------------------------------------------------------------------
# ci
# ------------------------------------------------------------------------------
# Full build and verification for all platforms
[group('ci')]
full:
just bidd && just ba && just ci && just compile
[private]
alias f := full
# Run all CI checks
[group('ci')]
[script('bash')]
[working-directory: 'rust']
ci:
set -e
just fmt
cargo fmt --check
just lint
just compile
just test
# ------------------------------------------------------------------------------
# build
# ------------------------------------------------------------------------------
# Build Android debug APK
[group('build')]
build-android:
just xtask build-android debug && just say "done android"
[private]
alias ba := build-android
# Build Android release APK
[group('build')]
build-android-release:
just xtask build-android release-speed && just say "done android release"
[private]
alias bar := build-android-release
# Build signed AAB for Google Play, copy to Downloads
[group('build')]
bundle-android: build-android-release
just xtask bundle-android && just say "done android bundle"
[private]
alias bua := bundle-android
# Build iOS debug for simulator
[group('build')]
build-ios profile="debug" *flags="":
just xtask build-ios {{profile}} {{flags}} && just say "done ios"
[private]
alias bi := build-ios
# Build iOS release for device
[group('build')]
build-ios-release:
just xtask build-ios release-speed --device && just say "done ios release"
[private]
alias bir := build-ios-release
# Build iOS debug for device
[group('build')]
build-ios-debug-device:
just xtask build-ios debug --device && just say "done ios device"
[private]
alias bidd := build-ios-debug-device
[private]
alias gen-swift := build-ios
# Compile both iOS and Android
[group('build')]
@compile:
just compile-ios && just compile-android
# Compile iOS for simulator
[group('build')]
[working-directory: 'ios']
compile-ios:
xcodebuild -scheme Cove -sdk iphonesimulator -arch arm64 build && just notf "done compile ios"
# Compile Android debug
[group('build')]
[working-directory: 'android']
compile-android:
./gradlew assembleDebug && just notf "done compile android"
# ------------------------------------------------------------------------------
# test
# ------------------------------------------------------------------------------
# Run all tests
[group('test')]
[working-directory: 'rust']
test test="" flags="":
cargo nextest run {{test}} --workspace {{flags}}
# Run tests with cargo test
[group('test')]
[working-directory: 'rust']
ctest test="" flags="":
cargo test {{test}} --workspace -- {{flags}}
# Run tests with bacon
[group('test')]
[working-directory: 'rust']
btest test="":
bacon nextest -- {{test}} --workspace
# Watch and re-run tests on file changes
[group('test')]
watch-test test="" flags="":
watchexec --exts rs just test {{test}} {{flags}}
[private]
alias wt := watch-test
[private]
alias wtest := watch-test
# ------------------------------------------------------------------------------
# lint
# ------------------------------------------------------------------------------
# Lint all platforms
[group('lint')]
@lint *flags="":
just lint-rust {{flags}} && just lint-swift {{flags}} && just lint-android {{flags}}
# Lint Rust code
[group('lint')]
[working-directory: 'rust']
lint-rust *flags="":
cargo clippy --all-targets --all-features -- -D warnings {{flags}}
# Lint Android code
[group('lint')]
[working-directory: 'android']
lint-android *flags="":
./gradlew ktlintCheck {{flags}}
# Lint Swift code
[group('lint')]
lint-swift *flags="":
swiftformat --lint ios --swiftversion 6 {{flags}}
# Run clippy
[group('lint')]
[working-directory: 'rust']
clippy *flags="":
cargo clippy {{flags}}
# Run pedantic clippy checks (excluding must_use, truncation, single_match, if_not_else, needless_continue, option_if_let_else)
[group('lint')]
[working-directory: 'rust']
pedantic *flags="":
cargo clippy -- -D clippy::pedantic -D clippy::nursery \
-A clippy::must_use_candidate \
-A clippy::cast_possible_truncation \
-A clippy::single_match \
-A clippy::if_not_else \
-A clippy::needless_continue \
-A clippy::option_if_let_else \
-A clippy::unused_self \
-A clippy::unused_async \
-A clippy::significant_drop_tightening \
-A clippy::missing_const_for_fn \
-A clippy::needless_pass_by_value \
{{flags}}
# Run full pedantic clippy checks without any allows
[group('lint')]
[working-directory: 'rust']
pedantic-all *flags="":
cargo clippy -- -D clippy::pedantic -D clippy::nursery {{flags}}
# ------------------------------------------------------------------------------
# format
# ------------------------------------------------------------------------------
# Format all platforms
[group('format')]
@fmt:
just fmt-rust && just fmt-swift && just fmt-android
# Format Rust code
[group('format'), private]
[working-directory: 'rust']
fmt-rust:
cargo fmt --all
# Format Swift code
[private]
alias fmt-ios := fmt-swift
alias fi := fmt-swift
[group('format'), private]
fmt-swift:
swiftformat ios --swiftversion 6
# Format Android code
[group('format'), private]
[working-directory: 'android']
fmt-android:
./gradlew ktlintFormat
# ------------------------------------------------------------------------------
# dev
# ------------------------------------------------------------------------------
# Run bacon clippy watcher
[group('dev')]
[working-directory: 'rust']
bacon:
bacon clippy
# Run bacon check watcher
[group('dev')]
[working-directory: 'rust']
bcheck:
bacon check
# Run cargo check
[group('dev')]
[working-directory: 'rust']
check *flags="--workspace --all-targets --all-features":
cargo check {{flags}}
# Watch and rebuild iOS on file changes
[group('dev')]
watch-build profile="debug" *flags="":
watchexec --exts rs just build-ios {{profile}} {{flags}}
[private]
alias wb := watch-build
# Apply cargo fix
[group('dev')]
[working-directory: 'rust']
fix *flags="":
cargo fix --workspace {{flags}}
# ------------------------------------------------------------------------------
# release
# ------------------------------------------------------------------------------
# Bump version (type: major, minor, patch, build)
[group('release')]
bump type targets="":
just xtask bump-version {{type}} {{ if targets != "" { "--targets " + targets } else { "" } }}
# ------------------------------------------------------------------------------
# xcode
# ------------------------------------------------------------------------------
# Clean Xcode caches
[group('xcode')]
[working-directory: 'ios']
xcode-clean:
rm -rf ~/Library/Caches/org.swift.swiftpm
xcodebuild clean
[private]
alias xc := xcode-clean
# Reset Xcode completely
[group('xcode')]
[confirm("This will kill Xcode and delete caches. Continue?")]
[script('bash')]
[working-directory: 'ios']
xcode-reset:
killAll Xcode || true
rm -rf Cove.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
xcrun simctl --set previews delete all
rm -rf ~/Library/Caches/org.swift.swiftpm
rm -rf ~/Library/Developer/Xcode/DerivedData
xcodebuild clean
xcode-build-server config -project *.xcodeproj -scheme Cove
open Cove.xcodeproj
[private]
alias xr := xcode-reset
# ------------------------------------------------------------------------------
# util
# ------------------------------------------------------------------------------
# Clean all build artifacts
[group('util')]
[confirm("Delete all build artifacts?")]
[script('bash')]
[working-directory: 'rust']
clean:
cargo clean
rm -rf ../ios/Cove.xcframework
rm -rf ../ios/Cove
rm -rf target
# Update cargo dependencies
[group('util')]
[working-directory: 'rust']
update pkg="":
cargo update {{pkg}}
# Run Android app
[group('util')]
run-android profile="debug":
just xtask run-android {{profile}} && just notf "done run android"
[private]
alias ra := run-android
# Build and clean install Android (rebuilds native libs, clears Gradle cache)
[group('util')]
[working-directory: 'android']
install-android-clean:
just ba && ./gradlew --stop && ./gradlew clean installDebug && just notf "done install android clean"
[private]
alias iac := install-android-clean
# Run iOS app
[group('util')]
run-ios:
just xtask run-ios && just notf "done run ios"
# Show logcat for cove process
[group('util')]
logcat:
#!/usr/bin/env bash
pid=$(adb shell pidof org.bitcoinppl.cove.dev | tr -d '[:space:]')
if [ -z "$pid" ]; then
echo "error: org.bitcoinppl.cove.dev is not running" >&2
exit 1
fi
adb logcat --pid="$pid"
# ------------------------------------------------------------------------------
# helpers
# ------------------------------------------------------------------------------
# text-to-speech helper
[private]
say *args:
@say {{args}} 2>/dev/null || echo {{args}} || true
@just notf {{args}} || true
[private]
notf *args:
@command -v notf >/dev/null && notf "{{args}}" -t "Cove" -T bell,macos || true