The game kit: the shared infrastructure of Wiz-War and Waving Hands as a template
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0141G6xqLeNRYEtviLWSB5Up
This commit is contained in:
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# Stamp out a new game from the template.
|
||||
# ./new-game.sh <slug> "<Name>" [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 <slug> \"<Name>\" [port] [domain]}"
|
||||
NAME="${2:?usage: new-game.sh <slug> \"<Name>\" [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 && echo "dependencies installed" || echo "npm install failed; run it by hand"
|
||||
cat <<MSG
|
||||
|
||||
$NAME is at $DEST (port $PORT, $DOMAIN).
|
||||
|
||||
Next:
|
||||
1. Replace src/lib/game/index.ts with your game, keeping the GameSpec shape,
|
||||
and src/lib/components/Board.svelte with its board. Keep the tests green.
|
||||
2. Fill in the hall's pitch, tag and about panel (src/lib/components/Hall.svelte),
|
||||
the rules page, the guide, src/app.html's description, and the palette in src/app.css.
|
||||
3. Create the droplet (deploy/README.md), then replace __IP__ everywhere:
|
||||
grep -rl __IP__ . --exclude-dir=node_modules | xargs sed -i '' 's/__IP__/<ip>/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 <ip>
|
||||
docs/conventions.md is the house style every game follows.
|
||||
MSG
|
||||
Reference in New Issue
Block a user