@zod-to-form/cli 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +26 -31
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -37,13 +37,13 @@ Alias: `z2f`.
37
37
 
38
38
  Required options:
39
39
 
40
+ - `--config <path>`: path to config file (`.json` or `.ts`) that drives generation
40
41
  - `--schema <path>`: path to schema module
41
- - `--export <name>`: named export containing the schema
42
42
 
43
43
  Optional options:
44
44
 
45
+ - `--export <name>`: named export containing the schema (optional when `config.types` or `config.include` are set)
45
46
  - `--mode <mode>`: `submit | auto-save` (default `submit`)
46
- - `--config <path>`: path to generate config (`.json` or `.ts`) **required**
47
47
  - `--out <path>`: output directory or `.tsx` file path
48
48
  - `--name <componentName>`: generated component name override
49
49
  - `--ui <preset>`: `shadcn | unstyled` (default `shadcn`)
@@ -78,6 +78,7 @@ Optional options:
78
78
 
79
79
  - `--out <path>`: output file or directory (default `z2f.config.ts`)
80
80
  - `--components <modulePath>`: module path assigned to `components` in generated config (overrides inference)
81
+ - `--schemas <path>`: path to schema file or directory for autodiscovery
81
82
  - `--force`: overwrite existing config file
82
83
  - `--dry-run`: print generated config and skip file writes
83
84
  - `--verbose`: print detailed diagnostics for each step
@@ -139,42 +140,36 @@ zod-to-form init --components ../../src/components/zod-form-components
139
140
 
140
141
  The package exports helpers to define and validate component config.
141
142
 
142
- ### `defineComponentConfig(...)`
143
+ ### `defineConfig(...)`
143
144
 
144
- `defineComponentConfig` gives type-safe field path support (including array path normalization).
145
+ `defineConfig` (re-exported from `@zod-to-form/core`) gives type-safe config construction with preset merging.
145
146
 
146
147
  ```ts
147
- import { defineComponentConfig } from '@zod-to-form/cli';
148
-
149
- type Values = {
150
- profile: { bio: string };
151
- tags: Array<{ label: string }>;
152
- };
153
-
154
- type Components = {
155
- TextInput: unknown;
156
- TextareaInput: unknown;
157
- };
158
-
159
- export default defineComponentConfig<Components, Values>({
160
- components: '@/components/form-components',
161
- overwrite: true,
148
+ import { defineConfig } from '@zod-to-form/cli';
149
+
150
+ export default defineConfig({
151
+ components: {
152
+ source: '@/components/form-components',
153
+ preset: 'shadcn',
154
+ overrides: {
155
+ TextareaInput: { controlled: false },
156
+ },
157
+ },
162
158
  types: ['userSchema'],
163
159
  include: ['*Schema'],
164
160
  exclude: ['Internal*'],
161
+ defaults: {
162
+ overwrite: true,
163
+ },
165
164
  formPrimitives: {
166
165
  field: 'Field',
167
166
  label: 'FieldLabel',
168
- control: 'FieldControl'
169
- },
170
- fieldTypes: {
171
- Input: { component: 'TextInput' },
172
- textarea: { component: 'TextareaInput' }
167
+ control: 'FieldControl',
173
168
  },
174
169
  fields: {
175
- 'profile.bio': { fieldType: 'textarea', props: { rows: 5 } },
176
- 'tags[].label': { fieldType: 'Input' }
177
- }
170
+ 'profile.bio': { component: 'TextareaInput', props: { rows: 5 } },
171
+ 'tags[].label': { component: 'TextInput' },
172
+ },
178
173
  });
179
174
  ```
180
175
 
@@ -198,14 +193,14 @@ formPrimitives: {
198
193
  }
199
194
  ```
200
195
 
201
- ### `validateComponentConfig(...)`
196
+ ### `validateConfig(...)`
202
197
 
203
- Use at runtime when loading external config objects.
198
+ Use at runtime when loading external config objects. Validates and returns a typed `ZodFormsConfig`.
204
199
 
205
200
  ```ts
206
- import { validateComponentConfig } from '@zod-to-form/cli';
201
+ import { validateConfig } from '@zod-to-form/cli';
207
202
 
208
- const parsed = validateComponentConfig(configObject, 'component-config');
203
+ const parsed = validateConfig(configObject, 'component-config');
209
204
  ```
210
205
 
211
206
  ## Programmatic API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zod-to-form/cli",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Build-time code generator for Zod v4 form components",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/pradeepmouli/zod-to-form#readme",
@@ -37,7 +37,7 @@
37
37
  "chokidar": "^5.0.0",
38
38
  "commander": "^14.0.3",
39
39
  "jiti": "^2.6.1",
40
- "@zod-to-form/core": "0.6.0"
40
+ "@zod-to-form/core": "0.6.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "zod": "^4.3.6"