@reliverse/rempts 1.6.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/LICENSE +21 -0
- package/README.md +408 -0
- package/bin/core-impl/anykey/anykey-mod.d.ts +12 -0
- package/bin/core-impl/anykey/anykey-mod.js +125 -0
- package/bin/core-impl/date/date.d.ts +2 -0
- package/bin/core-impl/date/date.js +236 -0
- package/bin/core-impl/editor/editor-mod.d.ts +25 -0
- package/bin/core-impl/editor/editor-mod.js +897 -0
- package/bin/core-impl/figures/figures-mod.d.ts +462 -0
- package/bin/core-impl/figures/figures-mod.js +286 -0
- package/bin/core-impl/figures/figures.test.d.ts +1 -0
- package/bin/core-impl/figures/figures.test.js +474 -0
- package/bin/core-impl/input/confirm-prompt.d.ts +5 -0
- package/bin/core-impl/input/confirm-prompt.js +173 -0
- package/bin/core-impl/input/input-prompt.d.ts +16 -0
- package/bin/core-impl/input/input-prompt.js +370 -0
- package/bin/core-impl/launcher/deprecated/_parser.ts.txt +167 -0
- package/bin/core-impl/launcher/deprecated/_utils.ts.txt +41 -0
- package/bin/core-impl/launcher/deprecated/args.ts.txt +108 -0
- package/bin/core-impl/launcher/deprecated/command.ts.txt +95 -0
- package/bin/core-impl/launcher/deprecated/launcher-mod.ts.txt +50 -0
- package/bin/core-impl/launcher/deprecated/usage.ts.txt +157 -0
- package/bin/core-impl/launcher/launcher-mod.d.ts +87 -0
- package/bin/core-impl/launcher/launcher-mod.js +364 -0
- package/bin/core-impl/msg-fmt/colors.d.ts +30 -0
- package/bin/core-impl/msg-fmt/colors.js +42 -0
- package/bin/core-impl/msg-fmt/logger.d.ts +17 -0
- package/bin/core-impl/msg-fmt/logger.js +106 -0
- package/bin/core-impl/msg-fmt/mapping.d.ts +3 -0
- package/bin/core-impl/msg-fmt/mapping.js +49 -0
- package/bin/core-impl/msg-fmt/messages.d.ts +35 -0
- package/bin/core-impl/msg-fmt/messages.js +316 -0
- package/bin/core-impl/msg-fmt/terminal.d.ts +15 -0
- package/bin/core-impl/msg-fmt/terminal.js +60 -0
- package/bin/core-impl/msg-fmt/variants.d.ts +11 -0
- package/bin/core-impl/msg-fmt/variants.js +52 -0
- package/bin/core-impl/next-steps/next-steps.d.ts +14 -0
- package/bin/core-impl/next-steps/next-steps.js +24 -0
- package/bin/core-impl/number/number-mod.d.ts +28 -0
- package/bin/core-impl/number/number-mod.js +197 -0
- package/bin/core-impl/results/results.d.ts +7 -0
- package/bin/core-impl/results/results.js +27 -0
- package/bin/core-impl/select/multiselect-prompt.d.ts +2 -0
- package/bin/core-impl/select/multiselect-prompt.js +342 -0
- package/bin/core-impl/select/nummultiselect-prompt.d.ts +6 -0
- package/bin/core-impl/select/nummultiselect-prompt.js +105 -0
- package/bin/core-impl/select/numselect-prompt.d.ts +7 -0
- package/bin/core-impl/select/numselect-prompt.js +115 -0
- package/bin/core-impl/select/select-prompt.d.ts +33 -0
- package/bin/core-impl/select/select-prompt.js +303 -0
- package/bin/core-impl/select/toggle-prompt.d.ts +5 -0
- package/bin/core-impl/select/toggle-prompt.js +209 -0
- package/bin/core-impl/st-end/end.d.ts +2 -0
- package/bin/core-impl/st-end/end.js +42 -0
- package/bin/core-impl/st-end/start.d.ts +17 -0
- package/bin/core-impl/st-end/start.js +67 -0
- package/bin/core-impl/task/progress.d.ts +2 -0
- package/bin/core-impl/task/progress.js +57 -0
- package/bin/core-impl/task/spinner.d.ts +15 -0
- package/bin/core-impl/task/spinner.js +110 -0
- package/bin/core-impl/utils/colorize.d.ts +2 -0
- package/bin/core-impl/utils/colorize.js +135 -0
- package/bin/core-impl/utils/errors.d.ts +1 -0
- package/bin/core-impl/utils/errors.js +17 -0
- package/bin/core-impl/utils/prevent.d.ts +8 -0
- package/bin/core-impl/utils/prevent.js +65 -0
- package/bin/core-impl/utils/prompt-end.d.ts +8 -0
- package/bin/core-impl/utils/prompt-end.js +34 -0
- package/bin/core-impl/utils/stream-text.d.ts +18 -0
- package/bin/core-impl/utils/stream-text.js +136 -0
- package/bin/core-impl/utils/system.d.ts +6 -0
- package/bin/core-impl/utils/system.js +7 -0
- package/bin/core-impl/utils/validate.d.ts +21 -0
- package/bin/core-impl/utils/validate.js +17 -0
- package/bin/core-impl/visual/animate/animate.d.ts +14 -0
- package/bin/core-impl/visual/animate/animate.js +65 -0
- package/bin/core-impl/visual/ascii-art/ascii-art.d.ts +6 -0
- package/bin/core-impl/visual/ascii-art/ascii-art.js +13 -0
- package/bin/core-types.d.ts +334 -0
- package/bin/core-types.js +0 -0
- package/bin/main.d.ts +36 -0
- package/bin/main.js +86 -0
- package/package.json +58 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { re } from "@reliverse/relico";
|
|
2
|
+
import { stdout } from "node:process";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import { cursor } from "sisteransi";
|
|
5
|
+
import terminalSize from "terminal-size";
|
|
6
|
+
import wrapAnsi from "wrap-ansi";
|
|
7
|
+
import { toBaseColor } from "../msg-fmt/colors.js";
|
|
8
|
+
import { msg } from "../msg-fmt/messages.js";
|
|
9
|
+
function getTerminalWidth() {
|
|
10
|
+
return terminalSize().columns;
|
|
11
|
+
}
|
|
12
|
+
let isStartOfLine = true;
|
|
13
|
+
let isFirstLine = true;
|
|
14
|
+
function stripAnsi(text) {
|
|
15
|
+
return text.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
|
|
16
|
+
}
|
|
17
|
+
function extractAnsi(text) {
|
|
18
|
+
return text.match(/\x1b\[[0-9;]*[a-zA-Z]/g) || [];
|
|
19
|
+
}
|
|
20
|
+
function wrapWithBar(text, isFirst, color) {
|
|
21
|
+
const prefix = isFirst ? re.green("\u25C6") : re.dim("\u2502");
|
|
22
|
+
const ansiCodes = extractAnsi(text);
|
|
23
|
+
const cleanText = stripAnsi(text);
|
|
24
|
+
const coloredText = color ? re[color](cleanText) : re.dim(cleanText);
|
|
25
|
+
const finalText = ansiCodes.length > 0 ? ansiCodes.join("") + coloredText : coloredText;
|
|
26
|
+
return `${prefix} ${finalText}`;
|
|
27
|
+
}
|
|
28
|
+
function wrapText(text) {
|
|
29
|
+
const width = getTerminalWidth();
|
|
30
|
+
return wrapAnsi(text, width - 4, { hard: false, trim: true });
|
|
31
|
+
}
|
|
32
|
+
export async function streamText({
|
|
33
|
+
text,
|
|
34
|
+
delay = 50,
|
|
35
|
+
showCursor = false,
|
|
36
|
+
color,
|
|
37
|
+
newline = true,
|
|
38
|
+
clearLine = false,
|
|
39
|
+
onProgress
|
|
40
|
+
}) {
|
|
41
|
+
if (!showCursor) {
|
|
42
|
+
stdout.write(cursor.hide);
|
|
43
|
+
}
|
|
44
|
+
if (clearLine) {
|
|
45
|
+
stdout.write("\r\x1B[K");
|
|
46
|
+
}
|
|
47
|
+
const wrappedText = wrapText(text);
|
|
48
|
+
isFirstLine = true;
|
|
49
|
+
let buffer = "";
|
|
50
|
+
for (const char of wrappedText) {
|
|
51
|
+
if (char === "\n") {
|
|
52
|
+
if (buffer) {
|
|
53
|
+
const output = isStartOfLine ? wrapWithBar(buffer, isFirstLine, color) : color ? re[color](buffer) : re.dim(buffer);
|
|
54
|
+
stdout.write(output);
|
|
55
|
+
buffer = "";
|
|
56
|
+
}
|
|
57
|
+
stdout.write(char);
|
|
58
|
+
isStartOfLine = true;
|
|
59
|
+
isFirstLine = false;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
buffer += char;
|
|
63
|
+
if (!char.includes("\x1B[") && buffer) {
|
|
64
|
+
const output = isStartOfLine ? wrapWithBar(buffer, isFirstLine, color) : color ? re[color](buffer) : re.dim(buffer);
|
|
65
|
+
stdout.write(output);
|
|
66
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
67
|
+
isStartOfLine = false;
|
|
68
|
+
buffer = "";
|
|
69
|
+
if (onProgress) {
|
|
70
|
+
onProgress(output);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (buffer) {
|
|
75
|
+
const output = isStartOfLine ? wrapWithBar(buffer, isFirstLine, color) : color ? re[color](buffer) : re.dim(buffer);
|
|
76
|
+
stdout.write(output);
|
|
77
|
+
if (onProgress) {
|
|
78
|
+
onProgress(output);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (newline) {
|
|
82
|
+
stdout.write("\n");
|
|
83
|
+
}
|
|
84
|
+
if (!showCursor) {
|
|
85
|
+
stdout.write(cursor.show);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export async function streamTextBox({
|
|
89
|
+
text,
|
|
90
|
+
delay = 50,
|
|
91
|
+
color,
|
|
92
|
+
borderColor = "dim"
|
|
93
|
+
}) {
|
|
94
|
+
stdout.write(cursor.hide);
|
|
95
|
+
msg({
|
|
96
|
+
type: "M_START",
|
|
97
|
+
title: "",
|
|
98
|
+
borderColor
|
|
99
|
+
});
|
|
100
|
+
await streamText({
|
|
101
|
+
text,
|
|
102
|
+
delay,
|
|
103
|
+
showCursor: false,
|
|
104
|
+
color,
|
|
105
|
+
newline: false,
|
|
106
|
+
clearLine: false
|
|
107
|
+
});
|
|
108
|
+
msg({
|
|
109
|
+
type: "M_END",
|
|
110
|
+
borderColor
|
|
111
|
+
});
|
|
112
|
+
stdout.write(cursor.show);
|
|
113
|
+
}
|
|
114
|
+
export async function streamTextWithSpinner({
|
|
115
|
+
text,
|
|
116
|
+
delay = 50,
|
|
117
|
+
color = "cyan",
|
|
118
|
+
spinnerFrames,
|
|
119
|
+
spinnerDelay
|
|
120
|
+
}) {
|
|
121
|
+
let currentText = "";
|
|
122
|
+
const spinner = ora({
|
|
123
|
+
text: currentText,
|
|
124
|
+
color: toBaseColor(color),
|
|
125
|
+
spinner: spinnerFrames ? {
|
|
126
|
+
frames: spinnerFrames,
|
|
127
|
+
interval: spinnerDelay
|
|
128
|
+
} : "dots"
|
|
129
|
+
}).start();
|
|
130
|
+
for (const char of text) {
|
|
131
|
+
currentText += char;
|
|
132
|
+
spinner.text = color ? re[color](currentText) : currentText;
|
|
133
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
134
|
+
}
|
|
135
|
+
spinner.stop();
|
|
136
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getUserPkgManager } from "@reliverse/runtime";
|
|
2
|
+
export const pm = await getUserPkgManager();
|
|
3
|
+
export const reliversePrompts = {
|
|
4
|
+
name: "@reliverse/prompts",
|
|
5
|
+
version: "1.6.0",
|
|
6
|
+
description: "@reliverse/prompts is a powerful library that enables seamless, typesafe, and resilient prompts for command-line applications. Crafted with simplicity and elegance, it provides developers with an intuitive and robust way to build interactive CLIs."
|
|
7
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the terminal is interactive
|
|
3
|
+
*/
|
|
4
|
+
export declare function isTerminalInteractive(input?: NodeJS.ReadStream & {
|
|
5
|
+
fd: 0;
|
|
6
|
+
}): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Validates a name against allowed characters
|
|
9
|
+
*/
|
|
10
|
+
type ValidationResult = {
|
|
11
|
+
isValid: boolean;
|
|
12
|
+
message?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function isValidName(name: string): ValidationResult;
|
|
15
|
+
/**
|
|
16
|
+
* Cleans up project name from config by removing scope and invalid characters.
|
|
17
|
+
* For paths with multiple segments (e.g. "@org/subpath/cli"), takes the last segment.
|
|
18
|
+
* This also ensures complex cases (e.g. "@some@weird/path/the-name!" returns "the-name").
|
|
19
|
+
*/
|
|
20
|
+
export declare function normalizeName(name: string): string;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function isTerminalInteractive(input = process.stdin) {
|
|
2
|
+
return Boolean(input.isTTY);
|
|
3
|
+
}
|
|
4
|
+
export function isValidName(name) {
|
|
5
|
+
if (!/^[a-zA-Z0-9-]+$/.test(name)) {
|
|
6
|
+
return {
|
|
7
|
+
isValid: false,
|
|
8
|
+
message: "Project name can only contain latin letters, numbers and hyphens"
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
return { isValid: true };
|
|
12
|
+
}
|
|
13
|
+
export function normalizeName(name) {
|
|
14
|
+
const segments = name.split("/");
|
|
15
|
+
const lastSegment = segments[segments.length - 1] ?? name;
|
|
16
|
+
return lastSegment.replace(/[^a-zA-Z0-9-]/g, "");
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Animation, type AnimationName } from "@figliolia/chalk-animation";
|
|
2
|
+
import type { BorderColorName, ColorName, MsgType, TypographyName } from "../../../core-types.js";
|
|
3
|
+
export declare const animationMap: Record<AnimationName, (text: string) => Animation>;
|
|
4
|
+
export declare function animateText({ title, anim, delay, type, titleColor, titleTypography, border, borderColor, horizontalLineLength, }: {
|
|
5
|
+
title: string;
|
|
6
|
+
anim: AnimationName;
|
|
7
|
+
delay?: number;
|
|
8
|
+
type?: MsgType;
|
|
9
|
+
titleColor?: ColorName;
|
|
10
|
+
titleTypography?: TypographyName;
|
|
11
|
+
borderColor?: BorderColorName;
|
|
12
|
+
border?: boolean;
|
|
13
|
+
horizontalLineLength?: number;
|
|
14
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChalkAnimation
|
|
3
|
+
} from "@figliolia/chalk-animation";
|
|
4
|
+
import { relinka } from "@reliverse/relinka";
|
|
5
|
+
import { msg } from "../../msg-fmt/messages.js";
|
|
6
|
+
import {
|
|
7
|
+
deleteLastLine,
|
|
8
|
+
getTerminalWidth
|
|
9
|
+
} from "../../msg-fmt/terminal.js";
|
|
10
|
+
export const animationMap = {
|
|
11
|
+
rainbow: ChalkAnimation.rainbow,
|
|
12
|
+
pulse: ChalkAnimation.pulse,
|
|
13
|
+
glitch: ChalkAnimation.glitch,
|
|
14
|
+
radar: ChalkAnimation.radar,
|
|
15
|
+
neon: ChalkAnimation.neon,
|
|
16
|
+
karaoke: ChalkAnimation.karaoke
|
|
17
|
+
};
|
|
18
|
+
function calculateDelay(text) {
|
|
19
|
+
const baseDelay = 1e3;
|
|
20
|
+
const delayPerCharacter = 50;
|
|
21
|
+
return baseDelay + text.length * delayPerCharacter;
|
|
22
|
+
}
|
|
23
|
+
export async function animateText({
|
|
24
|
+
title = "",
|
|
25
|
+
anim,
|
|
26
|
+
delay,
|
|
27
|
+
type = "M_INFO",
|
|
28
|
+
titleColor = "cyan",
|
|
29
|
+
titleTypography = "none",
|
|
30
|
+
border = true,
|
|
31
|
+
borderColor = "dim",
|
|
32
|
+
horizontalLineLength = 0
|
|
33
|
+
}) {
|
|
34
|
+
if (horizontalLineLength === 0) {
|
|
35
|
+
horizontalLineLength = getTerminalWidth() - 5;
|
|
36
|
+
}
|
|
37
|
+
const finalDelay = delay ?? calculateDelay(title);
|
|
38
|
+
const animation = animationMap[anim](title);
|
|
39
|
+
try {
|
|
40
|
+
await new Promise((resolve) => {
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
animation.stop();
|
|
43
|
+
deleteLastLine();
|
|
44
|
+
if (title.includes("\u2502 ")) {
|
|
45
|
+
title = title.replace("\u2502 ", "");
|
|
46
|
+
} else if (title.includes("\u2139 ")) {
|
|
47
|
+
title = title.replace("\u2139 ", "");
|
|
48
|
+
}
|
|
49
|
+
msg({
|
|
50
|
+
type,
|
|
51
|
+
title,
|
|
52
|
+
titleColor,
|
|
53
|
+
titleTypography,
|
|
54
|
+
content: "",
|
|
55
|
+
borderColor,
|
|
56
|
+
border,
|
|
57
|
+
horizontalLineLength
|
|
58
|
+
});
|
|
59
|
+
resolve();
|
|
60
|
+
}, finalDelay);
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
relinka("error", "Animation failed to complete.", error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import figlet from "figlet";
|
|
3
|
+
export async function createAsciiArt({
|
|
4
|
+
message,
|
|
5
|
+
font = "Standard",
|
|
6
|
+
clearConsole = false
|
|
7
|
+
}) {
|
|
8
|
+
if (clearConsole) {
|
|
9
|
+
relinka("clear", "");
|
|
10
|
+
}
|
|
11
|
+
const asciiArt = figlet.textSync(message, { font });
|
|
12
|
+
relinka("info", asciiArt);
|
|
13
|
+
}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
export type MsgType = "M_NULL" | "M_INFO_NULL" | "M_START" | "M_MIDDLE" | "M_GENERAL" | "M_GENERAL_NULL" | "M_INFO" | "M_ERROR" | "M_ERROR_NULL" | "M_END" | "M_NEWLINE" | "M_BAR";
|
|
2
|
+
export type TypographyName = "bold" | "strikethrough" | "underline" | "italic" | "none";
|
|
3
|
+
export type BorderColorName = "reset" | "inverse" | "dim" | "black" | "red" | "redBright" | "green" | "greenBright" | "yellow" | "yellowBright" | "blue" | "blueBright" | "magenta" | "magentaBright" | "cyan" | "cyanBright" | "bgCyan" | "bgCyanBright" | "white" | "gray";
|
|
4
|
+
export type ColorName = BorderColorName | "gradientGradient" | "rainbowGradient" | "cristalGradient" | "mindGradient" | "passionGradient" | "viceGradient" | "retroGradient" | "none";
|
|
5
|
+
type AnimationName = "rainbow" | "pulse" | "glitch" | "radar" | "neon" | "karaoke";
|
|
6
|
+
export type VariantName = "doubleBox" | "none";
|
|
7
|
+
export type MsgConfig = {
|
|
8
|
+
symbol: string;
|
|
9
|
+
prefix?: string;
|
|
10
|
+
color?: (text: string) => string;
|
|
11
|
+
newLineBefore?: boolean;
|
|
12
|
+
newLineAfter?: boolean;
|
|
13
|
+
suffix?: string;
|
|
14
|
+
};
|
|
15
|
+
export type PromptOptions = {
|
|
16
|
+
schema?: any;
|
|
17
|
+
title?: string;
|
|
18
|
+
titleColor?: ColorName;
|
|
19
|
+
titleTypography?: TypographyName;
|
|
20
|
+
titleVariant?: VariantName;
|
|
21
|
+
titleAnimation?: AnimationName;
|
|
22
|
+
titleAnimationDelay?: number;
|
|
23
|
+
content?: string;
|
|
24
|
+
contentColor?: ColorName;
|
|
25
|
+
contentTypography?: TypographyName;
|
|
26
|
+
contentVariant?: VariantName;
|
|
27
|
+
hint?: string;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
validate?: (value: any) => boolean | string | Promise<boolean | string>;
|
|
30
|
+
defaultColor?: ColorName;
|
|
31
|
+
defaultTypography?: TypographyName;
|
|
32
|
+
choices?: ChoiceOptions[];
|
|
33
|
+
variantOptions?: {
|
|
34
|
+
box?: {
|
|
35
|
+
limit?: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
action?: () => Promise<void>;
|
|
39
|
+
border?: boolean;
|
|
40
|
+
borderColor?: BorderColorName;
|
|
41
|
+
additionalLinesToDelete?: number;
|
|
42
|
+
hintPlaceholderColor?: ColorName;
|
|
43
|
+
hints?: string[];
|
|
44
|
+
required?: boolean;
|
|
45
|
+
initial?: any[];
|
|
46
|
+
endTitle?: string;
|
|
47
|
+
endTitleColor?: ColorName;
|
|
48
|
+
horizontalLine?: boolean;
|
|
49
|
+
horizontalLineLength?: number;
|
|
50
|
+
symbol?: string;
|
|
51
|
+
customSymbol?: string;
|
|
52
|
+
};
|
|
53
|
+
type ChoiceRequiredOptions = {
|
|
54
|
+
id: string;
|
|
55
|
+
title: string;
|
|
56
|
+
};
|
|
57
|
+
type ChoiceOptionalOptions = {
|
|
58
|
+
description?: string;
|
|
59
|
+
titleTypography?: TypographyName;
|
|
60
|
+
action?: () => Promise<void>;
|
|
61
|
+
};
|
|
62
|
+
export type ChoiceOptions = ChoiceRequiredOptions & ChoiceOptionalOptions;
|
|
63
|
+
export type SelectOption<T> = {
|
|
64
|
+
value: T;
|
|
65
|
+
label: string;
|
|
66
|
+
hint?: string;
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Standard terminal colors supported by most terminals
|
|
71
|
+
*/
|
|
72
|
+
export type StandardColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray";
|
|
73
|
+
/**
|
|
74
|
+
* All possible output colors including special colors
|
|
75
|
+
*/
|
|
76
|
+
export type OutputColor = StandardColor | "dim";
|
|
77
|
+
export type EditorExitResult = {
|
|
78
|
+
saved: boolean;
|
|
79
|
+
content: string | null;
|
|
80
|
+
filename: string | null;
|
|
81
|
+
};
|
|
82
|
+
export type MessageKind = "log" | "info" | "warn" | "error" | "success";
|
|
83
|
+
type VerboseKind = `${MessageKind}-verbose`;
|
|
84
|
+
export type AllKinds = MessageKind | VerboseKind;
|
|
85
|
+
export type MessageConfig = {
|
|
86
|
+
type: "M_INFO" | "M_ERROR";
|
|
87
|
+
titleColor?: "retroGradient" | "viceGradient" | "yellowBright";
|
|
88
|
+
titleTypography?: "bold";
|
|
89
|
+
contentColor?: "dim";
|
|
90
|
+
contentTypography?: "italic";
|
|
91
|
+
};
|
|
92
|
+
export type StreamOptions = {
|
|
93
|
+
delay?: number;
|
|
94
|
+
useSpinner?: boolean;
|
|
95
|
+
spinnerFrames?: string[];
|
|
96
|
+
spinnerDelay?: number;
|
|
97
|
+
};
|
|
98
|
+
export type ProgressBarOptions = {
|
|
99
|
+
total: number;
|
|
100
|
+
width?: number;
|
|
101
|
+
completeChar?: string;
|
|
102
|
+
incompleteChar?: string;
|
|
103
|
+
format?: string;
|
|
104
|
+
colorize?: boolean;
|
|
105
|
+
increment?: number;
|
|
106
|
+
desiredTotalTime?: number;
|
|
107
|
+
};
|
|
108
|
+
export type ProgressBar = {
|
|
109
|
+
update: (value: number) => Promise<void>;
|
|
110
|
+
increment: (amount?: number) => Promise<void>;
|
|
111
|
+
render: () => Promise<void>;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Union type for available prompt types.
|
|
115
|
+
*/
|
|
116
|
+
export type PromptType = "input" | "inputmasked" | "select" | "multiselect" | "nummultiselect" | "numselect" | "toggle" | "confirm" | "spinner" | "progressbar" | "results" | "nextsteps" | "animatedtext" | "date" | "end";
|
|
117
|
+
export type ConfirmPromptOptions = {
|
|
118
|
+
title: string;
|
|
119
|
+
defaultValue?: boolean;
|
|
120
|
+
content?: string;
|
|
121
|
+
titleColor?: ColorName;
|
|
122
|
+
titleTypography?: TypographyName;
|
|
123
|
+
titleVariant?: VariantName;
|
|
124
|
+
contentColor?: ColorName;
|
|
125
|
+
contentTypography?: TypographyName;
|
|
126
|
+
contentVariant?: VariantName;
|
|
127
|
+
borderColor?: BorderColorName;
|
|
128
|
+
hintPlaceholderColor?: ColorName;
|
|
129
|
+
variantOptions?: any;
|
|
130
|
+
action?: () => Promise<void>;
|
|
131
|
+
displayInstructions?: boolean;
|
|
132
|
+
debug?: boolean;
|
|
133
|
+
endTitle?: string;
|
|
134
|
+
endTitleColor?: ColorName;
|
|
135
|
+
border?: boolean;
|
|
136
|
+
terminalWidth?: number;
|
|
137
|
+
};
|
|
138
|
+
export type StreamTextOptions = {
|
|
139
|
+
/**
|
|
140
|
+
* Text to stream
|
|
141
|
+
*/
|
|
142
|
+
text: string;
|
|
143
|
+
/**
|
|
144
|
+
* Delay between each character in milliseconds
|
|
145
|
+
* @default 50
|
|
146
|
+
*/
|
|
147
|
+
delay?: number;
|
|
148
|
+
/**
|
|
149
|
+
* Whether to show cursor while streaming
|
|
150
|
+
* @default false
|
|
151
|
+
*/
|
|
152
|
+
showCursor?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Color to use for the text
|
|
155
|
+
* @default undefined (no color)
|
|
156
|
+
*/
|
|
157
|
+
color?: ColorName;
|
|
158
|
+
/**
|
|
159
|
+
* Whether to add a newline at the end
|
|
160
|
+
* @default true
|
|
161
|
+
*/
|
|
162
|
+
newline?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Whether to clear the line before streaming
|
|
165
|
+
* @default false
|
|
166
|
+
*/
|
|
167
|
+
clearLine?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Callback function to update the spinner text
|
|
170
|
+
*/
|
|
171
|
+
onProgress?: (currentText: string) => void;
|
|
172
|
+
};
|
|
173
|
+
export type PreventWrongTerminalSizeOptions = {
|
|
174
|
+
isDev?: boolean;
|
|
175
|
+
shouldExit?: boolean;
|
|
176
|
+
minWidth?: number;
|
|
177
|
+
minHeight?: number;
|
|
178
|
+
sizeErrorDescription?: string;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* InputPromptOptions
|
|
182
|
+
*
|
|
183
|
+
* Extended options for handling user input prompts, including validation
|
|
184
|
+
* and UI styling. Inherits from PromptOptions.
|
|
185
|
+
*/
|
|
186
|
+
export type InputPromptOptions = {
|
|
187
|
+
border?: boolean;
|
|
188
|
+
borderColor?: BorderColorName;
|
|
189
|
+
content?: string;
|
|
190
|
+
contentColor?: ColorName;
|
|
191
|
+
contentTypography?: TypographyName;
|
|
192
|
+
contentVariant?: VariantName;
|
|
193
|
+
customSymbol?: string;
|
|
194
|
+
defaultValue?: string;
|
|
195
|
+
endTitle?: string;
|
|
196
|
+
endTitleColor?: ColorName;
|
|
197
|
+
hardcoded?: {
|
|
198
|
+
userInput?: string;
|
|
199
|
+
errorMessage?: string;
|
|
200
|
+
showPlaceholder?: boolean;
|
|
201
|
+
};
|
|
202
|
+
hint?: string;
|
|
203
|
+
hintPlaceholderColor?: ColorName;
|
|
204
|
+
mode?: "plain" | "password";
|
|
205
|
+
mask?: string;
|
|
206
|
+
placeholder?: string;
|
|
207
|
+
schema?: any;
|
|
208
|
+
shouldStream?: boolean;
|
|
209
|
+
streamDelay?: number;
|
|
210
|
+
symbol?: SymbolName;
|
|
211
|
+
symbolColor?: ColorName;
|
|
212
|
+
title: string;
|
|
213
|
+
titleColor?: ColorName;
|
|
214
|
+
titleTypography?: TypographyName;
|
|
215
|
+
titleVariant?: VariantName;
|
|
216
|
+
validate?: (value: string) => string | boolean | undefined | Promise<string | boolean | undefined>;
|
|
217
|
+
variantOptions?: unknown;
|
|
218
|
+
} & PromptOptions;
|
|
219
|
+
export type RenderParams = {
|
|
220
|
+
border: boolean;
|
|
221
|
+
borderColor?: BorderColorName;
|
|
222
|
+
content?: string;
|
|
223
|
+
contentColor?: ColorName;
|
|
224
|
+
contentTypography?: TypographyName;
|
|
225
|
+
contentVariant?: VariantName;
|
|
226
|
+
customSymbol?: string;
|
|
227
|
+
errorMessage: string;
|
|
228
|
+
hint?: string;
|
|
229
|
+
hintPlaceholderColor?: ColorName;
|
|
230
|
+
mask?: string;
|
|
231
|
+
placeholder?: string;
|
|
232
|
+
symbol?: SymbolName;
|
|
233
|
+
symbolColor?: ColorName;
|
|
234
|
+
title: string;
|
|
235
|
+
titleColor?: ColorName;
|
|
236
|
+
titleTypography?: TypographyName;
|
|
237
|
+
titleVariant?: VariantName;
|
|
238
|
+
userInput: string;
|
|
239
|
+
isRerender?: boolean;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Known symbol names that will have IntelliSense support
|
|
243
|
+
*/
|
|
244
|
+
export type SymbolName = "pointer" | "start" | "middle" | "end" | "line" | "corner_top_right" | "step_active" | "step_error" | "info" | "success";
|
|
245
|
+
export type Symbols = Record<SymbolName, string>;
|
|
246
|
+
export type FmtMsgOptions = {
|
|
247
|
+
type: MsgType;
|
|
248
|
+
title?: string;
|
|
249
|
+
titleAfterAnim?: string;
|
|
250
|
+
content?: string | undefined;
|
|
251
|
+
titleColor?: ColorName;
|
|
252
|
+
titleTypography?: TypographyName;
|
|
253
|
+
titleVariant?: VariantName;
|
|
254
|
+
contentColor?: ColorName;
|
|
255
|
+
contentTypography?: TypographyName;
|
|
256
|
+
contentVariant?: VariantName;
|
|
257
|
+
hint?: string;
|
|
258
|
+
hintPlaceholderColor?: ColorName;
|
|
259
|
+
hintTypography?: TypographyName;
|
|
260
|
+
border?: boolean;
|
|
261
|
+
borderColor?: ColorName;
|
|
262
|
+
dontRemoveBar?: boolean;
|
|
263
|
+
variantOptions?: {
|
|
264
|
+
box?: {
|
|
265
|
+
limit?: number;
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
errorMessage?: string;
|
|
269
|
+
addNewLineBefore?: boolean;
|
|
270
|
+
addNewLineAfter?: boolean;
|
|
271
|
+
placeholder?: string;
|
|
272
|
+
horizontalLine?: boolean;
|
|
273
|
+
horizontalLineLength?: number;
|
|
274
|
+
terminalWidth?: number;
|
|
275
|
+
instructions?: string;
|
|
276
|
+
wrapTitle?: boolean;
|
|
277
|
+
wrapContent?: boolean;
|
|
278
|
+
symbol?: SymbolName;
|
|
279
|
+
customSymbol?: string;
|
|
280
|
+
symbolColor?: ColorName;
|
|
281
|
+
noNewLine?: boolean;
|
|
282
|
+
};
|
|
283
|
+
export type TogglePromptParams<T extends string> = {
|
|
284
|
+
title: string;
|
|
285
|
+
content?: string;
|
|
286
|
+
options?: [T, T];
|
|
287
|
+
defaultValue?: T;
|
|
288
|
+
borderColor?: BorderColorName;
|
|
289
|
+
titleColor?: ColorName;
|
|
290
|
+
titleTypography?: TypographyName;
|
|
291
|
+
titleVariant?: VariantName;
|
|
292
|
+
contentColor?: ColorName;
|
|
293
|
+
contentTypography?: TypographyName;
|
|
294
|
+
border?: boolean;
|
|
295
|
+
endTitle?: string;
|
|
296
|
+
endTitleColor?: ColorName;
|
|
297
|
+
displayInstructions?: boolean;
|
|
298
|
+
debug?: boolean;
|
|
299
|
+
};
|
|
300
|
+
export type SeparatorOption = {
|
|
301
|
+
separator: true;
|
|
302
|
+
width?: number;
|
|
303
|
+
symbol?: SymbolName;
|
|
304
|
+
};
|
|
305
|
+
export type MultiselectPromptParams<T extends string> = {
|
|
306
|
+
title: string;
|
|
307
|
+
content?: string;
|
|
308
|
+
options: (SelectOption<T> | SeparatorOption)[];
|
|
309
|
+
defaultValue?: T[];
|
|
310
|
+
borderColor?: BorderColorName;
|
|
311
|
+
titleColor?: ColorName;
|
|
312
|
+
titleTypography?: TypographyName;
|
|
313
|
+
titleVariant?: VariantName;
|
|
314
|
+
contentColor?: ColorName;
|
|
315
|
+
contentTypography?: TypographyName;
|
|
316
|
+
border?: boolean;
|
|
317
|
+
endTitle?: string;
|
|
318
|
+
endTitleColor?: ColorName;
|
|
319
|
+
debug?: boolean;
|
|
320
|
+
terminalWidth?: number;
|
|
321
|
+
displayInstructions?: boolean;
|
|
322
|
+
minSelect?: number;
|
|
323
|
+
maxSelect?: number;
|
|
324
|
+
selectAll?: boolean;
|
|
325
|
+
};
|
|
326
|
+
export type DatePromptOptions = PromptOptions & {
|
|
327
|
+
dateFormat: string;
|
|
328
|
+
dateKind: "birthday" | "other";
|
|
329
|
+
defaultValue?: string;
|
|
330
|
+
endTitle?: string;
|
|
331
|
+
endTitleColor?: ColorName;
|
|
332
|
+
border?: boolean;
|
|
333
|
+
};
|
|
334
|
+
export {};
|
|
File without changes
|
package/bin/main.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export { anykeyPrompt } from "./core-impl/anykey/anykey-mod.js";
|
|
2
|
+
export { datePrompt } from "./core-impl/date/date.js";
|
|
3
|
+
export { startEditor } from "./core-impl/editor/editor-mod.js";
|
|
4
|
+
export { mainSymbols, fallbackSymbols, } from "./core-impl/figures/figures-mod.js";
|
|
5
|
+
export { confirmPrompt } from "./core-impl/input/confirm-prompt.js";
|
|
6
|
+
export { inputPrompt } from "./core-impl/input/input-prompt.js";
|
|
7
|
+
export type { ArgDefinition, ArgDefinitions, SubCommandsMap, Command, InferArgTypes, FileBasedCmdsOptions, } from "./core-impl/launcher/launcher-mod.js";
|
|
8
|
+
export { defineCommand, showUsage, runMain, } from "./core-impl/launcher/launcher-mod.js";
|
|
9
|
+
export { toBaseColor, toSolidColor } from "./core-impl/msg-fmt/colors.js";
|
|
10
|
+
export { relinkaByRemptsDeprecated, relinkaAsyncByRemptsDeprecated, throwError, } from "./core-impl/msg-fmt/logger.js";
|
|
11
|
+
export { colorMap, typographyMap } from "./core-impl/msg-fmt/mapping.js";
|
|
12
|
+
export { symbols, bar, fmt, msg, msgUndo, msgUndoAll, printLineBar, } from "./core-impl/msg-fmt/messages.js";
|
|
13
|
+
export { getTerminalHeight, getExactTerminalWidth, getTerminalWidth, breakLines, removeCursor, restoreCursor, deleteLastLine, deleteLastLines, countLines, } from "./core-impl/msg-fmt/terminal.js";
|
|
14
|
+
export { variantMap, isValidVariant, applyVariant, } from "./core-impl/msg-fmt/variants.js";
|
|
15
|
+
export { nextStepsPrompt } from "./core-impl/next-steps/next-steps.js";
|
|
16
|
+
export { numberPrompt } from "./core-impl/number/number-mod.js";
|
|
17
|
+
export type { ResultsType } from "./core-impl/results/results.js";
|
|
18
|
+
export { resultPrompt } from "./core-impl/results/results.js";
|
|
19
|
+
export { multiselectPrompt } from "./core-impl/select/multiselect-prompt.js";
|
|
20
|
+
export { numMultiSelectPrompt } from "./core-impl/select/nummultiselect-prompt.js";
|
|
21
|
+
export { numSelectPrompt } from "./core-impl/select/numselect-prompt.js";
|
|
22
|
+
export { selectPrompt } from "./core-impl/select/select-prompt.js";
|
|
23
|
+
export { togglePrompt } from "./core-impl/select/toggle-prompt.js";
|
|
24
|
+
export { endPrompt } from "./core-impl/st-end/end.js";
|
|
25
|
+
export { startPrompt } from "./core-impl/st-end/start.js";
|
|
26
|
+
export { progressTaskPrompt } from "./core-impl/task/progress.js";
|
|
27
|
+
export { spinnerTaskPrompt } from "./core-impl/task/spinner.js";
|
|
28
|
+
export { colorize } from "./core-impl/utils/colorize.js";
|
|
29
|
+
export { errorHandler } from "./core-impl/utils/errors.js";
|
|
30
|
+
export { preventUnsupportedTTY, preventWindowsHomeDirRoot, preventWrongTerminalSize, } from "./core-impl/utils/prevent.js";
|
|
31
|
+
export { completePrompt, renderEndLine, renderEndLineInput, } from "./core-impl/utils/prompt-end.js";
|
|
32
|
+
export { streamText, streamTextBox, streamTextWithSpinner, } from "./core-impl/utils/stream-text.js";
|
|
33
|
+
export { pm, reliversePrompts } from "./core-impl/utils/system.js";
|
|
34
|
+
export { isTerminalInteractive, isValidName, normalizeName, } from "./core-impl/utils/validate.js";
|
|
35
|
+
export { animationMap, animateText, } from "./core-impl/visual/animate/animate.js";
|
|
36
|
+
export { createAsciiArt } from "./core-impl/visual/ascii-art/ascii-art.js";
|