#!/bin/sh set -eu [ -z "${WEB_CMD:-}" ] && [ "$WEB_BIN" = "$WEB_BUILT" ] || exit 0 web=$TNGL_ROOT/web data=$TNGL_STATE/data/web mkdir -p "$data" # the ghstub client id and secret have to match make-certs.sh and github-stub if [ ! -s "$TNGL_CERTS/github.env" ]; then secret=$(head -c 24 /dev/urandom | od -An -tx1 | tr -d ' \n') printf 'GITHUB_CLIENT_ID=ghstub-client-id\nGITHUB_CLIENT_SECRET=ghstub-client-secret\nGITHUB_SESSION_SECRET=%s\nGITHUB_APP_SLUG=tangled-dev-stub\n' "$secret" > "$TNGL_CERTS/github.env" fi # fonts and logos only exist as a nix package, and web-hash covers web/static so a change rebuilds static=$(cd "$TNGL_ROOT" && nix build .#web-static-files --no-link --print-out-paths) if [ "$(cat "$data/static" 2>/dev/null || true)" != "$static" ] || [ ! -d "$web/static/fonts" ]; then mkdir -p "$web/static" rm -rf "$web/static/fonts" "$web/static/logos" cp -fr --no-preserve=ownership,mode "$static"/* "$web/static" echo "$static" > "$data/static" fi want="$(node "$TNGL_ROOT/e2e/harness/web-hash.ts") $(cksum < "$TNGL_PC/services/web/web.env" | cut -d ' ' -f 1)" [ "$(cat "$data/built" 2>/dev/null || true)" != "$want" ] || { patch-workerd "$web"; exit 0; } set -a . "$TNGL_PC/services/web/web.env" set +a cd "$web" corepack pnpm install --frozen-lockfile patch-workerd "$web" "$WEB_BIN" build echo "$want" > "$data/built"