@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
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
interface SpinnerOptions {
|
|
2
|
+
cancelMessage?: string;
|
|
3
|
+
color?: string;
|
|
4
|
+
delay?: number;
|
|
5
|
+
errorMessage?: string;
|
|
6
|
+
failText?: string;
|
|
7
|
+
frames?: string[];
|
|
8
|
+
hideCursor?: boolean;
|
|
9
|
+
indicator?: "dots" | "timer";
|
|
10
|
+
onCancel?: () => void;
|
|
11
|
+
prefixText?: string;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
silent?: boolean;
|
|
14
|
+
spinner?: string;
|
|
15
|
+
successText?: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
interface ProgressOptions {
|
|
19
|
+
current: number;
|
|
20
|
+
total: number;
|
|
21
|
+
format?: "percentage" | "count" | "both";
|
|
22
|
+
}
|
|
23
|
+
interface SpinnerControls {
|
|
24
|
+
start: (text?: string) => SpinnerControls;
|
|
25
|
+
stop: (text?: string, code?: number) => void;
|
|
26
|
+
setText: (text: string) => void;
|
|
27
|
+
setProgress: (progress: ProgressOptions) => void;
|
|
28
|
+
succeed: (text?: string) => void;
|
|
29
|
+
fail: (text?: string) => void;
|
|
30
|
+
warn: (text?: string) => void;
|
|
31
|
+
info: (text?: string) => void;
|
|
32
|
+
isSpinning: () => boolean;
|
|
33
|
+
clear: () => void;
|
|
34
|
+
getElapsedTime: () => number;
|
|
35
|
+
pause: () => void;
|
|
36
|
+
resume: () => void;
|
|
37
|
+
dispose: () => void;
|
|
38
|
+
isCancelled: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a terminal spinner with enhanced controls and styling options.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Basic usage
|
|
46
|
+
* const spinner = useSpinner({ text: "Loading..." }).start();
|
|
47
|
+
* spinner.stop();
|
|
48
|
+
*
|
|
49
|
+
* // With progress tracking
|
|
50
|
+
* const spinner = useSpinner({ text: "Processing files..." }).start();
|
|
51
|
+
* for (let i = 0; i < files.length; i++) {
|
|
52
|
+
* spinner.setProgress({ current: i + 1, total: files.length });
|
|
53
|
+
* await processFile(files[i]);
|
|
54
|
+
* }
|
|
55
|
+
* spinner.succeed();
|
|
56
|
+
*
|
|
57
|
+
* // With custom color and spinner
|
|
58
|
+
* const spinner = useSpinner({
|
|
59
|
+
* text: "Processing...",
|
|
60
|
+
* color: "cyan",
|
|
61
|
+
* spinner: "dots"
|
|
62
|
+
* }).start();
|
|
63
|
+
*
|
|
64
|
+
* // With success/failure states
|
|
65
|
+
* const spinner = useSpinner({
|
|
66
|
+
* text: "Uploading...",
|
|
67
|
+
* successText: "Upload complete!",
|
|
68
|
+
* failText: "Upload failed!"
|
|
69
|
+
* }).start();
|
|
70
|
+
* try {
|
|
71
|
+
* await uploadFile();
|
|
72
|
+
* spinner.succeed();
|
|
73
|
+
* } catch (error) {
|
|
74
|
+
* spinner.fail();
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* // Using the wrapper for async operations
|
|
78
|
+
* await useSpinner.promise(
|
|
79
|
+
* async (spinner) => {
|
|
80
|
+
* await longOperation();
|
|
81
|
+
* spinner.setProgress({ current: 50, total: 100 });
|
|
82
|
+
* },
|
|
83
|
+
* {
|
|
84
|
+
* text: "Working...",
|
|
85
|
+
* successText: "Done!",
|
|
86
|
+
* failText: "Failed!"
|
|
87
|
+
* }
|
|
88
|
+
* );
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function useSpinner(options: SpinnerOptions): SpinnerControls;
|
|
92
|
+
export declare namespace useSpinner {
|
|
93
|
+
var promise: <T>(operation: (spinner: SpinnerControls) => Promise<T>, options: SpinnerOptions) => Promise<T>;
|
|
94
|
+
var nested: (parentOptions: SpinnerOptions) => {
|
|
95
|
+
start: () => {
|
|
96
|
+
child: (childOptions: SpinnerOptions) => SpinnerControls;
|
|
97
|
+
finish: (success: boolean, text?: string) => void;
|
|
98
|
+
dispose: () => void;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
var withTiming: <T>(operation: (spinner: SpinnerControls) => Promise<T>, options: SpinnerOptions) => Promise<{
|
|
102
|
+
result: T;
|
|
103
|
+
duration: number;
|
|
104
|
+
}>;
|
|
105
|
+
}
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { re } from "@reliverse/relico";
|
|
2
|
+
import { block } from "../cancel/cancel.js";
|
|
3
|
+
const unicode = process.platform !== "win32" || process.env.TERM_PROGRAM === "vscode";
|
|
4
|
+
const defaultFrames = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"];
|
|
5
|
+
const defaultDelay = unicode ? 80 : 120;
|
|
6
|
+
function isInteractive() {
|
|
7
|
+
return process.stdout.isTTY && !process.env.CI && !process.env.GITHUB_ACTIONS && !process.env.GITLAB_CI && !process.env.BUILDKITE && process.env.TERM !== "dumb";
|
|
8
|
+
}
|
|
9
|
+
function formatProgress(options) {
|
|
10
|
+
const { current, total, format = "both" } = options;
|
|
11
|
+
const percentage = Math.round(current / total * 100);
|
|
12
|
+
switch (format) {
|
|
13
|
+
case "percentage":
|
|
14
|
+
return `${percentage}%`;
|
|
15
|
+
case "count":
|
|
16
|
+
return `${current}/${total}`;
|
|
17
|
+
case "both":
|
|
18
|
+
return `${current}/${total} (${percentage}%)`;
|
|
19
|
+
default:
|
|
20
|
+
return `${current}/${total}`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function formatTimer(origin) {
|
|
24
|
+
const duration = (performance.now() - origin) / 1e3;
|
|
25
|
+
const min = Math.floor(duration / 60);
|
|
26
|
+
const secs = Math.floor(duration % 60);
|
|
27
|
+
return min > 0 ? `[${min}m ${secs}s]` : `[${secs}s]`;
|
|
28
|
+
}
|
|
29
|
+
function removeTrailingDots(msg) {
|
|
30
|
+
return msg.replace(/\.+$/, "");
|
|
31
|
+
}
|
|
32
|
+
export function useSpinner(options) {
|
|
33
|
+
let loop;
|
|
34
|
+
const interactive = isInteractive();
|
|
35
|
+
let unblock = null;
|
|
36
|
+
const state = {
|
|
37
|
+
isActive: false,
|
|
38
|
+
isPaused: false,
|
|
39
|
+
startTime: null,
|
|
40
|
+
pausedTime: 0,
|
|
41
|
+
text: options.text,
|
|
42
|
+
isCancelled: false,
|
|
43
|
+
origin: performance.now(),
|
|
44
|
+
indicatorTimer: 0
|
|
45
|
+
};
|
|
46
|
+
const handleExit = (code) => {
|
|
47
|
+
const msg = code > 1 ? options.errorMessage ?? "Operation failed" : options.cancelMessage ?? "Operation cancelled";
|
|
48
|
+
state.isCancelled = code === 1;
|
|
49
|
+
if (state.isActive) {
|
|
50
|
+
controls.stop(msg, code);
|
|
51
|
+
if (state.isCancelled && typeof options.onCancel === "function") {
|
|
52
|
+
options.onCancel();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const errorEventHandler = () => handleExit(2);
|
|
57
|
+
const signalEventHandler = () => handleExit(1);
|
|
58
|
+
const registerHooks = () => {
|
|
59
|
+
process.on("uncaughtExceptionMonitor", errorEventHandler);
|
|
60
|
+
process.on("unhandledRejection", errorEventHandler);
|
|
61
|
+
process.on("SIGINT", signalEventHandler);
|
|
62
|
+
process.on("SIGTERM", signalEventHandler);
|
|
63
|
+
process.on("exit", handleExit);
|
|
64
|
+
if (options.signal) {
|
|
65
|
+
options.signal.addEventListener("abort", signalEventHandler);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const clearHooks = () => {
|
|
69
|
+
process.removeListener("uncaughtExceptionMonitor", errorEventHandler);
|
|
70
|
+
process.removeListener("unhandledRejection", errorEventHandler);
|
|
71
|
+
process.removeListener("SIGINT", signalEventHandler);
|
|
72
|
+
process.removeListener("SIGTERM", signalEventHandler);
|
|
73
|
+
process.removeListener("exit", handleExit);
|
|
74
|
+
if (options.signal) {
|
|
75
|
+
options.signal.removeEventListener("abort", signalEventHandler);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const clearPrevMessage = () => {
|
|
79
|
+
if (state.prevMessage === void 0) return;
|
|
80
|
+
if (process.env.CI) process.stdout.write("\n");
|
|
81
|
+
const prevLines = state.prevMessage.split("\n");
|
|
82
|
+
process.stdout.write(`\x1B[${prevLines.length}A`);
|
|
83
|
+
process.stdout.write("\x1B[0J");
|
|
84
|
+
};
|
|
85
|
+
const controls = {
|
|
86
|
+
start: (text) => {
|
|
87
|
+
if (text) {
|
|
88
|
+
options.text = text;
|
|
89
|
+
state.text = text;
|
|
90
|
+
}
|
|
91
|
+
if (options.silent || !interactive) {
|
|
92
|
+
console.log(
|
|
93
|
+
options.prefixText ? `${options.prefixText} ${options.text}` : options.text
|
|
94
|
+
);
|
|
95
|
+
state.isActive = true;
|
|
96
|
+
state.startTime = Date.now();
|
|
97
|
+
return controls;
|
|
98
|
+
}
|
|
99
|
+
state.isActive = true;
|
|
100
|
+
state.origin = performance.now();
|
|
101
|
+
unblock = block({ output: process.stdout });
|
|
102
|
+
process.stdout.write(`${re.dim("\u2502")}
|
|
103
|
+
`);
|
|
104
|
+
let frameIndex = 0;
|
|
105
|
+
registerHooks();
|
|
106
|
+
loop = setInterval(() => {
|
|
107
|
+
if (process.env.CI && state.text === state.prevMessage) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
clearPrevMessage();
|
|
111
|
+
state.prevMessage = state.text;
|
|
112
|
+
const frame = re.magenta(
|
|
113
|
+
(options.frames ?? defaultFrames)[frameIndex] ?? ""
|
|
114
|
+
);
|
|
115
|
+
if (process.env.CI) {
|
|
116
|
+
process.stdout.write(`${frame} ${state.text}...`);
|
|
117
|
+
} else if (options.indicator === "timer") {
|
|
118
|
+
process.stdout.write(
|
|
119
|
+
`${frame} ${state.text} ${formatTimer(state.origin)}`
|
|
120
|
+
);
|
|
121
|
+
} else {
|
|
122
|
+
const loadingDots = ".".repeat(Math.floor(state.indicatorTimer)).slice(0, 3);
|
|
123
|
+
process.stdout.write(`${frame} ${state.text}${loadingDots}`);
|
|
124
|
+
}
|
|
125
|
+
frameIndex = (frameIndex + 1) % (options.frames ?? defaultFrames).length;
|
|
126
|
+
state.indicatorTimer = state.indicatorTimer < 4 ? state.indicatorTimer + 0.125 : 0;
|
|
127
|
+
}, options.delay ?? defaultDelay);
|
|
128
|
+
return controls;
|
|
129
|
+
},
|
|
130
|
+
stop: (text, code = 0) => {
|
|
131
|
+
if (!state.isActive) return;
|
|
132
|
+
state.isActive = false;
|
|
133
|
+
clearInterval(loop);
|
|
134
|
+
clearPrevMessage();
|
|
135
|
+
const step = code === 0 ? re.green("\u2713") : code === 1 ? re.red("\u2717") : re.red("\u2717");
|
|
136
|
+
const finalText = text ?? state.text;
|
|
137
|
+
if (options.indicator === "timer") {
|
|
138
|
+
process.stdout.write(
|
|
139
|
+
`${step} ${finalText} ${formatTimer(state.origin)}
|
|
140
|
+
`
|
|
141
|
+
);
|
|
142
|
+
} else {
|
|
143
|
+
process.stdout.write(`${step} ${finalText}
|
|
144
|
+
`);
|
|
145
|
+
}
|
|
146
|
+
clearHooks();
|
|
147
|
+
if (unblock) unblock();
|
|
148
|
+
},
|
|
149
|
+
setText: (text) => {
|
|
150
|
+
state.text = removeTrailingDots(text);
|
|
151
|
+
options.text = text;
|
|
152
|
+
},
|
|
153
|
+
setProgress: (progress) => {
|
|
154
|
+
const progressText = formatProgress(progress);
|
|
155
|
+
const newText = `${state.text} [${progressText}]`;
|
|
156
|
+
state.text = newText;
|
|
157
|
+
options.text = newText;
|
|
158
|
+
},
|
|
159
|
+
succeed: (text) => {
|
|
160
|
+
const successText = text ?? options.successText ?? state.text;
|
|
161
|
+
controls.stop(successText, 0);
|
|
162
|
+
},
|
|
163
|
+
fail: (text) => {
|
|
164
|
+
const failText = text ?? options.failText ?? state.text;
|
|
165
|
+
controls.stop(failText, 2);
|
|
166
|
+
},
|
|
167
|
+
warn: (text) => {
|
|
168
|
+
const warnText = text ?? state.text;
|
|
169
|
+
controls.stop(warnText, 0);
|
|
170
|
+
},
|
|
171
|
+
info: (text) => {
|
|
172
|
+
const infoText = text ?? state.text;
|
|
173
|
+
controls.stop(infoText, 0);
|
|
174
|
+
},
|
|
175
|
+
isSpinning: () => {
|
|
176
|
+
return state.isActive && !state.isPaused;
|
|
177
|
+
},
|
|
178
|
+
clear: () => {
|
|
179
|
+
clearPrevMessage();
|
|
180
|
+
},
|
|
181
|
+
getElapsedTime: () => {
|
|
182
|
+
if (!state.startTime) return 0;
|
|
183
|
+
const currentTime = Date.now();
|
|
184
|
+
return currentTime - state.startTime - state.pausedTime;
|
|
185
|
+
},
|
|
186
|
+
pause: () => {
|
|
187
|
+
if (state.isActive && !state.isPaused) {
|
|
188
|
+
clearInterval(loop);
|
|
189
|
+
state.isPaused = true;
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
resume: () => {
|
|
193
|
+
if (state.isActive && state.isPaused) {
|
|
194
|
+
loop = setInterval(() => {
|
|
195
|
+
}, options.delay ?? defaultDelay);
|
|
196
|
+
state.isPaused = false;
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
dispose: () => {
|
|
200
|
+
if (state.isActive) {
|
|
201
|
+
controls.stop();
|
|
202
|
+
}
|
|
203
|
+
state.isActive = false;
|
|
204
|
+
state.isPaused = false;
|
|
205
|
+
},
|
|
206
|
+
get isCancelled() {
|
|
207
|
+
return state.isCancelled;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
return controls;
|
|
211
|
+
}
|
|
212
|
+
useSpinner.promise = async (operation, options) => {
|
|
213
|
+
const spinner = useSpinner(options).start();
|
|
214
|
+
try {
|
|
215
|
+
const result = await operation(spinner);
|
|
216
|
+
spinner.succeed();
|
|
217
|
+
return result;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
spinner.fail();
|
|
220
|
+
throw error;
|
|
221
|
+
} finally {
|
|
222
|
+
spinner.dispose();
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
useSpinner.nested = (parentOptions) => {
|
|
226
|
+
const parentSpinner = useSpinner({
|
|
227
|
+
...parentOptions,
|
|
228
|
+
silent: true
|
|
229
|
+
// Parent is silent, children will show progress
|
|
230
|
+
});
|
|
231
|
+
return {
|
|
232
|
+
start: () => {
|
|
233
|
+
parentSpinner.start();
|
|
234
|
+
return {
|
|
235
|
+
child: (childOptions) => useSpinner(childOptions),
|
|
236
|
+
finish: (success, text) => {
|
|
237
|
+
if (success) {
|
|
238
|
+
parentSpinner.succeed(text);
|
|
239
|
+
} else {
|
|
240
|
+
parentSpinner.fail(text);
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
dispose: () => parentSpinner.dispose()
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
useSpinner.withTiming = async (operation, options) => {
|
|
249
|
+
const spinner = useSpinner(options).start();
|
|
250
|
+
const startTime = Date.now();
|
|
251
|
+
try {
|
|
252
|
+
const result = await operation(spinner);
|
|
253
|
+
const duration = Date.now() - startTime;
|
|
254
|
+
spinner.succeed(`${options.successText || options.text} (${duration}ms)`);
|
|
255
|
+
return { result, duration };
|
|
256
|
+
} catch (error) {
|
|
257
|
+
const duration = Date.now() - startTime;
|
|
258
|
+
spinner.fail(
|
|
259
|
+
`${options.failText || options.text} (failed after ${duration}ms)`
|
|
260
|
+
);
|
|
261
|
+
throw error;
|
|
262
|
+
} finally {
|
|
263
|
+
spinner.dispose();
|
|
264
|
+
}
|
|
265
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ProgressBar, ProgressBarOptions } from "../../types.js";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function taskProgressPrompt(options: ProgressBarOptions): Promise<ProgressBar>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { re } from "@reliverse/relico";
|
|
2
2
|
import { cursor, erase } from "sisteransi";
|
|
3
|
-
export async function
|
|
3
|
+
export async function taskProgressPrompt(options) {
|
|
4
4
|
if (options.total <= 0) {
|
|
5
5
|
throw new Error("Total must be a positive number");
|
|
6
6
|
}
|
|
@@ -2,7 +2,7 @@ import type { SpinnerName } from "cli-spinners";
|
|
|
2
2
|
type SimpleSpinnerType = "default" | "dottedCircle" | "boxSpinner";
|
|
3
3
|
type OraSpinnerType = Extract<SpinnerName, OraAllowedSpinners>;
|
|
4
4
|
type OraAllowedSpinners = "dots" | "bouncingBar" | "arc";
|
|
5
|
-
|
|
5
|
+
interface TaskOptions<T extends "simple" | "ora"> {
|
|
6
6
|
initialMessage: string;
|
|
7
7
|
successMessage?: string;
|
|
8
8
|
errorMessage?: string;
|
|
@@ -10,6 +10,6 @@ type TaskOptions<T extends "simple" | "ora"> = {
|
|
|
10
10
|
spinnerSolution: T;
|
|
11
11
|
spinnerType?: T extends "simple" ? SimpleSpinnerType : OraSpinnerType;
|
|
12
12
|
action: (updateMessage: (message: string) => void) => Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
export declare function
|
|
13
|
+
}
|
|
14
|
+
export declare function taskSpinPrompt<T extends "simple" | "ora">(options: TaskOptions<T>): Promise<void>;
|
|
15
15
|
export {};
|
|
@@ -3,7 +3,7 @@ import process from "node:process";
|
|
|
3
3
|
import ora from "ora";
|
|
4
4
|
import { cursor, erase } from "sisteransi";
|
|
5
5
|
import { msg } from "../msg-fmt/messages.js";
|
|
6
|
-
export async function
|
|
6
|
+
export async function taskSpinPrompt(options) {
|
|
7
7
|
const {
|
|
8
8
|
initialMessage,
|
|
9
9
|
successMessage = "Task completed successfully.",
|
|
@@ -65,7 +65,7 @@ export async function spinnerTaskPrompt(options) {
|
|
|
65
65
|
process.stdin.on("data", handleInput);
|
|
66
66
|
}
|
|
67
67
|
interval = setInterval(() => {
|
|
68
|
-
const frame = re.magenta(frames[frameIndex]);
|
|
68
|
+
const frame = re.magenta(frames[frameIndex] ?? "");
|
|
69
69
|
process.stdout.write(
|
|
70
70
|
`${cursor.move(-999, 0)}${erase.line}${frame} ${re.cyan(message)}`
|
|
71
71
|
);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ColorName, TypographyName } from "
|
|
1
|
+
import type { ColorName, TypographyName } from "../../types.js";
|
|
2
2
|
export declare function colorize(text: string, colorName?: ColorName, typography?: TypographyName): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PreventWrongTerminalSizeOptions } from "
|
|
1
|
+
import type { PreventWrongTerminalSizeOptions } from "../../types.js";
|
|
2
2
|
export declare function preventUnsupportedTTY(): void;
|
|
3
3
|
/**
|
|
4
4
|
* Prevents EISDIR errors when trying to read Windows home directory as a file
|
|
@@ -2,11 +2,11 @@ import { re } from "@reliverse/relico";
|
|
|
2
2
|
import { relinka } from "@reliverse/relinka";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import terminalSize from "terminal-size";
|
|
5
|
-
import { msg } from "../
|
|
5
|
+
import { msg } from "../msg-fmt/messages.js";
|
|
6
6
|
import {
|
|
7
7
|
getExactTerminalWidth,
|
|
8
8
|
getTerminalWidth
|
|
9
|
-
} from "../
|
|
9
|
+
} from "../msg-fmt/terminal.js";
|
|
10
10
|
export function preventUnsupportedTTY() {
|
|
11
11
|
if (!process.stdout.isTTY) {
|
|
12
12
|
relinka(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BorderColorName, ColorName, TypographyName, VariantName } from "
|
|
1
|
+
import type { BorderColorName, ColorName, TypographyName, VariantName } from "../../types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Ends the prompt by optionally displaying an end message and running the action if confirmed.
|
|
4
4
|
* Preserves the last prompt state unless there's an endTitle.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { re } from "@reliverse/relico";
|
|
2
2
|
import { relinka } from "@reliverse/relinka";
|
|
3
|
-
import { msg, symbols } from "../
|
|
4
|
-
import { getExactTerminalWidth } from "../
|
|
3
|
+
import { msg, symbols } from "../msg-fmt/messages.js";
|
|
4
|
+
import { getExactTerminalWidth } from "../msg-fmt/terminal.js";
|
|
5
5
|
export async function completePrompt(prompt, isCtrlC, _endTitle = "", _endTitleColor = "dim", _titleTypography = "none", _titleVariant = void 0, _border = true, borderColor = "dim", action, value) {
|
|
6
6
|
if (action && value) {
|
|
7
7
|
await action();
|
|
@@ -4,8 +4,8 @@ import ora from "ora";
|
|
|
4
4
|
import { cursor } from "sisteransi";
|
|
5
5
|
import terminalSize from "terminal-size";
|
|
6
6
|
import wrapAnsi from "wrap-ansi";
|
|
7
|
-
import { toBaseColor } from "../
|
|
8
|
-
import { msg } from "../
|
|
7
|
+
import { toBaseColor } from "../msg-fmt/colors.js";
|
|
8
|
+
import { msg } from "../msg-fmt/messages.js";
|
|
9
9
|
function getTerminalWidth() {
|
|
10
10
|
return terminalSize().columns;
|
|
11
11
|
}
|
|
@@ -7,10 +7,10 @@ export declare function isTerminalInteractive(input?: NodeJS.ReadStream & {
|
|
|
7
7
|
/**
|
|
8
8
|
* Validates a name against allowed characters
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
interface ValidationResult {
|
|
11
11
|
isValid: boolean;
|
|
12
12
|
message?: string;
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
14
|
export declare function isValidName(name: string): ValidationResult;
|
|
15
15
|
/**
|
|
16
16
|
* Cleans up project name from config by removing scope and invalid characters.
|
package/bin/mod.d.ts
CHANGED
|
@@ -1,38 +1,66 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export {
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
1
|
+
export { animationMap, animateText } from "./libs/animate/animate-mod.js";
|
|
2
|
+
export { anykeyPrompt } from "./libs/anykey/anykey-mod.js";
|
|
3
|
+
export { createAsciiArt } from "./libs/visual/visual-mod.js";
|
|
4
|
+
export type { CancelValue } from "./libs/cancel/cancel.js";
|
|
5
|
+
export { CANCEL, isWindows, setRawMode, getColumns, block, isCancel, cancel, createCancel, } from "./libs/cancel/cancel.js";
|
|
6
|
+
export { confirm } from "./libs/confirm/confirm-alias.js";
|
|
7
|
+
export { confirmPrompt } from "./libs/confirm/confirm-mod.js";
|
|
8
|
+
export { datePrompt } from "./libs/date/date.js";
|
|
9
|
+
export { startEditor } from "./libs/editor/editor-mod.js";
|
|
10
|
+
export { mainSymbols, fallbackSymbols, figures, } from "./libs/figures/figures-mod.js";
|
|
11
|
+
export { input, text, password } from "./libs/input/input-alias.js";
|
|
12
|
+
export { inputPrompt } from "./libs/input/input-mod.js";
|
|
13
|
+
export { startPrompt, intro } from "./libs/intro/intro-alias.js";
|
|
14
|
+
export { introPrompt } from "./libs/intro/intro-mod.js";
|
|
15
|
+
export { runMain } from "./libs/launcher/launcher-alias.js";
|
|
16
|
+
export { defineCommand, showUsage, createCli, defineArgs, runCmd, } from "./libs/launcher/launcher-mod.js";
|
|
17
|
+
export type { EmptyArgs, BaseArgProps, BaseArgDefinition, PositionalArgDefinition, BooleanArgDefinition, StringArgDefinition, NumberArgDefinition, ArrayArgDefinition, ArgDefinition, ArgDefinitions, CommandMeta, CommandSpec, CommandsMap, CommandContext, CommandRun, CommandHook, DefineCommandOptions, Command, InferArgTypes, FileBasedOptions, } from "./libs/launcher/launcher-types.js";
|
|
18
|
+
export { loadCommand } from "./libs/launcher/run-command.js";
|
|
19
|
+
export { addCompletions } from "./libs/launcher/trpc-orpc-support/completions.js";
|
|
20
|
+
export { CliValidationError, FailedToExitError, } from "./libs/launcher/trpc-orpc-support/errors.js";
|
|
21
|
+
export { TrpcCommand, parseRouter, createRpcCli, z, } from "./libs/launcher/trpc-orpc-support/index.js";
|
|
22
|
+
export { flattenedProperties, incompatiblePropertyPairs, getDescription, getSchemaTypes, getEnumChoices, } from "./libs/launcher/trpc-orpc-support/json-schema.js";
|
|
23
|
+
export type { CommandJSON } from "./libs/launcher/trpc-orpc-support/json.js";
|
|
24
|
+
export { commandToJSON } from "./libs/launcher/trpc-orpc-support/json.js";
|
|
25
|
+
export { lineByLineLogger, lineByLineConsoleLogger, } from "./libs/launcher/trpc-orpc-support/logging.js";
|
|
26
|
+
export { parseProcedureInputs } from "./libs/launcher/trpc-orpc-support/parse-procedure.js";
|
|
27
|
+
export { createShadowCommand, promptify, } from "./libs/launcher/trpc-orpc-support/prompts.js";
|
|
28
|
+
export type { StandardSchemaV1, StandardSchemaV1Props, StandardSchemaV1Result, StandardSchemaV1SuccessResult, StandardSchemaV1FailureResult, StandardSchemaV1Issue, StandardSchemaV1PathSegment, StandardSchemaV1Types, StandardSchemaV1InferInput, StandardSchemaV1InferOutput, } from "./libs/launcher/trpc-orpc-support/standard-schema/contract.js";
|
|
29
|
+
export { prettifyStandardSchemaError, toDotPath, StandardSchemaV1Error, } from "./libs/launcher/trpc-orpc-support/standard-schema/errors.js";
|
|
30
|
+
export { looksLikeStandardSchemaFailure, looksLikeStandardSchema, } from "./libs/launcher/trpc-orpc-support/standard-schema/utils.js";
|
|
31
|
+
export type { Trpc11RouterLike, Trpc11ProcedureRecordLike, Trpc11ProcedureLike, Trpc10RouterLike, Trpc10ProcedureLike, OrpcProcedureLike, OrpcRouterLike, CreateCallerFactoryLike, AnyRouter, AnyProcedure, inferRouterContext, } from "./libs/launcher/trpc-orpc-support/trpc-compat.js";
|
|
32
|
+
export { isTrpc11Procedure, isTrpc11Router, isOrpcRouter, } from "./libs/launcher/trpc-orpc-support/trpc-compat.js";
|
|
33
|
+
export type { TrpcCliParams, TrpcServerModuleLike, TrpcCliMeta, ParsedProcedure, Result, Log, Logger, OmeletteInstanceLike, InquirerPromptOptions, InquirerPromptsLike, PromptsLike, EnquirerLike, ClackPromptsLike, Promptable, TrpcCliRunParams, CommanderProgramLike, TrpcCli, Dependencies, PromptContext, Prompter, } from "./libs/launcher/trpc-orpc-support/types.js";
|
|
34
|
+
export { looksLikeInstanceof } from "./libs/launcher/trpc-orpc-support/util.js";
|
|
35
|
+
export { log } from "./libs/log/log-alias.js";
|
|
36
|
+
export { toBaseColor, toSolidColor } from "./libs/msg-fmt/colors.js";
|
|
37
|
+
export { relinkaByRemptsDeprecated, relinkaAsyncByRemptsDeprecated, throwError, } from "./libs/msg-fmt/logger.js";
|
|
38
|
+
export { colorMap, typographyMap } from "./libs/msg-fmt/mapping.js";
|
|
39
|
+
export { symbols, bar, fmt, msg, msgUndo, msgUndoAll, printLineBar, } from "./libs/msg-fmt/messages.js";
|
|
40
|
+
export { getTerminalHeight, getExactTerminalWidth, getTerminalWidth, breakLines, removeCursor, restoreCursor, deleteLastLine, deleteLastLines, countLines, } from "./libs/msg-fmt/terminal.js";
|
|
41
|
+
export { variantMap, isValidVariant, applyVariant, } from "./libs/msg-fmt/variants.js";
|
|
42
|
+
export { multiselect } from "./libs/multiselect/multiselect-alias.js";
|
|
43
|
+
export { multiselectPrompt } from "./libs/multiselect/multiselect-prompt.js";
|
|
44
|
+
export { nextStepsPrompt } from "./libs/next-steps/next-steps.js";
|
|
45
|
+
export { numberPrompt } from "./libs/number/number-mod.js";
|
|
46
|
+
export { endPrompt, outro } from "./libs/outro/outro-alias.js";
|
|
47
|
+
export { outroPrompt } from "./libs/outro/outro-mod.js";
|
|
48
|
+
export type { ResultsType } from "./libs/results/results.js";
|
|
49
|
+
export { resultPrompt } from "./libs/results/results.js";
|
|
50
|
+
export { select } from "./libs/select/aliases-alias.js";
|
|
51
|
+
export { numMultiSelectPrompt } from "./libs/select/nummultiselect-prompt.js";
|
|
52
|
+
export { numSelectPrompt } from "./libs/select/numselect-prompt.js";
|
|
53
|
+
export { selectPrompt } from "./libs/select/select-prompt.js";
|
|
54
|
+
export { togglePrompt } from "./libs/select/toggle-prompt.js";
|
|
55
|
+
export { spinner } from "./libs/spinner/spinner-alias.js";
|
|
56
|
+
export { useSpinner } from "./libs/spinner/spinner-mod.js";
|
|
57
|
+
export { taskProgressPrompt } from "./libs/task/progress.js";
|
|
58
|
+
export { taskSpinPrompt } from "./libs/task/task-spin.js";
|
|
59
|
+
export { colorize } from "./libs/utils/colorize.js";
|
|
60
|
+
export { errorHandler } from "./libs/utils/errors.js";
|
|
61
|
+
export { preventUnsupportedTTY, preventWindowsHomeDirRoot, preventWrongTerminalSize, } from "./libs/utils/prevent.js";
|
|
62
|
+
export { completePrompt, renderEndLine, renderEndLineInput, } from "./libs/utils/prompt-end.js";
|
|
63
|
+
export { streamText, streamTextBox, streamTextWithSpinner, } from "./libs/utils/stream-text.js";
|
|
64
|
+
export { pm, reliversePrompts } from "./libs/utils/system.js";
|
|
65
|
+
export { isTerminalInteractive, isValidName, normalizeName, } from "./libs/utils/validate.js";
|
|
66
|
+
export type { MsgType, TypographyName, BorderColorName, ColorName, VariantName, MsgConfig, PromptOptions, ChoiceOptions, SelectOption, StandardColor, OutputColor, EditorExitResult, MessageKind, AllKinds, MessageConfig, StreamOptions, ProgressBarOptions, ProgressBar, PromptType, ConfirmPromptOptions, StreamTextOptions, PreventWrongTerminalSizeOptions, InputPromptOptions, RenderParams, SymbolName, Symbols, FmtMsgOptions, TogglePromptParams, SeparatorOption, MultiselectPromptParams, DatePromptOptions, } from "./types.js";
|