Skip to main content

Function: buildConfigSource()

buildConfigSource(opts): string

Defined in: packages/codegen/src/config-template.ts:59

Generate a z2f.config.ts starter file as a source string. Produces a defineConfig(...) call with components, defaults, include/exclude, optional fields, and schemas blocks based on the provided options.

Parameters

opts

ConfigTemplateOptions

Template options controlling the generated config structure.

Returns

string

The complete config file source as a string, ready to write to disk.

Example

const source = buildConfigSource({ componentSource: './components/ui', preset: 'shadcn' });
await fs.writeFile('z2f.config.ts', source);

Remarks

The generated file uses TypeScript generics for full type inference: defineConfig<typeof Components, typeof ZodSchemas>(...). Preset-specific overrides (e.g. SHADCN_OVERRIDES) are spread into the overrides block.