IAPL rename: gate checks, and two breaks they found on an unedited 1.16.7 site

- pnpm legacy:site (scripts/legacy-site-check.mjs): the reference site of v1.16.7, unedited, installed against
  this build — old commands, doctor without errors, import map unchanged, tsc, builds with webpack and Turbopack
- test/legacyNameForms.test.ts: the remaining spellings with 'ipal' as a closed list; a new one fails
- found by legacy:site and fixed: 'ipal-tokens --check' called a tokens.css written before 1.17.0 out of date
  (its header names the command); the doctor's env-example rule did not accept IPAL_* in .env.example
- the doctor's seed rules catch IPAL_SEED_ALLOW_FULL=1 as before
- PROGRAMISTA: the new release check

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 17:41:26 +01:00
co-authored by Claude Fable 5.2
parent b91984fbcd
commit 926ba4a67e
11 changed files with 348 additions and 5 deletions
+120
View File
@@ -0,0 +1,120 @@
#!/usr/bin/env node
/**
* pnpm legacy:site — a site written for the last release BEFORE the rename to IAPL works on this build, unedited.
*
* The reference site as it was at a tag (default v1.16.7: `ipalKit()`, `ipal-tokens`, `ipal-doctor.json`, `ipal-*`
* skills, the old pointer block) is unpacked next to the plugin and installed against the plugin built from this
* tree. Nothing in it is changed. Then:
* 1. the old commands run: `ipal-tokens --check`, `ipal-doctor` (no error; the warnings are printed);
* 2. `payload generate:importmap` leaves the committed import map byte for byte as it was;
* 3. `tsc --noEmit`: the old names still type-check;
* 4. a production build with webpack and one with Turbopack.
*
* Needs: the plugin built (`pnpm build`; --skip-plugin-build when dist is current), the tag in the local repository.
* The builds need no database (pages that read it are built on demand), but DATABASE_URI must be set to something.
* Options: --tag=v1.16.7 · --only=webpack|turbopack · --skip-build (steps 1–3 only) · --keep (leave the folder).
* The folder (.legacy-site-<tag>, git-ignored) is removed at the end unless --keep.
*/
import { spawnSync } from 'node:child_process'
import { existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const args = process.argv.slice(2)
const opt = (name, fallback) => args.find((a) => a.startsWith(`--${name}=`))?.slice(name.length + 3) ?? fallback
const tag = opt('tag', 'v1.16.7')
const only = opt('only')
const bundlers = ['webpack', 'turbopack'].filter((b) => !only || b === only)
const site = path.join(root, `.legacy-site-${tag.replace(/[^\w.-]/g, '_')}`)
const env = {
...process.env,
DATABASE_URI: process.env.DATABASE_URI ?? 'mongodb://127.0.0.1:27017/example-studiopl_dev',
NEXT_PUBLIC_SERVER_URL: process.env.NEXT_PUBLIC_SERVER_URL ?? 'http://localhost:3000',
NEXT_TELEMETRY_DISABLED: '1',
PAYLOAD_SECRET: process.env.PAYLOAD_SECRET ?? 'legacy-site-check-secret-0123456789abcdef',
}
const results = []
const sh = (label, command, commandArgs, { capture = false, cwd = site, allowFail = false } = {}) => {
console.log(`\n[legacy:site] ${label}`)
const res = spawnSync(command, commandArgs, { cwd, encoding: 'utf8', env, maxBuffer: 256 * 1024 * 1024, stdio: capture ? ['ignore', 'pipe', 'inherit'] : 'inherit' })
if (res.status !== 0 && !allowFail) {
console.error(`\n[legacy:site] ✗ FAILED: ${label}`)
finish(1)
}
return res
}
const finish = (code) => {
if (!args.includes('--keep')) {rmSync(site, { force: true, recursive: true })}
for (const line of results) {console.log(`[legacy:site] ${line}`)}
process.exit(code)
}
if (spawnSync('git', ['rev-parse', '--verify', '--quiet', `${tag}^{commit}`], { cwd: root }).status !== 0) {
console.error(`[legacy:site] tag ${tag} is not in this repository (git fetch --tags)`)
process.exit(2)
}
if (!args.includes('--skip-plugin-build')) {sh('build the plugin', 'pnpm', ['build'], { cwd: root })}
if (!existsSync(path.join(root, 'dist/index.js'))) {
console.error('[legacy:site] dist/ is missing — run pnpm build')
process.exit(2)
}
rmSync(site, { force: true, recursive: true })
mkdirSync(site, { recursive: true })
// reference/ of the tag, unpacked as a direct child of the plugin root: its "file:.." dependency is this tree.
const archive = spawnSync('sh', ['-c', `git archive ${tag} reference | tar -x --strip-components=1 -C "${site}"`], { cwd: root, stdio: 'inherit' })
if (archive.status !== 0) {finish(1)}
const config = readFileSync(path.join(site, 'src/payload.config.ts'), 'utf8')
if (!/\bipalKit\s*\(/.test(config)) {
console.error(`[legacy:site] ${tag}: the reference site does not call ipalKit() — pick a tag from before 1.17.0`)
finish(2)
}
sh('install the old site against this build', 'pnpm', ['install', '--ignore-workspace', '--no-frozen-lockfile'])
const installed = JSON.parse(readFileSync(path.join(site, 'node_modules/@intecion/ipal-kit/package.json'), 'utf8')).version
results.push(`site of ${tag}, plugin ${installed} from this tree`)
sh('old command: ipal-tokens --check', 'pnpm', ['exec', 'ipal-tokens', '--check'])
results.push('ipal-tokens --check: ok')
const doctor = sh('old command: ipal-doctor (static, offline)', 'pnpm', ['exec', 'ipal-doctor', '.', '--offline', '--json'], { allowFail: true, capture: true })
let report
try {
report = JSON.parse(doctor.stdout)
} catch {
console.error(doctor.stdout)
console.error('[legacy:site] ✗ ipal-doctor did not print JSON')
finish(1)
}
const open = report.findings.filter((f) => !f.silenced)
const count = (severity) => open.filter((f) => f.severity === severity)
for (const f of open.filter((x) => x.severity !== 'info')) {console.log(` ${f.severity}: ${f.rule} — ${f.message}`)}
results.push(`ipal-doctor: ${count('error').length} error(s), ${count('warning').length} warning(s) [${[...new Set(count('warning').map((f) => f.rule))].join(', ')}], ${count('info').length} info [${[...new Set(count('info').map((f) => f.rule))].join(', ')}]`)
if (count('error').length) {
console.error('[legacy:site] ✗ the doctor reports an error on a site that had none')
finish(1)
}
const mapFile = path.join(site, 'src/app/(payload)/admin/importMap.js')
const mapBefore = readFileSync(mapFile, 'utf8')
sh('payload generate:importmap', 'pnpm', ['generate:importmap'])
if (readFileSync(mapFile, 'utf8') !== mapBefore) {
console.error('[legacy:site] ✗ the generated import map differs from the one the old site has committed')
finish(1)
}
results.push('import map: unchanged')
sh('tsc --noEmit (old names against the new types)', 'pnpm', ['typecheck'])
results.push('typecheck: ok')
if (!args.includes('--skip-build')) {
for (const bundler of bundlers) {
rmSync(path.join(site, '.next'), { force: true, recursive: true })
sh(`production build, ${bundler}`, 'pnpm', ['exec', 'cross-env', 'NODE_OPTIONS=--max-old-space-size=3072', 'next', 'build', ...(bundler === 'webpack' ? ['--webpack'] : [])])
results.push(`build (${bundler}): ok`)
}
}
console.log('\n[legacy:site] ✓ the old site works on this build')
finish(0)