ipal-doctor: one command that checks a site against the team rules
bin ipal-doctor + @intecion/ipal-kit/doctor: static rules (versions, Node 22, AGENT.md §3 layout and naming, database names, env rules, headers, X-Powered-By, CSP, 2FA, cookie scanner, adminMeta, AGENTS.md, skills, seeds, block library via blockLibraryManifest, ipal-audit --quick), registry rules (latest plugin, pnpm audit --prod), live rules (--url, ipal-seo-check), deep rules (--deep via payload run; GET /api/ipal/doctor, off until IPAL_DOCTOR_TOKEN). Human / JSON output, --strict, exit codes 0/1/2/3, --sites drift table, ipal-doctor.json with reasons, until, files, seen. Fixes found on the way: sitemap leaves out the System pages 404 page; ipal-audit finds array labels after fields, any form seed, runs grep in UTF-8; ipal-seo-check counts duplicate titles per language. Reference site at zero findings (static), CI steps on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0ab133fbd7
commit
a4e8cfeae8
@@ -18,6 +18,31 @@ const lineOf = (src, i) => src.slice(0, i).split('\n').length
|
||||
const out = (level, rule, file, src, i, detail) => console.log(`${level}|${rule}|${file}:${lineOf(src, i)}: ${detail}`)
|
||||
const strip = (s) => s.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, ' ')).replace(/(^|[^:])\/\/.*$/gm, (m, p) => p + ' '.repeat(m.length - p.length))
|
||||
|
||||
// The text of the object literal around index i, without the contents of its nested `fields: [...]`.
|
||||
function ownObject(src, i) {
|
||||
let start = i
|
||||
for (let depth = 0; start > 0; start--) {
|
||||
const ch = src[start - 1]
|
||||
if (ch === '}') depth++
|
||||
else if (ch === '{') { if (depth === 0) { start--; break } depth-- }
|
||||
}
|
||||
let end = i
|
||||
for (let depth = 0; end < src.length; end++) {
|
||||
const ch = src[end]
|
||||
if (ch === '{') depth++
|
||||
else if (ch === '}') { if (depth === 0) break; depth-- }
|
||||
}
|
||||
const obj = src.slice(start, end + 1)
|
||||
const at = obj.search(/\bfields\s*:\s*\[/)
|
||||
if (at < 0) return obj
|
||||
let j = obj.indexOf('[', at)
|
||||
for (let depth = 0; j < obj.length; j++) {
|
||||
if (obj[j] === '[') depth++
|
||||
else if (obj[j] === ']' && --depth === 0) break
|
||||
}
|
||||
return obj.slice(0, at) + obj.slice(j + 1)
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
const src = strip(readFileSync(file, 'utf8'))
|
||||
|
||||
@@ -35,15 +60,13 @@ for (const file of files) {
|
||||
else if (m[1] === 'description' && text.length > 120) out('WARNING', 'description over 120 chars — one short sentence: what it does / where it shows', file, src, m.index, `${text.length} chars`)
|
||||
}
|
||||
|
||||
// arrays: labels (→ "Add Feature" button) + rowLabel (→ readable rows)
|
||||
// arrays: labels (→ "Add Feature" button) + rowLabel (→ readable rows) — anywhere in the array's own
|
||||
// object (before or after its `fields`), not inside the nested fields
|
||||
for (const m of src.matchAll(/type:\s*['"]array['"]/g)) {
|
||||
const before = src.slice(0, m.index)
|
||||
const start = Math.max(before.lastIndexOf('name:'), before.lastIndexOf('{'))
|
||||
const fieldsAt = src.indexOf('fields:', m.index)
|
||||
const head = src.slice(start < 0 ? m.index : start, fieldsAt < 0 ? m.index + 400 : fieldsAt)
|
||||
const name = head.match(/name:\s*['"](\w+)['"]/)?.[1] ?? '?'
|
||||
if (!/\blabels\s*:/.test(head)) out('WARNING', 'array without labels {singular, plural} — panel shows "Add Row"', file, src, m.index, name)
|
||||
if (!/rowLabel|RowLabel/.test(head)) out('WARNING', 'array without rowLabel() — rows read "Item 01" instead of their content', file, src, m.index, name)
|
||||
const own = ownObject(src, m.index)
|
||||
const name = own.match(/name:\s*['"](\w+)['"]/)?.[1] ?? '?'
|
||||
if (!/\blabels\s*:/.test(own)) out('WARNING', 'array without labels {singular, plural} — panel shows "Add Row"', file, src, m.index, name)
|
||||
if (!/rowLabel|RowLabel/.test(own)) out('WARNING', 'array without rowLabel() — rows read "Item 01" instead of their content', file, src, m.index, name)
|
||||
}
|
||||
|
||||
// too many fields in one block config → tabs / condition / arrays / variant
|
||||
|
||||
Reference in New Issue
Block a user