IAPL rename: the old names keep working, and a second cookie name and counter key for new sites
- exports: ipalKit, IpalOptions, ipalEnvRules, IpalEnvFeatures, ipalT, ipalVar, IPAL_TOKENS, IPAL_BREAKPOINTS, IpalTokenName, IpalGlobalSlug are aliases of the iapl names - env: IAPL_* is read first, IPAL_* as fallback (readEnv; EnvRule.aliases for assertEnv); the crawler service reads IPAL_CRAWLER_SITES too - doctor: reads ipal-doctor.json when it is the only one, the old pointer block, ipal-audit-skip and old skill folders; new rule legacy-names (info) and storage-names (warning) - iapl-skills: installs iapl-*, removes the 16 old folders by exact name, rewrites the old pointer block in place; a project's own ipal-* skill stays - storageNames: 'ipal' (default) | 'iapl': the cookie the scanner declares and the 2FA counter's kv prefix; <PageStats visitorCookie>, IAPL_VISITOR_COOKIE, verifyLimit.keyPrefix - test/legacyNames.test.ts: 24 tests for all of the above Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
0a4f001797
commit
425fac14fb
+20
-3
@@ -8,6 +8,9 @@
|
||||
// pnpm exec iapl-skills --external ext-accessibility,ext-payload → only those
|
||||
// Only folders named iapl-* are touched; the project's own skills stay as they are.
|
||||
// iapl-* folders that no longer exist in the package are removed (renamed/retired skills).
|
||||
// Before 1.17.0 the skills were named ipal-*: the 16 folders of that set are removed by their
|
||||
// exact names (LEGACY_SKILLS) — any other ipal-<something> folder is the project's own and stays.
|
||||
// `ipal-skills` is the same command under its old name.
|
||||
// ext-* folders are touched only with --external, and only those carrying IAPL's SOURCE.md.
|
||||
// AGENTS.md (and CLAUDE.md) get a marked IAPL block pointing at the guide — only the
|
||||
// text between the markers is ever rewritten; the project's own content stays as it is.
|
||||
@@ -58,10 +61,19 @@ if (unknown.length) {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const isSkillDir = (base, name) => name.startsWith('ipal-') && statSync(join(base, name)).isDirectory()
|
||||
// The same list as LEGACY_SKILL_NAMES in src/modules/doctor/rules/legacy.ts (test/legacyNames.test.ts compares them).
|
||||
const LEGACY_SKILLS = [
|
||||
'audit', 'block', 'collection', 'consent-check', 'debug', 'doctor', 'form', 'locale-add',
|
||||
'migrate-fields', 'nav', 'plugin-gap', 'reference', 'seo-check', 'setup', 'site', 'upgrade',
|
||||
].map((name) => `ipal-${name}`)
|
||||
const isDir = (base, name) => statSync(join(base, name)).isDirectory()
|
||||
const isSkillDir = (base, name) => name.startsWith('iapl-') && isDir(base, name)
|
||||
const shipped = readdirSync(src).filter((n) => isSkillDir(src, n))
|
||||
const existing = existsSync(dest) ? readdirSync(dest).filter((n) => isSkillDir(dest, n)) : []
|
||||
const retired = existing.filter((n) => !shipped.includes(n))
|
||||
const retired = [
|
||||
...existing.filter((n) => !shipped.includes(n)),
|
||||
...(existsSync(dest) ? readdirSync(dest).filter((n) => LEGACY_SKILLS.includes(n) && isDir(dest, n)) : []),
|
||||
]
|
||||
|
||||
if (!dryRun) mkdirSync(dest, { recursive: true })
|
||||
for (const name of shipped) {
|
||||
@@ -73,7 +85,7 @@ for (const name of shipped) {
|
||||
}
|
||||
}
|
||||
for (const name of retired) {
|
||||
console.log(`remove ${name} (no longer in IAPL)`)
|
||||
console.log(`remove ${name} (${LEGACY_SKILLS.includes(name) ? `now ${name.replace('ipal-', 'iapl-')}` : 'no longer in IAPL'})`)
|
||||
if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true })
|
||||
}
|
||||
console.log(`${dryRun ? '[dry-run] ' : ''}${shipped.length} skill(s) → ${dest}`)
|
||||
@@ -119,6 +131,8 @@ if (externalArg >= 0) {
|
||||
if (pointer) {
|
||||
const START = '<!-- iapl:start -->'
|
||||
const END = '<!-- iapl:end -->'
|
||||
const OLD_START = '<!-- ipal-kit:start -->'
|
||||
const OLD_END = '<!-- ipal-kit:end -->'
|
||||
const version = JSON.parse(readFileSync(join(pkgRoot, 'package.json'), 'utf8')).version
|
||||
const skillsDir = relative(process.cwd(), dest).split('\\').join('/')
|
||||
const block = [
|
||||
@@ -146,6 +160,9 @@ if (pointer) {
|
||||
next = create === 'import' ? '@AGENTS.md\n' : `# ${file.replace('.md', '')}\n\n${block}\n`
|
||||
} else if (text.includes(START) && text.includes(END)) {
|
||||
next = text.slice(0, text.indexOf(START)) + block + text.slice(text.indexOf(END) + END.length)
|
||||
} else if (text.includes(OLD_START) && text.includes(OLD_END)) {
|
||||
// the block written before 1.17.0: replaced where it stands, markers included
|
||||
next = text.slice(0, text.indexOf(OLD_START)) + block + text.slice(text.indexOf(OLD_END) + OLD_END.length)
|
||||
} else {
|
||||
next = `${text.replace(/\s*$/, '')}\n\n${block}\n`
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
// IAPL — the plugin's command line.
|
||||
// iapl — the IAPL command line (also installed as `ipal-kit`, its name before 1.17.0, which `pnpm dlx @intecion/ipal-kit` runs).
|
||||
// pnpm dlx @intecion/ipal-kit@<version> create intecion.com → a new client site (docs/project-starter.md)
|
||||
// pnpm exec iapl create intecion.com --dir ../intecioncom-web --answers answers.json
|
||||
// `pnpm dlx <package>` runs the bin named after the package, so every subcommand lives here.
|
||||
@@ -8,7 +8,7 @@
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
|
||||
const USAGE = `Usage: IAPL <command> [options]
|
||||
const USAGE = `Usage: iapl <command> [options]
|
||||
create <domain> a new client site from the reference site (iapl create --help)
|
||||
|
||||
Other tools: iapl-skills, iapl-blocks, iapl-tokens, iapl-doctor`
|
||||
|
||||
Reference in New Issue
Block a user