mirror of
https://github.com/hanzoai/gui.git
synced 2026-10-25 02:31:41 +00:00
Every published manifest now states the same exports: types, the native emit where the package builds one, ESM under import and CommonJS under require, with src, types and dist in files. The nine packages that read import.meta do so in one here.ts each, with a here.cjs.ts sibling for the CommonJS emit; the stragglers on bun, esbuild, plain tsc or hand-written shims build with the runner like everything else, and the root-level .cjs shims that pointed at emits no build produces are gone, as is the vite-plugin-cjs mirror. Co-authored-by: Hanzo Dev <[email protected]>
28 lines
742 B
TypeScript
28 lines
742 B
TypeScript
import { readFile, writeFile } from 'node:fs/promises'
|
|
|
|
import type { generateThemes } from './generate-themes.ts'
|
|
|
|
export async function writeGeneratedThemes(
|
|
hanzoguiDotDir: string,
|
|
outPath: string,
|
|
generatedOutput: Awaited<ReturnType<typeof generateThemes>>
|
|
) {
|
|
if (!generatedOutput) return
|
|
|
|
const { generated } = generatedOutput
|
|
|
|
if (process.env.DEBUG === 'hanzogui') {
|
|
console.info(`Generated themes:`, JSON.stringify(generatedOutput, null, 2))
|
|
}
|
|
|
|
const newContent = `// @ts-nocheck\n` + generated
|
|
|
|
// Skip writing if contents are unchanged
|
|
const existingContent = await readFile(outPath, 'utf-8').catch(() => null)
|
|
if (existingContent === newContent) {
|
|
return
|
|
}
|
|
|
|
await writeFile(outPath, newContent)
|
|
}
|