- shared/ = portable Android-origin sources vendored from deferred/desktop-server (app/build.gradle.kts srcDir repointed; PlaybackController.kt excluded as Android-only) - backend/ = bundled-lite engine (SQLite + inline queue); .venv symlinked from the old checkout, PYTHONPATH pins THIS backend's code over any editable install - repoRoot() resolves this project dir (env SHONAR_REPO still wins); desktop-dev.sh watches shared/ + backend/ - Verified: :app:compileKotlin + :app:test green (23 tests); engine boots on :8010, self-migrates, /healthz ok
60 lines
1.8 KiB
Bash
Executable file
60 lines
1.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# SHONAR desktop dev loop: runs the app and auto-restarts it when any
|
|
# Kotlin/Gradle source changes (inotifywait). Engine runs in dev mode
|
|
# (SHONAR_DEV=1 -> uvicorn --reload), so backend edits apply live too.
|
|
#
|
|
# Stop with Ctrl-C (or pkill -f desktop-dev.sh).
|
|
set -uo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
export SHONAR_DEV=1
|
|
export DISPLAY="${DISPLAY:-:0}"
|
|
|
|
FLAG="$(pwd)/.dev-restart-flag"
|
|
|
|
# Watch targets resolved to absolute paths, non-existent dirs skipped at
|
|
# start but retried each cycle (inotifywait -r tolerates a dir appearing).
|
|
watch_targets() {
|
|
local t=()
|
|
for d in "$PWD/app/src/main/kotlin" \
|
|
"$PWD/shared/com/shonar" \
|
|
"$PWD/backend/shonar"; do
|
|
[ -d "$d" ] && t+=("$d")
|
|
done
|
|
printf '%s\n' "${t[@]}"
|
|
}
|
|
|
|
pkill -f "com.shonar.desktop.MainKt" 2>/dev/null || true
|
|
rm -f "$FLAG"
|
|
sleep 1
|
|
|
|
(
|
|
while true; do
|
|
mapfile -t TARGETS < <(watch_targets)
|
|
[ ${#TARGETS[@]} -eq 0 ] && { sleep 5; continue; }
|
|
if inotifywait -qq -e close_write,move --include '\.kt$|\.kts$' \
|
|
-r "${TARGETS[@]}"; then
|
|
echo "[dev] source change -> restarting app…"
|
|
touch "$FLAG"
|
|
pkill -f "com.shonar.desktop.MainKt" 2>/dev/null || true
|
|
sleep 2 # debounce bursts (editor writes can fire several events)
|
|
else
|
|
sleep 5 # targets vanished; retry with a fresh list
|
|
fi
|
|
done
|
|
) &
|
|
WATCHER=$!
|
|
trap 'kill $WATCHER 2>/dev/null || true; rm -f "$FLAG"' EXIT
|
|
|
|
while true; do
|
|
rm -f "$FLAG"
|
|
./gradlew run --offline
|
|
if [ -f "$FLAG" ]; then
|
|
continue # killed by a source edit: rebuild now
|
|
fi
|
|
rm -f "$FLAG"
|
|
# App closed cleanly or build failed — wait for the next edit.
|
|
mapfile -t TARGETS < <(watch_targets)
|
|
[ ${#TARGETS[@]} -eq 0 ] && { sleep 5; continue; }
|
|
inotifywait -qq -e close_write,move --include '\.kt$|\.kts$' -r "${TARGETS[@]}" || sleep 5
|
|
done
|