Files
ipal-kit/scripts/routes-check.mjs
T
Radosław SmolińskiandClaude Opus 5.5 2468390538 Outside-in tests (IAWL ideas 33, 34): closed doors on the built site as anonymous, customer and editor; every public route judged
- reference/e2e/closed-doors.ts + closed-doors.spec.ts: one table of doors, asked by pnpm e2e:built in both bundlers;
  doors still open while the owner decides are asserted open (test.fail) with their question
- listPublicRoutes / listNextRouteFiles / compareRouteSnapshot / updateRouteSnapshot (main entry), runRouteCheck (/doctor)
- reference/e2e/routes.ts + routes.snapshot.json (395 routes, one reason each); pnpm routes:check [--update], first step of e2e:built
- create-test-admin.ts makes an editor test account
- docs: security.md sections, AGENT.md 8a, iapl-audit templates, iapl-upgrade 1.17.1, changelog draft

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 20:26:30 +01:00

24 lines
1.6 KiB
JavaScript

#!/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)