// `archilyzer reports export [--report ] [--formats html,pdf,md,slides,slides-pdf,zip]` // — write a site's published reports as files (report.html, report.pdf, // report.md, slides.html, slides.pdf, evidence-pack.zip) into // `.export-index/sites//report-exports//`, where compose // publishes them from. The work is publish/reportExports.ts's, the same the // editor's `reports-export` job runs; this file prints its log and problems. // // Exit 0 when every asked-for export was written (a PDF skipped for want of a // browser is a note, not a problem); 1 when any problem is listed; 2 for bad // arguments or a site or report that does not exist. import { exportSiteReports, formatReportExportProblems, type ExportSiteReportsOptions, } from "../publish/reportExports"; type Out = { log: (s: string) => void; error: (s: string) => void }; export async function main( opts: Omit, out: Out = console, ): Promise { let result; try { result = await exportSiteReports({ ...opts, onLog: out.log }); } catch (err) { out.error(`reports export: ${(err as Error).message}`); return opts.signal?.aborted ? 1 : 2; } for (const r of result.exported) { for (const note of r.manifest.notes) out.log(` note: ${r.reportId}: ${note}`); } if (result.problems.length === 0) return 0; out.error(`reports export ${opts.siteId}: ${result.problems.length} problem(s):`); for (const line of formatReportExportProblems(result.problems)) out.error(` ${line}`); return 1; }