@reliverse/rempts 1.7.64 → 1.7.65
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/bin/libs/date/date.js +41 -1
- package/bin/libs/figures/figures-mod.d.ts +2 -2
- package/bin/libs/input/input-mod.js +39 -41
- package/bin/libs/number/number-mod.js +41 -1
- package/bin/libs/select/nummultiselect-prompt.d.ts +1 -1
- package/bin/libs/select/nummultiselect-prompt.js +41 -1
- package/package.json +4 -4
package/bin/libs/date/date.js
CHANGED
|
@@ -44,6 +44,46 @@ const regexYYYYMMDD = buildRegExp([
|
|
|
44
44
|
// DD
|
|
45
45
|
endOfString
|
|
46
46
|
]);
|
|
47
|
+
async function askForInput(prompt) {
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
let buffer = "";
|
|
50
|
+
process.stdout.write(prompt);
|
|
51
|
+
const onData = (data) => {
|
|
52
|
+
const str = data.toString("utf-8");
|
|
53
|
+
for (const char of str) {
|
|
54
|
+
if (char === "\n" || char === "\r") {
|
|
55
|
+
process.stdout.write("\n");
|
|
56
|
+
cleanup();
|
|
57
|
+
resolve(buffer);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (char === "") {
|
|
61
|
+
cleanup();
|
|
62
|
+
resolve(null);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (char === "\x7F" || char === "\b") {
|
|
66
|
+
if (buffer.length > 0) {
|
|
67
|
+
buffer = buffer.slice(0, -1);
|
|
68
|
+
}
|
|
69
|
+
redrawPrompt(buffer, prompt);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
buffer += char;
|
|
73
|
+
redrawPrompt(buffer, prompt);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
process.stdin.on("data", onData);
|
|
77
|
+
const cleanup = () => {
|
|
78
|
+
process.stdin.removeListener("data", onData);
|
|
79
|
+
};
|
|
80
|
+
const redrawPrompt = (inputBuffer, textPrompt) => {
|
|
81
|
+
process.stdout.clearLine(0);
|
|
82
|
+
process.stdout.cursorTo(0);
|
|
83
|
+
process.stdout.write(textPrompt + inputBuffer);
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
47
87
|
export async function datePrompt(opts) {
|
|
48
88
|
const {
|
|
49
89
|
title = "",
|
|
@@ -115,7 +155,7 @@ export async function datePrompt(opts) {
|
|
|
115
155
|
deleteLastLine();
|
|
116
156
|
deleteLastLine();
|
|
117
157
|
}
|
|
118
|
-
const answerInput = await
|
|
158
|
+
const answerInput = await askForInput(`${re.dim(symbols.middle)} `);
|
|
119
159
|
if (answerInput === null) {
|
|
120
160
|
rl.close();
|
|
121
161
|
if (endTitle !== "") {
|
|
@@ -229,7 +229,7 @@ export declare const mainSymbols: {
|
|
|
229
229
|
lineSlash: string;
|
|
230
230
|
};
|
|
231
231
|
export declare const fallbackSymbols: Record<string, string>;
|
|
232
|
-
export declare const figures: {
|
|
232
|
+
export declare const figures: Record<string, string> | {
|
|
233
233
|
tick: string;
|
|
234
234
|
info: string;
|
|
235
235
|
warning: string;
|
|
@@ -458,4 +458,4 @@ export declare const figures: {
|
|
|
458
458
|
lineCross: string;
|
|
459
459
|
lineBackslash: string;
|
|
460
460
|
lineSlash: string;
|
|
461
|
-
}
|
|
461
|
+
};
|
|
@@ -11,49 +11,47 @@ function getMaskChar(customMask) {
|
|
|
11
11
|
if (!unicode) return "*";
|
|
12
12
|
return customMask ?? S_MASK;
|
|
13
13
|
}
|
|
14
|
-
async function ask(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
buffer = buffer.slice(0, -1);
|
|
37
|
-
}
|
|
38
|
-
redrawPrompt(buffer, prompt);
|
|
39
|
-
continue;
|
|
14
|
+
async function ask(prompt, mode, mask) {
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
let buffer = "";
|
|
17
|
+
const maskChar = getMaskChar(mask);
|
|
18
|
+
process.stdout.write(prompt);
|
|
19
|
+
const onData = (data) => {
|
|
20
|
+
const str = data.toString("utf-8");
|
|
21
|
+
for (const char of str) {
|
|
22
|
+
if (char === "\n" || char === "\r") {
|
|
23
|
+
process.stdout.write("\n");
|
|
24
|
+
cleanup();
|
|
25
|
+
resolve(buffer);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (char === "") {
|
|
29
|
+
cleanup();
|
|
30
|
+
resolve(null);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (char === "\x7F" || char === "\b") {
|
|
34
|
+
if (buffer.length > 0) {
|
|
35
|
+
buffer = buffer.slice(0, -1);
|
|
40
36
|
}
|
|
41
|
-
buffer += char;
|
|
42
37
|
redrawPrompt(buffer, prompt);
|
|
38
|
+
continue;
|
|
43
39
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
buffer += char;
|
|
41
|
+
redrawPrompt(buffer, prompt);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
process.stdin.on("data", onData);
|
|
45
|
+
const cleanup = () => {
|
|
46
|
+
process.stdin.removeListener("data", onData);
|
|
47
|
+
};
|
|
48
|
+
const redrawPrompt = (inputBuffer, textPrompt) => {
|
|
49
|
+
process.stdout.clearLine(0);
|
|
50
|
+
process.stdout.cursorTo(0);
|
|
51
|
+
const displayText = mode === "password" ? maskChar.repeat(inputBuffer.length) : inputBuffer;
|
|
52
|
+
process.stdout.write(textPrompt + displayText);
|
|
53
|
+
};
|
|
54
|
+
});
|
|
57
55
|
}
|
|
58
56
|
function renderPromptUI(params) {
|
|
59
57
|
const {
|
|
@@ -335,7 +333,7 @@ export async function inputPrompt(options) {
|
|
|
335
333
|
deleteLastLine();
|
|
336
334
|
}
|
|
337
335
|
const formattedBar = bar({ borderColor });
|
|
338
|
-
const userInputRaw = await ask(
|
|
336
|
+
const userInputRaw = await ask(`${formattedBar} `, mode, mask);
|
|
339
337
|
isRerender = true;
|
|
340
338
|
if (userInputRaw === null) {
|
|
341
339
|
return "";
|
|
@@ -2,6 +2,46 @@ import { stdin as input, stdout as output } from "node:process";
|
|
|
2
2
|
import readline from "node:readline/promises";
|
|
3
3
|
import { bar, msg } from "../msg-fmt/messages.js";
|
|
4
4
|
import { deleteLastLine, deleteLastLines } from "../msg-fmt/terminal.js";
|
|
5
|
+
async function askForInput(prompt) {
|
|
6
|
+
return new Promise((resolve) => {
|
|
7
|
+
let buffer = "";
|
|
8
|
+
process.stdout.write(prompt);
|
|
9
|
+
const onData = (data) => {
|
|
10
|
+
const str = data.toString("utf-8");
|
|
11
|
+
for (const char of str) {
|
|
12
|
+
if (char === "\n" || char === "\r") {
|
|
13
|
+
process.stdout.write("\n");
|
|
14
|
+
cleanup();
|
|
15
|
+
resolve(buffer);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (char === "") {
|
|
19
|
+
cleanup();
|
|
20
|
+
resolve(null);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (char === "\x7F" || char === "\b") {
|
|
24
|
+
if (buffer.length > 0) {
|
|
25
|
+
buffer = buffer.slice(0, -1);
|
|
26
|
+
}
|
|
27
|
+
redrawPrompt(buffer, prompt);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
buffer += char;
|
|
31
|
+
redrawPrompt(buffer, prompt);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
process.stdin.on("data", onData);
|
|
35
|
+
const cleanup = () => {
|
|
36
|
+
process.stdin.removeListener("data", onData);
|
|
37
|
+
};
|
|
38
|
+
const redrawPrompt = (inputBuffer, textPrompt) => {
|
|
39
|
+
process.stdout.clearLine(0);
|
|
40
|
+
process.stdout.cursorTo(0);
|
|
41
|
+
process.stdout.write(textPrompt + inputBuffer);
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
5
45
|
function renderPromptUI(params) {
|
|
6
46
|
const {
|
|
7
47
|
title,
|
|
@@ -135,7 +175,7 @@ export async function numberPrompt(opts) {
|
|
|
135
175
|
isRerender
|
|
136
176
|
});
|
|
137
177
|
const formattedBar = bar({ borderColor });
|
|
138
|
-
const answerInput = await
|
|
178
|
+
const answerInput = await askForInput(`${formattedBar} `);
|
|
139
179
|
isRerender = true;
|
|
140
180
|
if (answerInput === null) {
|
|
141
181
|
if (endTitle !== "") {
|
|
@@ -2,5 +2,5 @@ import type { PromptOptions } from "../../types";
|
|
|
2
2
|
type NumMultiSelectPromptOptions = PromptOptions & {
|
|
3
3
|
defaultValue?: string[];
|
|
4
4
|
};
|
|
5
|
-
export declare function numMultiSelectPrompt(opts: NumMultiSelectPromptOptions): Promise<
|
|
5
|
+
export declare function numMultiSelectPrompt(opts: NumMultiSelectPromptOptions): Promise<string[]>;
|
|
6
6
|
export {};
|
|
@@ -3,6 +3,46 @@ import readline from "node:readline/promises";
|
|
|
3
3
|
import { re } from "@reliverse/relico";
|
|
4
4
|
import { bar, fmt, msg } from "../msg-fmt/messages.js";
|
|
5
5
|
import { countLines, deleteLastLine, deleteLastLines } from "../msg-fmt/terminal.js";
|
|
6
|
+
async function askForInput(prompt) {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
let buffer = "";
|
|
9
|
+
process.stdout.write(prompt);
|
|
10
|
+
const onData = (data) => {
|
|
11
|
+
const str = data.toString("utf-8");
|
|
12
|
+
for (const char of str) {
|
|
13
|
+
if (char === "\n" || char === "\r") {
|
|
14
|
+
process.stdout.write("\n");
|
|
15
|
+
cleanup();
|
|
16
|
+
resolve(buffer);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (char === "") {
|
|
20
|
+
cleanup();
|
|
21
|
+
resolve(null);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (char === "\x7F" || char === "\b") {
|
|
25
|
+
if (buffer.length > 0) {
|
|
26
|
+
buffer = buffer.slice(0, -1);
|
|
27
|
+
}
|
|
28
|
+
redrawPrompt(buffer, prompt);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
buffer += char;
|
|
32
|
+
redrawPrompt(buffer, prompt);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
process.stdin.on("data", onData);
|
|
36
|
+
const cleanup = () => {
|
|
37
|
+
process.stdin.removeListener("data", onData);
|
|
38
|
+
};
|
|
39
|
+
const redrawPrompt = (inputBuffer, textPrompt) => {
|
|
40
|
+
process.stdout.clearLine(0);
|
|
41
|
+
process.stdout.cursorTo(0);
|
|
42
|
+
process.stdout.write(textPrompt + inputBuffer);
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
6
46
|
export async function numMultiSelectPrompt(opts) {
|
|
7
47
|
const {
|
|
8
48
|
title = "",
|
|
@@ -64,7 +104,7 @@ ${formattedBar} `;
|
|
|
64
104
|
});
|
|
65
105
|
const questionLines = countLines(formattedPrompt);
|
|
66
106
|
linesToDelete = questionLines + 1;
|
|
67
|
-
const answer = (await
|
|
107
|
+
const answer = (await askForInput(`${formattedPrompt} `))?.trim() || "";
|
|
68
108
|
if (!answer && defaultValue !== void 0) {
|
|
69
109
|
deleteLastLine();
|
|
70
110
|
msg({
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"@reliverse/relico": "^1.4.0",
|
|
4
4
|
"@reliverse/relinka": "^1.6.1",
|
|
5
5
|
"@reliverse/reltime": "^1.1.1",
|
|
6
|
-
"ansi-escapes": "^7.
|
|
6
|
+
"ansi-escapes": "^7.1.0",
|
|
7
7
|
"cli-cursor": "^5.0.0",
|
|
8
8
|
"cli-spinners": "^3.2.0",
|
|
9
9
|
"gradient-string": "^3.0.0",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"sisteransi": "^1.0.5",
|
|
17
17
|
"stdin-discarder": "^0.2.2",
|
|
18
18
|
"string-width": "^8.1.0",
|
|
19
|
-
"strip-ansi": "^7.1.
|
|
19
|
+
"strip-ansi": "^7.1.2",
|
|
20
20
|
"terminal-size": "^4.0.0",
|
|
21
21
|
"ts-regex-builder": "^1.8.2",
|
|
22
|
-
"wrap-ansi": "^9.0.
|
|
22
|
+
"wrap-ansi": "^9.0.2"
|
|
23
23
|
},
|
|
24
24
|
"description": "@reliverse/rempts is a modern, type-safe toolkit for building delightful cli experiences. it's fast, flexible, and made for developer happiness. file-based commands keep things simple.",
|
|
25
25
|
"homepage": "https://docs.reliverse.org/cli",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"name": "@reliverse/rempts",
|
|
28
28
|
"type": "module",
|
|
29
|
-
"version": "1.7.
|
|
29
|
+
"version": "1.7.65",
|
|
30
30
|
"author": "reliverse",
|
|
31
31
|
"bugs": {
|
|
32
32
|
"email": "blefnk@gmail.com",
|