@wocker/utils 2.0.0 → 2.0.1-beta.1
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/codecov +0 -0
- package/codecov.SHA256SUM +1 -0
- package/codecov.SHA256SUM.sig +16 -0
- package/lib/prompts/promptConfirm.js +8 -4
- package/lib/prompts/promptInput.js +4 -13
- package/lib/prompts/promptSelect.js +5 -14
- package/lib/tools/prepareMessage.d.ts +2 -0
- package/lib/tools/prepareMessage.js +15 -0
- package/lib/tools/prepareValue.d.ts +2 -0
- package/lib/tools/prepareValue.js +20 -0
- package/lib/types/Theme.d.ts +1 -0
- package/package.json +1 -1
package/codecov
ADDED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0f7aadde579ebde1443ad2f977beada703f562997fdda603f213faf2a8559868 codecov
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-----BEGIN PGP SIGNATURE-----
|
|
2
|
+
|
|
3
|
+
iQIzBAABCgAdFiEEJwNOf9uFDgu8LGL/gGuyiu13mGkFAmf1418ACgkQgGuyiu13
|
|
4
|
+
mGke3w/8DpgS1CDxKdV50CKy81LmiA995bEw2ePBRc90JzNrGX7m2JcFQr/GUITs
|
|
5
|
+
JofhfQ6sxnvLLxTLAyiMI8Tcbr2yN/BIjBERIhN8b20zL3KGY6kVS85czQdPs0a7
|
|
6
|
+
BlY3xp7VgCv24E/SWc0m367GvBjVnanhMg+hIoaK4HQpWOx+93GzaGZWCnISl6yh
|
|
7
|
+
Zn13zn/b/oXwvd3iekh3qb918kPwq3F3Ufd8gHLf71gH0usDoRIUwVIMYMjuoMeI
|
|
8
|
+
ceIjZYe1BLG+hNAUkqboi1GK8IJQH66hwyB82KQxUZG0zEOTwhbvFrIijR30BSk6
|
|
9
|
+
KROFxxe8s1kuEZGI/zhKPXkYkjiIdXQQvMP7emsQeLQljRb2k3prUhHw7LyFTPla
|
|
10
|
+
KRK9MX1BoLr1Iol0Py/y8luSBCNvAmeCmbh6uGWS/1SJ/mj6CiZibWIO40qH9NJI
|
|
11
|
+
wDY/JHrTHA2W2EsvREegny7znurxk1ORwT2scEJobu/NiLQEvpz6fvHaKiBcX45z
|
|
12
|
+
53pv1v0xlTFCEF6Vfg2geywIk4Dfi4l7dxyG9hyHtb1lQ0zwcz9KaAPhMjiJCUPa
|
|
13
|
+
zGh0nN/xgkD9u7TNhOW3vG01R/wNW5BF+E8+04AO+RroV230m+a/e958I6pCd9M+
|
|
14
|
+
N6FtNND7ZyIVoHiVA/v/tWc+ODZ5b9K8Q1Y6a0jkCbFZ3ZeCrPI=
|
|
15
|
+
=onSD
|
|
16
|
+
-----END PGP SIGNATURE-----
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.promptConfirm = void 0;
|
|
13
13
|
const core_1 = require("@inquirer/core");
|
|
14
14
|
const validatePrompt_1 = require("../validation/validatePrompt");
|
|
15
|
+
const prepareMessage_1 = require("../tools/prepareMessage");
|
|
15
16
|
exports.promptConfirm = (0, core_1.createPrompt)((config, done) => {
|
|
16
17
|
const { message = "Confirm", default: defaultValue = false } = config;
|
|
17
18
|
const [status, setStatus] = (0, core_1.useState)("idle"), [inputValue, setInputValue] = (0, core_1.useState)(""), [error, setError] = (0, core_1.useState)(""), icon = (0, core_1.usePrefix)({ status });
|
|
@@ -27,7 +28,11 @@ exports.promptConfirm = (0, core_1.createPrompt)((config, done) => {
|
|
|
27
28
|
}
|
|
28
29
|
return defaultValue;
|
|
29
30
|
}, [inputValue, defaultValue]);
|
|
30
|
-
const theme = (0, core_1.makeTheme)({
|
|
31
|
+
const theme = (0, core_1.makeTheme)({
|
|
32
|
+
style: {
|
|
33
|
+
message: prepareMessage_1.prepareMessage
|
|
34
|
+
}
|
|
35
|
+
}, config.theme);
|
|
31
36
|
(0, core_1.useKeypress)((key, readline) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
37
|
setStatus("idle");
|
|
33
38
|
setError("");
|
|
@@ -62,9 +67,8 @@ exports.promptConfirm = (0, core_1.createPrompt)((config, done) => {
|
|
|
62
67
|
return [
|
|
63
68
|
[
|
|
64
69
|
`${icon} `,
|
|
65
|
-
theme.style.message(message, status),
|
|
66
|
-
" ",
|
|
67
|
-
theme.style.defaultAnswer(config.default ? "Y/n" : "y/N"),
|
|
70
|
+
theme.style.message(message, status, "?"),
|
|
71
|
+
theme.style.defaultAnswer(typeof config.default === "boolean" ? (config.default ? "Y/n" : "y/N") : "y/n"),
|
|
68
72
|
" ",
|
|
69
73
|
inputValue
|
|
70
74
|
].join(""),
|
|
@@ -8,27 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.promptInput = void 0;
|
|
16
13
|
const core_1 = require("@inquirer/core");
|
|
17
|
-
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
18
14
|
const validatePrompt_1 = require("../validation/validatePrompt");
|
|
15
|
+
const prepareMessage_1 = require("../tools/prepareMessage");
|
|
16
|
+
const prepareValue_1 = require("../tools/prepareValue");
|
|
19
17
|
exports.promptInput = (0, core_1.createPrompt)((config, done) => {
|
|
20
18
|
const { message = "Input", type = "text", step = 1, prefix = "", suffix = "", default: defaultValue } = config;
|
|
21
19
|
const theme = (0, core_1.makeTheme)({
|
|
22
20
|
style: {
|
|
23
|
-
message:
|
|
24
|
-
value:
|
|
25
|
-
switch (status) {
|
|
26
|
-
case "error":
|
|
27
|
-
return yoctocolors_cjs_1.default.red(value);
|
|
28
|
-
default:
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
21
|
+
message: prepareMessage_1.prepareMessage,
|
|
22
|
+
value: prepareValue_1.prepareValue
|
|
32
23
|
}
|
|
33
24
|
}, config.theme);
|
|
34
25
|
const [inputValue = "", setInputValue] = (0, core_1.useState)(typeof defaultValue === "number" ? defaultValue.toString() : defaultValue), [status, setStatus] = (0, core_1.useState)("idle"), [error, setError] = (0, core_1.useState)("");
|
|
@@ -19,23 +19,14 @@ const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
|
|
|
19
19
|
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
20
20
|
const tools_1 = require("../tools");
|
|
21
21
|
const validatePrompt_1 = require("../validation/validatePrompt");
|
|
22
|
+
const prepareMessage_1 = require("../tools/prepareMessage");
|
|
23
|
+
const prepareValue_1 = require("../tools/prepareValue");
|
|
22
24
|
const selectView = (config, done) => {
|
|
23
25
|
const { message = "Select", multiple, pageSize = 5, options: rawOptions = [] } = config;
|
|
24
26
|
const theme = (0, core_1.makeTheme)({
|
|
25
27
|
style: {
|
|
26
|
-
message:
|
|
27
|
-
value:
|
|
28
|
-
switch (status) {
|
|
29
|
-
case "selected":
|
|
30
|
-
return yoctocolors_cjs_1.default.green(value);
|
|
31
|
-
case "active":
|
|
32
|
-
return yoctocolors_cjs_1.default.blue(value);
|
|
33
|
-
case "done":
|
|
34
|
-
return yoctocolors_cjs_1.default.cyan(value);
|
|
35
|
-
default:
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
28
|
+
message: prepareMessage_1.prepareMessage,
|
|
29
|
+
value: prepareValue_1.prepareValue
|
|
39
30
|
}
|
|
40
31
|
}, config.theme);
|
|
41
32
|
const options = (0, core_1.useMemo)(() => {
|
|
@@ -45,7 +36,7 @@ const selectView = (config, done) => {
|
|
|
45
36
|
}
|
|
46
37
|
return options;
|
|
47
38
|
}, [rawOptions]);
|
|
48
|
-
const [status, setStatus] = (0, core_1.useState)("idle"), [showHint, setShowHint] = (0, core_1.useState)(true), [values, setValues] = (0, core_1.useState)(typeof config.default === "string" ? [config.default] : config.default || []), [active, setActive] = (0, core_1.useState)(values.length > 0 ? options.findIndex((o) => o.value === values[0]) : 0), [error, setError] = (0, core_1.useState)(""), icon = (0, core_1.usePrefix)({ theme, status });
|
|
39
|
+
const [status, setStatus] = (0, core_1.useState)("idle"), [showHint, setShowHint] = (0, core_1.useState)(true), [values, setValues] = (0, core_1.useState)(typeof config.default === "string" ? [config.default] : config.default || []), [active, setActive] = (0, core_1.useState)(values.length > 0 ? Math.max(0, options.findIndex((o) => o.value === values[0])) : 0), [error, setError] = (0, core_1.useState)(""), icon = (0, core_1.usePrefix)({ theme, status });
|
|
49
40
|
const activeOption = (0, core_1.useMemo)(() => {
|
|
50
41
|
return options[active];
|
|
51
42
|
}, [options, active]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.prepareMessage = void 0;
|
|
7
|
+
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
8
|
+
const prepareMessage = (message, _, ending = ":") => {
|
|
9
|
+
message = message.trim();
|
|
10
|
+
if (!/[?:.!,;]$/.test(message)) {
|
|
11
|
+
message += ending;
|
|
12
|
+
}
|
|
13
|
+
return yoctocolors_cjs_1.default.bold(message) + " ";
|
|
14
|
+
};
|
|
15
|
+
exports.prepareMessage = prepareMessage;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.prepareValue = void 0;
|
|
7
|
+
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
|
|
8
|
+
const prepareValue = (value, status) => {
|
|
9
|
+
switch (status) {
|
|
10
|
+
case "selected":
|
|
11
|
+
return yoctocolors_cjs_1.default.green(value);
|
|
12
|
+
case "active":
|
|
13
|
+
return yoctocolors_cjs_1.default.blue(value);
|
|
14
|
+
case "done":
|
|
15
|
+
return yoctocolors_cjs_1.default.cyan(value);
|
|
16
|
+
default:
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.prepareValue = prepareValue;
|
package/lib/types/Theme.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Theme as InquirerTheme, Status } from "@inquirer/core";
|
|
2
2
|
export type Theme<T extends object = object> = InquirerTheme<T & {
|
|
3
3
|
style: {
|
|
4
|
+
message: (message: string, status: Status, ending?: string) => string;
|
|
4
5
|
value: (value: string, status: Status) => string;
|
|
5
6
|
};
|
|
6
7
|
}>;
|