#!/usr/bin/env bash # Compila o Cellular: Automata (puzzle de cartas de autômatos celulares de Ilya Baturinsky, Ludum Dare 46; MIT; Preact, # MIT; fonte Didact Gothic, OFL-1.1) a partir do commit 4ae7c2f de github.com/baturinsky/cellular, como o package.json # do autor: yarn 1.22.22 (yarn.lock dele, "--frozen-lockfile", sem os scripts de instalacao) e "rollup -c" (TypeScript, # terser), com o Node 24.21.0 de artifacts/tools. O public/bundle.js que o autor commitou e substituido pelo gerado. # # Mudancas (cellular-automata/cellular-fredygames.patch): o main.css deixa de apontar para a copia da fonte no # fonts.gstatic.com (a mesma fonte ja vai junto, DidactGothic.woff) e o index.html ganha uma CSP que barra qualquer # requisicao fora do site. O codigo do jogo nao muda. Vai junto a OFL da fonte, do google/fonts num commit fixo. # # src/FredGames.Bundler/Builds/build-cellular-automata.sh # # Saida: artifacts/build/cellular-automata-4ae7c2f/{cellular-automata-4ae7c2f-dist.tar.gz,licenses.txt}; o tar.gz # (pasta dist/) sai igual em dois builds seguidos. set -euo pipefail COMMIT=4ae7c2f0f8055a753e11f851cf52a89bdb91a5ae SHA256=577728534781a6958dba627f67f860227fa1fb225825c29ca7e986c744293b33 NODE=24.21.0 YARN=1.22.22 YARN_SHA256=c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca FONTS_COMMIT=2eb0b48d5f760f62e286216f0859a8c540dbc1bd OFL_SHA256=36e2f1debc9778bac79fac1a0cb5a5ef51c102f00b58ef7d8a05324144b68166 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/cellular-automata-${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" fetch() { if [ ! -f "$cache/$2" ]; then curl -fsSL --retry 4 "$1" -o "$cache/$2.partial" && mv "$cache/$2.partial" "$cache/$2" fi echo "$3 $cache/$2" | shasum -a 256 -c - } fetch "https://github.com/baturinsky/cellular/archive/$COMMIT.tar.gz" "cellular-${COMMIT:0:7}.tar.gz" "$SHA256" fetch "https://registry.npmjs.org/yarn/-/yarn-$YARN.tgz" "yarn-$YARN.tgz" "$YARN_SHA256" fetch "https://raw.githubusercontent.com/google/fonts/$FONTS_COMMIT/ofl/didactgothic/OFL.txt" "DidactGothic-OFL-${FONTS_COMMIT:0:7}.txt" "$OFL_SHA256" rm -rf "$out" mkdir -p "$out/tree" "$out/yarn" "$out/dist" tar -xzf "$cache/cellular-${COMMIT:0:7}.tar.gz" -C "$out/tree" --strip-components 1 tar -xzf "$cache/yarn-$YARN.tgz" -C "$out/yarn" patch -s -p1 -d "$out/tree" < "$here/cellular-automata/cellular-fredygames.patch" cd "$out/tree" node "$out/yarn/package/bin/yarn.js" install --frozen-lockfile --ignore-scripts --silent --cache-folder "$cache/yarn-cellular" rm -f public/bundle.js public/bundle.js.map npx rollup -c >"$out/rollup.log" 2>&1 || { tail -30 "$out/rollup.log"; exit 1; } [ -s public/bundle.js ] cp public/index.html public/main.css public/bundle.js public/DidactGothic.woff public/favicon.png "$out/dist/" cp "$cache/DidactGothic-OFL-${FONTS_COMMIT:0:7}.txt" "$out/dist/DidactGothic-OFL.txt" { echo "== Cellular: Automata (LICENSE do repositorio, MIT)" cat LICENSE echo echo "== Preact $(node -p "require('./node_modules/preact/package.json').version") (LICENSE do pacote, MIT; entra no bundle)" cat node_modules/preact/LICENSE echo echo "== Didact Gothic (DidactGothic.woff; google/fonts $FONTS_COMMIT, ofl/didactgothic/OFL.txt)" cat "$cache/DidactGothic-OFL-${FONTS_COMMIT:0:7}.txt" } > "$out/licenses.txt" find "$out/dist" -exec touch -t 202511010000 {} + ( 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 > "cellular-automata-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) cd "$out" && rm -rf tree yarn ls -l "$out/cellular-automata-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "$out/cellular-automata-${COMMIT:0:7}-dist.tar.gz" "$out/licenses.txt"