#!/usr/bin/env bash # Compila The Last Pawn (puzzle de xadrez com um peao so, MIT, Gabriel Edradan / gbrln; React 19 + Redux Toolkit + SCSS + Vite 6) # a partir do commit 13ac4da de github.com/gbrln/the-last-pawn, com o "npm ci" do package-lock.json do autor (hashes de integridade # do npm) e "vite build --base=./" (o base do vite.config.js e do GitHub Pages dele), com o Node 24.21.0 de artifacts/tools. # Mudancas: a pasta public/readme (imagens e um GIF de 12 MB so do README) fica de fora, e entra o OFL.txt da fonte Concert One # (SIL OFL 1.1, Johan Kallas e Mihkel Virkus), que o repositorio traz sem a licenca (Builds/the-last-pawn/OFL.txt, copia do # google/fonts). As pecas sao SVG do autor, o cursor e um SVG embutido e o jogo nao tem audio nem rede. # # src/FredGames.Bundler/Builds/build-the-last-pawn.sh # # Saida: artifacts/build/spider-solitaire-51aee4f/spider-solitaire-51aee4f-site.tar.gz (pasta site/); dois builds # seguidos dao os mesmos bytes. set -euo pipefail COMMIT=13ac4dab9393f9e6088deba09bdb7c63e9fb95ad SHA256=73a135eef530bd53a7c5de420465043dc84c668f6f18e452fc4af9c50ab17f53 NODE=24.21.0 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" slug=the-last-pawn out="$root/artifacts/build/$slug-${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:/usr/bin:/bin" mkdir -p "$cache" tarball="$cache/$slug-${COMMIT:0:7}.tar.gz" [ -f "$tarball" ] || curl -fsSL --retry 4 "https://github.com/gbrln/the-last-pawn/archive/$COMMIT.tar.gz" -o "$tarball" 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" rm -rf public/readme export npm_config_cache="$cache/npm-$slug" npm_config_update_notifier=false npm ci --ignore-scripts --no-audit --no-fund --loglevel=error node node_modules/vite/bin/vite.js build --base=./ --outDir "$out/site" > "$out/build.log" 2>&1 || { tail -30 "$out/build.log"; exit 1; } if grep -rIlE "https?://[a-z0-9.-]+" "$out/site" --include=index.html --include=*.css | grep .; then echo "endereco externo no HTML/CSS" >&2; exit 1; fi cp "$here/the-last-pawn/OFL.txt" "$out/site/OFL.txt" cd "$out" find site -exec touch -t 202611010000 {} + find site -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 > "$slug-${COMMIT:0:7}-site.tar.gz" cat files.txt; rm -rf files.txt tree site build.log shasum -a 256 "$slug-${COMMIT:0:7}-site.tar.gz"