Files
oh-my-pi/packages/coding-agent/scripts/generate-template.ts
T
can1357 440ac33dbf style: reformatted TypeScript code formatting and added benchmark reports
- Reformatted code indentation and spacing across multiple TypeScript files.
- Standardized export statements to single-line format in various modules.
- Fixed async/await precedence and corrected indentation in benchmark files.
- Added benchmark report files for GPT-5.1-codex-mini model performance.
2026-01-19 16:22:47 +01:00

33 lines
971 B
TypeScript

#!/usr/bin/env bun
/**
* Pre-compute the HTML template at publish time.
* This avoids the Bun macro restriction in node_modules.
*/
const dir = new URL("../src/core/export-html/", import.meta.url).pathname;
// Read all files
const html = await Bun.file(`${dir}template.html`).text();
const css = await Bun.file(`${dir}template.css`).text();
const js = await Bun.file(`${dir}template.js`).text();
// Minify CSS
const minifiedCss = css
.replace(/\/\*[\s\S]*?\*\//g, "")
.replace(/\s+/g, " ")
.replace(/\s*([{}:;,])\s*/g, "$1")
.trim();
// Inline everything
const template = html
.replace("<template-css/>", `<style>${minifiedCss}</style>`)
.replace("<template-js/>", `<script>${js}</script>`);
// Write generated file
const output = `// Auto-generated by scripts/generate-template.ts - DO NOT EDIT
export const TEMPLATE = ${JSON.stringify(template)};
`;
await Bun.write(`${dir}template.generated.ts`, output);
console.log("Generated template.generated.ts");