/** * Charts the bundled flow sets in flows/ (the system and Shopify sets as deployed) into docs/flows//: a page per * flow and a README per set, generated by src/docs/flow-docs.js (exported as jsfe/docs). * * node scripts/flow-docs.mjs writes the generated parts * node scripts/flow-docs.mjs --check writes nothing; fails on a stale page, an orphan page or a broken link * (tests/flow-docs-current.test.mjs runs this in npm test) */ import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; import { generateFlowDocs } from '../src/docs/flow-docs.js'; const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); const read = (f) => JSON.parse(fs.readFileSync(path.join(ROOT, 'flows', f), 'utf8')); const { failed } = generateFlowDocs({ root: path.join(ROOT, 'docs/flows'), check: process.argv.includes('--check'), hostRun: { 'live-agent-handoff': 'the host, at every live-agent handoff' }, sets: [ { key: 'system', title: 'System flows', flows: read('system.flows.json'), tools: read('system.tools.json'), source: '`flows/system.flows.json`', how: 'The native forms in this set are built from `src/forms`; the rest is copied from the deployed set. Run `node scripts/flow-docs.mjs` after changing `flows/`.' }, { key: 'shopify', title: 'Shopify flows', flows: read('shopify.flows.json'), tools: read('shopify.tools.json'), source: '`flows/shopify.flows.json`', how: 'Run `node scripts/flow-docs.mjs` after changing `flows/`.' }, ], }); process.exit(failed ? 1 : 0);