-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
415 lines (343 loc) · 13.6 KB
/
Justfile
File metadata and controls
415 lines (343 loc) · 13.6 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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# React Native Template - Development Commands
# Usage: just <recipe>
# Android SDK path (for Waydroid compatibility)
android_sdk := env_var_or_default("ANDROID_HOME", home_directory() / "Android/Sdk")
# App package name (change this for your project)
APP_PKG := env_var_or_default("APP_PKG", "com.template.app")
# Set environment
set export
ANDROID_HOME := android_sdk
PATH := android_sdk / "platform-tools:" + env_var("PATH")
# Default - show available commands
default:
@just --list
# ─────────────────────────────────────────────────────────────
# Metro Bundler
# ─────────────────────────────────────────────────────────────
# Start Metro dev server (foreground)
dev:
npx expo start
# Start Metro with cache cleared
dev-clean:
npx expo start --clear
# Start Metro in tunnel mode (for remote devices)
dev-tunnel:
npx expo start --tunnel
# Start Metro in background
metro-bg:
@echo "Starting Metro bundler in background..."
npx expo start --port 8081 > /tmp/metro.log 2>&1 &
@echo "Metro logs: /tmp/metro.log"
@sleep 5
@curl -s http://localhost:8081/status > /dev/null && echo "✓ Metro started!" || echo "⏳ Metro may still be starting..."
# Stop Metro bundler
metro-stop:
@echo "Stopping Metro bundler..."
-@pkill -f "expo start" 2>/dev/null
@echo "Metro stopped."
# View Metro logs (live)
metro-logs:
@tail -f /tmp/metro.log
# ─────────────────────────────────────────────────────────────
# Native Builds
# ─────────────────────────────────────────────────────────────
# Build and run on Android
run-android:
npx expo run:android
# Build and run on iOS simulator
run-ios:
npx expo run:ios
# Generate native projects
prebuild:
npx expo prebuild
# Regenerate native projects (clean)
prebuild-clean:
npx expo prebuild --clean
# ─────────────────────────────────────────────────────────────
# Code Quality
# ─────────────────────────────────────────────────────────────
# Run all checks (lint + format + typecheck + test)
check: lint format-check typecheck test
# Run ESLint
lint:
npm run lint
# Run ESLint with auto-fix
lint-fix:
npm run lint:fix
# Check formatting with Prettier
format-check:
npm run format:check
# Format code with Prettier
format:
npm run format
# Run TypeScript type check
typecheck:
npm run typecheck
# Fix all auto-fixable issues
fix: lint-fix format
# ─────────────────────────────────────────────────────────────
# Testing
# ─────────────────────────────────────────────────────────────
# Run all tests
test:
npm test
# Run tests in watch mode
test-watch:
npm run test:watch
# Run tests with coverage
test-coverage:
npm run test:coverage
# Run CI checks
ci:
npm run ci
# ─────────────────────────────────────────────────────────────
# Database (Docker + Drizzle)
# ─────────────────────────────────────────────────────────────
# Start PostgreSQL database
db-up:
docker compose up -d postgres
# Stop PostgreSQL database
db-down:
docker compose down
# View database logs
db-logs:
docker compose logs -f postgres
# Connect to database with psql
db-shell:
docker compose exec postgres psql -U postgres -d template_db
# Reset database (WARNING: destroys all data)
db-reset:
docker compose down -v && docker compose up -d postgres
# Generate migration from schema changes
db-generate:
npm run db:generate
# Apply pending migrations
db-migrate:
npm run db:migrate
# Push schema directly (dev only)
db-push:
npm run db:push
# Open Drizzle Studio
db-studio:
npm run db:studio
# ─────────────────────────────────────────────────────────────
# EAS Cloud Builds
# ─────────────────────────────────────────────────────────────
# Development build - Android
eas-dev-android:
eas build --profile development --platform android
# Development build - iOS
eas-dev-ios:
eas build --profile development --platform ios
# Development build - All platforms
eas-dev:
eas build --profile development --platform all
# Preview build - Android
eas-preview-android:
eas build --profile preview --platform android
# Preview build - iOS
eas-preview-ios:
eas build --profile preview --platform ios
# Production build - Android
eas-prod-android:
eas build --profile production --platform android
# Production build - iOS
eas-prod-ios:
eas build --profile production --platform ios
# Production build - All platforms
eas-prod:
eas build --profile production --platform all
# ─────────────────────────────────────────────────────────────
# Dependencies & Cleanup
# ─────────────────────────────────────────────────────────────
# Install dependencies
install:
yarn install
# Clean install (remove node_modules first)
install-clean:
rm -rf node_modules && yarn install
# Clean build caches
clean:
rm -rf node_modules/.cache
rm -rf android/.gradle 2>/dev/null || true
rm -rf android/app/build 2>/dev/null || true
rm -rf .expo 2>/dev/null || true
@echo "Caches cleared."
# Show project info
info:
npx expo-env-info
# ─────────────────────────────────────────────────────────────
# Waydroid (Linux Android Emulator)
# ─────────────────────────────────────────────────────────────
# Full Waydroid setup (start + connect + ports)
waydroid-setup: waydroid-start
@sleep 3
@just adb-connect
@sleep 1
@just adb-ports
# Start Waydroid container session
waydroid-start:
#!/usr/bin/env bash
echo "Starting Waydroid session..."
if waydroid status 2>/dev/null | grep -q "RUNNING"; then
echo "Waydroid already running"
else
waydroid session start &
sleep 5
if waydroid status 2>/dev/null | grep -q "RUNNING"; then
echo "✓ Waydroid started"
else
echo "⏳ Waydroid still starting..."
sleep 5
fi
fi
# Stop Waydroid session
waydroid-stop:
@echo "Stopping Waydroid session..."
waydroid session stop
# Check Waydroid status
waydroid-status:
@waydroid status
# ─────────────────────────────────────────────────────────────
# ADB / Device Connection
# ─────────────────────────────────────────────────────────────
# Connect ADB to Waydroid
adb-connect:
#!/usr/bin/env bash
echo "Connecting ADB to Waydroid..."
WAYDROID_IP=$(waydroid status 2>/dev/null | grep -oP 'IP address:\s*\K[\d.]+' || echo "192.168.240.112")
if [ -z "$WAYDROID_IP" ] || [ "$WAYDROID_IP" = "192.168.240.112" ]; then
if ! waydroid status &>/dev/null; then
echo "Warning: Waydroid may not be running. Start it first with: just waydroid-start"
fi
WAYDROID_IP="192.168.240.112"
fi
adb connect "$WAYDROID_IP:5555"
echo "Connected to $WAYDROID_IP:5555"
# Set up ADB reverse port forwarding
adb-ports:
#!/usr/bin/env bash
echo "Setting up ADB reverse port forwarding..."
DEVICE=$(adb devices | grep -oP '[\d.]+:5555' | head -1)
if [ -z "$DEVICE" ]; then
echo "No device connected. Run: just adb-connect"
exit 1
fi
adb -s "$DEVICE" reverse tcp:8081 tcp:8081
echo " ✓ Port 8081 (Metro bundler)"
adb -s "$DEVICE" reverse tcp:3000 tcp:3000
echo " ✓ Port 3000 (API server)"
echo ""
echo "Port forwarding complete!"
# Restart ADB server (fixes connection issues)
adb-restart:
@echo "Restarting ADB server..."
adb kill-server
adb start-server
@echo "ADB restarted. Run 'just adb-connect' to reconnect."
# List connected devices
adb-devices:
adb devices
# ─────────────────────────────────────────────────────────────
# App Control (on device)
# ─────────────────────────────────────────────────────────────
# Launch app on device
app-launch:
#!/usr/bin/env bash
DEVICE=$(adb devices | grep -oP '[\d.]+:5555' | head -1)
if [ -z "$DEVICE" ]; then
echo "No device connected. Run: just adb-connect"
exit 1
fi
echo "Launching app..."
adb -s "$DEVICE" shell am start -n {{APP_PKG}}/.MainActivity
# Restart app (force stop + launch)
app-restart:
#!/usr/bin/env bash
DEVICE=$(adb devices | grep -oP '[\d.]+:5555' | head -1)
if [ -z "$DEVICE" ]; then
echo "No device connected. Run: just adb-connect"
exit 1
fi
echo "Restarting app..."
adb -s "$DEVICE" shell am force-stop {{APP_PKG}}
sleep 1
adb -s "$DEVICE" shell am start -n {{APP_PKG}}/.MainActivity
echo "App restarted!"
# Clear app data (fixes state/login issues)
app-clear:
#!/usr/bin/env bash
DEVICE=$(adb devices | grep -oP '[\d.]+:5555' | head -1)
if [ -z "$DEVICE" ]; then
echo "No device connected. Run: just adb-connect"
exit 1
fi
echo "Clearing app data..."
adb -s "$DEVICE" shell pm clear {{APP_PKG}}
echo "App data cleared. Run 'just app-launch' to restart."
# Install APK from path
app-install APK_PATH:
#!/usr/bin/env bash
DEVICE=$(adb devices | grep -oP '[\d.]+:5555' | head -1)
if [ -z "$DEVICE" ]; then
echo "No device connected. Run: just adb-connect"
exit 1
fi
echo "Installing APK..."
adb -s "$DEVICE" install "{{APK_PATH}}"
# Take a screenshot from device
app-screenshot:
#!/usr/bin/env bash
DEVICE=$(adb devices | grep -oP '[\d.]+:5555' | head -1)
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
FILEPATH="/tmp/screenshot_$TIMESTAMP.png"
adb -s "$DEVICE" exec-out screencap -p > "$FILEPATH"
echo "Screenshot saved to $FILEPATH"
# ─────────────────────────────────────────────────────────────
# Status & Troubleshooting
# ─────────────────────────────────────────────────────────────
# Check all service statuses
status:
#!/usr/bin/env bash
echo "=== Service Status ==="
echo ""
# Metro
if curl -s http://localhost:8081/status > /dev/null 2>&1; then
echo "✓ Metro (8081): Running"
else
echo "✗ Metro (8081): Not running"
fi
# Waydroid
if waydroid status 2>/dev/null | grep -q "RUNNING"; then
echo "✓ Waydroid: Running"
else
echo "✗ Waydroid: Not running"
fi
# ADB
DEVICE=$(adb devices 2>/dev/null | grep -oP '[\d.]+:5555' | head -1)
if [ -n "$DEVICE" ]; then
echo "✓ ADB: Connected ($DEVICE)"
if adb -s "$DEVICE" reverse --list 2>/dev/null | grep -q "8081"; then
echo "✓ Port Forwarding: Configured"
else
echo "⚠ Port Forwarding: Not configured (run: just adb-ports)"
fi
else
echo "✗ ADB: Not connected"
fi
echo ""
# Kill ALL processes on dev ports (nuclear option)
kill-ports:
#!/usr/bin/env bash
echo "Killing all processes on development ports..."
pkill -f "expo start" 2>/dev/null || true
pkill -f "metro" 2>/dev/null || true
fuser -k 8081/tcp 2>/dev/null || true
fuser -k 3000/tcp 2>/dev/null || true
sleep 1
echo ""
echo "Port status:"
echo " 8081 (Metro): $(lsof -ti:8081 >/dev/null 2>&1 && echo 'IN USE' || echo 'free')"
echo " 3000 (API): $(lsof -ti:3000 >/dev/null 2>&1 && echo 'IN USE' || echo 'free')"
echo ""
echo "Ready to restart services."