-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·89 lines (77 loc) · 2.38 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·89 lines (77 loc) · 2.38 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
# Start the local editor+player dev environment.
#
# Usage:
# ./dev.sh [--release] [--api-proxy <url>]
#
# Options:
# --release Build in Release mode (AOT-compiled WasmPlayer, ~15s extra)
# --api-proxy <url> Proxy /api requests to <url> (e.g. http://localhost:5043
# for a local textadventures.co.uk instance). Also switches
# the editor to server-save-only mode (textadventures.co.uk
# behaviour) instead of the default local-only mode
# (play.questviva.com behaviour).
#
# Servers started:
# http://localhost:5174 WasmEditor (Vite / SvelteKit)
# http://localhost:5175 WasmPlayer (static dev server)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
API_PROXY=""
RELEASE=false
while [[ $# -gt 0 ]]; do
case "$1" in
--release) RELEASE=true; shift;;
--api-proxy) API_PROXY="$2"; shift 2;;
*) echo "Unknown argument: $1" >&2; exit 1;;
esac
done
echo "Building WasmEditor..."
if [[ "$RELEASE" == true ]]; then
dotnet build src/WasmEditor/WasmEditor.csproj --configuration Release
else
dotnet build src/WasmEditor/WasmEditor.csproj
fi
echo ""
echo "Building WasmPlayer..."
if [[ "$RELEASE" == true ]]; then
dotnet build src/WasmPlayer/WasmPlayer.csproj --configuration Release
else
dotnet build src/WasmPlayer/WasmPlayer.csproj
fi
echo ""
echo "Starting dev servers..."
echo ""
if [[ "$RELEASE" == true ]]; then
node src/WasmPlayer/dev-server.mjs --release &
else
node src/WasmPlayer/dev-server.mjs &
fi
PLAYER_PID=$!
VITE_ENV=(
"PUBLIC_WASM_PLAYER_URL=http://localhost:5174/player/"
)
if [[ "$RELEASE" == true ]]; then
VITE_ENV+=("WASM_CONFIG=Release")
fi
if [[ -n "$API_PROXY" ]]; then
VITE_ENV+=("VITE_API_PROXY=$API_PROXY")
VITE_ENV+=("PUBLIC_HAS_SERVER=true")
fi
env "${VITE_ENV[@]}" npm --prefix src/WebEditor run dev &
EDITOR_PID=$!
cleanup() {
echo ""
echo "Shutting down..."
kill "$PLAYER_PID" "$EDITOR_PID" 2>/dev/null || true
wait "$PLAYER_PID" "$EDITOR_PID" 2>/dev/null || true
}
trap cleanup EXIT INT TERM
echo " WasmEditor: http://localhost:5174"
echo " WasmPlayer: http://localhost:5175/?game=/examples/simple.aslx"
[[ -n "$API_PROXY" ]] && echo " API proxy → $API_PROXY"
echo ""
echo "Ctrl+C to stop."
echo ""
wait "$PLAYER_PID" "$EDITOR_PID"