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
@@ -7,6 +7,8 @@
|
||||
# Exit code: 0 = no errors (warnings allowed), 1 = at least one error.
|
||||
|
||||
set -u
|
||||
# UTF-8 for grep: in the C locale a multibyte class like [ąę…] matches single bytes (an en dash hit "Polish").
|
||||
export LC_ALL="${LC_ALL:-C.UTF-8}"
|
||||
|
||||
QUICK=0
|
||||
for arg in "$@"; do
|
||||
@@ -322,8 +324,10 @@ if [ -n "$CFG" ]; then
|
||||
report WARNING "robots blocks AI bots" "§0b.8 — only with the client's decision in AGENTS.md" \
|
||||
"$(skipped aibots || g "aiBots: *'(disallow|block-training)'" src --include=*.ts)"
|
||||
fi
|
||||
if [ -n "$CFG" ] && grep -qE 'forms *:' "$CFG" 2>/dev/null && ! ls scripts/seed-form* >/dev/null 2>&1 && ! skipped forms-seed; then
|
||||
report WARNING "no form seed" "ipal-form §5 — every form from scripts/seed-form-*.ts (notification + sender confirmation, all languages)" "scripts/seed-form-*.ts"
|
||||
# A form seed: scripts/seed-form-*.ts, or a seed file (src/seed, scripts) that seeds the forms collection.
|
||||
FORM_SEED=$(ls scripts/seed-form* 2>/dev/null; grep -rlE "collection: *['\"]forms['\"]|upsertBy\( *['\"]forms['\"]|seed\.form\(|\.forms?\(" $(dirs src/seed scripts) 2>/dev/null)
|
||||
if [ -n "$CFG" ] && grep -qE 'forms *:' "$CFG" 2>/dev/null && [ -z "$FORM_SEED" ] && ! skipped forms-seed; then
|
||||
report WARNING "no form seed" "ipal-form §5 — every form from a seed (scripts/seed-form-*.ts or src/seed/forms.ts: notification + sender confirmation, all languages)" "scripts/seed-form-*.ts"
|
||||
fi
|
||||
need WARNING r2 "R2 env in .env.example" ".env.example lists R2_BUCKET, R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_PUBLIC_URL" 'R2_BUCKET' .env.example
|
||||
need WARNING '' "IPAL_IP_HEADER in .env.example" "header the rate limit trusts, e.g. cf-connecting-ip (forms.md)" 'IPAL_IP_HEADER' .env.example
|
||||
|
||||
@@ -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