#!/usr/bin/env bash # Compila o Super Mega Squid: Terror of the Deep (arcade de fisica, de Rory Bourdon, MIT; TypeScript, Phaser 4.2.1 + Planck.js 1.5.0, Vite 8.3.1) a partir do # commit 5280dc8 de github.com/rbourdon/super-mega-squid, com as bibliotecas nas versoes do package-lock.json do autor ("npm ci", Node 24.21.0) e "vite build" # (a verificacao de tipos "tsc --noEmit" do "npm run build" do autor fica de fora; o Vite so remove os tipos). # # Mudancas (super-mega-squid/super-mega-squid-fredygames.patch + um arquivo): a fonte "Rocket Propelled" (Digital Graphic Labs, so "freeware" no FontSpace, sem # licenca que permita redistribuir) sai e entra a Bangers (SIL OFL 1.1, google/fonts commit cf67eac; super-mega-squid/Bangers-Regular.ttf, publicada como # assets/fonts/bangers.ttf); index.html com CSP que bloqueia qualquer requisicao fora da pasta. Os arquivos de art/ (fontes de arte), tests/, scripts/ e docs/ # nao entram no site. # # src/FredGames.Bundler/Builds/build-super-mega-squid.sh # # Saida: artifacts/build/super-mega-squid-5280dc8/{super-mega-squid-5280dc8-dist.tar.gz,licenses.txt}; o tar.gz tem que sair igual em dois builds. set -euo pipefail COMMIT=5280dc8ada0f57bdebfdc504bc02691ea162007b SHA256=7d31adf309a162348a8c5b7b9e78fed9a4521f00096ae22c6f1c1555d55c32b5 FONT_SHA256=4160a7311de9342674cce9160cde9fcbb30f48190397d86ff1b70b455af65824 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/super-mega-squid-${COMMIT:0:7}" cache="$root/artifacts/build/cache" nodebin="$root/artifacts/tools/node-v$NODE/bin" pp="$here/super-mega-squid" [ -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" tgz="$cache/super-mega-squid-${COMMIT:0:7}.tar.gz" if [ ! -f "$tgz" ]; then curl -fsSL --retry 4 "https://github.com/rbourdon/super-mega-squid/archive/$COMMIT.tar.gz" -o "$tgz.partial" && mv "$tgz.partial" "$tgz" fi echo "$SHA256 $tgz" | shasum -a 256 -c - echo "$FONT_SHA256 $pp/Bangers-Regular.ttf" | shasum -a 256 -c - rm -rf "$out" mkdir -p "$out/tree" tar -xzf "$tgz" -C "$out/tree" --strip-components 1 cd "$out/tree" patch -s -p1 < "$pp/super-mega-squid-fredygames.patch" rm public/assets/fonts/rockprp.ttf cp "$pp/Bangers-Regular.ttf" public/assets/fonts/bangers.ttf npm_config_cache="$cache/npm-sq" npm_config_update_notifier=false npm ci --ignore-scripts --no-audit --no-fund --loglevel=error ./node_modules/.bin/vite build --logLevel warn [ -s dist/index.html ] if grep -rIlE "rockprp|Rocket Propelled" dist; then echo "sobrou a fonte antiga" >&2; exit 1; fi if grep -rIoE "https?://[^\"' )]+" dist/index.html dist/assets/*.js 2>/dev/null | grep -vE "w3.org|github.com/pmndrs|phaser.io|piqnt.com|localhost" | head -5 | grep . ; then echo "conferir enderecos acima" >&2; fi mv dist "$out/dist" { echo "== Super Mega Squid (LICENSE do repositorio, MIT)" cat LICENSE echo echo "== Bangers (assets/fonts/bangers.ttf; OFL.txt do google/fonts)" cat "$pp/Bangers-OFL.txt" echo for pkg in phaser planck eventemitter3; do echo "== $pkg $(node -p "require('./node_modules/$pkg/package.json').version") (entra no bundle; LICENSE)" cat "node_modules/$pkg/LICENSE"* echo done } > "$out/licenses.txt" find "$out/dist" -exec touch -t 202611040000 {} + ( 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 > "super-mega-squid-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) du -sh "$out/dist" cd "$out" && rm -rf tree ls -l "$out/super-mega-squid-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "$out/super-mega-squid-${COMMIT:0:7}-dist.tar.gz" "$out/licenses.txt"