skpm-cli 1.4.6

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.
@@ -0,0 +1,334 @@
1
+ import { r as __toESM } from "../../rolldown-runtime.mjs";
2
+ import { a as SD, c as fD, d as require_src, i as RD, l as pD, n as LD, o as _D, r as MD, s as dD, t as ID, u as require_picocolors } from "./core.mjs";
3
+ import { stripVTControlCharacters } from "node:util";
4
+ import y from "node:process";
5
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
6
+ var import_src = require_src();
7
+ function ce() {
8
+ return y.platform !== "win32" ? y.env.TERM !== "linux" : !!y.env.CI || !!y.env.WT_SESSION || !!y.env.TERMINUS_SUBLIME || y.env.ConEmuTask === "{cmd::Cmder}" || y.env.TERM_PROGRAM === "Terminus-Sublime" || y.env.TERM_PROGRAM === "vscode" || y.env.TERM === "xterm-256color" || y.env.TERM === "alacritty" || y.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
9
+ }
10
+ const V = ce(), u = (t, n) => V ? t : n, le = u("◆", "*"), L = u("■", "x"), W = u("▲", "x"), C = u("◇", "o"), ue = u("┌", "T"), o = u("│", "|"), d = u("└", "—"), k = u("●", ">"), P = u("○", " "), A = u("◻", "[•]"), T = u("◼", "[+]"), F = u("◻", "[ ]");
11
+ u("▪", "•");
12
+ const _ = u("─", "-"), me = u("╮", "+"), de = u("├", "+"), pe = u("╯", "+"), q = u("●", "•"), D = u("◆", "*"), U = u("▲", "!"), K = u("■", "x"), b = (t) => {
13
+ switch (t) {
14
+ case "initial":
15
+ case "active": return import_picocolors.default.cyan(le);
16
+ case "cancel": return import_picocolors.default.red(L);
17
+ case "error": return import_picocolors.default.yellow(W);
18
+ case "submit": return import_picocolors.default.green(C);
19
+ }
20
+ }, G = (t) => {
21
+ const { cursor: n, options: r, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
22
+ let l = 0;
23
+ n >= l + a - 3 ? l = Math.max(Math.min(n - a + 3, r.length - a), 0) : n < l + 2 && (l = Math.max(n - 2, 0));
24
+ const $ = a < r.length && l > 0, g = a < r.length && l + a < r.length;
25
+ return r.slice(l, l + a).map((p, v, f) => {
26
+ const j = v === 0 && $, E = v === f.length - 1 && g;
27
+ return j || E ? import_picocolors.default.dim("...") : i(p, v + l === n);
28
+ });
29
+ }, ye = (t) => {
30
+ const n = t.active ?? "Yes", r = t.inactive ?? "No";
31
+ return new dD({
32
+ active: n,
33
+ inactive: r,
34
+ initialValue: t.initialValue ?? !0,
35
+ render() {
36
+ const i = `${import_picocolors.default.gray(o)}
37
+ ${b(this.state)} ${t.message}
38
+ `, s = this.value ? n : r;
39
+ switch (this.state) {
40
+ case "submit": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(s)}`;
41
+ case "cancel": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}
42
+ ${import_picocolors.default.gray(o)}`;
43
+ default: return `${i}${import_picocolors.default.cyan(o)} ${this.value ? `${import_picocolors.default.green(k)} ${n}` : `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(n)}`} ${import_picocolors.default.dim("/")} ${this.value ? `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(r)}` : `${import_picocolors.default.green(k)} ${r}`}
44
+ ${import_picocolors.default.cyan(d)}
45
+ `;
46
+ }
47
+ }
48
+ }).prompt();
49
+ }, ve = (t) => {
50
+ const n = (r, i) => {
51
+ const s = r.label ?? String(r.value);
52
+ switch (i) {
53
+ case "selected": return `${import_picocolors.default.dim(s)}`;
54
+ case "active": return `${import_picocolors.default.green(k)} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}`;
55
+ case "cancelled": return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}`;
56
+ default: return `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(s)}`;
57
+ }
58
+ };
59
+ return new LD({
60
+ options: t.options,
61
+ initialValue: t.initialValue,
62
+ render() {
63
+ const r = `${import_picocolors.default.gray(o)}
64
+ ${b(this.state)} ${t.message}
65
+ `;
66
+ switch (this.state) {
67
+ case "submit": return `${r}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
68
+ case "cancel": return `${r}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
69
+ ${import_picocolors.default.gray(o)}`;
70
+ default: return `${r}${import_picocolors.default.cyan(o)} ${G({
71
+ cursor: this.cursor,
72
+ options: this.options,
73
+ maxItems: t.maxItems,
74
+ style: (i, s) => n(i, s ? "active" : "inactive")
75
+ }).join(`
76
+ ${import_picocolors.default.cyan(o)} `)}
77
+ ${import_picocolors.default.cyan(d)}
78
+ `;
79
+ }
80
+ }
81
+ }).prompt();
82
+ }, fe = (t) => {
83
+ const n = (r, i) => {
84
+ const s = r.label ?? String(r.value);
85
+ return i === "active" ? `${import_picocolors.default.cyan(A)} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}` : i === "selected" ? `${import_picocolors.default.green(T)} ${import_picocolors.default.dim(s)} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}` : i === "active-selected" ? `${import_picocolors.default.green(T)} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}` : i === "submitted" ? `${import_picocolors.default.dim(s)}` : `${import_picocolors.default.dim(F)} ${import_picocolors.default.dim(s)}`;
86
+ };
87
+ return new SD({
88
+ options: t.options,
89
+ initialValues: t.initialValues,
90
+ required: t.required ?? !0,
91
+ cursorAt: t.cursorAt,
92
+ validate(r) {
93
+ if (this.required && r.length === 0) return `Please select at least one option.
94
+ ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
95
+ },
96
+ render() {
97
+ const r = `${import_picocolors.default.gray(o)}
98
+ ${b(this.state)} ${t.message}
99
+ `, i = (s, c) => {
100
+ const a = this.value.includes(s.value);
101
+ return c && a ? n(s, "active-selected") : a ? n(s, "selected") : n(s, c ? "active" : "inactive");
102
+ };
103
+ switch (this.state) {
104
+ case "submit": return `${r}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none")}`;
105
+ case "cancel": {
106
+ const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors.default.dim(", "));
107
+ return `${r}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
108
+ ${import_picocolors.default.gray(o)}` : ""}`;
109
+ }
110
+ case "error": {
111
+ const s = this.error.split(`
112
+ `).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
113
+ `);
114
+ return `${r + import_picocolors.default.yellow(o)} ${G({
115
+ options: this.options,
116
+ cursor: this.cursor,
117
+ maxItems: t.maxItems,
118
+ style: i
119
+ }).join(`
120
+ ${import_picocolors.default.yellow(o)} `)}
121
+ ${s}
122
+ `;
123
+ }
124
+ default: return `${r}${import_picocolors.default.cyan(o)} ${G({
125
+ options: this.options,
126
+ cursor: this.cursor,
127
+ maxItems: t.maxItems,
128
+ style: i
129
+ }).join(`
130
+ ${import_picocolors.default.cyan(o)} `)}
131
+ ${import_picocolors.default.cyan(d)}
132
+ `;
133
+ }
134
+ }
135
+ }).prompt();
136
+ }, be = (t) => {
137
+ const { selectableGroups: n = !0 } = t, r = (i, s, c = []) => {
138
+ const a = i.label ?? String(i.value), l = typeof i.group == "string", $ = l && (c[c.indexOf(i) + 1] ?? { group: !0 }), g = l && $.group === !0, p = l ? n ? `${g ? d : o} ` : " " : "";
139
+ if (s === "active") return `${import_picocolors.default.dim(p)}${import_picocolors.default.cyan(A)} ${a} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
140
+ if (s === "group-active") return `${p}${import_picocolors.default.cyan(A)} ${import_picocolors.default.dim(a)}`;
141
+ if (s === "group-active-selected") return `${p}${import_picocolors.default.green(T)} ${import_picocolors.default.dim(a)}`;
142
+ if (s === "selected") {
143
+ const f = l || n ? import_picocolors.default.green(T) : "";
144
+ return `${import_picocolors.default.dim(p)}${f} ${import_picocolors.default.dim(a)} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
145
+ }
146
+ if (s === "cancelled") return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}`;
147
+ if (s === "active-selected") return `${import_picocolors.default.dim(p)}${import_picocolors.default.green(T)} ${a} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
148
+ if (s === "submitted") return `${import_picocolors.default.dim(a)}`;
149
+ const v = l || n ? import_picocolors.default.dim(F) : "";
150
+ return `${import_picocolors.default.dim(p)}${v} ${import_picocolors.default.dim(a)}`;
151
+ };
152
+ return new _D({
153
+ options: t.options,
154
+ initialValues: t.initialValues,
155
+ required: t.required ?? !0,
156
+ cursorAt: t.cursorAt,
157
+ selectableGroups: n,
158
+ validate(i) {
159
+ if (this.required && i.length === 0) return `Please select at least one option.
160
+ ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
161
+ },
162
+ render() {
163
+ const i = `${import_picocolors.default.gray(o)}
164
+ ${b(this.state)} ${t.message}
165
+ `;
166
+ switch (this.state) {
167
+ case "submit": return `${i}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => r(s, "submitted")).join(import_picocolors.default.dim(", "))}`;
168
+ case "cancel": {
169
+ const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => r(c, "cancelled")).join(import_picocolors.default.dim(", "));
170
+ return `${i}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
171
+ ${import_picocolors.default.gray(o)}` : ""}`;
172
+ }
173
+ case "error": {
174
+ const s = this.error.split(`
175
+ `).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
176
+ `);
177
+ return `${i}${import_picocolors.default.yellow(o)} ${this.options.map((c, a, l) => {
178
+ const $ = this.value.includes(c.value) || c.group === !0 && this.isGroupSelected(`${c.value}`), g = a === this.cursor;
179
+ return !g && typeof c.group == "string" && this.options[this.cursor].value === c.group ? r(c, $ ? "group-active-selected" : "group-active", l) : g && $ ? r(c, "active-selected", l) : $ ? r(c, "selected", l) : r(c, g ? "active" : "inactive", l);
180
+ }).join(`
181
+ ${import_picocolors.default.yellow(o)} `)}
182
+ ${s}
183
+ `;
184
+ }
185
+ default: return `${i}${import_picocolors.default.cyan(o)} ${this.options.map((s, c, a) => {
186
+ const l = this.value.includes(s.value) || s.group === !0 && this.isGroupSelected(`${s.value}`), $ = c === this.cursor;
187
+ return !$ && typeof s.group == "string" && this.options[this.cursor].value === s.group ? r(s, l ? "group-active-selected" : "group-active", a) : $ && l ? r(s, "active-selected", a) : l ? r(s, "selected", a) : r(s, $ ? "active" : "inactive", a);
188
+ }).join(`
189
+ ${import_picocolors.default.cyan(o)} `)}
190
+ ${import_picocolors.default.cyan(d)}
191
+ `;
192
+ }
193
+ }
194
+ }).prompt();
195
+ }, Me = (t = "", n = "") => {
196
+ const r = `
197
+ ${t}
198
+ `.split(`
199
+ `), i = stripVTControlCharacters(n).length, s = Math.max(r.reduce((a, l) => {
200
+ const $ = stripVTControlCharacters(l);
201
+ return $.length > a ? $.length : a;
202
+ }, 0), i) + 2, c = r.map((a) => `${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(a)}${" ".repeat(s - stripVTControlCharacters(a).length)}${import_picocolors.default.gray(o)}`).join(`
203
+ `);
204
+ process.stdout.write(`${import_picocolors.default.gray(o)}
205
+ ${import_picocolors.default.green(C)} ${import_picocolors.default.reset(n)} ${import_picocolors.default.gray(_.repeat(Math.max(s - i - 1, 1)) + me)}
206
+ ${c}
207
+ ${import_picocolors.default.gray(de + _.repeat(s + 2) + pe)}
208
+ `);
209
+ }, xe = (t = "") => {
210
+ process.stdout.write(`${import_picocolors.default.gray(d)} ${import_picocolors.default.red(t)}
211
+
212
+ `);
213
+ }, Ie = (t = "") => {
214
+ process.stdout.write(`${import_picocolors.default.gray(ue)} ${t}
215
+ `);
216
+ }, Se = (t = "") => {
217
+ process.stdout.write(`${import_picocolors.default.gray(o)}
218
+ ${import_picocolors.default.gray(d)} ${t}
219
+
220
+ `);
221
+ }, M = {
222
+ message: (t = "", { symbol: n = import_picocolors.default.gray(o) } = {}) => {
223
+ const r = [`${import_picocolors.default.gray(o)}`];
224
+ if (t) {
225
+ const [i, ...s] = t.split(`
226
+ `);
227
+ r.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors.default.gray(o)} ${c}`));
228
+ }
229
+ process.stdout.write(`${r.join(`
230
+ `)}
231
+ `);
232
+ },
233
+ info: (t) => {
234
+ M.message(t, { symbol: import_picocolors.default.blue(q) });
235
+ },
236
+ success: (t) => {
237
+ M.message(t, { symbol: import_picocolors.default.green(D) });
238
+ },
239
+ step: (t) => {
240
+ M.message(t, { symbol: import_picocolors.default.green(C) });
241
+ },
242
+ warn: (t) => {
243
+ M.message(t, { symbol: import_picocolors.default.yellow(U) });
244
+ },
245
+ warning: (t) => {
246
+ M.warn(t);
247
+ },
248
+ error: (t) => {
249
+ M.message(t, { symbol: import_picocolors.default.red(K) });
250
+ }
251
+ }, J = `${import_picocolors.default.gray(o)} `, x = {
252
+ message: async (t, { symbol: n = import_picocolors.default.gray(o) } = {}) => {
253
+ process.stdout.write(`${import_picocolors.default.gray(o)}
254
+ ${n} `);
255
+ let r = 3;
256
+ for await (let i of t) {
257
+ i = i.replace(/\n/g, `
258
+ ${J}`), i.includes(`
259
+ `) && (r = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
260
+ `))).length);
261
+ const s = stripVTControlCharacters(i).length;
262
+ r + s < process.stdout.columns ? (r += s, process.stdout.write(i)) : (process.stdout.write(`
263
+ ${J}${i.trimStart()}`), r = 3 + stripVTControlCharacters(i.trimStart()).length);
264
+ }
265
+ process.stdout.write(`
266
+ `);
267
+ },
268
+ info: (t) => x.message(t, { symbol: import_picocolors.default.blue(q) }),
269
+ success: (t) => x.message(t, { symbol: import_picocolors.default.green(D) }),
270
+ step: (t) => x.message(t, { symbol: import_picocolors.default.green(C) }),
271
+ warn: (t) => x.message(t, { symbol: import_picocolors.default.yellow(U) }),
272
+ warning: (t) => x.warn(t),
273
+ error: (t) => x.message(t, { symbol: import_picocolors.default.red(K) })
274
+ }, Y = ({ indicator: t = "dots" } = {}) => {
275
+ const n = V ? [
276
+ "◒",
277
+ "◐",
278
+ "◓",
279
+ "◑"
280
+ ] : [
281
+ "•",
282
+ "o",
283
+ "O",
284
+ "0"
285
+ ], r = V ? 80 : 120, i = process.env.CI === "true";
286
+ let s, c, a = !1, l = "", $, g = performance.now();
287
+ const p = (m) => {
288
+ a && N(m > 1 ? "Something went wrong" : "Canceled", m);
289
+ }, v = () => p(2), f = () => p(1), j = () => {
290
+ process.on("uncaughtExceptionMonitor", v), process.on("unhandledRejection", v), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p);
291
+ }, E = () => {
292
+ process.removeListener("uncaughtExceptionMonitor", v), process.removeListener("unhandledRejection", v), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p);
293
+ }, B = () => {
294
+ if ($ === void 0) return;
295
+ i && process.stdout.write(`
296
+ `);
297
+ const m = $.split(`
298
+ `);
299
+ process.stdout.write(import_src.cursor.move(-999, m.length - 1)), process.stdout.write(import_src.erase.down(m.length));
300
+ }, R = (m) => m.replace(/\.+$/, ""), O = (m) => {
301
+ const h = (performance.now() - m) / 1e3, w = Math.floor(h / 60), I = Math.floor(h % 60);
302
+ return w > 0 ? `[${w}m ${I}s]` : `[${I}s]`;
303
+ }, H = (m = "") => {
304
+ a = !0, s = fD(), l = R(m), g = performance.now(), process.stdout.write(`${import_picocolors.default.gray(o)}
305
+ `);
306
+ let h = 0, w = 0;
307
+ j(), c = setInterval(() => {
308
+ if (i && l === $) return;
309
+ B(), $ = l;
310
+ const I = import_picocolors.default.magenta(n[h]);
311
+ if (i) process.stdout.write(`${I} ${l}...`);
312
+ else if (t === "timer") process.stdout.write(`${I} ${l} ${O(g)}`);
313
+ else {
314
+ const z = ".".repeat(Math.floor(w)).slice(0, 3);
315
+ process.stdout.write(`${I} ${l}${z}`);
316
+ }
317
+ h = h + 1 < n.length ? h + 1 : 0, w = w < n.length ? w + .125 : 0;
318
+ }, r);
319
+ }, N = (m = "", h = 0) => {
320
+ a = !1, clearInterval(c), B();
321
+ const w = h === 0 ? import_picocolors.default.green(C) : h === 1 ? import_picocolors.default.red(L) : import_picocolors.default.red(W);
322
+ l = R(m ?? l), t === "timer" ? process.stdout.write(`${w} ${l} ${O(g)}
323
+ `) : process.stdout.write(`${w} ${l}
324
+ `), E(), s();
325
+ };
326
+ return {
327
+ start: H,
328
+ stop: N,
329
+ message: (m = "") => {
330
+ l = R(m ?? l);
331
+ }
332
+ };
333
+ };
334
+ export { Y as a, ve as c, Se as i, xe as l, M as n, be as o, Me as r, fe as s, Ie as t, ye as u };