gunshi 0.31.0 → 0.33.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/lib/bone.d.ts +2 -2
- package/lib/{constants-CPTXtFxe.d.ts → constants-XndHBbIz.d.ts} +1 -1
- package/lib/context.d.ts +13 -7
- package/lib/definition.d.ts +15 -36
- package/lib/generator.d.ts +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/plugin.d.ts +3 -3
- package/lib/renderer.d.ts +1 -1
- package/lib/{types-CyyzAaDx.d.ts → types-CUdYQC8F.d.ts} +69 -46
- package/lib/utils.d.ts +1 -1
- package/package.json +6 -6
package/lib/bone.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-CIPNDx1a.js";
|
|
2
|
-
import { C as
|
|
2
|
+
import { C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, O as ValidationErrorsDecorator, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-CUdYQC8F.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/bone.d.ts
|
|
5
5
|
/**
|
|
@@ -54,4 +54,4 @@ declare function cli<G extends GunshiParams = DefaultGunshiParams>(args: string[
|
|
|
54
54
|
*/
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
|
-
export { ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, Prettify, RendererDecorator, RenderingOptions, SubCommandable, ValidationErrorsDecorator, cli };
|
|
57
|
+
export { ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, MergeGunshiExtensions, NormalizeToGunshiParams, Prettify, RendererDecorator, RenderingOptions, SubCommandable, ValidationErrorsDecorator, cli };
|
package/lib/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as Args, o as ArgToken, r as ArgValues } from "./resolver-CIPNDx1a.js";
|
|
2
|
-
import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, m as DefaultGunshiParams, n as CliOptions, r as Command, s as CommandContextExtension, x as LazyCommand, y as GunshiParams } from "./types-
|
|
2
|
+
import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, m as DefaultGunshiParams, n as CliOptions, r as Command, s as CommandContextExtension, x as LazyCommand, y as GunshiParams } from "./types-CUdYQC8F.js";
|
|
3
3
|
|
|
4
4
|
//#region src/context.d.ts
|
|
5
5
|
|
|
@@ -8,7 +8,16 @@ import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g a
|
|
|
8
8
|
*
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
type
|
|
11
|
+
type ExtractExtensionValues<E extends Record<string, CommandContextExtension>> = { [K in keyof E]: E[K] extends CommandContextExtension<infer T> ? T : never };
|
|
12
|
+
/**
|
|
13
|
+
* Return type of {@link createCommandContext}
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
type CommandContextResult<G extends GunshiParamsConstraint, E extends Record<string, CommandContextExtension>> = {} extends ExtractExtensionValues<E> ? Readonly<CommandContext<G>> : Readonly<CommandContext<GunshiParams<{
|
|
18
|
+
args: ExtractArgs<G>;
|
|
19
|
+
extensions: ExtractExtensionValues<E>;
|
|
20
|
+
}>>>;
|
|
12
21
|
/**
|
|
13
22
|
* Parameters of {@link createCommandContext}
|
|
14
23
|
*/
|
|
@@ -95,9 +104,6 @@ declare function createCommandContext<G extends GunshiParamsConstraint = Default
|
|
|
95
104
|
commandPath,
|
|
96
105
|
omitted,
|
|
97
106
|
validationError
|
|
98
|
-
}: CommandContextParams<G, V, C, E>): Promise<
|
|
99
|
-
args: ExtractArgs<G>;
|
|
100
|
-
extensions: ExtractExtensions<E>;
|
|
101
|
-
}>>>>;
|
|
107
|
+
}: CommandContextParams<G, V, C, E>): Promise<CommandContextResult<G, E>>;
|
|
102
108
|
//#endregion
|
|
103
|
-
export { CommandContextParams,
|
|
109
|
+
export { CommandContextParams, ExtractExtensionValues, createCommandContext };
|
package/lib/definition.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as Args, n as ArgSchema, r as ArgValues } from "./resolver-CIPNDx1a.js";
|
|
2
|
-
import { C as
|
|
2
|
+
import { C as NormalizeToGunshiParams, _ as ExtractArgs, b as GunshiParamsConstraint, d as CommandLoader, f as CommandRunner, h as ExtendContext, m as DefaultGunshiParams, r as Command, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-CUdYQC8F.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
4
|
|
|
5
5
|
//#region src/definition.d.ts
|
|
@@ -9,17 +9,23 @@ import { CommandContextParams, createCommandContext } from "./context.js";
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* The result type of the {@link define} function
|
|
13
13
|
*
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
type
|
|
16
|
+
type CommandDefinitionResult<G extends GunshiParamsConstraint = DefaultGunshiParams, C = {}> = Prettify<Pick<C, keyof C> & Partial<Pick<Command<G>, Exclude<keyof Command<G>, keyof C>>>>;
|
|
17
17
|
/**
|
|
18
|
-
* The
|
|
18
|
+
* The command definition accepted by {@link define} helpers.
|
|
19
19
|
*
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
type
|
|
22
|
+
type CommandDefinition<A extends Args, E extends ExtendContext, C extends Partial<Command<{
|
|
23
|
+
args: A;
|
|
24
|
+
extensions: E;
|
|
25
|
+
}>>> = C & Command<{
|
|
26
|
+
args: A;
|
|
27
|
+
extensions: E;
|
|
28
|
+
}>;
|
|
23
29
|
/**
|
|
24
30
|
* Define a {@link Command | command}.
|
|
25
31
|
*
|
|
@@ -50,10 +56,10 @@ type CommandDefinitionResult<G extends GunshiParamsConstraint = DefaultGunshiPar
|
|
|
50
56
|
* @param definition - A {@link Command | command} definition
|
|
51
57
|
* @returns A defined {@link Command | command}
|
|
52
58
|
*/
|
|
53
|
-
declare function define<G extends GunshiParamsConstraint = DefaultGunshiParams, A extends Args = ExtractArgs<G>, C extends
|
|
59
|
+
declare function define<G extends GunshiParamsConstraint = DefaultGunshiParams, A extends Args = ExtractArgs<G>, C extends Partial<Command<{
|
|
54
60
|
args: A;
|
|
55
61
|
extensions: ExtractExtensions<G>;
|
|
56
|
-
}>): CommandDefinitionResult<G, C>;
|
|
62
|
+
}>> = {}>(definition: CommandDefinition<A, ExtractExtensions<G>, C>): CommandDefinitionResult<G, C>;
|
|
57
63
|
/**
|
|
58
64
|
* Return type for defineWithTypes
|
|
59
65
|
*
|
|
@@ -64,10 +70,7 @@ declare function define<G extends GunshiParamsConstraint = DefaultGunshiParams,
|
|
|
64
70
|
type DefineWithTypesReturn<DefaultExtensions extends ExtendContext, DefaultArgs extends Args> = <A extends DefaultArgs = DefaultArgs, C extends Partial<Command<{
|
|
65
71
|
args: A;
|
|
66
72
|
extensions: DefaultExtensions;
|
|
67
|
-
}>> = {}>(definition: C
|
|
68
|
-
args: A;
|
|
69
|
-
extensions: DefaultExtensions;
|
|
70
|
-
}>) => CommandDefinitionResult<{
|
|
73
|
+
}>> = {}>(definition: CommandDefinition<A, DefaultExtensions, C>) => CommandDefinitionResult<{
|
|
71
74
|
args: A;
|
|
72
75
|
extensions: DefaultExtensions;
|
|
73
76
|
}, C>;
|
|
@@ -170,30 +173,6 @@ declare function lazy<G extends GunshiParamsConstraint = DefaultGunshiParams, A
|
|
|
170
173
|
args: A;
|
|
171
174
|
extensions: {};
|
|
172
175
|
}, D>;
|
|
173
|
-
/**
|
|
174
|
-
* Normalize G to a full GunshiParams type
|
|
175
|
-
*
|
|
176
|
-
* @typeParam G - A {@link GunshiParamsConstraint} type
|
|
177
|
-
*
|
|
178
|
-
* @internal
|
|
179
|
-
*/
|
|
180
|
-
type NormalizeGunshiParams<G extends GunshiParamsConstraint> = G extends GunshiParams<any> ? G : G extends {
|
|
181
|
-
args: infer A;
|
|
182
|
-
extensions: infer E;
|
|
183
|
-
} ? {
|
|
184
|
-
args: A;
|
|
185
|
-
extensions: E;
|
|
186
|
-
} : G extends {
|
|
187
|
-
args: infer A;
|
|
188
|
-
} ? {
|
|
189
|
-
args: A;
|
|
190
|
-
extensions: {};
|
|
191
|
-
} : G extends {
|
|
192
|
-
extensions: infer E;
|
|
193
|
-
} ? {
|
|
194
|
-
args: Args;
|
|
195
|
-
extensions: E;
|
|
196
|
-
} : DefaultGunshiParams;
|
|
197
176
|
/**
|
|
198
177
|
* Return type for lazyWithTypes
|
|
199
178
|
*
|
|
@@ -236,6 +215,6 @@ type LazyWithTypesReturn<FullG extends GunshiParamsConstraint> = <D extends Part
|
|
|
236
215
|
*
|
|
237
216
|
* @since v0.27.0
|
|
238
217
|
*/
|
|
239
|
-
declare function lazyWithTypes<G extends GunshiParamsConstraint>(): LazyWithTypesReturn<
|
|
218
|
+
declare function lazyWithTypes<G extends GunshiParamsConstraint>(): LazyWithTypesReturn<NormalizeToGunshiParams<G>>;
|
|
240
219
|
//#endregion
|
|
241
220
|
export { type ArgSchema, type ArgValues, type Args, type Command, type CommandContextParams, type CommandLoader, type CommandRunner, type DefaultGunshiParams, type ExtendContext, type GunshiParams, type LazyCommand, createCommandContext, define, defineWithTypes, lazy, lazyWithTypes };
|
package/lib/generator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, n as CliOptions, r as Command, x as LazyCommand } from "./types-
|
|
1
|
+
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, n as CliOptions, r as Command, x as LazyCommand } from "./types-CUdYQC8F.js";
|
|
2
2
|
|
|
3
3
|
//#region src/generator.d.ts
|
|
4
4
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as resolveArgs, i as Args, n as ArgSchema, o as ArgToken, r as ArgValues, s as parseArgs } from "./resolver-CIPNDx1a.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as Plugin, C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, F as PluginWithExtension, I as PluginWithoutExtension, L as plugin, M as PluginExtension, N as PluginFunction, O as ValidationErrorsDecorator, P as PluginOptions, R as PluginContext, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, j as PluginDependency, k as OnPluginExtension, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-CUdYQC8F.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
4
|
import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition.js";
|
|
5
|
-
import { t as ANONYMOUS_COMMAND_NAME } from "./constants-
|
|
5
|
+
import { t as ANONYMOUS_COMMAND_NAME } from "./constants-XndHBbIz.js";
|
|
6
6
|
|
|
7
7
|
//#region ../plugin-i18n/src/types.d.ts
|
|
8
8
|
/**
|
|
@@ -186,4 +186,4 @@ declare function cli(args: string[], entry: SubCommandable, options?: CliOptions
|
|
|
186
186
|
*/
|
|
187
187
|
|
|
188
188
|
//#endregion
|
|
189
|
-
export { ANONYMOUS_COMMAND_NAME, ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, type CommandContextParams, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, DefaultTranslation, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, type OnPluginExtension, type Plugin, type PluginContext, type PluginDependency, type PluginExtension, type PluginFunction, type PluginOptions, type PluginWithExtension, type PluginWithoutExtension, Prettify, RendererDecorator, RenderingOptions, SubCommandable, ValidationErrorsDecorator, cli, createCommandContext, define, defineWithTypes, lazy, lazyWithTypes, parseArgs, plugin, resolveArgs };
|
|
189
|
+
export { ANONYMOUS_COMMAND_NAME, ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, type CommandContextParams, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, DefaultTranslation, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, MergeGunshiExtensions, NormalizeToGunshiParams, type OnPluginExtension, type Plugin, type PluginContext, type PluginDependency, type PluginExtension, type PluginFunction, type PluginOptions, type PluginWithExtension, type PluginWithoutExtension, Prettify, RendererDecorator, RenderingOptions, SubCommandable, ValidationErrorsDecorator, cli, createCommandContext, define, defineWithTypes, lazy, lazyWithTypes, parseArgs, plugin, resolveArgs };
|
package/lib/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-CIPNDx1a.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as Plugin, C as NormalizeToGunshiParams, F as PluginWithExtension, I as PluginWithoutExtension, L as plugin, M as PluginExtension, N as PluginFunction, O as ValidationErrorsDecorator, P as PluginOptions, R as PluginContext, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, f as CommandRunner, h as ExtendContext, j as PluginDependency, k as OnPluginExtension, m as DefaultGunshiParams, o as CommandContextCore, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-CUdYQC8F.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
|
-
import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./constants-
|
|
4
|
+
import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./constants-XndHBbIz.js";
|
|
5
5
|
|
|
6
6
|
//#region src/plugin.d.ts
|
|
7
7
|
/**
|
|
@@ -10,4 +10,4 @@ import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./constan
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
|
-
export { ANONYMOUS_COMMAND_NAME, type ArgSchema, type ArgToken, type ArgValues, type Args, type Awaitable, CLI_OPTIONS_DEFAULT, type Command, type CommandContext, type CommandContextCore, type CommandContextExtension, type CommandContextParams, type CommandDecorator, type CommandExamplesFetcher, type CommandRunner, type DefaultGunshiParams, type ExtendContext, type ExtractArgs, type ExtractExtensions, type GunshiParams, type GunshiParamsConstraint, type LazyCommand, type NormalizeToGunshiParams, type OnPluginExtension, type Plugin, type PluginContext, type PluginDependency, type PluginExtension, type PluginFunction, type PluginOptions, type PluginWithExtension, type PluginWithoutExtension, type Prettify, type RendererDecorator, type ValidationErrorsDecorator, createCommandContext, plugin };
|
|
13
|
+
export { ANONYMOUS_COMMAND_NAME, type ArgSchema, type ArgToken, type ArgValues, type Args, type Awaitable, CLI_OPTIONS_DEFAULT, type Command, type CommandContext, type CommandContextCore, type CommandContextExtension, type CommandContextParams, type CommandDecorator, type CommandExamplesFetcher, type CommandRunner, type DefaultGunshiParams, type ExtendContext, type ExtractArgs, type ExtractExtensions, type GunshiParams, type GunshiParamsConstraint, type LazyCommand, type MergeGunshiExtensions, type NormalizeToGunshiParams, type OnPluginExtension, type Plugin, type PluginContext, type PluginDependency, type PluginExtension, type PluginFunction, type PluginOptions, type PluginWithExtension, type PluginWithoutExtension, type Prettify, type RendererDecorator, type ValidationErrorsDecorator, createCommandContext, plugin };
|
package/lib/renderer.d.ts
CHANGED
|
@@ -6,15 +6,6 @@ import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues, t as ArgExpli
|
|
|
6
6
|
* @license MIT
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Type helper to create GunshiParams from extracted args and extensions
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
type ExtractedParams<G extends GunshiParamsConstraint, L extends Record<string, unknown> = {}> = {
|
|
15
|
-
args: ExtractArgs<G>;
|
|
16
|
-
extensions: ExtractExtensions<G> & L;
|
|
17
|
-
};
|
|
18
9
|
/**
|
|
19
10
|
* Gunshi plugin context interface.
|
|
20
11
|
*
|
|
@@ -63,7 +54,7 @@ interface PluginContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
|
|
|
63
54
|
*
|
|
64
55
|
* @param decorator - A decorator function that wraps the base header renderer.
|
|
65
56
|
*/
|
|
66
|
-
decorateHeaderRenderer<L extends Record<string, unknown> = DefaultGunshiParams['extensions']>(decorator: (baseRenderer: (ctx: Readonly<CommandContext<
|
|
57
|
+
decorateHeaderRenderer<L extends Record<string, unknown> = DefaultGunshiParams['extensions']>(decorator: (baseRenderer: (ctx: Readonly<CommandContext<MergeGunshiExtensions<G, L>>>) => Promise<string>, ctx: Readonly<CommandContext<MergeGunshiExtensions<G, L>>>) => Promise<string>): void;
|
|
67
58
|
/**
|
|
68
59
|
* Decorate the usage renderer.
|
|
69
60
|
*
|
|
@@ -71,7 +62,7 @@ interface PluginContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
|
|
|
71
62
|
*
|
|
72
63
|
* @param decorator - A decorator function that wraps the base usage renderer.
|
|
73
64
|
*/
|
|
74
|
-
decorateUsageRenderer<L extends Record<string, unknown> = DefaultGunshiParams['extensions']>(decorator: (baseRenderer: (ctx: Readonly<CommandContext<
|
|
65
|
+
decorateUsageRenderer<L extends Record<string, unknown> = DefaultGunshiParams['extensions']>(decorator: (baseRenderer: (ctx: Readonly<CommandContext<MergeGunshiExtensions<G, L>>>) => Promise<string>, ctx: Readonly<CommandContext<MergeGunshiExtensions<G, L>>>) => Promise<string>): void;
|
|
75
66
|
/**
|
|
76
67
|
* Decorate the validation errors renderer.
|
|
77
68
|
*
|
|
@@ -79,7 +70,7 @@ interface PluginContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
|
|
|
79
70
|
*
|
|
80
71
|
* @param decorator - A decorator function that wraps the base validation errors renderer.
|
|
81
72
|
*/
|
|
82
|
-
decorateValidationErrorsRenderer<L extends Record<string, unknown> = DefaultGunshiParams['extensions']>(decorator: (baseRenderer: (ctx: Readonly<CommandContext<
|
|
73
|
+
decorateValidationErrorsRenderer<L extends Record<string, unknown> = DefaultGunshiParams['extensions']>(decorator: (baseRenderer: (ctx: Readonly<CommandContext<MergeGunshiExtensions<G, L>>>, error: AggregateError) => Promise<string>, ctx: Readonly<CommandContext<MergeGunshiExtensions<G, L>>>, error: AggregateError) => Promise<string>): void;
|
|
83
74
|
/**
|
|
84
75
|
* Decorate the command execution.
|
|
85
76
|
*
|
|
@@ -89,7 +80,7 @@ interface PluginContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
|
|
|
89
80
|
*
|
|
90
81
|
* @param decorator - A decorator function that wraps the command runner
|
|
91
82
|
*/
|
|
92
|
-
decorateCommand<L extends Record<string, unknown> = DefaultGunshiParams['extensions']>(decorator: (baseRunner: (ctx: Readonly<CommandContext<
|
|
83
|
+
decorateCommand<L extends Record<string, unknown> = DefaultGunshiParams['extensions']>(decorator: (baseRunner: (ctx: Readonly<CommandContext<MergeGunshiExtensions<G, L>>>) => Awaitable<void | string>) => (ctx: Readonly<CommandContext<MergeGunshiExtensions<G, L>>>) => Awaitable<void | string>): void;
|
|
93
84
|
}
|
|
94
85
|
//#endregion
|
|
95
86
|
//#region src/plugin/core.d.ts
|
|
@@ -155,6 +146,36 @@ type PluginExtension<T = Record<string, unknown>, G extends GunshiParams = Defau
|
|
|
155
146
|
type OnPluginExtension<G extends GunshiParams = DefaultGunshiParams> = (ctx: Readonly<CommandContext<G>>, cmd: Readonly<Command<G>>) => Awaitable<void>;
|
|
156
147
|
type IsStringLiteral<S extends string> = string extends S ? false : true;
|
|
157
148
|
type MergeExtension<Id, ResolvedDepExt extends ExtendContext, PluginExt extends ExtendContext> = Id extends infer I ? I extends string ? IsStringLiteral<I> extends true ? ResolvedDepExt & { [K in I]: PluginExt } : ResolvedDepExt : ResolvedDepExt : ResolvedDepExt;
|
|
149
|
+
/**
|
|
150
|
+
* Extensions resolved from the declared plugin dependencies.
|
|
151
|
+
*
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
type DependencyExtensions<Deps extends ReadonlyArray<PluginDependency | string>, Context extends ExtendContext> = InferDependencyExtensions<Deps, Context>;
|
|
155
|
+
/**
|
|
156
|
+
* Gunshi params available while a plugin extension resolves its dependencies.
|
|
157
|
+
*
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
type DependencyParams<Deps extends ReadonlyArray<PluginDependency | string>, Context extends ExtendContext> = GunshiParams<{
|
|
161
|
+
args: Args;
|
|
162
|
+
extensions: DependencyExtensions<Deps, Context>;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Extensions available after applying the current plugin extension.
|
|
166
|
+
*
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
type MergedPluginExtensions<Id extends string, Deps extends ReadonlyArray<PluginDependency | string>, Context extends ExtendContext, Ext extends ExtendContext> = MergeExtension<Id, DependencyExtensions<Deps, Context>, Ext>;
|
|
170
|
+
/**
|
|
171
|
+
* Gunshi params available after applying the current plugin extension.
|
|
172
|
+
*
|
|
173
|
+
* @internal
|
|
174
|
+
*/
|
|
175
|
+
type MergedPluginParams<Id extends string, Deps extends ReadonlyArray<PluginDependency | string>, Context extends ExtendContext, Ext extends ExtendContext> = GunshiParams<{
|
|
176
|
+
args: Args;
|
|
177
|
+
extensions: MergedPluginExtensions<Id, Deps, Context, Ext>;
|
|
178
|
+
}>;
|
|
158
179
|
/**
|
|
159
180
|
* Plugin definition options
|
|
160
181
|
*
|
|
@@ -168,13 +189,7 @@ Deps extends ReadonlyArray<PluginDependency | string> = (PluginDependency | stri
|
|
|
168
189
|
// for plugin dependencies
|
|
169
190
|
Ext extends Record<string, unknown> = {},
|
|
170
191
|
// for plugin extension type
|
|
171
|
-
ResolvedDepExt extends GunshiParams = GunshiParams<{
|
|
172
|
-
args: Args;
|
|
173
|
-
extensions: InferDependencyExtensions<Deps, DepExt>;
|
|
174
|
-
}>, PluginExt extends PluginExtension<Ext, ResolvedDepExt> = PluginExtension<Ext, ResolvedDepExt>, MergedExt extends GunshiParams = GunshiParams<{
|
|
175
|
-
args: Args;
|
|
176
|
-
extensions: MergeExtension<Id, InferDependencyExtensions<Deps, DepExt>, Awaited<ReturnType<PluginExt>>>;
|
|
177
|
-
}>> {
|
|
192
|
+
ResolvedDepExt extends GunshiParams = DependencyParams<Deps, DepExt>, PluginExt extends PluginExtension<Ext, ResolvedDepExt> = PluginExtension<Ext, ResolvedDepExt>, MergedExt extends GunshiParams = MergedPluginParams<Id, Deps, DepExt, Awaited<ReturnType<PluginExt>>>> {
|
|
178
193
|
/**
|
|
179
194
|
* Plugin unique identifier
|
|
180
195
|
*/
|
|
@@ -283,20 +298,11 @@ Deps extends ReadonlyArray<PluginDependency | string> = [],
|
|
|
283
298
|
// for plugin dependencies
|
|
284
299
|
Extension extends {} = {},
|
|
285
300
|
// for plugin extension type
|
|
286
|
-
ResolvedDepExtensions extends GunshiParams = GunshiParams<{
|
|
287
|
-
args: Args;
|
|
288
|
-
extensions: InferDependencyExtensions<Deps, Context>;
|
|
289
|
-
}>, PluginExt extends PluginExtension<Extension, DefaultGunshiParams> = PluginExtension<Extension, ResolvedDepExtensions>, MergedExtensions extends GunshiParams = GunshiParams<{
|
|
290
|
-
args: Args;
|
|
291
|
-
extensions: MergeExtension<Id, InferDependencyExtensions<Deps, Context>, Awaited<ReturnType<PluginExt>>>;
|
|
292
|
-
}>>(options: {
|
|
301
|
+
ResolvedDepExtensions extends GunshiParams = DependencyParams<Deps, Context>, PluginExt extends PluginExtension<Extension, DefaultGunshiParams> = PluginExtension<Extension, ResolvedDepExtensions>, MergedExtensions extends GunshiParams = MergedPluginParams<Id, Deps, Context, Awaited<ReturnType<PluginExt>>>>(options: {
|
|
293
302
|
id: Id;
|
|
294
303
|
name?: string;
|
|
295
304
|
dependencies?: Deps;
|
|
296
|
-
setup?: (ctx: Readonly<PluginContext<
|
|
297
|
-
args: Args;
|
|
298
|
-
extensions: MergeExtension<Id, InferDependencyExtensions<Deps, Context>, Awaited<ReturnType<PluginExt>>>;
|
|
299
|
-
}>>>) => Awaitable<void>;
|
|
305
|
+
setup?: (ctx: Readonly<PluginContext<MergedPluginParams<Id, Deps, Context, Awaited<ReturnType<PluginExt>>>>>) => Awaitable<void>;
|
|
300
306
|
extension: PluginExt;
|
|
301
307
|
onExtension?: OnPluginExtension<MergedExtensions>;
|
|
302
308
|
}): PluginWithExtension<Awaited<ReturnType<PluginExt>>>;
|
|
@@ -321,20 +327,11 @@ Deps extends ReadonlyArray<PluginDependency | string> = [],
|
|
|
321
327
|
// for plugin dependencies
|
|
322
328
|
Extension extends Record<string, unknown> = {},
|
|
323
329
|
// for plugin extension type
|
|
324
|
-
ResolvedDepExtensions extends GunshiParams = GunshiParams<{
|
|
325
|
-
args: Args;
|
|
326
|
-
extensions: InferDependencyExtensions<Deps, Context>;
|
|
327
|
-
}>, PluginExt extends PluginExtension<Extension, DefaultGunshiParams> = PluginExtension<Extension, ResolvedDepExtensions>, MergedExtensions extends GunshiParams = GunshiParams<{
|
|
328
|
-
args: Args;
|
|
329
|
-
extensions: MergeExtension<Id, InferDependencyExtensions<Deps, Context>, Awaited<ReturnType<PluginExt>>>;
|
|
330
|
-
}>>(options: {
|
|
330
|
+
ResolvedDepExtensions extends GunshiParams = DependencyParams<Deps, Context>, PluginExt extends PluginExtension<Extension, DefaultGunshiParams> = PluginExtension<Extension, ResolvedDepExtensions>, MergedExtensions extends GunshiParams = MergedPluginParams<Id, Deps, Context, Awaited<ReturnType<PluginExt>>>>(options: {
|
|
331
331
|
id: Id;
|
|
332
332
|
name?: string;
|
|
333
333
|
dependencies?: Deps;
|
|
334
|
-
setup?: (ctx: Readonly<PluginContext<
|
|
335
|
-
args: Args;
|
|
336
|
-
extensions: MergeExtension<Id, InferDependencyExtensions<Deps, Context>, Awaited<ReturnType<PluginExt>>>;
|
|
337
|
-
}>>>) => Awaitable<void>;
|
|
334
|
+
setup?: (ctx: Readonly<PluginContext<MergedPluginParams<Id, Deps, Context, Awaited<ReturnType<PluginExt>>>>>) => Awaitable<void>;
|
|
338
335
|
onExtension?: OnPluginExtension<MergedExtensions>;
|
|
339
336
|
}): PluginWithoutExtension<DefaultGunshiParams['extensions']>;
|
|
340
337
|
//#endregion
|
|
@@ -436,11 +433,37 @@ type ExtractExtensions<G> = G extends GunshiParams<any> ? G['extensions'] : G ex
|
|
|
436
433
|
* @internal
|
|
437
434
|
*/
|
|
438
435
|
type NormalizeToGunshiParams<G> = G extends GunshiParams<any> ? G : G extends {
|
|
439
|
-
|
|
436
|
+
args: infer A extends Args;
|
|
437
|
+
extensions: infer E extends ExtendContext;
|
|
438
|
+
} ? GunshiParams<{
|
|
439
|
+
args: A;
|
|
440
|
+
extensions: E;
|
|
441
|
+
}> : G extends {
|
|
442
|
+
args: infer A extends Args;
|
|
443
|
+
} ? GunshiParams<{
|
|
444
|
+
args: A;
|
|
445
|
+
extensions: {};
|
|
446
|
+
}> : G extends {
|
|
447
|
+
extensions: infer E extends ExtendContext;
|
|
440
448
|
} ? GunshiParams<{
|
|
441
449
|
args: Args;
|
|
442
|
-
extensions:
|
|
450
|
+
extensions: E;
|
|
443
451
|
}> : DefaultGunshiParams;
|
|
452
|
+
/**
|
|
453
|
+
* Type helper to merge command context extensions into G
|
|
454
|
+
*
|
|
455
|
+
* @internal
|
|
456
|
+
*/
|
|
457
|
+
type MergeGunshiExtensions<G extends GunshiParamsConstraint, E extends ExtendContext> = GunshiParams<{
|
|
458
|
+
/**
|
|
459
|
+
* Command argument definitions.
|
|
460
|
+
*/
|
|
461
|
+
args: ExtractArgs<G>;
|
|
462
|
+
/**
|
|
463
|
+
* Merged command context extensions.
|
|
464
|
+
*/
|
|
465
|
+
extensions: ExtractExtensions<G> & E;
|
|
466
|
+
}>;
|
|
444
467
|
/**
|
|
445
468
|
* Command environment.
|
|
446
469
|
*
|
|
@@ -754,7 +777,7 @@ interface CommandContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
|
|
|
754
777
|
validationError?: AggregateError;
|
|
755
778
|
}
|
|
756
779
|
/**
|
|
757
|
-
*
|
|
780
|
+
* Readonly command context available to a command context extension factory.
|
|
758
781
|
*
|
|
759
782
|
* @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command context.
|
|
760
783
|
*
|
|
@@ -1037,4 +1060,4 @@ type RendererDecorator<T, G extends GunshiParamsConstraint = DefaultGunshiParams
|
|
|
1037
1060
|
*/
|
|
1038
1061
|
type ValidationErrorsDecorator<G extends GunshiParamsConstraint = DefaultGunshiParams> = (baseRenderer: (ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>, ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>;
|
|
1039
1062
|
//#endregion
|
|
1040
|
-
export {
|
|
1063
|
+
export { Plugin as A, NormalizeToGunshiParams as C, SubCommandable as D, RenderingOptions as E, PluginWithExtension as F, PluginWithoutExtension as I, plugin as L, PluginExtension as M, PluginFunction as N, ValidationErrorsDecorator as O, PluginOptions as P, PluginContext as R, MergeGunshiExtensions as S, RendererDecorator as T, ExtractArgs as _, CommandContext as a, GunshiParamsConstraint as b, CommandDecorator as c, CommandLoader as d, CommandRunner as f, ExtractArgExplicitlyProvided as g, ExtendContext as h, CommandCallMode as i, PluginDependency as j, OnPluginExtension as k, CommandEnvironment as l, DefaultGunshiParams as m, CliOptions as n, CommandContextCore as o, Commandable as p, Command as r, CommandContextExtension as s, Awaitable as t, CommandExamplesFetcher as u, ExtractExtensions as v, Prettify as w, LazyCommand as x, GunshiParams as y };
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, p as Commandable, r as Command, x as LazyCommand } from "./types-
|
|
1
|
+
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, p as Commandable, r as Command, x as LazyCommand } from "./types-CUdYQC8F.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../node_modules/.pnpm/args-tokens@0.25.0/node_modules/args-tokens/lib/utils.d.ts
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gunshi",
|
|
3
3
|
"description": "Modern javascript command-line library",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.33.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -116,11 +116,11 @@
|
|
|
116
116
|
"std-env": "^4.1.0",
|
|
117
117
|
"tsdown": "0.21.0",
|
|
118
118
|
"zod": "^4.4.3",
|
|
119
|
-
"@gunshi/plugin-global": "0.
|
|
120
|
-
"@gunshi/plugin-
|
|
121
|
-
"@gunshi/
|
|
122
|
-
"@gunshi/resources": "0.
|
|
123
|
-
"@gunshi/
|
|
119
|
+
"@gunshi/plugin-global": "0.33.0",
|
|
120
|
+
"@gunshi/plugin-renderer": "0.33.0",
|
|
121
|
+
"@gunshi/shared": "0.33.0",
|
|
122
|
+
"@gunshi/resources": "0.33.0",
|
|
123
|
+
"@gunshi/plugin-i18n": "0.33.0"
|
|
124
124
|
},
|
|
125
125
|
"scripts": {
|
|
126
126
|
"build": "tsdown",
|