#!/usr/bin/env bash # Compila o The Ninth Vigil (RPG de acao isometrico em 3D de iamlukethedev, MIT; JavaScript + three.js + Vite, escrito inteiro por # agentes de IA, como diz o README) a partir do commit d476c9b de github.com/iamlukethedev/The-Ninth-Vigil, com o "npm ci" do # package-lock.json do autor (hashes de integridade do npm) e "vite build --base ./" (a pagina roda numa subpasta), com o Node # 24.21.0 de artifacts/tools. O jogo nao tem imagem, modelo, fonte nem audio: tudo (texturas, malhas, esqueletos, animacoes, sons e # musica) e gerado por codigo ao carregar. Sem source maps; as pastas shots/ e tools/ do repositorio nao entram no que e servido. # # Mudanca (the-ninth-vigil/the-ninth-vigil-fredygames.patch): uma CSP que bloqueia qualquer requisicao fora da propria pagina. # # src/FredGames.Bundler/Builds/build-the-ninth-vigil.sh # # Saida: artifacts/build/the-ninth-vigil-d476c9b/{the-ninth-vigil-d476c9b-dist.tar.gz,licenses.txt}; o tar.gz (pasta dist/) tem que sair # igual em dois builds seguidos. licenses.txt traz a licenca do three.js (MIT), embutido no bundle. set -euo pipefail COMMIT=d476c9ba4ac39cee16c7391aa9c9bcc76acf7aa8 SHA256=e2c8afbf0ae78f275d0cedcde97bb3657ad5985911532b60ee34fd4ad4711b6a NODE=24.21.0 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/the-ninth-vigil-${COMMIT:0:7}" cache="$root/artifacts/build/cache" nodebin="$root/artifacts/tools/node-v$NODE/bin" [ -x "$nodebin/node" ] && [ "$("$nodebin/node" -v)" = "v$NODE" ] || { echo "Precisa do Node $NODE em $nodebin." >&2; exit 1; } export PATH="$nodebin:$PATH" mkdir -p "$cache" tarball="$cache/the-ninth-vigil-${COMMIT:0:7}.tar.gz" if [ ! -f "$tarball" ]; then curl -fsSL --retry 4 "https://github.com/iamlukethedev/The-Ninth-Vigil/archive/$COMMIT.tar.gz" -o "$tarball.partial" && mv "$tarball.partial" "$tarball" fi echo "$SHA256 $tarball" | shasum -a 256 -c - rm -rf "$out" mkdir -p "$out/tree" tar -xzf "$tarball" -C "$out/tree" --strip-components 1 cd "$out/tree" patch -s -p1 < "$here/the-ninth-vigil/the-ninth-vigil-fredygames.patch" export npm_config_cache="$cache/npm-the-ninth-vigil" npm_config_update_notifier=false PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm ci --ignore-scripts --no-audit --no-fund --loglevel=error sed -i.bak 's/sourcemap: true/sourcemap: false/' vite.config.js npx vite build --base ./ > "$out/build.log" 2>&1 || { tail -30 "$out/build.log"; exit 1; } [ -f dist/index.html ] if grep -rIl "https\?://" dist | head -3 | grep .; then echo "(aviso) ha URLs no dist; conferir se sao so namespaces/comentarios" >&2 fi { for pkg in three; do echo "== $pkg $(node -p "require('./node_modules/$pkg/package.json').version"): LICENSE" cat node_modules/$pkg/LICENSE* echo done } > "$out/licenses.txt" # dist/ vira um tar.gz deterministico (datas fixas, ordem fixa, sem dono). cp -R dist "$out/dist" find "$out/dist" -exec touch -t 202611060000 {} + ( cd "$out" && find dist -type f | LC_ALL=C sort > files.txt \ && COPYFILE_DISABLE=1 tar --format=ustar --uid 0 --gid 0 --uname root --gname root -n -cf - -T files.txt \ | gzip -n -9 > "the-ninth-vigil-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) rm -rf "$out/tree" ls -l "$out/the-ninth-vigil-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "$out/the-ninth-vigil-${COMMIT:0:7}-dist.tar.gz" "$out/licenses.txt" find "$out/dist" -type f | sed "s|$out/||"