#!/usr/bin/env bash # Compila Hook, Line, and Spelunker (roguelike de pesca de Devin Spikowski, MIT; TypeScript + pixi.js 6 + webpack 5, 7DRL 2022) # a partir do commit c9eb48c de github.com/vegeta897/7drl-2022, com o Node 24.21.0 de artifacts/tools e o package-lock.json do # autor ("npm ci --ignore-scripts"). # # Mudancas (hook-line-and-spelunker/hook-line-and-spelunker-fredygames.patch): o webpack de producao nao gera o app.zip do itch, # nem o relatorio do bundle analyzer, nem roda o ESLint nem o optipng (binario baixado por script), e so os sprites do jogo vao # para o dist (sem capas do itch nem arquivos .aseprite); titulo da pagina e viewport. # # src/FredGames.Bundler/Builds/build-hook-line-and-spelunker.sh # # Saida: artifacts/build/hook-line-and-spelunker-c9eb48c/hook-line-and-spelunker-c9eb48c-dist.tar.gz (dist/); sai igual em dois builds. set -euo pipefail COMMIT=c9eb48c0560ae0fd63fe0e4f9e258f2b94bc68d0 SHA256=029ba33be0f1c69b43246b54f8b6e11a08891ba9b9f5e49bf29036ce5230c843 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/hook-line-and-spelunker-${COMMIT:0:7}" cache="$root/artifacts/build/cache" tgz="$cache/hook-line-and-spelunker-${COMMIT:0:7}.tar.gz" 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" if [ ! -f "$tgz" ]; then curl -fsSL --retry 4 "https://github.com/vegeta897/7drl-2022/archive/$COMMIT.tar.gz" -o "$tgz.partial" && mv "$tgz.partial" "$tgz" fi echo "$SHA256 $tgz" | 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 < "$here/hook-line-and-spelunker/hook-line-and-spelunker-fredygames.patch" export npm_config_cache="$cache/npm-hook-line-and-spelunker" npm ci --ignore-scripts --no-audit --no-fund > "$out/install.log" 2>&1 || { tail -20 "$out/install.log"; exit 1; } rm -rf dist NO_COLOR=1 npx webpack --env mode=production > "$out/webpack.log" 2>&1 || { tail -30 "$out/webpack.log"; exit 1; } [ -s dist/index.html ] mv dist "$out/dist" if grep -rqE 'https?://[a-z0-9.-]+\.(com|net|org|io)' "$out/dist/index.html"; then echo "Endereco externo no index.html" >&2; exit 1; fi find "$out/dist" -exec touch -t 202604090000 {} + ( 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 > "hook-line-and-spelunker-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) ls -lR "$out/dist" | head -20 rm -rf "$out/tree" shasum -a 256 "$out/hook-line-and-spelunker-${COMMIT:0:7}-dist.tar.gz"