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
+4 -2
View File
@@ -1,6 +1,7 @@
import type { DoctorRule, RuleFinding } from '../types.js'
import { databaseNameFromUri, databaseNamesFor } from '../../env/databaseName.js'
import { legacyEnvName } from '../../shared/envName.js'
import { configFile } from '../project.js'
import { stripComments } from '../util.js'
@@ -77,12 +78,13 @@ export const envRules: DoctorRule[] = [
const want = ['DATABASE_URI', 'PAYLOAD_SECRET', 'NEXT_PUBLIC_SERVER_URL', 'IAPL_IP_HEADER']
if (/buildR2Storage/.test(cfg) && !ctx.auditSkips.has('r2')) {want.push('R2_BUCKET', 'R2_ENDPOINT', 'R2_ACCESS_KEY_ID', 'R2_SECRET_ACCESS_KEY', 'R2_PUBLIC_URL')}
if (/cookieScanner\s*:\s*\{[^}]*\bcrawl\s*:\s*(?!false)/.test(cfg)) {want.push('IAPL_COOKIE_SCAN_URL', 'IAPL_COOKIE_SCAN_TOKEN')}
const missing = want.filter((v) => !(v in ctx.env.example!))
// a plugin variable under its spelling from before 1.17.0 (IPAL_…) is there too
const missing = want.filter((v) => !(v in ctx.env.example!) && !((legacyEnvName(v) ?? v) in ctx.env.example!))
if (missing.length) {out.push({ file: '.env.example', fix: 'add the names (empty or placeholder values)', message: `.env.example lacks ${missing.join(', ')}`, severity: 'warning' })}
// A real-looking credential in a committed file.
const creds = (ctx.env.example.DATABASE_URI ?? '').match(/^[a-z+]+:\/\/([^@/]+)@/i)?.[1]
if (creds && !PLACEHOLDER.test(creds)) {out.push({ file: '.env.example', fix: 'replace with USER:PASS', message: 'DATABASE_URI in .env.example carries credentials', severity: 'error' })}
for (const key of ['PAYLOAD_SECRET', 'R2_SECRET_ACCESS_KEY', 'GRAPH_CLIENT_SECRET', 'IAPL_DOCTOR_TOKEN']) {
for (const key of ['PAYLOAD_SECRET', 'R2_SECRET_ACCESS_KEY', 'GRAPH_CLIENT_SECRET', 'IAPL_DOCTOR_TOKEN', 'IPAL_DOCTOR_TOKEN']) {
const value = ctx.env.example[key]
if (value && value.length >= 16 && !PLACEHOLDER.test(value)) {out.push({ file: '.env.example', fix: `leave ${key} empty`, message: `${key} in .env.example has a value`, severity: 'error' })}
}
+2 -2
View File
@@ -32,7 +32,7 @@ export const seedRules: DoctorRule[] = [
for (const [name, command] of Object.entries(ctx.pkg.scripts ?? {})) {
if (!/seed/i.test(name)) {continue}
if (/fresh|reset/i.test(name)) {out.push({ file: 'package.json', fix: 'remove it — seeds never delete (seeding.md)', message: `script "${name}" re-creates content from scratch`, severity: 'error' })}
if (/IAPL_SEED_ALLOW_FULL=1/.test(command)) {out.push({ file: 'package.json', fix: 'set IAPL_SEED_ALLOW_FULL=1 by hand for one run, only with the owner\'s OK', message: `script "${name}" switches the full-seed guard off`, severity: 'error' })}
if (/I(?:AP|PA)L_SEED_ALLOW_FULL=1/.test(command)) {out.push({ file: 'package.json', fix: 'set IAPL_SEED_ALLOW_FULL=1 by hand for one run, only with the owner\'s OK', message: `script "${name}" switches the full-seed guard off`, severity: 'error' })}
const entry = command.match(/(?:^|\s)([\w./@-]+\.[cm]?[jt]s)(?:\s|$)/)?.[1]?.replace(/^\.\//, '')
if (!entry) {continue}
if (!ctx.exists(entry)) {out.push({ file: 'package.json', message: `script "${name}" runs ${entry}, which does not exist`, severity: 'warning' }); continue}
@@ -45,7 +45,7 @@ export const seedRules: DoctorRule[] = [
if (ctx.launched && /createSeeder\s*\(/.test(code) && !/\bonly\s*:/.test(code)) {out.push({ file: entry, fix: 'run it with SEED_ONLY="pages:<slug>,global:<slug>" or pass only: [...] (seeding.md → after launch)', message: `script "${name}" has no record list — after launch every run needs SEED_ONLY`, severity: 'warning' })}
}
for (const file of ['.env.example', '.env.production']) {
if (/^\s*IAPL_SEED_ALLOW_FULL\s*=\s*1/m.test(ctx.read(file))) {out.push({ file, message: `${file} sets IAPL_SEED_ALLOW_FULL=1`, severity: 'error' })}
if (/^\s*I(?:AP|PA)L_SEED_ALLOW_FULL\s*=\s*1/m.test(ctx.read(file))) {out.push({ file, message: `${file} sets IAPL_SEED_ALLOW_FULL=1`, severity: 'error' })}
}
return out
},
+5 -1
View File
@@ -46,6 +46,9 @@ async function loadTokens(file: string): Promise<TokensInput> {
}
}
/** The two header lines of a generated file that name the command (`ipal-tokens` before 1.17.0). */
const LEGACY_HEADER = /^ \* (?:GENERATED by `ipal-tokens` from|`pnpm exec ipal-tokens`\.) .*$/gm
/** The `iapl-tokens` command. Returns the exit code. */
export async function runTokensCli(args: string[], { cwd = process.cwd(), log = (line: string) => process.stdout.write(`${line}\n`) }: { cwd?: string; log?: Log } = {}): Promise<number> {
if (args.includes('--help') || args.includes('-h')) {
@@ -64,7 +67,8 @@ export async function runTokensCli(args: string[], { cwd = process.cwd(), log =
const current = existsSync(output) ? readFileSync(output, 'utf8') : null
let code = 0
if (args.includes('--check')) {
if (current !== css) {
// A file written before 1.17.0 names the command `ipal-tokens` in its header: the same tokens, not out of date.
if (current !== css && current?.replace(LEGACY_HEADER, (line) => line.replace('ipal-tokens', 'iapl-tokens')) !== css) {
log(`✗ ${relative(cwd, output)} is out of date — run \`pnpm exec iapl-tokens\``)
code = 1
} else {log(`✓ ${relative(cwd, output)} is up to date`)}