@wocker/utils 1.0.11 → 2.0.0-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.
Files changed (63) hide show
  1. package/README.md +73 -2
  2. package/lib/index.d.ts +3 -8
  3. package/lib/index.js +3 -8
  4. package/lib/messages.d.ts +15 -0
  5. package/lib/messages.js +18 -0
  6. package/lib/prompts/index.d.ts +3 -0
  7. package/lib/prompts/index.js +19 -0
  8. package/lib/prompts/promptConfirm.d.ts +4 -0
  9. package/lib/prompts/promptConfirm.js +75 -0
  10. package/lib/prompts/promptInput.d.ts +15 -0
  11. package/lib/prompts/promptInput.js +179 -0
  12. package/lib/prompts/promptSelect.d.ts +15 -0
  13. package/lib/prompts/promptSelect.js +162 -0
  14. package/lib/tools/index.d.ts +4 -0
  15. package/lib/tools/index.js +20 -0
  16. package/lib/{normalizeOptions.d.ts → tools/normalizeOptions.d.ts} +6 -8
  17. package/lib/tools/normalizeOptions.js +26 -0
  18. package/lib/{volumeFormat.js → tools/volumeFormat.js} +1 -1
  19. package/lib/types/KeypressEvent.d.ts +5 -0
  20. package/lib/types/KeypressEvent.js +2 -0
  21. package/lib/types/PromptConfig.d.ts +8 -0
  22. package/lib/types/PromptConfig.js +2 -0
  23. package/lib/types/PromptValidationConfig.d.ts +10 -0
  24. package/lib/types/PromptValidationConfig.js +2 -0
  25. package/lib/types/Theme.d.ts +6 -0
  26. package/lib/types/Theme.js +2 -0
  27. package/lib/types/Validation.d.ts +2 -0
  28. package/lib/types/Validation.js +2 -0
  29. package/lib/types/ValidationError.d.ts +4 -0
  30. package/lib/types/ValidationError.js +2 -0
  31. package/lib/types/ValidationResult.d.ts +1 -0
  32. package/lib/types/ValidationResult.js +2 -0
  33. package/lib/types/ValidationRule.d.ts +3 -0
  34. package/lib/types/ValidationRule.js +2 -0
  35. package/lib/types/ValidationValue.d.ts +1 -0
  36. package/lib/types/ValidationValue.js +2 -0
  37. package/lib/types/ValidationValueMessage.d.ts +5 -0
  38. package/lib/types/ValidationValueMessage.js +2 -0
  39. package/lib/validation/normalizeRule.d.ts +3 -0
  40. package/lib/validation/normalizeRule.js +16 -0
  41. package/lib/validation/validatePrompt.d.ts +3 -0
  42. package/lib/validation/validatePrompt.js +101 -0
  43. package/lib/validators/index.d.ts +1 -0
  44. package/lib/validators/index.js +17 -0
  45. package/lib/validators/validateVolume.d.ts +2 -0
  46. package/lib/validators/validateVolume.js +20 -0
  47. package/package.json +18 -7
  48. package/lib/normalizeOptions.js +0 -23
  49. package/lib/promptConfig.d.ts +0 -14
  50. package/lib/promptConfig.js +0 -76
  51. package/lib/promptConfirm.d.ts +0 -6
  52. package/lib/promptConfirm.js +0 -27
  53. package/lib/promptGroup.d.ts +0 -14
  54. package/lib/promptGroup.js +0 -55
  55. package/lib/promptSelect.d.ts +0 -14
  56. package/lib/promptSelect.js +0 -58
  57. package/lib/promptText.d.ts +0 -11
  58. package/lib/promptText.js +0 -62
  59. /package/lib/{demuxOutput.d.ts → tools/demuxOutput.d.ts} +0 -0
  60. /package/lib/{demuxOutput.js → tools/demuxOutput.js} +0 -0
  61. /package/lib/{volumeFormat.d.ts → tools/volumeFormat.d.ts} +0 -0
  62. /package/lib/{volumeParse.d.ts → tools/volumeParse.d.ts} +0 -0
  63. /package/lib/{volumeParse.js → tools/volumeParse.js} +0 -0
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.promptSelect = void 0;
16
- const inquirer_1 = __importDefault(require("inquirer"));
17
- const normalizeOptions_1 = require("./normalizeOptions");
18
- const promptSelect = (props) => __awaiter(void 0, void 0, void 0, function* () {
19
- const { message, options: rawOptions, } = props;
20
- const options = (0, normalizeOptions_1.normalizeOptions)(rawOptions);
21
- if (props.multiple) {
22
- const { value } = yield inquirer_1.default.prompt({
23
- message,
24
- name: "value",
25
- type: "checkbox",
26
- choices: options.map((option) => {
27
- return {
28
- name: option.label,
29
- value: option.value,
30
- checked: Array.isArray(props.default)
31
- ? props.default.includes(option.value)
32
- : false
33
- };
34
- })
35
- });
36
- return value;
37
- }
38
- const defaultOption = options.find((option) => {
39
- return option.value === props.default;
40
- });
41
- const { value } = yield inquirer_1.default.prompt({
42
- choices: options.map((option) => {
43
- return option.label;
44
- }),
45
- message,
46
- name: "value",
47
- type: "list",
48
- default: defaultOption ? (defaultOption.label || defaultOption.value) : ""
49
- });
50
- const selected = options.find((option) => {
51
- return option.label === value;
52
- });
53
- if (selected) {
54
- return selected.value;
55
- }
56
- return "";
57
- });
58
- exports.promptSelect = promptSelect;
@@ -1,11 +0,0 @@
1
- type Options = {
2
- required?: boolean;
3
- message?: string;
4
- prefix?: string;
5
- suffix?: string;
6
- type?: "string" | "number" | "int" | "password";
7
- default?: number | string;
8
- validate?: (value?: string) => boolean | string | Promise<boolean | string>;
9
- };
10
- export declare const promptText: (options: Options) => Promise<any>;
11
- export { Options as PromptTextOptions };
package/lib/promptText.js DELETED
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.promptText = void 0;
16
- const inquirer_1 = __importDefault(require("inquirer"));
17
- const chalk_1 = __importDefault(require("chalk"));
18
- const promptText = (options) => __awaiter(void 0, void 0, void 0, function* () {
19
- const { required, message, prefix = "", suffix = "", type, default: defaultValue, validate } = options;
20
- const { value } = yield inquirer_1.default.prompt({
21
- name: "value",
22
- type: (() => {
23
- switch (type) {
24
- case "password":
25
- return type;
26
- default:
27
- return "input";
28
- }
29
- })(),
30
- message,
31
- default: defaultValue,
32
- validate(value) {
33
- if (required) {
34
- if (typeof value === "undefined" || value === "") {
35
- return "Mandatory value";
36
- }
37
- }
38
- if (type === "int" || type === "number") {
39
- if (isNaN(parseInt(value)) || parseInt(value).toString() !== value) {
40
- return "Should be integer";
41
- }
42
- }
43
- if (validate) {
44
- return validate(value);
45
- }
46
- return true;
47
- },
48
- transformer(value) {
49
- if (!prefix && !suffix) {
50
- return value;
51
- }
52
- if (suffix) {
53
- setTimeout(() => {
54
- process.stdout.write(`\x1b[${suffix.length}D`);
55
- }, 0);
56
- }
57
- return `${chalk_1.default.gray(prefix)}${value}${chalk_1.default.gray(suffix)}`;
58
- }
59
- });
60
- return value;
61
- });
62
- exports.promptText = promptText;
File without changes
File without changes