Gate was process.env.NODE_ENV === 'development' — unsafe default. react-scripts inlines NODE_ENV=development when unset, so prod deploys forgetting the env var exposed the delete-all button. Switched to explicit opt-in REACT_APP_DEV_TOOLS=1. process.env.REACT_APP_DEV_TOOLS as static literal gets inlined by DefinePlugin at webpack build time — runtime mutations in tests had no effect, and dev-start without the env produced bundles with the branch dead-stripped. Extracted gate to src/config/devTools.js using dynamic key access (process.env['REACT_APP_' + 'DEV_TOOLS']) so DefinePlugin cannot inline it; the value is read at runtime. dev-start.sh now exports REACT_APP_DEV_TOOLS=1. Button had also drifted outside the campaigns collapse block to the page bottom; moved it back inside the campaigns section after the grid. Tests cover both paths: gate logic (unset/0/arbitrary/1) in BulkDelete.gate.test.js, prod safety render (button absent when unset) in BulkDelete.render-hidden.test.js, dev feature render (button present when DEV_TOOLS=1) in BulkDelete.render-shown.test.js.
56 lines
1.6 KiB
Bash
Executable File
56 lines
1.6 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 ALLOW_DEV_ENDPOINTS=1 \
|
|
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..."
|
|
NODE_ENV=development REACT_APP_DEV_TOOLS=1 \
|
|
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"
|