#!/usr/bin/env tsx // Bakes each site's editor-authored chart templates into its export staging dir // as chart-templates.json, composed into the site's bundle by build:site. Falls // back to built-in presets when a site has authored no templates file. import { getPaths, type Paths } from "../lib/paths"; import { listSiteIds } from "../lib/site"; import { syncTemplatesToExport, siteTemplatesStagingPath, } from "../lib/chartsStore"; import { runIfEntryPoint } from "./_cli"; export async function main(opts: { paths?: Paths } = {}): Promise { const paths = opts.paths ?? getPaths(); const siteIds = listSiteIds(paths); if (siteIds.length === 0) { console.log("No sites configured; nothing to do."); } for (const siteId of siteIds) { syncTemplatesToExport(paths, siteId); console.log(`Wrote ${siteTemplatesStagingPath(paths, siteId)}`); } } runIfEntryPoint(import.meta.url, () => main());