#!/usr/bin/env bash # Compila o MarbleFish (damas chinesas contra uma IA, MIT, arthur-x; Vue 3 + Vite 3) a partir do commit 68f7b41 de # github.com/arthur-x/MarbleFish, com o "npm ci" do package-lock.json do autor (hashes de integridade do npm) e # "vite build" (o vite.config.js ja tem base './'), com o Node 24.21.0 de artifacts/tools. # # Mudancas, todas feitas aqui (cada uma falha se o texto esperado nao existir): # - o index.html carregava a fonte de icones Material Symbols do fonts.googleapis.com (requisicao a terceiro, e a interface # toda e de icones): sai o , e os 14 icones (dificuldade, reiniciar, desfazer, confirmar e as 8 carinhas) viram SVG # inline de desenho proprio (Builds/marblefish-icons.js, MIT como o resto do projeto), no lugar dos glifos da fonte; # - a imagem mf.png (o icone da aba, desenho do autor) fica como esta (o Vite a embute no index.html). # O jogo roda a IA num Web Worker do proprio pacote; nao ha som nem outra fonte. # # src/FredGames.Bundler/Builds/build-marblefish.sh # # Saida: artifacts/build/marblefish-68f7b41/marblefish-68f7b41-site.tar.gz (pasta site/); dois builds seguidos dao os mesmos bytes. set -euo pipefail COMMIT=68f7b41db8ecc170df457545ec7837055b25c8be SHA256=19844cc0843b618c263c4e437223798f40abe2de5508b0bbb216cc92be4b9338 NODE=24.21.0 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" slug=marblefish 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/arthur-x/MarbleFish/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" python3 -I - "$here/marblefish-icons.js" <<'PY' import sys def edit(path, fn): s = open(path, encoding="utf-8").read() n = fn(s) assert n != s, path open(path, "w", encoding="utf-8", newline="").write(n) def index(s): a = s.index(' {{depth == 2 ? 'icecream' : depth == 4 ? 'fitness_center' : 'skull'}}""", """""") rep("""{{showEmotion()}}""", """""") for name in ("refresh", "close", "done"): rep('%s' % name, '' % name) a = s.index(".material-symbols-rounded {") b = s.index("}\n", a) + 2 s = s[:a] + """.ico { width: calc(var(--button-size) / 2); height: calc(var(--button-size) / 2); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; } .ico.emotion { width: var(--emotion-size); height: var(--emotion-size); margin: calc((var(--button-size) - var(--emotion-size)) / 2) 0; } """ + s[b:] return s edit("src/App.vue", app) PY 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 LICENSE "$out/site/LICENSE" 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"