mc8yp 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/add-CO4XaqJr.mjs +720 -0
- package/dist/cli.mjs +23299 -163
- package/dist/creds-NskvbfG3.mjs +18 -0
- package/dist/{list-ONo8XOjk.mjs → list-DGPagAtJ.mjs} +1 -3
- package/dist/prompt-_h8n-XjA.mjs +847 -0
- package/dist/{remove-BTNzrd-j.mjs → remove-CAB5quKV.mjs} +1 -3
- package/dist/sqids-DepConIy.mjs +683 -0
- package/package.json +13 -13
- package/dist/add-CmQVWyPy.mjs +0 -58
- package/dist/creds-BiObd0k6.mjs +0 -18
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
import { a as parse, c as url, f as __commonJSMin, i as setStoredC8yAuth, l as consola, o as pipe, r as getStoredC8yAuth, s as string, t as cleanTenantUrl, u as defineCommand } from "./cli.mjs";
|
|
2
|
+
import process$1, { exit, stdin, stdout } from "node:process";
|
|
3
|
+
import { styleText } from "node:util";
|
|
4
|
+
import "node:path";
|
|
5
|
+
import f from "node:readline";
|
|
6
|
+
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
7
|
+
const getCodePointsLength = (() => {
|
|
8
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
9
|
+
return (input) => {
|
|
10
|
+
let surrogatePairsNr = 0;
|
|
11
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
12
|
+
while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
|
|
13
|
+
return input.length - surrogatePairsNr;
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
const isFullWidth = (x) => {
|
|
17
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
18
|
+
};
|
|
19
|
+
const isWideNotCJKTNotEmoji = (x) => {
|
|
20
|
+
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;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
|
|
24
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
25
|
+
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
26
|
+
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;
|
|
27
|
+
const TAB_RE = /\t{1,1000}/y;
|
|
28
|
+
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;
|
|
29
|
+
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
30
|
+
const MODIFIER_RE = /\p{M}+/gu;
|
|
31
|
+
const NO_TRUNCATION$1 = {
|
|
32
|
+
limit: Infinity,
|
|
33
|
+
ellipsis: ""
|
|
34
|
+
};
|
|
35
|
+
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
36
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
37
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
38
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
|
|
39
|
+
const ANSI_WIDTH = 0;
|
|
40
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
41
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
42
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
43
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
44
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
45
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
46
|
+
const PARSE_BLOCKS = [
|
|
47
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
48
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
49
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
50
|
+
[TAB_RE, TAB_WIDTH],
|
|
51
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
52
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
53
|
+
];
|
|
54
|
+
let indexPrev = 0;
|
|
55
|
+
let index = 0;
|
|
56
|
+
let length = input.length;
|
|
57
|
+
let lengthExtra = 0;
|
|
58
|
+
let truncationEnabled = false;
|
|
59
|
+
let truncationIndex = length;
|
|
60
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
61
|
+
let unmatchedStart = 0;
|
|
62
|
+
let unmatchedEnd = 0;
|
|
63
|
+
let width = 0;
|
|
64
|
+
let widthExtra = 0;
|
|
65
|
+
outer: while (true) {
|
|
66
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
67
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
68
|
+
lengthExtra = 0;
|
|
69
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
70
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
71
|
+
if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
|
|
72
|
+
else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
|
|
73
|
+
else widthExtra = REGULAR_WIDTH;
|
|
74
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
75
|
+
if (width + widthExtra > LIMIT) {
|
|
76
|
+
truncationEnabled = true;
|
|
77
|
+
break outer;
|
|
78
|
+
}
|
|
79
|
+
lengthExtra += char.length;
|
|
80
|
+
width += widthExtra;
|
|
81
|
+
}
|
|
82
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
83
|
+
}
|
|
84
|
+
if (index >= length) break outer;
|
|
85
|
+
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
86
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
87
|
+
BLOCK_RE.lastIndex = index;
|
|
88
|
+
if (BLOCK_RE.test(input)) {
|
|
89
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
90
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
91
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
92
|
+
if (width + widthExtra > LIMIT) {
|
|
93
|
+
truncationEnabled = true;
|
|
94
|
+
break outer;
|
|
95
|
+
}
|
|
96
|
+
width += widthExtra;
|
|
97
|
+
unmatchedStart = indexPrev;
|
|
98
|
+
unmatchedEnd = index;
|
|
99
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
100
|
+
continue outer;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
index += 1;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
107
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
108
|
+
truncated: truncationEnabled,
|
|
109
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
|
|
114
|
+
const NO_TRUNCATION = {
|
|
115
|
+
limit: Infinity,
|
|
116
|
+
ellipsis: "",
|
|
117
|
+
ellipsisWidth: 0
|
|
118
|
+
};
|
|
119
|
+
const fastStringWidth = (input, options = {}) => {
|
|
120
|
+
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
|
|
124
|
+
const ESC = "\x1B";
|
|
125
|
+
const CSI = "";
|
|
126
|
+
const END_CODE = 39;
|
|
127
|
+
const ANSI_ESCAPE_BELL = "\x07";
|
|
128
|
+
const ANSI_CSI = "[";
|
|
129
|
+
const ANSI_OSC = "]";
|
|
130
|
+
const ANSI_SGR_TERMINATOR = "m";
|
|
131
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
132
|
+
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
133
|
+
const getClosingCode = (openingCode) => {
|
|
134
|
+
if (openingCode >= 30 && openingCode <= 37) return 39;
|
|
135
|
+
if (openingCode >= 90 && openingCode <= 97) return 39;
|
|
136
|
+
if (openingCode >= 40 && openingCode <= 47) return 49;
|
|
137
|
+
if (openingCode >= 100 && openingCode <= 107) return 49;
|
|
138
|
+
if (openingCode === 1 || openingCode === 2) return 22;
|
|
139
|
+
if (openingCode === 3) return 23;
|
|
140
|
+
if (openingCode === 4) return 24;
|
|
141
|
+
if (openingCode === 7) return 27;
|
|
142
|
+
if (openingCode === 8) return 28;
|
|
143
|
+
if (openingCode === 9) return 29;
|
|
144
|
+
if (openingCode === 0) return 0;
|
|
145
|
+
};
|
|
146
|
+
const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
147
|
+
const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
148
|
+
const wrapWord = (rows, word, columns) => {
|
|
149
|
+
const characters = word[Symbol.iterator]();
|
|
150
|
+
let isInsideEscape = false;
|
|
151
|
+
let isInsideLinkEscape = false;
|
|
152
|
+
let lastRow = rows.at(-1);
|
|
153
|
+
let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
|
|
154
|
+
let currentCharacter = characters.next();
|
|
155
|
+
let nextCharacter = characters.next();
|
|
156
|
+
let rawCharacterIndex = 0;
|
|
157
|
+
while (!currentCharacter.done) {
|
|
158
|
+
const character = currentCharacter.value;
|
|
159
|
+
const characterLength = fastStringWidth(character);
|
|
160
|
+
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
161
|
+
else {
|
|
162
|
+
rows.push(character);
|
|
163
|
+
visible = 0;
|
|
164
|
+
}
|
|
165
|
+
if (character === ESC || character === CSI) {
|
|
166
|
+
isInsideEscape = true;
|
|
167
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
168
|
+
}
|
|
169
|
+
if (isInsideEscape) {
|
|
170
|
+
if (isInsideLinkEscape) {
|
|
171
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
172
|
+
isInsideEscape = false;
|
|
173
|
+
isInsideLinkEscape = false;
|
|
174
|
+
}
|
|
175
|
+
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
176
|
+
} else {
|
|
177
|
+
visible += characterLength;
|
|
178
|
+
if (visible === columns && !nextCharacter.done) {
|
|
179
|
+
rows.push("");
|
|
180
|
+
visible = 0;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
currentCharacter = nextCharacter;
|
|
184
|
+
nextCharacter = characters.next();
|
|
185
|
+
rawCharacterIndex += character.length;
|
|
186
|
+
}
|
|
187
|
+
lastRow = rows.at(-1);
|
|
188
|
+
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
|
|
189
|
+
};
|
|
190
|
+
const stringVisibleTrimSpacesRight = (string) => {
|
|
191
|
+
const words = string.split(" ");
|
|
192
|
+
let last = words.length;
|
|
193
|
+
while (last) {
|
|
194
|
+
if (fastStringWidth(words[last - 1])) break;
|
|
195
|
+
last--;
|
|
196
|
+
}
|
|
197
|
+
if (last === words.length) return string;
|
|
198
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
199
|
+
};
|
|
200
|
+
const exec = (string, columns, options = {}) => {
|
|
201
|
+
if (options.trim !== false && string.trim() === "") return "";
|
|
202
|
+
let returnValue = "";
|
|
203
|
+
let escapeCode;
|
|
204
|
+
let escapeUrl;
|
|
205
|
+
const words = string.split(" ");
|
|
206
|
+
let rows = [""];
|
|
207
|
+
let rowLength = 0;
|
|
208
|
+
for (let index = 0; index < words.length; index++) {
|
|
209
|
+
const word = words[index];
|
|
210
|
+
if (options.trim !== false) {
|
|
211
|
+
const row = rows.at(-1) ?? "";
|
|
212
|
+
const trimmed = row.trimStart();
|
|
213
|
+
if (row.length !== trimmed.length) {
|
|
214
|
+
rows[rows.length - 1] = trimmed;
|
|
215
|
+
rowLength = fastStringWidth(trimmed);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (index !== 0) {
|
|
219
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
220
|
+
rows.push("");
|
|
221
|
+
rowLength = 0;
|
|
222
|
+
}
|
|
223
|
+
if (rowLength || options.trim === false) {
|
|
224
|
+
rows[rows.length - 1] += " ";
|
|
225
|
+
rowLength++;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const wordLength = fastStringWidth(word);
|
|
229
|
+
if (options.hard && wordLength > columns) {
|
|
230
|
+
const remainingColumns = columns - rowLength;
|
|
231
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
232
|
+
if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
|
|
233
|
+
wrapWord(rows, word, columns);
|
|
234
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
238
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
239
|
+
wrapWord(rows, word, columns);
|
|
240
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
rows.push("");
|
|
244
|
+
rowLength = 0;
|
|
245
|
+
}
|
|
246
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
247
|
+
wrapWord(rows, word, columns);
|
|
248
|
+
rowLength = fastStringWidth(rows.at(-1) ?? "");
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
rows[rows.length - 1] += word;
|
|
252
|
+
rowLength += wordLength;
|
|
253
|
+
}
|
|
254
|
+
if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
255
|
+
const preString = rows.join("\n");
|
|
256
|
+
let inSurrogate = false;
|
|
257
|
+
for (let i = 0; i < preString.length; i++) {
|
|
258
|
+
const character = preString[i];
|
|
259
|
+
returnValue += character;
|
|
260
|
+
if (!inSurrogate) {
|
|
261
|
+
inSurrogate = character >= "\ud800" && character <= "\udbff";
|
|
262
|
+
if (inSurrogate) continue;
|
|
263
|
+
} else inSurrogate = false;
|
|
264
|
+
if (character === ESC || character === CSI) {
|
|
265
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
266
|
+
const groups = GROUP_REGEX.exec(preString)?.groups;
|
|
267
|
+
if (groups?.code !== void 0) {
|
|
268
|
+
const code = Number.parseFloat(groups.code);
|
|
269
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
270
|
+
} else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
271
|
+
}
|
|
272
|
+
if (preString[i + 1] === "\n") {
|
|
273
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink("");
|
|
274
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
275
|
+
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
276
|
+
} else if (character === "\n") {
|
|
277
|
+
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
278
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return returnValue;
|
|
282
|
+
};
|
|
283
|
+
const CRLF_OR_LF = /\r?\n/;
|
|
284
|
+
function wrapAnsi(string, columns, options) {
|
|
285
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region node_modules/.pnpm/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
|
|
289
|
+
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
290
|
+
const ESC = "\x1B";
|
|
291
|
+
const CSI = `${ESC}[`;
|
|
292
|
+
const beep = "\x07";
|
|
293
|
+
const cursor = {
|
|
294
|
+
to(x, y) {
|
|
295
|
+
if (!y) return `${CSI}${x + 1}G`;
|
|
296
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
297
|
+
},
|
|
298
|
+
move(x, y) {
|
|
299
|
+
let ret = "";
|
|
300
|
+
if (x < 0) ret += `${CSI}${-x}D`;
|
|
301
|
+
else if (x > 0) ret += `${CSI}${x}C`;
|
|
302
|
+
if (y < 0) ret += `${CSI}${-y}A`;
|
|
303
|
+
else if (y > 0) ret += `${CSI}${y}B`;
|
|
304
|
+
return ret;
|
|
305
|
+
},
|
|
306
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
307
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
308
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
309
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
310
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
311
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
312
|
+
left: `${CSI}G`,
|
|
313
|
+
hide: `${CSI}?25l`,
|
|
314
|
+
show: `${CSI}?25h`,
|
|
315
|
+
save: `${ESC}7`,
|
|
316
|
+
restore: `${ESC}8`
|
|
317
|
+
};
|
|
318
|
+
module.exports = {
|
|
319
|
+
cursor,
|
|
320
|
+
scroll: {
|
|
321
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
322
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
323
|
+
},
|
|
324
|
+
erase: {
|
|
325
|
+
screen: `${CSI}2J`,
|
|
326
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
327
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
328
|
+
line: `${CSI}2K`,
|
|
329
|
+
lineEnd: `${CSI}K`,
|
|
330
|
+
lineStart: `${CSI}1K`,
|
|
331
|
+
lines(count) {
|
|
332
|
+
let clear = "";
|
|
333
|
+
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
334
|
+
if (count) clear += cursor.left;
|
|
335
|
+
return clear;
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
beep
|
|
339
|
+
};
|
|
340
|
+
})))();
|
|
341
|
+
const settings = {
|
|
342
|
+
actions: new Set([
|
|
343
|
+
"up",
|
|
344
|
+
"down",
|
|
345
|
+
"left",
|
|
346
|
+
"right",
|
|
347
|
+
"space",
|
|
348
|
+
"enter",
|
|
349
|
+
"cancel"
|
|
350
|
+
]),
|
|
351
|
+
aliases: /* @__PURE__ */ new Map([
|
|
352
|
+
["k", "up"],
|
|
353
|
+
["j", "down"],
|
|
354
|
+
["h", "left"],
|
|
355
|
+
["l", "right"],
|
|
356
|
+
["", "cancel"],
|
|
357
|
+
["escape", "cancel"]
|
|
358
|
+
]),
|
|
359
|
+
messages: {
|
|
360
|
+
cancel: "Canceled",
|
|
361
|
+
error: "Something went wrong"
|
|
362
|
+
},
|
|
363
|
+
withGuide: true,
|
|
364
|
+
date: {
|
|
365
|
+
monthNames: [...[
|
|
366
|
+
"January",
|
|
367
|
+
"February",
|
|
368
|
+
"March",
|
|
369
|
+
"April",
|
|
370
|
+
"May",
|
|
371
|
+
"June",
|
|
372
|
+
"July",
|
|
373
|
+
"August",
|
|
374
|
+
"September",
|
|
375
|
+
"October",
|
|
376
|
+
"November",
|
|
377
|
+
"December"
|
|
378
|
+
]],
|
|
379
|
+
messages: {
|
|
380
|
+
required: "Please enter a valid date",
|
|
381
|
+
invalidMonth: "There are only 12 months in a year",
|
|
382
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
383
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
384
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
function isActionKey(n, e) {
|
|
389
|
+
if (typeof n == "string") return settings.aliases.get(n) === e;
|
|
390
|
+
for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
function diffLines(i, s) {
|
|
394
|
+
if (i === s) return;
|
|
395
|
+
const e = i.split(`
|
|
396
|
+
`), t = s.split(`
|
|
397
|
+
`), r = Math.max(e.length, t.length), f = [];
|
|
398
|
+
for (let n = 0; n < r; n++) e[n] !== t[n] && f.push(n);
|
|
399
|
+
return {
|
|
400
|
+
lines: f,
|
|
401
|
+
numLinesBefore: e.length,
|
|
402
|
+
numLinesAfter: t.length,
|
|
403
|
+
numLines: r
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
globalThis.process.platform.startsWith("win");
|
|
407
|
+
const CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
408
|
+
function isCancel(e) {
|
|
409
|
+
return e === CANCEL_SYMBOL;
|
|
410
|
+
}
|
|
411
|
+
function setRawMode(e, r) {
|
|
412
|
+
const o = e;
|
|
413
|
+
o.isTTY && o.setRawMode(r);
|
|
414
|
+
}
|
|
415
|
+
const getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
416
|
+
function runValidation(e, n) {
|
|
417
|
+
if ("~standard" in e) {
|
|
418
|
+
const a = e["~standard"].validate(n);
|
|
419
|
+
if (a instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
420
|
+
return a.issues?.at(0)?.message;
|
|
421
|
+
}
|
|
422
|
+
return e(n);
|
|
423
|
+
}
|
|
424
|
+
var V = class {
|
|
425
|
+
input;
|
|
426
|
+
output;
|
|
427
|
+
_abortSignal;
|
|
428
|
+
rl;
|
|
429
|
+
opts;
|
|
430
|
+
_render;
|
|
431
|
+
_track = false;
|
|
432
|
+
_prevFrame = "";
|
|
433
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
434
|
+
_cursor = 0;
|
|
435
|
+
state = "initial";
|
|
436
|
+
error = "";
|
|
437
|
+
value;
|
|
438
|
+
userInput = "";
|
|
439
|
+
constructor(t, e = true) {
|
|
440
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
|
|
441
|
+
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;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Unsubscribe all listeners
|
|
445
|
+
*/
|
|
446
|
+
unsubscribe() {
|
|
447
|
+
this._subscribers.clear();
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Set a subscriber with opts
|
|
451
|
+
* @param event - The event name
|
|
452
|
+
*/
|
|
453
|
+
setSubscriber(t, e) {
|
|
454
|
+
const i = this._subscribers.get(t) ?? [];
|
|
455
|
+
i.push(e), this._subscribers.set(t, i);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Subscribe to an event
|
|
459
|
+
* @param event - The event name
|
|
460
|
+
* @param cb - The callback
|
|
461
|
+
*/
|
|
462
|
+
on(t, e) {
|
|
463
|
+
this.setSubscriber(t, { cb: e });
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Subscribe to an event once
|
|
467
|
+
* @param event - The event name
|
|
468
|
+
* @param cb - The callback
|
|
469
|
+
*/
|
|
470
|
+
once(t, e) {
|
|
471
|
+
this.setSubscriber(t, {
|
|
472
|
+
cb: e,
|
|
473
|
+
once: true
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Emit an event with data
|
|
478
|
+
* @param event - The event name
|
|
479
|
+
* @param data - The data to pass to the callback
|
|
480
|
+
*/
|
|
481
|
+
emit(t, ...e) {
|
|
482
|
+
const i = this._subscribers.get(t) ?? [], n = [];
|
|
483
|
+
for (const s of i) s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
484
|
+
for (const s of n) s();
|
|
485
|
+
}
|
|
486
|
+
prompt() {
|
|
487
|
+
return new Promise((t) => {
|
|
488
|
+
if (this._abortSignal) {
|
|
489
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
|
|
490
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
491
|
+
this.state = "cancel", this.close();
|
|
492
|
+
}, { once: true });
|
|
493
|
+
}
|
|
494
|
+
this.rl = f.createInterface({
|
|
495
|
+
input: this.input,
|
|
496
|
+
tabSize: 2,
|
|
497
|
+
prompt: "",
|
|
498
|
+
escapeCodeTimeout: 50,
|
|
499
|
+
terminal: true
|
|
500
|
+
}), 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", () => {
|
|
501
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
502
|
+
}), this.once("cancel", () => {
|
|
503
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
_isActionKey(t, e) {
|
|
508
|
+
return t === " ";
|
|
509
|
+
}
|
|
510
|
+
_shouldSubmit(t, e) {
|
|
511
|
+
return true;
|
|
512
|
+
}
|
|
513
|
+
_setValue(t) {
|
|
514
|
+
this.value = t, this.emit("value", this.value);
|
|
515
|
+
}
|
|
516
|
+
_setUserInput(t, e) {
|
|
517
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
518
|
+
}
|
|
519
|
+
_clearUserInput() {
|
|
520
|
+
this.rl?.write(null, {
|
|
521
|
+
ctrl: true,
|
|
522
|
+
name: "u"
|
|
523
|
+
}), this._setUserInput("");
|
|
524
|
+
}
|
|
525
|
+
onKeypress(t, e) {
|
|
526
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
|
|
527
|
+
ctrl: true,
|
|
528
|
+
name: "h"
|
|
529
|
+
}), 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)) {
|
|
530
|
+
if (this.opts.validate) {
|
|
531
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
532
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
533
|
+
}
|
|
534
|
+
this.state !== "error" && (this.state = "submit");
|
|
535
|
+
}
|
|
536
|
+
isActionKey([
|
|
537
|
+
t,
|
|
538
|
+
e?.name,
|
|
539
|
+
e?.sequence
|
|
540
|
+
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
541
|
+
}
|
|
542
|
+
close() {
|
|
543
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
544
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
545
|
+
}
|
|
546
|
+
restoreCursor() {
|
|
547
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
|
|
548
|
+
hard: true,
|
|
549
|
+
trim: false
|
|
550
|
+
}).split(`
|
|
551
|
+
`).length - 1;
|
|
552
|
+
this.output.write(import_src.cursor.move(-999, t * -1));
|
|
553
|
+
}
|
|
554
|
+
render() {
|
|
555
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
556
|
+
hard: true,
|
|
557
|
+
trim: false
|
|
558
|
+
});
|
|
559
|
+
if (t !== this._prevFrame) {
|
|
560
|
+
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
561
|
+
else {
|
|
562
|
+
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
563
|
+
if (this.restoreCursor(), e) {
|
|
564
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
565
|
+
let r = e.lines.find((o) => o >= n);
|
|
566
|
+
if (r === void 0) {
|
|
567
|
+
this._prevFrame = t;
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
if (e.lines.length === 1) {
|
|
571
|
+
this.output.write(import_src.cursor.move(0, r - s)), this.output.write(import_src.erase.lines(1));
|
|
572
|
+
const o = t.split(`
|
|
573
|
+
`);
|
|
574
|
+
this.output.write(o[r]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - r - 1));
|
|
575
|
+
return;
|
|
576
|
+
} else if (e.lines.length > 1) {
|
|
577
|
+
if (n < s) r = n;
|
|
578
|
+
else {
|
|
579
|
+
const h = r - s;
|
|
580
|
+
h > 0 && this.output.write(import_src.cursor.move(0, h));
|
|
581
|
+
}
|
|
582
|
+
this.output.write(import_src.erase.down());
|
|
583
|
+
const f = t.split(`
|
|
584
|
+
`).slice(r);
|
|
585
|
+
this.output.write(f.join(`
|
|
586
|
+
`)), this._prevFrame = t;
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
this.output.write(import_src.erase.down());
|
|
591
|
+
}
|
|
592
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
var o = class extends V {
|
|
597
|
+
_mask = "•";
|
|
598
|
+
get cursor() {
|
|
599
|
+
return this._cursor;
|
|
600
|
+
}
|
|
601
|
+
get masked() {
|
|
602
|
+
return this.userInput.replaceAll(/./g, this._mask);
|
|
603
|
+
}
|
|
604
|
+
get userInputWithCursor() {
|
|
605
|
+
if (this.state === "submit" || this.state === "cancel") return this.masked;
|
|
606
|
+
const t = this.userInput;
|
|
607
|
+
if (this.cursor >= t.length) return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
|
|
608
|
+
const s = this.masked, r = s.slice(0, this.cursor), e = s.slice(this.cursor);
|
|
609
|
+
return `${r}${styleText("inverse", e[0])}${e.slice(1)}`;
|
|
610
|
+
}
|
|
611
|
+
clear() {
|
|
612
|
+
this._clearUserInput();
|
|
613
|
+
}
|
|
614
|
+
constructor({ mask: t, ...s }) {
|
|
615
|
+
super(s), this._mask = t ?? "•", this.on("userInput", (r) => {
|
|
616
|
+
this._setValue(r);
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
//#endregion
|
|
621
|
+
//#region node_modules/.pnpm/@clack+prompts@1.5.1/node_modules/@clack/prompts/dist/index.mjs
|
|
622
|
+
function isUnicodeSupported() {
|
|
623
|
+
if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
|
|
624
|
+
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";
|
|
625
|
+
}
|
|
626
|
+
const unicode = isUnicodeSupported(), unicodeOr = (e, o) => unicode ? e : o, S_STEP_ACTIVE = unicodeOr("◆", "*"), S_STEP_CANCEL = unicodeOr("■", "x"), S_STEP_ERROR = unicodeOr("▲", "x"), S_STEP_SUBMIT = unicodeOr("◇", "o"), S_BAR = unicodeOr("│", "|"), S_BAR_END = unicodeOr("└", "—"), S_PASSWORD_MASK = unicodeOr("▪", "•"), symbol = (e) => {
|
|
627
|
+
switch (e) {
|
|
628
|
+
case "initial":
|
|
629
|
+
case "active": return styleText("cyan", S_STEP_ACTIVE);
|
|
630
|
+
case "cancel": return styleText("red", S_STEP_CANCEL);
|
|
631
|
+
case "error": return styleText("yellow", S_STEP_ERROR);
|
|
632
|
+
case "submit": return styleText("green", S_STEP_SUBMIT);
|
|
633
|
+
}
|
|
634
|
+
}, cancel = (o = "", t) => {
|
|
635
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_END)} ` : "";
|
|
636
|
+
i.write(`${e}${styleText("red", o)}
|
|
637
|
+
|
|
638
|
+
`);
|
|
639
|
+
};
|
|
640
|
+
const password = (r) => new o({
|
|
641
|
+
validate: r.validate,
|
|
642
|
+
mask: r.mask ?? S_PASSWORD_MASK,
|
|
643
|
+
signal: r.signal,
|
|
644
|
+
input: r.input,
|
|
645
|
+
output: r.output,
|
|
646
|
+
render() {
|
|
647
|
+
const e = r.withGuide ?? settings.withGuide, o = `${e ? `${styleText("gray", S_BAR)}
|
|
648
|
+
` : ""}${symbol(this.state)} ${r.message}
|
|
649
|
+
`, c = this.userInputWithCursor, i = this.masked;
|
|
650
|
+
switch (this.state) {
|
|
651
|
+
case "error": {
|
|
652
|
+
const s = e ? `${styleText("yellow", S_BAR)} ` : "", n = e ? `${styleText("yellow", S_BAR_END)} ` : "", l = i ?? "";
|
|
653
|
+
return r.clearOnError && this.clear(), `${o.trim()}
|
|
654
|
+
${s}${l}
|
|
655
|
+
${n}${styleText("yellow", this.error)}
|
|
656
|
+
`;
|
|
657
|
+
}
|
|
658
|
+
case "submit": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${i ? styleText("dim", i) : ""}`;
|
|
659
|
+
case "cancel": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${i ? styleText(["strikethrough", "dim"], i) : ""}${i && e ? `
|
|
660
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
661
|
+
default: return `${o}${e ? `${styleText("cyan", S_BAR)} ` : ""}${c}
|
|
662
|
+
${e ? styleText("cyan", S_BAR_END) : ""}
|
|
663
|
+
`;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}).prompt();
|
|
667
|
+
`${styleText("gray", S_BAR)}`;
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region src/cli/subcommands/subcommands/add.ts
|
|
670
|
+
const command = defineCommand({
|
|
671
|
+
meta: {
|
|
672
|
+
name: "add",
|
|
673
|
+
description: "Add new Cumulocity credentials"
|
|
674
|
+
},
|
|
675
|
+
run: async () => {
|
|
676
|
+
try {
|
|
677
|
+
const tenantUrl = await consola.prompt("Cumulocity tenant URL:", {
|
|
678
|
+
type: "text",
|
|
679
|
+
cancel: "reject"
|
|
680
|
+
});
|
|
681
|
+
parse(pipe(string(), url()), tenantUrl);
|
|
682
|
+
const user = await consola.prompt("Username:", {
|
|
683
|
+
type: "text",
|
|
684
|
+
cancel: "reject"
|
|
685
|
+
});
|
|
686
|
+
const passwordPrompt = await password({
|
|
687
|
+
message: "Password:",
|
|
688
|
+
clearOnError: true,
|
|
689
|
+
validate: (value) => {
|
|
690
|
+
if (!value) return "Password is required.";
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
if (isCancel(passwordPrompt)) {
|
|
694
|
+
cancel("Cancelled.");
|
|
695
|
+
exit();
|
|
696
|
+
}
|
|
697
|
+
if ((await getStoredC8yAuth()).some((cred) => cred.tenantUrl === cleanTenantUrl(tenantUrl))) {
|
|
698
|
+
if (!await consola.prompt("Credentials for this tenant already exist. Overwrite?", {
|
|
699
|
+
type: "confirm",
|
|
700
|
+
cancel: "reject"
|
|
701
|
+
})) {
|
|
702
|
+
consola.info("Cancelled.");
|
|
703
|
+
exit();
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
await setStoredC8yAuth({
|
|
707
|
+
tenantUrl,
|
|
708
|
+
user,
|
|
709
|
+
password: passwordPrompt
|
|
710
|
+
});
|
|
711
|
+
consola.success("Credentials saved successfully!");
|
|
712
|
+
exit();
|
|
713
|
+
} catch (error) {
|
|
714
|
+
consola.error("Failed to add credentials:", error);
|
|
715
|
+
exit();
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
//#endregion
|
|
720
|
+
export { command as default };
|