@cmflow/atlas 3.4.0-beta.2 → 3.4.0-beta.21
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/README.md +231 -5
- package/dist/bin/atlas.d.mts +2 -0
- package/dist/bin/atlas.mjs +29100 -3106
- package/dist/bin/atlas.mjs.map +1 -0
- package/dist/defineExpressionRule-GhkeHHT8.mjs +10 -0
- package/dist/defineExpressionRule-GhkeHHT8.mjs.map +1 -0
- package/dist/index.d.mts +36 -0
- package/dist/index.mjs +1297 -0
- package/dist/index.mjs.map +1 -0
- package/dist/propertyExtractionService-8BjqpPFa.mjs +172 -0
- package/dist/propertyExtractionService-8BjqpPFa.mjs.map +1 -0
- package/dist/rolldown-runtime-CGR6nZuH.mjs +34 -0
- package/dist/routeBackendTopologyService-CkOLUfcj.mjs +8728 -0
- package/dist/routeBackendTopologyService-CkOLUfcj.mjs.map +1 -0
- package/dist/rules/lodashGetRule.d.mts +7 -0
- package/dist/rules/lodashGetRule.mjs +24 -0
- package/dist/rules/lodashGetRule.mjs.map +1 -0
- package/dist/rules/mappingUtilityRule.d.mts +7 -0
- package/dist/rules/mappingUtilityRule.mjs +38 -0
- package/dist/rules/mappingUtilityRule.mjs.map +1 -0
- package/dist/rules/memberGetFieldRule.d.mts +7 -0
- package/dist/rules/memberGetFieldRule.mjs +27 -0
- package/dist/rules/memberGetFieldRule.mjs.map +1 -0
- package/dist/taskProgressService-CAC_RIoa.mjs +1229 -0
- package/dist/taskProgressService-CAC_RIoa.mjs.map +1 -0
- package/dist/token-CiiblKFL.mjs +62 -0
- package/dist/token-CiiblKFL.mjs.map +1 -0
- package/dist/token-util-Br4-y5kE.mjs +7 -0
- package/dist/token-util-Dnzm6rU4.mjs +471 -0
- package/dist/token-util-Dnzm6rU4.mjs.map +1 -0
- package/dist/types-Af0_VOnh.d.mts +122 -0
- package/dist/workers/routeBackendTopologyWorker.d.mts +2 -0
- package/dist/workers/routeBackendTopologyWorker.mjs +34 -0
- package/dist/workers/routeBackendTopologyWorker.mjs.map +1 -0
- package/knowledges/cms-and-directus-indirect-routes.md +5 -3
- package/package.json +22 -13
- package/dist/defineRule-Dfvzj6n2.mjs +0 -2
- package/dist/defineRule-Dfvzj6n2.mjs.map +0 -1
|
@@ -0,0 +1,1229 @@
|
|
|
1
|
+
import { fileURLToPath as __atlasFileURLToPath } from "node:url";
|
|
2
|
+
const __filename = __atlasFileURLToPath(import.meta.url);
|
|
3
|
+
import { t as __commonJSMin } from "./rolldown-runtime-CGR6nZuH.mjs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import process$1, { stdin, stdout } from "node:process";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { Project } from "ts-morph";
|
|
9
|
+
import { styleText } from "node:util";
|
|
10
|
+
import * as l from "node:readline";
|
|
11
|
+
import l__default from "node:readline";
|
|
12
|
+
import { ReadStream } from "node:tty";
|
|
13
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
14
|
+
|
|
15
|
+
//#region src/config/mappers/normalizeBackendSources.ts
|
|
16
|
+
function normalizeBackendSources(backends) {
|
|
17
|
+
const sources = backends.map((backend) => typeof backend === "string" ? { name: backend } : backend);
|
|
18
|
+
const sourcesByName = /* @__PURE__ */ new Map();
|
|
19
|
+
for (const source of sources) {
|
|
20
|
+
if (!source.name.trim()) throw new Error("Backend source names must not be empty");
|
|
21
|
+
sourcesByName.set(source.name, source);
|
|
22
|
+
}
|
|
23
|
+
return [...sourcesByName.values()];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/config/mappers/normalizeExpressionRules.ts
|
|
28
|
+
function normalizeExpressionRules(rules) {
|
|
29
|
+
return [...new Set(rules)].map((rule, index) => ({
|
|
30
|
+
rule,
|
|
31
|
+
index
|
|
32
|
+
})).sort((left, right) => (right.rule.priority || 0) - (left.rule.priority || 0) || left.index - right.index).map(({ rule }) => rule);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/config/utils/getTsconfigAliases.ts
|
|
37
|
+
function getTsconfigAliases(workingDirectory = process.cwd()) {
|
|
38
|
+
const tsconfigPath = path.join(workingDirectory, "tsconfig.json");
|
|
39
|
+
if (!fs.existsSync(tsconfigPath)) return {};
|
|
40
|
+
const paths = new Project({
|
|
41
|
+
tsConfigFilePath: tsconfigPath,
|
|
42
|
+
skipAddingFilesFromTsConfig: true
|
|
43
|
+
}).getCompilerOptions().paths ?? {};
|
|
44
|
+
return Object.fromEntries(Object.entries(paths).flatMap(([alias, targets]) => {
|
|
45
|
+
const target = targets?.[0];
|
|
46
|
+
if (!target) return [];
|
|
47
|
+
return [[alias.replace(/\/\*$/, ""), target.replace(/^\.\//, "").replace(/\/\*$/, "")]];
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/config/userConfig.ts
|
|
53
|
+
let _config;
|
|
54
|
+
function setUserConfig(config) {
|
|
55
|
+
const backends = normalizeBackendSources(config.analysis.backends);
|
|
56
|
+
_config = {
|
|
57
|
+
...config,
|
|
58
|
+
envs: config.envs ?? {},
|
|
59
|
+
analysis: {
|
|
60
|
+
...config.analysis,
|
|
61
|
+
backends,
|
|
62
|
+
rules: normalizeExpressionRules([...config.analysis.rules, ...backends.flatMap((backend) => backend.rules || [])])
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function getUserConfig() {
|
|
67
|
+
if (!_config) throw new Error("Atlas config not loaded. Run Atlas from a directory containing atlas.config.ts or pass --config.");
|
|
68
|
+
return _config;
|
|
69
|
+
}
|
|
70
|
+
async function userConfig(configPath, projectRoot) {
|
|
71
|
+
const filePath = path.resolve(configPath);
|
|
72
|
+
try {
|
|
73
|
+
let mod;
|
|
74
|
+
if (filePath.endsWith(".ts")) {
|
|
75
|
+
const { register } = await import("tsx/esm/api");
|
|
76
|
+
const unregister = register();
|
|
77
|
+
try {
|
|
78
|
+
mod = await import(pathToFileURL(filePath).href);
|
|
79
|
+
} finally {
|
|
80
|
+
await unregister();
|
|
81
|
+
}
|
|
82
|
+
} else mod = await import(pathToFileURL(filePath).href);
|
|
83
|
+
const config = mod.default ?? mod;
|
|
84
|
+
const repoRoot = projectRoot || config.repoRoot || process.cwd();
|
|
85
|
+
const backends = normalizeBackendSources(config.analysis.backends);
|
|
86
|
+
return {
|
|
87
|
+
...config,
|
|
88
|
+
repoRoot,
|
|
89
|
+
cwd: repoRoot,
|
|
90
|
+
envs: config.envs ?? {},
|
|
91
|
+
analysis: {
|
|
92
|
+
...config.analysis,
|
|
93
|
+
backends
|
|
94
|
+
},
|
|
95
|
+
resolver: { alias: {
|
|
96
|
+
...getTsconfigAliases(),
|
|
97
|
+
...config.resolver?.alias
|
|
98
|
+
} }
|
|
99
|
+
};
|
|
100
|
+
} catch (error) {
|
|
101
|
+
throw new Error(`Unable to load Atlas configuration at ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region ../../node_modules/fast-string-truncated-width/dist/utils.js
|
|
107
|
+
const getCodePointsLength = (() => {
|
|
108
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
109
|
+
return (input) => {
|
|
110
|
+
let surrogatePairsNr = 0;
|
|
111
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
112
|
+
while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
|
|
113
|
+
return input.length - surrogatePairsNr;
|
|
114
|
+
};
|
|
115
|
+
})();
|
|
116
|
+
const isFullWidth = (x) => {
|
|
117
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
118
|
+
};
|
|
119
|
+
const isWideNotCJKTNotEmoji = (x) => {
|
|
120
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region ../../node_modules/fast-string-truncated-width/dist/index.js
|
|
125
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
126
|
+
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
127
|
+
const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
|
|
128
|
+
const TAB_RE = /\t{1,1000}/y;
|
|
129
|
+
const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
|
|
130
|
+
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
131
|
+
const MODIFIER_RE = /\p{M}+/gu;
|
|
132
|
+
const NO_TRUNCATION$1 = {
|
|
133
|
+
limit: Infinity,
|
|
134
|
+
ellipsis: ""
|
|
135
|
+
};
|
|
136
|
+
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
137
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
138
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
139
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
|
|
140
|
+
const ANSI_WIDTH = 0;
|
|
141
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
142
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
143
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
144
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
145
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
146
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
147
|
+
const PARSE_BLOCKS = [
|
|
148
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
149
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
150
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
151
|
+
[TAB_RE, TAB_WIDTH],
|
|
152
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
153
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
154
|
+
];
|
|
155
|
+
let indexPrev = 0;
|
|
156
|
+
let index = 0;
|
|
157
|
+
let length = input.length;
|
|
158
|
+
let lengthExtra = 0;
|
|
159
|
+
let truncationEnabled = false;
|
|
160
|
+
let truncationIndex = length;
|
|
161
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
162
|
+
let unmatchedStart = 0;
|
|
163
|
+
let unmatchedEnd = 0;
|
|
164
|
+
let width = 0;
|
|
165
|
+
let widthExtra = 0;
|
|
166
|
+
outer: while (true) {
|
|
167
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
168
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
169
|
+
lengthExtra = 0;
|
|
170
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
171
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
172
|
+
if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
|
|
173
|
+
else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
|
|
174
|
+
else widthExtra = REGULAR_WIDTH;
|
|
175
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
176
|
+
if (width + widthExtra > LIMIT) {
|
|
177
|
+
truncationEnabled = true;
|
|
178
|
+
break outer;
|
|
179
|
+
}
|
|
180
|
+
lengthExtra += char.length;
|
|
181
|
+
width += widthExtra;
|
|
182
|
+
}
|
|
183
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
184
|
+
}
|
|
185
|
+
if (index >= length) break outer;
|
|
186
|
+
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
187
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
188
|
+
BLOCK_RE.lastIndex = index;
|
|
189
|
+
if (BLOCK_RE.test(input)) {
|
|
190
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
191
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
192
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
193
|
+
if (width + widthExtra > LIMIT) {
|
|
194
|
+
truncationEnabled = true;
|
|
195
|
+
break outer;
|
|
196
|
+
}
|
|
197
|
+
width += widthExtra;
|
|
198
|
+
unmatchedStart = indexPrev;
|
|
199
|
+
unmatchedEnd = index;
|
|
200
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
201
|
+
continue outer;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
index += 1;
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
208
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
209
|
+
truncated: truncationEnabled,
|
|
210
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region ../../node_modules/fast-string-width/dist/index.js
|
|
216
|
+
const NO_TRUNCATION = {
|
|
217
|
+
limit: Infinity,
|
|
218
|
+
ellipsis: "",
|
|
219
|
+
ellipsisWidth: 0
|
|
220
|
+
};
|
|
221
|
+
const fastStringWidth = (input, options = {}) => {
|
|
222
|
+
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region ../../node_modules/fast-wrap-ansi/lib/main.js
|
|
227
|
+
const ESC = "\x1B";
|
|
228
|
+
const CSI = "";
|
|
229
|
+
const END_CODE = 39;
|
|
230
|
+
const ANSI_ESCAPE_BELL = "\x07";
|
|
231
|
+
const ANSI_CSI = "[";
|
|
232
|
+
const ANSI_OSC = "]";
|
|
233
|
+
const ANSI_SGR_TERMINATOR = "m";
|
|
234
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
235
|
+
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
236
|
+
const getClosingCode = (openingCode) => {
|
|
237
|
+
if (openingCode >= 30 && openingCode <= 37) return 39;
|
|
238
|
+
if (openingCode >= 90 && openingCode <= 97) return 39;
|
|
239
|
+
if (openingCode >= 40 && openingCode <= 47) return 49;
|
|
240
|
+
if (openingCode >= 100 && openingCode <= 107) return 49;
|
|
241
|
+
if (openingCode === 1 || openingCode === 2) return 22;
|
|
242
|
+
if (openingCode === 3) return 23;
|
|
243
|
+
if (openingCode === 4) return 24;
|
|
244
|
+
if (openingCode === 7) return 27;
|
|
245
|
+
if (openingCode === 8) return 28;
|
|
246
|
+
if (openingCode === 9) return 29;
|
|
247
|
+
if (openingCode === 0) return 0;
|
|
248
|
+
};
|
|
249
|
+
const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
250
|
+
const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
251
|
+
const wrapWord = (rows, word, columns) => {
|
|
252
|
+
const characters = word[Symbol.iterator]();
|
|
253
|
+
let isInsideEscape = false;
|
|
254
|
+
let isInsideLinkEscape = false;
|
|
255
|
+
let lastRow = rows.at(-1);
|
|
256
|
+
let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
|
|
257
|
+
let currentCharacter = characters.next();
|
|
258
|
+
let nextCharacter = characters.next();
|
|
259
|
+
let rawCharacterIndex = 0;
|
|
260
|
+
while (!currentCharacter.done) {
|
|
261
|
+
const character = currentCharacter.value;
|
|
262
|
+
const characterLength = fastStringWidth(character);
|
|
263
|
+
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
264
|
+
else {
|
|
265
|
+
rows.push(character);
|
|
266
|
+
visible = 0;
|
|
267
|
+
}
|
|
268
|
+
if (character === ESC || character === CSI) {
|
|
269
|
+
isInsideEscape = true;
|
|
270
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
271
|
+
}
|
|
272
|
+
if (isInsideEscape) {
|
|
273
|
+
if (isInsideLinkEscape) {
|
|
274
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
275
|
+
isInsideEscape = false;
|
|
276
|
+
isInsideLinkEscape = false;
|
|
277
|
+
}
|
|
278
|
+
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
279
|
+
} else {
|
|
280
|
+
visible += characterLength;
|
|
281
|
+
if (visible === columns && !nextCharacter.done) {
|
|
282
|
+
rows.push("");
|
|
283
|
+
visible = 0;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
currentCharacter = nextCharacter;
|
|
287
|
+
nextCharacter = characters.next();
|
|
288
|
+
rawCharacterIndex += character.length;
|
|
289
|
+
}
|
|
290
|
+
lastRow = rows.at(-1);
|
|
291
|
+
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
|
|
292
|
+
};
|
|
293
|
+
const stringVisibleTrimSpacesRight = (string) => {
|
|
294
|
+
const words = string.split(" ");
|
|
295
|
+
let last = words.length;
|
|
296
|
+
while (last) {
|
|
297
|
+
if (fastStringWidth(words[last - 1])) break;
|
|
298
|
+
last--;
|
|
299
|
+
}
|
|
300
|
+
if (last === words.length) return string;
|
|
301
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
302
|
+
};
|
|
303
|
+
const exec = (string, columns, options = {}) => {
|
|
304
|
+
if (options.trim !== false && string.trim() === "") return "";
|
|
305
|
+
let returnValue = "";
|
|
306
|
+
let escapeCode;
|
|
307
|
+
let escapeUrl;
|
|
308
|
+
const words = string.split(" ");
|
|
309
|
+
let rows = [""];
|
|
310
|
+
let rowLength = 0;
|
|
311
|
+
for (let index = 0; index < words.length; index++) {
|
|
312
|
+
const word = words[index];
|
|
313
|
+
if (options.trim !== false) {
|
|
314
|
+
const row = rows.at(-1) ?? "";
|
|
315
|
+
const trimmed = row.trimStart();
|
|
316
|
+
if (row.length !== trimmed.length) {
|
|
317
|
+
rows[rows.length - 1] = trimmed;
|
|
318
|
+
rowLength = fastStringWidth(trimmed);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (index !== 0) {
|
|
322
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
323
|
+
rows.push("");
|
|
324
|
+
rowLength = 0;
|
|
325
|
+
}
|
|
326
|
+
if (rowLength || options.trim === false) {
|
|
327
|
+
rows[rows.length - 1] += " ";
|
|
328
|
+
rowLength++;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const wordLength = fastStringWidth(word);
|
|
332
|
+
if (options.hard && wordLength > columns) {
|
|
333
|
+
const remainingColumns = columns - rowLength;
|
|
334
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
335
|
+
if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
|
|
336
|
+
wrapWord(rows, word, columns);
|
|
337
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
341
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
342
|
+
wrapWord(rows, word, columns);
|
|
343
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
rows.push("");
|
|
347
|
+
rowLength = 0;
|
|
348
|
+
}
|
|
349
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
350
|
+
wrapWord(rows, word, columns);
|
|
351
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
rows[rows.length - 1] += word;
|
|
355
|
+
rowLength += wordLength;
|
|
356
|
+
}
|
|
357
|
+
if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
358
|
+
const preString = rows.join("\n");
|
|
359
|
+
let inSurrogate = false;
|
|
360
|
+
for (let i = 0; i < preString.length; i++) {
|
|
361
|
+
const character = preString[i];
|
|
362
|
+
returnValue += character;
|
|
363
|
+
if (!inSurrogate) {
|
|
364
|
+
inSurrogate = character >= "\ud800" && character <= "\udbff";
|
|
365
|
+
if (inSurrogate) continue;
|
|
366
|
+
} else inSurrogate = false;
|
|
367
|
+
if (character === ESC || character === CSI) {
|
|
368
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
369
|
+
const groups = GROUP_REGEX.exec(preString)?.groups;
|
|
370
|
+
if (groups?.code !== void 0) {
|
|
371
|
+
const code = Number.parseFloat(groups.code);
|
|
372
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
373
|
+
} else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
374
|
+
}
|
|
375
|
+
if (preString[i + 1] === "\n") {
|
|
376
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink("");
|
|
377
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
378
|
+
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
379
|
+
} else if (character === "\n") {
|
|
380
|
+
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
381
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return returnValue;
|
|
385
|
+
};
|
|
386
|
+
const CRLF_OR_LF = /\r?\n/;
|
|
387
|
+
function wrapAnsi(string, columns, options) {
|
|
388
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region ../../node_modules/sisteransi/src/index.js
|
|
393
|
+
var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
394
|
+
const ESC = "\x1B";
|
|
395
|
+
const CSI = `${ESC}[`;
|
|
396
|
+
const beep = "\x07";
|
|
397
|
+
const cursor = {
|
|
398
|
+
to(x, y) {
|
|
399
|
+
if (!y) return `${CSI}${x + 1}G`;
|
|
400
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
401
|
+
},
|
|
402
|
+
move(x, y) {
|
|
403
|
+
let ret = "";
|
|
404
|
+
if (x < 0) ret += `${CSI}${-x}D`;
|
|
405
|
+
else if (x > 0) ret += `${CSI}${x}C`;
|
|
406
|
+
if (y < 0) ret += `${CSI}${-y}A`;
|
|
407
|
+
else if (y > 0) ret += `${CSI}${y}B`;
|
|
408
|
+
return ret;
|
|
409
|
+
},
|
|
410
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
411
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
412
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
413
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
414
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
415
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
416
|
+
left: `${CSI}G`,
|
|
417
|
+
hide: `${CSI}?25l`,
|
|
418
|
+
show: `${CSI}?25h`,
|
|
419
|
+
save: `${ESC}7`,
|
|
420
|
+
restore: `${ESC}8`
|
|
421
|
+
};
|
|
422
|
+
const scroll = {
|
|
423
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
424
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
425
|
+
};
|
|
426
|
+
const erase = {
|
|
427
|
+
screen: `${CSI}2J`,
|
|
428
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
429
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
430
|
+
line: `${CSI}2K`,
|
|
431
|
+
lineEnd: `${CSI}K`,
|
|
432
|
+
lineStart: `${CSI}1K`,
|
|
433
|
+
lines(count) {
|
|
434
|
+
let clear = "";
|
|
435
|
+
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
436
|
+
if (count) clear += cursor.left;
|
|
437
|
+
return clear;
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
module.exports = {
|
|
441
|
+
cursor,
|
|
442
|
+
scroll,
|
|
443
|
+
erase,
|
|
444
|
+
beep
|
|
445
|
+
};
|
|
446
|
+
}));
|
|
447
|
+
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region ../../node_modules/@clack/core/dist/index.mjs
|
|
450
|
+
var import_src = require_src();
|
|
451
|
+
function findCursor(s, o, l) {
|
|
452
|
+
if (!l.some((r) => !r.disabled)) return s;
|
|
453
|
+
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
454
|
+
return l[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
455
|
+
}
|
|
456
|
+
const settings = {
|
|
457
|
+
actions: /* @__PURE__ */ new Set([
|
|
458
|
+
"up",
|
|
459
|
+
"down",
|
|
460
|
+
"left",
|
|
461
|
+
"right",
|
|
462
|
+
"space",
|
|
463
|
+
"enter",
|
|
464
|
+
"cancel"
|
|
465
|
+
]),
|
|
466
|
+
aliases: /* @__PURE__ */ new Map([
|
|
467
|
+
["k", "up"],
|
|
468
|
+
["j", "down"],
|
|
469
|
+
["h", "left"],
|
|
470
|
+
["l", "right"],
|
|
471
|
+
["", "cancel"],
|
|
472
|
+
["escape", "cancel"]
|
|
473
|
+
]),
|
|
474
|
+
messages: {
|
|
475
|
+
cancel: "Canceled",
|
|
476
|
+
error: "Something went wrong"
|
|
477
|
+
},
|
|
478
|
+
withGuide: true,
|
|
479
|
+
date: {
|
|
480
|
+
monthNames: [...[
|
|
481
|
+
"January",
|
|
482
|
+
"February",
|
|
483
|
+
"March",
|
|
484
|
+
"April",
|
|
485
|
+
"May",
|
|
486
|
+
"June",
|
|
487
|
+
"July",
|
|
488
|
+
"August",
|
|
489
|
+
"September",
|
|
490
|
+
"October",
|
|
491
|
+
"November",
|
|
492
|
+
"December"
|
|
493
|
+
]],
|
|
494
|
+
messages: {
|
|
495
|
+
required: "Please enter a valid date",
|
|
496
|
+
invalidMonth: "There are only 12 months in a year",
|
|
497
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
498
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
499
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
function isActionKey(n, e) {
|
|
504
|
+
if (typeof n == "string") return settings.aliases.get(n) === e;
|
|
505
|
+
for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
function diffLines(i, s) {
|
|
509
|
+
if (i === s) return;
|
|
510
|
+
const e = i.split(`
|
|
511
|
+
`), t = s.split(`
|
|
512
|
+
`), r = Math.max(e.length, t.length), f = [];
|
|
513
|
+
for (let n = 0; n < r; n++) e[n] !== t[n] && f.push(n);
|
|
514
|
+
return {
|
|
515
|
+
lines: f,
|
|
516
|
+
numLinesBefore: e.length,
|
|
517
|
+
numLinesAfter: t.length,
|
|
518
|
+
numLines: r
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
const R = globalThis.process.platform.startsWith("win");
|
|
522
|
+
const CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
523
|
+
function isCancel(e) {
|
|
524
|
+
return e === CANCEL_SYMBOL;
|
|
525
|
+
}
|
|
526
|
+
function setRawMode(e, r) {
|
|
527
|
+
const o = e;
|
|
528
|
+
o.isTTY && o.setRawMode(r);
|
|
529
|
+
}
|
|
530
|
+
function block({ input: e = stdin, output: r = stdout, overwrite: o = true, hideCursor: t = true } = {}) {
|
|
531
|
+
const s = l.createInterface({
|
|
532
|
+
input: e,
|
|
533
|
+
output: r,
|
|
534
|
+
prompt: "",
|
|
535
|
+
tabSize: 1
|
|
536
|
+
});
|
|
537
|
+
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
538
|
+
const n = (f, { name: a, sequence: p }) => {
|
|
539
|
+
if (isActionKey([
|
|
540
|
+
String(f),
|
|
541
|
+
a,
|
|
542
|
+
p
|
|
543
|
+
], "cancel")) {
|
|
544
|
+
t && r.write(import_src.cursor.show), process.exit(0);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
if (!o) return;
|
|
548
|
+
const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
549
|
+
l.moveCursor(r, i, m, () => {
|
|
550
|
+
l.clearLine(r, 1, () => {
|
|
551
|
+
e.once("keypress", n);
|
|
552
|
+
});
|
|
553
|
+
});
|
|
554
|
+
};
|
|
555
|
+
return t && r.write(import_src.cursor.hide), e.once("keypress", n), () => {
|
|
556
|
+
e.off("keypress", n), t && r.write(import_src.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
|
|
560
|
+
const getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
561
|
+
function wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
|
|
562
|
+
const f = getColumns(e ?? stdout);
|
|
563
|
+
return wrapAnsi(r, f - o.length, {
|
|
564
|
+
hard: true,
|
|
565
|
+
trim: false
|
|
566
|
+
}).split(`
|
|
567
|
+
`).map((c, i, m) => {
|
|
568
|
+
const d = n ? n(c, i) : c;
|
|
569
|
+
return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
570
|
+
}).join(`
|
|
571
|
+
`);
|
|
572
|
+
}
|
|
573
|
+
function runValidation(e, n) {
|
|
574
|
+
if ("~standard" in e) {
|
|
575
|
+
const a = e["~standard"].validate(n);
|
|
576
|
+
if (a instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
577
|
+
return a.issues?.at(0)?.message;
|
|
578
|
+
}
|
|
579
|
+
return e(n);
|
|
580
|
+
}
|
|
581
|
+
var V = class {
|
|
582
|
+
input;
|
|
583
|
+
output;
|
|
584
|
+
_abortSignal;
|
|
585
|
+
rl;
|
|
586
|
+
opts;
|
|
587
|
+
_render;
|
|
588
|
+
_track = false;
|
|
589
|
+
_prevFrame = "";
|
|
590
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
591
|
+
_cursor = 0;
|
|
592
|
+
state = "initial";
|
|
593
|
+
error = "";
|
|
594
|
+
value;
|
|
595
|
+
userInput = "";
|
|
596
|
+
constructor(t, e = true) {
|
|
597
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
|
|
598
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Unsubscribe all listeners
|
|
602
|
+
*/
|
|
603
|
+
unsubscribe() {
|
|
604
|
+
this._subscribers.clear();
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Set a subscriber with opts
|
|
608
|
+
* @param event - The event name
|
|
609
|
+
*/
|
|
610
|
+
setSubscriber(t, e) {
|
|
611
|
+
const i = this._subscribers.get(t) ?? [];
|
|
612
|
+
i.push(e), this._subscribers.set(t, i);
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Subscribe to an event
|
|
616
|
+
* @param event - The event name
|
|
617
|
+
* @param cb - The callback
|
|
618
|
+
*/
|
|
619
|
+
on(t, e) {
|
|
620
|
+
this.setSubscriber(t, { cb: e });
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Subscribe to an event once
|
|
624
|
+
* @param event - The event name
|
|
625
|
+
* @param cb - The callback
|
|
626
|
+
*/
|
|
627
|
+
once(t, e) {
|
|
628
|
+
this.setSubscriber(t, {
|
|
629
|
+
cb: e,
|
|
630
|
+
once: true
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Emit an event with data
|
|
635
|
+
* @param event - The event name
|
|
636
|
+
* @param data - The data to pass to the callback
|
|
637
|
+
*/
|
|
638
|
+
emit(t, ...e) {
|
|
639
|
+
const i = this._subscribers.get(t) ?? [], n = [];
|
|
640
|
+
for (const s of i) s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
641
|
+
for (const s of n) s();
|
|
642
|
+
}
|
|
643
|
+
prompt() {
|
|
644
|
+
return new Promise((t) => {
|
|
645
|
+
if (this._abortSignal) {
|
|
646
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
|
|
647
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
648
|
+
this.state = "cancel", this.close();
|
|
649
|
+
}, { once: true });
|
|
650
|
+
}
|
|
651
|
+
this.rl = l__default.createInterface({
|
|
652
|
+
input: this.input,
|
|
653
|
+
tabSize: 2,
|
|
654
|
+
prompt: "",
|
|
655
|
+
escapeCodeTimeout: 50,
|
|
656
|
+
terminal: true
|
|
657
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
658
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
659
|
+
}), this.once("cancel", () => {
|
|
660
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
_isActionKey(t, e) {
|
|
665
|
+
return t === " ";
|
|
666
|
+
}
|
|
667
|
+
_shouldSubmit(t, e) {
|
|
668
|
+
return true;
|
|
669
|
+
}
|
|
670
|
+
_setValue(t) {
|
|
671
|
+
this.value = t, this.emit("value", this.value);
|
|
672
|
+
}
|
|
673
|
+
_setUserInput(t, e) {
|
|
674
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
675
|
+
}
|
|
676
|
+
_clearUserInput() {
|
|
677
|
+
this.rl?.write(null, {
|
|
678
|
+
ctrl: true,
|
|
679
|
+
name: "u"
|
|
680
|
+
}), this._setUserInput("");
|
|
681
|
+
}
|
|
682
|
+
onKeypress(t, e) {
|
|
683
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
|
|
684
|
+
ctrl: true,
|
|
685
|
+
name: "h"
|
|
686
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
|
|
687
|
+
if (this.opts.validate) {
|
|
688
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
689
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
690
|
+
}
|
|
691
|
+
this.state !== "error" && (this.state = "submit");
|
|
692
|
+
}
|
|
693
|
+
isActionKey([
|
|
694
|
+
t,
|
|
695
|
+
e?.name,
|
|
696
|
+
e?.sequence
|
|
697
|
+
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
698
|
+
}
|
|
699
|
+
close() {
|
|
700
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
701
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
702
|
+
}
|
|
703
|
+
restoreCursor() {
|
|
704
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
|
|
705
|
+
hard: true,
|
|
706
|
+
trim: false
|
|
707
|
+
}).split(`
|
|
708
|
+
`).length - 1;
|
|
709
|
+
this.output.write(import_src.cursor.move(-999, t * -1));
|
|
710
|
+
}
|
|
711
|
+
render() {
|
|
712
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
713
|
+
hard: true,
|
|
714
|
+
trim: false
|
|
715
|
+
});
|
|
716
|
+
if (t !== this._prevFrame) {
|
|
717
|
+
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
718
|
+
else {
|
|
719
|
+
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
720
|
+
if (this.restoreCursor(), e) {
|
|
721
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
722
|
+
let r = e.lines.find((o) => o >= n);
|
|
723
|
+
if (r === void 0) {
|
|
724
|
+
this._prevFrame = t;
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
if (e.lines.length === 1) {
|
|
728
|
+
this.output.write(import_src.cursor.move(0, r - s)), this.output.write(import_src.erase.lines(1));
|
|
729
|
+
const o = t.split(`
|
|
730
|
+
`);
|
|
731
|
+
this.output.write(o[r]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - r - 1));
|
|
732
|
+
return;
|
|
733
|
+
} else if (e.lines.length > 1) {
|
|
734
|
+
if (n < s) r = n;
|
|
735
|
+
else {
|
|
736
|
+
const h = r - s;
|
|
737
|
+
h > 0 && this.output.write(import_src.cursor.move(0, h));
|
|
738
|
+
}
|
|
739
|
+
this.output.write(import_src.erase.down());
|
|
740
|
+
const f = t.split(`
|
|
741
|
+
`).slice(r);
|
|
742
|
+
this.output.write(f.join(`
|
|
743
|
+
`)), this._prevFrame = t;
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
this.output.write(import_src.erase.down());
|
|
748
|
+
}
|
|
749
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
let n$1 = class n extends V {
|
|
754
|
+
options;
|
|
755
|
+
cursor = 0;
|
|
756
|
+
get _selectedValue() {
|
|
757
|
+
return this.options[this.cursor];
|
|
758
|
+
}
|
|
759
|
+
changeValue() {
|
|
760
|
+
const e = this._selectedValue;
|
|
761
|
+
this.value = e === void 0 ? void 0 : e.value;
|
|
762
|
+
}
|
|
763
|
+
constructor(e) {
|
|
764
|
+
super(e, false), this.options = e.options;
|
|
765
|
+
const o = this.options.findIndex(({ value: s }) => s === e.initialValue), t = o === -1 ? 0 : o;
|
|
766
|
+
this.cursor = this.options[t]?.disabled ? findCursor(t, 1, this.options) : t, this.changeValue(), this.on("cursor", (s) => {
|
|
767
|
+
switch (s) {
|
|
768
|
+
case "left":
|
|
769
|
+
case "up":
|
|
770
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
771
|
+
break;
|
|
772
|
+
case "down":
|
|
773
|
+
case "right": this.cursor = findCursor(this.cursor, 1, this.options);
|
|
774
|
+
}
|
|
775
|
+
this.changeValue();
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
//#endregion
|
|
781
|
+
//#region ../../node_modules/@clack/prompts/dist/index.mjs
|
|
782
|
+
function isUnicodeSupported() {
|
|
783
|
+
if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
|
|
784
|
+
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
785
|
+
}
|
|
786
|
+
const unicode = isUnicodeSupported();
|
|
787
|
+
const isCI = () => process.env.CI === "true";
|
|
788
|
+
const unicodeOr = (o, e) => unicode ? o : e;
|
|
789
|
+
const S_STEP_ACTIVE = unicodeOr("◆", "*");
|
|
790
|
+
const S_STEP_CANCEL = unicodeOr("■", "x");
|
|
791
|
+
const S_STEP_ERROR = unicodeOr("▲", "x");
|
|
792
|
+
const S_STEP_SUBMIT = unicodeOr("◇", "o");
|
|
793
|
+
const S_BAR_START = unicodeOr("┌", "T");
|
|
794
|
+
const S_BAR = unicodeOr("│", "|");
|
|
795
|
+
const S_BAR_END = unicodeOr("└", "—");
|
|
796
|
+
const S_BAR_START_RIGHT = unicodeOr("┐", "T");
|
|
797
|
+
const S_BAR_END_RIGHT = unicodeOr("┘", "—");
|
|
798
|
+
const S_RADIO_ACTIVE = unicodeOr("●", ">");
|
|
799
|
+
const S_RADIO_INACTIVE = unicodeOr("○", " ");
|
|
800
|
+
const S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]");
|
|
801
|
+
const S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]");
|
|
802
|
+
const S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]");
|
|
803
|
+
const S_PASSWORD_MASK = unicodeOr("▪", "•");
|
|
804
|
+
const S_BAR_H = unicodeOr("─", "-");
|
|
805
|
+
const S_CORNER_TOP_RIGHT = unicodeOr("╮", "+");
|
|
806
|
+
const S_CONNECT_LEFT = unicodeOr("├", "+");
|
|
807
|
+
const S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+");
|
|
808
|
+
const S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+");
|
|
809
|
+
const S_CORNER_TOP_LEFT = unicodeOr("╭", "+");
|
|
810
|
+
const S_INFO = unicodeOr("●", "•");
|
|
811
|
+
const S_SUCCESS = unicodeOr("◆", "*");
|
|
812
|
+
const S_WARN = unicodeOr("▲", "!");
|
|
813
|
+
const S_ERROR = unicodeOr("■", "x");
|
|
814
|
+
const symbol = (o) => {
|
|
815
|
+
switch (o) {
|
|
816
|
+
case "initial":
|
|
817
|
+
case "active": return styleText("cyan", S_STEP_ACTIVE);
|
|
818
|
+
case "cancel": return styleText("red", S_STEP_CANCEL);
|
|
819
|
+
case "error": return styleText("yellow", S_STEP_ERROR);
|
|
820
|
+
case "submit": return styleText("green", S_STEP_SUBMIT);
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
const symbolBar = (o) => {
|
|
824
|
+
switch (o) {
|
|
825
|
+
case "initial":
|
|
826
|
+
case "active": return styleText("cyan", S_BAR);
|
|
827
|
+
case "cancel": return styleText("red", S_BAR);
|
|
828
|
+
case "error": return styleText("yellow", S_BAR);
|
|
829
|
+
case "submit": return styleText("green", S_BAR);
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
function formatInstructionFooter(o, e) {
|
|
833
|
+
const r = [`${e ? `${styleText("cyan", S_BAR)} ` : ""}${o.join(" • ")}`];
|
|
834
|
+
return e && r.push(styleText("cyan", S_BAR_END)), r;
|
|
835
|
+
}
|
|
836
|
+
const I = (l, e, w, p, b, C = false) => {
|
|
837
|
+
let r = e, O = 0;
|
|
838
|
+
if (C) for (let i = p - 1; i >= w; i--) {
|
|
839
|
+
const m = l[i];
|
|
840
|
+
if (m && (r -= m.length), O++, r <= b) break;
|
|
841
|
+
}
|
|
842
|
+
else for (let i = w; i < p; i++) {
|
|
843
|
+
const m = l[i];
|
|
844
|
+
if (m && (r -= m.length), O++, r <= b) break;
|
|
845
|
+
}
|
|
846
|
+
return {
|
|
847
|
+
lineCount: r,
|
|
848
|
+
removals: O
|
|
849
|
+
};
|
|
850
|
+
};
|
|
851
|
+
const limitOptions = ({ cursor: l, options: e, style: w, output: p = process.stdout, maxItems: b = Number.POSITIVE_INFINITY, columnPadding: C = 0, rowPadding: r = 4 }) => {
|
|
852
|
+
const i = getColumns(p) - C, m = getRows(p), M = styleText("dim", "..."), v = Math.max(m - r, 0), a = Math.max(Math.min(b, v), 5);
|
|
853
|
+
let f = 0;
|
|
854
|
+
l >= a - 3 && (f = Math.max(Math.min(l - a + 3, e.length - a), 0));
|
|
855
|
+
let d = a < e.length && f > 0, c = a < e.length && f + a < e.length;
|
|
856
|
+
const W = Math.min(f + a, e.length), s = [];
|
|
857
|
+
let g = 0;
|
|
858
|
+
d && g++, c && g++;
|
|
859
|
+
const T = f + (d ? 1 : 0), y = W - (c ? 1 : 0);
|
|
860
|
+
for (let t = T; t < y; t++) {
|
|
861
|
+
const n = e[t], o = n ? w(n, t === l) : "", h = wrapAnsi(o, i, {
|
|
862
|
+
hard: true,
|
|
863
|
+
trim: false
|
|
864
|
+
}).split(`
|
|
865
|
+
`);
|
|
866
|
+
s.push(h), g += h.length;
|
|
867
|
+
}
|
|
868
|
+
if (g > v) {
|
|
869
|
+
let t = 0, n = 0, o = g;
|
|
870
|
+
const h = l - T;
|
|
871
|
+
let u = v;
|
|
872
|
+
const L = () => I(s, o, 0, h, u), E = () => I(s, o, h + 1, s.length, u, true);
|
|
873
|
+
d ? ({lineCount: o, removals: t} = L(), o > u && (c || (u -= 1), {lineCount: o, removals: n} = E())) : (c || (u -= 1), {lineCount: o, removals: n} = E(), o > u && (u -= 1, {lineCount: o, removals: t} = L())), t > 0 && (d = true, s.splice(0, t)), n > 0 && (c = true, s.splice(s.length - n, n));
|
|
874
|
+
}
|
|
875
|
+
const x = [];
|
|
876
|
+
d && x.push(M);
|
|
877
|
+
for (const t of s) for (const n of t) x.push(n);
|
|
878
|
+
return c && x.push(M), x;
|
|
879
|
+
};
|
|
880
|
+
const MULTISELECT_INSTRUCTIONS = [
|
|
881
|
+
`${styleText("dim", "↑/↓")} to navigate`,
|
|
882
|
+
`${styleText("dim", "Space:")} select`,
|
|
883
|
+
`${styleText("dim", "Enter:")} confirm`
|
|
884
|
+
];
|
|
885
|
+
const log = {
|
|
886
|
+
message: (s = [], { symbol: e = styleText("gray", S_BAR), secondarySymbol: r = styleText("gray", S_BAR), output: m = process.stdout, spacing: l = 1, withGuide: c } = {}) => {
|
|
887
|
+
const t = [], o = c ?? settings.withGuide, f = o ? r : "", O = o ? `${e} ` : "", u = o ? `${r} ` : "";
|
|
888
|
+
for (let i = 0; i < l; i++) t.push(f);
|
|
889
|
+
const g = Array.isArray(s) ? s : s.split(`
|
|
890
|
+
`);
|
|
891
|
+
if (g.length > 0) {
|
|
892
|
+
const [i, ...y] = g;
|
|
893
|
+
i.length > 0 ? t.push(`${O}${i}`) : t.push(o ? e : "");
|
|
894
|
+
for (const p of y) p.length > 0 ? t.push(`${u}${p}`) : t.push(o ? r : "");
|
|
895
|
+
}
|
|
896
|
+
m.write(`${t.join(`
|
|
897
|
+
`)}
|
|
898
|
+
`);
|
|
899
|
+
},
|
|
900
|
+
info: (s, e) => {
|
|
901
|
+
log.message(s, {
|
|
902
|
+
...e,
|
|
903
|
+
symbol: styleText("blue", S_INFO)
|
|
904
|
+
});
|
|
905
|
+
},
|
|
906
|
+
success: (s, e) => {
|
|
907
|
+
log.message(s, {
|
|
908
|
+
...e,
|
|
909
|
+
symbol: styleText("green", S_SUCCESS)
|
|
910
|
+
});
|
|
911
|
+
},
|
|
912
|
+
step: (s, e) => {
|
|
913
|
+
log.message(s, {
|
|
914
|
+
...e,
|
|
915
|
+
symbol: styleText("green", S_STEP_SUBMIT)
|
|
916
|
+
});
|
|
917
|
+
},
|
|
918
|
+
warn: (s, e) => {
|
|
919
|
+
log.message(s, {
|
|
920
|
+
...e,
|
|
921
|
+
symbol: styleText("yellow", S_WARN)
|
|
922
|
+
});
|
|
923
|
+
},
|
|
924
|
+
/** alias for `log.warn()`. */
|
|
925
|
+
warning: (s, e) => {
|
|
926
|
+
log.warn(s, e);
|
|
927
|
+
},
|
|
928
|
+
error: (s, e) => {
|
|
929
|
+
log.message(s, {
|
|
930
|
+
...e,
|
|
931
|
+
symbol: styleText("red", S_ERROR)
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
const cancel = (o = "", t) => {
|
|
936
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_END)} ` : "";
|
|
937
|
+
i.write(`${e}${styleText("red", o)}
|
|
938
|
+
|
|
939
|
+
`);
|
|
940
|
+
};
|
|
941
|
+
const intro = (o = "", t) => {
|
|
942
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_START)} ` : "";
|
|
943
|
+
i.write(`${e}${o}
|
|
944
|
+
`);
|
|
945
|
+
};
|
|
946
|
+
const outro = (o = "", t) => {
|
|
947
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)}
|
|
948
|
+
${styleText("gray", S_BAR_END)} ` : "";
|
|
949
|
+
i.write(`${e}${o}
|
|
950
|
+
|
|
951
|
+
`);
|
|
952
|
+
};
|
|
953
|
+
const W$1 = (o) => o;
|
|
954
|
+
const C = (o, e, s) => {
|
|
955
|
+
const a = {
|
|
956
|
+
hard: true,
|
|
957
|
+
trim: false
|
|
958
|
+
}, i = wrapAnsi(o, e, a).split(`
|
|
959
|
+
`), c = i.reduce((n, t) => Math.max(fastStringWidth(t), n), 0), g = e - (i.map(s).reduce((n, t) => Math.max(fastStringWidth(t), n), 0) - c);
|
|
960
|
+
return wrapAnsi(o, g, a);
|
|
961
|
+
};
|
|
962
|
+
const note = (o = "", e = "", s) => {
|
|
963
|
+
const a = s?.output ?? process$1.stdout, i = s?.withGuide ?? settings.withGuide, c = s?.format ?? W$1, g = [
|
|
964
|
+
"",
|
|
965
|
+
...C(o, getColumns(a) - 6, c).split(`
|
|
966
|
+
`).map(c),
|
|
967
|
+
""
|
|
968
|
+
], n = fastStringWidth(e), t = Math.max(g.reduce((m, F) => {
|
|
969
|
+
const O = fastStringWidth(F);
|
|
970
|
+
return O > m ? O : m;
|
|
971
|
+
}, 0), n) + 2, h = g.map((m) => `${styleText("gray", S_BAR)} ${m}${" ".repeat(t - fastStringWidth(m))}${styleText("gray", S_BAR)}`).join(`
|
|
972
|
+
`), T = i ? `${styleText("gray", S_BAR)}
|
|
973
|
+
` : "", l$1 = i ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
974
|
+
a.write(`${T}${styleText("green", S_STEP_SUBMIT)} ${styleText("reset", e)} ${styleText("gray", S_BAR_H.repeat(Math.max(t - n - 1, 1)) + S_CORNER_TOP_RIGHT)}
|
|
975
|
+
${h}
|
|
976
|
+
${styleText("gray", l$1 + S_BAR_H.repeat(t + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
977
|
+
`);
|
|
978
|
+
};
|
|
979
|
+
const W = (l) => styleText("magenta", l);
|
|
980
|
+
const spinner = ({ indicator: l = "dots", onCancel: h, output: n = process.stdout, cancelMessage: G, errorMessage: O, frames: E = unicode ? [
|
|
981
|
+
"◒",
|
|
982
|
+
"◐",
|
|
983
|
+
"◓",
|
|
984
|
+
"◑"
|
|
985
|
+
] : [
|
|
986
|
+
"•",
|
|
987
|
+
"o",
|
|
988
|
+
"O",
|
|
989
|
+
"0"
|
|
990
|
+
], delay: F = unicode ? 80 : 120, signal: m, ...I } = {}) => {
|
|
991
|
+
const u = isCI();
|
|
992
|
+
let M, T, d = false, S = false, s = "", p, w = performance.now();
|
|
993
|
+
const x = getColumns(n), k = I?.styleFrame ?? W, g = (e) => {
|
|
994
|
+
const r = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
995
|
+
S = e === 1, d && (a(r, e), S && typeof h == "function" && h());
|
|
996
|
+
}, f = () => g(2), i = () => g(1), A = () => {
|
|
997
|
+
process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g), m && m.addEventListener("abort", i);
|
|
998
|
+
}, H = () => {
|
|
999
|
+
process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g), m && m.removeEventListener("abort", i);
|
|
1000
|
+
}, y = () => {
|
|
1001
|
+
if (p === void 0) return;
|
|
1002
|
+
u && n.write(`
|
|
1003
|
+
`);
|
|
1004
|
+
const r = wrapAnsi(p, x, {
|
|
1005
|
+
hard: true,
|
|
1006
|
+
trim: false
|
|
1007
|
+
}).split(`
|
|
1008
|
+
`);
|
|
1009
|
+
r.length > 1 && n.write(import_src.cursor.up(r.length - 1)), n.write(import_src.cursor.to(0)), n.write(import_src.erase.down());
|
|
1010
|
+
}, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
|
|
1011
|
+
const r = (performance.now() - e) / 1e3, t = Math.floor(r / 60), o = Math.floor(r % 60);
|
|
1012
|
+
return t > 0 ? `[${t}m ${o}s]` : `[${o}s]`;
|
|
1013
|
+
}, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
1014
|
+
d = true, M = block({ output: n }), s = C(e), w = performance.now(), N && n.write(`${styleText("gray", S_BAR)}
|
|
1015
|
+
`);
|
|
1016
|
+
let r = 0, t = 0;
|
|
1017
|
+
A(), T = setInterval(() => {
|
|
1018
|
+
if (u && s === p) return;
|
|
1019
|
+
y(), p = s;
|
|
1020
|
+
const o = k(E[r]);
|
|
1021
|
+
let v;
|
|
1022
|
+
if (u) v = `${o} ${s}...`;
|
|
1023
|
+
else if (l === "timer") v = `${o} ${s} ${_(w)}`;
|
|
1024
|
+
else {
|
|
1025
|
+
const B = ".".repeat(Math.floor(t)).slice(0, 3);
|
|
1026
|
+
v = `${o} ${s}${B}`;
|
|
1027
|
+
}
|
|
1028
|
+
const j = wrapAnsi(v, x, {
|
|
1029
|
+
hard: true,
|
|
1030
|
+
trim: false
|
|
1031
|
+
});
|
|
1032
|
+
n.write(j), r = r + 1 < E.length ? r + 1 : 0, t = t < 4 ? t + .125 : 0;
|
|
1033
|
+
}, F);
|
|
1034
|
+
}, a = (e = "", r = 0, t = false) => {
|
|
1035
|
+
if (!d) return;
|
|
1036
|
+
d = false, clearInterval(T), y();
|
|
1037
|
+
const o = r === 0 ? styleText("green", S_STEP_SUBMIT) : r === 1 ? styleText("red", S_STEP_CANCEL) : styleText("red", S_STEP_ERROR);
|
|
1038
|
+
s = e ?? s, t || (l === "timer" ? n.write(`${o} ${s} ${_(w)}
|
|
1039
|
+
`) : n.write(`${o} ${s}
|
|
1040
|
+
`)), H(), M();
|
|
1041
|
+
};
|
|
1042
|
+
return {
|
|
1043
|
+
start: P,
|
|
1044
|
+
stop: (e = "") => a(e, 0),
|
|
1045
|
+
message: (e = "") => {
|
|
1046
|
+
s = C(e ?? s);
|
|
1047
|
+
},
|
|
1048
|
+
cancel: (e = "") => a(e, 1),
|
|
1049
|
+
error: (e = "") => a(e, 2),
|
|
1050
|
+
clear: () => a("", 0, true),
|
|
1051
|
+
get isCancelled() {
|
|
1052
|
+
return S;
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
};
|
|
1056
|
+
const u = {
|
|
1057
|
+
light: unicodeOr("─", "-"),
|
|
1058
|
+
heavy: unicodeOr("━", "="),
|
|
1059
|
+
block: unicodeOr("█", "#")
|
|
1060
|
+
};
|
|
1061
|
+
function progress({ style: o = "heavy", max: d = 100, size: v = 40, ...x } = {}) {
|
|
1062
|
+
const r = spinner(x);
|
|
1063
|
+
let a = 0, n = "";
|
|
1064
|
+
const c = Math.max(1, d), l = Math.max(1, v), S = (t) => {
|
|
1065
|
+
switch (t) {
|
|
1066
|
+
case "initial":
|
|
1067
|
+
case "active": return (e) => styleText("magenta", e);
|
|
1068
|
+
case "error":
|
|
1069
|
+
case "cancel": return (e) => styleText("red", e);
|
|
1070
|
+
case "submit": return (e) => styleText("green", e);
|
|
1071
|
+
default: return (e) => styleText("magenta", e);
|
|
1072
|
+
}
|
|
1073
|
+
}, p = (t, e) => {
|
|
1074
|
+
const m = Math.floor(a / c * l);
|
|
1075
|
+
return `${S(t)(u[o].repeat(m))}${styleText("dim", u[o].repeat(l - m))} ${e}`;
|
|
1076
|
+
}, h = (t = "") => {
|
|
1077
|
+
n = t, r.start(p("initial", t));
|
|
1078
|
+
}, g = (t = 1, e) => {
|
|
1079
|
+
a = Math.min(c, t + a), r.message(p("active", e ?? n)), n = e ?? n;
|
|
1080
|
+
};
|
|
1081
|
+
return {
|
|
1082
|
+
start: h,
|
|
1083
|
+
stop: r.stop,
|
|
1084
|
+
cancel: r.cancel,
|
|
1085
|
+
error: r.error,
|
|
1086
|
+
clear: r.clear,
|
|
1087
|
+
advance: g,
|
|
1088
|
+
isCancelled: r.isCancelled,
|
|
1089
|
+
message: (t) => g(0, t)
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
const SELECT_INSTRUCTIONS = [`${styleText("dim", "↑/↓")} to navigate`, `${styleText("dim", "Enter:")} confirm`];
|
|
1093
|
+
const c = (t, o) => t.includes(`
|
|
1094
|
+
`) ? t.split(`
|
|
1095
|
+
`).map((d) => o(d)).join(`
|
|
1096
|
+
`) : o(t);
|
|
1097
|
+
const select = (t) => {
|
|
1098
|
+
const o = (n, m) => {
|
|
1099
|
+
if (n === void 0) return "";
|
|
1100
|
+
const s = n.label ?? String(n.value);
|
|
1101
|
+
switch (m) {
|
|
1102
|
+
case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${c(s, (i) => styleText("gray", i))}${n.hint ? ` ${styleText("dim", `(${n.hint ?? "disabled"})`)}` : ""}`;
|
|
1103
|
+
case "selected": return `${c(s, (i) => styleText("dim", i))}`;
|
|
1104
|
+
case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${s}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
1105
|
+
case "cancelled": return `${c(s, (i) => styleText(["strikethrough", "dim"], i))}`;
|
|
1106
|
+
default: return `${styleText("dim", S_RADIO_INACTIVE)} ${c(s, (i) => styleText("dim", i))}`;
|
|
1107
|
+
}
|
|
1108
|
+
}, d = t.showInstructions ?? true;
|
|
1109
|
+
return new n$1({
|
|
1110
|
+
options: t.options,
|
|
1111
|
+
signal: t.signal,
|
|
1112
|
+
input: t.input,
|
|
1113
|
+
output: t.output,
|
|
1114
|
+
initialValue: t.initialValue,
|
|
1115
|
+
render() {
|
|
1116
|
+
const n = t.withGuide ?? settings.withGuide, m = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, i = wrapTextWithPrefix(t.output, t.message, s, m), u = `${n ? `${styleText("gray", S_BAR)}
|
|
1117
|
+
` : ""}${i}
|
|
1118
|
+
`;
|
|
1119
|
+
switch (this.state) {
|
|
1120
|
+
case "submit": {
|
|
1121
|
+
const r = n ? `${styleText("gray", S_BAR)} ` : "";
|
|
1122
|
+
return `${u}${wrapTextWithPrefix(t.output, o(this.options[this.cursor], "selected"), r)}`;
|
|
1123
|
+
}
|
|
1124
|
+
case "cancel": {
|
|
1125
|
+
const r = n ? `${styleText("gray", S_BAR)} ` : "";
|
|
1126
|
+
return `${u}${wrapTextWithPrefix(t.output, o(this.options[this.cursor], "cancelled"), r)}${n ? `
|
|
1127
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
1128
|
+
}
|
|
1129
|
+
default: {
|
|
1130
|
+
const r = n ? `${styleText("cyan", S_BAR)} ` : "", a = u.split(`
|
|
1131
|
+
`).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n) : n ? [styleText("cyan", S_BAR_END)] : [], b = p.join(`
|
|
1132
|
+
`), f = p.length + 1;
|
|
1133
|
+
return `${u}${r}${limitOptions({
|
|
1134
|
+
output: t.output,
|
|
1135
|
+
cursor: this.cursor,
|
|
1136
|
+
options: this.options,
|
|
1137
|
+
maxItems: t.maxItems,
|
|
1138
|
+
columnPadding: r.length,
|
|
1139
|
+
rowPadding: a + f,
|
|
1140
|
+
style: (g, x) => o(g, g.disabled ? "disabled" : x ? "active" : "inactive")
|
|
1141
|
+
}).join(`
|
|
1142
|
+
${r}`)}
|
|
1143
|
+
${b}
|
|
1144
|
+
`;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
}).prompt();
|
|
1149
|
+
};
|
|
1150
|
+
const i = `${styleText("gray", S_BAR)} `;
|
|
1151
|
+
|
|
1152
|
+
//#endregion
|
|
1153
|
+
//#region src/services/tasks/taskProgressService.ts
|
|
1154
|
+
function formatDuration(durationMs) {
|
|
1155
|
+
if (durationMs < 1e3) return `${durationMs}ms`;
|
|
1156
|
+
return `${(durationMs / 1e3).toFixed(1)}s`;
|
|
1157
|
+
}
|
|
1158
|
+
var TaskProgressService = class {
|
|
1159
|
+
#storage = new AsyncLocalStorage();
|
|
1160
|
+
attach(sink, task) {
|
|
1161
|
+
return this.#storage.run(sink, task);
|
|
1162
|
+
}
|
|
1163
|
+
log(message) {
|
|
1164
|
+
this.#storage.getStore()?.log(message);
|
|
1165
|
+
}
|
|
1166
|
+
report(message) {
|
|
1167
|
+
const sink = this.#storage.getStore();
|
|
1168
|
+
(sink?.report || sink?.log)?.(message);
|
|
1169
|
+
}
|
|
1170
|
+
createStepProgress(classify = (message) => ({
|
|
1171
|
+
id: message,
|
|
1172
|
+
title: message
|
|
1173
|
+
})) {
|
|
1174
|
+
const progress = spinner();
|
|
1175
|
+
let active;
|
|
1176
|
+
const finishActive = (label) => {
|
|
1177
|
+
if (!active) return;
|
|
1178
|
+
const duration = formatDuration(Date.now() - active.startedAt);
|
|
1179
|
+
progress.stop(`${label || active.completedTitle || `${active.title} completed`} (${duration})`);
|
|
1180
|
+
active = void 0;
|
|
1181
|
+
};
|
|
1182
|
+
const start = (step) => {
|
|
1183
|
+
if (active?.id === step.id) {
|
|
1184
|
+
progress.message(step.detail ? `${step.title}: ${step.detail}` : step.title);
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
finishActive();
|
|
1188
|
+
active = {
|
|
1189
|
+
id: step.id,
|
|
1190
|
+
title: step.title,
|
|
1191
|
+
completedTitle: step.completedTitle,
|
|
1192
|
+
startedAt: Date.now()
|
|
1193
|
+
};
|
|
1194
|
+
progress.start(step.detail ? `${step.title}: ${step.detail}` : step.title);
|
|
1195
|
+
};
|
|
1196
|
+
const execute = (task) => this.attach({
|
|
1197
|
+
log: (message) => progress.message(active ? `${active.title}: ${message}` : message),
|
|
1198
|
+
report: (message) => start(classify(message))
|
|
1199
|
+
}, task);
|
|
1200
|
+
return {
|
|
1201
|
+
report(message) {
|
|
1202
|
+
start(classify(message));
|
|
1203
|
+
},
|
|
1204
|
+
start,
|
|
1205
|
+
execute,
|
|
1206
|
+
run: async (step, task) => {
|
|
1207
|
+
start(step);
|
|
1208
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
1209
|
+
const result = await execute(task);
|
|
1210
|
+
finishActive();
|
|
1211
|
+
return result;
|
|
1212
|
+
},
|
|
1213
|
+
finish(label) {
|
|
1214
|
+
finishActive(label);
|
|
1215
|
+
},
|
|
1216
|
+
fail(label) {
|
|
1217
|
+
if (!active) return;
|
|
1218
|
+
const duration = formatDuration(Date.now() - active.startedAt);
|
|
1219
|
+
progress.stop(`${label} (${duration})`);
|
|
1220
|
+
active = void 0;
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
const taskProgressService = new TaskProgressService();
|
|
1226
|
+
|
|
1227
|
+
//#endregion
|
|
1228
|
+
export { note as a, select as c, setUserConfig as d, userConfig as f, log as i, isCancel as l, cancel as n, outro as o, intro as r, progress as s, taskProgressService as t, getUserConfig as u };
|
|
1229
|
+
//# sourceMappingURL=taskProgressService-CAC_RIoa.mjs.map
|