|
| 1 | +// ADR-0080: generate the public-tier SDUI component manifest. |
| 2 | +// |
| 3 | +// The registry is a browser app (plugin-map/charts pull browser-only deps), so |
| 4 | +// the reliable way to enumerate it is in a real browser: load the built |
| 5 | +// `manifest-dump.html` (which registers everything the console does and exposes |
| 6 | +// `window.__MANIFEST = manifestFromConfigs(getPublicConfigs())`) and read it. |
| 7 | +// |
| 8 | +// Usage (build-console.sh wires this after building + serving the console dist): |
| 9 | +// BASE_URL=http://localhost:4173 OUT=packages/console/dist/sdui.manifest.json \ |
| 10 | +// node scripts/dump-public-manifest.mjs |
| 11 | +import { writeFileSync } from 'node:fs'; |
| 12 | +import { chromium } from 'playwright'; |
| 13 | + |
| 14 | +const BASE = process.env.BASE_URL ?? 'http://localhost:5180'; |
| 15 | +const OUT = process.env.OUT ?? 'sdui.manifest.json'; |
| 16 | + |
| 17 | +const browser = await chromium.launch(); |
| 18 | +try { |
| 19 | + const page = await browser.newPage(); |
| 20 | + await page.goto(`${BASE}/dev/manifest-dump.html`, { waitUntil: 'networkidle', timeout: 120_000 }); |
| 21 | + const json = await page.waitForFunction(() => globalThis.__MANIFEST, null, { timeout: 120_000 }) |
| 22 | + .then((h) => h.jsonValue()); |
| 23 | + const manifest = JSON.parse(json); |
| 24 | + const n = Object.keys(manifest.components ?? {}).length; |
| 25 | + if (n === 0) throw new Error('empty manifest — registry not populated'); |
| 26 | + writeFileSync(OUT, JSON.stringify(manifest, null, 2)); |
| 27 | + console.log(`✓ wrote ${n} public blocks → ${OUT}`); |
| 28 | +} finally { |
| 29 | + await browser.close(); |
| 30 | +} |
0 commit comments