goke 6.6.2 → 6.7.0
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/__test__/index.test.js +46 -2
- package/dist/__test__/types.test-d.js +64 -0
- package/dist/goke.d.ts +40 -3
- package/dist/goke.d.ts.map +1 -1
- package/dist/goke.js +21 -3
- package/package.json +1 -1
- package/src/__test__/index.test.ts +54 -2
- package/src/__test__/types.test-d.ts +73 -4
- package/src/goke.ts +65 -6
|
@@ -568,6 +568,46 @@ describe('regression: oracle-found issues', () => {
|
|
|
568
568
|
const { options } = cli.parse('node bin --count 42'.split(' '));
|
|
569
569
|
expect(options.count).toBe(42);
|
|
570
570
|
});
|
|
571
|
+
test('optional value option with schema default returns default when omitted', () => {
|
|
572
|
+
// `z.number().default(30)` has input `number | undefined` → output `number`,
|
|
573
|
+
// so goke marks this option as effectively required and must surface the
|
|
574
|
+
// default value at runtime when the flag is omitted.
|
|
575
|
+
const cli = goke();
|
|
576
|
+
cli.option('--limit [n]', z.number().default(30).describe('Max items'));
|
|
577
|
+
const { options } = cli.parse('node bin'.split(' '));
|
|
578
|
+
expect(options.limit).toBe(30);
|
|
579
|
+
});
|
|
580
|
+
test('optional value option with schema default returns default when passed bare', () => {
|
|
581
|
+
// Bare `--limit` is mri's "flag present, no value" sentinel. Without a
|
|
582
|
+
// default, goke replaces it with `undefined`. With a default, goke must
|
|
583
|
+
// preserve the preset default value instead of clobbering it, so the
|
|
584
|
+
// type-level `HasSchemaDefault` promise ("property is required at runtime")
|
|
585
|
+
// holds for all three input states: omitted, bare, and with-value.
|
|
586
|
+
const cli = goke();
|
|
587
|
+
cli.option('--limit [n]', z.number().default(30).describe('Max items'));
|
|
588
|
+
const { options } = cli.parse('node bin --limit'.split(' '));
|
|
589
|
+
expect(options.limit).toBe(30);
|
|
590
|
+
});
|
|
591
|
+
test('optional value option with schema default coerces explicit value', () => {
|
|
592
|
+
const cli = goke();
|
|
593
|
+
cli.option('--limit [n]', z.number().default(30).describe('Max items'));
|
|
594
|
+
const { options } = cli.parse('node bin --limit 5'.split(' '));
|
|
595
|
+
expect(options.limit).toBe(5);
|
|
596
|
+
});
|
|
597
|
+
test('multiple optional options with defaults all preserve their defaults', () => {
|
|
598
|
+
// Regression test for the runtime-overwrite bug: when several schema-backed
|
|
599
|
+
// optional flags have defaults, passing one bare should not clobber the
|
|
600
|
+
// others, and the bare one should keep its own default.
|
|
601
|
+
const cli = goke();
|
|
602
|
+
cli
|
|
603
|
+
.option('--limit [n]', z.number().default(30))
|
|
604
|
+
.option('--sort [mode]', z.enum(['asc', 'desc']).default('asc'))
|
|
605
|
+
.option('--host [host]', z.string().default('localhost'));
|
|
606
|
+
const { options } = cli.parse('node bin --sort'.split(' '));
|
|
607
|
+
expect(options.limit).toBe(30);
|
|
608
|
+
expect(options.sort).toBe('asc');
|
|
609
|
+
expect(options.host).toBe('localhost');
|
|
610
|
+
});
|
|
571
611
|
test('alias + schema coercion works', () => {
|
|
572
612
|
const cli = goke();
|
|
573
613
|
cli.option('-p, --port <port>', z.number().describe('Port'));
|
|
@@ -606,9 +646,13 @@ describe('edge cases: schema + defaults interaction', () => {
|
|
|
606
646
|
// Passed with value → coerced
|
|
607
647
|
const { options: opts2 } = cli.parse('node bin --count 42'.split(' '));
|
|
608
648
|
expect(opts2.count).toBe(42);
|
|
609
|
-
// Passed without value →
|
|
649
|
+
// Passed without value → default preserved. Before goke 6.7.0 this test
|
|
650
|
+
// expected `undefined` because the bare-flag sentinel overwrote the
|
|
651
|
+
// preset default. With the HasSchemaDefault type inference, the runtime
|
|
652
|
+
// must keep the default so that the type-level promise ("options.count
|
|
653
|
+
// is always a number") holds for all three input states.
|
|
610
654
|
const { options: opts3 } = cli.parse('node bin --count'.split(' '));
|
|
611
|
-
expect(opts3.count).toBe(
|
|
655
|
+
expect(opts3.count).toBe(10);
|
|
612
656
|
});
|
|
613
657
|
});
|
|
614
658
|
describe('edge cases: boolean flags + schema', () => {
|
|
@@ -288,6 +288,65 @@ describe('type-level: command() .action() option inference', () => {
|
|
|
288
288
|
expectTypeOf(options.verbose).toEqualTypeOf();
|
|
289
289
|
});
|
|
290
290
|
});
|
|
291
|
+
test('schema with .default() on [value] is typed as required', () => {
|
|
292
|
+
// `z.number().default(30)` has Standard Schema input `number | undefined`
|
|
293
|
+
// but output `number`, so goke recognizes it as "effectively required"
|
|
294
|
+
// even though the bracket syntax is `[...]`. The property should NOT
|
|
295
|
+
// be optional in the action options — the runtime always produces 30
|
|
296
|
+
// when the flag is omitted or passed bare.
|
|
297
|
+
goke('test')
|
|
298
|
+
.command('list', 'List stuff')
|
|
299
|
+
.option('--limit [n]', z.number().default(30).describe('Max items'))
|
|
300
|
+
.option('--sort [mode]', z.enum(['asc', 'desc']).default('asc'))
|
|
301
|
+
.action((options) => {
|
|
302
|
+
expectTypeOf(options.limit).toEqualTypeOf();
|
|
303
|
+
expectTypeOf(options.sort).toEqualTypeOf();
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
test('schema without .default() on [value] stays optional', () => {
|
|
307
|
+
// Without a default, `[value]` remains genuinely optional at the type
|
|
308
|
+
// level — bare flag or omitted flag both produce `undefined`.
|
|
309
|
+
goke('test')
|
|
310
|
+
.command('list', 'List stuff')
|
|
311
|
+
.option('--limit [n]', z.number().describe('Max items'))
|
|
312
|
+
.option('--filter [pattern]', z.string())
|
|
313
|
+
.action((options) => {
|
|
314
|
+
expectTypeOf(options.limit).toEqualTypeOf();
|
|
315
|
+
expectTypeOf(options.filter).toEqualTypeOf();
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
test('z.string().optional() on [value] stays optional (no default)', () => {
|
|
319
|
+
// `.optional()` makes both input and output allow undefined, so
|
|
320
|
+
// HasSchemaDefault is false and the bracket-based optionality wins.
|
|
321
|
+
goke('test')
|
|
322
|
+
.command('serve', 'Start server')
|
|
323
|
+
.option('--host [host]', z.string().optional().describe('Host'))
|
|
324
|
+
.action((options) => {
|
|
325
|
+
expectTypeOf(options.host).toEqualTypeOf();
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
test('.default() combined with .optional() stays optional', () => {
|
|
329
|
+
// `z.number().default(30).optional()` has Input `number | undefined` AND
|
|
330
|
+
// Output `number | undefined`, so HasSchemaDefault is false — the user
|
|
331
|
+
// explicitly opted out of the default-inferred-as-required behavior by
|
|
332
|
+
// re-adding `.optional()`.
|
|
333
|
+
goke('test')
|
|
334
|
+
.command('list', 'List stuff')
|
|
335
|
+
.option('--limit [n]', z.number().default(30).optional())
|
|
336
|
+
.action((options) => {
|
|
337
|
+
expectTypeOf(options.limit).toEqualTypeOf();
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
test('.default() on <required> is typed as required output', () => {
|
|
341
|
+
// With `<value>` syntax the property is already required; the schema
|
|
342
|
+
// default just narrows the output type. This is the "old" behavior.
|
|
343
|
+
goke('test')
|
|
344
|
+
.command('serve', 'Start server')
|
|
345
|
+
.option('--port <port>', z.number().default(3000))
|
|
346
|
+
.action((options) => {
|
|
347
|
+
expectTypeOf(options.port).toEqualTypeOf();
|
|
348
|
+
});
|
|
349
|
+
});
|
|
291
350
|
test('accessing a non-existent option in action is a type error', () => {
|
|
292
351
|
goke('test')
|
|
293
352
|
.command('serve', 'Start server')
|
|
@@ -339,6 +398,11 @@ describe('type-level: README TypeScript examples', () => {
|
|
|
339
398
|
});
|
|
340
399
|
});
|
|
341
400
|
test('README global options and middleware example stays typed end-to-end', () => {
|
|
401
|
+
// `z.boolean().default(false)` and `z.string().default(...)` are
|
|
402
|
+
// effectively required at runtime: the default applies when the flag is
|
|
403
|
+
// omitted or passed bare, so goke types the property as required (no
|
|
404
|
+
// `| undefined`). Raw untyped boolean flags like `--dry-run` stay
|
|
405
|
+
// `boolean | undefined`.
|
|
342
406
|
goke('mycli')
|
|
343
407
|
.option('--verbose', z.boolean().default(false).describe('Enable verbose logging'))
|
|
344
408
|
.option('--api-url [url]', z.string().default('https://api.example.com').describe('API base URL'))
|
package/dist/goke.d.ts
CHANGED
|
@@ -53,8 +53,24 @@ type ExtractOptionName<S extends string> = S extends `${string}--${infer Name} <
|
|
|
53
53
|
* Determines if an option takes a required value (<...>) vs optional ([...]) vs boolean flag.
|
|
54
54
|
*/
|
|
55
55
|
type IsOptionalOption<S extends string> = S extends `${string}<${string}>` ? false : true;
|
|
56
|
+
/**
|
|
57
|
+
* Infer the input type from a StandardTypedV1-compatible schema.
|
|
58
|
+
*
|
|
59
|
+
* For Zod, this is the type accepted by `.parse()` before any transforms or
|
|
60
|
+
* defaults are applied (e.g. `z.number().default(30)` has input `number | undefined`).
|
|
61
|
+
*/
|
|
62
|
+
type InferSchemaInput<S> = S extends {
|
|
63
|
+
readonly "~standard": {
|
|
64
|
+
readonly types?: {
|
|
65
|
+
readonly input: infer I;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
} ? I : unknown;
|
|
56
69
|
/**
|
|
57
70
|
* Infer the output type from a StandardTypedV1-compatible schema.
|
|
71
|
+
*
|
|
72
|
+
* For Zod, this is the type produced by `.parse()` after transforms/defaults
|
|
73
|
+
* run (e.g. `z.number().default(30)` has output `number`).
|
|
58
74
|
*/
|
|
59
75
|
type InferSchemaOutput<S> = S extends {
|
|
60
76
|
readonly "~standard": {
|
|
@@ -63,12 +79,33 @@ type InferSchemaOutput<S> = S extends {
|
|
|
63
79
|
};
|
|
64
80
|
};
|
|
65
81
|
} ? O : unknown;
|
|
82
|
+
/**
|
|
83
|
+
* Detects whether a Standard Schema has a "default" behavior: its input allows
|
|
84
|
+
* `undefined` but its output does not. This matches `z.number().default(30)`
|
|
85
|
+
* and similar `.default(...)` wrappers in other libraries: the schema fills
|
|
86
|
+
* in a value whenever the caller omits it, so at runtime the property is
|
|
87
|
+
* always populated and goke can mark it as required in the options type even
|
|
88
|
+
* when the option is declared with `[value]` square brackets.
|
|
89
|
+
*
|
|
90
|
+
* The `unknown extends Input` guard excludes the `wrapJsonSchema` path, where
|
|
91
|
+
* input defaults to `unknown` because the hand-written schema has no way to
|
|
92
|
+
* express a separate input type. For those schemas we fall back to the raw
|
|
93
|
+
* bracket-based optionality, which keeps existing behavior for consumers
|
|
94
|
+
* that use `wrapJsonSchema<T>()` for truly optional options.
|
|
95
|
+
*/
|
|
96
|
+
type HasSchemaDefault<S> = unknown extends InferSchemaInput<S> ? false : undefined extends InferSchemaInput<S> ? undefined extends InferSchemaOutput<S> ? false : true : false;
|
|
66
97
|
/**
|
|
67
98
|
* Build the option type entry for a single .option() call.
|
|
68
|
-
*
|
|
69
|
-
*
|
|
99
|
+
*
|
|
100
|
+
* Required options (`<...>`) produce a required key.
|
|
101
|
+
* Optional options (`[...]`) produce an optional key, EXCEPT when the schema
|
|
102
|
+
* has an effective default (see `HasSchemaDefault`) — in that case goke's
|
|
103
|
+
* runtime always surfaces the default value, so the property is typed as
|
|
104
|
+
* required with the post-coercion output type.
|
|
70
105
|
*/
|
|
71
|
-
type OptionEntry<RawName extends string, Schema> = IsOptionalOption<RawName> extends true ? {
|
|
106
|
+
type OptionEntry<RawName extends string, Schema> = IsOptionalOption<RawName> extends true ? HasSchemaDefault<Schema> extends true ? {
|
|
107
|
+
[K in ExtractOptionName<RawName>]: InferSchemaOutput<Schema>;
|
|
108
|
+
} : {
|
|
72
109
|
[K in ExtractOptionName<RawName>]?: InferSchemaOutput<Schema>;
|
|
73
110
|
} : {
|
|
74
111
|
[K in ExtractOptionName<RawName>]: InferSchemaOutput<Schema>;
|
package/dist/goke.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goke.d.ts","sourceRoot":"","sources":["../src/goke.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAmB,aAAa,EAAW,MAAM,UAAU,CAAA;AAmNhF,cA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AAE,oBAAoB,KAC1B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GACxB,IAAI;IAKP;;;OAGG;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE,YAAY;IAO5B;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,SAAkB;IAMtD;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,cAAc;IAK/B;;;;OAIG;IACH,QAAQ,IAAI,MAAM;IAOlB;;;;OAIG;IACH,UAAU;IAIV;;;OAGG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,EAAE,YAAY,UAAQ;IAwBrF;;;OAGG;IACH,aAAa;IAIb,OAAO,CAAC,aAAa;IAgBrB,mBAAmB;IAKnB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACH,KAAK,CACH,IAAI,WAAoB,EACxB;IACE,oDAAoD;IACpD,GAAU,GACX;;KAAK,GACL,UAAU;IA2Ib,OAAO,CAAC,GAAG;IAwJX,iBAAiB;CA0FlB;AAID,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,EAAE,CAAA;AACrG,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,CAAA;AACjE,eAAe,IAAI,CAAA"}
|
package/dist/goke.js
CHANGED
|
@@ -1105,8 +1105,13 @@ class Goke extends EventEmitter {
|
|
|
1105
1105
|
// For optional options ([...]) we want a single, uniform shape: `string`
|
|
1106
1106
|
// with `''` meaning "flag present but no value" — callers get clean
|
|
1107
1107
|
// `string | undefined` types instead of `string | boolean | undefined`.
|
|
1108
|
+
// The `optionsWithDefault` set tracks options whose schema produced a
|
|
1109
|
+
// non-undefined default — when the user passes such an option bare, we
|
|
1110
|
+
// keep the preset default instead of overwriting it with `undefined`,
|
|
1111
|
+
// which matches what the new `HasSchemaDefault` type inference promises.
|
|
1108
1112
|
const requiredValueOptions = new Set();
|
|
1109
1113
|
const optionalValueOptions = new Set();
|
|
1114
|
+
const optionsWithDefault = new Set();
|
|
1110
1115
|
for (const cliOption of cliOptions) {
|
|
1111
1116
|
if (cliOption.required === true) {
|
|
1112
1117
|
for (const name of cliOption.names) {
|
|
@@ -1118,6 +1123,11 @@ class Goke extends EventEmitter {
|
|
|
1118
1123
|
optionalValueOptions.add(name);
|
|
1119
1124
|
}
|
|
1120
1125
|
}
|
|
1126
|
+
if (cliOption.default !== undefined) {
|
|
1127
|
+
for (const name of cliOption.names) {
|
|
1128
|
+
optionsWithDefault.add(name);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1121
1131
|
}
|
|
1122
1132
|
// Set option values (support dot-nested property name)
|
|
1123
1133
|
// Apply schema-based coercion for options with schemas
|
|
@@ -1129,15 +1139,23 @@ class Goke extends EventEmitter {
|
|
|
1129
1139
|
// When value is boolean `true` and the option takes a value, it's mri's sentinel
|
|
1130
1140
|
// for "flag present, no value given":
|
|
1131
1141
|
// - Required options (<...>): preserve `true` so checkOptionValue() throws
|
|
1132
|
-
// - Optional options ([...]) with schema
|
|
1133
|
-
//
|
|
1134
|
-
//
|
|
1142
|
+
// - Optional options ([...]) with schema AND a default: skip this
|
|
1143
|
+
// key entirely so the preset default (written into `options` at
|
|
1144
|
+
// the top of this function) survives. This keeps the type-level
|
|
1145
|
+
// `HasSchemaDefault` promise honest at runtime.
|
|
1146
|
+
// - Optional options ([...]) with schema and NO default: replace
|
|
1147
|
+
// `true` with `undefined` so the caller sees "flag present, no value"
|
|
1148
|
+
// as `undefined`.
|
|
1135
1149
|
const schemaInfo = schemaMap.get(key);
|
|
1136
1150
|
if (schemaInfo && value !== undefined) {
|
|
1137
1151
|
if (value === true && requiredValueOptions.has(key)) {
|
|
1138
1152
|
// Keep sentinel for checkOptionValue() to detect
|
|
1139
1153
|
}
|
|
1140
1154
|
else if (value === true && optionalValueOptions.has(key)) {
|
|
1155
|
+
if (optionsWithDefault.has(key)) {
|
|
1156
|
+
// Preserve the preset default — don't overwrite with undefined.
|
|
1157
|
+
continue;
|
|
1158
|
+
}
|
|
1141
1159
|
value = undefined;
|
|
1142
1160
|
}
|
|
1143
1161
|
else {
|
package/package.json
CHANGED
|
@@ -728,6 +728,54 @@ describe('regression: oracle-found issues', () => {
|
|
|
728
728
|
expect(options.count).toBe(42)
|
|
729
729
|
})
|
|
730
730
|
|
|
731
|
+
test('optional value option with schema default returns default when omitted', () => {
|
|
732
|
+
// `z.number().default(30)` has input `number | undefined` → output `number`,
|
|
733
|
+
// so goke marks this option as effectively required and must surface the
|
|
734
|
+
// default value at runtime when the flag is omitted.
|
|
735
|
+
const cli = goke()
|
|
736
|
+
cli.option('--limit [n]', z.number().default(30).describe('Max items'))
|
|
737
|
+
|
|
738
|
+
const { options } = cli.parse('node bin'.split(' '))
|
|
739
|
+
expect(options.limit).toBe(30)
|
|
740
|
+
})
|
|
741
|
+
|
|
742
|
+
test('optional value option with schema default returns default when passed bare', () => {
|
|
743
|
+
// Bare `--limit` is mri's "flag present, no value" sentinel. Without a
|
|
744
|
+
// default, goke replaces it with `undefined`. With a default, goke must
|
|
745
|
+
// preserve the preset default value instead of clobbering it, so the
|
|
746
|
+
// type-level `HasSchemaDefault` promise ("property is required at runtime")
|
|
747
|
+
// holds for all three input states: omitted, bare, and with-value.
|
|
748
|
+
const cli = goke()
|
|
749
|
+
cli.option('--limit [n]', z.number().default(30).describe('Max items'))
|
|
750
|
+
|
|
751
|
+
const { options } = cli.parse('node bin --limit'.split(' '))
|
|
752
|
+
expect(options.limit).toBe(30)
|
|
753
|
+
})
|
|
754
|
+
|
|
755
|
+
test('optional value option with schema default coerces explicit value', () => {
|
|
756
|
+
const cli = goke()
|
|
757
|
+
cli.option('--limit [n]', z.number().default(30).describe('Max items'))
|
|
758
|
+
|
|
759
|
+
const { options } = cli.parse('node bin --limit 5'.split(' '))
|
|
760
|
+
expect(options.limit).toBe(5)
|
|
761
|
+
})
|
|
762
|
+
|
|
763
|
+
test('multiple optional options with defaults all preserve their defaults', () => {
|
|
764
|
+
// Regression test for the runtime-overwrite bug: when several schema-backed
|
|
765
|
+
// optional flags have defaults, passing one bare should not clobber the
|
|
766
|
+
// others, and the bare one should keep its own default.
|
|
767
|
+
const cli = goke()
|
|
768
|
+
cli
|
|
769
|
+
.option('--limit [n]', z.number().default(30))
|
|
770
|
+
.option('--sort [mode]', z.enum(['asc', 'desc']).default('asc'))
|
|
771
|
+
.option('--host [host]', z.string().default('localhost'))
|
|
772
|
+
|
|
773
|
+
const { options } = cli.parse('node bin --sort'.split(' '))
|
|
774
|
+
expect(options.limit).toBe(30)
|
|
775
|
+
expect(options.sort).toBe('asc')
|
|
776
|
+
expect(options.host).toBe('localhost')
|
|
777
|
+
})
|
|
778
|
+
|
|
731
779
|
test('alias + schema coercion works', () => {
|
|
732
780
|
const cli = goke()
|
|
733
781
|
|
|
@@ -783,9 +831,13 @@ describe('edge cases: schema + defaults interaction', () => {
|
|
|
783
831
|
const { options: opts2 } = cli.parse('node bin --count 42'.split(' '))
|
|
784
832
|
expect(opts2.count).toBe(42)
|
|
785
833
|
|
|
786
|
-
// Passed without value →
|
|
834
|
+
// Passed without value → default preserved. Before goke 6.7.0 this test
|
|
835
|
+
// expected `undefined` because the bare-flag sentinel overwrote the
|
|
836
|
+
// preset default. With the HasSchemaDefault type inference, the runtime
|
|
837
|
+
// must keep the default so that the type-level promise ("options.count
|
|
838
|
+
// is always a number") holds for all three input states.
|
|
787
839
|
const { options: opts3 } = cli.parse('node bin --count'.split(' '))
|
|
788
|
-
expect(opts3.count).toBe(
|
|
840
|
+
expect(opts3.count).toBe(10)
|
|
789
841
|
})
|
|
790
842
|
})
|
|
791
843
|
|
|
@@ -362,6 +362,70 @@ describe('type-level: command() .action() option inference', () => {
|
|
|
362
362
|
})
|
|
363
363
|
})
|
|
364
364
|
|
|
365
|
+
test('schema with .default() on [value] is typed as required', () => {
|
|
366
|
+
// `z.number().default(30)` has Standard Schema input `number | undefined`
|
|
367
|
+
// but output `number`, so goke recognizes it as "effectively required"
|
|
368
|
+
// even though the bracket syntax is `[...]`. The property should NOT
|
|
369
|
+
// be optional in the action options — the runtime always produces 30
|
|
370
|
+
// when the flag is omitted or passed bare.
|
|
371
|
+
goke('test')
|
|
372
|
+
.command('list', 'List stuff')
|
|
373
|
+
.option('--limit [n]', z.number().default(30).describe('Max items'))
|
|
374
|
+
.option('--sort [mode]', z.enum(['asc', 'desc']).default('asc'))
|
|
375
|
+
.action((options) => {
|
|
376
|
+
expectTypeOf(options.limit).toEqualTypeOf<number>()
|
|
377
|
+
expectTypeOf(options.sort).toEqualTypeOf<'asc' | 'desc'>()
|
|
378
|
+
})
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
test('schema without .default() on [value] stays optional', () => {
|
|
382
|
+
// Without a default, `[value]` remains genuinely optional at the type
|
|
383
|
+
// level — bare flag or omitted flag both produce `undefined`.
|
|
384
|
+
goke('test')
|
|
385
|
+
.command('list', 'List stuff')
|
|
386
|
+
.option('--limit [n]', z.number().describe('Max items'))
|
|
387
|
+
.option('--filter [pattern]', z.string())
|
|
388
|
+
.action((options) => {
|
|
389
|
+
expectTypeOf(options.limit).toEqualTypeOf<number | undefined>()
|
|
390
|
+
expectTypeOf(options.filter).toEqualTypeOf<string | undefined>()
|
|
391
|
+
})
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
test('z.string().optional() on [value] stays optional (no default)', () => {
|
|
395
|
+
// `.optional()` makes both input and output allow undefined, so
|
|
396
|
+
// HasSchemaDefault is false and the bracket-based optionality wins.
|
|
397
|
+
goke('test')
|
|
398
|
+
.command('serve', 'Start server')
|
|
399
|
+
.option('--host [host]', z.string().optional().describe('Host'))
|
|
400
|
+
.action((options) => {
|
|
401
|
+
expectTypeOf(options.host).toEqualTypeOf<string | undefined>()
|
|
402
|
+
})
|
|
403
|
+
})
|
|
404
|
+
|
|
405
|
+
test('.default() combined with .optional() stays optional', () => {
|
|
406
|
+
// `z.number().default(30).optional()` has Input `number | undefined` AND
|
|
407
|
+
// Output `number | undefined`, so HasSchemaDefault is false — the user
|
|
408
|
+
// explicitly opted out of the default-inferred-as-required behavior by
|
|
409
|
+
// re-adding `.optional()`.
|
|
410
|
+
goke('test')
|
|
411
|
+
.command('list', 'List stuff')
|
|
412
|
+
.option('--limit [n]', z.number().default(30).optional())
|
|
413
|
+
.action((options) => {
|
|
414
|
+
expectTypeOf(options.limit).toEqualTypeOf<number | undefined>()
|
|
415
|
+
})
|
|
416
|
+
})
|
|
417
|
+
|
|
418
|
+
test('.default() on <required> is typed as required output', () => {
|
|
419
|
+
// With `<value>` syntax the property is already required; the schema
|
|
420
|
+
// default just narrows the output type. This is the "old" behavior.
|
|
421
|
+
goke('test')
|
|
422
|
+
.command('serve', 'Start server')
|
|
423
|
+
.option('--port <port>', z.number().default(3000))
|
|
424
|
+
.action((options) => {
|
|
425
|
+
expectTypeOf(options.port).toEqualTypeOf<number>()
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
|
|
365
429
|
test('accessing a non-existent option in action is a type error', () => {
|
|
366
430
|
goke('test')
|
|
367
431
|
.command('serve', 'Start server')
|
|
@@ -418,20 +482,25 @@ describe('type-level: README TypeScript examples', () => {
|
|
|
418
482
|
})
|
|
419
483
|
|
|
420
484
|
test('README global options and middleware example stays typed end-to-end', () => {
|
|
485
|
+
// `z.boolean().default(false)` and `z.string().default(...)` are
|
|
486
|
+
// effectively required at runtime: the default applies when the flag is
|
|
487
|
+
// omitted or passed bare, so goke types the property as required (no
|
|
488
|
+
// `| undefined`). Raw untyped boolean flags like `--dry-run` stay
|
|
489
|
+
// `boolean | undefined`.
|
|
421
490
|
goke('mycli')
|
|
422
491
|
.option('--verbose', z.boolean().default(false).describe('Enable verbose logging'))
|
|
423
492
|
.option('--api-url [url]', z.string().default('https://api.example.com').describe('API base URL'))
|
|
424
493
|
.use((options, { process }) => {
|
|
425
|
-
expectTypeOf(options.verbose).toEqualTypeOf<boolean
|
|
426
|
-
expectTypeOf(options.apiUrl).toEqualTypeOf<string
|
|
494
|
+
expectTypeOf(options.verbose).toEqualTypeOf<boolean>()
|
|
495
|
+
expectTypeOf(options.apiUrl).toEqualTypeOf<string>()
|
|
427
496
|
expectTypeOf(process.stdin).toEqualTypeOf<string>()
|
|
428
497
|
})
|
|
429
498
|
.command('deploy <env>', 'Deploy to an environment')
|
|
430
499
|
.option('--dry-run', 'Preview without deploying')
|
|
431
500
|
.action((env, options, ctx) => {
|
|
432
501
|
expectTypeOf(env).toEqualTypeOf<string>()
|
|
433
|
-
expectTypeOf(options.verbose).toEqualTypeOf<boolean
|
|
434
|
-
expectTypeOf(options.apiUrl).toEqualTypeOf<string
|
|
502
|
+
expectTypeOf(options.verbose).toEqualTypeOf<boolean>()
|
|
503
|
+
expectTypeOf(options.apiUrl).toEqualTypeOf<string>()
|
|
435
504
|
expectTypeOf(options.dryRun).toEqualTypeOf<boolean | undefined>()
|
|
436
505
|
expectTypeOf(ctx).toEqualTypeOf<GokeExecutionContext>()
|
|
437
506
|
})
|
package/src/goke.ts
CHANGED
|
@@ -332,20 +332,61 @@ type IsOptionalOption<S extends string> =
|
|
|
332
332
|
S extends `${string}<${string}>` ? false :
|
|
333
333
|
true
|
|
334
334
|
|
|
335
|
+
/**
|
|
336
|
+
* Infer the input type from a StandardTypedV1-compatible schema.
|
|
337
|
+
*
|
|
338
|
+
* For Zod, this is the type accepted by `.parse()` before any transforms or
|
|
339
|
+
* defaults are applied (e.g. `z.number().default(30)` has input `number | undefined`).
|
|
340
|
+
*/
|
|
341
|
+
type InferSchemaInput<S> =
|
|
342
|
+
S extends { readonly "~standard": { readonly types?: { readonly input: infer I } } } ? I : unknown
|
|
343
|
+
|
|
335
344
|
/**
|
|
336
345
|
* Infer the output type from a StandardTypedV1-compatible schema.
|
|
346
|
+
*
|
|
347
|
+
* For Zod, this is the type produced by `.parse()` after transforms/defaults
|
|
348
|
+
* run (e.g. `z.number().default(30)` has output `number`).
|
|
337
349
|
*/
|
|
338
350
|
type InferSchemaOutput<S> =
|
|
339
351
|
S extends { readonly "~standard": { readonly types?: { readonly output: infer O } } } ? O : unknown
|
|
340
352
|
|
|
353
|
+
/**
|
|
354
|
+
* Detects whether a Standard Schema has a "default" behavior: its input allows
|
|
355
|
+
* `undefined` but its output does not. This matches `z.number().default(30)`
|
|
356
|
+
* and similar `.default(...)` wrappers in other libraries: the schema fills
|
|
357
|
+
* in a value whenever the caller omits it, so at runtime the property is
|
|
358
|
+
* always populated and goke can mark it as required in the options type even
|
|
359
|
+
* when the option is declared with `[value]` square brackets.
|
|
360
|
+
*
|
|
361
|
+
* The `unknown extends Input` guard excludes the `wrapJsonSchema` path, where
|
|
362
|
+
* input defaults to `unknown` because the hand-written schema has no way to
|
|
363
|
+
* express a separate input type. For those schemas we fall back to the raw
|
|
364
|
+
* bracket-based optionality, which keeps existing behavior for consumers
|
|
365
|
+
* that use `wrapJsonSchema<T>()` for truly optional options.
|
|
366
|
+
*/
|
|
367
|
+
type HasSchemaDefault<S> =
|
|
368
|
+
unknown extends InferSchemaInput<S>
|
|
369
|
+
? false
|
|
370
|
+
: undefined extends InferSchemaInput<S>
|
|
371
|
+
? undefined extends InferSchemaOutput<S>
|
|
372
|
+
? false
|
|
373
|
+
: true
|
|
374
|
+
: false
|
|
375
|
+
|
|
341
376
|
/**
|
|
342
377
|
* Build the option type entry for a single .option() call.
|
|
343
|
-
*
|
|
344
|
-
*
|
|
378
|
+
*
|
|
379
|
+
* Required options (`<...>`) produce a required key.
|
|
380
|
+
* Optional options (`[...]`) produce an optional key, EXCEPT when the schema
|
|
381
|
+
* has an effective default (see `HasSchemaDefault`) — in that case goke's
|
|
382
|
+
* runtime always surfaces the default value, so the property is typed as
|
|
383
|
+
* required with the post-coercion output type.
|
|
345
384
|
*/
|
|
346
385
|
type OptionEntry<RawName extends string, Schema> =
|
|
347
386
|
IsOptionalOption<RawName> extends true
|
|
348
|
-
?
|
|
387
|
+
? HasSchemaDefault<Schema> extends true
|
|
388
|
+
? { [K in ExtractOptionName<RawName>]: InferSchemaOutput<Schema> }
|
|
389
|
+
: { [K in ExtractOptionName<RawName>]?: InferSchemaOutput<Schema> }
|
|
349
390
|
: { [K in ExtractOptionName<RawName>]: InferSchemaOutput<Schema> }
|
|
350
391
|
|
|
351
392
|
/**
|
|
@@ -1619,8 +1660,13 @@ class Goke<Opts = {}> extends EventEmitter {
|
|
|
1619
1660
|
// For optional options ([...]) we want a single, uniform shape: `string`
|
|
1620
1661
|
// with `''` meaning "flag present but no value" — callers get clean
|
|
1621
1662
|
// `string | undefined` types instead of `string | boolean | undefined`.
|
|
1663
|
+
// The `optionsWithDefault` set tracks options whose schema produced a
|
|
1664
|
+
// non-undefined default — when the user passes such an option bare, we
|
|
1665
|
+
// keep the preset default instead of overwriting it with `undefined`,
|
|
1666
|
+
// which matches what the new `HasSchemaDefault` type inference promises.
|
|
1622
1667
|
const requiredValueOptions = new Set<string>()
|
|
1623
1668
|
const optionalValueOptions = new Set<string>()
|
|
1669
|
+
const optionsWithDefault = new Set<string>()
|
|
1624
1670
|
for (const cliOption of cliOptions) {
|
|
1625
1671
|
if (cliOption.required === true) {
|
|
1626
1672
|
for (const name of cliOption.names) {
|
|
@@ -1631,6 +1677,11 @@ class Goke<Opts = {}> extends EventEmitter {
|
|
|
1631
1677
|
optionalValueOptions.add(name)
|
|
1632
1678
|
}
|
|
1633
1679
|
}
|
|
1680
|
+
if (cliOption.default !== undefined) {
|
|
1681
|
+
for (const name of cliOption.names) {
|
|
1682
|
+
optionsWithDefault.add(name)
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1634
1685
|
}
|
|
1635
1686
|
|
|
1636
1687
|
// Set option values (support dot-nested property name)
|
|
@@ -1644,14 +1695,22 @@ class Goke<Opts = {}> extends EventEmitter {
|
|
|
1644
1695
|
// When value is boolean `true` and the option takes a value, it's mri's sentinel
|
|
1645
1696
|
// for "flag present, no value given":
|
|
1646
1697
|
// - Required options (<...>): preserve `true` so checkOptionValue() throws
|
|
1647
|
-
// - Optional options ([...]) with schema
|
|
1648
|
-
//
|
|
1649
|
-
//
|
|
1698
|
+
// - Optional options ([...]) with schema AND a default: skip this
|
|
1699
|
+
// key entirely so the preset default (written into `options` at
|
|
1700
|
+
// the top of this function) survives. This keeps the type-level
|
|
1701
|
+
// `HasSchemaDefault` promise honest at runtime.
|
|
1702
|
+
// - Optional options ([...]) with schema and NO default: replace
|
|
1703
|
+
// `true` with `undefined` so the caller sees "flag present, no value"
|
|
1704
|
+
// as `undefined`.
|
|
1650
1705
|
const schemaInfo = schemaMap.get(key)
|
|
1651
1706
|
if (schemaInfo && value !== undefined) {
|
|
1652
1707
|
if (value === true && requiredValueOptions.has(key)) {
|
|
1653
1708
|
// Keep sentinel for checkOptionValue() to detect
|
|
1654
1709
|
} else if (value === true && optionalValueOptions.has(key)) {
|
|
1710
|
+
if (optionsWithDefault.has(key)) {
|
|
1711
|
+
// Preserve the preset default — don't overwrite with undefined.
|
|
1712
|
+
continue
|
|
1713
|
+
}
|
|
1655
1714
|
value = undefined
|
|
1656
1715
|
} else {
|
|
1657
1716
|
value = coerceBySchema(value, schemaInfo.jsonSchema, schemaInfo.optionName)
|