import z from "zod"; import path from "node:path"; import fsExtra from "fs-extra"; import * as yaml from "yaml"; import type { baseSpecSchema } from "./base-spec-schema.js"; import { logger } from "../cli/logging.js"; export const generateExtraExports = async ( spec: z.infer, file: string, ) => { for (const extra of spec.extra ?? []) { const target = path.join(path.dirname(file), extra.file); await fsExtra.ensureDir(path.dirname(target)); if (extra.type === "text") { await fsExtra.writeFile(target, String(extra.content)); } else if (extra.type === "json") { await fsExtra.writeFile(target, JSON.stringify(extra.content, null, 2)); } else if (extra.type === "yaml") { await fsExtra.writeFile(target, yaml.stringify(extra.content)); } logger.success(`Generated {${extra.file}} from {${file}}`); } };