mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-02 21:25:26 +09:00
statusKind()/statusVariant()/statusDotClass()/statusLabel() drive both Pill kinds and Badge variants from ONE table; ~40 per-page maps across 35+ files migrate to it. Scoped overrides stay in the same file: serviceStatusKind (running IS the healthy steady state for services/ units/previews -> green), processStateVariant, alertStatusKind, envActionKind, impactTone. Unifications: run-shaped 'running' is cyan everywhere (Git.jsx's amber gone), QueueDetail/QueueOperations' invalid blue/yellow kinds fixed, severity tones (critical/high/medium/low) agree across security surfaces. Ratchet: npm run check:status fails on new local maps outside ds/status.js (frozen allowlist for domain maps and D4-territory hex/css-class renderers). Lint + build green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
61 lines
2.9 KiB
JavaScript
61 lines
2.9 KiB
JavaScript
#!/usr/bin/env node
|
|
// Plan 77 D3 ratchet — ONE frontend status→tone vocabulary.
|
|
//
|
|
// Fails when a file outside src/components/ds/status.js defines its own
|
|
// status→color/kind/variant object map. Run with: npm run check:status
|
|
//
|
|
// The allowlist below is the frozen 2026-08-19 population of files whose
|
|
// matches are NOT status color maps (rank orders, label-only maps, icon
|
|
// metadata, raw CSS-var renderers deferred to the D4 SCSS pass). Shrinking
|
|
// it is progress; adding to it needs a reason that is not "my page wants
|
|
// its own colors" — extend ds/status.js instead.
|
|
|
|
import { readFileSync, readdirSync, statSync } from 'node:fs';
|
|
import { join, relative } from 'node:path';
|
|
|
|
const SRC = new URL('../src', import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1');
|
|
|
|
const ALLOWED = new Set([
|
|
'components/ds/status.js', // the one door
|
|
'components/backups/BackupCalendar.jsx', // STATUS_RANK: severity ordering, not colors
|
|
'components/databases/SourceTree.jsx', // STATUS_LABEL: labels only
|
|
'pages/DeployConsole.jsx', // STATUS_META: labels+icons+css classes (D4 territory)
|
|
'components/dashboard/widgets/renderers.jsx', // raw CSS-var renderer (D4 territory)
|
|
'components/NotificationBell.jsx', // SEVERITY_DOT hex dots (D4 territory)
|
|
'pages/Notifications.jsx', // SEVERITY_DOT hex dots (D4 territory)
|
|
'components/LinkedAppsSection.jsx', // css-class map (D4 territory)
|
|
'components/apps/AppWafPanel.jsx', // WAF mode map (block=green is domain-inverted) + ModSec severities
|
|
'components/monitoring/MonitoringOverview.jsx', // metric-series colors (cpu/mem/disk), not statuses
|
|
'components/security/FirewallTab.jsx', // firewall rule-TYPE tones, not statuses
|
|
'pages/PublicStatusPage.jsx', // status-page meta bundle (labels+icons), public surface
|
|
'pages/StatusPages.jsx', // status-page meta bundle (labels+icons+dots)
|
|
]);
|
|
|
|
// A "status map" smell: an object-literal or switch mapping status-ish keys
|
|
// to Pill kinds / Badge variants.
|
|
const DEF_RE = /(?:const|let|var)\s+\w*(?:STATUS|SEVERITY|TONE|PILL)\w*\s*=\s*\{[^}]*(?:'green'|'amber'|'red'|'cyan'|'violet'|'gray'|'success'|'destructive'|'warning'|'info'|'outline'|'secondary')/s;
|
|
|
|
function* walk(dir) {
|
|
for (const name of readdirSync(dir)) {
|
|
const p = join(dir, name);
|
|
const st = statSync(p);
|
|
if (st.isDirectory()) yield* walk(p);
|
|
else if (/\.(jsx?|mjs)$/.test(name)) yield p;
|
|
}
|
|
}
|
|
|
|
const offenders = [];
|
|
for (const file of walk(SRC)) {
|
|
const rel = relative(SRC, file).replaceAll('\\', '/');
|
|
if (ALLOWED.has(rel)) continue;
|
|
const text = readFileSync(file, 'utf8');
|
|
if (DEF_RE.test(text)) offenders.push(rel);
|
|
}
|
|
|
|
if (offenders.length) {
|
|
console.error('New local status→tone maps (extend src/components/ds/status.js instead):');
|
|
for (const f of offenders) console.error(' ' + f);
|
|
process.exit(1);
|
|
}
|
|
console.log('status one-door: OK');
|