Skip to content

Commit d0d01e9

Browse files
committed
feat: add shared infra recipes and just mobile-dev
`just relay` previously assumed Docker services were already running, requiring manual `docker compose up` first. The desktop and mobile workflows had the same gap — multiple manual steps across terminals. Adds `_ensure-services` and `_ensure-migrations` private recipes that idempotently start Docker services and wait for health. Wires `relay` to depend on `_ensure-migrations` so it works from a cold start. Adds `mobile-dev` that handles the full stack: Docker, relay (background), iOS simulator, and `flutter run` — all in one command.
1 parent f34a21d commit d0d01e9

1 file changed

Lines changed: 59 additions & 2 deletions

File tree

justfile

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,40 @@ _ensure-sidecar-stubs:
122122
touch "desktop/src-tauri/binaries/${bin}-${TARGET}"
123123
done
124124
125+
# Ensure Docker dev services (Postgres, Redis, etc.) are running and healthy
126+
_ensure-services:
127+
#!/usr/bin/env bash
128+
set -euo pipefail
129+
pg=$(docker inspect --format '{{"{{"}}.State.Health.Status{{"}}"}}' sprout-postgres 2>/dev/null || echo "not_found")
130+
redis=$(docker inspect --format '{{"{{"}}.State.Health.Status{{"}}"}}' sprout-redis 2>/dev/null || echo "not_found")
131+
if [[ "$pg" == "healthy" && "$redis" == "healthy" ]]; then
132+
echo "Services already healthy"
133+
exit 0
134+
fi
135+
echo "Starting services..."
136+
docker compose up -d || true
137+
echo -n "Waiting for services"
138+
for i in $(seq 1 40); do
139+
pg=$(docker inspect --format '{{"{{"}}.State.Health.Status{{"}}"}}' sprout-postgres 2>/dev/null || echo "not_found")
140+
redis=$(docker inspect --format '{{"{{"}}.State.Health.Status{{"}}"}}' sprout-redis 2>/dev/null || echo "not_found")
141+
if [[ "$pg" == "healthy" && "$redis" == "healthy" ]]; then
142+
echo " ready"
143+
exit 0
144+
fi
145+
echo -n "."
146+
sleep 3
147+
done
148+
echo " timed out"
149+
exit 1
150+
151+
# Apply database migrations if pgschema is available
152+
_ensure-migrations: _ensure-services
153+
#!/usr/bin/env bash
154+
set -euo pipefail
155+
if [[ -x bin/pgschema && -f schema/schema.sql ]]; then
156+
bin/pgschema apply --file schema/schema.sql --auto-approve 2>/dev/null || true
157+
fi
158+
125159
# Run clippy on the desktop Tauri Rust crate
126160
desktop-tauri-clippy: _ensure-sidecar-stubs
127161
cargo clippy --manifest-path {{desktop_tauri_manifest}} --all-targets -- -D warnings
@@ -188,8 +222,8 @@ test-integration:
188222

189223
# ─── Run ──────────────────────────────────────────────────────────────────────
190224

191-
# Start the relay server
192-
relay:
225+
# Start the relay server (auto-starts Docker services if needed)
226+
relay: _ensure-migrations
193227
cargo run -p sprout-relay
194228

195229
# Start the relay with the built web UI served from it
@@ -318,6 +352,29 @@ mobile-check:
318352
mobile-test:
319353
unset GIT_DIR GIT_WORK_TREE; cd {{mobile_dir}} && flutter test
320354

355+
# Run the mobile app on iOS simulator (starts infra + relay automatically)
356+
mobile-dev:
357+
#!/usr/bin/env bash
358+
set -euo pipefail
359+
just _ensure-migrations
360+
# Start relay in background if not already running
361+
if ! lsof -i :3000 -sTCP:LISTEN -t &>/dev/null; then
362+
echo "Starting relay in background (log: /tmp/sprout-relay.log)..."
363+
cargo run -p sprout-relay &>/tmp/sprout-relay.log &
364+
sleep 3
365+
else
366+
echo "Relay already running on :3000"
367+
fi
368+
# Open iOS simulator if not already running
369+
if ! pgrep -x Simulator &>/dev/null; then
370+
open -a Simulator
371+
sleep 3
372+
fi
373+
# Run Flutter
374+
cd {{mobile_dir}}
375+
unset GIT_DIR GIT_WORK_TREE
376+
flutter run
377+
321378
# ─── Database ─────────────────────────────────────────────────────────────────
322379

323380
# Apply schema migrations via pgschema

0 commit comments

Comments
 (0)