- 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]>
65 lines
3.3 KiB
TypeScript
65 lines
3.3 KiB
TypeScript
/**
|
|
* The spellings with `ipal` that are still in the repository, as a closed list.
|
|
*
|
|
* Since 1.17.0 the plugin is IAPL (docs/dev/rename-iapl-plan.md). What keeps the old letters is either
|
|
* a name a site depends on (the package, routes, CSS tokens, `custom.ipal`, context flags, the cookie,
|
|
* the kv key), an alias kept for 1.x, or a test's own scratch name. A NEW name must not be born with the
|
|
* old letters: this test fails when a form appears that is not in test/fixtures/legacyNameForms.json.
|
|
*
|
|
* - meant to write `iapl`? fix the spelling (the two differ by two swapped letters);
|
|
* - a real addition to the list (rare)? UPDATE_LEGACY_FORMS=1 pnpm vitest run test/legacyNameForms.test.ts
|
|
* and say why in the commit.
|
|
*
|
|
* Not searched: past changelog entries, the proposals in docs/dev, the vendored external skills, the
|
|
* lockfiles, the reference site's copy of the skills, and the two tests about the old names.
|
|
*/
|
|
import { execFileSync } from 'node:child_process'
|
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
import { expect, test } from 'vitest'
|
|
|
|
const root = path.resolve(import.meta.dirname, '..')
|
|
const FIXTURE = path.join(root, 'test/fixtures/legacyNameForms.json')
|
|
const SKIP = /^docs\/CHANGELOG\.md$|^docs\/dev\/.*proposal\.md$|^docs\/dev\/rename-iapl-plan\.md$|^docs\/agent\/external\/|pnpm-lock\.yaml$|package-lock\.json$|^reference\/\.agents\/|^test\/legacyName|^test\/fixtures\/legacyNameForms\.json$/
|
|
const TEXT = /\.(?:md|ts|tsx|mjs|js|json|css|scss|sh|yml|yaml|html|txt)$|^[^.]+$|\/Dockerfile$|\.npmrc$|\.env\.example$/
|
|
|
|
/** Families counted as one form: design tokens, data hooks, element ids and scratch names with a varying tail. */
|
|
const FAMILIES: Array<[RegExp, string]> = [
|
|
[/^--ipal-/, '--ipal-*'],
|
|
[/^data-ipal/, 'data-ipal*'],
|
|
[/^ipal-test-/, 'ipal-test-*'],
|
|
[/^ipal-stats/, 'ipal-stats*'],
|
|
[/^ipal-badge/, 'ipal-badge*'],
|
|
[/^ipal-f-/, 'ipal-f-*'],
|
|
[/^ipal-consent-/, 'ipal-consent-*'],
|
|
[/^ipal-two-factor-/, 'ipal-two-factor-*'],
|
|
[/^ipal-ext-/, 'ipal-ext-*'],
|
|
[/^ipal-starter-gate-/, 'ipal-starter-gate-*'],
|
|
]
|
|
|
|
function forms(): string[] {
|
|
const files = execFileSync('git', ['ls-files', '-z'], { cwd: root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 }).split('\0').filter((f) => f && !SKIP.test(f) && TEXT.test(f))
|
|
const found = new Set<string>()
|
|
for (const file of files) {
|
|
const full = path.join(root, file)
|
|
if (!existsSync(full)) {continue}
|
|
for (const m of readFileSync(full, 'utf8').matchAll(/[\w-]*ipal[\w-]*/gi)) {
|
|
found.add(FAMILIES.find(([pattern]) => pattern.test(m[0]))?.[1] ?? m[0])
|
|
}
|
|
}
|
|
return [...found].sort()
|
|
}
|
|
|
|
test('no new name carries the old spelling', () => {
|
|
const now = forms()
|
|
if (process.env.UPDATE_LEGACY_FORMS === '1') {writeFileSync(FIXTURE, `${JSON.stringify(now, null, 2)}\n`)}
|
|
const allowed = JSON.parse(readFileSync(FIXTURE, 'utf8')) as string[]
|
|
expect(now.filter((form) => !allowed.includes(form)), 'new forms with "ipal" — see the comment at the top of this test').toEqual([])
|
|
})
|
|
|
|
test('the list holds nothing that is gone', () => {
|
|
const now = forms()
|
|
const allowed = JSON.parse(readFileSync(FIXTURE, 'utf8')) as string[]
|
|
expect(allowed.filter((form) => !now.includes(form)), 'forms no longer in the repository — remove them from the list').toEqual([])
|
|
})
|