IAPL rename, scripted: preferred names in src, bin, scripts, services, tests; bin files and skill folders moved
Replaced by an explicit list of forms only (ten exported names, runtime env names, project file names and marks, commands, skill names, the log prefix, the brand in prose). Package name, import paths, routes, CSS tokens, data attributes, custom keys, context flags, the cookie and kv keys are not touched. package.json keeps the five old bin names beside the five new ones. The old names stop working in this commit and come back as aliases in the next; docs follow. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
414a4702df
commit
0a4f001797
+29
-29
@@ -21,7 +21,7 @@ let dirs: string[] = []
|
||||
|
||||
/** A project folder from a { path: content } map; package.json objects are serialised. */
|
||||
function project(files: Record<string, object | string>): string {
|
||||
const root = mkdtempSync(path.join(tmpdir(), 'ipal-doctor-'))
|
||||
const root = mkdtempSync(path.join(tmpdir(), 'iapl-doctor-'))
|
||||
dirs.push(root)
|
||||
for (const [rel, content] of Object.entries(files)) {
|
||||
const file = path.join(root, rel)
|
||||
@@ -154,18 +154,18 @@ describe('M1 rules: access-missing, turnstile-degraded, turnstile-env-key', () =
|
||||
const run = async (config: string, only: string[], deepStatus?: object) =>
|
||||
rules(await doctor(project({ ...base(), 'src/payload.config.ts': config }), only, deepStatus ? { deepStatus } : {}))
|
||||
|
||||
test('access-missing: ipalKit without `access` means every account is an admin', async () => {
|
||||
expect(await run("plugins: [ipalKit({ i18n, twoFactor: { issuer: 'A', plugin: payloadTotp } })]", ['access-missing'])).toEqual(['access-missing:warning'])
|
||||
test('access-missing: iapl without `access` means every account is an admin', async () => {
|
||||
expect(await run("plugins: [iapl({ i18n, twoFactor: { issuer: 'A', plugin: payloadTotp } })]", ['access-missing'])).toEqual(['access-missing:warning'])
|
||||
// a collection's own access rules are not the plugin option
|
||||
expect(await run("collections: [{ slug: 'pages', access: { read: () => true } }], plugins: [ipalKit({ i18n })]", ['access-missing'])).toEqual(['access-missing:warning'])
|
||||
for (const ok of ["ipalKit({ access: { authCollection: 'users' }, i18n })", "ipalKit({ i18n, access: { defaultRole: 'editor' } })", 'ipalKit({ access: {}, i18n })', 'ipalKit({ access: accessOptions, i18n })', '// no plugin here']) {
|
||||
expect(await run("collections: [{ slug: 'pages', access: { read: () => true } }], plugins: [iapl({ i18n })]", ['access-missing'])).toEqual(['access-missing:warning'])
|
||||
for (const ok of ["iapl({ access: { authCollection: 'users' }, i18n })", "iapl({ i18n, access: { defaultRole: 'editor' } })", 'iapl({ access: {}, i18n })', 'iapl({ access: accessOptions, i18n })', '// no plugin here']) {
|
||||
expect([ok, await run(`plugins: [${ok}]`, ['access-missing'])]).toEqual([ok, []])
|
||||
}
|
||||
})
|
||||
|
||||
test('turnstile-degraded: a warning, an error after a day', async () => {
|
||||
const at = (hoursAgo: number) => new Date(Date.parse(`${TODAY}T12:00:00Z`) - hoursAgo * 3_600_000).toISOString()
|
||||
const cfg = "ipalKit({ access: { authCollection: 'users' } })"
|
||||
const cfg = "iapl({ access: { authCollection: 'users' } })"
|
||||
expect(await run(cfg, ['turnstile-degraded'], { turnstile: { code: 'invalid-input-secret', since: at(2), state: 'degraded' } })).toEqual(['turnstile-degraded:warning'])
|
||||
expect(await run(cfg, ['turnstile-degraded'], { turnstile: { code: 'invalid-input-secret', since: at(48), state: 'degraded' } })).toEqual(['turnstile-degraded:error'])
|
||||
expect(await run(cfg, ['turnstile-degraded'], { turnstile: { state: 'degraded' } })).toEqual(['turnstile-degraded:warning'])
|
||||
@@ -180,7 +180,7 @@ describe('M1 rules: access-missing, turnstile-degraded, turnstile-env-key', () =
|
||||
})
|
||||
|
||||
test('turnstile-env-key: the secret still comes from the environment', async () => {
|
||||
const cfg = "ipalKit({ access: { authCollection: 'users' } })"
|
||||
const cfg = "iapl({ access: { authCollection: 'users' } })"
|
||||
expect(await run(cfg, ['turnstile-env-key'], { turnstileSecretFromEnv: true })).toEqual(['turnstile-env-key:warning'])
|
||||
expect(await run(cfg, ['turnstile-env-key'], { turnstileSecretFromEnv: false })).toEqual([])
|
||||
expect(await run(cfg, ['turnstile-env-key'])).toEqual([])
|
||||
@@ -189,14 +189,14 @@ describe('M1 rules: access-missing, turnstile-degraded, turnstile-env-key', () =
|
||||
test('csrf-empty: without serverURL and csrf Payload takes the login cookie from any origin', async () => {
|
||||
// the word is spelled in two parts: test/testConfig.test.ts refuses test files that name Payload's config builder
|
||||
const build = (body: string) => `export default ${'build'}${'Config'}(${body})`
|
||||
expect(await run(build("{ plugins: [ipalKit({ access: { authCollection: 'users' } })] }"), ['csrf-empty'])).toEqual(['csrf-empty:warning'])
|
||||
expect(await run(build("{ plugins: [iapl({ access: { authCollection: 'users' } })] }"), ['csrf-empty'])).toEqual(['csrf-empty:warning'])
|
||||
expect(await run(build('{ serverURL: process.env.NEXT_PUBLIC_SERVER_URL, plugins: [] }'), ['csrf-empty'])).toEqual([])
|
||||
expect(await run(build("{ csrf: ['https://site.example'], plugins: [] }"), ['csrf-empty'])).toEqual([])
|
||||
expect(await run('// not a Payload config', ['csrf-empty'])).toEqual([])
|
||||
})
|
||||
|
||||
test('open-signup: an auth collection anyone can register in is said, as info', async () => {
|
||||
const cfg = "ipalKit({ access: { authCollection: 'users' } })"
|
||||
const cfg = "iapl({ access: { authCollection: 'users' } })"
|
||||
expect(await run(cfg, ['open-signup'], { openSignUp: ['customers', 'members'] })).toEqual(['open-signup:info', 'open-signup:info'])
|
||||
expect(await run(cfg, ['open-signup'], { openSignUp: [] })).toEqual([])
|
||||
expect(await run(cfg, ['open-signup'], { openSignUp: null })).toEqual([])
|
||||
@@ -204,7 +204,7 @@ describe('M1 rules: access-missing, turnstile-degraded, turnstile-env-key', () =
|
||||
})
|
||||
|
||||
test('staff-accounts-open: a staff collection an account of another collection may write to is an error', async () => {
|
||||
const cfg = "ipalKit({ access: { authCollection: 'users' } })"
|
||||
const cfg = "iapl({ access: { authCollection: 'users' } })"
|
||||
expect(await run(cfg, ['staff-accounts-open'], { staffOpenToOthers: ['agents:delete', 'agents:update', 'users:create'] })).toEqual(['staff-accounts-open:error', 'staff-accounts-open:error', 'staff-accounts-open:error'])
|
||||
expect(await run(cfg, ['staff-accounts-open'], { staffOpenToOthers: ['agents:read', 'agents:unlock'] })).toEqual(expect.arrayContaining(['staff-accounts-open:warning', 'staff-accounts-open:error']))
|
||||
expect(await run(cfg, ['staff-own-roles'], { staffOnOwnRoles: ['crew'] })).toEqual(['staff-own-roles:warning'])
|
||||
@@ -237,7 +237,7 @@ describe('helpers', () => {
|
||||
expect(parseEnvFile('# c\nA=1\nexport B="two"\n C = \'3\'\nbad line')).toEqual({ A: '1', B: 'two', C: '3' })
|
||||
})
|
||||
test('readAuditSkips maps keys to the reason', () => {
|
||||
const skips = readAuditSkips('- ipal-audit-skip: mcp, twofactor — client decision 2026-10-01\n')
|
||||
const skips = readAuditSkips('- iapl-audit-skip: mcp, twofactor — client decision 2026-10-01\n')
|
||||
expect(skips.get('mcp')).toBe('client decision 2026-10-01')
|
||||
expect(skips.get('twofactor')).toBe('client decision 2026-10-01')
|
||||
})
|
||||
@@ -250,7 +250,7 @@ describe('helpers', () => {
|
||||
expect(globToRegExp('src/*.ts').test('src/a/b.ts')).toBe(false)
|
||||
})
|
||||
test('parseToolOutput reads the [LEVEL] title (n) — rule blocks of audit.sh and seo-check', () => {
|
||||
const lines = parseToolOutput('ipal-audit\n\n[ERROR] hex colors in classes (2) — §6.11 tokens\n src/a.tsx:1: bg-[#fff]\n src/b.tsx:2: x\n[INFO] note — fine\n')
|
||||
const lines = parseToolOutput('iapl-audit\n\n[ERROR] hex colors in classes (2) — §6.11 tokens\n src/a.tsx:1: bg-[#fff]\n src/b.tsx:2: x\n[INFO] note — fine\n')
|
||||
expect(lines).toEqual([
|
||||
{ items: ['src/a.tsx:1: bg-[#fff]', 'src/b.tsx:2: x'], level: 'error', rule: '§6.11 tokens', title: 'hex colors in classes' },
|
||||
{ items: [], level: 'info', rule: 'fine', title: 'note' },
|
||||
@@ -263,7 +263,7 @@ describe('helpers', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('ipal-audit through the doctor', () => {
|
||||
describe('iapl-audit through the doctor', () => {
|
||||
const site = (contentTs: string) =>
|
||||
project({ ...base(), 'src/lib/content.ts': contentTs, 'src/payload.config.ts': "import { payloadTotp } from '@clocklimited/payload-2fa'\n" })
|
||||
const aiBots = async (root: string) => (await doctor(root, ['audit'])).findings.filter((f) => f.rule === 'audit:robots-blocks-ai-bots')
|
||||
@@ -350,10 +350,10 @@ describe('versions', () => {
|
||||
describe('db-name', () => {
|
||||
const env = (dev: string, example = dev) => ({ ...base(), '.env': `DATABASE_URI=mongodb://127.0.0.1:27017/${dev}\n`, '.env.example': `DATABASE_URI=mongodb://USER:PASS@HOST:PORT/${example}?authSource=admin\n` })
|
||||
test('<domain without dots>_dev passes', async () => {
|
||||
expect(rules(await doctor(project({ ...env('examplepl_dev'), 'ipal-doctor.json': { domain: 'example.pl' } }), ['db-name']))).toEqual([])
|
||||
expect(rules(await doctor(project({ ...env('examplepl_dev'), 'iapl-doctor.json': { domain: 'example.pl' } }), ['db-name']))).toEqual([])
|
||||
})
|
||||
test('a local .env on _prod is an error, another name too', async () => {
|
||||
const report = await doctor(project({ ...env('examplepl_prod', 'dev'), 'ipal-doctor.json': { domain: 'example.pl' } }), ['db-name'])
|
||||
const report = await doctor(project({ ...env('examplepl_prod', 'dev'), 'iapl-doctor.json': { domain: 'example.pl' } }), ['db-name'])
|
||||
expect(report.findings.map((f) => f.message)).toEqual([
|
||||
'.env points at the production database examplepl_prod — a local run or seed writes to production',
|
||||
'.env.example: database "dev", expected examplepl_dev',
|
||||
@@ -413,7 +413,7 @@ describe('layout, blocks, seeds, agents', () => {
|
||||
expect(report.findings[0].message).toContain('src/proxy.ts')
|
||||
})
|
||||
test('layout.allow extends the src/ allow list; an audit skip drops its file', async () => {
|
||||
const root = project({ ...base(), 'AGENTS.md': '## Project decisions\n- ipal-audit-skip: mcp — client decision\n', 'src/scripts/x.ts': '' })
|
||||
const root = project({ ...base(), 'AGENTS.md': '## Project decisions\n- iapl-audit-skip: mcp — client decision\n', 'src/scripts/x.ts': '' })
|
||||
const report = await doctor(root, ['layout-required', 'layout-extra'], { config: { layout: { allow: ['scripts'] } } })
|
||||
expect(report.findings.map((f) => f.rule)).toEqual(['layout-required'])
|
||||
expect(report.findings[0].message).not.toContain('api/mcp')
|
||||
@@ -459,7 +459,7 @@ describe('layout, blocks, seeds, agents', () => {
|
||||
test('seeds: helper, no deletes, no fresh script, guard on; after launch a record list', async () => {
|
||||
const files = {
|
||||
...base(),
|
||||
'package.json': pkgJson({ scripts: { seed: 'payload run src/seed/index.ts', 'seed:fresh': 'payload run src/seed/old.ts', 'seed:full': 'IPAL_SEED_ALLOW_FULL=1 payload run src/seed/index.ts' } }),
|
||||
'package.json': pkgJson({ scripts: { seed: 'payload run src/seed/index.ts', 'seed:fresh': 'payload run src/seed/old.ts', 'seed:full': 'IAPL_SEED_ALLOW_FULL=1 payload run src/seed/index.ts' } }),
|
||||
'src/seed/index.ts': "import { pages } from './pages'\nconst seed = createSeeder(payload)",
|
||||
'src/seed/old.ts': 'await payload.delete({ collection: "pages" })',
|
||||
'src/seed/pages.ts': 'export const pages = []',
|
||||
@@ -467,19 +467,19 @@ describe('layout, blocks, seeds, agents', () => {
|
||||
expect(rules(await doctor(project(files), ['seed-named']))).toEqual([
|
||||
'seed-named:error', // seed:fresh name
|
||||
'seed-named:error', // old.ts deletes
|
||||
'seed-named:error', // IPAL_SEED_ALLOW_FULL=1 in seed:full
|
||||
'seed-named:error', // IAPL_SEED_ALLOW_FULL=1 in seed:full
|
||||
'seed-named:warning', // old.ts without the helper (errors sort first)
|
||||
])
|
||||
const launched = await doctor(project({ ...files, 'package.json': pkgJson({ scripts: { seed: 'payload run src/seed/index.ts' } }) }), ['seed-named'], { config: { launched: true } })
|
||||
expect(launched.findings.map((f) => f.message)).toEqual(['script "seed" has no record list — after launch every run needs SEED_ONLY'])
|
||||
})
|
||||
test('AGENTS.md needs a non-empty "Project decisions" and the pointer for the installed version', async () => {
|
||||
const pointer = '<!-- ipal-kit:start -->\n## ipal-kit 1.14.6 — agent guide\n<!-- ipal-kit:end -->'
|
||||
const pointer = '<!-- iapl:start -->\n## IAPL 1.14.6 — agent guide\n<!-- iapl:end -->'
|
||||
expect(rules(await doctor(project({ ...base(), 'AGENTS.md': `# x\n${pointer}`, 'CLAUDE.md': '@AGENTS.md\n' }), ['agents-md']))).toEqual(['agents-md:error'])
|
||||
expect(rules(await doctor(project({ ...base(), 'AGENTS.md': `## Project decisions\n<!-- todo -->\n${pointer}`, 'CLAUDE.md': '@AGENTS.md\n' }), ['agents-md']))).toEqual(['agents-md:warning'])
|
||||
expect(rules(await doctor(project({ ...base(), 'AGENTS.md': `## Project decisions\n- pl only\n${pointer}`, 'CLAUDE.md': '@AGENTS.md\n' }), ['agents-md']))).toEqual([])
|
||||
})
|
||||
test('planSkills: missing, stale and retired ipal-* folders', () => {
|
||||
test('planSkills: missing, stale and retired iapl-* folders', () => {
|
||||
const source = project({ 'ipal-a/SKILL.md': 'a', 'ipal-b/SKILL.md': 'b' })
|
||||
const dest = project({ 'ipal-b/SKILL.md': 'old', 'ipal-old/SKILL.md': 'x', 'mine/SKILL.md': 'own' })
|
||||
expect(planSkills({ dest, source })).toEqual({ missing: ['ipal-a'], retired: ['ipal-old'], stale: ['ipal-b'] })
|
||||
@@ -538,7 +538,7 @@ describe('security and deep status', () => {
|
||||
const payload = { config: { admin: { user: 'users' }, collections: [] }, count: vi.fn() }
|
||||
const call = (auth?: string) => endpoint.handler({ headers: new Headers(auth ? { authorization: auth, 'x-forwarded-for': '1.2.3.4' } : {}), payload } as never) as Promise<Response>
|
||||
expect((await call()).status).toBe(404)
|
||||
vi.stubEnv('IPAL_DOCTOR_TOKEN', 'x'.repeat(40))
|
||||
vi.stubEnv('IAPL_DOCTOR_TOKEN', 'x'.repeat(40))
|
||||
expect((await call('Bearer wrong')).status).toBe(401)
|
||||
const ok = await call(`Bearer ${'x'.repeat(40)}`)
|
||||
expect(ok.status).toBe(200)
|
||||
@@ -546,7 +546,7 @@ describe('security and deep status', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('silencing (ipal-doctor.json)', () => {
|
||||
describe('silencing (iapl-doctor.json)', () => {
|
||||
const noAgents = () => project(base())
|
||||
test('off with a reason silences (kept in the report); without a reason it is ignored and reported', async () => {
|
||||
const silenced = await doctor(noAgents(), ['agents-md'], { config: { rules: { 'agents-md': { off: true, reason: 'demo' } } } })
|
||||
@@ -555,11 +555,11 @@ describe('silencing (ipal-doctor.json)', () => {
|
||||
const noReason = await doctor(noAgents(), ['agents-md'], { config: { rules: { 'agents-md': { off: true } } } })
|
||||
expect(rules(noReason)).toEqual(['doctor-config:error', 'agents-md:error'])
|
||||
})
|
||||
test('severity override, expired until, files filter, ipal-audit-skip', async () => {
|
||||
test('severity override, expired until, files filter, iapl-audit-skip', async () => {
|
||||
expect(rules(await doctor(noAgents(), ['agents-md'], { config: { rules: { 'agents-md': { reason: 'r', severity: 'info' } } } }))).toEqual(['agents-md:info'])
|
||||
expect(rules(await doctor(noAgents(), ['agents-md'], { config: { rules: { 'agents-md': { off: true, reason: 'r', until: '2026-10-01' } } } }))).toEqual(['agents-md:error', 'doctor-config:warning'])
|
||||
expect(rules(await doctor(noAgents(), ['agents-md'], { config: { rules: { 'agents-md': { files: ['src/**'], off: true, reason: 'r' } } } }))).toEqual(['agents-md:error'])
|
||||
const skip = project({ ...base(), 'AGENTS.md': '- ipal-audit-skip: twofactor — the client signs in with SSO\n', 'src/payload.config.ts': '' })
|
||||
const skip = project({ ...base(), 'AGENTS.md': '- iapl-audit-skip: twofactor — the client signs in with SSO\n', 'src/payload.config.ts': '' })
|
||||
expect((await doctor(skip, ['2fa'])).findings[0]).toMatchObject({ reason: 'the client signs in with SSO', silenced: true })
|
||||
})
|
||||
})
|
||||
@@ -595,7 +595,7 @@ describe('live (--url)', () => {
|
||||
})
|
||||
|
||||
describe('CLI', () => {
|
||||
const clean = () => project({ ...base(), 'AGENTS.md': '## Project decisions\n- x\n<!-- ipal-kit:start -->\n## ipal-kit 1.14.6 — agent guide\n<!-- ipal-kit:end -->', 'CLAUDE.md': '@AGENTS.md\n' })
|
||||
const clean = () => project({ ...base(), 'AGENTS.md': '## Project decisions\n- x\n<!-- iapl:start -->\n## IAPL 1.14.6 — agent guide\n<!-- iapl:end -->', 'CLAUDE.md': '@AGENTS.md\n' })
|
||||
const cli = async (args: string[], cwd: string) => {
|
||||
const out: string[] = []
|
||||
const code = await runDoctorCli(args, { cwd, log: (l) => out.push(l), packageRoot })
|
||||
@@ -613,7 +613,7 @@ describe('CLI', () => {
|
||||
expect((await cli([info, '--offline', '--only', 'versions'], info)).code).toBe(0)
|
||||
expect((await cli([info, '--offline', '--only', 'versions', '--strict'], info)).code).toBe(1)
|
||||
expect((await cli([project({ 'x.txt': '' })], packageRoot)).code).toBe(2)
|
||||
const bad = project({ ...base(), 'ipal-doctor.json': '{ nope' })
|
||||
const bad = project({ ...base(), 'iapl-doctor.json': '{ nope' })
|
||||
expect((await cli([bad, '--offline', '--only', 'versions'], bad)).code).toBe(2)
|
||||
})
|
||||
test('--json is schema 1 with a summary; the human report lists fix and docs', async () => {
|
||||
@@ -644,13 +644,13 @@ describe('CLI', () => {
|
||||
})
|
||||
|
||||
describe('the reference site', () => {
|
||||
test('reference/ipal-doctor.json silences only with reasons', () => {
|
||||
const config = JSON.parse(readFileSync(path.join(packageRoot, 'reference/ipal-doctor.json'), 'utf8')) as DoctorConfig
|
||||
test('reference/iapl-doctor.json silences only with reasons', () => {
|
||||
const config = JSON.parse(readFileSync(path.join(packageRoot, 'reference/iapl-doctor.json'), 'utf8')) as DoctorConfig
|
||||
for (const setting of Object.values(config.rules ?? {})) {expect(setting.reason?.trim()).toBeTruthy()}
|
||||
})
|
||||
})
|
||||
|
||||
describe('ipal-doctor: first-seen dates', () => {
|
||||
describe('iapl-doctor: first-seen dates', () => {
|
||||
test('are written only outside CI, and never with --json or --sites', () => {
|
||||
expect(shouldWriteSeen({}, {})).toBe(true)
|
||||
expect(shouldWriteSeen({}, { CI: 'true' })).toBe(false)
|
||||
|
||||
Reference in New Issue
Block a user