@reliverse/rempts 1.7.51 → 1.7.53

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 (105) hide show
  1. package/bin/libs/animate/animate-mod.d.ts +14 -0
  2. package/bin/libs/animate/animate-mod.js +60 -0
  3. package/bin/libs/anykey/anykey-mod.d.ts +12 -0
  4. package/bin/libs/anykey/anykey-mod.js +125 -0
  5. package/bin/libs/cancel/cancel.d.ts +45 -0
  6. package/bin/libs/cancel/cancel.js +72 -0
  7. package/bin/libs/confirm/confirm-alias.d.ts +2 -0
  8. package/bin/libs/confirm/confirm-alias.js +2 -0
  9. package/bin/libs/confirm/confirm-mod.d.ts +5 -0
  10. package/bin/libs/confirm/confirm-mod.js +179 -0
  11. package/bin/libs/date/date.d.ts +2 -0
  12. package/bin/libs/date/date.js +214 -0
  13. package/bin/libs/editor/editor-mod.d.ts +25 -0
  14. package/bin/libs/editor/editor-mod.js +1133 -0
  15. package/bin/libs/figures/figures-mod.d.ts +461 -0
  16. package/bin/libs/figures/figures-mod.js +285 -0
  17. package/bin/libs/group/group-mod.d.ts +33 -0
  18. package/bin/libs/group/group-mod.js +89 -0
  19. package/bin/libs/input/input-alias.d.ts +5 -0
  20. package/bin/libs/input/input-alias.js +4 -0
  21. package/bin/libs/input/input-mod.d.ts +16 -0
  22. package/bin/libs/input/input-mod.js +372 -0
  23. package/bin/libs/intro/intro-alias.d.ts +3 -0
  24. package/bin/libs/intro/intro-alias.js +3 -0
  25. package/bin/libs/intro/intro-mod.d.ts +20 -0
  26. package/bin/libs/intro/intro-mod.js +77 -0
  27. package/bin/libs/launcher/command-runner.d.ts +31 -0
  28. package/bin/libs/launcher/command-runner.js +229 -0
  29. package/bin/libs/launcher/launcher-alias.d.ts +2 -0
  30. package/bin/libs/launcher/launcher-alias.js +2 -0
  31. package/bin/libs/launcher/launcher-mod.d.ts +66 -0
  32. package/bin/libs/launcher/launcher-mod.js +975 -0
  33. package/bin/libs/launcher/launcher-types.d.ts +176 -0
  34. package/bin/libs/launcher/launcher-types.js +0 -0
  35. package/bin/libs/log/log-alias.d.ts +1 -0
  36. package/bin/libs/log/log-alias.js +2 -0
  37. package/bin/libs/msg-fmt/colors.d.ts +30 -0
  38. package/bin/libs/msg-fmt/colors.js +42 -0
  39. package/bin/libs/msg-fmt/logger.d.ts +17 -0
  40. package/bin/libs/msg-fmt/logger.js +103 -0
  41. package/bin/libs/msg-fmt/mapping.d.ts +3 -0
  42. package/bin/libs/msg-fmt/mapping.js +41 -0
  43. package/bin/libs/msg-fmt/messages.d.ts +35 -0
  44. package/bin/libs/msg-fmt/messages.js +305 -0
  45. package/bin/libs/msg-fmt/terminal.d.ts +15 -0
  46. package/bin/libs/msg-fmt/terminal.js +60 -0
  47. package/bin/libs/msg-fmt/variants.d.ts +11 -0
  48. package/bin/libs/msg-fmt/variants.js +52 -0
  49. package/bin/libs/multiselect/multiselect-alias.d.ts +2 -0
  50. package/bin/libs/multiselect/multiselect-alias.js +2 -0
  51. package/bin/libs/multiselect/multiselect-prompt.d.ts +2 -0
  52. package/bin/libs/multiselect/multiselect-prompt.js +340 -0
  53. package/bin/libs/next-steps/next-steps.d.ts +13 -0
  54. package/bin/libs/next-steps/next-steps.js +24 -0
  55. package/bin/libs/number/number-mod.d.ts +28 -0
  56. package/bin/libs/number/number-mod.js +194 -0
  57. package/bin/libs/outro/outro-alias.d.ts +3 -0
  58. package/bin/libs/outro/outro-alias.js +3 -0
  59. package/bin/libs/outro/outro-mod.d.ts +8 -0
  60. package/bin/libs/outro/outro-mod.js +55 -0
  61. package/bin/libs/reliarg/reliarg-mod.d.ts +76 -0
  62. package/bin/libs/reliarg/reliarg-mod.js +276 -0
  63. package/bin/libs/results/results.d.ts +7 -0
  64. package/bin/libs/results/results.js +27 -0
  65. package/bin/libs/select/nummultiselect-prompt.d.ts +6 -0
  66. package/bin/libs/select/nummultiselect-prompt.js +101 -0
  67. package/bin/libs/select/numselect-prompt.d.ts +7 -0
  68. package/bin/libs/select/numselect-prompt.js +111 -0
  69. package/bin/libs/select/select-alias.d.ts +9 -0
  70. package/bin/libs/select/select-alias.js +9 -0
  71. package/bin/libs/select/select-prompt.d.ts +5 -0
  72. package/bin/libs/select/select-prompt.js +308 -0
  73. package/bin/libs/select/toggle-prompt.d.ts +5 -0
  74. package/bin/libs/select/toggle-prompt.js +207 -0
  75. package/bin/libs/spinner/spinner-alias.d.ts +2 -0
  76. package/bin/libs/spinner/spinner-alias.js +2 -0
  77. package/bin/libs/spinner/spinner-mod.d.ts +106 -0
  78. package/bin/libs/spinner/spinner-mod.js +255 -0
  79. package/bin/libs/task/progress.d.ts +2 -0
  80. package/bin/libs/task/progress.js +57 -0
  81. package/bin/libs/task/task-spin.d.ts +15 -0
  82. package/bin/libs/task/task-spin.js +106 -0
  83. package/bin/libs/utils/colorize.d.ts +2 -0
  84. package/bin/libs/utils/colorize.js +122 -0
  85. package/bin/libs/utils/errors.d.ts +1 -0
  86. package/bin/libs/utils/errors.js +17 -0
  87. package/bin/libs/utils/prevent.d.ts +8 -0
  88. package/bin/libs/utils/prevent.js +62 -0
  89. package/bin/libs/utils/prompt-end.d.ts +8 -0
  90. package/bin/libs/utils/prompt-end.js +34 -0
  91. package/bin/libs/utils/stream-text.d.ts +18 -0
  92. package/bin/libs/utils/stream-text.js +137 -0
  93. package/bin/libs/utils/system.d.ts +6 -0
  94. package/bin/libs/utils/system.js +7 -0
  95. package/bin/libs/utils/validate.d.ts +21 -0
  96. package/bin/libs/utils/validate.js +17 -0
  97. package/bin/libs/visual/visual-mod.d.ts +6 -0
  98. package/bin/libs/visual/visual-mod.js +13 -0
  99. package/bin/mod.d.ts +53 -0
  100. package/bin/mod.js +107 -0
  101. package/bin/types.d.ts +371 -0
  102. package/bin/types.js +0 -0
  103. package/package.json +35 -60
  104. package/dist-npm/bin/mod.d.mts +0 -1753
  105. package/dist-npm/bin/mod.mjs +0 -6779
@@ -0,0 +1,214 @@
1
+ import { stdin as input, stdout as output } from "node:process";
2
+ import readline from "node:readline/promises";
3
+ import { re } from "@reliverse/relico";
4
+ import { buildRegExp, digit, endOfString, repeat, startOfString } from "ts-regex-builder";
5
+ import { fmt, msg, symbols } from "../msg-fmt/messages.js";
6
+ import { countLines, deleteLastLine, deleteLastLines } from "../msg-fmt/terminal.js";
7
+ const twoDigits = repeat(digit, 2);
8
+ const fourDigits = repeat(digit, 4);
9
+ const separatorDot = ".";
10
+ const separatorSlash = "/";
11
+ const regexDDMMYYYY = buildRegExp([
12
+ startOfString,
13
+ twoDigits,
14
+ // DD
15
+ separatorDot,
16
+ twoDigits,
17
+ // MM
18
+ separatorDot,
19
+ fourDigits,
20
+ // YYYY
21
+ endOfString
22
+ ]);
23
+ const regexMMDDYYYY = buildRegExp([
24
+ startOfString,
25
+ twoDigits,
26
+ // MM
27
+ separatorSlash,
28
+ twoDigits,
29
+ // DD
30
+ separatorSlash,
31
+ fourDigits,
32
+ // YYYY
33
+ endOfString
34
+ ]);
35
+ const regexYYYYMMDD = buildRegExp([
36
+ startOfString,
37
+ fourDigits,
38
+ // YYYY
39
+ separatorDot,
40
+ twoDigits,
41
+ // MM
42
+ separatorDot,
43
+ twoDigits,
44
+ // DD
45
+ endOfString
46
+ ]);
47
+ export async function datePrompt(opts) {
48
+ const {
49
+ title = "",
50
+ dateFormat,
51
+ dateKind,
52
+ hint,
53
+ hintPlaceholderColor = "blue",
54
+ validate,
55
+ defaultValue = "",
56
+ titleColor = "cyan",
57
+ titleTypography = "none",
58
+ titleVariant,
59
+ content,
60
+ contentColor = "dim",
61
+ contentTypography = "italic",
62
+ contentVariant,
63
+ borderColor = "dim",
64
+ variantOptions,
65
+ endTitle = "",
66
+ endTitleColor = "dim",
67
+ border = true
68
+ } = opts;
69
+ const rl = readline.createInterface({ input, output });
70
+ rl.on("SIGINT", () => {
71
+ rl.close();
72
+ if (endTitle !== "") {
73
+ msg({
74
+ type: "M_END",
75
+ title: endTitle,
76
+ titleColor: endTitleColor,
77
+ titleTypography,
78
+ border,
79
+ borderColor
80
+ });
81
+ }
82
+ process.exit(0);
83
+ });
84
+ let linesToDelete = 0;
85
+ let errorMessage = "";
86
+ try {
87
+ while (true) {
88
+ if (linesToDelete > 0) {
89
+ deleteLastLines(linesToDelete);
90
+ linesToDelete = 0;
91
+ }
92
+ const { text: questionText } = fmt({
93
+ type: errorMessage !== "" ? "M_ERROR_NULL" : "M_GENERAL_NULL",
94
+ title: `${title} [${dateFormat}]`,
95
+ titleColor,
96
+ titleTypography,
97
+ titleVariant,
98
+ content,
99
+ contentColor,
100
+ contentTypography,
101
+ contentVariant,
102
+ borderColor,
103
+ hint: `${hint ? `${hint} ` : ""}${defaultValue ? `Default: ${defaultValue}` : ""}`,
104
+ hintPlaceholderColor,
105
+ variantOptions,
106
+ errorMessage
107
+ });
108
+ const questionLines = countLines(questionText);
109
+ linesToDelete = questionLines + 1;
110
+ msg({
111
+ type: errorMessage !== "" ? "M_ERROR" : "M_GENERAL",
112
+ title: questionText
113
+ });
114
+ if (errorMessage !== "") {
115
+ deleteLastLine();
116
+ deleteLastLine();
117
+ }
118
+ const answerInput = await rl.question(`${re.dim(symbols.middle)} `);
119
+ if (answerInput === null) {
120
+ rl.close();
121
+ if (endTitle !== "") {
122
+ msg({
123
+ type: "M_END",
124
+ title: endTitle,
125
+ titleColor: endTitleColor,
126
+ titleTypography,
127
+ border,
128
+ borderColor
129
+ });
130
+ }
131
+ process.exit(0);
132
+ }
133
+ const answer = answerInput.trim() || defaultValue;
134
+ if (errorMessage !== "") {
135
+ deleteLastLine();
136
+ }
137
+ deleteLastLine();
138
+ msg({
139
+ type: "M_MIDDLE",
140
+ title: ` ${answer}`,
141
+ titleColor: "none"
142
+ });
143
+ if (!(regexDDMMYYYY.test(answer) || regexMMDDYYYY.test(answer) || regexYYYYMMDD.test(answer))) {
144
+ if (errorMessage !== "") {
145
+ deleteLastLine();
146
+ deleteLastLine();
147
+ }
148
+ errorMessage = `Please enter a valid date in ${dateFormat} format.`;
149
+ msg({ type: "M_ERROR", title: errorMessage });
150
+ linesToDelete = countLines(errorMessage) + 1;
151
+ continue;
152
+ }
153
+ let matchedFormat = null;
154
+ if (regexDDMMYYYY.test(answer)) {
155
+ matchedFormat = "DD.MM.YYYY";
156
+ } else if (regexMMDDYYYY.test(answer)) {
157
+ matchedFormat = "MM/DD/YYYY";
158
+ } else if (regexYYYYMMDD.test(answer)) {
159
+ matchedFormat = "YYYY.MM.DD";
160
+ }
161
+ if (dateKind === "birthday" && matchedFormat) {
162
+ const parts = answer.split(/[./-]/);
163
+ let date;
164
+ if (matchedFormat === "DD.MM.YYYY") {
165
+ date = new Date(Number(parts[2]), Number(parts[1]) - 1, Number(parts[0]));
166
+ } else if (matchedFormat === "MM/DD/YYYY") {
167
+ date = new Date(Number(parts[2]), Number(parts[0]) - 1, Number(parts[1]));
168
+ } else if (matchedFormat === "YYYY.MM.DD") {
169
+ date = new Date(Number(parts[0]), Number(parts[1]) - 1, Number(parts[2]));
170
+ } else {
171
+ date = new Date(answer);
172
+ }
173
+ if (Number.isNaN(date.getTime()) || date.getFullYear() < 1900 || date > /* @__PURE__ */ new Date()) {
174
+ errorMessage = "Please enter a valid birthday date (e.g., 14.09.1999).";
175
+ msg({ type: "M_ERROR", title: errorMessage });
176
+ linesToDelete = countLines(errorMessage) + 1;
177
+ continue;
178
+ }
179
+ }
180
+ let isValid = true;
181
+ let gotError = false;
182
+ if (errorMessage !== "") {
183
+ gotError = true;
184
+ }
185
+ errorMessage = "";
186
+ if (validate && isValid) {
187
+ const validation = await validate(answer);
188
+ if (validation !== true) {
189
+ isValid = false;
190
+ errorMessage = typeof validation === "string" ? validation : "Invalid input.";
191
+ msg({ type: "M_ERROR", title: errorMessage });
192
+ gotError = true;
193
+ linesToDelete = countLines(errorMessage) + 1;
194
+ continue;
195
+ }
196
+ }
197
+ if (isValid) {
198
+ if (gotError) {
199
+ deleteLastLine();
200
+ deleteLastLine();
201
+ msg({ type: "M_MIDDLE", title: ` ${answer}` });
202
+ }
203
+ msg({
204
+ type: "M_BAR",
205
+ borderColor
206
+ });
207
+ rl.close();
208
+ return answer;
209
+ }
210
+ }
211
+ } finally {
212
+ rl.close();
213
+ }
214
+ }
@@ -0,0 +1,25 @@
1
+ import type { EditorExitResult } from "../../types";
2
+ interface EditorConfig {
3
+ syntaxHighlighting?: boolean;
4
+ theme?: "auto" | "light" | "dark";
5
+ defaultAllowSaveAs?: boolean;
6
+ defaultAllowOpen?: boolean;
7
+ defaultAutoCloseOnSave?: boolean;
8
+ defaultReturnContentOnSave?: boolean;
9
+ [key: string]: any;
10
+ }
11
+ interface EditorOptions {
12
+ filename?: string | null;
13
+ initialContent?: string | null;
14
+ onSave?: (content: string, filename: string | null) => Promise<string | boolean | undefined> | string | boolean | undefined;
15
+ onExit?: (content: string | null, saved: boolean, filename: string | null) => Promise<void> | void;
16
+ configOverrides?: Partial<EditorConfig>;
17
+ allowSaveAs?: boolean;
18
+ allowOpen?: boolean;
19
+ autoCloseOnSave?: boolean;
20
+ returnContentOnSave?: boolean;
21
+ mode?: string;
22
+ cwd?: string;
23
+ }
24
+ export declare function startEditor(options?: EditorOptions): Promise<EditorExitResult>;
25
+ export {};