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:
co-authored by
Claude Fable 5.2
parent
b91984fbcd
commit
926ba4a67e
@@ -194,6 +194,20 @@ describe('iapl-tokens CLI', () => {
|
||||
expect(lines.join('\n')).toMatch(/out of date/)
|
||||
})
|
||||
|
||||
test('a file generated before 1.17.0 (header names `ipal-tokens`) is up to date; a changed value is not', async () => {
|
||||
writeFileSync(path.join(dir, 'tokens.json'), JSON.stringify({ color: { light: { primary: '#1d4ed8' } } }))
|
||||
const args = ['--in', 'tokens.json', '--out', 'out/tokens.css']
|
||||
expect(await runTokensCli(args, { cwd: dir, log })).toBe(0)
|
||||
const file = path.join(dir, 'out/tokens.css')
|
||||
const old = readFileSync(file, 'utf8').replaceAll('iapl-tokens', 'ipal-tokens')
|
||||
expect(old).toContain('GENERATED by `ipal-tokens`')
|
||||
writeFileSync(file, old)
|
||||
expect(await runTokensCli([...args, '--check'], { cwd: dir, log })).toBe(0)
|
||||
expect(readFileSync(file, 'utf8')).toBe(old) // --check writes nothing
|
||||
writeFileSync(file, old.replace('#1d4ed8', '#000000'))
|
||||
expect(await runTokensCli([...args, '--check'], { cwd: dir, log })).toBe(1)
|
||||
})
|
||||
|
||||
test('fails on a contrast error unless --warn-only', async () => {
|
||||
writeFileSync(path.join(dir, 'tokens.json'), JSON.stringify({ color: { light: { primary: '#ffeb3b' } } }))
|
||||
const args = ['--in', 'tokens.json', '--out', 'tokens.css']
|
||||
|
||||
Vendored
+113
@@ -0,0 +1,113 @@
|
||||
[
|
||||
"--ipal-*",
|
||||
"2Fipal-kit",
|
||||
"IPAL",
|
||||
"IPAL_",
|
||||
"IPAL_BREAKPOINTS",
|
||||
"IPAL_COOKIE_SCAN_TOKEN",
|
||||
"IPAL_COOKIE_SCAN_URL",
|
||||
"IPAL_COPY_BASELINE",
|
||||
"IPAL_CRAWLER_SITES",
|
||||
"IPAL_DEV_2FA",
|
||||
"IPAL_DOCTOR_IMPORT_MAP",
|
||||
"IPAL_DOCTOR_TOKEN",
|
||||
"IPAL_IP_HEADER",
|
||||
"IPAL_NOINDEX",
|
||||
"IPAL_SEED_ALLOW_FULL",
|
||||
"IPAL_SEED_ALLOW_PROD_UPDATE",
|
||||
"IPAL_TEST_MONGO_URI",
|
||||
"IPAL_TEST_POSTGRES_URI",
|
||||
"IPAL_TEST_SHAPE",
|
||||
"IPAL_TOKENS",
|
||||
"IpalEnvFeatures",
|
||||
"IpalGlobalSlug",
|
||||
"IpalOptions",
|
||||
"IpalTokenName",
|
||||
"X-Ipal-Cookie-Crawler",
|
||||
"__ipal-other__",
|
||||
"__ipal-outsider__",
|
||||
"_ipalSyncingCrossLocale",
|
||||
"data-ipal*",
|
||||
"ipal",
|
||||
"ipal-",
|
||||
"ipal-a",
|
||||
"ipal-audit-skip",
|
||||
"ipal-b",
|
||||
"ipal-badge*",
|
||||
"ipal-bar",
|
||||
"ipal-blocks",
|
||||
"ipal-consent-*",
|
||||
"ipal-cookie-approval",
|
||||
"ipal-cookie-crawler",
|
||||
"ipal-cookie-scan",
|
||||
"ipal-cookie-scan-names",
|
||||
"ipal-cs-",
|
||||
"ipal-doctor",
|
||||
"ipal-eject-",
|
||||
"ipal-ext-*",
|
||||
"ipal-f-*",
|
||||
"ipal-forms-mailbox",
|
||||
"ipal-graph",
|
||||
"ipal-group",
|
||||
"ipal-importmap-",
|
||||
"ipal-kit",
|
||||
"ipal-kit-",
|
||||
"ipal-label",
|
||||
"ipal-lightbox-caption",
|
||||
"ipal-linkedin-insight",
|
||||
"ipal-locale",
|
||||
"ipal-mail-dispatcher",
|
||||
"ipal-old",
|
||||
"ipal-pad",
|
||||
"ipal-panel-smtp",
|
||||
"ipal-polish-",
|
||||
"ipal-primary",
|
||||
"ipal-release",
|
||||
"ipal-row",
|
||||
"ipal-safe-back",
|
||||
"ipal-sandbox",
|
||||
"ipal-second-factor-guard",
|
||||
"ipal-sites-",
|
||||
"ipal-skills",
|
||||
"ipal-starter-gate-*",
|
||||
"ipal-stats*",
|
||||
"ipal-test-*",
|
||||
"ipal-theme",
|
||||
"ipal-tokens",
|
||||
"ipal-tokens-not-installed",
|
||||
"ipal-totp-view",
|
||||
"ipal-two-factor-*",
|
||||
"ipal-value",
|
||||
"ipalAccountRules",
|
||||
"ipalAccounts",
|
||||
"ipalBlock",
|
||||
"ipalCookieApproval",
|
||||
"ipalCookieReview",
|
||||
"ipalCookieScan",
|
||||
"ipalCookieSiteCheck",
|
||||
"ipalEnvRules",
|
||||
"ipalFillLocales",
|
||||
"ipalFirstRegister",
|
||||
"ipalFirstUser",
|
||||
"ipalFormFiles",
|
||||
"ipalIntegrationStatus",
|
||||
"ipalKit",
|
||||
"ipalLibrary",
|
||||
"ipalMigration",
|
||||
"ipalSafeBack",
|
||||
"ipalSeed",
|
||||
"ipalSkipAutoFill",
|
||||
"ipalSkipIndexNow",
|
||||
"ipalStats",
|
||||
"ipalT",
|
||||
"ipalTestBoundary",
|
||||
"ipalTotpClientProps",
|
||||
"ipalTotpView",
|
||||
"ipalVar",
|
||||
"ipalWriteOnly",
|
||||
"ipal_vid",
|
||||
"missing-forms-in-ipalkit",
|
||||
"missing-ipal-ip-header-in-env-example",
|
||||
"names-iapl-and-ipal-kit",
|
||||
"nav-ipal-stats"
|
||||
]
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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([])
|
||||
})
|
||||
@@ -199,6 +199,22 @@ describe('the doctor on a project that was not touched', () => {
|
||||
expect((await run(dir, ['legacy-names'])).findings.filter((f) => f.severity === 'warning')).toEqual([])
|
||||
})
|
||||
|
||||
test('IPAL_* names in .env.example satisfy env-example; IPAL_SEED_ALLOW_FULL=1 is still caught', async () => {
|
||||
const example = 'DATABASE_URI=\nPAYLOAD_SECRET=\nNEXT_PUBLIC_SERVER_URL=\nIPAL_IP_HEADER=\nIPAL_COOKIE_SCAN_URL=\nIPAL_COOKIE_SCAN_TOKEN=\n'
|
||||
const config = "export default { plugins: [ipalKit({ cookieScanner: { crawl: true } })] }\n"
|
||||
const ok = site({ '.env.example': example, 'src/payload.config.ts': config })
|
||||
expect((await run(ok, ['env-example'])).findings.filter((f) => f.rule === 'env-example')).toEqual([])
|
||||
const bad = site({
|
||||
'.env.example': `${example}IPAL_SEED_ALLOW_FULL=1\nIPAL_DOCTOR_TOKEN=0123456789abcdef0123456789abcdef\n`,
|
||||
'package.json': { name: 'x', scripts: { 'seed:all': 'IPAL_SEED_ALLOW_FULL=1 payload run src/seed/index.ts' } },
|
||||
'src/payload.config.ts': config,
|
||||
})
|
||||
const messages = (await run(bad, ['env-example', 'seed-named'])).findings.map((f) => f.message).join('\n')
|
||||
expect(messages).toMatch(/IPAL_DOCTOR_TOKEN in \.env\.example has a value/)
|
||||
expect(messages).toMatch(/\.env\.example sets IAPL_SEED_ALLOW_FULL=1/)
|
||||
expect(messages).toMatch(/script "seed:all" switc/)
|
||||
})
|
||||
|
||||
test('storage-names: the cookie the page sets must be the one the scanner declares', async () => {
|
||||
const layout = (props: string) => `import { PageStats } from '@intecion/ipal-kit/client'\nexport default function L() { return <PageStats ${props} /> }\n`
|
||||
const config = (names: string) => `import { iapl } from '@intecion/ipal-kit'\nexport default { plugins: [iapl({ ${names} })] }\n`
|
||||
|
||||
Reference in New Issue
Block a user