render-examples.mjs
36 lines · archify/scripts/render-examples.mjs at a406594
1// Re-render every bundled example from its JSON IR. Installed skills keep HTML
2// beside the JSON examples; the development script passes the golden directory.
4import { execFileSync } from 'node:child_process';
5import path from 'node:path';
6import { fileURLToPath } from 'node:url';
8const __dirname = path.dirname(fileURLToPath(import.meta.url));
9const skillRoot = path.resolve(__dirname, '..');
10const outputRoot = path.resolve(process.argv[2] || path.join(skillRoot, 'examples'));
12const TARGETS = [
13 ['workflow', 'agent-tool-call.workflow.json', 'workflow-agent-tool-call-rendered.html'],
14 ['sequence', 'cache-miss-request.sequence.json', 'sequence-cache-miss-request.html'],
15 ['dataflow', 'product-analytics.dataflow.json', 'dataflow-product-analytics.html'],
16 ['lifecycle', 'agent-run.lifecycle.json', 'lifecycle-agent-run.html'],
17 ['architecture', 'web-app.architecture.json', 'web-app-rendered.html'],
18 ['erd', 'orders.erd.json', 'erd-orders-rendered.html'],
19 ['erd', 'subscription-billing.erd.json', 'subscription-billing-rendered.html'],
20 ['tree', 'payment-platform.tree.json', 'tree-payment-platform-rendered.html'],
21 ['tree', 'archify-repository.tree.json', 'tree-archify-repository-rendered.html'],
22 ['class', 'payments.class.json', 'class-payments-rendered.html'],
23 ['class', 'payment-processors.class.json', 'class-payment-processors-rendered.html'],
24 ['timeline', 'payment-incident.timeline.json', 'timeline-payment-incident-rendered.html'],
25 ['timeline', 'archify-dev-activity.timeline.json', 'timeline-archify-dev-activity-rendered.html'],
26 ['waterfall', 'checkout-request.waterfall.json', 'waterfall-checkout-request-rendered.html'],
27 ['waterfall', 'example-rebuild.waterfall.json', 'waterfall-example-rebuild-rendered.html'],
28];
30for (const [mode, input, output] of TARGETS) {
31 execFileSync(process.execPath, [
32 path.join(skillRoot, `renderers/${mode}/render-${mode}.mjs`),
33 path.join(skillRoot, 'examples', input),
34 path.join(outputRoot, output),
35 ], { stdio: 'inherit' });
36}