Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0141G6xqLeNRYEtviLWSB5Up
32 lines
1.7 KiB
Bash
Executable File
32 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Show how far a game's shared files have drifted from the kit's template.
|
|
# ./drift.sh <game-dir> [slug] e.g. ./drift.sh ../waving-hands waving-hands
|
|
# Files are paired by drift-map/<slug>.txt when a game's layout differs from
|
|
# the template's ("template/path game/path" per line); otherwise the same
|
|
# path is compared. Placeholders are filled with the slug before diffing, so
|
|
# only real divergence shows. Prints changed lines per file, then the total.
|
|
set -euo pipefail
|
|
GAME="${1:?usage: drift.sh <game-dir> [slug]}"
|
|
SLUG="${2:-$(basename "$(cd "$GAME" && pwd)")}"
|
|
KIT="$(cd "$(dirname "$0")" && pwd)"
|
|
MAP="$KIT/drift-map/$SLUG.txt"
|
|
SHARED="server/src/index.ts server/src/rooms.ts server/src/store.ts server/src/reports.ts server/src/ratelimit.ts
|
|
src/lib/net/client.ts src/lib/net/talk.ts src/lib/components/TableTalk.svelte src/lib/components/ReportSlip.svelte
|
|
deploy/deploy.sh deploy/setup-droplet.sh deploy/setup-server.sh deploy/Caddyfile.tmpl deploy/verify-ledgers.sh
|
|
deploy/replay-ledgers.ts deploy/pulse.sh deploy/visitors.sh deploy/sentry-slack-alert.sh deploy/pull-reports.sh deploy/report-reply.sh
|
|
deploy/__SLUG__.service deploy/__SLUG__.cron deploy/__SLUG__-backup.sh deploy/__SLUG__-rollup.sh"
|
|
total=0
|
|
for t in $SHARED; do
|
|
g="$t"
|
|
if [ -f "$MAP" ]; then
|
|
m=$(awk -v t="$t" '$1 == t { print $2 }' "$MAP")
|
|
[ -n "$m" ] && g="$m"
|
|
fi
|
|
g="${g//__SLUG__/$SLUG}"
|
|
if [ ! -f "$GAME/$g" ]; then printf '%-44s %s\n' "$t" "missing in game ($g)"; continue; fi
|
|
n=$(diff <(sed -e "s/__SLUG__/$SLUG/g" "$KIT/template/$t") "$GAME/$g" | grep -c '^[<>]' || true)
|
|
total=$((total + n))
|
|
printf '%-44s %4d lines differ\n' "$t" "$n"
|
|
done
|
|
echo "total: $total lines differ from the template"
|