UNPKG

@maizzle/framework

Version:

Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.

44 lines (43 loc) 1.53 kB
import { resolveConfig } from "./config/index.js"; import { isLaravel } from "./utils/detect.js"; import { normalizeComponentSources } from "./utils/componentSources.js"; import { createRenderer } from "./render/createRenderer.js"; import { relative, resolve } from "node:path"; import ora from "ora"; //#region src/prepare.ts /** * Generate IDE type definitions in `.maizzle/` * (`auto-imports.d.ts` and `components.d.ts`). * * Intended as a `postinstall` step so editors get autocompletion before the * user runs `dev` or `build`. Spins up the renderer with `dts: true`, runs * a trivial render to trigger the unplugin scans, then shuts down. */ async function prepare(options = {}) { const spinner = ora({ text: "Generating types...", spinner: "circleHalves" }).start(); const config = await resolveConfig(options.config); const renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite }); try { await renderer.render("<template><div></div></template>", config); } finally { await renderer.close(); } const dtsDir = isLaravel() ? resolve(process.cwd(), "resources/js/types/maizzle") : resolve(config.root ?? process.cwd(), ".maizzle"); const displayPath = relative(process.cwd(), dtsDir) || dtsDir; spinner.stopAndPersist({ symbol: "✅", text: `Types generated in ${displayPath}` }); } //#endregion export { prepare }; //# sourceMappingURL=prepare.js.map