# Checkmate — real-time chess on atproto + SpacetimeDB pid_file := ".spacetime.pid" log_file := ".spacetime.log" # Install all dependencies install: cd server && bun install cd client && bun install # Build the SpacetimeDB server module build: spacetime build --module-path ./server # Generate TypeScript client bindings from the server module generate: spacetime generate --lang typescript --out-dir client/src/module_bindings --module-path server # Publish the module to local SpacetimeDB (clears existing data) publish: spacetime publish checkmate --module-path ./server --server local --delete-data -y # Start SpacetimeDB in the background up: #!/usr/bin/env bash set -euo pipefail if [ -f {{pid_file}} ] && kill -0 "$(cat {{pid_file}})" 2>/dev/null; then echo "SpacetimeDB already running (pid $(cat {{pid_file}}))" exit 0 fi spacetime start --non-interactive > {{log_file}} 2>&1 & echo $! > {{pid_file}} echo "SpacetimeDB started (pid $(cat {{pid_file}}))" # Wait for the server to accept TCP connections for i in $(seq 1 30); do if curl -so /dev/null http://127.0.0.1:3000/ 2>/dev/null; then echo "SpacetimeDB ready" exit 0 fi sleep 0.2 done echo "Warning: SpacetimeDB may not be ready yet — check 'just logs'" # Stop SpacetimeDB down: #!/usr/bin/env bash set -euo pipefail if [ ! -f {{pid_file}} ]; then echo "No PID file found — SpacetimeDB not running" exit 0 fi pid=$(cat {{pid_file}}) if kill -0 "$pid" 2>/dev/null; then kill "$pid" echo "SpacetimeDB stopped (pid $pid)" else echo "SpacetimeDB was not running (stale PID file)" fi rm -f {{pid_file}} # Start the Vite dev server dev: cd client && bun run dev # Run all tests test: cd client && bun run test:ci # Run tests in watch mode test-watch: cd client && bun run test # Type-check the client check: cd client && npx tsc --noEmit # Full build + type-check + test ci: build check test # View SpacetimeDB server logs logs: spacetime logs checkmate # Query the database sql query: spacetime sql checkmate "{{query}}" # First-time setup: install deps, start db, build, publish, generate bindings setup: install up build publish generate