Files
vendoo/tools/verify-command-platform-ux-1.44.0.mjs

31 lines
2.6 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
const root = process.cwd();
const read = relative => fs.readFileSync(path.join(root, relative), 'utf8');
const js = read('public/command-platform.js');
const css = read('public/command-platform.css');
const loader = read('public/module-extension-workspace.js');
const pkg = JSON.parse(read('package.json'));
const failures = [];
const expect = (condition, message) => { if (!condition) failures.push(message); };
const includesAll = (source, values, label) => values.forEach(value => expect(source.includes(value), `${label}: ${value}`));
includesAll(js, ['uxCommandPlatformReady','VendooCommands','VendooNavigation','register','unregister','execute','toggleFavorite','history.back','history.forward','ux-command-breadcrumb','ux-command-favorite-toggle','ux-command-drawer','vendoo_command_favorites_v1','vendoo_navigation_recents_v1','MutationObserver','CustomEvent'], 'Command Platform JS-Vertrag fehlt');
includesAll(css, ['.ux-command-platform-chrome','.ux-command-breadcrumb','.ux-command-favorite-toggle','.ux-command-drawer','.ux-command-drawer-item','@media(max-width:780px)','@media(max-width:520px)','@media(prefers-reduced-motion:reduce)',':focus-visible','var(--'], 'Command Platform CSS-Vertrag fehlt');
includesAll(loader, ['loadCommandPlatformAssets','command-platform.css?v=1.44.0','command-platform.js?v=1.44.0','data-ux-command-platform','loadCommandPlatformAssets();','loadGlobalNavigationAssets();'], 'Command Platform Loader fehlt');
expect(loader.indexOf('loadCommandPlatformAssets();') < loader.indexOf('loadGlobalNavigationAssets();'), 'Command Platform muss vor globaler Navigation geladen werden');
expect(pkg.scripts?.['verify:command-platform'] === 'node tools/verify-command-platform-ux-1.44.0.mjs', 'verify:command-platform fehlt');
expect(pkg.scripts?.['verify:all']?.includes('npm run verify:command-platform'), 'verify:all enthält Command-Platform-Gate nicht');
expect(!/\bfetch\s*\(/.test(js), 'Command Platform darf keine Netzwerkaufrufe ausführen');
expect(!/\b(?:POST|PUT|PATCH|DELETE)\b/.test(js), 'Command Platform darf keine HTTP-Schreiboperationen implementieren');
expect(!/\.innerHTML\s*=/.test(js), 'Command Platform darf innerHTML nicht setzen');
expect(!/confirm\s*\(/.test(js), 'Command Platform darf keine kritischen Aktionen bestätigen');
expect(!/setInterval\s*\(/.test(js), 'Command Platform darf kein Polling starten');
if (failures.length) {
console.error('Command Platform UX Gate fehlgeschlagen:');
failures.forEach(failure => console.error(`- ${failure}`));
process.exit(1);
}
console.log('Command Platform UX Gate bestanden.');