@reliverse/rempts 1.7.28 → 1.7.30
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/README.md +176 -37
- package/bin/{components/visual/animate/animate.d.ts → libs/animate/animate-mod.d.ts} +1 -1
- package/bin/{components/visual/animate/animate.js → libs/animate/animate-mod.js} +2 -5
- package/bin/{components → libs}/anykey/anykey-mod.d.ts +2 -2
- package/bin/{components → libs}/anykey/anykey-mod.js +3 -3
- package/bin/libs/cancel/cancel.d.ts +45 -0
- package/bin/libs/cancel/cancel.js +72 -0
- package/bin/libs/confirm/confirm-alias.d.ts +1 -0
- package/bin/libs/confirm/confirm-alias.js +2 -0
- package/bin/{components/input/confirm-prompt.js → libs/confirm/confirm-mod.js} +1 -1
- package/bin/{components → libs}/editor/editor-mod.d.ts +4 -4
- package/bin/{components → libs}/editor/editor-mod.js +8 -8
- package/bin/{components → libs}/figures/figures-mod.d.ts +2 -3
- package/bin/{components → libs}/figures/figures-mod.js +1 -2
- package/bin/libs/input/input-alias.d.ts +4 -0
- package/bin/libs/input/input-alias.js +4 -0
- package/bin/{components/input/input-prompt.js → libs/input/input-mod.js} +2 -2
- package/bin/libs/intro/intro-alias.d.ts +2 -0
- package/bin/libs/intro/intro-alias.js +3 -0
- package/bin/{components/st-end/start.d.ts → libs/intro/intro-mod.d.ts} +4 -1
- package/bin/{components/st-end/start.js → libs/intro/intro-mod.js} +35 -21
- package/bin/libs/launcher/launcher-alias.d.ts +2 -0
- package/bin/libs/launcher/launcher-alias.js +2 -0
- package/bin/{components → libs}/launcher/launcher-mod.d.ts +37 -5
- package/bin/{components → libs}/launcher/launcher-mod.js +326 -205
- package/bin/{components → libs}/launcher/launcher-types.d.ts +15 -18
- package/bin/libs/launcher/trpc-orpc-support/completions.d.ts +4 -0
- package/bin/libs/launcher/trpc-orpc-support/completions.js +45 -0
- package/bin/libs/launcher/trpc-orpc-support/errors.d.ts +11 -0
- package/bin/libs/launcher/trpc-orpc-support/errors.js +10 -0
- package/bin/libs/launcher/trpc-orpc-support/index.d.ts +34 -0
- package/bin/libs/launcher/trpc-orpc-support/index.js +641 -0
- package/bin/libs/launcher/trpc-orpc-support/json-schema.d.ts +17 -0
- package/bin/libs/launcher/trpc-orpc-support/json-schema.js +168 -0
- package/bin/libs/launcher/trpc-orpc-support/json.d.ts +44 -0
- package/bin/libs/launcher/trpc-orpc-support/json.js +41 -0
- package/bin/libs/launcher/trpc-orpc-support/logging.d.ts +11 -0
- package/bin/libs/launcher/trpc-orpc-support/logging.js +26 -0
- package/bin/libs/launcher/trpc-orpc-support/parse-procedure.d.ts +2 -0
- package/bin/libs/launcher/trpc-orpc-support/parse-procedure.js +486 -0
- package/bin/libs/launcher/trpc-orpc-support/prompts.d.ts +18 -0
- package/bin/libs/launcher/trpc-orpc-support/prompts.js +534 -0
- package/bin/libs/launcher/trpc-orpc-support/standard-schema/contract.d.ts +53 -0
- package/bin/libs/launcher/trpc-orpc-support/standard-schema/contract.js +0 -0
- package/bin/libs/launcher/trpc-orpc-support/standard-schema/errors.d.ts +9 -0
- package/bin/libs/launcher/trpc-orpc-support/standard-schema/errors.js +47 -0
- package/bin/libs/launcher/trpc-orpc-support/standard-schema/utils.d.ts +3 -0
- package/bin/libs/launcher/trpc-orpc-support/standard-schema/utils.js +6 -0
- package/bin/libs/launcher/trpc-orpc-support/trpc-compat.d.ts +71 -0
- package/bin/libs/launcher/trpc-orpc-support/trpc-compat.js +11 -0
- package/bin/libs/launcher/trpc-orpc-support/types.d.ts +276 -0
- package/bin/libs/launcher/trpc-orpc-support/types.js +0 -0
- package/bin/libs/launcher/trpc-orpc-support/util.d.ts +9 -0
- package/bin/libs/launcher/trpc-orpc-support/util.js +9 -0
- package/bin/libs/log/log-alias.d.ts +2 -0
- package/bin/libs/log/log-alias.js +2 -0
- package/bin/{components → libs}/msg-fmt/logger.js +1 -1
- package/bin/libs/multiselect/multiselect-alias.d.ts +1 -0
- package/bin/libs/multiselect/multiselect-alias.js +2 -0
- package/bin/{components/select → libs/multiselect}/multiselect-prompt.js +1 -1
- package/bin/{components → libs}/next-steps/next-steps.d.ts +2 -2
- package/bin/{components → libs}/number/number-mod.d.ts +2 -2
- package/bin/{components → libs}/number/number-mod.js +1 -4
- package/bin/libs/outro/outro-alias.d.ts +2 -0
- package/bin/libs/outro/outro-alias.js +3 -0
- package/bin/libs/outro/outro-mod.d.ts +8 -0
- package/bin/libs/outro/outro-mod.js +55 -0
- package/bin/{components → libs}/results/results.d.ts +2 -2
- package/bin/libs/select/aliases-alias.d.ts +1 -0
- package/bin/libs/select/aliases-alias.js +2 -0
- package/bin/{components → libs}/select/select-prompt.d.ts +6 -5
- package/bin/{components → libs}/select/select-prompt.js +6 -4
- package/bin/{components → libs}/select/toggle-prompt.js +1 -1
- package/bin/libs/spinner/spinner-alias.d.ts +1 -0
- package/bin/libs/spinner/spinner-alias.js +2 -0
- package/bin/libs/spinner/spinner-mod.d.ts +106 -0
- package/bin/libs/spinner/spinner-mod.js +265 -0
- package/bin/{components → libs}/task/progress.d.ts +1 -1
- package/bin/{components → libs}/task/progress.js +1 -1
- package/bin/{components/task/spinner.d.ts → libs/task/task-spin.d.ts} +3 -3
- package/bin/{components/task/spinner.js → libs/task/task-spin.js} +2 -2
- package/bin/{utils → libs/utils}/colorize.d.ts +1 -1
- package/bin/{utils → libs/utils}/prevent.d.ts +1 -1
- package/bin/{utils → libs/utils}/prevent.js +2 -2
- package/bin/{utils → libs/utils}/prompt-end.d.ts +1 -1
- package/bin/{utils → libs/utils}/prompt-end.js +2 -2
- package/bin/{utils → libs/utils}/stream-text.d.ts +1 -1
- package/bin/{utils → libs/utils}/stream-text.js +2 -2
- package/bin/{utils → libs/utils}/validate.d.ts +2 -2
- package/bin/mod.d.ts +66 -38
- package/bin/mod.js +102 -43
- package/bin/types.d.ts +36 -36
- package/package.json +17 -3
- package/bin/components/st-end/end.d.ts +0 -2
- package/bin/components/st-end/end.js +0 -42
- package/bin/hooks/spinner/spinner-mod.d.ts +0 -64
- package/bin/hooks/spinner/spinner-mod.js +0 -74
- /package/bin/{components/input/confirm-prompt.d.ts → libs/confirm/confirm-mod.d.ts} +0 -0
- /package/bin/{components → libs}/date/date.d.ts +0 -0
- /package/bin/{components → libs}/date/date.js +0 -0
- /package/bin/{components/input/input-prompt.d.ts → libs/input/input-mod.d.ts} +0 -0
- /package/bin/{components → libs}/launcher/launcher-types.js +0 -0
- /package/bin/{components → libs}/launcher/run-command.d.ts +0 -0
- /package/bin/{components → libs}/launcher/run-command.js +0 -0
- /package/bin/{components → libs}/msg-fmt/colors.d.ts +0 -0
- /package/bin/{components → libs}/msg-fmt/colors.js +0 -0
- /package/bin/{components → libs}/msg-fmt/logger.d.ts +0 -0
- /package/bin/{components → libs}/msg-fmt/mapping.d.ts +0 -0
- /package/bin/{components → libs}/msg-fmt/mapping.js +0 -0
- /package/bin/{components → libs}/msg-fmt/messages.d.ts +0 -0
- /package/bin/{components → libs}/msg-fmt/messages.js +0 -0
- /package/bin/{components → libs}/msg-fmt/terminal.d.ts +0 -0
- /package/bin/{components → libs}/msg-fmt/terminal.js +0 -0
- /package/bin/{components → libs}/msg-fmt/variants.d.ts +0 -0
- /package/bin/{components → libs}/msg-fmt/variants.js +0 -0
- /package/bin/{components/select → libs/multiselect}/multiselect-prompt.d.ts +0 -0
- /package/bin/{components → libs}/next-steps/next-steps.js +0 -0
- /package/bin/{components → libs}/results/results.js +0 -0
- /package/bin/{components → libs}/select/nummultiselect-prompt.d.ts +0 -0
- /package/bin/{components → libs}/select/nummultiselect-prompt.js +0 -0
- /package/bin/{components → libs}/select/numselect-prompt.d.ts +0 -0
- /package/bin/{components → libs}/select/numselect-prompt.js +0 -0
- /package/bin/{components → libs}/select/toggle-prompt.d.ts +0 -0
- /package/bin/{utils → libs/utils}/colorize.js +0 -0
- /package/bin/{utils → libs/utils}/errors.d.ts +0 -0
- /package/bin/{utils → libs/utils}/errors.js +0 -0
- /package/bin/{utils → libs/utils}/system.d.ts +0 -0
- /package/bin/{utils → libs/utils}/system.js +0 -0
- /package/bin/{utils → libs/utils}/validate.js +0 -0
- /package/bin/{components/visual/ascii-art/ascii-art.d.ts → libs/visual/visual-mod.d.ts} +0 -0
- /package/bin/{components/visual/ascii-art/ascii-art.js → libs/visual/visual-mod.js} +0 -0
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
export type EmptyArgs = Record<string, never>;
|
|
2
|
-
export
|
|
2
|
+
export interface BaseArgProps {
|
|
3
3
|
description?: string;
|
|
4
4
|
required?: boolean;
|
|
5
5
|
allowed?: string[];
|
|
6
|
-
}
|
|
7
|
-
export
|
|
6
|
+
}
|
|
7
|
+
export interface BaseArgDefinition {
|
|
8
8
|
type: string;
|
|
9
9
|
description?: string;
|
|
10
10
|
required?: boolean;
|
|
11
11
|
default?: any;
|
|
12
12
|
allowed?: any[];
|
|
13
13
|
dependencies?: string[];
|
|
14
|
-
|
|
15
|
-
};
|
|
14
|
+
}
|
|
16
15
|
export type PositionalArgDefinition = BaseArgDefinition & {
|
|
17
16
|
type: "positional";
|
|
18
17
|
default?: string;
|
|
@@ -41,13 +40,13 @@ export type ArrayArgDefinition = BaseArgDefinition & {
|
|
|
41
40
|
};
|
|
42
41
|
export type ArgDefinition = PositionalArgDefinition | BooleanArgDefinition | StringArgDefinition | NumberArgDefinition | ArrayArgDefinition;
|
|
43
42
|
export type ArgDefinitions = Record<string, ArgDefinition>;
|
|
44
|
-
export
|
|
43
|
+
export interface CommandMeta {
|
|
45
44
|
name: string;
|
|
46
45
|
version?: string;
|
|
47
46
|
description?: string;
|
|
48
47
|
hidden?: boolean;
|
|
49
48
|
aliases?: string[];
|
|
50
|
-
}
|
|
49
|
+
}
|
|
51
50
|
/**
|
|
52
51
|
* A subcommand can be either:
|
|
53
52
|
* 1) A string path to a module with a default export of type Command.
|
|
@@ -58,13 +57,13 @@ export type CommandSpec = string | (() => Promise<{
|
|
|
58
57
|
default: Command<any>;
|
|
59
58
|
} | Command<any>>);
|
|
60
59
|
export type CommandsMap = Record<string, CommandSpec>;
|
|
61
|
-
export
|
|
60
|
+
export interface CommandContext<ARGS> {
|
|
62
61
|
args: ARGS;
|
|
63
62
|
raw: string[];
|
|
64
|
-
}
|
|
63
|
+
}
|
|
65
64
|
export type CommandRun<ARGS> = (ctx: CommandContext<ARGS>) => void | Promise<void>;
|
|
66
65
|
export type CommandHook<ARGS> = (ctx: CommandContext<ARGS>) => void | Promise<void>;
|
|
67
|
-
export
|
|
66
|
+
export interface DefineCommandOptions<A extends ArgDefinitions = EmptyArgs> {
|
|
68
67
|
meta?: CommandMeta;
|
|
69
68
|
args?: A;
|
|
70
69
|
run?: CommandRun<InferArgTypes<A>>;
|
|
@@ -100,8 +99,8 @@ export type DefineCommandOptions<A extends ArgDefinitions = EmptyArgs> = {
|
|
|
100
99
|
* Called once per CLI process, after all command/run() logic is finished
|
|
101
100
|
*/
|
|
102
101
|
onLauncherExit?: () => void | Promise<void>;
|
|
103
|
-
}
|
|
104
|
-
export
|
|
102
|
+
}
|
|
103
|
+
export interface Command<A extends ArgDefinitions = EmptyArgs> {
|
|
105
104
|
meta?: CommandMeta;
|
|
106
105
|
args: A;
|
|
107
106
|
run?: CommandRun<InferArgTypes<A>>;
|
|
@@ -137,15 +136,13 @@ export type Command<A extends ArgDefinitions = EmptyArgs> = {
|
|
|
137
136
|
* Called once per CLI process, after all command/run() logic is finished
|
|
138
137
|
*/
|
|
139
138
|
onLauncherExit?: () => void | Promise<void>;
|
|
140
|
-
}
|
|
139
|
+
}
|
|
141
140
|
export type InferArgTypes<A extends ArgDefinitions> = {
|
|
142
|
-
[K in keyof A]: A[K] extends {
|
|
143
|
-
useTsType: infer T;
|
|
144
|
-
} ? T : A[K] extends PositionalArgDefinition ? string : A[K] extends BooleanArgDefinition ? boolean : A[K] extends StringArgDefinition ? string : A[K] extends NumberArgDefinition ? number : A[K] extends {
|
|
141
|
+
[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 {
|
|
145
142
|
type: "array";
|
|
146
143
|
} ? string[] : never;
|
|
147
144
|
};
|
|
148
|
-
export
|
|
145
|
+
export interface FileBasedOptions {
|
|
149
146
|
enable: boolean;
|
|
150
147
|
cmdsRootPath: string;
|
|
151
|
-
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function addCompletions(program, completion) {
|
|
2
|
+
const commandSymbol = Symbol("command");
|
|
3
|
+
const cTree = {};
|
|
4
|
+
function addCommandCompletions(command, cTreeNode) {
|
|
5
|
+
command.commands.forEach((c) => {
|
|
6
|
+
const node = cTreeNode[c.name()] ||= {};
|
|
7
|
+
Object.defineProperty(node, commandSymbol, {
|
|
8
|
+
value: c,
|
|
9
|
+
enumerable: false
|
|
10
|
+
});
|
|
11
|
+
addCommandCompletions(c, node);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
addCommandCompletions(program, cTree);
|
|
15
|
+
completion.on("complete", (fragment, params) => {
|
|
16
|
+
const segments = params.line.split(/ +/).slice(1, params.fragment);
|
|
17
|
+
const last = segments.at(-1);
|
|
18
|
+
let node = cTree;
|
|
19
|
+
const existingFlags = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const segment of segments) {
|
|
21
|
+
if (segment.startsWith("-")) {
|
|
22
|
+
existingFlags.add(segment);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (existingFlags.size > 0) continue;
|
|
26
|
+
node = node[segment];
|
|
27
|
+
if (!node) return;
|
|
28
|
+
}
|
|
29
|
+
const correspondingCommand = node[commandSymbol];
|
|
30
|
+
if (correspondingCommand?.options?.length) {
|
|
31
|
+
const suggestions = [];
|
|
32
|
+
for (const o of correspondingCommand.options) {
|
|
33
|
+
if (last === o.long || last === o.short) {
|
|
34
|
+
if (o.argChoices) suggestions.push(...o.argChoices);
|
|
35
|
+
if (!o.isBoolean()) break;
|
|
36
|
+
}
|
|
37
|
+
if (existingFlags.has(o.long)) continue;
|
|
38
|
+
if (existingFlags.has(o.short)) continue;
|
|
39
|
+
suggestions.push(o.long);
|
|
40
|
+
}
|
|
41
|
+
return params.reply(suggestions);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
completion.tree(cTree).init();
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** An error thrown when the trpc procedure results in a bad request */
|
|
2
|
+
export declare class CliValidationError extends Error {
|
|
3
|
+
}
|
|
4
|
+
/** An error which is only thrown when a custom \`process\` parameter is used. Under normal circumstances, this should not be used, even internally. */
|
|
5
|
+
export declare class FailedToExitError extends Error {
|
|
6
|
+
readonly exitCode: number;
|
|
7
|
+
constructor(message: string, { exitCode, cause }: {
|
|
8
|
+
exitCode: number;
|
|
9
|
+
cause: unknown;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class CliValidationError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export class FailedToExitError extends Error {
|
|
4
|
+
exitCode;
|
|
5
|
+
constructor(message, { exitCode, cause }) {
|
|
6
|
+
const fullMessage = `${message}. The process was expected to exit with exit code ${exitCode} but did not. This may be because a custom \`process\` parameter was used. The exit reason is in the \`cause\` property.`;
|
|
7
|
+
super(fullMessage, { cause });
|
|
8
|
+
this.exitCode = exitCode;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Command as BaseCommand } from "commander";
|
|
2
|
+
import type { AnyRouter } from "./trpc-compat";
|
|
3
|
+
import type { ParsedProcedure, TrpcCli, TrpcCliMeta, TrpcCliParams } from "./types";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export { z } from "zod/v4";
|
|
6
|
+
export * as zod from "zod";
|
|
7
|
+
export * as trpcServer from "@trpc/server";
|
|
8
|
+
export declare class TrpcCommand extends BaseCommand {
|
|
9
|
+
/** @internal track the commands that have been run, so that we can find the `__result` of the last command */
|
|
10
|
+
__ran: TrpcCommand[];
|
|
11
|
+
__input?: unknown;
|
|
12
|
+
/** @internal stash the return value of the underlying procedure on the command so to pass to `FailedToExitError` for use in a pinch */
|
|
13
|
+
__result?: unknown;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @internal takes a trpc router and returns an object that you **could** use to build a CLI, or UI, or a bunch of other things with.
|
|
17
|
+
* Officially, just internal for building a CLI. GLHF.
|
|
18
|
+
*/
|
|
19
|
+
export declare const parseRouter: <R extends AnyRouter>({ router, ...params }: TrpcCliParams<R>) => [string, ProcedureInfo][];
|
|
20
|
+
interface ProcedureInfo {
|
|
21
|
+
meta: TrpcCliMeta;
|
|
22
|
+
parsedProcedure: ParsedProcedure;
|
|
23
|
+
incompatiblePairs: [string, string][];
|
|
24
|
+
procedure: {};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Run a trpc router as a CLI.
|
|
28
|
+
*
|
|
29
|
+
* @param router A trpc router
|
|
30
|
+
* @param context The context to use when calling the procedures - needed if your router requires a context
|
|
31
|
+
* @param trpcServer The trpc server module to use. Only needed if using trpc v10.
|
|
32
|
+
* @returns A CLI object with a `run` method that can be called to run the CLI. The `run` method will parse the command line arguments, call the appropriate trpc procedure, log the result and exit the process. On error, it will log the error and exit with a non-zero exit code.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createRpcCli<R extends AnyRouter>({ router, ...params }: TrpcCliParams<R>): TrpcCli;
|