#!/usr/bin/env bash # Compila o BreakLock (maxwellito, MIT; JS puro + SCSS, webpack 5) a partir do commit 8dedd3b de # github.com/maxwellito/breaklock, com o Node 24.21.0 de artifacts/tools e o package-lock.json do autor ("npm ci"). # # Mudancas (breaklock/breaklock-fredygames.patch): node-sass 9 (nao compila no Node 24) trocado por sass (dart-sass) # no package.json e no lock; sem service worker, manifest, icones de PWA, redirecionamento por idioma, links para # Twitter/GitHub/Facebook, botao de compartilhar e pedido de feedback por tweet; "Mastermind" tirado das descricoes. # # src/FredGames.Bundler/Builds/build-breaklock.sh # # Saida: artifacts/build/breaklock-8dedd3b/breaklock-8dedd3b-dist.tar.gz (public/); tem que sair igual em dois builds. set -euo pipefail COMMIT=8dedd3baccc051928b09605db5cb8dae3702d2f3 SHA256=1f38cfd9a0708d830767598a27892e2abae8f0bf3e288ebe7f289e610710ceb1 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/breaklock-${COMMIT:0:7}" cache="$root/artifacts/build/cache" tgz="$cache/breaklock-${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/maxwellito/breaklock/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/breaklock/breaklock-fredygames.patch" rm -rf lab service-worker.js manifest.json src/utils/share.js export npm_config_cache="$cache/npm-breaklock" npm ci --ignore-scripts --no-audit --no-fund > "$out/install.log" 2>&1 || { tail -20 "$out/install.log"; exit 1; } npm run build > "$out/build.log" 2>&1 || { tail -30 "$out/build.log"; exit 1; } [ -s public/index.html ] && [ -s public/en/app.js ] mv public "$out/dist" if grep -rqE 'twitter|facebook|github|serviceWorker|service-worker|googleapis' "$out/dist"; then echo "Sobrou referencia externa:" >&2 grep -rnoE 'twitter|facebook|github|serviceWorker|service-worker|googleapis' "$out/dist" >&2 exit 1 fi find "$out/dist" -exec touch -t 202611170000 {} + ( cd "$out" && find dist -type f | LC_ALL=C sort > list.txt \ && COPYFILE_DISABLE=1 tar --format=ustar --uid 0 --gid 0 --uname root --gname root -n -cf - -T list.txt \ | gzip -n -9 > "breaklock-${COMMIT:0:7}-dist.tar.gz" && rm list.txt ) rm -rf "$out/tree" ls -l "$out/breaklock-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "$out/breaklock-${COMMIT:0:7}-dist.tar.gz"