@reliverse/rempts 1.6.2 → 1.7.1

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 (89) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +311 -77
  3. package/bin/{core-impl → components}/anykey/anykey-mod.d.ts +1 -1
  4. package/bin/{core-impl → components}/anykey/anykey-mod.js +1 -1
  5. package/bin/{core-impl → components}/date/date.d.ts +1 -1
  6. package/bin/{core-impl → components}/editor/editor-mod.d.ts +1 -1
  7. package/bin/{core-impl → components}/editor/editor-mod.js +7 -7
  8. package/bin/{core-impl → components}/input/confirm-prompt.d.ts +1 -1
  9. package/bin/{core-impl → components}/input/confirm-prompt.js +1 -1
  10. package/bin/{core-impl → components}/input/input-prompt.d.ts +1 -1
  11. package/bin/{core-impl → components}/input/input-prompt.js +3 -7
  12. package/bin/{core-impl → components}/launcher/deprecated/_parser.ts.txt +1 -1
  13. package/bin/{core-impl → components}/launcher/deprecated/_utils.ts.txt +1 -1
  14. package/bin/{core-impl → components}/launcher/deprecated/args.ts.txt +1 -1
  15. package/bin/{core-impl → components}/launcher/deprecated/command.ts.txt +1 -1
  16. package/bin/{core-impl → components}/launcher/deprecated/launcher-mod.ts.txt +1 -1
  17. package/bin/{core-impl → components}/launcher/deprecated/usage.ts.txt +1 -1
  18. package/bin/components/launcher/launcher-mod.d.ts +177 -0
  19. package/bin/components/launcher/launcher-mod.js +626 -0
  20. package/bin/{core-impl → components}/msg-fmt/colors.d.ts +1 -1
  21. package/bin/{core-impl → components}/msg-fmt/logger.d.ts +1 -1
  22. package/bin/{core-impl → components}/msg-fmt/logger.js +1 -4
  23. package/bin/{core-impl → components}/msg-fmt/mapping.d.ts +1 -1
  24. package/bin/{core-impl → components}/msg-fmt/messages.d.ts +1 -1
  25. package/bin/{core-impl → components}/msg-fmt/variants.d.ts +1 -1
  26. package/bin/{core-impl → components}/next-steps/next-steps.d.ts +2 -2
  27. package/bin/{core-impl → components}/number/number-mod.d.ts +1 -1
  28. package/bin/{core-impl → components}/select/multiselect-prompt.d.ts +1 -1
  29. package/bin/{core-impl → components}/select/multiselect-prompt.js +1 -1
  30. package/bin/{core-impl → components}/select/nummultiselect-prompt.d.ts +1 -1
  31. package/bin/{core-impl → components}/select/numselect-prompt.d.ts +1 -1
  32. package/bin/{core-impl → components}/select/numselect-prompt.js +1 -1
  33. package/bin/{core-impl → components}/select/select-prompt.d.ts +1 -1
  34. package/bin/{core-impl → components}/select/select-prompt.js +2 -2
  35. package/bin/{core-impl → components}/select/toggle-prompt.d.ts +1 -1
  36. package/bin/{core-impl → components}/select/toggle-prompt.js +1 -1
  37. package/bin/{core-impl → components}/st-end/end.d.ts +1 -1
  38. package/bin/{core-impl → components}/st-end/start.d.ts +1 -1
  39. package/bin/{core-impl → components}/st-end/start.js +2 -2
  40. package/bin/{core-impl → components}/task/progress.d.ts +1 -1
  41. package/bin/{core-impl → components}/visual/animate/animate.d.ts +1 -1
  42. package/bin/hooks/spinner/spinner-mod.d.ts +20 -0
  43. package/bin/hooks/spinner/spinner-mod.js +26 -0
  44. package/bin/mod.d.ts +37 -0
  45. package/bin/mod.js +88 -0
  46. package/bin/{core-impl/utils → utils}/colorize.d.ts +1 -1
  47. package/bin/{core-impl/utils → utils}/prevent.d.ts +1 -1
  48. package/bin/{core-impl/utils → utils}/prevent.js +2 -2
  49. package/bin/{core-impl/utils → utils}/prompt-end.d.ts +1 -1
  50. package/bin/{core-impl/utils → utils}/prompt-end.js +2 -2
  51. package/bin/{core-impl/utils → utils}/stream-text.d.ts +1 -1
  52. package/bin/{core-impl/utils → utils}/stream-text.js +2 -2
  53. package/package.json +46 -24
  54. package/bin/core-impl/figures/figures.test.d.ts +0 -1
  55. package/bin/core-impl/figures/figures.test.js +0 -474
  56. package/bin/core-impl/launcher/launcher-mod.d.ts +0 -92
  57. package/bin/core-impl/launcher/launcher-mod.js +0 -371
  58. package/bin/main.d.ts +0 -36
  59. package/bin/main.js +0 -86
  60. /package/bin/{core-impl → components}/date/date.js +0 -0
  61. /package/bin/{core-impl → components}/figures/figures-mod.d.ts +0 -0
  62. /package/bin/{core-impl → components}/figures/figures-mod.js +0 -0
  63. /package/bin/{core-impl → components}/msg-fmt/colors.js +0 -0
  64. /package/bin/{core-impl → components}/msg-fmt/mapping.js +0 -0
  65. /package/bin/{core-impl → components}/msg-fmt/messages.js +0 -0
  66. /package/bin/{core-impl → components}/msg-fmt/terminal.d.ts +0 -0
  67. /package/bin/{core-impl → components}/msg-fmt/terminal.js +0 -0
  68. /package/bin/{core-impl → components}/msg-fmt/variants.js +0 -0
  69. /package/bin/{core-impl → components}/next-steps/next-steps.js +0 -0
  70. /package/bin/{core-impl → components}/number/number-mod.js +0 -0
  71. /package/bin/{core-impl → components}/results/results.d.ts +0 -0
  72. /package/bin/{core-impl → components}/results/results.js +0 -0
  73. /package/bin/{core-impl → components}/select/nummultiselect-prompt.js +0 -0
  74. /package/bin/{core-impl → components}/st-end/end.js +0 -0
  75. /package/bin/{core-impl → components}/task/progress.js +0 -0
  76. /package/bin/{core-impl → components}/task/spinner.d.ts +0 -0
  77. /package/bin/{core-impl → components}/task/spinner.js +0 -0
  78. /package/bin/{core-impl → components}/visual/animate/animate.js +0 -0
  79. /package/bin/{core-impl → components}/visual/ascii-art/ascii-art.d.ts +0 -0
  80. /package/bin/{core-impl → components}/visual/ascii-art/ascii-art.js +0 -0
  81. /package/bin/{core-types.d.ts → types.d.ts} +0 -0
  82. /package/bin/{core-types.js → types.js} +0 -0
  83. /package/bin/{core-impl/utils → utils}/colorize.js +0 -0
  84. /package/bin/{core-impl/utils → utils}/errors.d.ts +0 -0
  85. /package/bin/{core-impl/utils → utils}/errors.js +0 -0
  86. /package/bin/{core-impl/utils → utils}/system.d.ts +0 -0
  87. /package/bin/{core-impl/utils → utils}/system.js +0 -0
  88. /package/bin/{core-impl/utils → utils}/validate.d.ts +0 -0
  89. /package/bin/{core-impl/utils → utils}/validate.js +0 -0
@@ -1,14 +1,10 @@
1
1
  import { re } from "@reliverse/relico";
2
2
  import { isUnicodeSupported } from "@reliverse/runtime";
3
3
  import readline from "node:readline/promises";
4
- import {
5
- bar,
6
- msg,
7
- msgUndoAll
8
- } from "../msg-fmt/messages.js";
4
+ import { bar, msg, msgUndoAll } from "../msg-fmt/messages.js";
9
5
  import { deleteLastLine } from "../msg-fmt/terminal.js";
10
- import { completePrompt } from "../utils/prompt-end.js";
11
- import { streamText } from "../utils/stream-text.js";
6
+ import { completePrompt } from "../../utils/prompt-end.js";
7
+ import { streamText } from "../../utils/stream-text.js";
12
8
  const unicode = isUnicodeSupported();
13
9
  const S_MASK = unicode ? "\u258B" : "*";
14
10
  function getMaskChar(customMask) {
@@ -2,7 +2,7 @@ import type {
2
2
  Default,
3
3
  ParserArgv,
4
4
  ParserOptions,
5
- } from "~/libs/core/core-types.js";
5
+ } from "~/types.js";
6
6
 
7
7
  function toArr(any: any) {
8
8
  // biome-ignore lint/suspicious/noDoubleEquals: <explanation>
@@ -1,4 +1,4 @@
1
- import type { Resolvable } from "~/libs/core/core-types.js";
1
+ import type { Resolvable } from "~/types.js";
2
2
 
3
3
  export function toArray(val: any) {
4
4
  if (Array.isArray(val)) {
@@ -1,6 +1,6 @@
1
1
  import { kebabCase, camelCase } from "scule";
2
2
 
3
- import type { Arg, ArgsDef, ParsedArgs } from "~/libs/core/core-types.js";
3
+ import type { Arg, ArgsDef, ParsedArgs } from "~/types.js";
4
4
 
5
5
  import { parseRawArgs } from "./_parser.js";
6
6
  import { CLIError, toArray } from "./_utils.js";
@@ -3,7 +3,7 @@ import type {
3
3
  CommandContext,
4
4
  CommandDef,
5
5
  RunCommandOptions,
6
- } from "~/libs/core/core-types.js";
6
+ } from "~/types.js";
7
7
 
8
8
  import { CLIError, resolveValue } from "./_utils.js";
9
9
  import { parseArgs } from "./args.js";
@@ -1,6 +1,6 @@
1
1
  import { relinka } from "@reliverse/relinka";
2
2
 
3
- import type { ArgsDef, CommandDef } from "~/libs/core/core-types.js";
3
+ import type { ArgsDef, CommandDef } from "~/types.js";
4
4
 
5
5
  import { CLIError } from "./_utils.js";
6
6
  import { resolveSubCommand, runCommand } from "./command.js";
@@ -1,7 +1,7 @@
1
1
  import { re } from "@reliverse/relico";
2
2
  import { relinka } from "@reliverse/relinka";
3
3
 
4
- import type { ArgsDef, CommandDef } from "~/libs/core/core-types.js";
4
+ import type { ArgsDef, CommandDef } from "~/types.js";
5
5
 
6
6
  import { formatLineColumns, resolveValue } from "./_utils.js";
7
7
  import { resolveArgs } from "./args.js";
@@ -0,0 +1,177 @@
1
+ import type { ReliArgParserOptions } from "@reliverse/reliarg";
2
+ type InvalidDefaultError<O extends readonly string[]> = {
3
+ __error__: "Default value(s) must be a subset of options";
4
+ options: O;
5
+ };
6
+ type EmptyArgs = Record<string, never>;
7
+ type BaseArgProps = {
8
+ description?: string;
9
+ required?: boolean;
10
+ };
11
+ type PositionalArgDefinition = {
12
+ type: "positional";
13
+ default?: string;
14
+ } & BaseArgProps;
15
+ type BooleanArgDefinition = {
16
+ type: "boolean";
17
+ default?: boolean;
18
+ } & BaseArgProps;
19
+ type StringArgDefinition = {
20
+ type: "string";
21
+ default?: string;
22
+ } & BaseArgProps;
23
+ type NumberArgDefinition = {
24
+ type: "number";
25
+ default?: number;
26
+ } & BaseArgProps;
27
+ type ArrayArgDefinition = {
28
+ type: "array";
29
+ default?: string | readonly string[];
30
+ options: readonly string[];
31
+ } & BaseArgProps;
32
+ export type ArgDefinition = PositionalArgDefinition | BooleanArgDefinition | StringArgDefinition | NumberArgDefinition | ArrayArgDefinition;
33
+ export type ArgDefinitions = Record<string, ArgDefinition>;
34
+ type CommandMeta = {
35
+ name: string;
36
+ version?: string;
37
+ description?: string;
38
+ hidden?: boolean;
39
+ aliases?: string[];
40
+ };
41
+ /**
42
+ * A subcommand can be either:
43
+ * 1) A string path to a module with a default export of type Command.
44
+ * 2) A lazy import function returning a Promise that resolves to
45
+ * { default: Command<any> } or directly to a Command instance.
46
+ */
47
+ type SubCommandSpec = string | (() => Promise<{
48
+ default: Command<any>;
49
+ } | Command<any>>);
50
+ export type SubCommandsMap = Record<string, SubCommandSpec>;
51
+ type CommandContext<ARGS> = {
52
+ args: ARGS;
53
+ raw: string[];
54
+ };
55
+ type CommandRun<ARGS> = (ctx: CommandContext<ARGS>) => void | Promise<void>;
56
+ type DefineCommandOptions<A extends ArgDefinitions = EmptyArgs> = {
57
+ meta?: CommandMeta;
58
+ args?: A;
59
+ run?: CommandRun<InferArgTypes<A>>;
60
+ subCommands?: SubCommandsMap;
61
+ /**
62
+ * Called before the command or subcommand runs
63
+ */
64
+ onCmdStart?: () => void | Promise<void>;
65
+ /**
66
+ * Called after the command or subcommand finishes
67
+ */
68
+ onCmdEnd?: () => void | Promise<void>;
69
+ /**
70
+ * @deprecated Use onCmdStart instead
71
+ */
72
+ setup?: () => void | Promise<void>;
73
+ /**
74
+ * @deprecated Use onCmdEnd instead
75
+ */
76
+ cleanup?: () => void | Promise<void>;
77
+ /**
78
+ * Called once per CLI process, before any command/subcommand/run() is executed
79
+ */
80
+ onLauncherStart?: () => void | Promise<void>;
81
+ /**
82
+ * Called once per CLI process, after all command/subcommand/run() logic is finished
83
+ */
84
+ onLauncherEnd?: () => void | Promise<void>;
85
+ };
86
+ export type Command<A extends ArgDefinitions = EmptyArgs> = {
87
+ meta?: CommandMeta;
88
+ args: A;
89
+ run?: CommandRun<InferArgTypes<A>>;
90
+ subCommands?: SubCommandsMap;
91
+ /**
92
+ * Called before the command or subcommand runs
93
+ */
94
+ onCmdStart?: () => void | Promise<void>;
95
+ /**
96
+ * Called after the command or subcommand finishes
97
+ */
98
+ onCmdEnd?: () => void | Promise<void>;
99
+ /**
100
+ * @deprecated Use onCmdStart instead
101
+ */
102
+ setup?: () => void | Promise<void>;
103
+ /**
104
+ * @deprecated Use onCmdEnd instead
105
+ */
106
+ cleanup?: () => void | Promise<void>;
107
+ /**
108
+ * Called once per CLI process, before any command/subcommand/run() is executed
109
+ */
110
+ onLauncherStart?: () => void | Promise<void>;
111
+ /**
112
+ * Called once per CLI process, after all command/subcommand/run() logic is finished
113
+ */
114
+ onLauncherEnd?: () => void | Promise<void>;
115
+ };
116
+ export type InferArgTypes<A extends ArgDefinitions> = {
117
+ [K in keyof A]: A[K] extends PositionalArgDefinition ? string : A[K] extends BooleanArgDefinition ? boolean : A[K] extends StringArgDefinition ? string : A[K] extends NumberArgDefinition ? number : A[K] extends {
118
+ type: "array";
119
+ options: infer O extends readonly string[];
120
+ } ? O[number][] : never;
121
+ };
122
+ type ValidateArrayDefaults<A extends ArgDefinitions> = {
123
+ [K in keyof A]: A[K] extends {
124
+ type: "array";
125
+ options: infer O extends readonly string[];
126
+ default?: infer D;
127
+ } ? D extends undefined ? A[K] : D extends O[number] ? A[K] : D extends readonly (infer E)[] ? E extends O[number] ? A[K] : Omit<A[K], "default"> & {
128
+ default: InvalidDefaultError<O>;
129
+ } : Omit<A[K], "default"> & {
130
+ default: InvalidDefaultError<O>;
131
+ } : A[K];
132
+ };
133
+ export type FileBasedCmdsOptions = {
134
+ enable: boolean;
135
+ cmdsRootPath: string;
136
+ };
137
+ /**
138
+ * Defines a command with metadata, argument definitions,
139
+ * an execution function, and (optional) subCommands.
140
+ */
141
+ export declare function defineCommand<A extends ArgDefinitions = EmptyArgs>(options: DefineCommandOptions<A>): Command<A>;
142
+ /**
143
+ * Show usage for a given command.
144
+ */
145
+ export declare function showUsage<A extends ArgDefinitions>(command: Command<A>, parserOptions?: ReliArgParserOptions & {
146
+ fileBasedCmds?: FileBasedCmdsOptions;
147
+ autoExit?: boolean;
148
+ metaSettings?: {
149
+ showDescriptionOnMain?: boolean;
150
+ };
151
+ }, displayNotFoundMessage?: boolean): Promise<void>;
152
+ /**
153
+ * Primary entry point to run a command. This function supports:
154
+ *
155
+ * - File-based Subcommands: scanning for subcommands within a given commands root.
156
+ * - SubCommands defined within the command object.
157
+ * - Standard flags like --help, --version, and --debug.
158
+ *
159
+ * This function passes along remaining arguments to subcommand runners to ensure
160
+ * consistent parsing.
161
+ */
162
+ export declare function runMain<A extends ArgDefinitions = EmptyArgs>(command: Command<A>, parserOptions?: ReliArgParserOptions & {
163
+ fileBasedCmds?: FileBasedCmdsOptions;
164
+ autoExit?: boolean;
165
+ metaSettings?: {
166
+ showDescriptionOnMain?: boolean;
167
+ };
168
+ }): Promise<void>;
169
+ /**
170
+ * Helper to define argument definitions with improved type inference
171
+ * for IntelliSense and validation for array defaults against options.
172
+ *
173
+ * **Note:** For array types, use `as const` on the `options` array to enable
174
+ * precise default value validation (e.g., `options: ["a", "b"] as const`).
175
+ */
176
+ export declare function defineArgs<A extends ArgDefinitions>(args: A & ValidateArrayDefaults<A>): A;
177
+ export {};