@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.
- package/LICENSE +1 -1
- package/README.md +311 -77
- package/bin/{core-impl → components}/anykey/anykey-mod.d.ts +1 -1
- package/bin/{core-impl → components}/anykey/anykey-mod.js +1 -1
- package/bin/{core-impl → components}/date/date.d.ts +1 -1
- package/bin/{core-impl → components}/editor/editor-mod.d.ts +1 -1
- package/bin/{core-impl → components}/editor/editor-mod.js +7 -7
- package/bin/{core-impl → components}/input/confirm-prompt.d.ts +1 -1
- package/bin/{core-impl → components}/input/confirm-prompt.js +1 -1
- package/bin/{core-impl → components}/input/input-prompt.d.ts +1 -1
- package/bin/{core-impl → components}/input/input-prompt.js +3 -7
- package/bin/{core-impl → components}/launcher/deprecated/_parser.ts.txt +1 -1
- package/bin/{core-impl → components}/launcher/deprecated/_utils.ts.txt +1 -1
- package/bin/{core-impl → components}/launcher/deprecated/args.ts.txt +1 -1
- package/bin/{core-impl → components}/launcher/deprecated/command.ts.txt +1 -1
- package/bin/{core-impl → components}/launcher/deprecated/launcher-mod.ts.txt +1 -1
- package/bin/{core-impl → components}/launcher/deprecated/usage.ts.txt +1 -1
- package/bin/components/launcher/launcher-mod.d.ts +177 -0
- package/bin/components/launcher/launcher-mod.js +626 -0
- package/bin/{core-impl → components}/msg-fmt/colors.d.ts +1 -1
- package/bin/{core-impl → components}/msg-fmt/logger.d.ts +1 -1
- package/bin/{core-impl → components}/msg-fmt/logger.js +1 -4
- package/bin/{core-impl → components}/msg-fmt/mapping.d.ts +1 -1
- package/bin/{core-impl → components}/msg-fmt/messages.d.ts +1 -1
- package/bin/{core-impl → components}/msg-fmt/variants.d.ts +1 -1
- package/bin/{core-impl → components}/next-steps/next-steps.d.ts +2 -2
- package/bin/{core-impl → components}/number/number-mod.d.ts +1 -1
- package/bin/{core-impl → components}/select/multiselect-prompt.d.ts +1 -1
- package/bin/{core-impl → components}/select/multiselect-prompt.js +1 -1
- package/bin/{core-impl → components}/select/nummultiselect-prompt.d.ts +1 -1
- package/bin/{core-impl → components}/select/numselect-prompt.d.ts +1 -1
- package/bin/{core-impl → components}/select/numselect-prompt.js +1 -1
- package/bin/{core-impl → components}/select/select-prompt.d.ts +1 -1
- package/bin/{core-impl → components}/select/select-prompt.js +2 -2
- package/bin/{core-impl → components}/select/toggle-prompt.d.ts +1 -1
- package/bin/{core-impl → components}/select/toggle-prompt.js +1 -1
- package/bin/{core-impl → components}/st-end/end.d.ts +1 -1
- package/bin/{core-impl → components}/st-end/start.d.ts +1 -1
- package/bin/{core-impl → components}/st-end/start.js +2 -2
- package/bin/{core-impl → components}/task/progress.d.ts +1 -1
- package/bin/{core-impl → components}/visual/animate/animate.d.ts +1 -1
- package/bin/hooks/spinner/spinner-mod.d.ts +20 -0
- package/bin/hooks/spinner/spinner-mod.js +26 -0
- package/bin/mod.d.ts +37 -0
- package/bin/mod.js +88 -0
- package/bin/{core-impl/utils → utils}/colorize.d.ts +1 -1
- package/bin/{core-impl/utils → utils}/prevent.d.ts +1 -1
- package/bin/{core-impl/utils → utils}/prevent.js +2 -2
- package/bin/{core-impl/utils → utils}/prompt-end.d.ts +1 -1
- package/bin/{core-impl/utils → utils}/prompt-end.js +2 -2
- package/bin/{core-impl/utils → utils}/stream-text.d.ts +1 -1
- package/bin/{core-impl/utils → utils}/stream-text.js +2 -2
- package/package.json +46 -24
- package/bin/core-impl/figures/figures.test.d.ts +0 -1
- package/bin/core-impl/figures/figures.test.js +0 -474
- package/bin/core-impl/launcher/launcher-mod.d.ts +0 -92
- package/bin/core-impl/launcher/launcher-mod.js +0 -371
- package/bin/main.d.ts +0 -36
- package/bin/main.js +0 -86
- /package/bin/{core-impl → components}/date/date.js +0 -0
- /package/bin/{core-impl → components}/figures/figures-mod.d.ts +0 -0
- /package/bin/{core-impl → components}/figures/figures-mod.js +0 -0
- /package/bin/{core-impl → components}/msg-fmt/colors.js +0 -0
- /package/bin/{core-impl → components}/msg-fmt/mapping.js +0 -0
- /package/bin/{core-impl → components}/msg-fmt/messages.js +0 -0
- /package/bin/{core-impl → components}/msg-fmt/terminal.d.ts +0 -0
- /package/bin/{core-impl → components}/msg-fmt/terminal.js +0 -0
- /package/bin/{core-impl → components}/msg-fmt/variants.js +0 -0
- /package/bin/{core-impl → components}/next-steps/next-steps.js +0 -0
- /package/bin/{core-impl → components}/number/number-mod.js +0 -0
- /package/bin/{core-impl → components}/results/results.d.ts +0 -0
- /package/bin/{core-impl → components}/results/results.js +0 -0
- /package/bin/{core-impl → components}/select/nummultiselect-prompt.js +0 -0
- /package/bin/{core-impl → components}/st-end/end.js +0 -0
- /package/bin/{core-impl → components}/task/progress.js +0 -0
- /package/bin/{core-impl → components}/task/spinner.d.ts +0 -0
- /package/bin/{core-impl → components}/task/spinner.js +0 -0
- /package/bin/{core-impl → components}/visual/animate/animate.js +0 -0
- /package/bin/{core-impl → components}/visual/ascii-art/ascii-art.d.ts +0 -0
- /package/bin/{core-impl → components}/visual/ascii-art/ascii-art.js +0 -0
- /package/bin/{core-types.d.ts → types.d.ts} +0 -0
- /package/bin/{core-types.js → types.js} +0 -0
- /package/bin/{core-impl/utils → utils}/colorize.js +0 -0
- /package/bin/{core-impl/utils → utils}/errors.d.ts +0 -0
- /package/bin/{core-impl/utils → utils}/errors.js +0 -0
- /package/bin/{core-impl/utils → utils}/system.d.ts +0 -0
- /package/bin/{core-impl/utils → utils}/system.js +0 -0
- /package/bin/{core-impl/utils → utils}/validate.d.ts +0 -0
- /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 "
|
|
11
|
-
import { streamText } from "
|
|
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) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { kebabCase, camelCase } from "scule";
|
|
2
2
|
|
|
3
|
-
import type { Arg, ArgsDef, ParsedArgs } from "~/
|
|
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";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { relinka } from "@reliverse/relinka";
|
|
2
2
|
|
|
3
|
-
import type { ArgsDef, CommandDef } from "~/
|
|
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 "~/
|
|
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 {};
|