winzik/tools/check-forbidden-words.sh
David Nurdin fe42a30bd9 Deploy behind an existing Traefik that works, a check after each deploy
- bin/jumphp server:traefik: reads the Traefik already on the server (container,
  network, :80 / :443 entry points from its arguments or .toml / .yml files, the
  certificate resolver other sites really use) and says which mode fits
- deploy:setup uses it: traefik-external when a resolver works, otherwise
  traefik-passthrough, with the right entry point names (no more "websecure"
  guessed for a Traefik that calls them "secure" / "insecure")
- bin/jumphp deploy waits for https://<domain>/ with a valid certificate; if it
  does not come, shows the containers, their logs and what to check
- lint: the forbidden words are only searched in what git would publish
  (.env and other ignored files are private)
- AGENTS.md: createTexture*() / loadTexture() return a list of slices
- VERSION 0.1.1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018nX3d49j1YFpo3vu8qZuQd
2026-10-28 21:52:26 +01:00

31 lines
1.6 KiB
Shell
Executable file

#!/usr/bin/env bash
# Fails when the repository contains a word that must never appear (brand names of other games...).
# The words are stored rot13-encoded so that this file does not contain them itself.
# Add one: echo "word" | tr 'A-Za-z' 'N-ZA-Mn-za-m' -> append to WORDS.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
WORDS=(fbavp frtn ebobgavx rttzna xahpxyrf zvzvpung)
status=0
# in a git repository, only what git would publish: files ignored by .gitignore (.env, var/...) are private
in_git() { git -C "$ROOT" rev-parse --is-inside-work-tree >/dev/null 2>&1; }
search() {
if in_git; then
(cd "$ROOT" && git ls-files -z -co --exclude-standard | grep -zv -E '(^|/)(vendor|build|dist|node_modules)/' \
| xargs -0 -r grep -niI -e "$1" -- 2>/dev/null)
else
(cd "$ROOT" && grep -rniI --exclude-dir={vendor,.git,.build,.cache,build,dist,node_modules} -e "$1" . 2>/dev/null)
fi
}
for encoded in "${WORDS[@]}"; do
word="$(echo "$encoded" | tr 'A-Za-z' 'N-ZA-Mn-za-m')"
if hits="$(search "$word")"; then
echo "forbidden word found ($encoded, rot13):"; echo "$hits" | head -20; status=1
fi
if in_git; then paths="$(cd "$ROOT" && git ls-files -co --exclude-standard | grep -i -e "$word" || true)"
else paths="$(cd "$ROOT" && find . -path ./.git -prune -o \( -path '*/vendor' -o -path ./build -o -path ./.build -o -path ./.cache \) -prune -o -iname "*$word*" -print)"; fi
if [ -n "$paths" ]; then
echo "forbidden word in a file name ($encoded, rot13):"; echo "$paths"; status=1
fi
done
[ $status -eq 0 ] && echo "no forbidden word"
exit $status