@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,372 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import { isUnicodeSupported } from "@reliverse/runtime";
3
- import readline from "node:readline/promises";
4
- import { bar, msg, msgUndoAll } from "../msg-fmt/messages.js";
5
- import { deleteLastLine } from "../msg-fmt/terminal.js";
6
- import { completePrompt } from "../utils/prompt-end.js";
7
- import { streamText } from "../utils/stream-text.js";
8
- const unicode = isUnicodeSupported();
9
- const S_MASK = unicode ? "\u258B" : "*";
10
- function getMaskChar(customMask) {
11
- if (!unicode) return "*";
12
- return customMask ?? S_MASK;
13
- }
14
- async function ask(terminal, prompt, mode, mask) {
15
- if (mode === "password") {
16
- return new Promise((resolve) => {
17
- let buffer = "";
18
- const maskChar = getMaskChar(mask);
19
- process.stdout.write(prompt);
20
- const onData = (data) => {
21
- const str = data.toString("utf-8");
22
- for (const char of str) {
23
- if (char === "\n" || char === "\r") {
24
- process.stdout.write("\n");
25
- cleanup();
26
- resolve(buffer);
27
- return;
28
- }
29
- if (char === "") {
30
- cleanup();
31
- resolve(null);
32
- return;
33
- }
34
- if (char === "\x7F" || char === "\b") {
35
- if (buffer.length > 0) {
36
- buffer = buffer.slice(0, -1);
37
- }
38
- redrawPrompt(buffer, prompt);
39
- continue;
40
- }
41
- buffer += char;
42
- redrawPrompt(buffer, prompt);
43
- }
44
- };
45
- process.stdin.on("data", onData);
46
- const cleanup = () => {
47
- process.stdin.removeListener("data", onData);
48
- };
49
- const redrawPrompt = (maskedBuffer, textPrompt) => {
50
- process.stdout.clearLine(0);
51
- process.stdout.cursorTo(0);
52
- process.stdout.write(textPrompt + maskChar.repeat(maskedBuffer.length));
53
- };
54
- });
55
- }
56
- return terminal.question(prompt);
57
- }
58
- function renderPromptUI(params) {
59
- const {
60
- title,
61
- hint = "",
62
- hintPlaceholderColor = "blue",
63
- content = "",
64
- contentColor = "dim",
65
- contentTypography = "italic",
66
- contentVariant = "none",
67
- titleColor = "cyan",
68
- titleTypography = "none",
69
- titleVariant = "none",
70
- borderColor = "dim",
71
- placeholder = "",
72
- userInput,
73
- errorMessage,
74
- symbol = "step_active",
75
- customSymbol = "",
76
- symbolColor = "cyan",
77
- shouldStream = false,
78
- streamDelay = 30
79
- } = params;
80
- const type = errorMessage !== "" ? "M_ERROR" : "M_GENERAL";
81
- if (shouldStream) {
82
- return new Promise((resolve) => {
83
- msg({
84
- type,
85
- title: "",
86
- titleColor,
87
- titleTypography,
88
- titleVariant,
89
- content: "",
90
- contentColor,
91
- contentTypography,
92
- contentVariant,
93
- borderColor,
94
- hint,
95
- hintPlaceholderColor,
96
- placeholder: userInput === "" ? placeholder : "",
97
- errorMessage,
98
- symbol,
99
- customSymbol,
100
- symbolColor
101
- });
102
- void streamText({
103
- text: title || "",
104
- delay: streamDelay,
105
- color: titleColor,
106
- newline: false
107
- }).then(async () => {
108
- msgUndoAll();
109
- msg({
110
- type,
111
- title,
112
- titleColor,
113
- titleTypography,
114
- titleVariant,
115
- content: "",
116
- contentColor,
117
- contentTypography,
118
- contentVariant,
119
- borderColor,
120
- hint,
121
- hintPlaceholderColor,
122
- placeholder: userInput === "" ? placeholder : "",
123
- errorMessage,
124
- symbol,
125
- customSymbol,
126
- symbolColor
127
- });
128
- if (content) {
129
- await streamText({
130
- text: content,
131
- delay: streamDelay,
132
- color: contentColor,
133
- newline: false
134
- });
135
- }
136
- msgUndoAll();
137
- deleteLastLine();
138
- msg({
139
- type,
140
- title,
141
- titleColor,
142
- titleTypography,
143
- titleVariant,
144
- content,
145
- contentColor,
146
- contentTypography,
147
- contentVariant,
148
- borderColor,
149
- hint,
150
- hintPlaceholderColor,
151
- placeholder: userInput === "" ? placeholder : "",
152
- errorMessage,
153
- symbol,
154
- customSymbol,
155
- symbolColor
156
- });
157
- resolve();
158
- });
159
- });
160
- }
161
- msg({
162
- type,
163
- title,
164
- titleColor,
165
- titleTypography,
166
- titleVariant,
167
- content,
168
- contentColor,
169
- contentTypography,
170
- contentVariant,
171
- borderColor,
172
- hint,
173
- hintPlaceholderColor,
174
- placeholder: userInput === "" ? placeholder : "",
175
- errorMessage,
176
- symbol,
177
- customSymbol,
178
- symbolColor
179
- });
180
- if (userInput !== "") {
181
- msg({ type: "M_MIDDLE", title: ` ${userInput}` });
182
- }
183
- return Promise.resolve();
184
- }
185
- async function validateInput(input, validate) {
186
- let isValid = true;
187
- let errorMessage = "";
188
- if (validate && isValid) {
189
- const validationResult = await validate(input);
190
- if (typeof validationResult === "string") {
191
- isValid = false;
192
- errorMessage = validationResult;
193
- } else if (validationResult === false) {
194
- isValid = false;
195
- errorMessage = "Invalid input.";
196
- }
197
- }
198
- return { isValid, errorMessage };
199
- }
200
- export async function inputPrompt(options) {
201
- const {
202
- title,
203
- message,
204
- // Alias for title
205
- hint,
206
- hintPlaceholderColor = "blue",
207
- validate,
208
- defaultValue = "",
209
- initialValue,
210
- // Alias for defaultValue
211
- titleColor = "cyan",
212
- titleTypography = "none",
213
- titleVariant = "none",
214
- content,
215
- contentColor = "dim",
216
- contentTypography = "italic",
217
- contentVariant = "none",
218
- borderColor = "dim",
219
- placeholder,
220
- hardcoded,
221
- endTitle = "",
222
- endTitleColor = "dim",
223
- border = true,
224
- symbol,
225
- customSymbol,
226
- symbolColor,
227
- mode = "plain",
228
- mask,
229
- shouldStream = false,
230
- streamDelay = 20
231
- } = options;
232
- const finalTitle = message && title ? `${title}: ${message}` : message ?? title ?? "Input";
233
- const finalDefaultValue = defaultValue ?? initialValue;
234
- const terminal = readline.createInterface({
235
- input: process.stdin,
236
- output: process.stdout
237
- });
238
- async function endPrompt(isCtrlC) {
239
- await completePrompt(
240
- "input",
241
- isCtrlC,
242
- endTitle,
243
- endTitleColor,
244
- titleTypography,
245
- titleVariant,
246
- border,
247
- borderColor,
248
- void 0,
249
- false
250
- );
251
- terminal.close();
252
- if (isCtrlC) {
253
- process.exit(0);
254
- }
255
- }
256
- terminal.on("SIGINT", () => {
257
- void endPrompt(true);
258
- });
259
- let currentInput = hardcoded?.userInput ?? "";
260
- let errorMessage = hardcoded?.errorMessage ?? "";
261
- let showPlaceholder = hardcoded?.showPlaceholder ?? true;
262
- let isRerender = false;
263
- async function handleHardcodedInput() {
264
- msgUndoAll();
265
- await renderPromptUI({
266
- title: finalTitle,
267
- hint,
268
- hintPlaceholderColor,
269
- content,
270
- contentColor,
271
- contentTypography,
272
- contentVariant,
273
- titleColor,
274
- titleTypography,
275
- titleVariant,
276
- borderColor,
277
- placeholder: showPlaceholder ? placeholder : "",
278
- userInput: currentInput,
279
- errorMessage,
280
- border,
281
- symbol,
282
- customSymbol,
283
- symbolColor,
284
- mask,
285
- shouldStream,
286
- streamDelay
287
- });
288
- const finalAnswer = currentInput || finalDefaultValue;
289
- const validated = await validateInput(finalAnswer, validate);
290
- if (!validated.isValid) {
291
- terminal.close();
292
- throw new Error(validated.errorMessage || "Invalid input.");
293
- }
294
- msg({ type: "M_MIDDLE", title: ` ${finalAnswer}` });
295
- msg({ type: "M_BAR", borderColor });
296
- terminal.close();
297
- return finalAnswer;
298
- }
299
- if (hardcoded?.userInput !== void 0) {
300
- return handleHardcodedInput();
301
- }
302
- while (true) {
303
- if (isRerender) {
304
- msgUndoAll();
305
- }
306
- const displayedUserInput = mode === "password" ? getMaskChar(mask).repeat(currentInput.length) : currentInput;
307
- if (errorMessage) {
308
- deleteLastLine();
309
- deleteLastLine();
310
- }
311
- await renderPromptUI({
312
- title: finalTitle,
313
- hint,
314
- hintPlaceholderColor,
315
- content,
316
- contentColor,
317
- contentTypography,
318
- contentVariant,
319
- titleColor,
320
- titleTypography,
321
- titleVariant,
322
- borderColor,
323
- placeholder: showPlaceholder ? placeholder : "",
324
- userInput: displayedUserInput,
325
- errorMessage,
326
- border,
327
- symbol,
328
- customSymbol,
329
- symbolColor,
330
- mask,
331
- shouldStream,
332
- streamDelay
333
- });
334
- if (errorMessage) {
335
- deleteLastLine();
336
- }
337
- const formattedBar = bar({ borderColor });
338
- const userInputRaw = await ask(terminal, `${formattedBar} `, mode, mask);
339
- isRerender = true;
340
- if (userInputRaw === null) {
341
- return "";
342
- }
343
- currentInput = userInputRaw.trim();
344
- if (showPlaceholder && currentInput !== "") {
345
- showPlaceholder = false;
346
- }
347
- const finalAnswer = currentInput || finalDefaultValue;
348
- const validated = await validateInput(finalAnswer, validate);
349
- if (validated.isValid) {
350
- if (!currentInput && finalDefaultValue) {
351
- if (mode === "password") {
352
- deleteLastLine();
353
- deleteLastLine();
354
- msg({
355
- type: "M_MIDDLE",
356
- title: ` ${getMaskChar(mask).repeat(finalDefaultValue.length)}`
357
- });
358
- } else {
359
- deleteLastLine();
360
- msg({ type: "M_MIDDLE", title: ` ${re.reset(finalDefaultValue)}` });
361
- }
362
- }
363
- if (errorMessage) {
364
- deleteLastLine();
365
- }
366
- msg({ type: "M_BAR", borderColor });
367
- terminal.close();
368
- return finalAnswer;
369
- }
370
- errorMessage = validated.errorMessage;
371
- }
372
- }
@@ -1,2 +0,0 @@
1
- export declare const startPrompt: any;
2
- export declare const intro: any;
@@ -1,3 +0,0 @@
1
- import { introPrompt } from "./intro-mod.js";
2
- export const startPrompt = introPrompt;
3
- export const intro = introPrompt;
@@ -1,20 +0,0 @@
1
- import type { Fonts } from "figlet";
2
- import type { PreventWrongTerminalSizeOptions, PromptOptions } from "../../types.js";
3
- type StartPromptOptions = PromptOptions & {
4
- clearConsole?: boolean;
5
- horizontalLine?: boolean;
6
- horizontalLineLength?: number;
7
- packageName?: string;
8
- packageVersion?: string;
9
- terminalSizeOptions?: PreventWrongTerminalSizeOptions;
10
- isDev?: boolean;
11
- prevent?: {
12
- unsupportedTTY?: boolean;
13
- wrongTerminalSize?: boolean;
14
- windowsHomeDirRoot?: boolean;
15
- };
16
- variant?: "header" | "ascii-art";
17
- asciiArtFont?: Fonts;
18
- };
19
- export declare function introPrompt(optionsOrTitle: StartPromptOptions | string): Promise<void>;
20
- export {};
@@ -1,81 +0,0 @@
1
- import { relinka } from "@reliverse/relinka";
2
- import { getCurrentTerminalName } from "@reliverse/runtime";
3
- import { msg } from "../msg-fmt/messages.js";
4
- import {
5
- getExactTerminalWidth,
6
- getTerminalHeight,
7
- getTerminalWidth
8
- } from "../msg-fmt/terminal.js";
9
- import {
10
- preventWrongTerminalSize,
11
- preventWindowsHomeDirRoot,
12
- preventUnsupportedTTY
13
- } from "../utils/prevent.js";
14
- import { pm, reliversePrompts } from "../utils/system.js";
15
- import { createAsciiArt } from "../visual/visual-mod.js";
16
- export async function introPrompt(optionsOrTitle) {
17
- const options = typeof optionsOrTitle === "string" ? { title: optionsOrTitle } : optionsOrTitle;
18
- const {
19
- title = "",
20
- titleColor = "inverse",
21
- titleTypography = "none",
22
- titleVariant,
23
- borderColor = "dim",
24
- clearConsole = false,
25
- horizontalLine = true,
26
- horizontalLineLength: initialHorizontalLineLength = 0,
27
- packageName = reliversePrompts.name,
28
- packageVersion = reliversePrompts.version,
29
- terminalSizeOptions = {},
30
- isDev = false,
31
- prevent = {
32
- unsupportedTTY: true,
33
- wrongTerminalSize: true,
34
- windowsHomeDirRoot: true
35
- },
36
- variant = "header",
37
- asciiArtFont
38
- } = options;
39
- let horizontalLineLength = initialHorizontalLineLength;
40
- if (prevent.windowsHomeDirRoot) {
41
- preventWindowsHomeDirRoot(process.cwd());
42
- }
43
- if (prevent.unsupportedTTY) {
44
- preventUnsupportedTTY();
45
- }
46
- if (prevent.wrongTerminalSize) {
47
- await preventWrongTerminalSize({ ...terminalSizeOptions, isDev });
48
- }
49
- const terminalWidth = getTerminalWidth();
50
- const exactTerminalWidth = getExactTerminalWidth();
51
- const terminalHeight = getTerminalHeight();
52
- const formattedTitle = title !== "" ? title : `${packageName} v${packageVersion} | ${pm.packageManager} v${pm.version} | ${getCurrentTerminalName()}${isDev && terminalWidth > 80 ? ` | isDev | w${terminalWidth} h${terminalHeight}` : ""}`;
53
- if (variant === "ascii-art") {
54
- await createAsciiArt({
55
- message: formattedTitle,
56
- font: asciiArtFont,
57
- clearConsole
58
- });
59
- return;
60
- }
61
- if (horizontalLineLength === 0) {
62
- const titleFullLength = titleColor === "inverse" ? `\u2800${formattedTitle}\u2800`.length + 5 : formattedTitle.length + 5;
63
- horizontalLineLength = Math.max(1, exactTerminalWidth - titleFullLength);
64
- }
65
- if (clearConsole) {
66
- relinka("clear", "");
67
- relinka("log", "");
68
- } else {
69
- relinka("log", "");
70
- }
71
- msg({
72
- type: "M_START",
73
- title: titleColor === "inverse" ? `\u2800${formattedTitle}\u2800` : formattedTitle,
74
- titleColor,
75
- titleTypography,
76
- ...titleVariant ? { titleVariant } : {},
77
- borderColor,
78
- horizontalLine,
79
- horizontalLineLength
80
- });
81
- }
@@ -1,18 +0,0 @@
1
- import type { Command } from "./launcher-types.js";
2
- /**
3
- * Load a command from the filesystem.
4
- *
5
- * @param cmdPath - Path to the command file or directory containing cmd.ts/cmd.js
6
- * @returns Promise<Command> - The loaded command
7
- *
8
- * @example
9
- * ```ts
10
- * // Load a command
11
- * const cmd = await loadCommand("./web/cmd");
12
- *
13
- * // Use with runCmd - pass args as separate array elements
14
- * await runCmd(cmd, ["--dev", "true"]); // ✅ Correct
15
- * await runCmd(cmd, [`--dev ${isDev}`]); // ❌ Wrong - creates single string
16
- * ```
17
- */
18
- export declare function loadCommand(cmdPath: string): Promise<Command>;
@@ -1,79 +0,0 @@
1
- import { resolve, dirname } from "@reliverse/pathkit";
2
- import fs from "@reliverse/relifso";
3
- import { relinka } from "@reliverse/relinka";
4
- import { createJiti } from "jiti";
5
- import process from "node:process";
6
- const jiti = createJiti(import.meta.url, {
7
- debug: process.env.NODE_ENV === "development",
8
- fsCache: true,
9
- sourceMaps: true
10
- });
11
- const COMMAND_EXTENSIONS = [".ts", ".js"];
12
- const COMMAND_FILENAMES = ["cmd.ts", "cmd.js"];
13
- const getCallerDirectory = () => {
14
- const stack = new Error().stack?.split("\n") ?? [];
15
- for (const line of stack) {
16
- const match = /\((.*):(\d+):(\d+)\)/.exec(line) || /at (.*):(\d+):(\d+)/.exec(line);
17
- if (match?.[1]) {
18
- const filePath = match[1];
19
- if (!filePath.includes("run-command") && !filePath.includes("@reliverse/rempts") && !filePath.includes("node_modules") && !filePath.includes("command-runner") && !filePath.includes("command-typed") && !filePath.includes("launcher-mod") && !filePath.includes("launcher-types")) {
20
- return dirname(filePath);
21
- }
22
- }
23
- }
24
- return process.cwd();
25
- };
26
- const tryLoadCommand = async (path) => {
27
- if (!await fs.pathExists(path)) return null;
28
- try {
29
- const cmd = await jiti.import(path, { default: true });
30
- return cmd;
31
- } catch {
32
- relinka("verbose", `Failed to load ${path} as a command file`);
33
- return null;
34
- }
35
- };
36
- const generateCandidatePaths = async (resolvedPath) => {
37
- if (!await fs.pathExists(resolvedPath)) {
38
- return COMMAND_EXTENSIONS.map((ext) => `${resolvedPath}${ext}`);
39
- }
40
- if (await fs.isDirectory(resolvedPath)) {
41
- return COMMAND_FILENAMES.map((filename) => resolve(resolvedPath, filename));
42
- }
43
- return [resolvedPath];
44
- };
45
- const createCommandNotFoundError = (cmdPath, searchedPaths) => new Error(
46
- `No command file found for "${cmdPath}". Expected to find either:
47
- - A valid command file at the specified path
48
- - A directory containing cmd.ts or cmd.js
49
- - A file path that can be resolved with .ts or .js extension
50
- Searched paths: ${searchedPaths.join(", ")}
51
- Please ensure one of these exists and exports a default command.`
52
- );
53
- const createLoadError = (cmdPath, originalError) => new Error(
54
- `Failed to load command from "${cmdPath}"
55
- For developers: Ensure the command file:
56
- - Exists and is accessible
57
- - Exports a default command (e.g., export default defineCommand({...}))
58
- - Is a valid TypeScript/JavaScript module
59
- Original error: ${originalError instanceof Error ? originalError.message : String(originalError)}`
60
- );
61
- export async function loadCommand(cmdPath) {
62
- try {
63
- const callerDir = getCallerDirectory();
64
- const normalizedPath = cmdPath.replace(/^\.\//, "");
65
- const resolvedPath = resolve(callerDir, normalizedPath);
66
- const candidatePaths = await generateCandidatePaths(resolvedPath);
67
- for (const path of candidatePaths) {
68
- const command = await tryLoadCommand(path);
69
- if (command) return command;
70
- }
71
- throw createCommandNotFoundError(cmdPath, candidatePaths);
72
- } catch (error) {
73
- if (error instanceof Error && error.message.includes("No command file found")) {
74
- throw error;
75
- }
76
- relinka("error", `Failed to load command from ${cmdPath}:`, error);
77
- throw createLoadError(cmdPath, error);
78
- }
79
- }
@@ -1,16 +0,0 @@
1
- import type { Command } from "./launcher-types";
2
- /**
3
- * Static implementation functions for the typed command system.
4
- * These functions are imported by the generated cmds.ts file.
5
- */
6
- export declare function argsToStringArray(args: Record<string, unknown>): string[];
7
- export declare function createCallCmd<TCommandArgsMap>(): Promise<(<T extends keyof TCommandArgsMap>(cmdName: T, args?: TCommandArgsMap[T]) => Promise<void>)>;
8
- export declare function createGetTypedCmd<TCommandArgsMap>(): Promise<(<T extends keyof TCommandArgsMap>(cmdName: T) => Promise<{
9
- command: Command;
10
- run: (args?: TCommandArgsMap[T]) => Promise<void>;
11
- }>)>;
12
- export declare function callCmdImpl<TCommandArgsMap>(cmdName: keyof TCommandArgsMap, args?: TCommandArgsMap[keyof TCommandArgsMap]): Promise<void>;
13
- export declare function getTypedCmdImpl<TCommandArgsMap>(cmdName: keyof TCommandArgsMap): Promise<{
14
- command: Command;
15
- run: (args?: TCommandArgsMap[keyof TCommandArgsMap]) => Promise<void>;
16
- }>;
@@ -1,60 +0,0 @@
1
- import { loadCommand } from "./command-runner.js";
2
- import { runCmd } from "./launcher-mod.js";
3
- export function argsToStringArray(args) {
4
- const result = [];
5
- for (const [key, value] of Object.entries(args)) {
6
- if (value === void 0 || value === null) continue;
7
- if (typeof value === "boolean") {
8
- result.push(`--${key}=${value}`);
9
- } else if (Array.isArray(value)) {
10
- result.push(`--${key}=${value.join(",")}`);
11
- } else {
12
- result.push(`--${key}=${String(value)}`);
13
- }
14
- }
15
- return result;
16
- }
17
- export async function createCallCmd() {
18
- return async function callCmd(cmdName, args) {
19
- try {
20
- const command = await loadCommand(cmdName);
21
- const stringArgs = args ? argsToStringArray(args) : [];
22
- await runCmd(command, stringArgs);
23
- } catch (error) {
24
- console.error(`Error running command '${String(cmdName)}':`, error);
25
- throw error;
26
- }
27
- };
28
- }
29
- export async function createGetTypedCmd() {
30
- return async function getTypedCmd(cmdName) {
31
- const command = await loadCommand(cmdName);
32
- return {
33
- command,
34
- run: async (args) => {
35
- const stringArgs = args ? argsToStringArray(args) : [];
36
- await runCmd(command, stringArgs);
37
- }
38
- };
39
- };
40
- }
41
- export async function callCmdImpl(cmdName, args) {
42
- try {
43
- const command = await loadCommand(cmdName);
44
- const stringArgs = args ? argsToStringArray(args) : [];
45
- await runCmd(command, stringArgs);
46
- } catch (error) {
47
- console.error(`Error running command '${String(cmdName)}':`, error);
48
- throw error;
49
- }
50
- }
51
- export async function getTypedCmdImpl(cmdName) {
52
- const command = await loadCommand(cmdName);
53
- return {
54
- command,
55
- run: async (args) => {
56
- const stringArgs = args ? argsToStringArray(args) : [];
57
- await runCmd(command, stringArgs);
58
- }
59
- };
60
- }
@@ -1,2 +0,0 @@
1
- import { createCli } from "./launcher-mod";
2
- export declare const runMain: typeof createCli;
@@ -1,2 +0,0 @@
1
- import { createCli } from "./launcher-mod.js";
2
- export const runMain = createCli;