#!/usr/bin/env bash # Stamp out a new game from the template. # ./new-game.sh "" [port] [domain] # e.g. ./new-game.sh tumbleweed "Tumbleweed" 8789 tumbleweed.kestrelsnest.social # Ports so far: wizwar 8787, waving-hands 8788. Each game is its own droplet, # so the port only has to be unique on your machine for running two locally. set -euo pipefail SLUG="${1:?usage: new-game.sh \"\" [port] [domain]}" NAME="${2:?usage: new-game.sh \"\" [port] [domain]}" PORT="${3:-8789}" DOMAIN="${4:-$SLUG.kestrelsnest.social}" case "$SLUG" in *[!a-z0-9-]*) echo "slug: lowercase letters, digits and hyphens" >&2; exit 1;; esac DEST="$(cd "$(dirname "$0")/.." && pwd)/$SLUG" [ -e "$DEST" ] && { echo "$DEST already exists" >&2; exit 1; } KIT="$(cd "$(dirname "$0")" && pwd)" rsync -a --exclude node_modules --exclude .svelte-kit --exclude build --exclude data "$KIT/template/" "$DEST/" # File names carry the slug (unit, cron, backup, rollup, skills). find "$DEST" -depth -name '*__SLUG__*' | while read -r f; do mv "$f" "$(dirname "$f")/$(basename "$f" | sed "s/__SLUG__/$SLUG/g")" done # Then the placeholders inside. __IP__ and the Sentry ids stay until they exist. find "$DEST" -type f \( -name '*.ts' -o -name '*.svelte' -o -name '*.json' -o -name '*.md' -o -name '*.sh' -o -name '*.tmpl' -o -name '*.service' -o -name '*.cron' -o -name '*.html' -o -name '*.css' -o -name '.gitignore' \) -print0 \ | xargs -0 sed -i '' -e "s/__SLUG__/$SLUG/g" -e "s/__NAME__/$NAME/g" -e "s/__PORT__/$PORT/g" -e "s/__DOMAIN__/$DOMAIN/g" cp "$KIT/CONVENTIONS.md" "$DEST/docs-conventions.md" 2>/dev/null || true mkdir -p "$DEST/docs" && mv "$DEST/docs-conventions.md" "$DEST/docs/conventions.md" cd "$DEST" git init -q && git add -A && git commit -q -m "Begin $NAME from the game kit" npm install --no-audit --no-fund >/dev/null 2>&1 && (cd server && npm install --no-audit --no-fund >/dev/null 2>&1) && echo "dependencies installed" || echo "npm install failed; run it by hand (root and server/)" cat </g' 4. Create a Sentry project (the Sentry MCP can) and put its DSN and project id in deploy/$SLUG.service and deploy/sentry-slack-alert.sh. 5. deploy/deploy.sh docs/conventions.md is the house style every game follows. MSG