@h3ravel/shared 0.22.3 → 0.23.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/index.cjs CHANGED
@@ -29,6 +29,10 @@ let path = require("path");
29
29
  path = __toESM(path);
30
30
  let chalk = require("chalk");
31
31
  chalk = __toESM(chalk);
32
+ let inquirer_autocomplete_standalone = require("inquirer-autocomplete-standalone");
33
+ inquirer_autocomplete_standalone = __toESM(inquirer_autocomplete_standalone);
34
+ let __inquirer_prompts = require("@inquirer/prompts");
35
+ __inquirer_prompts = __toESM(__inquirer_prompts);
32
36
  let crypto = require("crypto");
33
37
  crypto = __toESM(crypto);
34
38
  let preferred_pm = require("preferred-pm");
@@ -290,10 +294,10 @@ var Logger = class Logger {
290
294
  process.exit(0);
291
295
  }
292
296
  static chalker(styles) {
293
- return (input) => styles.reduce((acc, style) => {
297
+ return (input$1) => styles.reduce((acc, style) => {
294
298
  if (style in chalk.default) return (typeof style === "function" ? style : chalk.default[style])(acc);
295
299
  return acc;
296
- }, input);
300
+ }, input$1);
297
301
  }
298
302
  static parse(config, joiner = " ", log = true, sc) {
299
303
  const string = config.map(([str, opt]) => {
@@ -361,6 +365,67 @@ var PathLoader = class {
361
365
  }
362
366
  };
363
367
 
368
+ //#endregion
369
+ //#region src/Utils/Prompts.ts
370
+ var Prompts = class extends Logger {
371
+ /**
372
+ * Allows users to pick from a predefined set of choices when asked a question.
373
+ */
374
+ static async choice(message, choices, defaultIndex) {
375
+ return (0, __inquirer_prompts.select)({
376
+ message,
377
+ choices,
378
+ default: defaultIndex ? choices.at(defaultIndex) : void 0
379
+ });
380
+ }
381
+ /**
382
+ * Ask the user for a simple "yes or no" confirmation.
383
+ * By default, this method returns `false`. However, if the user enters y or yes
384
+ * in response to the prompt, the method would return `true`.
385
+ */
386
+ static async confirm(message, def) {
387
+ return (0, __inquirer_prompts.confirm)({
388
+ message,
389
+ default: def
390
+ });
391
+ }
392
+ /**
393
+ * Prompt the user with the given question, accept their input,
394
+ * and then return the user's input back to your command.
395
+ */
396
+ static async ask(message, def) {
397
+ return (0, __inquirer_prompts.input)({
398
+ message,
399
+ default: def
400
+ });
401
+ }
402
+ /**
403
+ * Prompt the user with the given question, accept their input which
404
+ * will not be visible to them as they type in the console,
405
+ * and then return the user's input back to your command.
406
+ */
407
+ static async secret(message, mask) {
408
+ return (0, __inquirer_prompts.password)({
409
+ message,
410
+ mask
411
+ });
412
+ }
413
+ /**
414
+ * Provide auto-completion for possible choices.
415
+ * The user can still provide any answer, regardless of the auto-completion hints.
416
+ */
417
+ static async anticipate(message, source, def) {
418
+ return (0, inquirer_autocomplete_standalone.default)({
419
+ message,
420
+ source: Array.isArray(source) ? async (term) => {
421
+ return (term ? source.filter((e) => e.includes(term)) : source).map((e) => ({ value: e }));
422
+ } : source,
423
+ suggestOnly: true,
424
+ default: def
425
+ });
426
+ }
427
+ };
428
+
364
429
  //#endregion
365
430
  //#region src/Utils/Resolver.ts
366
431
  var Resolver = class {
@@ -482,6 +547,7 @@ exports.FileSystem = FileSystem;
482
547
  exports.HttpContext = HttpContext;
483
548
  exports.Logger = Logger;
484
549
  exports.PathLoader = PathLoader;
550
+ exports.Prompts = Prompts;
485
551
  exports.Resolver = Resolver;
486
552
  exports.TaskManager = TaskManager;
487
553
  exports.baseTsconfig = baseTsconfig;
package/dist/index.d.cts CHANGED
@@ -3,29 +3,31 @@ import { H3, H3Event, Middleware, MiddlewareOptions, serve } from "h3";
3
3
  import { Edge } from "edge.js";
4
4
  import { ResponseHeaderMap, TypedHeaders } from "fetchdts";
5
5
  import { DotNestedKeys as DotNestedKeys$1, DotNestedValue as DotNestedValue$1 } from "@h3ravel/shared";
6
+ import { Separator } from "@inquirer/prompts";
6
7
  import { ChalkInstance } from "chalk";
8
+ import { ChoiceOrSeparatorArray } from "inquirer-autocomplete-standalone";
7
9
 
8
10
  //#region src/Contracts/ObjContract.d.ts
9
11
  /**
10
12
  * Adds a dot prefix to nested keys
11
13
  */
12
- type DotPrefix<T extends string, U extends string> = T extends '' ? U : `${T}.${U}`;
14
+ type DotPrefix<T$1 extends string, U extends string> = T$1 extends '' ? U : `${T$1}.${U}`;
13
15
  /**
14
16
  * Converts a union of objects into a single merged object
15
17
  */
16
- type MergeUnion<T> = (T extends any ? (k: T) => void : never) extends ((k: infer I) => void) ? { [K in keyof I]: I[K] } : never;
18
+ type MergeUnion<T$1> = (T$1 extends any ? (k: T$1) => void : never) extends ((k: infer I) => void) ? { [K in keyof I]: I[K] } : never;
17
19
  /**
18
20
  * Flattens nested objects into dotted keys
19
21
  */
20
- type DotFlatten<T, Prefix extends string = ''> = MergeUnion<{ [K in keyof T & string]: T[K] extends Record<string, any> ? DotFlatten<T[K], DotPrefix<Prefix, K>> : { [P in DotPrefix<Prefix, K>]: T[K] } }[keyof T & string]>;
22
+ type DotFlatten<T$1, Prefix extends string = ''> = MergeUnion<{ [K in keyof T$1 & string]: T$1[K] extends Record<string, any> ? DotFlatten<T$1[K], DotPrefix<Prefix, K>> : { [P in DotPrefix<Prefix, K>]: T$1[K] } }[keyof T$1 & string]>;
21
23
  /**
22
24
  * Builds "nested.key" paths for autocompletion
23
25
  */
24
- type DotNestedKeys<T> = { [K in keyof T & string]: T[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T[K]>}` : `${K}` }[keyof T & string];
26
+ type DotNestedKeys<T$1> = { [K in keyof T$1 & string]: T$1[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T$1[K]>}` : `${K}` }[keyof T$1 & string];
25
27
  /**
26
28
  * Retrieves type at a given dot-path
27
29
  */
28
- type DotNestedValue<T, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? DotNestedValue<T[Key], Rest> : never : Path extends keyof T ? T[Path] : never;
30
+ type DotNestedValue<T$1, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T$1 ? DotNestedValue<T$1[Key], Rest> : never : Path extends keyof T$1 ? T$1[Path] : never;
29
31
  /**
30
32
  * A generic object type that supports nullable string values
31
33
  */
@@ -253,7 +255,7 @@ interface IResponse {
253
255
  //#endregion
254
256
  //#region src/Contracts/IHttp.d.ts
255
257
  type RouterEnd = 'get' | 'delete' | 'put' | 'post' | 'patch' | 'apiResource' | 'group' | 'route';
256
- type ExtractControllerMethods<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? K : never }[keyof T];
258
+ type ExtractControllerMethods<T$1> = { [K in keyof T$1]: T$1[K] extends ((...args: any[]) => any) ? K : never }[keyof T$1];
257
259
  /**
258
260
  * Interface for the Router contract, defining methods for HTTP routing.
259
261
  */
@@ -406,7 +408,7 @@ declare class PathLoader {
406
408
  }
407
409
  //#endregion
408
410
  //#region src/Contracts/BindingsContract.d.ts
409
- type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] };
411
+ type RemoveIndexSignature<T$1> = { [K in keyof T$1 as string extends K ? never : number extends K ? never : K]: T$1[K] };
410
412
  type Bindings = {
411
413
  [key: string]: any;
412
414
  [key: `app.${string}`]: any;
@@ -431,6 +433,17 @@ type Bindings = {
431
433
  };
432
434
  type UseKey = keyof RemoveIndexSignature<Bindings>;
433
435
  //#endregion
436
+ //#region src/Contracts/PromptsContract.d.ts
437
+ type Choice<Value> = {
438
+ value: Value;
439
+ name?: string;
440
+ description?: string;
441
+ short?: string;
442
+ disabled?: boolean | string;
443
+ type?: never;
444
+ };
445
+ type Choices = readonly (string | Separator)[] | readonly (Separator | Choice<string>)[];
446
+ //#endregion
434
447
  //#region src/Contracts/Router.d.ts
435
448
  type RouteMethod = 'get' | 'head' | 'put' | 'patch' | 'post' | 'delete';
436
449
  interface RouteDefinition {
@@ -616,6 +629,86 @@ declare class FileSystem {
616
629
  static resolveFileUp(name: string, extensions: string[] | ((dir: string, filesNames: string[]) => string | false), cwd?: string): string | undefined;
617
630
  }
618
631
  //#endregion
632
+ //#region src/Utils/Prompts.d.ts
633
+ declare class Prompts extends Logger {
634
+ /**
635
+ * Allows users to pick from a predefined set of choices when asked a question.
636
+ */
637
+ static choice(
638
+ /**
639
+ * Message to dislpay
640
+ */
641
+ message: string,
642
+ /**
643
+ * The choices available to the user
644
+ */
645
+ choices: Choices,
646
+ /**
647
+ * Item index front of which the cursor will initially appear
648
+ */
649
+ defaultIndex?: number): Promise<string>;
650
+ /**
651
+ * Ask the user for a simple "yes or no" confirmation.
652
+ * By default, this method returns `false`. However, if the user enters y or yes
653
+ * in response to the prompt, the method would return `true`.
654
+ */
655
+ static confirm(
656
+ /**
657
+ * Message to dislpay
658
+ */
659
+ message: string,
660
+ /**
661
+ * The default value
662
+ */
663
+ def?: boolean | undefined): Promise<boolean>;
664
+ /**
665
+ * Prompt the user with the given question, accept their input,
666
+ * and then return the user's input back to your command.
667
+ */
668
+ static ask(
669
+ /**
670
+ * Message to dislpay
671
+ */
672
+ message: string,
673
+ /**
674
+ * The default value
675
+ */
676
+ def?: string | undefined): Promise<string>;
677
+ /**
678
+ * Prompt the user with the given question, accept their input which
679
+ * will not be visible to them as they type in the console,
680
+ * and then return the user's input back to your command.
681
+ */
682
+ static secret(
683
+ /**
684
+ * Message to dislpay
685
+ */
686
+ message: string,
687
+ /**
688
+ * Mask the user input
689
+ *
690
+ * @default true
691
+ */
692
+ mask?: string | boolean): Promise<string>;
693
+ /**
694
+ * Provide auto-completion for possible choices.
695
+ * The user can still provide any answer, regardless of the auto-completion hints.
696
+ */
697
+ static anticipate(
698
+ /**
699
+ * Message to dislpay
700
+ */
701
+ message: string,
702
+ /**
703
+ * The source of completions
704
+ */
705
+ source: string[] | ((input?: string | undefined) => Promise<ChoiceOrSeparatorArray<any>>),
706
+ /**
707
+ * Set a default value
708
+ */
709
+ def?: string): Promise<any>;
710
+ }
711
+ //#endregion
619
712
  //#region src/Utils/Resolver.d.ts
620
713
  declare class Resolver {
621
714
  static getPakageInstallCommand(pkg?: string): Promise<string>;
@@ -676,4 +769,4 @@ declare class TaskManager {
676
769
  static advancedTaskRunner<R = any>(info: [[string, string], [string, string]] | [[string, string]], task: (() => Promise<R>) | (() => R)): Promise<R | undefined>;
677
770
  }
678
771
  //#endregion
679
- export { Bindings, DotFlatten, DotNestedKeys, DotNestedValue, EnvParser, EventHandler, ExtractControllerMethods, FileSystem, GenericWithNullableStringValues, HttpContext, IApplication, IContainer, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, PathLoader, Resolver, RouteDefinition, RouteEventHandler, RouteMethod, RouterEnd, TaskManager, UseKey, baseTsconfig, mainTsconfig, packageJsonScript };
772
+ export { Bindings, Choice, Choices, DotFlatten, DotNestedKeys, DotNestedValue, EnvParser, EventHandler, ExtractControllerMethods, FileSystem, GenericWithNullableStringValues, HttpContext, IApplication, IContainer, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, PathLoader, Prompts, Resolver, RouteDefinition, RouteEventHandler, RouteMethod, RouterEnd, TaskManager, UseKey, baseTsconfig, mainTsconfig, packageJsonScript };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  /// <reference path="./app.globals.d.ts" />
2
2
  import { ChalkInstance } from "chalk";
3
+ import { ChoiceOrSeparatorArray } from "inquirer-autocomplete-standalone";
4
+ import { Separator } from "@inquirer/prompts";
3
5
  import { H3, H3Event, Middleware, MiddlewareOptions, serve } from "h3";
4
6
  import { Edge } from "edge.js";
5
7
  import { ResponseHeaderMap, TypedHeaders } from "fetchdts";
@@ -9,23 +11,23 @@ import { DotNestedKeys as DotNestedKeys$1, DotNestedValue as DotNestedValue$1 }
9
11
  /**
10
12
  * Adds a dot prefix to nested keys
11
13
  */
12
- type DotPrefix<T extends string, U extends string> = T extends '' ? U : `${T}.${U}`;
14
+ type DotPrefix<T$1 extends string, U extends string> = T$1 extends '' ? U : `${T$1}.${U}`;
13
15
  /**
14
16
  * Converts a union of objects into a single merged object
15
17
  */
16
- type MergeUnion<T> = (T extends any ? (k: T) => void : never) extends ((k: infer I) => void) ? { [K in keyof I]: I[K] } : never;
18
+ type MergeUnion<T$1> = (T$1 extends any ? (k: T$1) => void : never) extends ((k: infer I) => void) ? { [K in keyof I]: I[K] } : never;
17
19
  /**
18
20
  * Flattens nested objects into dotted keys
19
21
  */
20
- type DotFlatten<T, Prefix extends string = ''> = MergeUnion<{ [K in keyof T & string]: T[K] extends Record<string, any> ? DotFlatten<T[K], DotPrefix<Prefix, K>> : { [P in DotPrefix<Prefix, K>]: T[K] } }[keyof T & string]>;
22
+ type DotFlatten<T$1, Prefix extends string = ''> = MergeUnion<{ [K in keyof T$1 & string]: T$1[K] extends Record<string, any> ? DotFlatten<T$1[K], DotPrefix<Prefix, K>> : { [P in DotPrefix<Prefix, K>]: T$1[K] } }[keyof T$1 & string]>;
21
23
  /**
22
24
  * Builds "nested.key" paths for autocompletion
23
25
  */
24
- type DotNestedKeys<T> = { [K in keyof T & string]: T[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T[K]>}` : `${K}` }[keyof T & string];
26
+ type DotNestedKeys<T$1> = { [K in keyof T$1 & string]: T$1[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T$1[K]>}` : `${K}` }[keyof T$1 & string];
25
27
  /**
26
28
  * Retrieves type at a given dot-path
27
29
  */
28
- type DotNestedValue<T, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? DotNestedValue<T[Key], Rest> : never : Path extends keyof T ? T[Path] : never;
30
+ type DotNestedValue<T$1, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T$1 ? DotNestedValue<T$1[Key], Rest> : never : Path extends keyof T$1 ? T$1[Path] : never;
29
31
  /**
30
32
  * A generic object type that supports nullable string values
31
33
  */
@@ -253,7 +255,7 @@ interface IResponse {
253
255
  //#endregion
254
256
  //#region src/Contracts/IHttp.d.ts
255
257
  type RouterEnd = 'get' | 'delete' | 'put' | 'post' | 'patch' | 'apiResource' | 'group' | 'route';
256
- type ExtractControllerMethods<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? K : never }[keyof T];
258
+ type ExtractControllerMethods<T$1> = { [K in keyof T$1]: T$1[K] extends ((...args: any[]) => any) ? K : never }[keyof T$1];
257
259
  /**
258
260
  * Interface for the Router contract, defining methods for HTTP routing.
259
261
  */
@@ -406,7 +408,7 @@ declare class PathLoader {
406
408
  }
407
409
  //#endregion
408
410
  //#region src/Contracts/BindingsContract.d.ts
409
- type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] };
411
+ type RemoveIndexSignature<T$1> = { [K in keyof T$1 as string extends K ? never : number extends K ? never : K]: T$1[K] };
410
412
  type Bindings = {
411
413
  [key: string]: any;
412
414
  [key: `app.${string}`]: any;
@@ -431,6 +433,17 @@ type Bindings = {
431
433
  };
432
434
  type UseKey = keyof RemoveIndexSignature<Bindings>;
433
435
  //#endregion
436
+ //#region src/Contracts/PromptsContract.d.ts
437
+ type Choice<Value> = {
438
+ value: Value;
439
+ name?: string;
440
+ description?: string;
441
+ short?: string;
442
+ disabled?: boolean | string;
443
+ type?: never;
444
+ };
445
+ type Choices = readonly (string | Separator)[] | readonly (Separator | Choice<string>)[];
446
+ //#endregion
434
447
  //#region src/Contracts/Router.d.ts
435
448
  type RouteMethod = 'get' | 'head' | 'put' | 'patch' | 'post' | 'delete';
436
449
  interface RouteDefinition {
@@ -616,6 +629,86 @@ declare class FileSystem {
616
629
  static resolveFileUp(name: string, extensions: string[] | ((dir: string, filesNames: string[]) => string | false), cwd?: string): string | undefined;
617
630
  }
618
631
  //#endregion
632
+ //#region src/Utils/Prompts.d.ts
633
+ declare class Prompts extends Logger {
634
+ /**
635
+ * Allows users to pick from a predefined set of choices when asked a question.
636
+ */
637
+ static choice(
638
+ /**
639
+ * Message to dislpay
640
+ */
641
+ message: string,
642
+ /**
643
+ * The choices available to the user
644
+ */
645
+ choices: Choices,
646
+ /**
647
+ * Item index front of which the cursor will initially appear
648
+ */
649
+ defaultIndex?: number): Promise<string>;
650
+ /**
651
+ * Ask the user for a simple "yes or no" confirmation.
652
+ * By default, this method returns `false`. However, if the user enters y or yes
653
+ * in response to the prompt, the method would return `true`.
654
+ */
655
+ static confirm(
656
+ /**
657
+ * Message to dislpay
658
+ */
659
+ message: string,
660
+ /**
661
+ * The default value
662
+ */
663
+ def?: boolean | undefined): Promise<boolean>;
664
+ /**
665
+ * Prompt the user with the given question, accept their input,
666
+ * and then return the user's input back to your command.
667
+ */
668
+ static ask(
669
+ /**
670
+ * Message to dislpay
671
+ */
672
+ message: string,
673
+ /**
674
+ * The default value
675
+ */
676
+ def?: string | undefined): Promise<string>;
677
+ /**
678
+ * Prompt the user with the given question, accept their input which
679
+ * will not be visible to them as they type in the console,
680
+ * and then return the user's input back to your command.
681
+ */
682
+ static secret(
683
+ /**
684
+ * Message to dislpay
685
+ */
686
+ message: string,
687
+ /**
688
+ * Mask the user input
689
+ *
690
+ * @default true
691
+ */
692
+ mask?: string | boolean): Promise<string>;
693
+ /**
694
+ * Provide auto-completion for possible choices.
695
+ * The user can still provide any answer, regardless of the auto-completion hints.
696
+ */
697
+ static anticipate(
698
+ /**
699
+ * Message to dislpay
700
+ */
701
+ message: string,
702
+ /**
703
+ * The source of completions
704
+ */
705
+ source: string[] | ((input?: string | undefined) => Promise<ChoiceOrSeparatorArray<any>>),
706
+ /**
707
+ * Set a default value
708
+ */
709
+ def?: string): Promise<any>;
710
+ }
711
+ //#endregion
619
712
  //#region src/Utils/Resolver.d.ts
620
713
  declare class Resolver {
621
714
  static getPakageInstallCommand(pkg?: string): Promise<string>;
@@ -676,4 +769,4 @@ declare class TaskManager {
676
769
  static advancedTaskRunner<R = any>(info: [[string, string], [string, string]] | [[string, string]], task: (() => Promise<R>) | (() => R)): Promise<R | undefined>;
677
770
  }
678
771
  //#endregion
679
- export { Bindings, DotFlatten, DotNestedKeys, DotNestedValue, EnvParser, EventHandler, ExtractControllerMethods, FileSystem, GenericWithNullableStringValues, HttpContext, IApplication, IContainer, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, PathLoader, Resolver, RouteDefinition, RouteEventHandler, RouteMethod, RouterEnd, TaskManager, UseKey, baseTsconfig, mainTsconfig, packageJsonScript };
772
+ export { Bindings, Choice, Choices, DotFlatten, DotNestedKeys, DotNestedValue, EnvParser, EventHandler, ExtractControllerMethods, FileSystem, GenericWithNullableStringValues, HttpContext, IApplication, IContainer, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, PathLoader, Prompts, Resolver, RouteDefinition, RouteEventHandler, RouteMethod, RouterEnd, TaskManager, UseKey, baseTsconfig, mainTsconfig, packageJsonScript };
package/dist/index.js CHANGED
@@ -2,6 +2,8 @@ import { access } from "fs/promises";
2
2
  import escalade from "escalade/sync";
3
3
  import path from "path";
4
4
  import chalk from "chalk";
5
+ import autocomplete from "inquirer-autocomplete-standalone";
6
+ import { confirm, input, password, select } from "@inquirer/prompts";
5
7
  import crypto from "crypto";
6
8
  import preferredPM from "preferred-pm";
7
9
 
@@ -261,10 +263,10 @@ var Logger = class Logger {
261
263
  process.exit(0);
262
264
  }
263
265
  static chalker(styles) {
264
- return (input) => styles.reduce((acc, style) => {
266
+ return (input$1) => styles.reduce((acc, style) => {
265
267
  if (style in chalk) return (typeof style === "function" ? style : chalk[style])(acc);
266
268
  return acc;
267
- }, input);
269
+ }, input$1);
268
270
  }
269
271
  static parse(config, joiner = " ", log = true, sc) {
270
272
  const string = config.map(([str, opt]) => {
@@ -332,6 +334,67 @@ var PathLoader = class {
332
334
  }
333
335
  };
334
336
 
337
+ //#endregion
338
+ //#region src/Utils/Prompts.ts
339
+ var Prompts = class extends Logger {
340
+ /**
341
+ * Allows users to pick from a predefined set of choices when asked a question.
342
+ */
343
+ static async choice(message, choices, defaultIndex) {
344
+ return select({
345
+ message,
346
+ choices,
347
+ default: defaultIndex ? choices.at(defaultIndex) : void 0
348
+ });
349
+ }
350
+ /**
351
+ * Ask the user for a simple "yes or no" confirmation.
352
+ * By default, this method returns `false`. However, if the user enters y or yes
353
+ * in response to the prompt, the method would return `true`.
354
+ */
355
+ static async confirm(message, def) {
356
+ return confirm({
357
+ message,
358
+ default: def
359
+ });
360
+ }
361
+ /**
362
+ * Prompt the user with the given question, accept their input,
363
+ * and then return the user's input back to your command.
364
+ */
365
+ static async ask(message, def) {
366
+ return input({
367
+ message,
368
+ default: def
369
+ });
370
+ }
371
+ /**
372
+ * Prompt the user with the given question, accept their input which
373
+ * will not be visible to them as they type in the console,
374
+ * and then return the user's input back to your command.
375
+ */
376
+ static async secret(message, mask) {
377
+ return password({
378
+ message,
379
+ mask
380
+ });
381
+ }
382
+ /**
383
+ * Provide auto-completion for possible choices.
384
+ * The user can still provide any answer, regardless of the auto-completion hints.
385
+ */
386
+ static async anticipate(message, source, def) {
387
+ return autocomplete({
388
+ message,
389
+ source: Array.isArray(source) ? async (term) => {
390
+ return (term ? source.filter((e) => e.includes(term)) : source).map((e) => ({ value: e }));
391
+ } : source,
392
+ suggestOnly: true,
393
+ default: def
394
+ });
395
+ }
396
+ };
397
+
335
398
  //#endregion
336
399
  //#region src/Utils/Resolver.ts
337
400
  var Resolver = class {
@@ -448,4 +511,4 @@ var TaskManager = class {
448
511
  };
449
512
 
450
513
  //#endregion
451
- export { EnvParser, FileSystem, HttpContext, Logger, PathLoader, Resolver, TaskManager, baseTsconfig, mainTsconfig, packageJsonScript };
514
+ export { EnvParser, FileSystem, HttpContext, Logger, PathLoader, Prompts, Resolver, TaskManager, baseTsconfig, mainTsconfig, packageJsonScript };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/shared",
3
- "version": "0.22.3",
3
+ "version": "0.23.0",
4
4
  "description": "Shared Utilities.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -44,15 +44,16 @@
44
44
  "laravel"
45
45
  ],
46
46
  "dependencies": {
47
- "h3": "^2.0.0-beta.4",
47
+ "@inquirer/prompts": "^7.9.0",
48
48
  "chalk": "^5.6.0",
49
49
  "edge.js": "^6.3.0",
50
- "preferred-pm": "^4.1.1",
51
- "escalade": "^3.2.0"
50
+ "escalade": "^3.2.0",
51
+ "h3": "^2.0.0-beta.4",
52
+ "inquirer-autocomplete-standalone": "^0.8.1",
53
+ "preferred-pm": "^4.1.1"
52
54
  },
53
55
  "devDependencies": {
54
56
  "fetchdts": "^0.1.6",
55
- "install": "^0.13.0",
56
57
  "pnpm": "^10.14.0"
57
58
  },
58
59
  "scripts": {