#!/bin/sh # Build everything the browser harness serves, into harness/serve/. # # harness/serve/ the assembled site, exactly as `web/assemble.sh` # produces it for GitHub Pages # harness/serve/opfs/ this harness's own page, worker and wasm bundle # # One server root, so Playwright runs one `python3 -m http.server`. The site # half is the *deployed* arrangement rather than `web/` itself, because a # harness that runs against a different tree from the one that ships is # testing something nobody deploys (improvise-vvl3). # # Re-run THIS script, never `web/assemble.sh harness/serve` alone: assembling # starts with `rm -rf` of its output, which deletes opfs/ and the fixtures # (improvise-mkbp). opfs.spec.js says so if it finds opfs/ missing. set -eu root=$(cd "$(dirname "$0")/.." && pwd) serve="$root/harness/serve" # A stale opfs-contract/Cargo.lock fails HERE rather than being rewritten in # every agent's tree (improvise-mkbp). wasm-pack cannot enforce this: it # re-resolves the lock itself before any `-- --locked` reaches cargo build. # Fix a failure with `cargo update -w` in harness/opfs-contract, and commit it. cargo metadata --locked --format-version 1 \ --manifest-path "$root/harness/opfs-contract/Cargo.toml" >/dev/null || { echo "harness/build.sh: harness/opfs-contract/Cargo.lock is stale. Do not remove --locked." >&2 echo " Run: cargo update -w --manifest-path harness/opfs-contract/Cargo.toml, and commit the lock." >&2 exit 1 } "$root/web/build.sh" >/dev/null "$root/web/assemble.sh" "$serve" harness >/dev/null # The harness's own documents, beside the shipped one. `web/demo.improv` is # the front page and stays as it is (gotcha 46); a grouped, multi-level model # is the only way to reach the header-level, group-span and collapse paths # `improvise-anr9` added (improvise-plcx). A seed that 404s is NOT an error -- # worker.js answers it with an empty model -- so every spec over these asserts # real labels rather than that a grid exists. cp -f "$root"/harness/fixtures/*.improv "$serve/app/" wasm-pack build "$root/harness/opfs-contract" \ --target web --out-dir "$root/harness/www/opfs/pkg" mkdir -p "$serve/opfs" cp -f "$root/harness/www/opfs/index.html" "$root/harness/www/opfs/worker.js" "$serve/opfs/" cp -rf "$root/harness/www/opfs/pkg" "$serve/opfs/pkg" rm -f "$serve/opfs/pkg/.gitignore" "$serve/opfs/pkg/package.json" echo "harness/serve ready"