ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
Ratchet one field per job in lint
Juan Denisb32a90b36d87
diff --git a/frontend/package.json b/frontend/package.jsonindex eaf098b2..2942a66a 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -9,7 +9,7 @@"test": "node --test","test:browser": "node scripts/settings-browser.mjs","test:settings-ui": "node scripts/settings-ui-browser.mjs",- "lint": "node scripts/lint.mjs && node scripts/check-font-integrity.mjs && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node scripts/check-style-ownership.mjs && node scripts/check-status-one-door.mjs && node scripts/check-status-scss.mjs && node scripts/check-i18n-literals.mjs && node scripts/check-intl-door.mjs && node scripts/extract-i18n.mjs --check && node scripts/check-i18n.mjs && node scripts/check-logical-properties.mjs && node scripts/generate-vendor-shims.mjs --check && node ../scripts/check-html-sinks.mjs",+ "lint": "node scripts/lint.mjs && node scripts/check-font-integrity.mjs && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node scripts/check-style-ownership.mjs && node scripts/check-status-one-door.mjs && node scripts/check-shared-fields.mjs && node scripts/check-status-scss.mjs && node scripts/check-i18n-literals.mjs && node scripts/check-intl-door.mjs && node scripts/extract-i18n.mjs --check && node scripts/check-i18n.mjs && node scripts/check-logical-properties.mjs && node scripts/generate-vendor-shims.mjs --check && node ../scripts/check-html-sinks.mjs","lint:baseline": "node scripts/lint.mjs --update","test:controls": "node scripts/controls-browser.mjs","test:metrics": "node scripts/metrics-browser.mjs",@@ -19,6 +19,7 @@"lint:settings-index": "node scripts/check-settings-index.mjs","lint:fonts": "node scripts/check-font-integrity.mjs","lint:status": "node scripts/check-status-one-door.mjs",+ "lint:shared-fields": "node scripts/check-shared-fields.mjs","lint:i18n": "node scripts/check-i18n-literals.mjs","lint:intl": "node scripts/check-intl-door.mjs","lint:locales": "node scripts/check-i18n.mjs",diff --git a/frontend/scripts/check-shared-fields.mjs b/frontend/scripts/check-shared-fields.mjsnew file mode 100644index 00000000..2b1eb500--- /dev/null+++ b/frontend/scripts/check-shared-fields.mjs@@ -0,0 +1,96 @@+#!/usr/bin/env node+// One field per job. Fails when core code hand-builds something a shared+// component already does:+//+// pick a server ............ components/ServerPicker.jsx+// enter a domain ........... components/DomainField.jsx (+ services/attachDomain.js)+// enter a host port ........ components/PortField.jsx+// choose one of N .......... components/ui/select.jsx (Radix) or ds/SegControl+//+// Each rule names the only files allowed to touch the underlying API or+// element. A new exception needs a reason in this file, not a copy of the+// component. Copy-to-clipboard is ratcheted by check-frontend-boundaries.+// Extension copies under src/plugins/ are out of scope (their source repos+// adopt the SDK exports instead).++import { readFileSync, readdirSync, statSync } from 'node:fs';+import { join, relative, sep } from 'node:path';++const SRC = new URL('../src', import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1');++const RULES = [+ {+ name: 'native <select>',+ door: 'Select from @/components/ui/select (size="sm" for compact) or SegControl',+ pattern: /<select\b/,+ allowed: new Set([+ // Fill in only with a reason.+ ]),+ jsxOnly: true,+ },+ {+ // Reading the server list as data is fine (status bar, widgets); a+ // resource picker over servers is a second ServerPicker.+ name: 'server picker',+ door: 'ServerPicker',+ pattern: /types=\{\[\s*['"]server['"]\s*\]\}|TargetPicker/,+ allowed: new Set(['components/ServerPicker.jsx']),+ },+ {+ name: 'base-domain / subdomain API',+ door: 'DomainField + attachDomain',+ pattern: /\b(getSiteBaseDomains|giveSubdomain|suggestSubdomain)\s*\(/,+ allowed: new Set([+ 'components/DomainField.jsx',+ 'services/attachDomain.js',+ 'services/api/files.js',+ // Base-domain registry management, not a domain input.+ 'components/settings/SiteSettingsTab.jsx',+ // Deploy drawer's read-only "will publish at" preview.+ 'pages/Templates.jsx',+ ]),+ },+ {+ name: 'host-port check API',+ door: 'PortField',+ pattern: /\b(checkPort|suggestPort)\s*\(/,+ allowed: new Set(['components/PortField.jsx', 'services/api/apps.js']),+ },+];++function* walk(dir) {+ for (const name of readdirSync(dir)) {+ const p = join(dir, name);+ if (statSync(p).isDirectory()) {+ if (name === 'node_modules' || name === '__tests__') continue;+ yield* walk(p);+ } else if (/\.(jsx?|mjs)$/.test(name)) {+ yield p;+ }+ }+}++// Strip comments so prose like "replaces native <select>" does not count.+function code(src) {+ return src.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^:])\/\/.*$/gm, '$1');+}++const problems = [];+for (const file of walk(SRC)) {+ const rel = relative(SRC, file).split(sep).join('/');+ if (rel.startsWith('plugins/')) continue;+ const body = code(readFileSync(file, 'utf8'));+ for (const rule of RULES) {+ if (rule.jsxOnly && !rel.endsWith('.jsx')) continue;+ if (rule.allowed.has(rel)) continue;+ if (rule.pattern.test(body)) problems.push(` - ${rel}: ${rule.name} — use ${rule.door}`);+ }+}++if (problems.length) {+ console.error('Shared-field check failed (one field per job):\n');+ console.error(problems.join('\n'));+ console.error('\nUse the shared component, or add the file to that rule\'s allowlist with a reason.');+ process.exit(1);+}+console.log(`✓ shared fields: ${RULES.length} doors hold (select, server picker, domain, port).`);