#!/usr/bin/env bash # Builds https://policy.did.bot into policy-site/dist/, ready to sync to a # bucket. It never touches AWS: scripts/publish-policy-site.sh calls this and # then does the upload. # # The page checks a policy with wasm that scripts/build-policy-wasm.sh writes # into policy-site/public/wasm/, and draws its background with wasm that # scripts/build-policy-anim-wasm.sh writes beside it. Vite copies that # directory into the build untouched, so both run first. The tests run last, against the built tree; among them, # policy-site/tests/check-csp.mjs holds it to the CSP in # infra/policy-site/main.tf. # # Usage: scripts/build-policy-site.sh set -euo pipefail cd "$(dirname "$0")/.." if [ "$#" -ne 0 ]; then echo "usage: $0" >&2 exit 2 fi for script in scripts/build-policy-wasm.sh scripts/build-policy-anim-wasm.sh; do if [ ! -f "$script" ]; then echo "build-policy-site: $script is missing." >&2 echo " It builds wasm the page loads, and the page is not built without it." >&2 exit 1 fi done if ! command -v npm >/dev/null 2>&1; then echo "build-policy-site: npm is required (policy-site/ is a Vite project) and was not found" >&2 exit 1 fi echo "=== build-policy-wasm: the policy check the page runs ===" >&2 scripts/build-policy-wasm.sh echo "=== build-policy-anim-wasm: the lattice behind the page ===" >&2 scripts/build-policy-anim-wasm.sh echo "=== npm ci: policy-site/'s locked dependencies ===" >&2 (cd policy-site && npm ci) echo "=== vite build ===" >&2 (cd policy-site && npm run build) echo "=== policy-site/tests ===" >&2 (cd policy-site && npm test) echo "build-policy-site: done — policy-site/dist/ is ready to publish" >&2