62 lines
2.9 KiB
Bash
62 lines
2.9 KiB
Bash
#!/usr/bin/env bash
|
|
# Dev subcommands: play, editor, guide, designs, screenshot.
|
|
#
|
|
# Previously this file was 546L conflating lint/format/test/verify/autoplay/
|
|
# dev-server into one module. It's now split:
|
|
# - lint.sh → cmd_lint, cmd_lint_gd/rust/ts, cmd_typecheck
|
|
# - format.sh → cmd_format, cmd_format_gd/rust/ts
|
|
# - test.sh → cmd_test, cmd_test_golden, cmd_coverage, cmd_validate
|
|
# - verify.sh → cmd_verify + _verify_* helpers
|
|
# - autoplay.sh → cmd_autoplay, cmd_autoplay_batch
|
|
# This file now only owns actually-"dev" workflows (launching the game/editor/guide).
|
|
|
|
cmd_play() {
|
|
local LOG_FILE="$REPO_ROOT/.project/logs/game_$(date +%Y%m%d_%H%M%S).log"
|
|
mkdir -p "$(dirname "$LOG_FILE")"
|
|
echo -e "${BLUE}Launching Magic Civilization...${NC}"
|
|
echo -e "${BLUE}Log: $LOG_FILE${NC}"
|
|
WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}" \
|
|
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" \
|
|
$GODOT_BIN --path "$GAME_DIR" --rendering-method gl_compatibility "$@" 2>&1 | tee "$LOG_FILE"
|
|
local EXIT_CODE=${PIPESTATUS[0]}
|
|
if [ $EXIT_CODE -ne 0 ]; then
|
|
echo -e "\n${RED}Game exited with code $EXIT_CODE${NC}"
|
|
echo -e "${RED}Crash log: $LOG_FILE${NC}"
|
|
tail -20 "$LOG_FILE" | grep -E "SCRIPT ERROR|ERROR:|Crash|FATAL|at:" | head -10
|
|
fi
|
|
}
|
|
|
|
cmd_editor() {
|
|
echo -e "${BLUE}Opening Godot editor...${NC}"
|
|
WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}" \
|
|
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" \
|
|
$GODOT_BIN --path "$GAME_DIR" -e --rendering-method gl_compatibility "$@" &
|
|
}
|
|
|
|
cmd_guide() {
|
|
# Pre-check: surface WASM artifact location issues before Vite starts so
|
|
# alias-resolution errors are self-describing instead of a cryptic
|
|
# "Rollup failed to resolve import".
|
|
if [ -d "$REPO_ROOT/src/simulator/pkg" ] && [ -n "$(ls -A "$REPO_ROOT/src/simulator/pkg" 2>/dev/null)" ]; then
|
|
echo -e "${YELLOW}warning: src/simulator/pkg/ has content — build output must live in .local/build/wasm/ (src/ is source-only).${NC}"
|
|
echo -e "${YELLOW} Re-run: (cd src/simulator && bash build-wasm.sh)${NC}"
|
|
fi
|
|
if [ ! -f "$REPO_ROOT/.local/build/wasm/magic_civ_physics.js" ]; then
|
|
echo -e "${YELLOW}warning: .local/build/wasm/magic_civ_physics.js missing — WASM not built locally.${NC}"
|
|
echo -e "${YELLOW} Build locally: (cd src/simulator && bash build-wasm.sh)${NC}"
|
|
echo -e "${YELLOW} Or rsync from apricot: rsync -a \"\$AUTOPLAY_HOST:\$PROJECT_ROOT_REMOTE/.local/build/wasm/\" .local/build/wasm/${NC}"
|
|
fi
|
|
echo -e "${BLUE}Starting guide dev server (port 5800)...${NC}"
|
|
pnpm --prefix "$GUIDE_DIR" dev
|
|
}
|
|
|
|
cmd_designs() {
|
|
local port="${1:-7777}"
|
|
echo -e "${BLUE}Starting design viewer (port ${port})...${NC}"
|
|
echo -e "${BLUE} http://localhost:${port}${NC}"
|
|
node "$REPO_ROOT/.project/designs/serve.js" "$port"
|
|
}
|
|
|
|
cmd_screenshot() {
|
|
"$REPO_ROOT/tools/screenshot.sh" "$@"
|
|
}
|