-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathred-dev.sh
More file actions
51 lines (43 loc) · 1.45 KB
/
Copy pathred-dev.sh
File metadata and controls
51 lines (43 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
# red-dev.sh — Start RED Engine development environment.
#
# Starts both the Go backend (with live reload via air) and the
# Vite frontend dev server (with HMR) in parallel.
#
# Prerequisites: Go, Node.js, npm
#
# Usage:
# ./red-dev.sh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
command -v go >/dev/null 2>&1 || { echo "Go is required. Install from https://golang.org/"; exit 1; }
command -v npm >/dev/null 2>&1 || { echo "npm is required. Install from https://nodejs.org/"; exit 1; }
# Install air if missing
if ! command -v air >/dev/null 2>&1; then
echo "air not found — installing..."
go install github.com/air-verse/air@latest
export PATH="$PATH:$(go env GOPATH)/bin"
fi
# Install frontend deps if missing
if [ ! -d "$ROOT/internal/router/red-engine-frontend/node_modules" ]; then
echo "Installing frontend dependencies..."
(cd "$ROOT/internal/router/red-engine-frontend" && npm install)
fi
# Start Vite dev server in background
export NODE_OPTIONS="--disable-warning=DEP0205"
echo "Starting Vite dev server on :5173..."
(cd "$ROOT/internal/router/red-engine-frontend" && npx vite) &
VITE_PID=$!
echo "Starting Go backend with live reload..."
export DEV_MODE=true
cleanup() {
kill "$VITE_PID" 2>/dev/null || true
echo "Development environment stopped."
}
trap cleanup EXIT
cd "$ROOT"
if [ -f ".air.dev.toml" ]; then
air -c .air.dev.toml -- "-config=config.json"
else
go run ./cmd/red/main.go "-config=config.json"
fi