@gunshi/shared 0.26.3 → 0.27.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.d.ts +21 -19
  2. package/package.json +6 -6
package/lib/index.d.ts CHANGED
@@ -53,13 +53,14 @@ interface ArgToken {
53
53
  * Inline value, e.g. `--foo=bar` => `true`, `-x=bar` => `true`.
54
54
  */
55
55
  inlineValue?: boolean;
56
- } //#endregion
57
- //#region ../../node_modules/.pnpm/args-tokens@0.20.1/node_modules/args-tokens/lib/resolver-U72Jg6Ll.d.ts
58
-
56
+ }
59
57
  /**
60
58
  * Parser Options.
61
59
  */
60
+ //#endregion
61
+ //#region ../../node_modules/.pnpm/args-tokens@0.20.1/node_modules/args-tokens/lib/resolver-U72Jg6Ll.d.ts
62
62
  //#region src/resolver.d.ts
63
+
63
64
  /**
64
65
  * An argument schema
65
66
  * This schema is similar to the schema of the `node:utils`.
@@ -147,20 +148,21 @@ type FilterArgs<A extends Args, V extends Record<keyof A, unknown>, K extends ke
147
148
  * @internal
148
149
  */
149
150
  type FilterPositionalArgs<A extends Args, V extends Record<keyof A, unknown>> = { [Arg in keyof A as A[Arg]["type"] extends "positional" ? Arg : never]: V[Arg] };
150
-
151
- //#endregion
152
- //#region ../gunshi/src/types.d.ts
153
151
  /**
154
152
  * An arguments for {@link resolveArgs | resolve arguments}.
155
153
  */
154
+ //#endregion
155
+ //#region ../gunshi/src/types.d.ts
156
156
  type Awaitable<T> = T | Promise<T>;
157
157
  /**
158
158
  * Extend command context type. This type is used to extend the command context with additional properties at {@link CommandContext.extensions}.
159
+ * @since v0.27.0
159
160
  */
160
161
  type ExtendContext = Record<string, unknown>;
161
162
  /**
162
163
  * Gunshi unified parameter type.
163
164
  * This type combines both argument definitions and command context extensions.
165
+ * @since v0.27.0
164
166
  */
165
167
  interface GunshiParams<P extends {
166
168
  args?: Args;
@@ -184,11 +186,13 @@ interface GunshiParams<P extends {
184
186
  }
185
187
  /**
186
188
  * Default Gunshi parameters
189
+ * @since v0.27.0
187
190
  */
188
191
  type DefaultGunshiParams = GunshiParams;
189
192
  /**
190
193
  * Generic constraint for command-related types.
191
194
  * This type constraint allows both GunshiParams and objects with extensions.
195
+ * @since v0.27.0
192
196
  */
193
197
  type GunshiParamsConstraint = GunshiParams<any> | {
194
198
  extensions: ExtendContext;
@@ -285,16 +289,19 @@ interface CommandEnvironment<G extends GunshiParamsConstraint = DefaultGunshiPar
285
289
  /**
286
290
  * Hook that runs before any command execution
287
291
  * @see {@link CliOptions.onBeforeCommand}
292
+ * @since v0.27.0
288
293
  */
289
294
  onBeforeCommand: ((ctx: Readonly<CommandContext<G>>) => Awaitable<void>) | undefined;
290
295
  /**
291
296
  * Hook that runs after successful command execution
292
297
  * @see {@link CliOptions.onAfterCommand}
298
+ * @since v0.27.0
293
299
  */
294
- onAfterCommand: ((ctx: Readonly<CommandContext<G>>, result: string | void) => Awaitable<void>) | undefined;
300
+ onAfterCommand: ((ctx: Readonly<CommandContext<G>>, result: string | undefined) => Awaitable<void>) | undefined;
295
301
  /**
296
302
  * Hook that runs when a command throws an error
297
303
  * @see {@link CliOptions.onErrorCommand}
304
+ * @since v0.27.0
298
305
  */
299
306
  onErrorCommand: ((ctx: Readonly<CommandContext<G>>, error: Error) => Awaitable<void>) | undefined;
300
307
  }
@@ -377,7 +384,8 @@ interface CommandContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
377
384
  */
378
385
  log: (message?: any, ...optionalParams: any[]) => void;
379
386
  /**
380
- * Command context extensions.
387
+ * Command context extensions.
388
+ * @since v0.27.0
381
389
  */
382
390
  extensions: keyof ExtractExtensions<G> extends never ? undefined : ExtractExtensions<G>;
383
391
  /**
@@ -388,6 +396,7 @@ interface CommandContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
388
396
  }
389
397
  /**
390
398
  * CommandContextCore type (base type without extensions)
399
+ * @since v0.27.0
391
400
  */
392
401
 
393
402
  /**
@@ -453,15 +462,15 @@ type CommandExamplesFetcher<G extends GunshiParamsConstraint = DefaultGunshiPara
453
462
  * @param ctx A {@link CommandContext | command context}
454
463
  * @returns void or string (for CLI output)
455
464
  */
456
- type CommandRunner<G extends GunshiParamsConstraint = DefaultGunshiParams> = (ctx: Readonly<CommandContext<G>>) => Awaitable<void | string>; //#endregion
457
- //#region ../../node_modules/.pnpm/args-tokens@0.20.1/node_modules/args-tokens/lib/utils.d.ts
458
-
465
+ type CommandRunner<G extends GunshiParamsConstraint = DefaultGunshiParams> = (ctx: Readonly<CommandContext<G>>) => Awaitable<string | void>;
459
466
  /**
460
467
  * Command loader.
461
468
  * A function that returns a command or command runner.
462
469
  * This is used to lazily load commands.
463
470
  * @returns A command or command runner
464
471
  */
472
+ //#endregion
473
+ //#region ../../node_modules/.pnpm/args-tokens@0.20.1/node_modules/args-tokens/lib/utils.d.ts
465
474
  //#region src/utils.d.ts
466
475
  /**
467
476
  * Entry point of utils.
@@ -475,18 +484,14 @@ type CommandRunner<G extends GunshiParamsConstraint = DefaultGunshiParams> = (ct
475
484
  * @license MIT
476
485
  */
477
486
  declare function kebabnize(str: string): string;
478
-
479
487
  //#endregion
480
- //#region ../gunshi/src/utils.d.ts
481
488
  //#endregion
489
+ //#region ../gunshi/src/utils.d.ts
482
490
  declare function isLazyCommand<G extends GunshiParamsConstraint = DefaultGunshiParams>(cmd: unknown): cmd is LazyCommand<G>;
483
491
  declare function resolveLazyCommand<G extends GunshiParamsConstraint = DefaultGunshiParams>(cmd: Commandable<G>, name?: string | undefined, needRunResolving?: boolean): Promise<Command<G>>;
484
492
  declare function create<T>(obj?: object | null): T;
485
493
  declare function log(...args: unknown[]): void;
486
494
  declare function deepFreeze<T extends Record<string, any>>(obj: T, ignores?: string[]): Readonly<T>;
487
-
488
- //#endregion
489
- //#region src/constants.d.ts
490
495
  declare namespace constants_d_exports {
491
496
  export { ARG_NEGATABLE_PREFIX, ARG_PREFIX, ARG_PREFIX_AND_KEY_SEPARATOR, BUILD_IN_PREFIX_AND_KEY_SEPARATOR, BUILT_IN_KEY_SEPARATOR, BUILT_IN_PREFIX, COMMAND_BUILTIN_RESOURCE_KEYS, COMMON_ARGS, PLUGIN_PREFIX };
492
497
  }
@@ -515,7 +520,6 @@ type CommonArgType = {
515
520
  };
516
521
  declare const COMMON_ARGS: CommonArgType;
517
522
  declare const COMMAND_BUILTIN_RESOURCE_KEYS: readonly ["USAGE", "COMMAND", "SUBCOMMAND", "COMMANDS", "ARGUMENTS", "OPTIONS", "EXAMPLES", "FORMORE", "NEGATABLE", "DEFAULT", "CHOICES"];
518
-
519
523
  //#endregion
520
524
  //#region src/types.d.ts
521
525
  type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] };
@@ -550,13 +554,11 @@ type CommandBuiltinKeys = GenerateNamespacedKey<BuiltinResourceKeys> | 'descript
550
554
  * The command i18n option keys are used by the i18n plugin for translation.
551
555
  */
552
556
  type CommandArgKeys<A extends Args> = GenerateNamespacedKey<KeyOfArgs<RemovedIndex<A>>, typeof ARG_PREFIX>;
553
-
554
557
  //#endregion
555
558
  //#region src/utils.d.ts
556
559
  declare function resolveBuiltInKey<K extends string = CommandBuiltinArgsKeys | CommandBuiltinResourceKeys>(key: K): GenerateNamespacedKey<K>;
557
560
  declare function resolveArgKey<A extends Args = DefaultGunshiParams['args'], K extends string = KeyOfArgs<RemovedIndex<A>>>(key: K): GenerateNamespacedKey<K, typeof ARG_PREFIX>;
558
561
  declare function resolveExamples<G extends GunshiParamsConstraint = DefaultGunshiParams>(ctx: Readonly<CommandContext<G>>, examples?: string | CommandExamplesFetcher<G>): Promise<string>;
559
562
  declare function namespacedId<K extends string>(id: K): GenerateNamespacedKey<K, typeof PLUGIN_PREFIX>;
560
-
561
563
  //#endregion
562
564
  export { ARG_NEGATABLE_PREFIX, ARG_PREFIX, ARG_PREFIX_AND_KEY_SEPARATOR, BUILD_IN_PREFIX_AND_KEY_SEPARATOR, BUILT_IN_KEY_SEPARATOR, BUILT_IN_PREFIX, BuiltinResourceKeys, COMMAND_BUILTIN_RESOURCE_KEYS, COMMON_ARGS, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, en_US_default as DefaultResource, GenerateNamespacedKey, KeyOfArgs, PLUGIN_PREFIX, RemovedIndex, create, deepFreeze, isLazyCommand, kebabnize, log, namespacedId, resolveArgKey, resolveBuiltInKey, resolveExamples, resolveLazyCommand };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/shared",
3
3
  "description": "shared utils for gunshi",
4
- "version": "0.26.3",
4
+ "version": "0.27.0-alpha.5",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -50,13 +50,13 @@
50
50
  }
51
51
  },
52
52
  "devDependencies": {
53
- "deno": "^2.3.3",
54
- "jsr": "^0.13.4",
53
+ "deno": "^2.4.0",
54
+ "jsr": "^0.13.5",
55
55
  "jsr-exports-lint": "^0.4.1",
56
56
  "publint": "^0.3.12",
57
- "tsdown": "^0.12.3",
58
- "gunshi": "0.26.3",
59
- "@gunshi/resources": "0.26.3"
57
+ "tsdown": "^0.12.9",
58
+ "@gunshi/resources": "0.27.0-alpha.5",
59
+ "gunshi": "0.27.0-alpha.5"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "tsdown",