Gameplay (legal moves, move application, pressure maps, PGN parsing) now runs entirely in the browser via a chess.js port of engine.py (static/engine.js + vendored chess.min.js). The app no longer calls the server during play, so it stays instant and works even when the backend is scaled to zero or offline. - engine.js: line-for-line port of engine.py; parity-verified identical output (pressure, FEN, status, SAN/UCI) across all 10 built-in games / 829 frames. - app.js: replace all /api fetches with local engine calls; graceful PGN parse errors; asset paths moved to root for static serving. - Save games to localStorage + load from the game dropdown; export any game as a .pgn file. Minimal additive UI in the existing export row. - games.json generated from games.py (scripts/export_games.py). - Production Dockerfile -> static-web-server (~9MB image, was ~150MB python). - make dev -> bun static server; add make games / make parity targets. - app.py kept as optional fallback (serves static app + /api routes). - parity/: automated JS-vs-python engine parity test. git diff stat: 16 files changed, 722 insertions(+), 128 deletions(-)
70 lines
1.7 KiB
Makefile
70 lines
1.7 KiB
Makefile
.PHONY: dev serve games parity lint fmt build publish fly-install deploy logs status help
|
|
|
|
# Static dev server (client-side app; refresh picks up edits)
|
|
dev:
|
|
bun run dev-server.js
|
|
|
|
# Optional Python fallback server (also serves the static app + /api routes)
|
|
serve:
|
|
uv run chess-pressure
|
|
|
|
# Regenerate static/games.json from games.py (run after editing games)
|
|
games:
|
|
uv run python scripts/export_games.py
|
|
|
|
# Verify the JS engine matches python-chess across every built-in game
|
|
parity:
|
|
cd parity && bun install --silent
|
|
uv run python parity/dump_python.py > parity/.py_frames.json
|
|
cd parity && bun run check.js
|
|
|
|
# Lint
|
|
lint: fmt
|
|
uvx ruff check src/chess_pressure/
|
|
|
|
# Format
|
|
fmt:
|
|
uvx ruff format src/chess_pressure/
|
|
uvx ruff check --fix src/chess_pressure/
|
|
|
|
# Build sdist + wheel
|
|
build:
|
|
rm -rf dist/
|
|
uv build
|
|
|
|
# Publish to PyPI
|
|
publish: build
|
|
uv publish
|
|
|
|
# Install flyctl
|
|
fly-install:
|
|
curl -L https://fly.io/install.sh | sh
|
|
|
|
# Deploy to Fly.io
|
|
deploy:
|
|
fly deploy -a chess-pressure
|
|
|
|
# Tail production logs
|
|
logs:
|
|
fly logs -a chess-pressure
|
|
|
|
# Production status
|
|
status:
|
|
fly status -a chess-pressure
|
|
|
|
help:
|
|
@echo "chess-pressure"
|
|
@echo ""
|
|
@echo " make dev static dev server (:8888)"
|
|
@echo " make serve optional Python fallback server (:8888)"
|
|
@echo " make games regenerate static/games.json from games.py"
|
|
@echo " make parity verify JS engine matches python-chess"
|
|
@echo " make lint ruff format + check"
|
|
@echo " make fmt ruff format + auto-fix"
|
|
@echo " make build build sdist + wheel"
|
|
@echo " make publish build + publish to PyPI"
|
|
@echo " make fly-install install flyctl"
|
|
@echo " make deploy deploy to Fly.io"
|
|
@echo " make logs tail production logs"
|
|
@echo " make status Fly.io app status"
|