buildR2Storage registered nothing without R2_* env, so `pnpm dev` / generate:importmap in dev
wrote an importMap.js without S3ClientUploadHandler — committed, the production admin (R2 on)
rendered a blank page with no console error (hit vanstev.pl). The injected s3Storage is now
always registered (enabled: false without R2 → local disk); storage-s3 still adds its client
handler, so the import map is identical in every environment. ipal-audit flags an import map
without the handler.
R2_PUBLIC_URL alone (absolute, outside production) = read-only media: URLs from the media
domain, upload/delete refused with 403 — local dev against a production database without
bucket keys. ipalEnvRules allows it in development.
Cookie Settings (MongoDB): the 1.11.1 rename buttons.save → savePreferences lost the texts on
the first save; onInit copies the old value (all locales) when the new field is missing.
getConsentTexts read the old field as a string, Mongo returns the raw { pl, en } map.
Also: context.ipalSkipAutoFill (SKIP_AUTO_FILL) — save without meta / aiSummary auto-fill;
createPageRoute redirects the homepage under its own slug (homeAlias, default 'redirect');
ipal-audit: multi-line tsconfig exclude, numeronyms (a11y) not "numbered fields",
`${prefix}/${slug}` links and slugs typed into links detected, clearer panel-language message.
Docs: fallback-on-save in i18n.md, `pnpm up --latest` and the stale-token 401 in PROGRAMISTA §1.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
56 lines
3.2 KiB
JavaScript
56 lines
3.2 KiB
JavaScript
#!/usr/bin/env node
|
|
// Editor-panel clarity checks (AGENT.md §6.5a): prints "LEVEL|rule|file:line: detail", exit 0.
|
|
// node panel-check.mjs src/blocks src/collections src/globals src/fields
|
|
import { readFileSync, readdirSync, statSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
|
|
const files = []
|
|
const walk = (p) => {
|
|
let st
|
|
try { st = statSync(p) } catch { return }
|
|
if (st.isDirectory()) for (const n of readdirSync(p)) walk(join(p, n))
|
|
else if (/\.ts$/.test(p) && !/Component|\.d\.ts$/.test(p)) files.push(p)
|
|
}
|
|
process.argv.slice(2).forEach(walk)
|
|
|
|
const POLISH = /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/
|
|
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))
|
|
|
|
for (const file of files) {
|
|
const src = strip(readFileSync(file, 'utf8'))
|
|
|
|
// numbered slots: cta1Label, feature2Title, image3, phone2 → array with "+ Add …"
|
|
// digits at the end or before a new word (cta1Label) — not numeronyms like a11y, i18n, l10n
|
|
for (const m of src.matchAll(/name:\s*['"]([a-zA-Z]+[0-9]+(?:[A-Z][a-zA-Z0-9]*)?)['"]/g)) {
|
|
if (/^(h[1-6]|x[0-9]|[a-z]?2fa)$/i.test(m[1])) continue
|
|
out('ERROR', 'numbered fields → one array field with labels {singular, plural} ("+ Add …")', file, src, m.index, m[1])
|
|
}
|
|
|
|
// panel text must be English and short
|
|
for (const m of src.matchAll(/\b(label|description|singular|plural|placeholder)\s*:\s*(['"`])((?:(?!\2).)*)\2/g)) {
|
|
const text = m[3]
|
|
if (POLISH.test(text)) out('WARNING', 'panel text in Polish — admin labels/descriptions are English', file, src, m.index, `${m[1]}: "${text.slice(0, 60)}"`)
|
|
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)
|
|
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)
|
|
}
|
|
|
|
// too many fields in one block config → tabs / condition / arrays / variant
|
|
if (/\/blocks\/[^/]+\/config\.ts$/.test(file)) {
|
|
const n = (src.match(/name:\s*['"]/g) ?? []).length
|
|
const hasTabs = /type:\s*['"]tabs['"]/.test(src)
|
|
if (n > 14 && !hasTabs) out('WARNING', 'block has many fields and no tabs — tabs Content/Media/Settings, admin.condition, arrays', file, src, 0, `${n} fields`)
|
|
}
|
|
}
|