12set -euo pipefail34script_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"5repo_dir="$(CDPATH='' cd -- "$script_dir/.." && pwd -P)"6site_dir="$repo_dir/website"7wrangler_config="$repo_dir/wrangler.jsonc"89for command_name in bash find grep node python3; do10 if ! command -v "$command_name" >/dev/null 2>&1; then11 printf 'required command is missing: %s\n' "$command_name" >&212 exit 113 fi14done1516for required_file in index.html styles.css dither.js _headers install-sigil portal-release.json; do17 if [[ ! -f "$site_dir/$required_file" ]]; then18 printf 'website asset is missing: %s\n' "$required_file" >&219 exit 120 fi21done2223node - "$wrangler_config" <<'NODE'24const fs = require('node:fs');2526const configPath = process.argv[2];27const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));2829if (config.name !== 'goq-sh') {30 throw new Error('Wrangler must deploy the existing goq-sh Worker');31}32if (config.assets?.directory !== './website') {33 throw new Error('Wrangler assets.directory must be ./website');34}35if ('main' in config || 'binding' in (config.assets ?? {})) {36 throw new Error('goq.sh must remain an assets-only Worker');37}38NODE3940if find "$site_dir" -type l -print -quit | grep -q .; then41 echo 'website output must not contain symbolic links' >&242 exit 143fi4445node --check "$site_dir/dither.js"46python3 "$repo_dir/scripts/verify-portal-release.py" website \47 --manifest "$site_dir/portal-release.json" >/dev/null48python3 "$repo_dir/scripts/verify-sigil-bootstrap.py" \49 --bootstrap "$site_dir/install-sigil" \50 --public-key-file "$repo_dir/release/sigil-minisign.pub" >/dev/null51bash -n "$site_dir/install-sigil"52[[ -x "$site_dir/install-sigil" ]] || {53 echo 'Sigil bootstrap must be executable' >&254 exit 155}56grep -Fq 'href="./styles.css"' "$site_dir/index.html"57grep -Fq 'src="./dither.js"' "$site_dir/index.html"58grep -Fq 'Content-Security-Policy:' "$site_dir/_headers"59grep -Fq 'https://goq.sh/install-sigil' "$site_dir/index.html"60grep -Fq 'data-copy="curl -fsSL https://goq.sh/install-sigil | bash"' "$site_dir/index.html"61grep -Fq 'github.com/FelineStateMachine/goq/releases' "$site_dir/index.html"62grep -Fq 'class="portal-download disabled"' "$site_dir/index.html"63grep -Fq 'id="portal-download" aria-disabled="true"' "$site_dir/index.html"64grep -Fq 'window.fetch("./portal-release.json"' "$site_dir/dither.js"65grep -Fq 'PORTAL_BUILDS["macos-arm"] = portalBuildFromManifest(manifest)' "$site_dir/dither.js"66grep -Fq "connect-src 'self'" "$site_dir/_headers"67for issue_number in 7 8 9 10; do68 grep -Fq "github.com/FelineStateMachine/goq/issues/$issue_number" "$site_dir/index.html"69done7071echo 'website_static_gate=ok'