#!/usr/bin/env bash # Monta o Quizzity (quiz de geografia de David Peter, MIT) a partir do commit 64399da de github.com/sharkdp/quizzity: "npm ci # --ignore-scripts" com o package-lock.json do autor (Node 24.21.0) e o proprio "npm run build" dele (copia o jogo, compila o LESS e # junta as bibliotecas em assets/). Mudancas nossas (quizzity/quizzity-fredygames.patch): sem Google Analytics, sem o registro de # partidas em php/log.php, sem o link para a Wikipedia, sem metadados de redes sociais, sem os links do GitHub e do PayPal (entram os # creditos do Natural Earth e do GeoNames). Do dist/ saem ainda php/, statistics/, o select2 (o jogo nao o usa) e a pasta de # desenvolvimento do geodata. Nada e pedido a outros sites. # # O leaflet.geodesic (GPL-3.0) entra no jogo: o fonte dele (tag v2.7.2) vai junto, como o do jogo, o patch e este script. # # src/FredGames.Bundler/Builds/build-quizzity.sh # # Saida: artifacts/build/quizzity-64399da/{quizzity-64399da-dist.tar.gz,licenses.txt}; o tar.gz sai igual em dois builds. set -euo pipefail COMMIT=64399da6c9249769e87853009684f4e952916bce SHA256=6510a1d823811a18b762a6b52d6fb3aa0a6c10afa89de7c2a2943c603bb06567 # Roboto Condensed (SIL OFL 1.1, google/fonts), que o CSS do autor pedia ao Google Fonts FONTS=https://raw.githubusercontent.com/google/fonts/2fe1e8c6b137fb13041a7cfca6fdcd8a910ea4dc/ofl/robotocondensed RC_TTF_SHA256=dace262afcee68a5276f200d8026c57221735c0118ab5fda8c2c0d3dc409a8d0 RC_OFL_SHA256=0e4cc6ece88573545be2ed25835363662a6182ba4a4c1b5c8feda52add30e8a6 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/quizzity-${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" f="$cache/quizzity-${COMMIT:0:7}.tar.gz" if [ ! -f "$f" ]; then curl -fsSL --retry 4 "https://github.com/sharkdp/quizzity/archive/$COMMIT.tar.gz" -o "$f.partial" && mv "$f.partial" "$f"; fi echo "$SHA256 $f" | shasum -a 256 -c - 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 "$FONTS/RobotoCondensed%5Bwght%5D.ttf" RobotoCondensed-2fe1e8c.ttf "$RC_TTF_SHA256" fetch "$FONTS/OFL.txt" RobotoCondensed-OFL-2fe1e8c.txt "$RC_OFL_SHA256" rm -rf "$out" mkdir -p "$out/tree" tar -xzf "$f" -C "$out/tree" --strip-components 1 cd "$out/tree" patch -s -p1 < "$here/quizzity/quizzity-fredygames.patch" npm ci --ignore-scripts --no-audit --no-fund --cache "$cache/npm" > "$out/install.log" 2>&1 || { tail -20 "$out/install.log"; exit 1; } npm run build > "$out/build.log" 2>&1 || { tail -20 "$out/build.log"; exit 1; } mkdir -p dist/fonts cp "$cache/RobotoCondensed-2fe1e8c.ttf" dist/fonts/RobotoCondensed.ttf cp "$cache/RobotoCondensed-OFL-2fe1e8c.txt" dist/fonts/RobotoCondensed-OFL.txt rm -rf dist/php dist/statistics dist/assets/select2 # so o que o navegador carrega: sem fontes em formatos antigos (o CSS do Font Awesome cai no woff2/woff), sem mapas nem versoes -src find dist/assets -type f \( -name '*.map' -o -name '*-src.js' -o -name '*.eot' -o -name '*.svg' -o -name '*.ttf' -o -name '*.otf' -o -name '*.esm.js' -o -name 'leaflet.awesome-markers.js' -o -name 'leaflet.geodesic.js' -o -name 'leaflet.geodesic.umd.js' -o -name '*.d.ts' -o -name '*.stats.html' -o -name '*.sha512' \) -delete rm -f dist/assets/jquery/dist/jquery.js dist/assets/jquery/dist/jquery.slim.js dist/assets/jquery/dist/jquery.slim.min.js [ -s dist/index.html ] && [ -s dist/css/quizzity.css ] && [ -d dist/tiles/2 ] if grep -rIhE "google|UA-39945208|log\.php|paypal|david-peter\.de|twitter\.com|wikipedia\.org|https?://" dist/index.html dist/js dist/css | grep -v 'xmlns='; then echo "o build ainda cita um servico de terceiros" >&2; exit 1 fi { echo "== Quizzity (LICENSE do repositorio, MIT)" cat LICENSE echo for pkg in animate.css font-awesome jquery leaflet leaflet.awesome-markers leaflet.geodesic lodash; do echo "== $pkg $(node -p "require('./node_modules/$pkg/package.json').version") (entra no jogo; package.json: $(node -p "JSON.stringify(require('./node_modules/$pkg/package.json').license || require('./node_modules/$pkg/package.json').licenses)"))" for lf in node_modules/$pkg/[Ll][Ii][Cc]*; do [ -f "$lf" ] && cat "$lf"; done if [ "$pkg" = font-awesome ]; then # o pacote npm nao traz arquivo de licenca; o cabecalho do CSS diz "Font: SIL OFL 1.1, CSS: MIT License" echo "Font Awesome 4.7.0 by Dave Gandy, https://fontawesome.io. The font (fonts/fontawesome-webfont.*) is licensed under the SIL Open" echo "Font License 1.1, copied below; the CSS (css/font-awesome.min.css) is licensed under the MIT licence." echo cat "$here/quizzity/ofl-1.1.txt" echo echo "MIT licence for the CSS: Copyright (c) Dave Gandy. Permission is hereby granted, free of charge, to any person obtaining a copy of this" echo "software and associated documentation files, to deal in it without restriction, subject to the same conditions and disclaimer as the" echo "MIT licence of animate.css above (the copyright notice and this permission notice shall be included in all copies)." fi echo done echo "== Roboto Condensed (fonts/RobotoCondensed.ttf, SIL OFL 1.1, google/fonts)" cat "$cache/RobotoCondensed-OFL-2fe1e8c.txt" } > "$out/licenses.txt" cp -R dist "$out/dist" 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 > "quizzity-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) du -sh "$out/dist" cd "$out" && rm -rf tree ls -l "$out/quizzity-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "$out/quizzity-${COMMIT:0:7}-dist.tar.gz" "$out/licenses.txt"