|
| 1 | +import { spawnSync } from 'node:child_process'; |
| 2 | +import { readFile } from 'node:fs/promises'; |
| 3 | + |
| 4 | +const live = process.argv.includes('--live'); |
| 5 | +const checks = [ |
| 6 | + ['ownership', 'scripts/audit_frontend_ownership.mjs'], |
| 7 | + ['scoped wiring', 'scripts/audit_frontend_scoped_wiring.mjs'], |
| 8 | +]; |
| 9 | +const requiredArtifacts = [ |
| 10 | + 'custom_components/blueprint_studio/www/panels/panel_custom.html', |
| 11 | + 'custom_components/blueprint_studio/www/modules/app.js', |
| 12 | + 'custom_components/blueprint_studio/www/modules/translations.js', |
| 13 | + 'custom_components/blueprint_studio/www/locales/en.json', |
| 14 | + 'scripts/audit_frontend_ownership.mjs', |
| 15 | + 'scripts/audit_frontend_scoped_wiring.mjs', |
| 16 | + 'scripts/audit_frontend_pseudo_locale.mjs', |
| 17 | + 'scripts/audit_frontend_degraded_states.mjs', |
| 18 | +]; |
| 19 | + |
| 20 | +const run = (label, command, args = []) => { |
| 21 | + const result = spawnSync(command, args, { stdio: 'inherit', env: process.env }); |
| 22 | + if (result.status !== 0) throw new Error(`${label} failed`); |
| 23 | +}; |
| 24 | + |
| 25 | +for (const [label, script] of checks) run(label, 'node', [script]); |
| 26 | +run('pseudo locale', 'node', ['scripts/audit_frontend_pseudo_locale.mjs']); |
| 27 | +run('degraded states', 'node', ['scripts/audit_frontend_degraded_states.mjs']); |
| 28 | +for (const artifact of requiredArtifacts) await readFile(new URL(`../${artifact}`, import.meta.url)); |
| 29 | +console.log(`PASS release artifact inventory (${requiredArtifacts.length} files)`); |
| 30 | + |
| 31 | +if (live) { |
| 32 | + const liveChecks = [ |
| 33 | + ['performance budgets', 'scripts/audit_frontend_performance_budgets.mjs'], |
| 34 | + ['lazy dependencies', 'scripts/audit_frontend_lazy_dependencies.mjs'], |
| 35 | + ['large workspace', 'scripts/audit_frontend_large_workspace.mjs'], |
| 36 | + ['reinitialization', 'scripts/audit_frontend_reinitialization.mjs'], |
| 37 | + ['viewport screenshots', 'scripts/audit_frontend_screenshots.mjs'], |
| 38 | + ['shortcut guide', 'scripts/audit_frontend_shortcuts.mjs'], |
| 39 | + ['Playwright layouts', 'scripts/audit_frontend_playwright.mjs'], |
| 40 | + ]; |
| 41 | + for (const [label, script] of liveChecks) run(label, 'node', [script]); |
| 42 | +} |
| 43 | + |
| 44 | +console.log(live ? 'Frontend release gate passed (static + live)' : 'Frontend release gate passed (CI static)'); |
0 commit comments