zod-commander 0.1.0 → 0.1.2
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.
- package/dist/chunk-Cmkb9WIj.cjs +15 -0
- package/dist/chunk-Dco9itRc.mjs +9 -0
- package/dist/common--ZfG2Kuo.d.mts +8 -0
- package/dist/common-x9DEqOZ0.d.cts +7 -0
- package/dist/zod3/index.cjs +96 -78
- package/dist/zod3/index.cjs.map +1 -1
- package/dist/zod3/index.d.cts +22 -19
- package/dist/zod3/{index.d.ts → index.d.mts} +23 -19
- package/dist/zod3/index.mjs +101 -0
- package/dist/zod3/index.mjs.map +1 -0
- package/dist/zod4/index.cjs +99 -80
- package/dist/zod4/index.cjs.map +1 -1
- package/dist/zod4/index.d.cts +22 -19
- package/dist/zod4/{index.d.ts → index.d.mts} +23 -19
- package/dist/zod4/index.mjs +104 -0
- package/dist/zod4/index.mjs.map +1 -0
- package/package.json +18 -18
- package/dist/chunk-7QVYU63E.js +0 -6
- package/dist/chunk-7QVYU63E.js.map +0 -1
- package/dist/zod3/index.js +0 -81
- package/dist/zod3/index.js.map +0 -1
- package/dist/zod4/index.js +0 -83
- package/dist/zod4/index.js.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
+
value,
|
|
5
|
+
configurable: true
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__name', {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return __name;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as __name } from "./chunk-Dco9itRc.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/common.d.ts
|
|
4
|
+
type BeforeFirstUnderscore<S> = S extends `${infer T}_${infer _}` ? T : S;
|
|
5
|
+
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { Prettify as n, BeforeFirstUnderscore as t };
|
|
8
|
+
//# sourceMappingURL=common--ZfG2Kuo.d.mts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#endregion
|
|
2
|
+
//#region src/common.d.ts
|
|
3
|
+
type BeforeFirstUnderscore<S> = S extends `${infer T}_${infer _}` ? T : S;
|
|
4
|
+
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
5
|
+
//#endregion
|
|
6
|
+
export { Prettify as n, __name as r, BeforeFirstUnderscore as t };
|
|
7
|
+
//# sourceMappingURL=common-x9DEqOZ0.d.cts.map
|
package/dist/zod3/index.cjs
CHANGED
|
@@ -1,86 +1,104 @@
|
|
|
1
|
-
'
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_chunk = require('../chunk-Cmkb9WIj.cjs');
|
|
3
|
+
let commander = require("commander");
|
|
4
|
+
let zod_v3 = require("zod/v3");
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
zodDefault
|
|
6
|
+
//#region src/zod3/utils.ts
|
|
7
|
+
const zodCore = (zod, fn) => {
|
|
8
|
+
const types = [
|
|
9
|
+
zod_v3.z.ZodDefault,
|
|
10
|
+
zod_v3.z.ZodNullable,
|
|
11
|
+
zod_v3.z.ZodOptional
|
|
12
|
+
];
|
|
13
|
+
for (const type of types) if (zod instanceof type) return zodCore(zod._def.innerType, fn);
|
|
14
|
+
if (zod instanceof zod_v3.z.ZodEffects) return zodCore(zod._def.schema, fn);
|
|
15
|
+
return fn(zod);
|
|
16
|
+
};
|
|
17
|
+
const zodEnumVals = (zod) => zodCore(zod, (zod) => zod instanceof zod_v3.z.ZodEnum ? zod._def.values : null);
|
|
18
|
+
const zodIsBoolean = (zod) => zodCore(zod, (zod) => zod instanceof zod_v3.z.ZodBoolean);
|
|
19
|
+
const zodDefault = (zod) => zod instanceof zod_v3.z.ZodEffects ? zodDefault(zod._def.schema) : zod instanceof zod_v3.z.ZodDefault ? zod._def.defaultValue() : void 0;
|
|
20
|
+
const utils = {
|
|
21
|
+
zodCore,
|
|
22
|
+
zodEnumVals,
|
|
23
|
+
zodIsBoolean,
|
|
24
|
+
zodDefault
|
|
23
25
|
};
|
|
24
|
-
var utils_default = utils;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/zod3/index.ts
|
|
29
|
+
/**
|
|
30
|
+
* Utilities for building type-safe Commander commands using Zod schemas.
|
|
31
|
+
* @module
|
|
32
|
+
*/
|
|
33
|
+
const zodParser = (zod, opt) => (value) => {
|
|
34
|
+
const result = zod.safeParse(value);
|
|
35
|
+
if (result.success) return result.data;
|
|
36
|
+
const msg = result.error.issues[0].message;
|
|
37
|
+
if (opt) throw new commander.InvalidOptionArgumentError(msg);
|
|
38
|
+
throw new commander.InvalidArgumentError(msg);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Creates a Commander.js Argument from a Zod schema.
|
|
42
|
+
* Handles optionality, default values, and enum choices.
|
|
43
|
+
* @param key - The argument name
|
|
44
|
+
* @param zod - The Zod schema for the argument
|
|
45
|
+
* @returns A Commander Argument instance
|
|
46
|
+
*/
|
|
47
|
+
const zodArgument = (key, zod) => {
|
|
48
|
+
const arg = new commander.Argument(zod.isOptional() ? `[${key}]` : `<${key}>`, zod.description);
|
|
49
|
+
const def = utils.zodDefault(zod);
|
|
50
|
+
if (def !== void 0) arg.default(zod.parse(def));
|
|
51
|
+
const choices = utils.zodEnumVals(zod);
|
|
52
|
+
if (choices) arg.choices(choices);
|
|
53
|
+
return arg.argParser(zodParser(zod));
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Creates a Commander.js Option from a Zod schema.
|
|
57
|
+
* Handles optionality, default values, enum choices, and boolean flags.
|
|
58
|
+
* Supports short flags via description prefix (e.g., 's;...').
|
|
59
|
+
* @param key - The option name (can include underscores for grouping)
|
|
60
|
+
* @param zod - The Zod schema for the option
|
|
61
|
+
* @returns A Commander Option instance
|
|
62
|
+
*/
|
|
63
|
+
const zodOption = (key, zod) => {
|
|
64
|
+
const abbr = zod.description?.match(/^(\w);/)?.[1];
|
|
65
|
+
const description = abbr ? zod.description.slice(2) : zod.description;
|
|
66
|
+
const arg = key.includes("_") ? key.split("_").slice(1).join("-") : key;
|
|
67
|
+
if (key.includes("_")) [key] = key.split("_");
|
|
68
|
+
const isBoolean = utils.zodIsBoolean(zod);
|
|
69
|
+
const flag = `--${key}${isBoolean ? "" : ` <${arg}>`}`;
|
|
70
|
+
const opt = new commander.Option(abbr ? `-${abbr}, ${flag}` : flag, description);
|
|
71
|
+
if (isBoolean) opt.optional = true;
|
|
72
|
+
else if (!zod.isOptional()) opt.makeOptionMandatory();
|
|
73
|
+
const def = utils.zodDefault(zod);
|
|
74
|
+
if (def !== void 0) opt.default(zod.parse(def));
|
|
75
|
+
const choices = utils.zodEnumVals(zod);
|
|
76
|
+
if (choices) opt.choices(choices);
|
|
77
|
+
return opt.argParser(zodParser(zod, "opt"));
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Defines a Commander.js Command using Zod schemas for arguments and options.
|
|
81
|
+
* Automatically wires up parsing, validation, and help configuration.
|
|
82
|
+
* @template A - ZodRawShape for arguments
|
|
83
|
+
* @template O - ZodRawShape for options
|
|
84
|
+
* @param props - Command properties (name, description, args, opts, action)
|
|
85
|
+
* @returns A Commander Command instance
|
|
86
|
+
*/
|
|
87
|
+
const zodCommand = ({ name, description, args, opts, action }) => {
|
|
88
|
+
const command = new commander.Command(name);
|
|
89
|
+
if (description) command.description(description);
|
|
90
|
+
for (const key in args) command.addArgument(zodArgument(key, args[key]));
|
|
91
|
+
for (const key in opts) command.addOption(zodOption(key, opts[key]));
|
|
92
|
+
if (action) command.action(async (...all) => {
|
|
93
|
+
const resultArgs = Object.fromEntries(Object.keys(args ?? {}).map((key, i) => [key, all[i]]));
|
|
94
|
+
const resultOpts = all[Object.keys(args ?? {}).length];
|
|
95
|
+
await action(resultArgs, resultOpts);
|
|
96
|
+
});
|
|
97
|
+
return command;
|
|
98
|
+
};
|
|
81
99
|
|
|
100
|
+
//#endregion
|
|
82
101
|
exports.zodArgument = zodArgument;
|
|
83
102
|
exports.zodCommand = zodCommand;
|
|
84
103
|
exports.zodOption = zodOption;
|
|
85
|
-
//# sourceMappingURL=index.cjs.map
|
|
86
104
|
//# sourceMappingURL=index.cjs.map
|
package/dist/zod3/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["z","InvalidOptionArgumentError","InvalidArgumentError","Argument","Option","Command"],"sources":["../../src/zod3/utils.ts","../../src/zod3/index.ts"],"sourcesContent":["import { z } from 'zod/v3'\n\nconst zodCore = <T>(zod: z.ZodTypeAny, fn: (zod: z.ZodTypeAny) => T): T => {\n\tconst types = [z.ZodDefault, z.ZodNullable, z.ZodOptional]\n\tfor (const type of types)\n\t\tif (zod instanceof type) return zodCore(zod._def.innerType, fn)\n\tif (zod instanceof z.ZodEffects) return zodCore(zod._def.schema, fn)\n\treturn fn(zod)\n}\n\nconst zodEnumVals = (zod: z.ZodTypeAny): string[] | null =>\n\tzodCore(zod, (zod) => (zod instanceof z.ZodEnum ? zod._def.values : null))\n\nconst zodIsBoolean = (zod: z.ZodTypeAny): boolean =>\n\tzodCore(zod, (zod) => zod instanceof z.ZodBoolean)\n\nconst zodDefault = <Output, Def extends z.ZodTypeDef, Input>(\n\tzod: z.ZodType<Output, Def, Input>,\n): Input | undefined =>\n\tzod instanceof z.ZodEffects\n\t\t? zodDefault(zod._def.schema)\n\t\t: zod instanceof z.ZodDefault\n\t\t\t? zod._def.defaultValue()\n\t\t\t: undefined\n\nconst utils = {\n\tzodCore,\n\tzodEnumVals,\n\tzodIsBoolean,\n\tzodDefault,\n}\n\nexport default utils\n","/**\n * Utilities for building type-safe Commander commands using Zod schemas.\n * @module\n */\n\nimport {\n\tArgument,\n\tCommand,\n\tInvalidArgumentError,\n\tInvalidOptionArgumentError,\n\tOption,\n} from 'commander'\nimport type { z } from 'zod/v3'\nimport type { BeforeFirstUnderscore, Prettify } from '#/common.js'\nimport utils from './utils.js'\n\nexport type { Argument, Command, Option } from 'commander'\n\ntype ReplaceKeyTypes<Type extends z.ZodRawShape> = {\n\t[Key in keyof Type as BeforeFirstUnderscore<Key>]: Type[Key]\n}\n\n/**\n * The action function signature for a Zod-powered command.\n * @template A - ZodRawShape for arguments\n * @template O - ZodRawShape for options\n * @param args - Parsed and validated arguments\n * @param opts - Parsed and validated options (with key normalization)\n * @returns A Promise or void\n */\nexport type ZodCommandAction<\n\tA extends z.ZodRawShape,\n\tO extends z.ZodRawShape,\n> = ZodCommandProps<A, O>['action']\n\ntype ZodCommandProps<A extends z.ZodRawShape, O extends z.ZodRawShape> = {\n\tname?: string\n\tdescription?: string\n\targs?: A\n\topts?: O\n\taction?: (\n\t\targs: Prettify<z.infer<z.ZodObject<A>>>,\n\t\topts: Prettify<z.infer<z.ZodObject<ReplaceKeyTypes<O>>>>,\n\t) => Promise<void> | void\n}\n\nconst zodParser = (zod: z.ZodTypeAny, opt?: 'opt') => (value: string) => {\n\tconst result = zod.safeParse(value)\n\tif (result.success) return result.data\n\tconst msg = result.error.issues[0].message\n\tif (opt) throw new InvalidOptionArgumentError(msg)\n\tthrow new InvalidArgumentError(msg)\n}\n\n/**\n * Creates a Commander.js Argument from a Zod schema.\n * Handles optionality, default values, and enum choices.\n * @param key - The argument name\n * @param zod - The Zod schema for the argument\n * @returns A Commander Argument instance\n */\nexport const zodArgument = (key: string, zod: z.ZodTypeAny): Argument => {\n\tconst flag = zod.isOptional() ? `[${key}]` : `<${key}>`\n\tconst arg = new Argument(flag, zod.description)\n\n\tconst def = utils.zodDefault(zod)\n\tif (def !== undefined) arg.default(zod.parse(def))\n\n\tconst choices = utils.zodEnumVals(zod)\n\tif (choices) arg.choices(choices)\n\n\t// parsing must be done at the end to override default parsers\n\treturn arg.argParser(zodParser(zod))\n}\n\n/**\n * Creates a Commander.js Option from a Zod schema.\n * Handles optionality, default values, enum choices, and boolean flags.\n * Supports short flags via description prefix (e.g., 's;...').\n * @param key - The option name (can include underscores for grouping)\n * @param zod - The Zod schema for the option\n * @returns A Commander Option instance\n */\nexport const zodOption = (key: string, zod: z.ZodTypeAny): Option => {\n\tconst abbr = zod.description?.match(/^(\\w);/)?.[1]\n\tconst description = abbr ? zod.description.slice(2) : zod.description\n\tconst arg = key.includes('_') ? key.split('_').slice(1).join('-') : key\n\tif (key.includes('_')) [key] = key.split('_')\n\tconst isBoolean = utils.zodIsBoolean(zod)\n\tconst flag = `--${key}${isBoolean ? '' : ` <${arg}>`}`\n\tconst flags = abbr ? `-${abbr}, ${flag}` : flag\n\tconst opt = new Option(flags, description)\n\n\t// required for boolean flags\n\tif (isBoolean) opt.optional = true\n\telse if (!zod.isOptional()) opt.makeOptionMandatory()\n\n\tconst def = utils.zodDefault(zod)\n\tif (def !== undefined) opt.default(zod.parse(def))\n\n\tconst choices = utils.zodEnumVals(zod)\n\tif (choices) opt.choices(choices)\n\n\t// parsing must be done at the end to override default parsers\n\treturn opt.argParser(zodParser(zod, 'opt'))\n}\n\n/**\n * Defines a Commander.js Command using Zod schemas for arguments and options.\n * Automatically wires up parsing, validation, and help configuration.\n * @template A - ZodRawShape for arguments\n * @template O - ZodRawShape for options\n * @param props - Command properties (name, description, args, opts, action)\n * @returns A Commander Command instance\n */\nexport const zodCommand = <A extends z.ZodRawShape, O extends z.ZodRawShape>({\n\tname,\n\tdescription,\n\targs,\n\topts,\n\taction,\n}: ZodCommandProps<A, O>): Command => {\n\tconst command = new Command(name)\n\tif (description) command.description(description)\n\tfor (const key in args) command.addArgument(zodArgument(key, args[key]))\n\tfor (const key in opts) command.addOption(zodOption(key, opts[key]))\n\tif (action)\n\t\tcommand.action(async (...all) => {\n\t\t\tconst resultArgs = Object.fromEntries(\n\t\t\t\tObject.keys(args ?? {}).map((key, i) => [key, all[i]]),\n\t\t\t) as z.infer<z.ZodObject<A>>\n\t\t\tconst resultOpts = all[Object.keys(args ?? {}).length] as z.infer<\n\t\t\t\tz.ZodObject<ReplaceKeyTypes<O>>\n\t\t\t>\n\t\t\tawait action(resultArgs, resultOpts)\n\t\t})\n\treturn command\n}\n"],"mappings":";;;;;;AAEA,MAAM,WAAc,KAAmB,OAAoC;CAC1E,MAAM,QAAQ;EAACA,SAAE;EAAYA,SAAE;EAA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
|
package/dist/zod3/index.d.cts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as Prettify, r as __name, t as BeforeFirstUnderscore } from "../common-x9DEqOZ0.cjs";
|
|
2
|
+
import { Argument, Argument as Argument$1, Command, Command as Command$1, Option, Option as Option$1 } from "commander";
|
|
3
|
+
import { z } from "zod/v3";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
type ReplaceKeyTypes<Type extends z.ZodRawShape> = {
|
|
6
|
-
[Key in keyof Type as BeforeFirstUnderscore<Key>]: Type[Key];
|
|
7
|
-
};
|
|
8
|
-
type Prettify<T> = {
|
|
9
|
-
[K in keyof T]: T[K];
|
|
10
|
-
} & {};
|
|
5
|
+
//#region src/zod3/index.d.ts
|
|
6
|
+
type ReplaceKeyTypes<Type extends z.ZodRawShape> = { [Key in keyof Type as BeforeFirstUnderscore<Key>]: Type[Key] };
|
|
11
7
|
/**
|
|
12
8
|
* The action function signature for a Zod-powered command.
|
|
13
9
|
* @template A - ZodRawShape for arguments
|
|
@@ -18,11 +14,11 @@ type Prettify<T> = {
|
|
|
18
14
|
*/
|
|
19
15
|
type ZodCommandAction<A extends z.ZodRawShape, O extends z.ZodRawShape> = ZodCommandProps<A, O>['action'];
|
|
20
16
|
type ZodCommandProps<A extends z.ZodRawShape, O extends z.ZodRawShape> = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
name?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
args?: A;
|
|
20
|
+
opts?: O;
|
|
21
|
+
action?: (args: Prettify<z.infer<z.ZodObject<A>>>, opts: Prettify<z.infer<z.ZodObject<ReplaceKeyTypes<O>>>>) => Promise<void> | void;
|
|
26
22
|
};
|
|
27
23
|
/**
|
|
28
24
|
* Creates a Commander.js Argument from a Zod schema.
|
|
@@ -31,7 +27,7 @@ type ZodCommandProps<A extends z.ZodRawShape, O extends z.ZodRawShape> = {
|
|
|
31
27
|
* @param zod - The Zod schema for the argument
|
|
32
28
|
* @returns A Commander Argument instance
|
|
33
29
|
*/
|
|
34
|
-
declare const zodArgument: (key: string, zod: z.ZodTypeAny) => Argument;
|
|
30
|
+
declare const zodArgument: (key: string, zod: z.ZodTypeAny) => Argument$1;
|
|
35
31
|
/**
|
|
36
32
|
* Creates a Commander.js Option from a Zod schema.
|
|
37
33
|
* Handles optionality, default values, enum choices, and boolean flags.
|
|
@@ -40,7 +36,7 @@ declare const zodArgument: (key: string, zod: z.ZodTypeAny) => Argument;
|
|
|
40
36
|
* @param zod - The Zod schema for the option
|
|
41
37
|
* @returns A Commander Option instance
|
|
42
38
|
*/
|
|
43
|
-
declare const zodOption: (key: string, zod: z.ZodTypeAny) => Option;
|
|
39
|
+
declare const zodOption: (key: string, zod: z.ZodTypeAny) => Option$1;
|
|
44
40
|
/**
|
|
45
41
|
* Defines a Commander.js Command using Zod schemas for arguments and options.
|
|
46
42
|
* Automatically wires up parsing, validation, and help configuration.
|
|
@@ -49,6 +45,13 @@ declare const zodOption: (key: string, zod: z.ZodTypeAny) => Option;
|
|
|
49
45
|
* @param props - Command properties (name, description, args, opts, action)
|
|
50
46
|
* @returns A Commander Command instance
|
|
51
47
|
*/
|
|
52
|
-
declare const zodCommand: <A extends z.ZodRawShape, O extends z.ZodRawShape>({
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
declare const zodCommand: <A extends z.ZodRawShape, O extends z.ZodRawShape>({
|
|
49
|
+
name,
|
|
50
|
+
description,
|
|
51
|
+
args,
|
|
52
|
+
opts,
|
|
53
|
+
action
|
|
54
|
+
}: ZodCommandProps<A, O>) => Command$1;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { type Argument, type Command, type Option, ZodCommandAction, zodArgument, zodCommand, zodOption };
|
|
57
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as __name } from "../chunk-Dco9itRc.mjs";
|
|
2
|
+
import { n as Prettify, t as BeforeFirstUnderscore } from "../common--ZfG2Kuo.mjs";
|
|
3
|
+
import { Argument, Argument as Argument$1, Command, Command as Command$1, Option, Option as Option$1 } from "commander";
|
|
4
|
+
import { z } from "zod/v3";
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
type ReplaceKeyTypes<Type extends z.ZodRawShape> = {
|
|
6
|
-
[Key in keyof Type as BeforeFirstUnderscore<Key>]: Type[Key];
|
|
7
|
-
};
|
|
8
|
-
type Prettify<T> = {
|
|
9
|
-
[K in keyof T]: T[K];
|
|
10
|
-
} & {};
|
|
6
|
+
//#region src/zod3/index.d.ts
|
|
7
|
+
type ReplaceKeyTypes<Type extends z.ZodRawShape> = { [Key in keyof Type as BeforeFirstUnderscore<Key>]: Type[Key] };
|
|
11
8
|
/**
|
|
12
9
|
* The action function signature for a Zod-powered command.
|
|
13
10
|
* @template A - ZodRawShape for arguments
|
|
@@ -18,11 +15,11 @@ type Prettify<T> = {
|
|
|
18
15
|
*/
|
|
19
16
|
type ZodCommandAction<A extends z.ZodRawShape, O extends z.ZodRawShape> = ZodCommandProps<A, O>['action'];
|
|
20
17
|
type ZodCommandProps<A extends z.ZodRawShape, O extends z.ZodRawShape> = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
name?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
args?: A;
|
|
21
|
+
opts?: O;
|
|
22
|
+
action?: (args: Prettify<z.infer<z.ZodObject<A>>>, opts: Prettify<z.infer<z.ZodObject<ReplaceKeyTypes<O>>>>) => Promise<void> | void;
|
|
26
23
|
};
|
|
27
24
|
/**
|
|
28
25
|
* Creates a Commander.js Argument from a Zod schema.
|
|
@@ -31,7 +28,7 @@ type ZodCommandProps<A extends z.ZodRawShape, O extends z.ZodRawShape> = {
|
|
|
31
28
|
* @param zod - The Zod schema for the argument
|
|
32
29
|
* @returns A Commander Argument instance
|
|
33
30
|
*/
|
|
34
|
-
declare const zodArgument: (key: string, zod: z.ZodTypeAny) => Argument;
|
|
31
|
+
declare const zodArgument: (key: string, zod: z.ZodTypeAny) => Argument$1;
|
|
35
32
|
/**
|
|
36
33
|
* Creates a Commander.js Option from a Zod schema.
|
|
37
34
|
* Handles optionality, default values, enum choices, and boolean flags.
|
|
@@ -40,7 +37,7 @@ declare const zodArgument: (key: string, zod: z.ZodTypeAny) => Argument;
|
|
|
40
37
|
* @param zod - The Zod schema for the option
|
|
41
38
|
* @returns A Commander Option instance
|
|
42
39
|
*/
|
|
43
|
-
declare const zodOption: (key: string, zod: z.ZodTypeAny) => Option;
|
|
40
|
+
declare const zodOption: (key: string, zod: z.ZodTypeAny) => Option$1;
|
|
44
41
|
/**
|
|
45
42
|
* Defines a Commander.js Command using Zod schemas for arguments and options.
|
|
46
43
|
* Automatically wires up parsing, validation, and help configuration.
|
|
@@ -49,6 +46,13 @@ declare const zodOption: (key: string, zod: z.ZodTypeAny) => Option;
|
|
|
49
46
|
* @param props - Command properties (name, description, args, opts, action)
|
|
50
47
|
* @returns A Commander Command instance
|
|
51
48
|
*/
|
|
52
|
-
declare const zodCommand: <A extends z.ZodRawShape, O extends z.ZodRawShape>({
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
declare const zodCommand: <A extends z.ZodRawShape, O extends z.ZodRawShape>({
|
|
50
|
+
name,
|
|
51
|
+
description,
|
|
52
|
+
args,
|
|
53
|
+
opts,
|
|
54
|
+
action
|
|
55
|
+
}: ZodCommandProps<A, O>) => Command$1;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { type Argument, type Command, type Option, ZodCommandAction, zodArgument, zodCommand, zodOption };
|
|
58
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { t as __name } from "../chunk-Dco9itRc.mjs";
|
|
2
|
+
import { Argument, Command, InvalidArgumentError, InvalidOptionArgumentError, Option } from "commander";
|
|
3
|
+
import { z } from "zod/v3";
|
|
4
|
+
|
|
5
|
+
//#region src/zod3/utils.ts
|
|
6
|
+
const zodCore = (zod, fn) => {
|
|
7
|
+
const types = [
|
|
8
|
+
z.ZodDefault,
|
|
9
|
+
z.ZodNullable,
|
|
10
|
+
z.ZodOptional
|
|
11
|
+
];
|
|
12
|
+
for (const type of types) if (zod instanceof type) return zodCore(zod._def.innerType, fn);
|
|
13
|
+
if (zod instanceof z.ZodEffects) return zodCore(zod._def.schema, fn);
|
|
14
|
+
return fn(zod);
|
|
15
|
+
};
|
|
16
|
+
const zodEnumVals = (zod) => zodCore(zod, (zod) => zod instanceof z.ZodEnum ? zod._def.values : null);
|
|
17
|
+
const zodIsBoolean = (zod) => zodCore(zod, (zod) => zod instanceof z.ZodBoolean);
|
|
18
|
+
const zodDefault = (zod) => zod instanceof z.ZodEffects ? zodDefault(zod._def.schema) : zod instanceof z.ZodDefault ? zod._def.defaultValue() : void 0;
|
|
19
|
+
const utils = {
|
|
20
|
+
zodCore,
|
|
21
|
+
zodEnumVals,
|
|
22
|
+
zodIsBoolean,
|
|
23
|
+
zodDefault
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/zod3/index.ts
|
|
28
|
+
/**
|
|
29
|
+
* Utilities for building type-safe Commander commands using Zod schemas.
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
const zodParser = (zod, opt) => (value) => {
|
|
33
|
+
const result = zod.safeParse(value);
|
|
34
|
+
if (result.success) return result.data;
|
|
35
|
+
const msg = result.error.issues[0].message;
|
|
36
|
+
if (opt) throw new InvalidOptionArgumentError(msg);
|
|
37
|
+
throw new InvalidArgumentError(msg);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Creates a Commander.js Argument from a Zod schema.
|
|
41
|
+
* Handles optionality, default values, and enum choices.
|
|
42
|
+
* @param key - The argument name
|
|
43
|
+
* @param zod - The Zod schema for the argument
|
|
44
|
+
* @returns A Commander Argument instance
|
|
45
|
+
*/
|
|
46
|
+
const zodArgument = (key, zod) => {
|
|
47
|
+
const arg = new Argument(zod.isOptional() ? `[${key}]` : `<${key}>`, zod.description);
|
|
48
|
+
const def = utils.zodDefault(zod);
|
|
49
|
+
if (def !== void 0) arg.default(zod.parse(def));
|
|
50
|
+
const choices = utils.zodEnumVals(zod);
|
|
51
|
+
if (choices) arg.choices(choices);
|
|
52
|
+
return arg.argParser(zodParser(zod));
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Creates a Commander.js Option from a Zod schema.
|
|
56
|
+
* Handles optionality, default values, enum choices, and boolean flags.
|
|
57
|
+
* Supports short flags via description prefix (e.g., 's;...').
|
|
58
|
+
* @param key - The option name (can include underscores for grouping)
|
|
59
|
+
* @param zod - The Zod schema for the option
|
|
60
|
+
* @returns A Commander Option instance
|
|
61
|
+
*/
|
|
62
|
+
const zodOption = (key, zod) => {
|
|
63
|
+
const abbr = zod.description?.match(/^(\w);/)?.[1];
|
|
64
|
+
const description = abbr ? zod.description.slice(2) : zod.description;
|
|
65
|
+
const arg = key.includes("_") ? key.split("_").slice(1).join("-") : key;
|
|
66
|
+
if (key.includes("_")) [key] = key.split("_");
|
|
67
|
+
const isBoolean = utils.zodIsBoolean(zod);
|
|
68
|
+
const flag = `--${key}${isBoolean ? "" : ` <${arg}>`}`;
|
|
69
|
+
const opt = new Option(abbr ? `-${abbr}, ${flag}` : flag, description);
|
|
70
|
+
if (isBoolean) opt.optional = true;
|
|
71
|
+
else if (!zod.isOptional()) opt.makeOptionMandatory();
|
|
72
|
+
const def = utils.zodDefault(zod);
|
|
73
|
+
if (def !== void 0) opt.default(zod.parse(def));
|
|
74
|
+
const choices = utils.zodEnumVals(zod);
|
|
75
|
+
if (choices) opt.choices(choices);
|
|
76
|
+
return opt.argParser(zodParser(zod, "opt"));
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Defines a Commander.js Command using Zod schemas for arguments and options.
|
|
80
|
+
* Automatically wires up parsing, validation, and help configuration.
|
|
81
|
+
* @template A - ZodRawShape for arguments
|
|
82
|
+
* @template O - ZodRawShape for options
|
|
83
|
+
* @param props - Command properties (name, description, args, opts, action)
|
|
84
|
+
* @returns A Commander Command instance
|
|
85
|
+
*/
|
|
86
|
+
const zodCommand = ({ name, description, args, opts, action }) => {
|
|
87
|
+
const command = new Command(name);
|
|
88
|
+
if (description) command.description(description);
|
|
89
|
+
for (const key in args) command.addArgument(zodArgument(key, args[key]));
|
|
90
|
+
for (const key in opts) command.addOption(zodOption(key, opts[key]));
|
|
91
|
+
if (action) command.action(async (...all) => {
|
|
92
|
+
const resultArgs = Object.fromEntries(Object.keys(args ?? {}).map((key, i) => [key, all[i]]));
|
|
93
|
+
const resultOpts = all[Object.keys(args ?? {}).length];
|
|
94
|
+
await action(resultArgs, resultOpts);
|
|
95
|
+
});
|
|
96
|
+
return command;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { zodArgument, zodCommand, zodOption };
|
|
101
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/zod3/utils.ts","../../src/zod3/index.ts"],"sourcesContent":["import { z } from 'zod/v3'\n\nconst zodCore = <T>(zod: z.ZodTypeAny, fn: (zod: z.ZodTypeAny) => T): T => {\n\tconst types = [z.ZodDefault, z.ZodNullable, z.ZodOptional]\n\tfor (const type of types)\n\t\tif (zod instanceof type) return zodCore(zod._def.innerType, fn)\n\tif (zod instanceof z.ZodEffects) return zodCore(zod._def.schema, fn)\n\treturn fn(zod)\n}\n\nconst zodEnumVals = (zod: z.ZodTypeAny): string[] | null =>\n\tzodCore(zod, (zod) => (zod instanceof z.ZodEnum ? zod._def.values : null))\n\nconst zodIsBoolean = (zod: z.ZodTypeAny): boolean =>\n\tzodCore(zod, (zod) => zod instanceof z.ZodBoolean)\n\nconst zodDefault = <Output, Def extends z.ZodTypeDef, Input>(\n\tzod: z.ZodType<Output, Def, Input>,\n): Input | undefined =>\n\tzod instanceof z.ZodEffects\n\t\t? zodDefault(zod._def.schema)\n\t\t: zod instanceof z.ZodDefault\n\t\t\t? zod._def.defaultValue()\n\t\t\t: undefined\n\nconst utils = {\n\tzodCore,\n\tzodEnumVals,\n\tzodIsBoolean,\n\tzodDefault,\n}\n\nexport default utils\n","/**\n * Utilities for building type-safe Commander commands using Zod schemas.\n * @module\n */\n\nimport {\n\tArgument,\n\tCommand,\n\tInvalidArgumentError,\n\tInvalidOptionArgumentError,\n\tOption,\n} from 'commander'\nimport type { z } from 'zod/v3'\nimport type { BeforeFirstUnderscore, Prettify } from '#/common.js'\nimport utils from './utils.js'\n\nexport type { Argument, Command, Option } from 'commander'\n\ntype ReplaceKeyTypes<Type extends z.ZodRawShape> = {\n\t[Key in keyof Type as BeforeFirstUnderscore<Key>]: Type[Key]\n}\n\n/**\n * The action function signature for a Zod-powered command.\n * @template A - ZodRawShape for arguments\n * @template O - ZodRawShape for options\n * @param args - Parsed and validated arguments\n * @param opts - Parsed and validated options (with key normalization)\n * @returns A Promise or void\n */\nexport type ZodCommandAction<\n\tA extends z.ZodRawShape,\n\tO extends z.ZodRawShape,\n> = ZodCommandProps<A, O>['action']\n\ntype ZodCommandProps<A extends z.ZodRawShape, O extends z.ZodRawShape> = {\n\tname?: string\n\tdescription?: string\n\targs?: A\n\topts?: O\n\taction?: (\n\t\targs: Prettify<z.infer<z.ZodObject<A>>>,\n\t\topts: Prettify<z.infer<z.ZodObject<ReplaceKeyTypes<O>>>>,\n\t) => Promise<void> | void\n}\n\nconst zodParser = (zod: z.ZodTypeAny, opt?: 'opt') => (value: string) => {\n\tconst result = zod.safeParse(value)\n\tif (result.success) return result.data\n\tconst msg = result.error.issues[0].message\n\tif (opt) throw new InvalidOptionArgumentError(msg)\n\tthrow new InvalidArgumentError(msg)\n}\n\n/**\n * Creates a Commander.js Argument from a Zod schema.\n * Handles optionality, default values, and enum choices.\n * @param key - The argument name\n * @param zod - The Zod schema for the argument\n * @returns A Commander Argument instance\n */\nexport const zodArgument = (key: string, zod: z.ZodTypeAny): Argument => {\n\tconst flag = zod.isOptional() ? `[${key}]` : `<${key}>`\n\tconst arg = new Argument(flag, zod.description)\n\n\tconst def = utils.zodDefault(zod)\n\tif (def !== undefined) arg.default(zod.parse(def))\n\n\tconst choices = utils.zodEnumVals(zod)\n\tif (choices) arg.choices(choices)\n\n\t// parsing must be done at the end to override default parsers\n\treturn arg.argParser(zodParser(zod))\n}\n\n/**\n * Creates a Commander.js Option from a Zod schema.\n * Handles optionality, default values, enum choices, and boolean flags.\n * Supports short flags via description prefix (e.g., 's;...').\n * @param key - The option name (can include underscores for grouping)\n * @param zod - The Zod schema for the option\n * @returns A Commander Option instance\n */\nexport const zodOption = (key: string, zod: z.ZodTypeAny): Option => {\n\tconst abbr = zod.description?.match(/^(\\w);/)?.[1]\n\tconst description = abbr ? zod.description.slice(2) : zod.description\n\tconst arg = key.includes('_') ? key.split('_').slice(1).join('-') : key\n\tif (key.includes('_')) [key] = key.split('_')\n\tconst isBoolean = utils.zodIsBoolean(zod)\n\tconst flag = `--${key}${isBoolean ? '' : ` <${arg}>`}`\n\tconst flags = abbr ? `-${abbr}, ${flag}` : flag\n\tconst opt = new Option(flags, description)\n\n\t// required for boolean flags\n\tif (isBoolean) opt.optional = true\n\telse if (!zod.isOptional()) opt.makeOptionMandatory()\n\n\tconst def = utils.zodDefault(zod)\n\tif (def !== undefined) opt.default(zod.parse(def))\n\n\tconst choices = utils.zodEnumVals(zod)\n\tif (choices) opt.choices(choices)\n\n\t// parsing must be done at the end to override default parsers\n\treturn opt.argParser(zodParser(zod, 'opt'))\n}\n\n/**\n * Defines a Commander.js Command using Zod schemas for arguments and options.\n * Automatically wires up parsing, validation, and help configuration.\n * @template A - ZodRawShape for arguments\n * @template O - ZodRawShape for options\n * @param props - Command properties (name, description, args, opts, action)\n * @returns A Commander Command instance\n */\nexport const zodCommand = <A extends z.ZodRawShape, O extends z.ZodRawShape>({\n\tname,\n\tdescription,\n\targs,\n\topts,\n\taction,\n}: ZodCommandProps<A, O>): Command => {\n\tconst command = new Command(name)\n\tif (description) command.description(description)\n\tfor (const key in args) command.addArgument(zodArgument(key, args[key]))\n\tfor (const key in opts) command.addOption(zodOption(key, opts[key]))\n\tif (action)\n\t\tcommand.action(async (...all) => {\n\t\t\tconst resultArgs = Object.fromEntries(\n\t\t\t\tObject.keys(args ?? {}).map((key, i) => [key, all[i]]),\n\t\t\t) as z.infer<z.ZodObject<A>>\n\t\t\tconst resultOpts = all[Object.keys(args ?? {}).length] as z.infer<\n\t\t\t\tz.ZodObject<ReplaceKeyTypes<O>>\n\t\t\t>\n\t\t\tawait action(resultArgs, resultOpts)\n\t\t})\n\treturn command\n}\n"],"mappings":";;;;;AAEA,MAAM,WAAc,KAAmB,OAAoC;CAC1E,MAAM,QAAQ;EAAC,EAAE;EAAY,EAAE;EAAa,EAAE;EAAY;AAC1D,MAAK,MAAM,QAAQ,MAClB,KAAI,eAAe,KAAM,QAAO,QAAQ,IAAI,KAAK,WAAW,GAAG;AAChE,KAAI,eAAe,EAAE,WAAY,QAAO,QAAQ,IAAI,KAAK,QAAQ,GAAG;AACpE,QAAO,GAAG,IAAI;;AAGf,MAAM,eAAe,QACpB,QAAQ,MAAM,QAAS,eAAe,EAAE,UAAU,IAAI,KAAK,SAAS,KAAM;AAE3E,MAAM,gBAAgB,QACrB,QAAQ,MAAM,QAAQ,eAAe,EAAE,WAAW;AAEnD,MAAM,cACL,QAEA,eAAe,EAAE,aACd,WAAW,IAAI,KAAK,OAAO,GAC3B,eAAe,EAAE,aAChB,IAAI,KAAK,cAAc,GACvB;AAEL,MAAM,QAAQ;CACb;CACA;CACA;CACA;CACA;;;;;;;;ACgBD,MAAM,aAAa,KAAmB,SAAiB,UAAkB;CACxE,MAAM,SAAS,IAAI,UAAU,MAAM;AACnC,KAAI,OAAO,QAAS,QAAO,OAAO;CAClC,MAA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