@reliverse/rempts 1.7.44 → 1.7.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +1 -1
  2. package/dist-npm/bin/mod.d.mts +2333 -0
  3. package/dist-npm/bin/mod.mjs +8236 -0
  4. package/package.json +84 -42
  5. package/bin/libs/animate/animate-mod.d.ts +0 -14
  6. package/bin/libs/animate/animate-mod.js +0 -62
  7. package/bin/libs/anykey/anykey-mod.d.ts +0 -12
  8. package/bin/libs/anykey/anykey-mod.js +0 -125
  9. package/bin/libs/cancel/cancel.d.ts +0 -45
  10. package/bin/libs/cancel/cancel.js +0 -72
  11. package/bin/libs/confirm/confirm-alias.d.ts +0 -2
  12. package/bin/libs/confirm/confirm-alias.js +0 -2
  13. package/bin/libs/confirm/confirm-mod.d.ts +0 -5
  14. package/bin/libs/confirm/confirm-mod.js +0 -179
  15. package/bin/libs/date/date.d.ts +0 -2
  16. package/bin/libs/date/date.js +0 -236
  17. package/bin/libs/editor/editor-mod.d.ts +0 -25
  18. package/bin/libs/editor/editor-mod.js +0 -897
  19. package/bin/libs/figures/figures-mod.d.ts +0 -461
  20. package/bin/libs/figures/figures-mod.js +0 -285
  21. package/bin/libs/group/group-mod.d.ts +0 -33
  22. package/bin/libs/group/group-mod.js +0 -93
  23. package/bin/libs/input/input-alias.d.ts +0 -5
  24. package/bin/libs/input/input-alias.js +0 -4
  25. package/bin/libs/input/input-mod.d.ts +0 -16
  26. package/bin/libs/input/input-mod.js +0 -372
  27. package/bin/libs/intro/intro-alias.d.ts +0 -2
  28. package/bin/libs/intro/intro-alias.js +0 -3
  29. package/bin/libs/intro/intro-mod.d.ts +0 -20
  30. package/bin/libs/intro/intro-mod.js +0 -81
  31. package/bin/libs/launcher/command-runner.d.ts +0 -18
  32. package/bin/libs/launcher/command-runner.js +0 -79
  33. package/bin/libs/launcher/command-typed.d.ts +0 -16
  34. package/bin/libs/launcher/command-typed.js +0 -60
  35. package/bin/libs/launcher/launcher-alias.d.ts +0 -2
  36. package/bin/libs/launcher/launcher-alias.js +0 -2
  37. package/bin/libs/launcher/launcher-mod.d.ts +0 -162
  38. package/bin/libs/launcher/launcher-mod.js +0 -1222
  39. package/bin/libs/launcher/launcher-types.d.ts +0 -159
  40. package/bin/libs/launcher/launcher-types.js +0 -0
  41. package/bin/libs/launcher/trpc-orpc-support/completions.d.ts +0 -4
  42. package/bin/libs/launcher/trpc-orpc-support/completions.js +0 -45
  43. package/bin/libs/launcher/trpc-orpc-support/errors.d.ts +0 -11
  44. package/bin/libs/launcher/trpc-orpc-support/errors.js +0 -10
  45. package/bin/libs/launcher/trpc-orpc-support/index.d.ts +0 -34
  46. package/bin/libs/launcher/trpc-orpc-support/index.js +0 -641
  47. package/bin/libs/launcher/trpc-orpc-support/json-schema.d.ts +0 -17
  48. package/bin/libs/launcher/trpc-orpc-support/json-schema.js +0 -168
  49. package/bin/libs/launcher/trpc-orpc-support/json.d.ts +0 -44
  50. package/bin/libs/launcher/trpc-orpc-support/json.js +0 -41
  51. package/bin/libs/launcher/trpc-orpc-support/logging.d.ts +0 -11
  52. package/bin/libs/launcher/trpc-orpc-support/logging.js +0 -26
  53. package/bin/libs/launcher/trpc-orpc-support/parse-procedure.d.ts +0 -2
  54. package/bin/libs/launcher/trpc-orpc-support/parse-procedure.js +0 -486
  55. package/bin/libs/launcher/trpc-orpc-support/prompts.d.ts +0 -18
  56. package/bin/libs/launcher/trpc-orpc-support/prompts.js +0 -534
  57. package/bin/libs/launcher/trpc-orpc-support/standard-schema/contract.d.ts +0 -53
  58. package/bin/libs/launcher/trpc-orpc-support/standard-schema/contract.js +0 -0
  59. package/bin/libs/launcher/trpc-orpc-support/standard-schema/errors.d.ts +0 -9
  60. package/bin/libs/launcher/trpc-orpc-support/standard-schema/errors.js +0 -47
  61. package/bin/libs/launcher/trpc-orpc-support/standard-schema/utils.d.ts +0 -3
  62. package/bin/libs/launcher/trpc-orpc-support/standard-schema/utils.js +0 -6
  63. package/bin/libs/launcher/trpc-orpc-support/trpc-compat.d.ts +0 -71
  64. package/bin/libs/launcher/trpc-orpc-support/trpc-compat.js +0 -11
  65. package/bin/libs/launcher/trpc-orpc-support/types.d.ts +0 -276
  66. package/bin/libs/launcher/trpc-orpc-support/types.js +0 -0
  67. package/bin/libs/launcher/trpc-orpc-support/util.d.ts +0 -9
  68. package/bin/libs/launcher/trpc-orpc-support/util.js +0 -9
  69. package/bin/libs/log/log-alias.d.ts +0 -1
  70. package/bin/libs/log/log-alias.js +0 -2
  71. package/bin/libs/msg-fmt/colors.d.ts +0 -30
  72. package/bin/libs/msg-fmt/colors.js +0 -42
  73. package/bin/libs/msg-fmt/logger.d.ts +0 -17
  74. package/bin/libs/msg-fmt/logger.js +0 -103
  75. package/bin/libs/msg-fmt/mapping.d.ts +0 -3
  76. package/bin/libs/msg-fmt/mapping.js +0 -49
  77. package/bin/libs/msg-fmt/messages.d.ts +0 -35
  78. package/bin/libs/msg-fmt/messages.js +0 -319
  79. package/bin/libs/msg-fmt/terminal.d.ts +0 -15
  80. package/bin/libs/msg-fmt/terminal.js +0 -60
  81. package/bin/libs/msg-fmt/variants.d.ts +0 -11
  82. package/bin/libs/msg-fmt/variants.js +0 -52
  83. package/bin/libs/multiselect/multiselect-alias.d.ts +0 -2
  84. package/bin/libs/multiselect/multiselect-alias.js +0 -2
  85. package/bin/libs/multiselect/multiselect-prompt.d.ts +0 -2
  86. package/bin/libs/multiselect/multiselect-prompt.js +0 -348
  87. package/bin/libs/next-steps/next-steps.d.ts +0 -14
  88. package/bin/libs/next-steps/next-steps.js +0 -24
  89. package/bin/libs/number/number-mod.d.ts +0 -28
  90. package/bin/libs/number/number-mod.js +0 -194
  91. package/bin/libs/outro/outro-alias.d.ts +0 -2
  92. package/bin/libs/outro/outro-alias.js +0 -3
  93. package/bin/libs/outro/outro-mod.d.ts +0 -8
  94. package/bin/libs/outro/outro-mod.js +0 -55
  95. package/bin/libs/results/results.d.ts +0 -7
  96. package/bin/libs/results/results.js +0 -27
  97. package/bin/libs/select/nummultiselect-prompt.d.ts +0 -6
  98. package/bin/libs/select/nummultiselect-prompt.js +0 -105
  99. package/bin/libs/select/numselect-prompt.d.ts +0 -7
  100. package/bin/libs/select/numselect-prompt.js +0 -115
  101. package/bin/libs/select/select-alias.d.ts +0 -9
  102. package/bin/libs/select/select-alias.js +0 -9
  103. package/bin/libs/select/select-prompt.d.ts +0 -5
  104. package/bin/libs/select/select-prompt.js +0 -314
  105. package/bin/libs/select/toggle-prompt.d.ts +0 -5
  106. package/bin/libs/select/toggle-prompt.js +0 -209
  107. package/bin/libs/spinner/spinner-alias.d.ts +0 -1
  108. package/bin/libs/spinner/spinner-alias.js +0 -2
  109. package/bin/libs/spinner/spinner-mod.d.ts +0 -106
  110. package/bin/libs/spinner/spinner-mod.js +0 -265
  111. package/bin/libs/task/progress.d.ts +0 -2
  112. package/bin/libs/task/progress.js +0 -57
  113. package/bin/libs/task/task-spin.d.ts +0 -15
  114. package/bin/libs/task/task-spin.js +0 -110
  115. package/bin/libs/utils/colorize.d.ts +0 -2
  116. package/bin/libs/utils/colorize.js +0 -135
  117. package/bin/libs/utils/errors.d.ts +0 -1
  118. package/bin/libs/utils/errors.js +0 -17
  119. package/bin/libs/utils/prevent.d.ts +0 -8
  120. package/bin/libs/utils/prevent.js +0 -65
  121. package/bin/libs/utils/prompt-end.d.ts +0 -8
  122. package/bin/libs/utils/prompt-end.js +0 -34
  123. package/bin/libs/utils/stream-text.d.ts +0 -18
  124. package/bin/libs/utils/stream-text.js +0 -136
  125. package/bin/libs/utils/system.d.ts +0 -6
  126. package/bin/libs/utils/system.js +0 -7
  127. package/bin/libs/utils/validate.d.ts +0 -21
  128. package/bin/libs/utils/validate.js +0 -17
  129. package/bin/libs/visual/visual-mod.d.ts +0 -6
  130. package/bin/libs/visual/visual-mod.js +0 -13
  131. package/bin/mod.d.ts +0 -69
  132. package/bin/mod.js +0 -159
  133. package/bin/types.d.ts +0 -371
  134. package/bin/types.js +0 -0
@@ -1,110 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import process from "node:process";
3
- import ora from "ora";
4
- import { cursor, erase } from "sisteransi";
5
- import { msg } from "../msg-fmt/messages.js";
6
- export async function taskSpinPrompt(options) {
7
- const {
8
- initialMessage,
9
- successMessage = "Task completed successfully.",
10
- errorMessage = "An error occurred during the task.",
11
- delay = 100,
12
- spinnerSolution,
13
- spinnerType,
14
- action
15
- } = options;
16
- let message = initialMessage;
17
- let interval = null;
18
- let frameIndex = 0;
19
- if (spinnerSolution === "ora") {
20
- const oraSpinner = ora({
21
- text: initialMessage,
22
- spinner: spinnerType
23
- });
24
- try {
25
- oraSpinner.start();
26
- await action((newMessage) => {
27
- message = newMessage;
28
- oraSpinner.text = newMessage;
29
- });
30
- oraSpinner.stop();
31
- msg({
32
- type: "M_INFO",
33
- title: successMessage,
34
- titleColor: "cyan"
35
- });
36
- } catch (error) {
37
- oraSpinner.stopAndPersist({
38
- symbol: re.red("\u2716"),
39
- text: errorMessage
40
- });
41
- msg({
42
- type: "M_ERROR",
43
- title: error instanceof Error ? error.message : "An unknown error occurred.",
44
- titleColor: "red"
45
- });
46
- process.exit(1);
47
- }
48
- } else {
49
- const simpleSpinners = {
50
- default: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
51
- dottedCircle: ["\u25CB", "\u25D4", "\u25D1", "\u25D5", "\u25CF"],
52
- boxSpinner: ["\u2596", "\u2598", "\u259D", "\u2597"]
53
- };
54
- const frames = spinnerType && spinnerType in simpleSpinners ? simpleSpinners[spinnerType] : simpleSpinners.default;
55
- const handleInput = (data) => {
56
- const key = data.toString();
57
- if (key === "\r" || key === "\n") {
58
- return;
59
- }
60
- };
61
- try {
62
- if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
63
- process.stdin.setRawMode(true);
64
- process.stdin.resume();
65
- process.stdin.on("data", handleInput);
66
- }
67
- interval = setInterval(() => {
68
- const frame = re.magenta(frames[frameIndex] ?? "");
69
- process.stdout.write(
70
- `${cursor.move(-999, 0)}${erase.line}${frame} ${re.cyan(message)}`
71
- );
72
- frameIndex = (frameIndex + 1) % frames.length;
73
- }, delay);
74
- await action((newMessage) => {
75
- message = newMessage;
76
- });
77
- clearInterval(interval);
78
- interval = null;
79
- process.stdout.write(
80
- `\r${erase.line}${re.green("\u2714")} ${successMessage}
81
- `
82
- );
83
- msg({
84
- type: "M_INFO",
85
- title: successMessage,
86
- titleColor: "cyan"
87
- });
88
- } catch (error) {
89
- if (interval) {
90
- clearInterval(interval);
91
- }
92
- process.stdout.write(
93
- `\r${erase.line}${re.red("\u2716")} ${error instanceof Error ? errorMessage : "An unknown error occurred."}
94
- `
95
- );
96
- msg({
97
- type: "M_ERROR",
98
- title: error instanceof Error ? error.message : "An unknown error occurred.",
99
- titleColor: "red"
100
- });
101
- process.exit(1);
102
- } finally {
103
- if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
104
- process.stdin.setRawMode(false);
105
- process.stdin.pause();
106
- process.stdin.removeListener("data", handleInput);
107
- }
108
- }
109
- }
110
- }
@@ -1,2 +0,0 @@
1
- import type { ColorName, TypographyName } from "../../types.js";
2
- export declare function colorize(text: string, colorName?: ColorName, typography?: TypographyName): string;
@@ -1,135 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import { relinka } from "@reliverse/relinka";
3
- import gradient, {
4
- cristal,
5
- mind,
6
- passion,
7
- rainbow,
8
- vice
9
- } from "gradient-string";
10
- function stripAnsi(text) {
11
- return re.reset(text);
12
- }
13
- export function colorize(text, colorName, typography) {
14
- if (!colorName) return text;
15
- text = stripAnsi(text);
16
- let result = text;
17
- if (colorName.endsWith("Gradient")) {
18
- switch (colorName) {
19
- case "gradientGradient":
20
- result = gradient([
21
- "red",
22
- "yellow",
23
- "green",
24
- "cyan",
25
- "blue",
26
- "magenta"
27
- ])(result);
28
- break;
29
- case "rainbowGradient":
30
- result = rainbow(result);
31
- break;
32
- case "cristalGradient":
33
- result = cristal(result);
34
- break;
35
- case "mindGradient":
36
- result = mind(result);
37
- break;
38
- case "passionGradient":
39
- result = passion(result);
40
- break;
41
- case "viceGradient":
42
- result = vice(result);
43
- break;
44
- case "retroGradient":
45
- result = gradient(["#ff8a00", "#e52e71"])(result);
46
- break;
47
- default:
48
- break;
49
- }
50
- return result;
51
- }
52
- switch (colorName) {
53
- case "inverse":
54
- result = re.inverse(` ${result} `);
55
- break;
56
- case "dim":
57
- result = re.dim(result);
58
- break;
59
- case "black":
60
- result = re.black(result);
61
- break;
62
- case "red":
63
- result = re.red(result);
64
- break;
65
- case "redBright":
66
- result = re.redBright(result);
67
- break;
68
- case "green":
69
- result = re.green(result);
70
- break;
71
- case "greenBright":
72
- result = re.greenBright(result);
73
- break;
74
- case "yellow":
75
- result = re.yellow(result);
76
- break;
77
- case "yellowBright":
78
- result = re.yellowBright(result);
79
- break;
80
- case "blue":
81
- result = re.blue(result);
82
- break;
83
- case "blueBright":
84
- result = re.blueBright(result);
85
- break;
86
- case "magenta":
87
- result = re.magenta(result);
88
- break;
89
- case "magentaBright":
90
- result = re.magentaBright(result);
91
- break;
92
- case "cyan":
93
- result = re.cyan(result);
94
- break;
95
- case "cyanBright":
96
- result = re.cyanBright(result);
97
- break;
98
- case "bgCyan":
99
- result = re.bgCyan(` ${result} `);
100
- break;
101
- case "bgCyanBright":
102
- result = re.bgCyanBright(` ${result} `);
103
- break;
104
- case "white":
105
- result = re.white(result);
106
- break;
107
- case "gray":
108
- result = re.gray(result);
109
- break;
110
- case "none":
111
- break;
112
- default:
113
- relinka("warn", `Warning: Unknown color "${colorName}"`);
114
- break;
115
- }
116
- if (typography) {
117
- switch (typography) {
118
- case "bold":
119
- result = re.bold(result);
120
- break;
121
- case "strikethrough":
122
- result = re.strikethrough(result);
123
- break;
124
- case "underline":
125
- result = re.underline(result);
126
- break;
127
- case "italic":
128
- result = re.italic(result);
129
- break;
130
- default:
131
- break;
132
- }
133
- }
134
- return result;
135
- }
@@ -1 +0,0 @@
1
- export declare const errorHandler: (error: Error, customMessage?: string) => never;
@@ -1,17 +0,0 @@
1
- import { relinka } from "@reliverse/relinka";
2
- export const errorHandler = (error, customMessage) => {
3
- const separator = "\u2500".repeat(71);
4
- relinka("error", `\u2502${separator}`);
5
- relinka("error", "\u2502 AN ERROR OCCURRED:\n\u2502 ", error.message);
6
- relinka("error", `\u2502${separator}`);
7
- if (customMessage) {
8
- relinka("error", `\u2502 ${customMessage}`);
9
- } else {
10
- relinka(
11
- "error",
12
- "\u2502 If this issue is related to @reliverse/rempts itself, please\n\u2502 report the details at https://github.com/reliverse/rempts/issues"
13
- );
14
- }
15
- relinka("error", `\u2570${separator}`);
16
- process.exit(1);
17
- };
@@ -1,8 +0,0 @@
1
- import type { PreventWrongTerminalSizeOptions } from "../../types.js";
2
- export declare function preventUnsupportedTTY(): void;
3
- /**
4
- * Prevents EISDIR errors when trying to read Windows home directory as a file
5
- * @param filePath The file path to check
6
- */
7
- export declare function preventWindowsHomeDirRoot(filePath: string): never | undefined;
8
- export declare function preventWrongTerminalSize({ isDev, shouldExit, minWidth, minHeight, sizeErrorDescription, }: PreventWrongTerminalSizeOptions): Promise<void>;
@@ -1,65 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import { relinka } from "@reliverse/relinka";
3
- import { homedir } from "node:os";
4
- import terminalSize from "terminal-size";
5
- import { msg } from "../msg-fmt/messages.js";
6
- import {
7
- getExactTerminalWidth,
8
- getTerminalWidth
9
- } from "../msg-fmt/terminal.js";
10
- export function preventUnsupportedTTY() {
11
- if (!process.stdout.isTTY) {
12
- relinka(
13
- "warn",
14
- "\u2502 Your terminal does not support terminal's cursor manipulations.\n\u2502 It's recommended to use a terminal which supports TTY."
15
- );
16
- }
17
- }
18
- export function preventWindowsHomeDirRoot(filePath) {
19
- if (process.platform !== "win32") {
20
- return;
21
- }
22
- const home = homedir();
23
- if (filePath === home || filePath === `${home}\\`) {
24
- msg({
25
- type: "M_ERROR",
26
- title: re.redBright("Cannot operate in Windows home directory root"),
27
- content: `Please use a command like ${re.cyan(`cd ${home}\\Desktop`)} to move to a safe working directory first.`,
28
- contentColor: "redBright"
29
- });
30
- process.exit(1);
31
- }
32
- }
33
- export async function preventWrongTerminalSize({
34
- isDev = false,
35
- shouldExit = true,
36
- minWidth = 80,
37
- minHeight = 12,
38
- sizeErrorDescription = "Please increase the terminal size to run the application"
39
- }) {
40
- const size = terminalSize();
41
- const exactTerminalWidth = getExactTerminalWidth();
42
- const terminalWidth = getTerminalWidth();
43
- const errors = [];
44
- if (terminalWidth < minWidth) {
45
- errors.push(
46
- isDev ? `Oops! Terminal width is too small. Expected >${minWidth} | Current: ${terminalWidth} (Exact: ${exactTerminalWidth})` : `Oops! Terminal width is too small. Expected >${minWidth} | Current: ${terminalWidth}`
47
- );
48
- }
49
- if (size.rows < minHeight) {
50
- errors.push(
51
- `Oops! Terminal height is too small. Expected >${minHeight} | Current: ${size.rows}`
52
- );
53
- }
54
- if (errors.length > 0) {
55
- msg({
56
- type: "M_ERROR",
57
- title: re.redBright(errors.join("\n\u2502\u2502 ")),
58
- content: size.rows >= 7 && terminalWidth >= 70 ? sizeErrorDescription : "",
59
- contentColor: "redBright"
60
- });
61
- if (shouldExit) {
62
- process.exit(1);
63
- }
64
- }
65
- }
@@ -1,8 +0,0 @@
1
- import type { BorderColorName, ColorName, TypographyName, VariantName } from "../../types.js";
2
- /**
3
- * Ends the prompt by optionally displaying an end message and running the action if confirmed.
4
- * Preserves the last prompt state unless there's an endTitle.
5
- */
6
- export declare function completePrompt(prompt: "input" | "confirm" | "select" | "multiselect" | "toggle", isCtrlC: boolean, _endTitle?: string, _endTitleColor?: ColorName, _titleTypography?: TypographyName, _titleVariant?: VariantName | undefined, _border?: boolean, borderColor?: BorderColorName, action?: () => Promise<void>, value?: boolean): Promise<boolean>;
7
- export declare function renderEndLine(): void;
8
- export declare function renderEndLineInput(): void;
@@ -1,34 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import { relinka } from "@reliverse/relinka";
3
- import { msg, symbols } from "../msg-fmt/messages.js";
4
- import { getExactTerminalWidth } from "../msg-fmt/terminal.js";
5
- export async function completePrompt(prompt, isCtrlC, _endTitle = "", _endTitleColor = "dim", _titleTypography = "none", _titleVariant = void 0, _border = true, borderColor = "dim", action, value) {
6
- if (action && value) {
7
- await action();
8
- }
9
- if (prompt === "input") {
10
- renderEndLineInput();
11
- return value ?? false;
12
- }
13
- if (isCtrlC) {
14
- renderEndLine();
15
- } else {
16
- msg({
17
- type: "M_BAR",
18
- borderColor
19
- });
20
- }
21
- return value ?? false;
22
- }
23
- export function renderEndLine() {
24
- const lineLength = getExactTerminalWidth() - 6;
25
- relinka("null", re.dim(symbols.middle));
26
- relinka("null", re.dim(`${symbols.end}${symbols.line.repeat(lineLength)}\u22B1`));
27
- relinka("null", "");
28
- }
29
- export function renderEndLineInput() {
30
- const lineLength = getExactTerminalWidth() - 6;
31
- relinka("null", "");
32
- relinka("null", re.dim(`${symbols.end}${symbols.line.repeat(lineLength)}\u22B1`));
33
- relinka("null", "");
34
- }
@@ -1,18 +0,0 @@
1
- import type { BorderColorName, StreamTextOptions } from "../../types.js";
2
- /**
3
- * Simulates streaming text output in the console, character by character
4
- */
5
- export declare function streamText({ text, delay, showCursor, color, newline, clearLine, onProgress, }: StreamTextOptions): Promise<void>;
6
- /**
7
- * Simulates streaming text output in a message box
8
- */
9
- export declare function streamTextBox({ text, delay, color, borderColor, }: Omit<StreamTextOptions, "showCursor" | "newline" | "clearLine"> & {
10
- borderColor?: BorderColorName;
11
- }): Promise<void>;
12
- /**
13
- * Simulates streaming text output with a loading spinner using ora
14
- */
15
- export declare function streamTextWithSpinner({ text, delay, color, spinnerFrames, spinnerDelay, }: StreamTextOptions & {
16
- spinnerFrames?: string[];
17
- spinnerDelay?: number;
18
- }): Promise<void>;
@@ -1,136 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- export declare const pm: import("@reliverse/runtime").PkgManagerInfo;
2
- export declare const reliversePrompts: {
3
- name: string;
4
- version: string;
5
- description: string;
6
- };
@@ -1,7 +0,0 @@
1
- import { getUserPkgManager } from "@reliverse/runtime";
2
- export const pm = await getUserPkgManager();
3
- export const reliversePrompts = {
4
- name: "@reliverse/rempts",
5
- version: "1.6.0",
6
- description: "@reliverse/rempts 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
- };
@@ -1,21 +0,0 @@
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
- interface 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 {};
@@ -1,17 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- import { type Fonts } from "figlet";
2
- export declare function createAsciiArt({ message, font, clearConsole, }: {
3
- message: string;
4
- font?: Fonts;
5
- clearConsole?: boolean;
6
- }): Promise<void>;
@@ -1,13 +0,0 @@
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("log", asciiArt);
13
- }