'ws' conflated storage mode with transport protocol (WebSocket). Renamed for clarity: the adapter talks the self-hosted server (src/storage/server.js), which happens to use WebSocket for realtime — but the name should describe what it connects to, not how. Renames: - src/storage/ws.js -> server.js - createWsStorage() -> createServerStorage() - storage mode 'ws' -> 'server' - REACT_APP_BACKEND_WS -> REACT_APP_BACKEND_REALTIME_URL - factory param wsUrl -> realtimeUrl - server/tests/ws-*.test.js -> server-*.test.js Kept literal: 'ws' npm package, ws:// protocol URLs, /ws WebSocket endpoint. Transport is accurate there; only storage-naming changed. Updated all docs (DEVELOPMENT, TESTING, REWORK_PLAN, GLOSSARY, TODO), scripts (dev-start.sh, replay-combat.js), factory + ESM tests. 204 tests green.
55 lines
1.5 KiB
Bash
Executable File
55 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Start local dev stack: node backend (sqlite) + react frontend, server storage mode.
|
|
# Usage: ./scripts/dev-start.sh
|
|
# Stop: ./scripts/dev-stop.sh
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
mkdir -p tmp data
|
|
|
|
# kill anything on the ports (zombies)
|
|
for port in 3999 4001; do
|
|
pids=$(lsof -ti :$port 2>/dev/null || true)
|
|
if [ -n "$pids" ]; then
|
|
echo "port $port in use by: $pids — leaving as-is."
|
|
echo " (run ./scripts/dev-stop.sh first to restart clean)"
|
|
fi
|
|
done
|
|
|
|
# backend: better-sqlite3, :4001
|
|
if ! lsof -ti :4001 >/dev/null 2>&1; then
|
|
echo "starting backend :4001..."
|
|
DB_PATH=$(pwd)/data/tracker.sqlite PORT=4001 \
|
|
nohup npm run server:dev > tmp/server.log 2>&1 &
|
|
echo $! > tmp/server.pid
|
|
else
|
|
echo "backend already on :4001"
|
|
fi
|
|
|
|
# frontend: server storage, :3999
|
|
if ! lsof -ti :3999 >/dev/null 2>&1; then
|
|
echo "starting frontend :3999..."
|
|
REACT_APP_STORAGE=server \
|
|
REACT_APP_BACKEND_URL=http://127.0.0.1:4001 \
|
|
REACT_APP_BACKEND_REALTIME_URL=ws://127.0.0.1:4001/ws \
|
|
BROWSER=none PORT=3999 \
|
|
nohup npm start > tmp/fe.log 2>&1 &
|
|
echo $! > tmp/fe.pid
|
|
else
|
|
echo "frontend already on :3999"
|
|
fi
|
|
|
|
# wait for ports to listen
|
|
echo "waiting for ports..."
|
|
for port in 4001 3999; do
|
|
for i in {1..30}; do
|
|
lsof -ti :$port >/dev/null 2>&1 && break
|
|
sleep 1
|
|
done
|
|
done
|
|
|
|
echo ""
|
|
echo "backend : http://127.0.0.1:4001 (curl http://127.0.0.1:4001/health)"
|
|
echo "frontend : http://127.0.0.1:3999 (admin / player /display)"
|
|
echo "logs : tmp/server.log tmp/fe.log"
|
|
echo "stop : ./scripts/dev-stop.sh"
|