#!/usr/bin/env node /** * pnpm routes:check — every public route of the reference site (REST, GraphQL, Next route files) against the judged * list reference/e2e/routes.snapshot.json (docs/security.md "Routes nobody has judged"). Fails on a route nobody * has judged and on an entry without a reason; reads the config only, never the database. * pnpm routes:check the check (also the first step of pnpm e2e:built) * pnpm routes:check --update after a Payload or plugin upgrade: new routes are added with an EMPTY reason (the * check fails until somebody writes one), gone ones dropped; review the diff * Needs the reference site installed (pnpm install --ignore-workspace in reference/) with a current plugin copy * (pnpm build first), and reference/.env (the config reads it; nothing connects). * The test fixtures (E2E_LATE_STAFF, E2E_MAIL_RELAY_URL) are switched off: the list is the site's, not the tests'. */ import { spawnSync } from 'node:child_process' import path from 'node:path' import { fileURLToPath } from 'node:url' const site = path.join(path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'), 'reference') const update = process.argv.slice(2).includes('--update') const env = { ...process.env } for (const fixture of ['E2E_LATE_STAFF', 'E2E_MAIL_RELAY_URL', 'E2E_DEVELOPMENT_HOSTS']) {delete env[fixture]} // `payload run` drops --flags (minimist), so the script takes the word `update` const result = spawnSync('pnpm', ['payload', 'run', 'e2e/routes.ts', ...(update ? ['update'] : [])], { cwd: site, env, stdio: 'inherit' }) process.exit(result.status ?? 1)