@@ -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 || true
157+ fi
158+
125159# Run clippy on the desktop Tauri Rust crate
126160desktop-tauri-clippy : _ensure-sidecar-stubs
127161 cargo clippy --manifest-path {{ desktop_tauri_manifest}} --all-targets -- -D warnings
@@ -153,15 +187,15 @@ desktop-release-build target="aarch64-apple-darwin":
153187desktop-ci : desktop-check desktop-test desktop-tauri-fmt-check desktop-build desktop-tauri-check desktop-tauri-test
154188
155189# Seed deterministic channel data for desktop Playwright tests
156- desktop-e2e-seed :
190+ desktop-e2e-seed : _ensure-migrations
157191 ./ scripts/ setup-desktop-test-data.sh
158192
159193# Run desktop browser smoke tests
160194desktop-e2e-smoke :
161195 cd {{ desktop_dir}} && pnpm test:e2e:smoke
162196
163197# Run desktop relay-backed e2e tests
164- desktop-e2e-integration :
198+ desktop-e2e-integration : _ensure-migrations
165199 cd {{ desktop_dir}} && pnpm test:e2e:integration
166200
167201# Run all checks suitable for CI / pre-push (no infra needed)
@@ -188,20 +222,20 @@ 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
196- relay-web :
230+ relay-web : _ensure-migrations
197231 #!/usr/bin/env bash
198232 set -euo pipefail
199233 [[ -d node_modules ]] || pnpm install
200234 pnpm -C web build
201235 SPROUT_WEB_DIR=./web/dist cargo run -p sprout-relay
202236
203237# Start the relay server in release mode
204- relay-release :
238+ relay-release : _ensure-migrations
205239 cargo run -p sprout-relay --release
206240
207241# Start sprout-proxy (dev mode)
@@ -248,10 +282,6 @@ desktop-dev:
248282 echo " Starting frontend dev server on Vite port ${SPROUT_VITE_PORT} , relay ${SPROUT_RELAY_URL} "
249283 pnpm exec vite --port " ${SPROUT_VITE_PORT} " --strictPort
250284
251- # Run the desktop Tauri app (alias for dev)
252- desktop-app * ARGS :
253- just dev {{ ARGS}}
254-
255285# ─── Web ─────────────────────────────────────────────────────────────────────
256286
257287# Run the web frontend dev server (port derived from worktree to avoid collisions)
@@ -266,14 +296,6 @@ web:
266296 cd {{web_dir}}
267297 pnpm exec vite --port " ${VITE_PORT} " --strictPort
268298
269- # Install web JS dependencies (pnpm workspace — installs all packages from root)
270- web-install :
271- pnpm install
272-
273- # Install web JS dependencies reproducibly for CI (pnpm workspace)
274- web-install-ci :
275- pnpm install --frozen-lockfile
276-
277299# Run web lint and format checks
278300web-check :
279301 cd {{ web_dir}} && pnpm check
@@ -318,10 +340,42 @@ mobile-check:
318340mobile-test :
319341 unset GIT_DIR GIT_WORK_TREE; cd {{ mobile_dir}} && flutter test
320342
343+ # Run the mobile app on iOS simulator (starts infra + relay automatically)
344+ mobile-dev :
345+ #!/usr/bin/env bash
346+ set -euo pipefail
347+ just _ensure-migrations
348+ # Start relay in background if not already running
349+ RELAY_PID=" "
350+ if ! lsof -i :3000 -sTCP:LISTEN -t & > /dev/null; then
351+ echo " Starting relay in background (log: /tmp/sprout-relay.log)..."
352+ cargo run -p sprout-relay & > /tmp/sprout-relay.log &
353+ RELAY_PID=$!
354+ trap ' if [[ -n "$RELAY_PID" ]]; then kill "$RELAY_PID" 2>/dev/null || true; fi' EXIT
355+ echo -n " Waiting for relay"
356+ for _ in $( seq 1 30) ; do
357+ lsof -i :3000 -sTCP:LISTEN -t & > /dev/null && break
358+ echo -n " ."
359+ sleep 3
360+ done
361+ echo " ready"
362+ else
363+ echo " Relay already running on :3000"
364+ fi
365+ # Open iOS simulator if not already running
366+ if ! pgrep -x Simulator & > /dev/null; then
367+ open -a Simulator
368+ sleep 3
369+ fi
370+ # Run Flutter
371+ cd {{mobile_dir}}
372+ unset GIT_DIR GIT_WORK_TREE
373+ flutter run
374+
321375# ─── Database ─────────────────────────────────────────────────────────────────
322376
323377# Apply schema migrations via pgschema
324- migrate :
378+ migrate : _ensure-services
325379 ./ bin/ pgschema apply --file schema/ schema.sql --auto-approve
326380
327381# ─── Utilities ────────────────────────────────────────────────────────────────
0 commit comments