@reliverse/rempts-core 1.6.1 → 2.3.2

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 (155) hide show
  1. package/README.md +398 -102
  2. package/dist/cli.d.ts +32 -0
  3. package/dist/cli.js +731 -0
  4. package/dist/config-loader.d.ts +42 -0
  5. package/dist/config-loader.js +20 -0
  6. package/dist/config.d.ts +99 -0
  7. package/dist/config.js +188 -0
  8. package/dist/file-loader.d.ts +43 -0
  9. package/dist/file-loader.js +199 -0
  10. package/dist/global-flags.d.ts +36 -0
  11. package/dist/global-flags.js +36 -0
  12. package/dist/mod.d.ts +13 -0
  13. package/dist/mod.js +19 -0
  14. package/dist/parser.d.ts +6 -0
  15. package/dist/parser.js +137 -0
  16. package/dist/plugin/context.d.ts +13 -0
  17. package/dist/plugin/context.js +53 -0
  18. package/dist/plugin/create.d.ts +92 -0
  19. package/dist/plugin/create.js +61 -0
  20. package/dist/plugin/loader.d.ts +12 -0
  21. package/dist/plugin/loader.js +65 -0
  22. package/dist/plugin/manager.d.ts +53 -0
  23. package/dist/plugin/manager.js +135 -0
  24. package/dist/plugin/mod.d.ts +10 -0
  25. package/dist/plugin/mod.js +27 -0
  26. package/dist/plugin/store.d.ts +45 -0
  27. package/dist/plugin/store.js +60 -0
  28. package/dist/plugin/testing.d.ts +38 -0
  29. package/dist/plugin/testing.js +175 -0
  30. package/dist/plugin/types.d.ts +146 -0
  31. package/dist/tui/registry.d.ts +8 -0
  32. package/dist/tui/registry.js +10 -0
  33. package/dist/tui/types.d.ts +58 -0
  34. package/dist/tui/types.js +10 -0
  35. package/dist/types.d.ts +178 -0
  36. package/dist/types.js +25 -0
  37. package/dist/utils/logger.d.ts +10 -0
  38. package/dist/utils/logger.js +27 -0
  39. package/dist/utils/merge.d.ts +13 -0
  40. package/dist/utils/merge.js +25 -0
  41. package/dist/utils/mod.d.ts +6 -0
  42. package/dist/utils/mod.js +2 -0
  43. package/dist/utils/type-helpers.d.ts +41 -0
  44. package/dist/utils/type-helpers.js +0 -0
  45. package/dist/validation.d.ts +30 -0
  46. package/dist/validation.js +121 -0
  47. package/package.json +47 -44
  48. package/src/cli.ts +1049 -0
  49. package/src/config-loader.ts +71 -0
  50. package/src/config.ts +270 -0
  51. package/src/file-loader.ts +346 -0
  52. package/src/global-flags.ts +50 -0
  53. package/src/mod.ts +74 -0
  54. package/src/parser.ts +212 -0
  55. package/src/plugin/context.ts +88 -0
  56. package/src/plugin/create.ts +174 -0
  57. package/src/plugin/loader.ts +111 -0
  58. package/src/plugin/manager.ts +244 -0
  59. package/src/plugin/mod.ts +51 -0
  60. package/src/plugin/store.ts +124 -0
  61. package/src/plugin/testing.ts +236 -0
  62. package/src/plugin/types.ts +206 -0
  63. package/src/tui/registry.ts +22 -0
  64. package/src/tui/types.ts +79 -0
  65. package/src/types.ts +285 -0
  66. package/src/utils/logger.ts +43 -0
  67. package/src/utils/merge.ts +54 -0
  68. package/src/utils/mod.ts +7 -0
  69. package/src/utils/type-helpers.ts +151 -0
  70. package/src/validation.ts +177 -0
  71. package/LICENSE +0 -21
  72. package/bin/core-impl/anykey/anykey-mod.d.ts +0 -12
  73. package/bin/core-impl/anykey/anykey-mod.js +0 -125
  74. package/bin/core-impl/date/date.d.ts +0 -2
  75. package/bin/core-impl/date/date.js +0 -236
  76. package/bin/core-impl/editor/editor-mod.d.ts +0 -25
  77. package/bin/core-impl/editor/editor-mod.js +0 -896
  78. package/bin/core-impl/figures/figures-mod.d.ts +0 -233
  79. package/bin/core-impl/figures/figures-mod.js +0 -286
  80. package/bin/core-impl/figures/figures.test.d.ts +0 -1
  81. package/bin/core-impl/figures/figures.test.js +0 -474
  82. package/bin/core-impl/input/confirm-prompt.d.ts +0 -5
  83. package/bin/core-impl/input/confirm-prompt.js +0 -173
  84. package/bin/core-impl/input/input-prompt.d.ts +0 -16
  85. package/bin/core-impl/input/input-prompt.js +0 -370
  86. package/bin/core-impl/launcher/_parser.d.ts +0 -2
  87. package/bin/core-impl/launcher/_parser.js +0 -122
  88. package/bin/core-impl/launcher/_utils.d.ts +0 -8
  89. package/bin/core-impl/launcher/_utils.js +0 -29
  90. package/bin/core-impl/launcher/args.d.ts +0 -3
  91. package/bin/core-impl/launcher/args.js +0 -89
  92. package/bin/core-impl/launcher/command.d.ts +0 -8
  93. package/bin/core-impl/launcher/command.js +0 -68
  94. package/bin/core-impl/launcher/launcher-mod.d.ts +0 -8
  95. package/bin/core-impl/launcher/launcher-mod.js +0 -34
  96. package/bin/core-impl/launcher/usage.d.ts +0 -3
  97. package/bin/core-impl/launcher/usage.js +0 -104
  98. package/bin/core-impl/msg-fmt/colors.d.ts +0 -30
  99. package/bin/core-impl/msg-fmt/colors.js +0 -42
  100. package/bin/core-impl/msg-fmt/logger.d.ts +0 -17
  101. package/bin/core-impl/msg-fmt/logger.js +0 -106
  102. package/bin/core-impl/msg-fmt/mapping.d.ts +0 -3
  103. package/bin/core-impl/msg-fmt/mapping.js +0 -49
  104. package/bin/core-impl/msg-fmt/messages.d.ts +0 -35
  105. package/bin/core-impl/msg-fmt/messages.js +0 -314
  106. package/bin/core-impl/msg-fmt/terminal.d.ts +0 -15
  107. package/bin/core-impl/msg-fmt/terminal.js +0 -59
  108. package/bin/core-impl/msg-fmt/variants.d.ts +0 -11
  109. package/bin/core-impl/msg-fmt/variants.js +0 -52
  110. package/bin/core-impl/next-steps/next-steps.d.ts +0 -14
  111. package/bin/core-impl/next-steps/next-steps.js +0 -24
  112. package/bin/core-impl/number/number-mod.d.ts +0 -28
  113. package/bin/core-impl/number/number-mod.js +0 -197
  114. package/bin/core-impl/results/results.d.ts +0 -7
  115. package/bin/core-impl/results/results.js +0 -27
  116. package/bin/core-impl/select/multiselect-prompt.d.ts +0 -2
  117. package/bin/core-impl/select/multiselect-prompt.js +0 -341
  118. package/bin/core-impl/select/nummultiselect-prompt.d.ts +0 -6
  119. package/bin/core-impl/select/nummultiselect-prompt.js +0 -105
  120. package/bin/core-impl/select/numselect-prompt.d.ts +0 -7
  121. package/bin/core-impl/select/numselect-prompt.js +0 -115
  122. package/bin/core-impl/select/select-prompt.d.ts +0 -33
  123. package/bin/core-impl/select/select-prompt.js +0 -302
  124. package/bin/core-impl/select/toggle-prompt.d.ts +0 -5
  125. package/bin/core-impl/select/toggle-prompt.js +0 -208
  126. package/bin/core-impl/st-end/end.d.ts +0 -2
  127. package/bin/core-impl/st-end/end.js +0 -42
  128. package/bin/core-impl/st-end/start.d.ts +0 -17
  129. package/bin/core-impl/st-end/start.js +0 -66
  130. package/bin/core-impl/task/progress.d.ts +0 -2
  131. package/bin/core-impl/task/progress.js +0 -57
  132. package/bin/core-impl/task/spinner.d.ts +0 -15
  133. package/bin/core-impl/task/spinner.js +0 -110
  134. package/bin/core-impl/utils/colorize.d.ts +0 -2
  135. package/bin/core-impl/utils/colorize.js +0 -134
  136. package/bin/core-impl/utils/errors.d.ts +0 -1
  137. package/bin/core-impl/utils/errors.js +0 -15
  138. package/bin/core-impl/utils/prevent.d.ts +0 -10
  139. package/bin/core-impl/utils/prevent.js +0 -69
  140. package/bin/core-impl/utils/prompt-end.d.ts +0 -8
  141. package/bin/core-impl/utils/prompt-end.js +0 -33
  142. package/bin/core-impl/utils/stream-text.d.ts +0 -18
  143. package/bin/core-impl/utils/stream-text.js +0 -136
  144. package/bin/core-impl/utils/system.d.ts +0 -6
  145. package/bin/core-impl/utils/system.js +0 -7
  146. package/bin/core-impl/utils/validate.d.ts +0 -22
  147. package/bin/core-impl/utils/validate.js +0 -17
  148. package/bin/core-impl/visual/animate/animate.d.ts +0 -14
  149. package/bin/core-impl/visual/animate/animate.js +0 -64
  150. package/bin/core-impl/visual/ascii-art/ascii-art.d.ts +0 -6
  151. package/bin/core-impl/visual/ascii-art/ascii-art.js +0 -12
  152. package/bin/core-types.d.ts +0 -434
  153. package/bin/main.d.ts +0 -41
  154. package/bin/main.js +0 -96
  155. /package/{bin/core-types.js → dist/plugin/types.js} +0 -0
@@ -1,236 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import { stdin as input, stdout as output } from "node:process";
3
- import readline from "node:readline/promises";
4
- import {
5
- buildRegExp,
6
- digit,
7
- endOfString,
8
- repeat,
9
- startOfString
10
- } from "ts-regex-builder";
11
- import { fmt, msg, symbols } from "../msg-fmt/messages.js";
12
- import {
13
- countLines,
14
- deleteLastLine,
15
- deleteLastLines
16
- } from "../msg-fmt/terminal.js";
17
- const twoDigits = repeat(digit, 2);
18
- const fourDigits = repeat(digit, 4);
19
- const separatorDot = ".";
20
- const separatorSlash = "/";
21
- const regexDDMMYYYY = buildRegExp([
22
- startOfString,
23
- twoDigits,
24
- // DD
25
- separatorDot,
26
- twoDigits,
27
- // MM
28
- separatorDot,
29
- fourDigits,
30
- // YYYY
31
- endOfString
32
- ]);
33
- const regexMMDDYYYY = buildRegExp([
34
- startOfString,
35
- twoDigits,
36
- // MM
37
- separatorSlash,
38
- twoDigits,
39
- // DD
40
- separatorSlash,
41
- fourDigits,
42
- // YYYY
43
- endOfString
44
- ]);
45
- const regexYYYYMMDD = buildRegExp([
46
- startOfString,
47
- fourDigits,
48
- // YYYY
49
- separatorDot,
50
- twoDigits,
51
- // MM
52
- separatorDot,
53
- twoDigits,
54
- // DD
55
- endOfString
56
- ]);
57
- export async function datePrompt(opts) {
58
- const {
59
- title = "",
60
- dateFormat,
61
- dateKind,
62
- hint,
63
- hintPlaceholderColor = "blue",
64
- validate,
65
- defaultValue = "",
66
- titleColor = "cyan",
67
- titleTypography = "none",
68
- titleVariant,
69
- content,
70
- contentColor = "dim",
71
- contentTypography = "italic",
72
- contentVariant,
73
- borderColor = "dim",
74
- variantOptions,
75
- endTitle = "",
76
- endTitleColor = "dim",
77
- border = true
78
- } = opts;
79
- const rl = readline.createInterface({ input, output });
80
- rl.on("SIGINT", () => {
81
- rl.close();
82
- if (endTitle !== "") {
83
- msg({
84
- type: "M_END",
85
- title: endTitle,
86
- titleColor: endTitleColor,
87
- titleTypography,
88
- border,
89
- borderColor
90
- });
91
- }
92
- process.exit(0);
93
- });
94
- let linesToDelete = 0;
95
- let errorMessage = "";
96
- try {
97
- while (true) {
98
- if (linesToDelete > 0) {
99
- deleteLastLines(linesToDelete);
100
- linesToDelete = 0;
101
- }
102
- const { text: questionText } = fmt({
103
- type: errorMessage !== "" ? "M_ERROR_NULL" : "M_GENERAL_NULL",
104
- title: `${title} [${dateFormat}]`,
105
- titleColor,
106
- titleTypography,
107
- titleVariant,
108
- content,
109
- contentColor,
110
- contentTypography,
111
- contentVariant,
112
- borderColor,
113
- hint: `${hint ? `${hint} ` : ""}${defaultValue ? `Default: ${defaultValue}` : ""}`,
114
- hintPlaceholderColor,
115
- variantOptions,
116
- errorMessage
117
- });
118
- const questionLines = countLines(questionText);
119
- linesToDelete = questionLines + 1;
120
- msg({
121
- type: errorMessage !== "" ? "M_ERROR" : "M_GENERAL",
122
- title: questionText
123
- });
124
- if (errorMessage !== "") {
125
- deleteLastLine();
126
- deleteLastLine();
127
- }
128
- const answerInput = await rl.question(`${re.dim(symbols.middle)} `);
129
- if (answerInput === null) {
130
- rl.close();
131
- if (endTitle !== "") {
132
- msg({
133
- type: "M_END",
134
- title: endTitle,
135
- titleColor: endTitleColor,
136
- titleTypography,
137
- border,
138
- borderColor
139
- });
140
- }
141
- process.exit(0);
142
- }
143
- const answer = answerInput.trim() || defaultValue;
144
- if (errorMessage !== "") {
145
- deleteLastLine();
146
- }
147
- deleteLastLine();
148
- msg({
149
- type: "M_MIDDLE",
150
- title: ` ${answer}`,
151
- titleColor: "none"
152
- });
153
- if (!(regexDDMMYYYY.test(answer) || regexMMDDYYYY.test(answer) || regexYYYYMMDD.test(answer))) {
154
- if (errorMessage !== "") {
155
- deleteLastLine();
156
- deleteLastLine();
157
- }
158
- errorMessage = `Please enter a valid date in ${dateFormat} format.`;
159
- msg({ type: "M_ERROR", title: errorMessage });
160
- linesToDelete = countLines(errorMessage) + 1;
161
- continue;
162
- }
163
- let matchedFormat = null;
164
- if (regexDDMMYYYY.test(answer)) {
165
- matchedFormat = "DD.MM.YYYY";
166
- } else if (regexMMDDYYYY.test(answer)) {
167
- matchedFormat = "MM/DD/YYYY";
168
- } else if (regexYYYYMMDD.test(answer)) {
169
- matchedFormat = "YYYY.MM.DD";
170
- }
171
- if (dateKind === "birthday" && matchedFormat) {
172
- const parts = answer.split(/[./-]/);
173
- let date;
174
- if (matchedFormat === "DD.MM.YYYY") {
175
- date = new Date(
176
- Number(parts[2]),
177
- Number(parts[1]) - 1,
178
- Number(parts[0])
179
- );
180
- } else if (matchedFormat === "MM/DD/YYYY") {
181
- date = new Date(
182
- Number(parts[2]),
183
- Number(parts[0]) - 1,
184
- Number(parts[1])
185
- );
186
- } else if (matchedFormat === "YYYY.MM.DD") {
187
- date = new Date(
188
- Number(parts[0]),
189
- Number(parts[1]) - 1,
190
- Number(parts[2])
191
- );
192
- } else {
193
- date = new Date(answer);
194
- }
195
- if (Number.isNaN(date.getTime()) || date.getFullYear() < 1900 || date > /* @__PURE__ */ new Date()) {
196
- errorMessage = "Please enter a valid birthday date (e.g., 14.09.1999).";
197
- msg({ type: "M_ERROR", title: errorMessage });
198
- linesToDelete = countLines(errorMessage) + 1;
199
- continue;
200
- }
201
- }
202
- let isValid = true;
203
- let gotError = false;
204
- if (errorMessage !== "") {
205
- gotError = true;
206
- }
207
- errorMessage = "";
208
- if (validate && isValid) {
209
- const validation = await validate(answer);
210
- if (validation !== true) {
211
- isValid = false;
212
- errorMessage = typeof validation === "string" ? validation : "Invalid input.";
213
- msg({ type: "M_ERROR", title: errorMessage });
214
- gotError = true;
215
- linesToDelete = countLines(errorMessage) + 1;
216
- continue;
217
- }
218
- }
219
- if (isValid) {
220
- if (gotError) {
221
- deleteLastLine();
222
- deleteLastLine();
223
- msg({ type: "M_MIDDLE", title: ` ${answer}` });
224
- }
225
- msg({
226
- type: "M_BAR",
227
- borderColor
228
- });
229
- rl.close();
230
- return answer;
231
- }
232
- }
233
- } finally {
234
- rl.close();
235
- }
236
- }
@@ -1,25 +0,0 @@
1
- import type { EditorExitResult } from "../../core-types.js";
2
- type 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
- type 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 {};