Queue-North-Website/scripts/verify.d/10-build

31 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# The build, which is the only gate this project actually has.
#
# There is no test runner and no typecheck here — no vitest, no jest, no
# tsconfig, and every source file is plain .jsx. `verify.sh` therefore detects
# nothing at all from package.json, whose script names are dev/build/preview/
# start/docker:*, and would exit 2 ("nothing was verified") on a project that
# does have something worth checking.
#
# So this is that something, named honestly. `npm run build` is three steps —
# the client bundle, the SSR bundle, then scripts/prerender.js across every
# route — and it fails on a broken import, a missing asset, a syntax error, or a
# route that cannot be rendered to static HTML. That last one is worth more than
# it sounds: prerendering exercises every page component in Node, which is the
# closest thing this repository has to running its own UI.
#
# What it does NOT do is check behaviour. A form that posts to the wrong URL
# builds perfectly. Do not read a green row here as "the site works".
#
# Exit 0 built, 1 did not.
set -uo pipefail
cd "$(git rev-parse --show-toplevel)" || exit 1
if ! command -v npm >/dev/null 2>&1; then
echo "build: npm is not on PATH — this guard did not run." >&2
exit 1
fi
npm run build