#!/usr/bin/env bash # Monta o Learn Git Branching (visualizacao interativa de git, de Peter Cottle, MIT) a partir do commit c7ed929 de # github.com/pcottle/learnGitBranching: "yarn install --frozen-lockfile" com o yarn.lock do autor (yarn 1.22.22, do pacote npm, conferido # pelo sha256, e Node 24.21.0), "node scripts/generate.js", "vite build" e o postbuild do autor (copia assets/). Sem o "yarn test". # Mudancas nossas (learn-git-branching/learn-git-branching-fredygames.patch): sem Google Analytics, sem as faixas de divulgacao de outros # projetos do autor (BiteRead e WaitingFor) e a logica que as sorteia, sem a meta de redes sociais e o canto do GitHub, sem o carregador # de niveis de gist do GitHub, sem os botoes de compartilhar (Twitter/X, LinkedIn, Facebook), sem o icone do Threads, sem os links de # documentacao do git-scm.com, sem os links "learngitbranching.js.org" (o link permanente do "export tree" usa a propria pagina e os # links alternativos de idioma saem), os links Markdown dos textos das licoes e dos dialogos para outros sites viram so texto (os que # apontavam para o jogo no site do autor viram links relativos), uma Content-Security-Policy e uma trava que impede o jogo de sair da # propria pagina por um link. Do build saem ainda as imagens de divulgacao (biteRead.png, waitingFor.png, learnGitBranching.png), as # fontes em formatos antigos (eot/svg/ttf, o CSS cai no woff2/woff) e a documentacao gerada (generatedDocs/). # # src/FredGames.Bundler/Builds/build-learn-git-branching.sh # # Saida: artifacts/build/learn-git-branching-c7ed929/{learn-git-branching-c7ed929-dist.tar.gz,licenses.txt}; o tar.gz sai igual em dois builds. set -euo pipefail COMMIT=c7ed92908e9a653d7d23facc2acbeb843b0492bf SHA256=295fe57eaac9c4892cc1bad254aa347f1ae4e845f833119d575630f8238eb123 NODE=24.21.0 YARN=1.22.22 YARN_SHA256=c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/learn-git-branching-${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/pcottle/learnGitBranching/archive/$COMMIT.tar.gz" "learnGitBranching-${COMMIT:0:7}.tar.gz" "$SHA256" fetch "https://registry.npmjs.org/yarn/-/yarn-$YARN.tgz" "yarn-$YARN.tgz" "$YARN_SHA256" yarndir="$root/artifacts/tools/yarn-$YARN" if [ ! -f "$yarndir/package/bin/yarn.js" ]; then mkdir -p "$yarndir" && tar -xzf "$cache/yarn-$YARN.tgz" -C "$yarndir"; fi rm -rf "$out" mkdir -p "$out/tree" tar -xzf "$cache/learnGitBranching-${COMMIT:0:7}.tar.gz" -C "$out/tree" --strip-components 1 cd "$out/tree" patch -s -p1 < "$here/learn-git-branching/learn-git-branching-fredygames.patch" node "$yarndir/package/bin/yarn.js" install --frozen-lockfile --ignore-scripts --non-interactive --cache-folder "$cache/yarn" > "$out/install.log" 2>&1 || { tail -20 "$out/install.log"; exit 1; } node scripts/generate.js > "$out/generate.log" 2>&1 NO_COLOR=1 node_modules/.bin/vite build > "$out/vite.log" 2>&1 || { tail -30 "$out/vite.log"; exit 1; } node scripts/postbuild.js >> "$out/vite.log" 2>&1 [ -s build/index.html ] && [ -d build/assets ] cd build rm -rf generatedDocs assets/biteRead.png assets/waitingFor.png assets/learnGitBranching.png find . -type f \( -name '*.eot' -o -name '*.svg' -o -name '*.ttf' \) -delete if grep -rIlE "googletagmanager|gtag|biteread|waitingfor|twitter\.com|facebook\.com|linkedin\.com|api\.github\.com|learngitbranching\.js\.org|pcottle\.github\.io|threads\.net|git-scm\.com|gtag\(" . >&2; then echo "o build ainda cita um servico de terceiros" >&2; exit 1 fi cd .. { echo "== Learn Git Branching (LICENSE.md do repositorio, MIT)" cat LICENSE.md echo for pkg in events fbjs flux jquery jquery-ui marked object-assign prop-types raphael react react-dom scheduler underscore vite-plugin-node-polyfills; 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)"))" for lf in node_modules/$pkg/[Ll][Ii][Cc]*; do [ -f "$lf" ] && cat "$lf"; done echo done echo "== Font Awesome Free 6.6.0 (src/style/all.min.css, assets/webfonts/*.woff2)" echo "Font Awesome Free 6.6.0 by @fontawesome, https://fontawesome.com. Copyright 2024 Fonticons, Inc. Licence: https://fontawesome.com/license/free" echo "(Icons: Creative Commons Attribution 4.0, https://creativecommons.org/licenses/by/4.0/; Fonts: SIL Open Font License 1.1, copied below; Code: MIT licence)." echo cat "$here/learn-git-branching/ofl-1.1.txt" echo echo "== Font Awesome (version anterior, src/style/font-awesome.css, assets/font/fontawesome-webfont.woff)" echo "Font Awesome by Dave Gandy, http://fortawesome.github.com/Font-Awesome. The webfont, CSS and LESS files are licensed under Creative Commons Attribution 3.0," echo "http://creativecommons.org/licenses/by/3.0/ (the notice 'Font Awesome - http://fortawesome.github.com/Font-Awesome' in the CSS is the attribution)." } > "$out/licenses.txt" cp -R build "$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 > "learn-git-branching-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) du -sh "$out/dist" cd "$out" && rm -rf tree ls -l "$out/learn-git-branching-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "$out/learn-git-branching-${COMMIT:0:7}-dist.tar.gz" "$out/licenses.txt"