@prisma/internals 6.6.0-integration-feat-orm-693-d1-driver-create-migration-adapter-using-new-http-binding.3 → 6.6.0-integration-push-xmzqvqxpztks.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/Generator.d.ts +23 -5
  2. package/dist/Generator.js +4 -2
  3. package/dist/{chunk-TV34NMBZ.js → chunk-2H6XXXKO.js} +15 -12
  4. package/dist/{chunk-N4XUH3VC.js → chunk-2UZFJUNN.js} +5 -6
  5. package/dist/{chunk-XQSHUIJ5.js → chunk-3BVB3DTJ.js} +8 -8
  6. package/dist/{chunk-HX2VLZFY.js → chunk-57TAND3C.js} +111 -287
  7. package/dist/{chunk-LHESHKC2.js → chunk-57VS7LXW.js} +5 -5
  8. package/dist/{chunk-VVPSLVOR.js → chunk-67I7CEQJ.js} +6 -7
  9. package/dist/{chunk-MWJN65OB.js → chunk-7UNYBZSU.js} +7 -7
  10. package/dist/{chunk-5IAGIQ5I.js → chunk-AO5ASZAS.js} +8 -8
  11. package/dist/{chunk-VYWUZ7RB.js → chunk-B2FA6NFQ.js} +5 -5
  12. package/dist/{chunk-DYVL6P7F.js → chunk-BPDMLM32.js} +46 -13
  13. package/dist/{chunk-UUO6X4LC.js → chunk-BWYO73FG.js} +8 -8
  14. package/dist/{chunk-6727N6PT.js → chunk-CTAL72US.js} +5 -5
  15. package/dist/{chunk-GI3F44TM.js → chunk-D6EDE5WT.js} +5 -5
  16. package/dist/{chunk-ABTIXQDX.js → chunk-EFNTOXMV.js} +4 -5
  17. package/dist/{chunk-75AJJ2SV.js → chunk-MIC43BOZ.js} +5 -5
  18. package/dist/{chunk-K5W6WZ6E.js → chunk-MJIP3FY5.js} +6 -238
  19. package/dist/{chunk-BTWAF3S4.js → chunk-MSOLVYP7.js} +7 -7
  20. package/dist/{chunk-TKUGTIBG.js → chunk-RB2BVNBD.js} +5 -5
  21. package/dist/{chunk-LLOWNQI4.js → chunk-RRCCSZ7D.js} +8 -8
  22. package/dist/{chunk-GIOVJ5SL.js → chunk-TD67MK6Y.js} +8 -8
  23. package/dist/{chunk-PQE76XRR.js → chunk-X3O2LTPO.js} +5 -5
  24. package/dist/{chunk-VAVGLPCV.js → chunk-XG33Y5QX.js} +111 -287
  25. package/dist/{chunk-XKIMYV5V.js → chunk-Y4ZCEXKJ.js} +5 -5
  26. package/dist/{chunk-MSQTODVE.js → chunk-Z2ISC3HD.js} +8 -8
  27. package/dist/cli/checkUnsupportedDataProxy.js +23 -29
  28. package/dist/cli/directoryConfig.d.ts +1 -1
  29. package/dist/cli/directoryConfig.js +2 -2
  30. package/dist/cli/getSchema.d.ts +3 -28
  31. package/dist/cli/getSchema.js +26 -33
  32. package/dist/cli/hashes.d.ts +1 -2
  33. package/dist/cli/hashes.js +23 -29
  34. package/dist/cli/schemaContext.d.ts +4 -3
  35. package/dist/cli/schemaContext.js +23 -29
  36. package/dist/engine-commands/errorHelpers.js +4 -4
  37. package/dist/engine-commands/formatSchema.js +22 -28
  38. package/dist/engine-commands/getConfig.js +10 -10
  39. package/dist/engine-commands/getDmmf.js +7 -7
  40. package/dist/engine-commands/index.js +31 -37
  41. package/dist/engine-commands/lintSchema.js +8 -8
  42. package/dist/engine-commands/mergeSchemas.js +7 -7
  43. package/dist/engine-commands/validate.js +7 -7
  44. package/dist/get-generators/getGenerators.d.ts +18 -9
  45. package/dist/get-generators/getGenerators.js +25 -31
  46. package/dist/getPackedPackage.js +3 -3
  47. package/dist/index.d.ts +3 -5
  48. package/dist/index.js +53 -60
  49. package/dist/resolvePkg.d.ts +7 -0
  50. package/dist/{get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.js → resolvePkg.js} +6 -6
  51. package/dist/utils/getEnvPaths.js +22 -28
  52. package/dist/utils/getVersionFromPackageJson.js +3 -3
  53. package/dist/utils/loadEnvFile.js +22 -28
  54. package/dist/wasm.js +4 -4
  55. package/package.json +11 -12
  56. package/dist/chunk-72UZXEBG.js +0 -28
  57. package/dist/chunk-BWGDP6B5.js +0 -4948
  58. package/dist/chunk-EUTJYQDW.js +0 -46
  59. package/dist/chunk-EWWOTVR3.js +0 -52
  60. package/dist/chunk-GHHABGYW.js +0 -28
  61. package/dist/chunk-QGJH4P4N.js +0 -35
  62. package/dist/get-generators/generatorResolvers/generatorResolvers.d.ts +0 -15
  63. package/dist/get-generators/generatorResolvers/generatorResolvers.js +0 -138
  64. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/findPrismaClientDir.d.ts +0 -6
  65. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/findPrismaClientDir.js +0 -26
  66. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/getPackageCmd.d.ts +0 -9
  67. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/getPackageCmd.js +0 -26
  68. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/runPackageCmd.d.ts +0 -8
  69. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/runPackageCmd.js +0 -29
  70. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.d.ts +0 -6
  71. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.js +0 -138
  72. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/isYarnUsed.d.ts +0 -1
  73. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/isYarnUsed.js +0 -26
  74. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/resolve.d.ts +0 -20
  75. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/resolve.js +0 -26
  76. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.d.ts +0 -7
  77. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.test.d.ts +0 -1
  78. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.test.js +0 -17
  79. package/dist/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.d.ts +0 -20
  80. package/dist/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.js +0 -139
@@ -1,4948 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_BWGDP6B5_exports = {};
30
- __export(chunk_BWGDP6B5_exports, {
31
- detect: () => detect,
32
- getCommand: () => getCommand
33
- });
34
- module.exports = __toCommonJS(chunk_BWGDP6B5_exports);
35
- var import_node_fs = __toESM(require("node:fs"));
36
- var import_node_path = __toESM(require("node:path"));
37
- var import_node_process = __toESM(require("node:process"));
38
- var import_node_buffer = require("node:buffer");
39
- var import_node_child_process = __toESM(require("node:child_process"));
40
- var import_child_process = __toESM(require("child_process"));
41
- var import_path = __toESM(require("path"));
42
- var import_fs = __toESM(require("fs"));
43
- var import_node_url = __toESM(require("node:url"));
44
- var import_node_os = __toESM(require("node:os"));
45
- var import_promises = require("node:timers/promises");
46
- var import_stream = __toESM(require("stream"));
47
- var import_node_util = require("node:util");
48
- var import_os = __toESM(require("os"));
49
- var import_tty = __toESM(require("tty"));
50
- var import_readline = __toESM(require("readline"));
51
- var import_events = __toESM(require("events"));
52
- var import_promises2 = __toESM(require("fs/promises"));
53
- function npmRun(agent) {
54
- return (args) => {
55
- if (args.length > 1)
56
- return `${agent} run ${args[0]} -- ${args.slice(1).join(" ")}`;
57
- else
58
- return `${agent} run ${args[0]}`;
59
- };
60
- }
61
- var yarn = {
62
- "agent": "yarn {0}",
63
- "run": "yarn run {0}",
64
- "install": "yarn install {0}",
65
- "frozen": "yarn install --frozen-lockfile",
66
- "global": "yarn global add {0}",
67
- "add": "yarn add {0}",
68
- "upgrade": "yarn upgrade {0}",
69
- "upgrade-interactive": "yarn upgrade-interactive {0}",
70
- "execute": "npx {0}",
71
- "uninstall": "yarn remove {0}",
72
- "global_uninstall": "yarn global remove {0}"
73
- };
74
- var pnpm = {
75
- "agent": "pnpm {0}",
76
- "run": "pnpm run {0}",
77
- "install": "pnpm i {0}",
78
- "frozen": "pnpm i --frozen-lockfile",
79
- "global": "pnpm add -g {0}",
80
- "add": "pnpm add {0}",
81
- "upgrade": "pnpm update {0}",
82
- "upgrade-interactive": "pnpm update -i {0}",
83
- "execute": "pnpm dlx {0}",
84
- "uninstall": "pnpm remove {0}",
85
- "global_uninstall": "pnpm remove --global {0}"
86
- };
87
- var bun = {
88
- "agent": "bun {0}",
89
- "run": "bun run {0}",
90
- "install": "bun install {0}",
91
- "frozen": "bun install --no-save",
92
- "global": "bun add -g {0}",
93
- "add": "bun add {0}",
94
- "upgrade": "bun update {0}",
95
- "upgrade-interactive": "bun update {0}",
96
- "execute": "bunx {0}",
97
- "uninstall": "bun remove {0}",
98
- "global_uninstall": "bun remove -g {0}"
99
- };
100
- var AGENTS = {
101
- "npm": {
102
- "agent": "npm {0}",
103
- "run": npmRun("npm"),
104
- "install": "npm i {0}",
105
- "frozen": "npm ci",
106
- "global": "npm i -g {0}",
107
- "add": "npm i {0}",
108
- "upgrade": "npm update {0}",
109
- "upgrade-interactive": null,
110
- "execute": "npx {0}",
111
- "uninstall": "npm uninstall {0}",
112
- "global_uninstall": "npm uninstall -g {0}"
113
- },
114
- "yarn": yarn,
115
- "yarn@berry": {
116
- ...yarn,
117
- "frozen": "yarn install --immutable",
118
- "upgrade": "yarn up {0}",
119
- "upgrade-interactive": "yarn up -i {0}",
120
- "execute": "yarn dlx {0}",
121
- // Yarn 2+ removed 'global', see https://github.com/yarnpkg/berry/issues/821
122
- "global": "npm i -g {0}",
123
- "global_uninstall": "npm uninstall -g {0}"
124
- },
125
- "pnpm": pnpm,
126
- // pnpm v6.x or below
127
- "pnpm@6": {
128
- ...pnpm,
129
- run: npmRun("pnpm")
130
- },
131
- "bun": bun
132
- };
133
- var agents = Object.keys(AGENTS);
134
- var LOCKS = {
135
- "bun.lockb": "bun",
136
- "pnpm-lock.yaml": "pnpm",
137
- "yarn.lock": "yarn",
138
- "package-lock.json": "npm",
139
- "npm-shrinkwrap.json": "npm"
140
- };
141
- var INSTALL_PAGE = {
142
- "bun": "https://bun.sh",
143
- "pnpm": "https://pnpm.io/installation",
144
- "pnpm@6": "https://pnpm.io/6.x/installation",
145
- "yarn": "https://classic.yarnpkg.com/en/docs/install",
146
- "yarn@berry": "https://yarnpkg.com/getting-started/install",
147
- "npm": "https://docs.npmjs.com/cli/v8/configuring-npm/install"
148
- };
149
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
150
- function getDefaultExportFromCjs(x) {
151
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
152
- }
153
- var { hasOwnProperty } = Object.prototype;
154
- var crossSpawn$1 = { exports: {} };
155
- var windows;
156
- var hasRequiredWindows;
157
- function requireWindows() {
158
- if (hasRequiredWindows) return windows;
159
- hasRequiredWindows = 1;
160
- windows = isexe2;
161
- isexe2.sync = sync2;
162
- var fs2 = import_fs.default;
163
- function checkPathExt2(path2, options2) {
164
- var pathext = options2.pathExt !== void 0 ? options2.pathExt : process.env.PATHEXT;
165
- if (!pathext) {
166
- return true;
167
- }
168
- pathext = pathext.split(";");
169
- if (pathext.indexOf("") !== -1) {
170
- return true;
171
- }
172
- for (var i = 0; i < pathext.length; i++) {
173
- var p = pathext[i].toLowerCase();
174
- if (p && path2.substr(-p.length).toLowerCase() === p) {
175
- return true;
176
- }
177
- }
178
- return false;
179
- }
180
- function checkStat2(stat, path2, options2) {
181
- if (!stat.isSymbolicLink() && !stat.isFile()) {
182
- return false;
183
- }
184
- return checkPathExt2(path2, options2);
185
- }
186
- function isexe2(path2, options2, cb) {
187
- fs2.stat(path2, function(er, stat) {
188
- cb(er, er ? false : checkStat2(stat, path2, options2));
189
- });
190
- }
191
- function sync2(path2, options2) {
192
- return checkStat2(fs2.statSync(path2), path2, options2);
193
- }
194
- return windows;
195
- }
196
- var mode;
197
- var hasRequiredMode;
198
- function requireMode() {
199
- if (hasRequiredMode) return mode;
200
- hasRequiredMode = 1;
201
- mode = isexe2;
202
- isexe2.sync = sync2;
203
- var fs2 = import_fs.default;
204
- function isexe2(path2, options2, cb) {
205
- fs2.stat(path2, function(er, stat) {
206
- cb(er, er ? false : checkStat2(stat, options2));
207
- });
208
- }
209
- function sync2(path2, options2) {
210
- return checkStat2(fs2.statSync(path2), options2);
211
- }
212
- function checkStat2(stat, options2) {
213
- return stat.isFile() && checkMode2(stat, options2);
214
- }
215
- function checkMode2(stat, options2) {
216
- var mod = stat.mode;
217
- var uid = stat.uid;
218
- var gid = stat.gid;
219
- var myUid = options2.uid !== void 0 ? options2.uid : process.getuid && process.getuid();
220
- var myGid = options2.gid !== void 0 ? options2.gid : process.getgid && process.getgid();
221
- var u = parseInt("100", 8);
222
- var g = parseInt("010", 8);
223
- var o = parseInt("001", 8);
224
- var ug = u | g;
225
- var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
226
- return ret;
227
- }
228
- return mode;
229
- }
230
- var core;
231
- if (process.platform === "win32" || commonjsGlobal.TESTING_WINDOWS) {
232
- core = requireWindows();
233
- } else {
234
- core = requireMode();
235
- }
236
- var isexe_1 = isexe$4;
237
- isexe$4.sync = sync$2;
238
- function isexe$4(path2, options2, cb) {
239
- if (typeof options2 === "function") {
240
- cb = options2;
241
- options2 = {};
242
- }
243
- if (!cb) {
244
- if (typeof Promise !== "function") {
245
- throw new TypeError("callback not provided");
246
- }
247
- return new Promise(function(resolve2, reject) {
248
- isexe$4(path2, options2 || {}, function(er, is) {
249
- if (er) {
250
- reject(er);
251
- } else {
252
- resolve2(is);
253
- }
254
- });
255
- });
256
- }
257
- core(path2, options2 || {}, function(er, is) {
258
- if (er) {
259
- if (er.code === "EACCES" || options2 && options2.ignoreErrors) {
260
- er = null;
261
- is = false;
262
- }
263
- }
264
- cb(er, is);
265
- });
266
- }
267
- function sync$2(path2, options2) {
268
- try {
269
- return core.sync(path2, options2 || {});
270
- } catch (er) {
271
- if (options2 && options2.ignoreErrors || er.code === "EACCES") {
272
- return false;
273
- } else {
274
- throw er;
275
- }
276
- }
277
- }
278
- var isWindows$1 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
279
- var path$2 = import_path.default;
280
- var COLON = isWindows$1 ? ";" : ":";
281
- var isexe$3 = isexe_1;
282
- var getNotFoundError$1 = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
283
- var getPathInfo$1 = (cmd, opt) => {
284
- const colon = opt.colon || COLON;
285
- const pathEnv = cmd.match(/\//) || isWindows$1 && cmd.match(/\\/) ? [""] : [
286
- // windows always checks the cwd first
287
- ...isWindows$1 ? [process.cwd()] : [],
288
- ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
289
- "").split(colon)
290
- ];
291
- const pathExtExe = isWindows$1 ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
292
- const pathExt = isWindows$1 ? pathExtExe.split(colon) : [""];
293
- if (isWindows$1) {
294
- if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
295
- pathExt.unshift("");
296
- }
297
- return {
298
- pathEnv,
299
- pathExt,
300
- pathExtExe
301
- };
302
- };
303
- var which$3 = (cmd, opt, cb) => {
304
- if (typeof opt === "function") {
305
- cb = opt;
306
- opt = {};
307
- }
308
- if (!opt)
309
- opt = {};
310
- const { pathEnv, pathExt, pathExtExe } = getPathInfo$1(cmd, opt);
311
- const found = [];
312
- const step = (i) => new Promise((resolve2, reject) => {
313
- if (i === pathEnv.length)
314
- return opt.all && found.length ? resolve2(found) : reject(getNotFoundError$1(cmd));
315
- const ppRaw = pathEnv[i];
316
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
317
- const pCmd = path$2.join(pathPart, cmd);
318
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
319
- resolve2(subStep(p, i, 0));
320
- });
321
- const subStep = (p, i, ii) => new Promise((resolve2, reject) => {
322
- if (ii === pathExt.length)
323
- return resolve2(step(i + 1));
324
- const ext = pathExt[ii];
325
- isexe$3(p + ext, { pathExt: pathExtExe }, (er, is) => {
326
- if (!er && is) {
327
- if (opt.all)
328
- found.push(p + ext);
329
- else
330
- return resolve2(p + ext);
331
- }
332
- return resolve2(subStep(p, i, ii + 1));
333
- });
334
- });
335
- return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
336
- };
337
- var whichSync$1 = (cmd, opt) => {
338
- opt = opt || {};
339
- const { pathEnv, pathExt, pathExtExe } = getPathInfo$1(cmd, opt);
340
- const found = [];
341
- for (let i = 0; i < pathEnv.length; i++) {
342
- const ppRaw = pathEnv[i];
343
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
344
- const pCmd = path$2.join(pathPart, cmd);
345
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
346
- for (let j = 0; j < pathExt.length; j++) {
347
- const cur = p + pathExt[j];
348
- try {
349
- const is = isexe$3.sync(cur, { pathExt: pathExtExe });
350
- if (is) {
351
- if (opt.all)
352
- found.push(cur);
353
- else
354
- return cur;
355
- }
356
- } catch (ex) {
357
- }
358
- }
359
- }
360
- if (opt.all && found.length)
361
- return found;
362
- if (opt.nothrow)
363
- return null;
364
- throw getNotFoundError$1(cmd);
365
- };
366
- var which_1 = which$3;
367
- which$3.sync = whichSync$1;
368
- var pathKey$2 = { exports: {} };
369
- var pathKey$1 = (options2 = {}) => {
370
- const environment = options2.env || process.env;
371
- const platform = options2.platform || process.platform;
372
- if (platform !== "win32") {
373
- return "PATH";
374
- }
375
- return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
376
- };
377
- pathKey$2.exports = pathKey$1;
378
- pathKey$2.exports.default = pathKey$1;
379
- var pathKeyExports = pathKey$2.exports;
380
- var path$1 = import_path.default;
381
- var which$2 = which_1;
382
- var getPathKey = pathKeyExports;
383
- function resolveCommandAttempt(parsed, withoutPathExt) {
384
- const env2 = parsed.options.env || process.env;
385
- const cwd = process.cwd();
386
- const hasCustomCwd = parsed.options.cwd != null;
387
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
388
- if (shouldSwitchCwd) {
389
- try {
390
- process.chdir(parsed.options.cwd);
391
- } catch (err) {
392
- }
393
- }
394
- let resolved;
395
- try {
396
- resolved = which$2.sync(parsed.command, {
397
- path: env2[getPathKey({ env: env2 })],
398
- pathExt: withoutPathExt ? path$1.delimiter : void 0
399
- });
400
- } catch (e) {
401
- } finally {
402
- if (shouldSwitchCwd) {
403
- process.chdir(cwd);
404
- }
405
- }
406
- if (resolved) {
407
- resolved = path$1.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
408
- }
409
- return resolved;
410
- }
411
- function resolveCommand$1(parsed) {
412
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
413
- }
414
- var resolveCommand_1 = resolveCommand$1;
415
- var _escape = {};
416
- var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
417
- function escapeCommand(arg) {
418
- arg = arg.replace(metaCharsRegExp, "^$1");
419
- return arg;
420
- }
421
- function escapeArgument(arg, doubleEscapeMetaChars) {
422
- arg = `${arg}`;
423
- arg = arg.replace(/(\\*)"/g, '$1$1\\"');
424
- arg = arg.replace(/(\\*)$/, "$1$1");
425
- arg = `"${arg}"`;
426
- arg = arg.replace(metaCharsRegExp, "^$1");
427
- if (doubleEscapeMetaChars) {
428
- arg = arg.replace(metaCharsRegExp, "^$1");
429
- }
430
- return arg;
431
- }
432
- _escape.command = escapeCommand;
433
- _escape.argument = escapeArgument;
434
- var shebangRegex$1 = /^#!(.*)/;
435
- var shebangRegex = shebangRegex$1;
436
- var shebangCommand$1 = (string = "") => {
437
- const match = string.match(shebangRegex);
438
- if (!match) {
439
- return null;
440
- }
441
- const [path2, argument] = match[0].replace(/#! ?/, "").split(" ");
442
- const binary = path2.split("/").pop();
443
- if (binary === "env") {
444
- return argument;
445
- }
446
- return argument ? `${binary} ${argument}` : binary;
447
- };
448
- var fs = import_fs.default;
449
- var shebangCommand = shebangCommand$1;
450
- function readShebang$1(command) {
451
- const size = 150;
452
- const buffer = Buffer.alloc(size);
453
- let fd;
454
- try {
455
- fd = fs.openSync(command, "r");
456
- fs.readSync(fd, buffer, 0, size, 0);
457
- fs.closeSync(fd);
458
- } catch (e) {
459
- }
460
- return shebangCommand(buffer.toString());
461
- }
462
- var readShebang_1 = readShebang$1;
463
- var path = import_path.default;
464
- var resolveCommand = resolveCommand_1;
465
- var escape = _escape;
466
- var readShebang = readShebang_1;
467
- var isWin$1 = process.platform === "win32";
468
- var isExecutableRegExp = /\.(?:com|exe)$/i;
469
- var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
470
- function detectShebang(parsed) {
471
- parsed.file = resolveCommand(parsed);
472
- const shebang = parsed.file && readShebang(parsed.file);
473
- if (shebang) {
474
- parsed.args.unshift(parsed.file);
475
- parsed.command = shebang;
476
- return resolveCommand(parsed);
477
- }
478
- return parsed.file;
479
- }
480
- function parseNonShell(parsed) {
481
- if (!isWin$1) {
482
- return parsed;
483
- }
484
- const commandFile = detectShebang(parsed);
485
- const needsShell = !isExecutableRegExp.test(commandFile);
486
- if (parsed.options.forceShell || needsShell) {
487
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
488
- parsed.command = path.normalize(parsed.command);
489
- parsed.command = escape.command(parsed.command);
490
- parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
491
- const shellCommand = [parsed.command].concat(parsed.args).join(" ");
492
- parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
493
- parsed.command = process.env.comspec || "cmd.exe";
494
- parsed.options.windowsVerbatimArguments = true;
495
- }
496
- return parsed;
497
- }
498
- function parse$1(command, args, options2) {
499
- if (args && !Array.isArray(args)) {
500
- options2 = args;
501
- args = null;
502
- }
503
- args = args ? args.slice(0) : [];
504
- options2 = Object.assign({}, options2);
505
- const parsed = {
506
- command,
507
- args,
508
- options: options2,
509
- file: void 0,
510
- original: {
511
- command,
512
- args
513
- }
514
- };
515
- return options2.shell ? parsed : parseNonShell(parsed);
516
- }
517
- var parse_1 = parse$1;
518
- var isWin = process.platform === "win32";
519
- function notFoundError(original, syscall) {
520
- return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
521
- code: "ENOENT",
522
- errno: "ENOENT",
523
- syscall: `${syscall} ${original.command}`,
524
- path: original.command,
525
- spawnargs: original.args
526
- });
527
- }
528
- function hookChildProcess(cp2, parsed) {
529
- if (!isWin) {
530
- return;
531
- }
532
- const originalEmit = cp2.emit;
533
- cp2.emit = function(name, arg1) {
534
- if (name === "exit") {
535
- const err = verifyENOENT(arg1, parsed);
536
- if (err) {
537
- return originalEmit.call(cp2, "error", err);
538
- }
539
- }
540
- return originalEmit.apply(cp2, arguments);
541
- };
542
- }
543
- function verifyENOENT(status, parsed) {
544
- if (isWin && status === 1 && !parsed.file) {
545
- return notFoundError(parsed.original, "spawn");
546
- }
547
- return null;
548
- }
549
- function verifyENOENTSync(status, parsed) {
550
- if (isWin && status === 1 && !parsed.file) {
551
- return notFoundError(parsed.original, "spawnSync");
552
- }
553
- return null;
554
- }
555
- var enoent$1 = {
556
- hookChildProcess,
557
- verifyENOENT,
558
- verifyENOENTSync,
559
- notFoundError
560
- };
561
- var cp = import_child_process.default;
562
- var parse = parse_1;
563
- var enoent = enoent$1;
564
- function spawn(command, args, options2) {
565
- const parsed = parse(command, args, options2);
566
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
567
- enoent.hookChildProcess(spawned, parsed);
568
- return spawned;
569
- }
570
- function spawnSync(command, args, options2) {
571
- const parsed = parse(command, args, options2);
572
- const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
573
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
574
- return result;
575
- }
576
- crossSpawn$1.exports = spawn;
577
- crossSpawn$1.exports.spawn = spawn;
578
- crossSpawn$1.exports.sync = spawnSync;
579
- crossSpawn$1.exports._parse = parse;
580
- crossSpawn$1.exports._enoent = enoent;
581
- var crossSpawnExports = crossSpawn$1.exports;
582
- var crossSpawn = /* @__PURE__ */ getDefaultExportFromCjs(crossSpawnExports);
583
- function stripFinalNewline(input) {
584
- const LF = typeof input === "string" ? "\n" : "\n".charCodeAt();
585
- const CR = typeof input === "string" ? "\r" : "\r".charCodeAt();
586
- if (input[input.length - 1] === LF) {
587
- input = input.slice(0, -1);
588
- }
589
- if (input[input.length - 1] === CR) {
590
- input = input.slice(0, -1);
591
- }
592
- return input;
593
- }
594
- function pathKey(options2 = {}) {
595
- const {
596
- env: env2 = process.env,
597
- platform = process.platform
598
- } = options2;
599
- if (platform !== "win32") {
600
- return "PATH";
601
- }
602
- return Object.keys(env2).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
603
- }
604
- function npmRunPath(options2 = {}) {
605
- const {
606
- cwd = import_node_process.default.cwd(),
607
- path: path_ = import_node_process.default.env[pathKey()],
608
- execPath = import_node_process.default.execPath
609
- } = options2;
610
- let previous;
611
- const cwdString = cwd instanceof URL ? import_node_url.default.fileURLToPath(cwd) : cwd;
612
- let cwdPath = import_node_path.default.resolve(cwdString);
613
- const result = [];
614
- while (previous !== cwdPath) {
615
- result.push(import_node_path.default.join(cwdPath, "node_modules/.bin"));
616
- previous = cwdPath;
617
- cwdPath = import_node_path.default.resolve(cwdPath, "..");
618
- }
619
- result.push(import_node_path.default.resolve(cwdString, execPath, ".."));
620
- return [...result, path_].join(import_node_path.default.delimiter);
621
- }
622
- function npmRunPathEnv({ env: env2 = import_node_process.default.env, ...options2 } = {}) {
623
- env2 = { ...env2 };
624
- const path2 = pathKey({ env: env2 });
625
- options2.path = env2[path2];
626
- env2[path2] = npmRunPath(options2);
627
- return env2;
628
- }
629
- var copyProperty = (to, from, property, ignoreNonConfigurable) => {
630
- if (property === "length" || property === "prototype") {
631
- return;
632
- }
633
- if (property === "arguments" || property === "caller") {
634
- return;
635
- }
636
- const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
637
- const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
638
- if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
639
- return;
640
- }
641
- Object.defineProperty(to, property, fromDescriptor);
642
- };
643
- var canCopyProperty = function(toDescriptor, fromDescriptor) {
644
- return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
645
- };
646
- var changePrototype = (to, from) => {
647
- const fromPrototype = Object.getPrototypeOf(from);
648
- if (fromPrototype === Object.getPrototypeOf(to)) {
649
- return;
650
- }
651
- Object.setPrototypeOf(to, fromPrototype);
652
- };
653
- var wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/
654
- ${fromBody}`;
655
- var toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
656
- var toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
657
- var changeToString = (to, from, name) => {
658
- const withName = name === "" ? "" : `with ${name.trim()}() `;
659
- const newToString = wrappedToString.bind(null, withName, from.toString());
660
- Object.defineProperty(newToString, "name", toStringName);
661
- Object.defineProperty(to, "toString", { ...toStringDescriptor, value: newToString });
662
- };
663
- function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
664
- const { name } = to;
665
- for (const property of Reflect.ownKeys(from)) {
666
- copyProperty(to, from, property, ignoreNonConfigurable);
667
- }
668
- changePrototype(to, from);
669
- changeToString(to, from, name);
670
- return to;
671
- }
672
- var calledFunctions = /* @__PURE__ */ new WeakMap();
673
- var onetime = (function_, options2 = {}) => {
674
- if (typeof function_ !== "function") {
675
- throw new TypeError("Expected a function");
676
- }
677
- let returnValue;
678
- let callCount = 0;
679
- const functionName = function_.displayName || function_.name || "<anonymous>";
680
- const onetime2 = function(...arguments_) {
681
- calledFunctions.set(onetime2, ++callCount);
682
- if (callCount === 1) {
683
- returnValue = function_.apply(this, arguments_);
684
- function_ = null;
685
- } else if (options2.throw === true) {
686
- throw new Error(`Function \`${functionName}\` can only be called once`);
687
- }
688
- return returnValue;
689
- };
690
- mimicFunction(onetime2, function_);
691
- calledFunctions.set(onetime2, callCount);
692
- return onetime2;
693
- };
694
- onetime.callCount = (function_) => {
695
- if (!calledFunctions.has(function_)) {
696
- throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
697
- }
698
- return calledFunctions.get(function_);
699
- };
700
- var getRealtimeSignals = () => {
701
- const length = SIGRTMAX - SIGRTMIN + 1;
702
- return Array.from({ length }, getRealtimeSignal);
703
- };
704
- var getRealtimeSignal = (value, index) => ({
705
- name: `SIGRT${index + 1}`,
706
- number: SIGRTMIN + index,
707
- action: "terminate",
708
- description: "Application-specific signal (realtime)",
709
- standard: "posix"
710
- });
711
- var SIGRTMIN = 34;
712
- var SIGRTMAX = 64;
713
- var SIGNALS = [
714
- {
715
- name: "SIGHUP",
716
- number: 1,
717
- action: "terminate",
718
- description: "Terminal closed",
719
- standard: "posix"
720
- },
721
- {
722
- name: "SIGINT",
723
- number: 2,
724
- action: "terminate",
725
- description: "User interruption with CTRL-C",
726
- standard: "ansi"
727
- },
728
- {
729
- name: "SIGQUIT",
730
- number: 3,
731
- action: "core",
732
- description: "User interruption with CTRL-\\",
733
- standard: "posix"
734
- },
735
- {
736
- name: "SIGILL",
737
- number: 4,
738
- action: "core",
739
- description: "Invalid machine instruction",
740
- standard: "ansi"
741
- },
742
- {
743
- name: "SIGTRAP",
744
- number: 5,
745
- action: "core",
746
- description: "Debugger breakpoint",
747
- standard: "posix"
748
- },
749
- {
750
- name: "SIGABRT",
751
- number: 6,
752
- action: "core",
753
- description: "Aborted",
754
- standard: "ansi"
755
- },
756
- {
757
- name: "SIGIOT",
758
- number: 6,
759
- action: "core",
760
- description: "Aborted",
761
- standard: "bsd"
762
- },
763
- {
764
- name: "SIGBUS",
765
- number: 7,
766
- action: "core",
767
- description: "Bus error due to misaligned, non-existing address or paging error",
768
- standard: "bsd"
769
- },
770
- {
771
- name: "SIGEMT",
772
- number: 7,
773
- action: "terminate",
774
- description: "Command should be emulated but is not implemented",
775
- standard: "other"
776
- },
777
- {
778
- name: "SIGFPE",
779
- number: 8,
780
- action: "core",
781
- description: "Floating point arithmetic error",
782
- standard: "ansi"
783
- },
784
- {
785
- name: "SIGKILL",
786
- number: 9,
787
- action: "terminate",
788
- description: "Forced termination",
789
- standard: "posix",
790
- forced: true
791
- },
792
- {
793
- name: "SIGUSR1",
794
- number: 10,
795
- action: "terminate",
796
- description: "Application-specific signal",
797
- standard: "posix"
798
- },
799
- {
800
- name: "SIGSEGV",
801
- number: 11,
802
- action: "core",
803
- description: "Segmentation fault",
804
- standard: "ansi"
805
- },
806
- {
807
- name: "SIGUSR2",
808
- number: 12,
809
- action: "terminate",
810
- description: "Application-specific signal",
811
- standard: "posix"
812
- },
813
- {
814
- name: "SIGPIPE",
815
- number: 13,
816
- action: "terminate",
817
- description: "Broken pipe or socket",
818
- standard: "posix"
819
- },
820
- {
821
- name: "SIGALRM",
822
- number: 14,
823
- action: "terminate",
824
- description: "Timeout or timer",
825
- standard: "posix"
826
- },
827
- {
828
- name: "SIGTERM",
829
- number: 15,
830
- action: "terminate",
831
- description: "Termination",
832
- standard: "ansi"
833
- },
834
- {
835
- name: "SIGSTKFLT",
836
- number: 16,
837
- action: "terminate",
838
- description: "Stack is empty or overflowed",
839
- standard: "other"
840
- },
841
- {
842
- name: "SIGCHLD",
843
- number: 17,
844
- action: "ignore",
845
- description: "Child process terminated, paused or unpaused",
846
- standard: "posix"
847
- },
848
- {
849
- name: "SIGCLD",
850
- number: 17,
851
- action: "ignore",
852
- description: "Child process terminated, paused or unpaused",
853
- standard: "other"
854
- },
855
- {
856
- name: "SIGCONT",
857
- number: 18,
858
- action: "unpause",
859
- description: "Unpaused",
860
- standard: "posix",
861
- forced: true
862
- },
863
- {
864
- name: "SIGSTOP",
865
- number: 19,
866
- action: "pause",
867
- description: "Paused",
868
- standard: "posix",
869
- forced: true
870
- },
871
- {
872
- name: "SIGTSTP",
873
- number: 20,
874
- action: "pause",
875
- description: 'Paused using CTRL-Z or "suspend"',
876
- standard: "posix"
877
- },
878
- {
879
- name: "SIGTTIN",
880
- number: 21,
881
- action: "pause",
882
- description: "Background process cannot read terminal input",
883
- standard: "posix"
884
- },
885
- {
886
- name: "SIGBREAK",
887
- number: 21,
888
- action: "terminate",
889
- description: "User interruption with CTRL-BREAK",
890
- standard: "other"
891
- },
892
- {
893
- name: "SIGTTOU",
894
- number: 22,
895
- action: "pause",
896
- description: "Background process cannot write to terminal output",
897
- standard: "posix"
898
- },
899
- {
900
- name: "SIGURG",
901
- number: 23,
902
- action: "ignore",
903
- description: "Socket received out-of-band data",
904
- standard: "bsd"
905
- },
906
- {
907
- name: "SIGXCPU",
908
- number: 24,
909
- action: "core",
910
- description: "Process timed out",
911
- standard: "bsd"
912
- },
913
- {
914
- name: "SIGXFSZ",
915
- number: 25,
916
- action: "core",
917
- description: "File too big",
918
- standard: "bsd"
919
- },
920
- {
921
- name: "SIGVTALRM",
922
- number: 26,
923
- action: "terminate",
924
- description: "Timeout or timer",
925
- standard: "bsd"
926
- },
927
- {
928
- name: "SIGPROF",
929
- number: 27,
930
- action: "terminate",
931
- description: "Timeout or timer",
932
- standard: "bsd"
933
- },
934
- {
935
- name: "SIGWINCH",
936
- number: 28,
937
- action: "ignore",
938
- description: "Terminal window size changed",
939
- standard: "bsd"
940
- },
941
- {
942
- name: "SIGIO",
943
- number: 29,
944
- action: "terminate",
945
- description: "I/O is available",
946
- standard: "other"
947
- },
948
- {
949
- name: "SIGPOLL",
950
- number: 29,
951
- action: "terminate",
952
- description: "Watched event",
953
- standard: "other"
954
- },
955
- {
956
- name: "SIGINFO",
957
- number: 29,
958
- action: "ignore",
959
- description: "Request for process information",
960
- standard: "other"
961
- },
962
- {
963
- name: "SIGPWR",
964
- number: 30,
965
- action: "terminate",
966
- description: "Device running out of power",
967
- standard: "systemv"
968
- },
969
- {
970
- name: "SIGSYS",
971
- number: 31,
972
- action: "core",
973
- description: "Invalid system call",
974
- standard: "other"
975
- },
976
- {
977
- name: "SIGUNUSED",
978
- number: 31,
979
- action: "terminate",
980
- description: "Invalid system call",
981
- standard: "other"
982
- }
983
- ];
984
- var getSignals = () => {
985
- const realtimeSignals = getRealtimeSignals();
986
- const signals2 = [...SIGNALS, ...realtimeSignals].map(normalizeSignal);
987
- return signals2;
988
- };
989
- var normalizeSignal = ({
990
- name,
991
- number: defaultNumber,
992
- description,
993
- action: action2,
994
- forced = false,
995
- standard
996
- }) => {
997
- const {
998
- signals: { [name]: constantSignal }
999
- } = import_node_os.constants;
1000
- const supported = constantSignal !== void 0;
1001
- const number2 = supported ? constantSignal : defaultNumber;
1002
- return { name, number: number2, description, supported, action: action2, forced, standard };
1003
- };
1004
- var getSignalsByName = () => {
1005
- const signals2 = getSignals();
1006
- return Object.fromEntries(signals2.map(getSignalByName));
1007
- };
1008
- var getSignalByName = ({
1009
- name,
1010
- number: number2,
1011
- description,
1012
- supported,
1013
- action: action2,
1014
- forced,
1015
- standard
1016
- }) => [name, { name, number: number2, description, supported, action: action2, forced, standard }];
1017
- var signalsByName = getSignalsByName();
1018
- var getSignalsByNumber = () => {
1019
- const signals2 = getSignals();
1020
- const length = SIGRTMAX + 1;
1021
- const signalsA = Array.from(
1022
- { length },
1023
- (value, number2) => getSignalByNumber(number2, signals2)
1024
- );
1025
- return Object.assign({}, ...signalsA);
1026
- };
1027
- var getSignalByNumber = (number2, signals2) => {
1028
- const signal = findSignalByNumber(number2, signals2);
1029
- if (signal === void 0) {
1030
- return {};
1031
- }
1032
- const { name, description, supported, action: action2, forced, standard } = signal;
1033
- return {
1034
- [number2]: {
1035
- name,
1036
- number: number2,
1037
- description,
1038
- supported,
1039
- action: action2,
1040
- forced,
1041
- standard
1042
- }
1043
- };
1044
- };
1045
- var findSignalByNumber = (number2, signals2) => {
1046
- const signal = signals2.find(({ name }) => import_node_os.constants.signals[name] === number2);
1047
- if (signal !== void 0) {
1048
- return signal;
1049
- }
1050
- return signals2.find((signalA) => signalA.number === number2);
1051
- };
1052
- getSignalsByNumber();
1053
- var getErrorPrefix = ({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled }) => {
1054
- if (timedOut) {
1055
- return `timed out after ${timeout} milliseconds`;
1056
- }
1057
- if (isCanceled) {
1058
- return "was canceled";
1059
- }
1060
- if (errorCode !== void 0) {
1061
- return `failed with ${errorCode}`;
1062
- }
1063
- if (signal !== void 0) {
1064
- return `was killed with ${signal} (${signalDescription})`;
1065
- }
1066
- if (exitCode !== void 0) {
1067
- return `failed with exit code ${exitCode}`;
1068
- }
1069
- return "failed";
1070
- };
1071
- var makeError = ({
1072
- stdout,
1073
- stderr,
1074
- all,
1075
- error,
1076
- signal,
1077
- exitCode,
1078
- command,
1079
- escapedCommand,
1080
- timedOut,
1081
- isCanceled,
1082
- killed,
1083
- parsed: { options: { timeout, cwd = import_node_process.default.cwd() } }
1084
- }) => {
1085
- exitCode = exitCode === null ? void 0 : exitCode;
1086
- signal = signal === null ? void 0 : signal;
1087
- const signalDescription = signal === void 0 ? void 0 : signalsByName[signal].description;
1088
- const errorCode = error && error.code;
1089
- const prefix = getErrorPrefix({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled });
1090
- const execaMessage = `Command ${prefix}: ${command}`;
1091
- const isError = Object.prototype.toString.call(error) === "[object Error]";
1092
- const shortMessage = isError ? `${execaMessage}
1093
- ${error.message}` : execaMessage;
1094
- const message = [shortMessage, stderr, stdout].filter(Boolean).join("\n");
1095
- if (isError) {
1096
- error.originalMessage = error.message;
1097
- error.message = message;
1098
- } else {
1099
- error = new Error(message);
1100
- }
1101
- error.shortMessage = shortMessage;
1102
- error.command = command;
1103
- error.escapedCommand = escapedCommand;
1104
- error.exitCode = exitCode;
1105
- error.signal = signal;
1106
- error.signalDescription = signalDescription;
1107
- error.stdout = stdout;
1108
- error.stderr = stderr;
1109
- error.cwd = cwd;
1110
- if (all !== void 0) {
1111
- error.all = all;
1112
- }
1113
- if ("bufferedData" in error) {
1114
- delete error.bufferedData;
1115
- }
1116
- error.failed = true;
1117
- error.timedOut = Boolean(timedOut);
1118
- error.isCanceled = isCanceled;
1119
- error.killed = killed && !timedOut;
1120
- return error;
1121
- };
1122
- var aliases = ["stdin", "stdout", "stderr"];
1123
- var hasAlias = (options2) => aliases.some((alias) => options2[alias] !== void 0);
1124
- var normalizeStdio = (options2) => {
1125
- if (!options2) {
1126
- return;
1127
- }
1128
- const { stdio } = options2;
1129
- if (stdio === void 0) {
1130
- return aliases.map((alias) => options2[alias]);
1131
- }
1132
- if (hasAlias(options2)) {
1133
- throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map((alias) => `\`${alias}\``).join(", ")}`);
1134
- }
1135
- if (typeof stdio === "string") {
1136
- return stdio;
1137
- }
1138
- if (!Array.isArray(stdio)) {
1139
- throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
1140
- }
1141
- const length = Math.max(stdio.length, aliases.length);
1142
- return Array.from({ length }, (value, index) => stdio[index]);
1143
- };
1144
- var signals = [];
1145
- signals.push("SIGHUP", "SIGINT", "SIGTERM");
1146
- if (process.platform !== "win32") {
1147
- signals.push(
1148
- "SIGALRM",
1149
- "SIGABRT",
1150
- "SIGVTALRM",
1151
- "SIGXCPU",
1152
- "SIGXFSZ",
1153
- "SIGUSR2",
1154
- "SIGTRAP",
1155
- "SIGSYS",
1156
- "SIGQUIT",
1157
- "SIGIOT"
1158
- // should detect profiler and enable/disable accordingly.
1159
- // see #21
1160
- // 'SIGPROF'
1161
- );
1162
- }
1163
- if (process.platform === "linux") {
1164
- signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
1165
- }
1166
- var processOk = (process2) => !!process2 && typeof process2 === "object" && typeof process2.removeListener === "function" && typeof process2.emit === "function" && typeof process2.reallyExit === "function" && typeof process2.listeners === "function" && typeof process2.kill === "function" && typeof process2.pid === "number" && typeof process2.on === "function";
1167
- var kExitEmitter = Symbol.for("signal-exit emitter");
1168
- var global$1 = globalThis;
1169
- var ObjectDefineProperty = Object.defineProperty.bind(Object);
1170
- var Emitter = class {
1171
- emitted = {
1172
- afterExit: false,
1173
- exit: false
1174
- };
1175
- listeners = {
1176
- afterExit: [],
1177
- exit: []
1178
- };
1179
- count = 0;
1180
- id = Math.random();
1181
- constructor() {
1182
- if (global$1[kExitEmitter]) {
1183
- return global$1[kExitEmitter];
1184
- }
1185
- ObjectDefineProperty(global$1, kExitEmitter, {
1186
- value: this,
1187
- writable: false,
1188
- enumerable: false,
1189
- configurable: false
1190
- });
1191
- }
1192
- on(ev, fn) {
1193
- this.listeners[ev].push(fn);
1194
- }
1195
- removeListener(ev, fn) {
1196
- const list = this.listeners[ev];
1197
- const i = list.indexOf(fn);
1198
- if (i === -1) {
1199
- return;
1200
- }
1201
- if (i === 0 && list.length === 1) {
1202
- list.length = 0;
1203
- } else {
1204
- list.splice(i, 1);
1205
- }
1206
- }
1207
- emit(ev, code, signal) {
1208
- if (this.emitted[ev]) {
1209
- return false;
1210
- }
1211
- this.emitted[ev] = true;
1212
- let ret = false;
1213
- for (const fn of this.listeners[ev]) {
1214
- ret = fn(code, signal) === true || ret;
1215
- }
1216
- if (ev === "exit") {
1217
- ret = this.emit("afterExit", code, signal) || ret;
1218
- }
1219
- return ret;
1220
- }
1221
- };
1222
- var SignalExitBase = class {
1223
- };
1224
- var signalExitWrap = (handler) => {
1225
- return {
1226
- onExit(cb, opts) {
1227
- return handler.onExit(cb, opts);
1228
- },
1229
- load() {
1230
- return handler.load();
1231
- },
1232
- unload() {
1233
- return handler.unload();
1234
- }
1235
- };
1236
- };
1237
- var SignalExitFallback = class extends SignalExitBase {
1238
- onExit() {
1239
- return () => {
1240
- };
1241
- }
1242
- load() {
1243
- }
1244
- unload() {
1245
- }
1246
- };
1247
- var SignalExit = class extends SignalExitBase {
1248
- // "SIGHUP" throws an `ENOSYS` error on Windows,
1249
- // so use a supported signal instead
1250
- /* c8 ignore start */
1251
- #hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
1252
- /* c8 ignore stop */
1253
- #emitter = new Emitter();
1254
- #process;
1255
- #originalProcessEmit;
1256
- #originalProcessReallyExit;
1257
- #sigListeners = {};
1258
- #loaded = false;
1259
- constructor(process2) {
1260
- super();
1261
- this.#process = process2;
1262
- this.#sigListeners = {};
1263
- for (const sig of signals) {
1264
- this.#sigListeners[sig] = () => {
1265
- const listeners = this.#process.listeners(sig);
1266
- let { count } = this.#emitter;
1267
- const p = process2;
1268
- if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
1269
- count += p.__signal_exit_emitter__.count;
1270
- }
1271
- if (listeners.length === count) {
1272
- this.unload();
1273
- const ret = this.#emitter.emit("exit", null, sig);
1274
- const s = sig === "SIGHUP" ? this.#hupSig : sig;
1275
- if (!ret)
1276
- process2.kill(process2.pid, s);
1277
- }
1278
- };
1279
- }
1280
- this.#originalProcessReallyExit = process2.reallyExit;
1281
- this.#originalProcessEmit = process2.emit;
1282
- }
1283
- onExit(cb, opts) {
1284
- if (!processOk(this.#process)) {
1285
- return () => {
1286
- };
1287
- }
1288
- if (this.#loaded === false) {
1289
- this.load();
1290
- }
1291
- const ev = opts?.alwaysLast ? "afterExit" : "exit";
1292
- this.#emitter.on(ev, cb);
1293
- return () => {
1294
- this.#emitter.removeListener(ev, cb);
1295
- if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
1296
- this.unload();
1297
- }
1298
- };
1299
- }
1300
- load() {
1301
- if (this.#loaded) {
1302
- return;
1303
- }
1304
- this.#loaded = true;
1305
- this.#emitter.count += 1;
1306
- for (const sig of signals) {
1307
- try {
1308
- const fn = this.#sigListeners[sig];
1309
- if (fn)
1310
- this.#process.on(sig, fn);
1311
- } catch (_) {
1312
- }
1313
- }
1314
- this.#process.emit = (ev, ...a) => {
1315
- return this.#processEmit(ev, ...a);
1316
- };
1317
- this.#process.reallyExit = (code) => {
1318
- return this.#processReallyExit(code);
1319
- };
1320
- }
1321
- unload() {
1322
- if (!this.#loaded) {
1323
- return;
1324
- }
1325
- this.#loaded = false;
1326
- signals.forEach((sig) => {
1327
- const listener = this.#sigListeners[sig];
1328
- if (!listener) {
1329
- throw new Error("Listener not defined for signal: " + sig);
1330
- }
1331
- try {
1332
- this.#process.removeListener(sig, listener);
1333
- } catch (_) {
1334
- }
1335
- });
1336
- this.#process.emit = this.#originalProcessEmit;
1337
- this.#process.reallyExit = this.#originalProcessReallyExit;
1338
- this.#emitter.count -= 1;
1339
- }
1340
- #processReallyExit(code) {
1341
- if (!processOk(this.#process)) {
1342
- return 0;
1343
- }
1344
- this.#process.exitCode = code || 0;
1345
- this.#emitter.emit("exit", this.#process.exitCode, null);
1346
- return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
1347
- }
1348
- #processEmit(ev, ...args) {
1349
- const og = this.#originalProcessEmit;
1350
- if (ev === "exit" && processOk(this.#process)) {
1351
- if (typeof args[0] === "number") {
1352
- this.#process.exitCode = args[0];
1353
- }
1354
- const ret = og.call(this.#process, ev, ...args);
1355
- this.#emitter.emit("exit", this.#process.exitCode, null);
1356
- return ret;
1357
- } else {
1358
- return og.call(this.#process, ev, ...args);
1359
- }
1360
- }
1361
- };
1362
- var process$1 = globalThis.process;
1363
- var {
1364
- /**
1365
- * Called when the process is exiting, whether via signal, explicit
1366
- * exit, or running out of stuff to do.
1367
- *
1368
- * If the global process object is not suitable for instrumentation,
1369
- * then this will be a no-op.
1370
- *
1371
- * Returns a function that may be used to unload signal-exit.
1372
- */
1373
- onExit,
1374
- /**
1375
- * Load the listeners. Likely you never need to call this, unless
1376
- * doing a rather deep integration with signal-exit functionality.
1377
- * Mostly exposed for the benefit of testing.
1378
- *
1379
- * @internal
1380
- */
1381
- load,
1382
- /**
1383
- * Unload the listeners. Likely you never need to call this, unless
1384
- * doing a rather deep integration with signal-exit functionality.
1385
- * Mostly exposed for the benefit of testing.
1386
- *
1387
- * @internal
1388
- */
1389
- unload
1390
- } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
1391
- var DEFAULT_FORCE_KILL_TIMEOUT = 1e3 * 5;
1392
- var spawnedKill = (kill, signal = "SIGTERM", options2 = {}) => {
1393
- const killResult = kill(signal);
1394
- setKillTimeout(kill, signal, options2, killResult);
1395
- return killResult;
1396
- };
1397
- var setKillTimeout = (kill, signal, options2, killResult) => {
1398
- if (!shouldForceKill(signal, options2, killResult)) {
1399
- return;
1400
- }
1401
- const timeout = getForceKillAfterTimeout(options2);
1402
- const t = setTimeout(() => {
1403
- kill("SIGKILL");
1404
- }, timeout);
1405
- if (t.unref) {
1406
- t.unref();
1407
- }
1408
- };
1409
- var shouldForceKill = (signal, { forceKillAfterTimeout }, killResult) => isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
1410
- var isSigterm = (signal) => signal === import_node_os.default.constants.signals.SIGTERM || typeof signal === "string" && signal.toUpperCase() === "SIGTERM";
1411
- var getForceKillAfterTimeout = ({ forceKillAfterTimeout = true }) => {
1412
- if (forceKillAfterTimeout === true) {
1413
- return DEFAULT_FORCE_KILL_TIMEOUT;
1414
- }
1415
- if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
1416
- throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
1417
- }
1418
- return forceKillAfterTimeout;
1419
- };
1420
- var spawnedCancel = (spawned, context) => {
1421
- const killResult = spawned.kill();
1422
- if (killResult) {
1423
- context.isCanceled = true;
1424
- }
1425
- };
1426
- var timeoutKill = (spawned, signal, reject) => {
1427
- spawned.kill(signal);
1428
- reject(Object.assign(new Error("Timed out"), { timedOut: true, signal }));
1429
- };
1430
- var setupTimeout = (spawned, { timeout, killSignal = "SIGTERM" }, spawnedPromise) => {
1431
- if (timeout === 0 || timeout === void 0) {
1432
- return spawnedPromise;
1433
- }
1434
- let timeoutId;
1435
- const timeoutPromise = new Promise((resolve2, reject) => {
1436
- timeoutId = setTimeout(() => {
1437
- timeoutKill(spawned, killSignal, reject);
1438
- }, timeout);
1439
- });
1440
- const safeSpawnedPromise = spawnedPromise.finally(() => {
1441
- clearTimeout(timeoutId);
1442
- });
1443
- return Promise.race([timeoutPromise, safeSpawnedPromise]);
1444
- };
1445
- var validateTimeout = ({ timeout }) => {
1446
- if (timeout !== void 0 && (!Number.isFinite(timeout) || timeout < 0)) {
1447
- throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
1448
- }
1449
- };
1450
- var setExitHandler = async (spawned, { cleanup, detached }, timedPromise) => {
1451
- if (!cleanup || detached) {
1452
- return timedPromise;
1453
- }
1454
- const removeExitHandler = onExit(() => {
1455
- spawned.kill();
1456
- });
1457
- return timedPromise.finally(() => {
1458
- removeExitHandler();
1459
- });
1460
- };
1461
- function isStream(stream) {
1462
- return stream !== null && typeof stream === "object" && typeof stream.pipe === "function";
1463
- }
1464
- function isWritableStream(stream) {
1465
- return isStream(stream) && stream.writable !== false && typeof stream._write === "function" && typeof stream._writableState === "object";
1466
- }
1467
- var isExecaChildProcess = (target) => target instanceof import_node_child_process.ChildProcess && typeof target.then === "function";
1468
- var pipeToTarget = (spawned, streamName, target) => {
1469
- if (typeof target === "string") {
1470
- spawned[streamName].pipe((0, import_node_fs.createWriteStream)(target));
1471
- return spawned;
1472
- }
1473
- if (isWritableStream(target)) {
1474
- spawned[streamName].pipe(target);
1475
- return spawned;
1476
- }
1477
- if (!isExecaChildProcess(target)) {
1478
- throw new TypeError("The second argument must be a string, a stream or an Execa child process.");
1479
- }
1480
- if (!isWritableStream(target.stdin)) {
1481
- throw new TypeError("The target child process's stdin must be available.");
1482
- }
1483
- spawned[streamName].pipe(target.stdin);
1484
- return target;
1485
- };
1486
- var addPipeMethods = (spawned) => {
1487
- if (spawned.stdout !== null) {
1488
- spawned.pipeStdout = pipeToTarget.bind(void 0, spawned, "stdout");
1489
- }
1490
- if (spawned.stderr !== null) {
1491
- spawned.pipeStderr = pipeToTarget.bind(void 0, spawned, "stderr");
1492
- }
1493
- if (spawned.all !== void 0) {
1494
- spawned.pipeAll = pipeToTarget.bind(void 0, spawned, "all");
1495
- }
1496
- };
1497
- var getStreamContents = async (stream, { init: init2, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize }, { maxBuffer = Number.POSITIVE_INFINITY } = {}) => {
1498
- if (!isAsyncIterable(stream)) {
1499
- throw new Error("The first argument must be a Readable, a ReadableStream, or an async iterable.");
1500
- }
1501
- const state = init2();
1502
- state.length = 0;
1503
- try {
1504
- for await (const chunk of stream) {
1505
- const chunkType = getChunkType(chunk);
1506
- const convertedChunk = convertChunk[chunkType](chunk, state);
1507
- appendChunk({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer });
1508
- }
1509
- appendFinalChunk({ state, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer });
1510
- return finalize(state);
1511
- } catch (error) {
1512
- error.bufferedData = finalize(state);
1513
- throw error;
1514
- }
1515
- };
1516
- var appendFinalChunk = ({ state, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer }) => {
1517
- const convertedChunk = getFinalChunk(state);
1518
- if (convertedChunk !== void 0) {
1519
- appendChunk({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer });
1520
- }
1521
- };
1522
- var appendChunk = ({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer }) => {
1523
- const chunkSize = getSize(convertedChunk);
1524
- const newLength = state.length + chunkSize;
1525
- if (newLength <= maxBuffer) {
1526
- addNewChunk(convertedChunk, state, addChunk, newLength);
1527
- return;
1528
- }
1529
- const truncatedChunk = truncateChunk(convertedChunk, maxBuffer - state.length);
1530
- if (truncatedChunk !== void 0) {
1531
- addNewChunk(truncatedChunk, state, addChunk, maxBuffer);
1532
- }
1533
- throw new MaxBufferError();
1534
- };
1535
- var addNewChunk = (convertedChunk, state, addChunk, newLength) => {
1536
- state.contents = addChunk(convertedChunk, state, newLength);
1537
- state.length = newLength;
1538
- };
1539
- var isAsyncIterable = (stream) => typeof stream === "object" && stream !== null && typeof stream[Symbol.asyncIterator] === "function";
1540
- var getChunkType = (chunk) => {
1541
- const typeOfChunk = typeof chunk;
1542
- if (typeOfChunk === "string") {
1543
- return "string";
1544
- }
1545
- if (typeOfChunk !== "object" || chunk === null) {
1546
- return "others";
1547
- }
1548
- if (globalThis.Buffer?.isBuffer(chunk)) {
1549
- return "buffer";
1550
- }
1551
- const prototypeName = objectToString.call(chunk);
1552
- if (prototypeName === "[object ArrayBuffer]") {
1553
- return "arrayBuffer";
1554
- }
1555
- if (prototypeName === "[object DataView]") {
1556
- return "dataView";
1557
- }
1558
- if (Number.isInteger(chunk.byteLength) && Number.isInteger(chunk.byteOffset) && objectToString.call(chunk.buffer) === "[object ArrayBuffer]") {
1559
- return "typedArray";
1560
- }
1561
- return "others";
1562
- };
1563
- var { toString: objectToString } = Object.prototype;
1564
- var MaxBufferError = class extends Error {
1565
- name = "MaxBufferError";
1566
- constructor() {
1567
- super("maxBuffer exceeded");
1568
- }
1569
- };
1570
- var identity = (value) => value;
1571
- var noop$1 = () => void 0;
1572
- var getContentsProp = ({ contents }) => contents;
1573
- var throwObjectStream = (chunk) => {
1574
- throw new Error(`Streams in object mode are not supported: ${String(chunk)}`);
1575
- };
1576
- var getLengthProp = (convertedChunk) => convertedChunk.length;
1577
- async function getStreamAsArrayBuffer(stream, options2) {
1578
- return getStreamContents(stream, arrayBufferMethods, options2);
1579
- }
1580
- var initArrayBuffer = () => ({ contents: new ArrayBuffer(0) });
1581
- var useTextEncoder = (chunk) => textEncoder.encode(chunk);
1582
- var textEncoder = new TextEncoder();
1583
- var useUint8Array = (chunk) => new Uint8Array(chunk);
1584
- var useUint8ArrayWithOffset = (chunk) => new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
1585
- var truncateArrayBufferChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize);
1586
- var addArrayBufferChunk = (convertedChunk, { contents, length: previousLength }, length) => {
1587
- const newContents = hasArrayBufferResize() ? resizeArrayBuffer(contents, length) : resizeArrayBufferSlow(contents, length);
1588
- new Uint8Array(newContents).set(convertedChunk, previousLength);
1589
- return newContents;
1590
- };
1591
- var resizeArrayBufferSlow = (contents, length) => {
1592
- if (length <= contents.byteLength) {
1593
- return contents;
1594
- }
1595
- const arrayBuffer = new ArrayBuffer(getNewContentsLength(length));
1596
- new Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);
1597
- return arrayBuffer;
1598
- };
1599
- var resizeArrayBuffer = (contents, length) => {
1600
- if (length <= contents.maxByteLength) {
1601
- contents.resize(length);
1602
- return contents;
1603
- }
1604
- const arrayBuffer = new ArrayBuffer(length, { maxByteLength: getNewContentsLength(length) });
1605
- new Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);
1606
- return arrayBuffer;
1607
- };
1608
- var getNewContentsLength = (length) => SCALE_FACTOR ** Math.ceil(Math.log(length) / Math.log(SCALE_FACTOR));
1609
- var SCALE_FACTOR = 2;
1610
- var finalizeArrayBuffer = ({ contents, length }) => hasArrayBufferResize() ? contents : contents.slice(0, length);
1611
- var hasArrayBufferResize = () => "resize" in ArrayBuffer.prototype;
1612
- var arrayBufferMethods = {
1613
- init: initArrayBuffer,
1614
- convertChunk: {
1615
- string: useTextEncoder,
1616
- buffer: useUint8Array,
1617
- arrayBuffer: useUint8Array,
1618
- dataView: useUint8ArrayWithOffset,
1619
- typedArray: useUint8ArrayWithOffset,
1620
- others: throwObjectStream
1621
- },
1622
- getSize: getLengthProp,
1623
- truncateChunk: truncateArrayBufferChunk,
1624
- addChunk: addArrayBufferChunk,
1625
- getFinalChunk: noop$1,
1626
- finalize: finalizeArrayBuffer
1627
- };
1628
- async function getStreamAsBuffer(stream, options2) {
1629
- if (!("Buffer" in globalThis)) {
1630
- throw new Error("getStreamAsBuffer() is only supported in Node.js");
1631
- }
1632
- try {
1633
- return arrayBufferToNodeBuffer(await getStreamAsArrayBuffer(stream, options2));
1634
- } catch (error) {
1635
- if (error.bufferedData !== void 0) {
1636
- error.bufferedData = arrayBufferToNodeBuffer(error.bufferedData);
1637
- }
1638
- throw error;
1639
- }
1640
- }
1641
- var arrayBufferToNodeBuffer = (arrayBuffer) => globalThis.Buffer.from(arrayBuffer);
1642
- async function getStreamAsString(stream, options2) {
1643
- return getStreamContents(stream, stringMethods, options2);
1644
- }
1645
- var initString = () => ({ contents: "", textDecoder: new TextDecoder() });
1646
- var useTextDecoder = (chunk, { textDecoder }) => textDecoder.decode(chunk, { stream: true });
1647
- var addStringChunk = (convertedChunk, { contents }) => contents + convertedChunk;
1648
- var truncateStringChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize);
1649
- var getFinalStringChunk = ({ textDecoder }) => {
1650
- const finalChunk = textDecoder.decode();
1651
- return finalChunk === "" ? void 0 : finalChunk;
1652
- };
1653
- var stringMethods = {
1654
- init: initString,
1655
- convertChunk: {
1656
- string: identity,
1657
- buffer: useTextDecoder,
1658
- arrayBuffer: useTextDecoder,
1659
- dataView: useTextDecoder,
1660
- typedArray: useTextDecoder,
1661
- others: throwObjectStream
1662
- },
1663
- getSize: getLengthProp,
1664
- truncateChunk: truncateStringChunk,
1665
- addChunk: addStringChunk,
1666
- getFinalChunk: getFinalStringChunk,
1667
- finalize: getContentsProp
1668
- };
1669
- var { PassThrough } = import_stream.default;
1670
- var mergeStream = function() {
1671
- var sources = [];
1672
- var output = new PassThrough({ objectMode: true });
1673
- output.setMaxListeners(0);
1674
- output.add = add;
1675
- output.isEmpty = isEmpty;
1676
- output.on("unpipe", remove2);
1677
- Array.prototype.slice.call(arguments).forEach(add);
1678
- return output;
1679
- function add(source) {
1680
- if (Array.isArray(source)) {
1681
- source.forEach(add);
1682
- return this;
1683
- }
1684
- sources.push(source);
1685
- source.once("end", remove2.bind(null, source));
1686
- source.once("error", output.emit.bind(output, "error"));
1687
- source.pipe(output, { end: false });
1688
- return this;
1689
- }
1690
- function isEmpty() {
1691
- return sources.length == 0;
1692
- }
1693
- function remove2(source) {
1694
- sources = sources.filter(function(it) {
1695
- return it !== source;
1696
- });
1697
- if (!sources.length && output.readable) {
1698
- output.end();
1699
- }
1700
- }
1701
- };
1702
- var mergeStream$1 = /* @__PURE__ */ getDefaultExportFromCjs(mergeStream);
1703
- var validateInputOptions = (input) => {
1704
- if (input !== void 0) {
1705
- throw new TypeError("The `input` and `inputFile` options cannot be both set.");
1706
- }
1707
- };
1708
- var getInput = ({ input, inputFile }) => {
1709
- if (typeof inputFile !== "string") {
1710
- return input;
1711
- }
1712
- validateInputOptions(input);
1713
- return (0, import_node_fs.createReadStream)(inputFile);
1714
- };
1715
- var handleInput = (spawned, options2) => {
1716
- const input = getInput(options2);
1717
- if (input === void 0) {
1718
- return;
1719
- }
1720
- if (isStream(input)) {
1721
- input.pipe(spawned.stdin);
1722
- } else {
1723
- spawned.stdin.end(input);
1724
- }
1725
- };
1726
- var makeAllStream = (spawned, { all }) => {
1727
- if (!all || !spawned.stdout && !spawned.stderr) {
1728
- return;
1729
- }
1730
- const mixed = mergeStream$1();
1731
- if (spawned.stdout) {
1732
- mixed.add(spawned.stdout);
1733
- }
1734
- if (spawned.stderr) {
1735
- mixed.add(spawned.stderr);
1736
- }
1737
- return mixed;
1738
- };
1739
- var getBufferedData = async (stream, streamPromise) => {
1740
- if (!stream || streamPromise === void 0) {
1741
- return;
1742
- }
1743
- await (0, import_promises.setTimeout)(0);
1744
- stream.destroy();
1745
- try {
1746
- return await streamPromise;
1747
- } catch (error) {
1748
- return error.bufferedData;
1749
- }
1750
- };
1751
- var getStreamPromise = (stream, { encoding, buffer, maxBuffer }) => {
1752
- if (!stream || !buffer) {
1753
- return;
1754
- }
1755
- if (encoding === "utf8" || encoding === "utf-8") {
1756
- return getStreamAsString(stream, { maxBuffer });
1757
- }
1758
- if (encoding === null || encoding === "buffer") {
1759
- return getStreamAsBuffer(stream, { maxBuffer });
1760
- }
1761
- return applyEncoding(stream, maxBuffer, encoding);
1762
- };
1763
- var applyEncoding = async (stream, maxBuffer, encoding) => {
1764
- const buffer = await getStreamAsBuffer(stream, { maxBuffer });
1765
- return buffer.toString(encoding);
1766
- };
1767
- var getSpawnedResult = async ({ stdout, stderr, all }, { encoding, buffer, maxBuffer }, processDone) => {
1768
- const stdoutPromise = getStreamPromise(stdout, { encoding, buffer, maxBuffer });
1769
- const stderrPromise = getStreamPromise(stderr, { encoding, buffer, maxBuffer });
1770
- const allPromise = getStreamPromise(all, { encoding, buffer, maxBuffer: maxBuffer * 2 });
1771
- try {
1772
- return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
1773
- } catch (error) {
1774
- return Promise.all([
1775
- { error, signal: error.signal, timedOut: error.timedOut },
1776
- getBufferedData(stdout, stdoutPromise),
1777
- getBufferedData(stderr, stderrPromise),
1778
- getBufferedData(all, allPromise)
1779
- ]);
1780
- }
1781
- };
1782
- var nativePromisePrototype = (async () => {
1783
- })().constructor.prototype;
1784
- var descriptors = ["then", "catch", "finally"].map((property) => [
1785
- property,
1786
- Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
1787
- ]);
1788
- var mergePromise = (spawned, promise) => {
1789
- for (const [property, descriptor] of descriptors) {
1790
- const value = typeof promise === "function" ? (...args) => Reflect.apply(descriptor.value, promise(), args) : descriptor.value.bind(promise);
1791
- Reflect.defineProperty(spawned, property, { ...descriptor, value });
1792
- }
1793
- };
1794
- var getSpawnedPromise = (spawned) => new Promise((resolve2, reject) => {
1795
- spawned.on("exit", (exitCode, signal) => {
1796
- resolve2({ exitCode, signal });
1797
- });
1798
- spawned.on("error", (error) => {
1799
- reject(error);
1800
- });
1801
- if (spawned.stdin) {
1802
- spawned.stdin.on("error", (error) => {
1803
- reject(error);
1804
- });
1805
- }
1806
- });
1807
- var normalizeArgs = (file, args = []) => {
1808
- if (!Array.isArray(args)) {
1809
- return [file];
1810
- }
1811
- return [file, ...args];
1812
- };
1813
- var NO_ESCAPE_REGEXP = /^[\w.-]+$/;
1814
- var escapeArg = (arg) => {
1815
- if (typeof arg !== "string" || NO_ESCAPE_REGEXP.test(arg)) {
1816
- return arg;
1817
- }
1818
- return `"${arg.replaceAll('"', '\\"')}"`;
1819
- };
1820
- var joinCommand = (file, args) => normalizeArgs(file, args).join(" ");
1821
- var getEscapedCommand = (file, args) => normalizeArgs(file, args).map((arg) => escapeArg(arg)).join(" ");
1822
- var SPACES_REGEXP = / +/g;
1823
- var parseCommand = (command) => {
1824
- const tokens = [];
1825
- for (const token of command.trim().split(SPACES_REGEXP)) {
1826
- const previousToken = tokens.at(-1);
1827
- if (previousToken && previousToken.endsWith("\\")) {
1828
- tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
1829
- } else {
1830
- tokens.push(token);
1831
- }
1832
- }
1833
- return tokens;
1834
- };
1835
- var verboseDefault = (0, import_node_util.debuglog)("execa").enabled;
1836
- var padField = (field, padding) => String(field).padStart(padding, "0");
1837
- var getTimestamp = () => {
1838
- const date2 = /* @__PURE__ */ new Date();
1839
- return `${padField(date2.getHours(), 2)}:${padField(date2.getMinutes(), 2)}:${padField(date2.getSeconds(), 2)}.${padField(date2.getMilliseconds(), 3)}`;
1840
- };
1841
- var logCommand = (escapedCommand, { verbose }) => {
1842
- if (!verbose) {
1843
- return;
1844
- }
1845
- import_node_process.default.stderr.write(`[${getTimestamp()}] ${escapedCommand}
1846
- `);
1847
- };
1848
- var DEFAULT_MAX_BUFFER = 1e3 * 1e3 * 100;
1849
- var getEnv = ({ env: envOption, extendEnv, preferLocal, localDir, execPath }) => {
1850
- const env2 = extendEnv ? { ...import_node_process.default.env, ...envOption } : envOption;
1851
- if (preferLocal) {
1852
- return npmRunPathEnv({ env: env2, cwd: localDir, execPath });
1853
- }
1854
- return env2;
1855
- };
1856
- var handleArguments = (file, args, options2 = {}) => {
1857
- const parsed = crossSpawn._parse(file, args, options2);
1858
- file = parsed.command;
1859
- args = parsed.args;
1860
- options2 = parsed.options;
1861
- options2 = {
1862
- maxBuffer: DEFAULT_MAX_BUFFER,
1863
- buffer: true,
1864
- stripFinalNewline: true,
1865
- extendEnv: true,
1866
- preferLocal: false,
1867
- localDir: options2.cwd || import_node_process.default.cwd(),
1868
- execPath: import_node_process.default.execPath,
1869
- encoding: "utf8",
1870
- reject: true,
1871
- cleanup: true,
1872
- all: false,
1873
- windowsHide: true,
1874
- verbose: verboseDefault,
1875
- ...options2
1876
- };
1877
- options2.env = getEnv(options2);
1878
- options2.stdio = normalizeStdio(options2);
1879
- if (import_node_process.default.platform === "win32" && import_node_path.default.basename(file, ".exe") === "cmd") {
1880
- args.unshift("/q");
1881
- }
1882
- return { file, args, options: options2, parsed };
1883
- };
1884
- var handleOutput = (options2, value, error) => {
1885
- if (typeof value !== "string" && !import_node_buffer.Buffer.isBuffer(value)) {
1886
- return error === void 0 ? void 0 : "";
1887
- }
1888
- if (options2.stripFinalNewline) {
1889
- return stripFinalNewline(value);
1890
- }
1891
- return value;
1892
- };
1893
- function execa(file, args, options2) {
1894
- const parsed = handleArguments(file, args, options2);
1895
- const command = joinCommand(file, args);
1896
- const escapedCommand = getEscapedCommand(file, args);
1897
- logCommand(escapedCommand, parsed.options);
1898
- validateTimeout(parsed.options);
1899
- let spawned;
1900
- try {
1901
- spawned = import_node_child_process.default.spawn(parsed.file, parsed.args, parsed.options);
1902
- } catch (error) {
1903
- const dummySpawned = new import_node_child_process.default.ChildProcess();
1904
- const errorPromise = Promise.reject(makeError({
1905
- error,
1906
- stdout: "",
1907
- stderr: "",
1908
- all: "",
1909
- command,
1910
- escapedCommand,
1911
- parsed,
1912
- timedOut: false,
1913
- isCanceled: false,
1914
- killed: false
1915
- }));
1916
- mergePromise(dummySpawned, errorPromise);
1917
- return dummySpawned;
1918
- }
1919
- const spawnedPromise = getSpawnedPromise(spawned);
1920
- const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
1921
- const processDone = setExitHandler(spawned, parsed.options, timedPromise);
1922
- const context = { isCanceled: false };
1923
- spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
1924
- spawned.cancel = spawnedCancel.bind(null, spawned, context);
1925
- const handlePromise = async () => {
1926
- const [{ error, exitCode, signal, timedOut }, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
1927
- const stdout = handleOutput(parsed.options, stdoutResult);
1928
- const stderr = handleOutput(parsed.options, stderrResult);
1929
- const all = handleOutput(parsed.options, allResult);
1930
- if (error || exitCode !== 0 || signal !== null) {
1931
- const returnedError = makeError({
1932
- error,
1933
- exitCode,
1934
- signal,
1935
- stdout,
1936
- stderr,
1937
- all,
1938
- command,
1939
- escapedCommand,
1940
- parsed,
1941
- timedOut,
1942
- isCanceled: parsed.options.signal ? parsed.options.signal.aborted : false,
1943
- killed: spawned.killed
1944
- });
1945
- if (!parsed.options.reject) {
1946
- return returnedError;
1947
- }
1948
- throw returnedError;
1949
- }
1950
- return {
1951
- command,
1952
- escapedCommand,
1953
- exitCode: 0,
1954
- stdout,
1955
- stderr,
1956
- all,
1957
- failed: false,
1958
- timedOut: false,
1959
- isCanceled: false,
1960
- killed: false
1961
- };
1962
- };
1963
- const handlePromiseOnce = onetime(handlePromise);
1964
- handleInput(spawned, parsed.options);
1965
- spawned.all = makeAllStream(spawned, parsed.options);
1966
- addPipeMethods(spawned);
1967
- mergePromise(spawned, handlePromiseOnce);
1968
- return spawned;
1969
- }
1970
- function execaCommand(command, options2) {
1971
- const [file, ...args] = parseCommand(command);
1972
- return execa(file, args, options2);
1973
- }
1974
- var Node = class {
1975
- value;
1976
- next;
1977
- constructor(value) {
1978
- this.value = value;
1979
- }
1980
- };
1981
- var Queue = class {
1982
- #head;
1983
- #tail;
1984
- #size;
1985
- constructor() {
1986
- this.clear();
1987
- }
1988
- enqueue(value) {
1989
- const node = new Node(value);
1990
- if (this.#head) {
1991
- this.#tail.next = node;
1992
- this.#tail = node;
1993
- } else {
1994
- this.#head = node;
1995
- this.#tail = node;
1996
- }
1997
- this.#size++;
1998
- }
1999
- dequeue() {
2000
- const current = this.#head;
2001
- if (!current) {
2002
- return;
2003
- }
2004
- this.#head = this.#head.next;
2005
- this.#size--;
2006
- return current.value;
2007
- }
2008
- clear() {
2009
- this.#head = void 0;
2010
- this.#tail = void 0;
2011
- this.#size = 0;
2012
- }
2013
- get size() {
2014
- return this.#size;
2015
- }
2016
- *[Symbol.iterator]() {
2017
- let current = this.#head;
2018
- while (current) {
2019
- yield current.value;
2020
- current = current.next;
2021
- }
2022
- }
2023
- };
2024
- function pLimit(concurrency) {
2025
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
2026
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
2027
- }
2028
- const queue = new Queue();
2029
- let activeCount = 0;
2030
- const next = () => {
2031
- activeCount--;
2032
- if (queue.size > 0) {
2033
- queue.dequeue()();
2034
- }
2035
- };
2036
- const run2 = async (fn, resolve2, args) => {
2037
- activeCount++;
2038
- const result = (async () => fn(...args))();
2039
- resolve2(result);
2040
- try {
2041
- await result;
2042
- } catch {
2043
- }
2044
- next();
2045
- };
2046
- const enqueue = (fn, resolve2, args) => {
2047
- queue.enqueue(run2.bind(void 0, fn, resolve2, args));
2048
- (async () => {
2049
- await Promise.resolve();
2050
- if (activeCount < concurrency && queue.size > 0) {
2051
- queue.dequeue()();
2052
- }
2053
- })();
2054
- };
2055
- const generator = (fn, ...args) => new Promise((resolve2) => {
2056
- enqueue(fn, resolve2, args);
2057
- });
2058
- Object.defineProperties(generator, {
2059
- activeCount: {
2060
- get: () => activeCount
2061
- },
2062
- pendingCount: {
2063
- get: () => queue.size
2064
- },
2065
- clearQueue: {
2066
- value: () => {
2067
- queue.clear();
2068
- }
2069
- }
2070
- });
2071
- return generator;
2072
- }
2073
- var EndError = class extends Error {
2074
- constructor(value) {
2075
- super();
2076
- this.value = value;
2077
- }
2078
- };
2079
- var testElement = async (element, tester) => tester(await element);
2080
- var finder = async (element) => {
2081
- const values = await Promise.all(element);
2082
- if (values[1] === true) {
2083
- throw new EndError(values[0]);
2084
- }
2085
- return false;
2086
- };
2087
- async function pLocate(iterable, tester, {
2088
- concurrency = Number.POSITIVE_INFINITY,
2089
- preserveOrder = true
2090
- } = {}) {
2091
- const limit = pLimit(concurrency);
2092
- const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
2093
- const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
2094
- try {
2095
- await Promise.all(items.map((element) => checkLimit(finder, element)));
2096
- } catch (error) {
2097
- if (error instanceof EndError) {
2098
- return error.value;
2099
- }
2100
- throw error;
2101
- }
2102
- }
2103
- var typeMappings = {
2104
- directory: "isDirectory",
2105
- file: "isFile"
2106
- };
2107
- function checkType(type) {
2108
- if (Object.hasOwnProperty.call(typeMappings, type)) {
2109
- return;
2110
- }
2111
- throw new Error(`Invalid type specified: ${type}`);
2112
- }
2113
- var matchType = (type, stat) => stat[typeMappings[type]]();
2114
- var toPath$1 = (urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url.fileURLToPath)(urlOrPath) : urlOrPath;
2115
- async function locatePath(paths, {
2116
- cwd = import_node_process.default.cwd(),
2117
- type = "file",
2118
- allowSymlinks = true,
2119
- concurrency,
2120
- preserveOrder
2121
- } = {}) {
2122
- checkType(type);
2123
- cwd = toPath$1(cwd);
2124
- const statFunction = allowSymlinks ? import_node_fs.promises.stat : import_node_fs.promises.lstat;
2125
- return pLocate(paths, async (path_) => {
2126
- try {
2127
- const stat = await statFunction(import_node_path.default.resolve(cwd, path_));
2128
- return matchType(type, stat);
2129
- } catch {
2130
- return false;
2131
- }
2132
- }, { concurrency, preserveOrder });
2133
- }
2134
- var toPath = (urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url.fileURLToPath)(urlOrPath) : urlOrPath;
2135
- var findUpStop = Symbol("findUpStop");
2136
- async function findUpMultiple(name, options2 = {}) {
2137
- let directory = import_node_path.default.resolve(toPath(options2.cwd) || "");
2138
- const { root } = import_node_path.default.parse(directory);
2139
- const stopAt = import_node_path.default.resolve(directory, options2.stopAt || root);
2140
- const limit = options2.limit || Number.POSITIVE_INFINITY;
2141
- const paths = [name].flat();
2142
- const runMatcher = async (locateOptions) => {
2143
- if (typeof name !== "function") {
2144
- return locatePath(paths, locateOptions);
2145
- }
2146
- const foundPath = await name(locateOptions.cwd);
2147
- if (typeof foundPath === "string") {
2148
- return locatePath([foundPath], locateOptions);
2149
- }
2150
- return foundPath;
2151
- };
2152
- const matches = [];
2153
- while (true) {
2154
- const foundPath = await runMatcher({ ...options2, cwd: directory });
2155
- if (foundPath === findUpStop) {
2156
- break;
2157
- }
2158
- if (foundPath) {
2159
- matches.push(import_node_path.default.resolve(directory, foundPath));
2160
- }
2161
- if (directory === stopAt || matches.length >= limit) {
2162
- break;
2163
- }
2164
- directory = import_node_path.default.dirname(directory);
2165
- }
2166
- return matches;
2167
- }
2168
- async function findUp(name, options2 = {}) {
2169
- const matches = await findUpMultiple(name, { ...options2, limit: 1 });
2170
- return matches[0];
2171
- }
2172
- var ESC$1 = "\x1B[";
2173
- var OSC = "\x1B]";
2174
- var BEL = "\x07";
2175
- var SEP = ";";
2176
- var isTerminalApp = process.env.TERM_PROGRAM === "Apple_Terminal";
2177
- var ansiEscapes = {};
2178
- ansiEscapes.cursorTo = (x, y) => {
2179
- if (typeof x !== "number") {
2180
- throw new TypeError("The `x` argument is required");
2181
- }
2182
- if (typeof y !== "number") {
2183
- return ESC$1 + (x + 1) + "G";
2184
- }
2185
- return ESC$1 + (y + 1) + ";" + (x + 1) + "H";
2186
- };
2187
- ansiEscapes.cursorMove = (x, y) => {
2188
- if (typeof x !== "number") {
2189
- throw new TypeError("The `x` argument is required");
2190
- }
2191
- let returnValue = "";
2192
- if (x < 0) {
2193
- returnValue += ESC$1 + -x + "D";
2194
- } else if (x > 0) {
2195
- returnValue += ESC$1 + x + "C";
2196
- }
2197
- if (y < 0) {
2198
- returnValue += ESC$1 + -y + "A";
2199
- } else if (y > 0) {
2200
- returnValue += ESC$1 + y + "B";
2201
- }
2202
- return returnValue;
2203
- };
2204
- ansiEscapes.cursorUp = (count = 1) => ESC$1 + count + "A";
2205
- ansiEscapes.cursorDown = (count = 1) => ESC$1 + count + "B";
2206
- ansiEscapes.cursorForward = (count = 1) => ESC$1 + count + "C";
2207
- ansiEscapes.cursorBackward = (count = 1) => ESC$1 + count + "D";
2208
- ansiEscapes.cursorLeft = ESC$1 + "G";
2209
- ansiEscapes.cursorSavePosition = isTerminalApp ? "\x1B7" : ESC$1 + "s";
2210
- ansiEscapes.cursorRestorePosition = isTerminalApp ? "\x1B8" : ESC$1 + "u";
2211
- ansiEscapes.cursorGetPosition = ESC$1 + "6n";
2212
- ansiEscapes.cursorNextLine = ESC$1 + "E";
2213
- ansiEscapes.cursorPrevLine = ESC$1 + "F";
2214
- ansiEscapes.cursorHide = ESC$1 + "?25l";
2215
- ansiEscapes.cursorShow = ESC$1 + "?25h";
2216
- ansiEscapes.eraseLines = (count) => {
2217
- let clear2 = "";
2218
- for (let i = 0; i < count; i++) {
2219
- clear2 += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : "");
2220
- }
2221
- if (count) {
2222
- clear2 += ansiEscapes.cursorLeft;
2223
- }
2224
- return clear2;
2225
- };
2226
- ansiEscapes.eraseEndLine = ESC$1 + "K";
2227
- ansiEscapes.eraseStartLine = ESC$1 + "1K";
2228
- ansiEscapes.eraseLine = ESC$1 + "2K";
2229
- ansiEscapes.eraseDown = ESC$1 + "J";
2230
- ansiEscapes.eraseUp = ESC$1 + "1J";
2231
- ansiEscapes.eraseScreen = ESC$1 + "2J";
2232
- ansiEscapes.scrollUp = ESC$1 + "S";
2233
- ansiEscapes.scrollDown = ESC$1 + "T";
2234
- ansiEscapes.clearScreen = "\x1Bc";
2235
- ansiEscapes.clearTerminal = process.platform === "win32" ? `${ansiEscapes.eraseScreen}${ESC$1}0f` : (
2236
- // 1. Erases the screen (Only done in case `2` is not supported)
2237
- // 2. Erases the whole screen including scrollback buffer
2238
- // 3. Moves cursor to the top-left position
2239
- // More info: https://www.real-world-systems.com/docs/ANSIcode.html
2240
- `${ansiEscapes.eraseScreen}${ESC$1}3J${ESC$1}H`
2241
- );
2242
- ansiEscapes.beep = BEL;
2243
- ansiEscapes.link = (text2, url2) => {
2244
- return [
2245
- OSC,
2246
- "8",
2247
- SEP,
2248
- SEP,
2249
- url2,
2250
- BEL,
2251
- text2,
2252
- OSC,
2253
- "8",
2254
- SEP,
2255
- SEP,
2256
- BEL
2257
- ].join("");
2258
- };
2259
- ansiEscapes.image = (buffer, options2 = {}) => {
2260
- let returnValue = `${OSC}1337;File=inline=1`;
2261
- if (options2.width) {
2262
- returnValue += `;width=${options2.width}`;
2263
- }
2264
- if (options2.height) {
2265
- returnValue += `;height=${options2.height}`;
2266
- }
2267
- if (options2.preserveAspectRatio === false) {
2268
- returnValue += ";preserveAspectRatio=0";
2269
- }
2270
- return returnValue + ":" + buffer.toString("base64") + BEL;
2271
- };
2272
- ansiEscapes.iTerm = {
2273
- setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
2274
- annotation: (message, options2 = {}) => {
2275
- let returnValue = `${OSC}1337;`;
2276
- const hasX = typeof options2.x !== "undefined";
2277
- const hasY = typeof options2.y !== "undefined";
2278
- if ((hasX || hasY) && !(hasX && hasY && typeof options2.length !== "undefined")) {
2279
- throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");
2280
- }
2281
- message = message.replace(/\|/g, "");
2282
- returnValue += options2.isHidden ? "AddHiddenAnnotation=" : "AddAnnotation=";
2283
- if (options2.length > 0) {
2284
- returnValue += (hasX ? [message, options2.length, options2.x, options2.y] : [options2.length, message]).join("|");
2285
- } else {
2286
- returnValue += message;
2287
- }
2288
- return returnValue + BEL;
2289
- }
2290
- };
2291
- var hasFlag$2 = (flag, argv = process.argv) => {
2292
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
2293
- const position = argv.indexOf(prefix + flag);
2294
- const terminatorPosition = argv.indexOf("--");
2295
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
2296
- };
2297
- var os = import_os.default;
2298
- var tty = import_tty.default;
2299
- var hasFlag$1 = hasFlag$2;
2300
- var { env } = process;
2301
- var forceColor;
2302
- if (hasFlag$1("no-color") || hasFlag$1("no-colors") || hasFlag$1("color=false") || hasFlag$1("color=never")) {
2303
- forceColor = 0;
2304
- } else if (hasFlag$1("color") || hasFlag$1("colors") || hasFlag$1("color=true") || hasFlag$1("color=always")) {
2305
- forceColor = 1;
2306
- }
2307
- if ("FORCE_COLOR" in env) {
2308
- if (env.FORCE_COLOR === "true") {
2309
- forceColor = 1;
2310
- } else if (env.FORCE_COLOR === "false") {
2311
- forceColor = 0;
2312
- } else {
2313
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
2314
- }
2315
- }
2316
- function translateLevel(level) {
2317
- if (level === 0) {
2318
- return false;
2319
- }
2320
- return {
2321
- level,
2322
- hasBasic: true,
2323
- has256: level >= 2,
2324
- has16m: level >= 3
2325
- };
2326
- }
2327
- function supportsColor$1(haveStream, streamIsTTY) {
2328
- if (forceColor === 0) {
2329
- return 0;
2330
- }
2331
- if (hasFlag$1("color=16m") || hasFlag$1("color=full") || hasFlag$1("color=truecolor")) {
2332
- return 3;
2333
- }
2334
- if (hasFlag$1("color=256")) {
2335
- return 2;
2336
- }
2337
- if (haveStream && !streamIsTTY && forceColor === void 0) {
2338
- return 0;
2339
- }
2340
- const min = forceColor || 0;
2341
- if (env.TERM === "dumb") {
2342
- return min;
2343
- }
2344
- if (process.platform === "win32") {
2345
- const osRelease = os.release().split(".");
2346
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
2347
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
2348
- }
2349
- return 1;
2350
- }
2351
- if ("CI" in env) {
2352
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
2353
- return 1;
2354
- }
2355
- return min;
2356
- }
2357
- if ("TEAMCITY_VERSION" in env) {
2358
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
2359
- }
2360
- if (env.COLORTERM === "truecolor") {
2361
- return 3;
2362
- }
2363
- if ("TERM_PROGRAM" in env) {
2364
- const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
2365
- switch (env.TERM_PROGRAM) {
2366
- case "iTerm.app":
2367
- return version >= 3 ? 3 : 2;
2368
- case "Apple_Terminal":
2369
- return 2;
2370
- }
2371
- }
2372
- if (/-256(color)?$/i.test(env.TERM)) {
2373
- return 2;
2374
- }
2375
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
2376
- return 1;
2377
- }
2378
- if ("COLORTERM" in env) {
2379
- return 1;
2380
- }
2381
- return min;
2382
- }
2383
- function getSupportLevel(stream) {
2384
- const level = supportsColor$1(stream, stream && stream.isTTY);
2385
- return translateLevel(level);
2386
- }
2387
- var supportsColor_1 = {
2388
- supportsColor: getSupportLevel,
2389
- stdout: translateLevel(supportsColor$1(true, tty.isatty(1))),
2390
- stderr: translateLevel(supportsColor$1(true, tty.isatty(2)))
2391
- };
2392
- var supportsColor = supportsColor_1;
2393
- var hasFlag = hasFlag$2;
2394
- function parseVersion(versionString) {
2395
- if (/^\d{3,4}$/.test(versionString)) {
2396
- const m = /(\d{1,2})(\d{2})/.exec(versionString);
2397
- return {
2398
- major: 0,
2399
- minor: parseInt(m[1], 10),
2400
- patch: parseInt(m[2], 10)
2401
- };
2402
- }
2403
- const versions = (versionString || "").split(".").map((n) => parseInt(n, 10));
2404
- return {
2405
- major: versions[0],
2406
- minor: versions[1],
2407
- patch: versions[2]
2408
- };
2409
- }
2410
- function supportsHyperlink(stream) {
2411
- const { env: env2 } = process;
2412
- if ("FORCE_HYPERLINK" in env2) {
2413
- return !(env2.FORCE_HYPERLINK.length > 0 && parseInt(env2.FORCE_HYPERLINK, 10) === 0);
2414
- }
2415
- if (hasFlag("no-hyperlink") || hasFlag("no-hyperlinks") || hasFlag("hyperlink=false") || hasFlag("hyperlink=never")) {
2416
- return false;
2417
- }
2418
- if (hasFlag("hyperlink=true") || hasFlag("hyperlink=always")) {
2419
- return true;
2420
- }
2421
- if (!supportsColor.supportsColor(stream)) {
2422
- return false;
2423
- }
2424
- if (stream && !stream.isTTY) {
2425
- return false;
2426
- }
2427
- if (process.platform === "win32") {
2428
- return false;
2429
- }
2430
- if ("NETLIFY" in env2) {
2431
- return true;
2432
- }
2433
- if ("CI" in env2) {
2434
- return false;
2435
- }
2436
- if ("TEAMCITY_VERSION" in env2) {
2437
- return false;
2438
- }
2439
- if ("TERM_PROGRAM" in env2) {
2440
- const version = parseVersion(env2.TERM_PROGRAM_VERSION);
2441
- switch (env2.TERM_PROGRAM) {
2442
- case "iTerm.app":
2443
- if (version.major === 3) {
2444
- return version.minor >= 1;
2445
- }
2446
- return version.major > 3;
2447
- }
2448
- }
2449
- if ("VTE_VERSION" in env2) {
2450
- if (env2.VTE_VERSION === "0.50.0") {
2451
- return false;
2452
- }
2453
- const version = parseVersion(env2.VTE_VERSION);
2454
- return version.major > 0 || version.minor >= 50;
2455
- }
2456
- return false;
2457
- }
2458
- var supportsHyperlinks = {
2459
- supportsHyperlink,
2460
- stdout: supportsHyperlink(process.stdout),
2461
- stderr: supportsHyperlink(process.stderr)
2462
- };
2463
- var supportsHyperlinks$1 = /* @__PURE__ */ getDefaultExportFromCjs(supportsHyperlinks);
2464
- function terminalLink(text2, url2, { target = "stdout", ...options2 } = {}) {
2465
- if (!supportsHyperlinks$1[target]) {
2466
- if (options2.fallback === false) {
2467
- return text2;
2468
- }
2469
- return typeof options2.fallback === "function" ? options2.fallback(text2, url2) : `${text2} (\u200B${url2}\u200B)`;
2470
- }
2471
- return ansiEscapes.link(text2, url2);
2472
- }
2473
- terminalLink.isSupported = supportsHyperlinks$1.stdout;
2474
- terminalLink.stderr = (text2, url2, options2 = {}) => terminalLink(text2, url2, { target: "stderr", ...options2 });
2475
- terminalLink.stderr.isSupported = supportsHyperlinks$1.stderr;
2476
- var prompts$3 = {};
2477
- var FORCE_COLOR$1;
2478
- var NODE_DISABLE_COLORS$1;
2479
- var NO_COLOR$1;
2480
- var TERM$1;
2481
- var isTTY$1 = true;
2482
- if (typeof process !== "undefined") {
2483
- ({ FORCE_COLOR: FORCE_COLOR$1, NODE_DISABLE_COLORS: NODE_DISABLE_COLORS$1, NO_COLOR: NO_COLOR$1, TERM: TERM$1 } = process.env || {});
2484
- isTTY$1 = process.stdout && process.stdout.isTTY;
2485
- }
2486
- var $$1 = {
2487
- enabled: !NODE_DISABLE_COLORS$1 && NO_COLOR$1 == null && TERM$1 !== "dumb" && (FORCE_COLOR$1 != null && FORCE_COLOR$1 !== "0" || isTTY$1),
2488
- // modifiers
2489
- reset: init$1(0, 0),
2490
- bold: init$1(1, 22),
2491
- dim: init$1(2, 22),
2492
- italic: init$1(3, 23),
2493
- underline: init$1(4, 24),
2494
- inverse: init$1(7, 27),
2495
- hidden: init$1(8, 28),
2496
- strikethrough: init$1(9, 29),
2497
- // colors
2498
- black: init$1(30, 39),
2499
- red: init$1(31, 39),
2500
- green: init$1(32, 39),
2501
- yellow: init$1(33, 39),
2502
- blue: init$1(34, 39),
2503
- magenta: init$1(35, 39),
2504
- cyan: init$1(36, 39),
2505
- white: init$1(37, 39),
2506
- gray: init$1(90, 39),
2507
- grey: init$1(90, 39),
2508
- // background colors
2509
- bgBlack: init$1(40, 49),
2510
- bgRed: init$1(41, 49),
2511
- bgGreen: init$1(42, 49),
2512
- bgYellow: init$1(43, 49),
2513
- bgBlue: init$1(44, 49),
2514
- bgMagenta: init$1(45, 49),
2515
- bgCyan: init$1(46, 49),
2516
- bgWhite: init$1(47, 49)
2517
- };
2518
- function run$2(arr, str) {
2519
- let i = 0, tmp, beg = "", end = "";
2520
- for (; i < arr.length; i++) {
2521
- tmp = arr[i];
2522
- beg += tmp.open;
2523
- end += tmp.close;
2524
- if (!!~str.indexOf(tmp.close)) {
2525
- str = str.replace(tmp.rgx, tmp.close + tmp.open);
2526
- }
2527
- }
2528
- return beg + str + end;
2529
- }
2530
- function chain$1(has, keys) {
2531
- let ctx = { has, keys };
2532
- ctx.reset = $$1.reset.bind(ctx);
2533
- ctx.bold = $$1.bold.bind(ctx);
2534
- ctx.dim = $$1.dim.bind(ctx);
2535
- ctx.italic = $$1.italic.bind(ctx);
2536
- ctx.underline = $$1.underline.bind(ctx);
2537
- ctx.inverse = $$1.inverse.bind(ctx);
2538
- ctx.hidden = $$1.hidden.bind(ctx);
2539
- ctx.strikethrough = $$1.strikethrough.bind(ctx);
2540
- ctx.black = $$1.black.bind(ctx);
2541
- ctx.red = $$1.red.bind(ctx);
2542
- ctx.green = $$1.green.bind(ctx);
2543
- ctx.yellow = $$1.yellow.bind(ctx);
2544
- ctx.blue = $$1.blue.bind(ctx);
2545
- ctx.magenta = $$1.magenta.bind(ctx);
2546
- ctx.cyan = $$1.cyan.bind(ctx);
2547
- ctx.white = $$1.white.bind(ctx);
2548
- ctx.gray = $$1.gray.bind(ctx);
2549
- ctx.grey = $$1.grey.bind(ctx);
2550
- ctx.bgBlack = $$1.bgBlack.bind(ctx);
2551
- ctx.bgRed = $$1.bgRed.bind(ctx);
2552
- ctx.bgGreen = $$1.bgGreen.bind(ctx);
2553
- ctx.bgYellow = $$1.bgYellow.bind(ctx);
2554
- ctx.bgBlue = $$1.bgBlue.bind(ctx);
2555
- ctx.bgMagenta = $$1.bgMagenta.bind(ctx);
2556
- ctx.bgCyan = $$1.bgCyan.bind(ctx);
2557
- ctx.bgWhite = $$1.bgWhite.bind(ctx);
2558
- return ctx;
2559
- }
2560
- function init$1(open, close) {
2561
- let blk = {
2562
- open: `\x1B[${open}m`,
2563
- close: `\x1B[${close}m`,
2564
- rgx: new RegExp(`\\x1b\\[${close}m`, "g")
2565
- };
2566
- return function(txt) {
2567
- if (this !== void 0 && this.has !== void 0) {
2568
- !!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
2569
- return txt === void 0 ? this : $$1.enabled ? run$2(this.keys, txt + "") : txt + "";
2570
- }
2571
- return txt === void 0 ? chain$1([open], [blk]) : $$1.enabled ? run$2([blk], txt + "") : txt + "";
2572
- };
2573
- }
2574
- var kleur = $$1;
2575
- var action$1 = (key, isSelect) => {
2576
- if (key.meta && key.name !== "escape") return;
2577
- if (key.ctrl) {
2578
- if (key.name === "a") return "first";
2579
- if (key.name === "c") return "abort";
2580
- if (key.name === "d") return "abort";
2581
- if (key.name === "e") return "last";
2582
- if (key.name === "g") return "reset";
2583
- if (key.name === "n") return "down";
2584
- if (key.name === "p") return "up";
2585
- return;
2586
- }
2587
- if (isSelect) {
2588
- if (key.name === "j") return "down";
2589
- if (key.name === "k") return "up";
2590
- }
2591
- if (key.name === "return") return "submit";
2592
- if (key.name === "enter") return "submit";
2593
- if (key.name === "backspace") return "delete";
2594
- if (key.name === "delete") return "deleteForward";
2595
- if (key.name === "abort") return "abort";
2596
- if (key.name === "escape") return "exit";
2597
- if (key.name === "tab") return "next";
2598
- if (key.name === "pagedown") return "nextPage";
2599
- if (key.name === "pageup") return "prevPage";
2600
- if (key.name === "home") return "home";
2601
- if (key.name === "end") return "end";
2602
- if (key.name === "up") return "up";
2603
- if (key.name === "down") return "down";
2604
- if (key.name === "right") return "right";
2605
- if (key.name === "left") return "left";
2606
- return false;
2607
- };
2608
- var strip$2 = (str) => {
2609
- const pattern = [
2610
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
2611
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
2612
- ].join("|");
2613
- const RGX = new RegExp(pattern, "g");
2614
- return typeof str === "string" ? str.replace(RGX, "") : str;
2615
- };
2616
- var ESC = "\x1B";
2617
- var CSI = `${ESC}[`;
2618
- var beep$1 = "\x07";
2619
- var cursor$b = {
2620
- to(x, y) {
2621
- if (!y) return `${CSI}${x + 1}G`;
2622
- return `${CSI}${y + 1};${x + 1}H`;
2623
- },
2624
- move(x, y) {
2625
- let ret = "";
2626
- if (x < 0) ret += `${CSI}${-x}D`;
2627
- else if (x > 0) ret += `${CSI}${x}C`;
2628
- if (y < 0) ret += `${CSI}${-y}A`;
2629
- else if (y > 0) ret += `${CSI}${y}B`;
2630
- return ret;
2631
- },
2632
- up: (count = 1) => `${CSI}${count}A`,
2633
- down: (count = 1) => `${CSI}${count}B`,
2634
- forward: (count = 1) => `${CSI}${count}C`,
2635
- backward: (count = 1) => `${CSI}${count}D`,
2636
- nextLine: (count = 1) => `${CSI}E`.repeat(count),
2637
- prevLine: (count = 1) => `${CSI}F`.repeat(count),
2638
- left: `${CSI}G`,
2639
- hide: `${CSI}?25l`,
2640
- show: `${CSI}?25h`,
2641
- save: `${ESC}7`,
2642
- restore: `${ESC}8`
2643
- };
2644
- var scroll = {
2645
- up: (count = 1) => `${CSI}S`.repeat(count),
2646
- down: (count = 1) => `${CSI}T`.repeat(count)
2647
- };
2648
- var erase$7 = {
2649
- screen: `${CSI}2J`,
2650
- up: (count = 1) => `${CSI}1J`.repeat(count),
2651
- down: (count = 1) => `${CSI}J`.repeat(count),
2652
- line: `${CSI}2K`,
2653
- lineEnd: `${CSI}K`,
2654
- lineStart: `${CSI}1K`,
2655
- lines(count) {
2656
- let clear2 = "";
2657
- for (let i = 0; i < count; i++)
2658
- clear2 += this.line + (i < count - 1 ? cursor$b.up() : "");
2659
- if (count)
2660
- clear2 += cursor$b.left;
2661
- return clear2;
2662
- }
2663
- };
2664
- var src = { cursor: cursor$b, scroll, erase: erase$7, beep: beep$1 };
2665
- var strip$1 = strip$2;
2666
- var { erase: erase$6, cursor: cursor$a } = src;
2667
- var width = (str) => [...strip$1(str)].length;
2668
- var clear$9 = function(prompt2, perLine) {
2669
- if (!perLine) return erase$6.line + cursor$a.to(0);
2670
- let rows = 0;
2671
- const lines2 = prompt2.split(/\r?\n/);
2672
- for (let line of lines2) {
2673
- rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine);
2674
- }
2675
- return erase$6.lines(rows);
2676
- };
2677
- var main = {
2678
- arrowUp: "\u2191",
2679
- arrowDown: "\u2193",
2680
- arrowLeft: "\u2190",
2681
- arrowRight: "\u2192",
2682
- radioOn: "\u25C9",
2683
- radioOff: "\u25EF",
2684
- tick: "\u2714",
2685
- cross: "\u2716",
2686
- ellipsis: "\u2026",
2687
- pointerSmall: "\u203A",
2688
- line: "\u2500",
2689
- pointer: "\u276F"
2690
- };
2691
- var win = {
2692
- arrowUp: main.arrowUp,
2693
- arrowDown: main.arrowDown,
2694
- arrowLeft: main.arrowLeft,
2695
- arrowRight: main.arrowRight,
2696
- radioOn: "(*)",
2697
- radioOff: "( )",
2698
- tick: "\u221A",
2699
- cross: "\xD7",
2700
- ellipsis: "...",
2701
- pointerSmall: "\xBB",
2702
- line: "\u2500",
2703
- pointer: ">"
2704
- };
2705
- var figures$8 = process.platform === "win32" ? win : main;
2706
- var figures_1 = figures$8;
2707
- var c = kleur;
2708
- var figures$7 = figures_1;
2709
- var styles = Object.freeze({
2710
- password: { scale: 1, render: (input) => "*".repeat(input.length) },
2711
- emoji: { scale: 2, render: (input) => "\u{1F603}".repeat(input.length) },
2712
- invisible: { scale: 0, render: (input) => "" },
2713
- default: { scale: 1, render: (input) => `${input}` }
2714
- });
2715
- var render = (type) => styles[type] || styles.default;
2716
- var symbols = Object.freeze({
2717
- aborted: c.red(figures$7.cross),
2718
- done: c.green(figures$7.tick),
2719
- exited: c.yellow(figures$7.cross),
2720
- default: c.cyan("?")
2721
- });
2722
- var symbol = (done, aborted, exited) => aborted ? symbols.aborted : exited ? symbols.exited : done ? symbols.done : symbols.default;
2723
- var delimiter$1 = (completing) => c.gray(completing ? figures$7.ellipsis : figures$7.pointerSmall);
2724
- var item = (expandable, expanded) => c.gray(expandable ? expanded ? figures$7.pointerSmall : "+" : figures$7.line);
2725
- var style$9 = {
2726
- styles,
2727
- render,
2728
- symbols,
2729
- symbol,
2730
- delimiter: delimiter$1,
2731
- item
2732
- };
2733
- var strip = strip$2;
2734
- var lines$2 = function(msg, perLine) {
2735
- let lines2 = String(strip(msg) || "").split(/\r?\n/);
2736
- if (!perLine) return lines2.length;
2737
- return lines2.map((l) => Math.ceil(l.length / perLine)).reduce((a, b) => a + b);
2738
- };
2739
- var wrap$3 = (msg, opts = {}) => {
2740
- const tab = Number.isSafeInteger(parseInt(opts.margin)) ? new Array(parseInt(opts.margin)).fill(" ").join("") : opts.margin || "";
2741
- const width2 = opts.width;
2742
- return (msg || "").split(/\r?\n/g).map((line) => line.split(/\s+/g).reduce((arr, w) => {
2743
- if (w.length + tab.length >= width2 || arr[arr.length - 1].length + w.length + 1 < width2)
2744
- arr[arr.length - 1] += ` ${w}`;
2745
- else arr.push(`${tab}${w}`);
2746
- return arr;
2747
- }, [tab]).join("\n")).join("\n");
2748
- };
2749
- var entriesToDisplay$3 = (cursor2, total, maxVisible) => {
2750
- maxVisible = maxVisible || total;
2751
- let startIndex = Math.min(total - maxVisible, cursor2 - Math.floor(maxVisible / 2));
2752
- if (startIndex < 0) startIndex = 0;
2753
- let endIndex = Math.min(startIndex + maxVisible, total);
2754
- return { startIndex, endIndex };
2755
- };
2756
- var util = {
2757
- action: action$1,
2758
- clear: clear$9,
2759
- style: style$9,
2760
- strip: strip$2,
2761
- figures: figures_1,
2762
- lines: lines$2,
2763
- wrap: wrap$3,
2764
- entriesToDisplay: entriesToDisplay$3
2765
- };
2766
- var readline = import_readline.default;
2767
- var { action } = util;
2768
- var EventEmitter = import_events.default;
2769
- var { beep, cursor: cursor$9 } = src;
2770
- var color$9 = kleur;
2771
- var Prompt$8 = class Prompt extends EventEmitter {
2772
- constructor(opts = {}) {
2773
- super();
2774
- this.firstRender = true;
2775
- this.in = opts.stdin || process.stdin;
2776
- this.out = opts.stdout || process.stdout;
2777
- this.onRender = (opts.onRender || (() => void 0)).bind(this);
2778
- const rl = readline.createInterface({ input: this.in, escapeCodeTimeout: 50 });
2779
- readline.emitKeypressEvents(this.in, rl);
2780
- if (this.in.isTTY) this.in.setRawMode(true);
2781
- const isSelect = ["SelectPrompt", "MultiselectPrompt"].indexOf(this.constructor.name) > -1;
2782
- const keypress = (str, key) => {
2783
- let a = action(key, isSelect);
2784
- if (a === false) {
2785
- this._ && this._(str, key);
2786
- } else if (typeof this[a] === "function") {
2787
- this[a](key);
2788
- } else {
2789
- this.bell();
2790
- }
2791
- };
2792
- this.close = () => {
2793
- this.out.write(cursor$9.show);
2794
- this.in.removeListener("keypress", keypress);
2795
- if (this.in.isTTY) this.in.setRawMode(false);
2796
- rl.close();
2797
- this.emit(this.aborted ? "abort" : this.exited ? "exit" : "submit", this.value);
2798
- this.closed = true;
2799
- };
2800
- this.in.on("keypress", keypress);
2801
- }
2802
- fire() {
2803
- this.emit("state", {
2804
- value: this.value,
2805
- aborted: !!this.aborted,
2806
- exited: !!this.exited
2807
- });
2808
- }
2809
- bell() {
2810
- this.out.write(beep);
2811
- }
2812
- render() {
2813
- this.onRender(color$9);
2814
- if (this.firstRender) this.firstRender = false;
2815
- }
2816
- };
2817
- var prompt$1 = Prompt$8;
2818
- var color$8 = kleur;
2819
- var Prompt$7 = prompt$1;
2820
- var { erase: erase$5, cursor: cursor$8 } = src;
2821
- var { style: style$8, clear: clear$8, lines: lines$1, figures: figures$6 } = util;
2822
- var TextPrompt = class extends Prompt$7 {
2823
- constructor(opts = {}) {
2824
- super(opts);
2825
- this.transform = style$8.render(opts.style);
2826
- this.scale = this.transform.scale;
2827
- this.msg = opts.message;
2828
- this.initial = opts.initial || ``;
2829
- this.validator = opts.validate || (() => true);
2830
- this.value = ``;
2831
- this.errorMsg = opts.error || `Please Enter A Valid Value`;
2832
- this.cursor = Number(!!this.initial);
2833
- this.cursorOffset = 0;
2834
- this.clear = clear$8(``, this.out.columns);
2835
- this.render();
2836
- }
2837
- set value(v) {
2838
- if (!v && this.initial) {
2839
- this.placeholder = true;
2840
- this.rendered = color$8.gray(this.transform.render(this.initial));
2841
- } else {
2842
- this.placeholder = false;
2843
- this.rendered = this.transform.render(v);
2844
- }
2845
- this._value = v;
2846
- this.fire();
2847
- }
2848
- get value() {
2849
- return this._value;
2850
- }
2851
- reset() {
2852
- this.value = ``;
2853
- this.cursor = Number(!!this.initial);
2854
- this.cursorOffset = 0;
2855
- this.fire();
2856
- this.render();
2857
- }
2858
- exit() {
2859
- this.abort();
2860
- }
2861
- abort() {
2862
- this.value = this.value || this.initial;
2863
- this.done = this.aborted = true;
2864
- this.error = false;
2865
- this.red = false;
2866
- this.fire();
2867
- this.render();
2868
- this.out.write("\n");
2869
- this.close();
2870
- }
2871
- async validate() {
2872
- let valid = await this.validator(this.value);
2873
- if (typeof valid === `string`) {
2874
- this.errorMsg = valid;
2875
- valid = false;
2876
- }
2877
- this.error = !valid;
2878
- }
2879
- async submit() {
2880
- this.value = this.value || this.initial;
2881
- this.cursorOffset = 0;
2882
- this.cursor = this.rendered.length;
2883
- await this.validate();
2884
- if (this.error) {
2885
- this.red = true;
2886
- this.fire();
2887
- this.render();
2888
- return;
2889
- }
2890
- this.done = true;
2891
- this.aborted = false;
2892
- this.fire();
2893
- this.render();
2894
- this.out.write("\n");
2895
- this.close();
2896
- }
2897
- next() {
2898
- if (!this.placeholder) return this.bell();
2899
- this.value = this.initial;
2900
- this.cursor = this.rendered.length;
2901
- this.fire();
2902
- this.render();
2903
- }
2904
- moveCursor(n) {
2905
- if (this.placeholder) return;
2906
- this.cursor = this.cursor + n;
2907
- this.cursorOffset += n;
2908
- }
2909
- _(c2, key) {
2910
- let s1 = this.value.slice(0, this.cursor);
2911
- let s2 = this.value.slice(this.cursor);
2912
- this.value = `${s1}${c2}${s2}`;
2913
- this.red = false;
2914
- this.cursor = this.placeholder ? 0 : s1.length + 1;
2915
- this.render();
2916
- }
2917
- delete() {
2918
- if (this.isCursorAtStart()) return this.bell();
2919
- let s1 = this.value.slice(0, this.cursor - 1);
2920
- let s2 = this.value.slice(this.cursor);
2921
- this.value = `${s1}${s2}`;
2922
- this.red = false;
2923
- if (this.isCursorAtStart()) {
2924
- this.cursorOffset = 0;
2925
- } else {
2926
- this.cursorOffset++;
2927
- this.moveCursor(-1);
2928
- }
2929
- this.render();
2930
- }
2931
- deleteForward() {
2932
- if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
2933
- let s1 = this.value.slice(0, this.cursor);
2934
- let s2 = this.value.slice(this.cursor + 1);
2935
- this.value = `${s1}${s2}`;
2936
- this.red = false;
2937
- if (this.isCursorAtEnd()) {
2938
- this.cursorOffset = 0;
2939
- } else {
2940
- this.cursorOffset++;
2941
- }
2942
- this.render();
2943
- }
2944
- first() {
2945
- this.cursor = 0;
2946
- this.render();
2947
- }
2948
- last() {
2949
- this.cursor = this.value.length;
2950
- this.render();
2951
- }
2952
- left() {
2953
- if (this.cursor <= 0 || this.placeholder) return this.bell();
2954
- this.moveCursor(-1);
2955
- this.render();
2956
- }
2957
- right() {
2958
- if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
2959
- this.moveCursor(1);
2960
- this.render();
2961
- }
2962
- isCursorAtStart() {
2963
- return this.cursor === 0 || this.placeholder && this.cursor === 1;
2964
- }
2965
- isCursorAtEnd() {
2966
- return this.cursor === this.rendered.length || this.placeholder && this.cursor === this.rendered.length + 1;
2967
- }
2968
- render() {
2969
- if (this.closed) return;
2970
- if (!this.firstRender) {
2971
- if (this.outputError)
2972
- this.out.write(cursor$8.down(lines$1(this.outputError, this.out.columns) - 1) + clear$8(this.outputError, this.out.columns));
2973
- this.out.write(clear$8(this.outputText, this.out.columns));
2974
- }
2975
- super.render();
2976
- this.outputError = "";
2977
- this.outputText = [
2978
- style$8.symbol(this.done, this.aborted),
2979
- color$8.bold(this.msg),
2980
- style$8.delimiter(this.done),
2981
- this.red ? color$8.red(this.rendered) : this.rendered
2982
- ].join(` `);
2983
- if (this.error) {
2984
- this.outputError += this.errorMsg.split(`
2985
- `).reduce((a, l, i) => a + `
2986
- ${i ? " " : figures$6.pointerSmall} ${color$8.red().italic(l)}`, ``);
2987
- }
2988
- this.out.write(erase$5.line + cursor$8.to(0) + this.outputText + cursor$8.save + this.outputError + cursor$8.restore + cursor$8.move(this.cursorOffset, 0));
2989
- }
2990
- };
2991
- var text = TextPrompt;
2992
- var color$7 = kleur;
2993
- var Prompt$6 = prompt$1;
2994
- var { style: style$7, clear: clear$7, figures: figures$5, wrap: wrap$2, entriesToDisplay: entriesToDisplay$2 } = util;
2995
- var { cursor: cursor$7 } = src;
2996
- var SelectPrompt = class extends Prompt$6 {
2997
- constructor(opts = {}) {
2998
- super(opts);
2999
- this.msg = opts.message;
3000
- this.hint = opts.hint || "- Use arrow-keys. Return to submit.";
3001
- this.warn = opts.warn || "- This option is disabled";
3002
- this.cursor = opts.initial || 0;
3003
- this.choices = opts.choices.map((ch, idx) => {
3004
- if (typeof ch === "string")
3005
- ch = { title: ch, value: idx };
3006
- return {
3007
- title: ch && (ch.title || ch.value || ch),
3008
- value: ch && (ch.value === void 0 ? idx : ch.value),
3009
- description: ch && ch.description,
3010
- selected: ch && ch.selected,
3011
- disabled: ch && ch.disabled
3012
- };
3013
- });
3014
- this.optionsPerPage = opts.optionsPerPage || 10;
3015
- this.value = (this.choices[this.cursor] || {}).value;
3016
- this.clear = clear$7("", this.out.columns);
3017
- this.render();
3018
- }
3019
- moveCursor(n) {
3020
- this.cursor = n;
3021
- this.value = this.choices[n].value;
3022
- this.fire();
3023
- }
3024
- reset() {
3025
- this.moveCursor(0);
3026
- this.fire();
3027
- this.render();
3028
- }
3029
- exit() {
3030
- this.abort();
3031
- }
3032
- abort() {
3033
- this.done = this.aborted = true;
3034
- this.fire();
3035
- this.render();
3036
- this.out.write("\n");
3037
- this.close();
3038
- }
3039
- submit() {
3040
- if (!this.selection.disabled) {
3041
- this.done = true;
3042
- this.aborted = false;
3043
- this.fire();
3044
- this.render();
3045
- this.out.write("\n");
3046
- this.close();
3047
- } else
3048
- this.bell();
3049
- }
3050
- first() {
3051
- this.moveCursor(0);
3052
- this.render();
3053
- }
3054
- last() {
3055
- this.moveCursor(this.choices.length - 1);
3056
- this.render();
3057
- }
3058
- up() {
3059
- if (this.cursor === 0) {
3060
- this.moveCursor(this.choices.length - 1);
3061
- } else {
3062
- this.moveCursor(this.cursor - 1);
3063
- }
3064
- this.render();
3065
- }
3066
- down() {
3067
- if (this.cursor === this.choices.length - 1) {
3068
- this.moveCursor(0);
3069
- } else {
3070
- this.moveCursor(this.cursor + 1);
3071
- }
3072
- this.render();
3073
- }
3074
- next() {
3075
- this.moveCursor((this.cursor + 1) % this.choices.length);
3076
- this.render();
3077
- }
3078
- _(c2, key) {
3079
- if (c2 === " ") return this.submit();
3080
- }
3081
- get selection() {
3082
- return this.choices[this.cursor];
3083
- }
3084
- render() {
3085
- if (this.closed) return;
3086
- if (this.firstRender) this.out.write(cursor$7.hide);
3087
- else this.out.write(clear$7(this.outputText, this.out.columns));
3088
- super.render();
3089
- let { startIndex, endIndex } = entriesToDisplay$2(this.cursor, this.choices.length, this.optionsPerPage);
3090
- this.outputText = [
3091
- style$7.symbol(this.done, this.aborted),
3092
- color$7.bold(this.msg),
3093
- style$7.delimiter(false),
3094
- this.done ? this.selection.title : this.selection.disabled ? color$7.yellow(this.warn) : color$7.gray(this.hint)
3095
- ].join(" ");
3096
- if (!this.done) {
3097
- this.outputText += "\n";
3098
- for (let i = startIndex; i < endIndex; i++) {
3099
- let title, prefix, desc = "", v = this.choices[i];
3100
- if (i === startIndex && startIndex > 0) {
3101
- prefix = figures$5.arrowUp;
3102
- } else if (i === endIndex - 1 && endIndex < this.choices.length) {
3103
- prefix = figures$5.arrowDown;
3104
- } else {
3105
- prefix = " ";
3106
- }
3107
- if (v.disabled) {
3108
- title = this.cursor === i ? color$7.gray().underline(v.title) : color$7.strikethrough().gray(v.title);
3109
- prefix = (this.cursor === i ? color$7.bold().gray(figures$5.pointer) + " " : " ") + prefix;
3110
- } else {
3111
- title = this.cursor === i ? color$7.cyan().underline(v.title) : v.title;
3112
- prefix = (this.cursor === i ? color$7.cyan(figures$5.pointer) + " " : " ") + prefix;
3113
- if (v.description && this.cursor === i) {
3114
- desc = ` - ${v.description}`;
3115
- if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
3116
- desc = "\n" + wrap$2(v.description, { margin: 3, width: this.out.columns });
3117
- }
3118
- }
3119
- }
3120
- this.outputText += `${prefix} ${title}${color$7.gray(desc)}
3121
- `;
3122
- }
3123
- }
3124
- this.out.write(this.outputText);
3125
- }
3126
- };
3127
- var select = SelectPrompt;
3128
- var color$6 = kleur;
3129
- var Prompt$5 = prompt$1;
3130
- var { style: style$6, clear: clear$6 } = util;
3131
- var { cursor: cursor$6, erase: erase$4 } = src;
3132
- var TogglePrompt = class extends Prompt$5 {
3133
- constructor(opts = {}) {
3134
- super(opts);
3135
- this.msg = opts.message;
3136
- this.value = !!opts.initial;
3137
- this.active = opts.active || "on";
3138
- this.inactive = opts.inactive || "off";
3139
- this.initialValue = this.value;
3140
- this.render();
3141
- }
3142
- reset() {
3143
- this.value = this.initialValue;
3144
- this.fire();
3145
- this.render();
3146
- }
3147
- exit() {
3148
- this.abort();
3149
- }
3150
- abort() {
3151
- this.done = this.aborted = true;
3152
- this.fire();
3153
- this.render();
3154
- this.out.write("\n");
3155
- this.close();
3156
- }
3157
- submit() {
3158
- this.done = true;
3159
- this.aborted = false;
3160
- this.fire();
3161
- this.render();
3162
- this.out.write("\n");
3163
- this.close();
3164
- }
3165
- deactivate() {
3166
- if (this.value === false) return this.bell();
3167
- this.value = false;
3168
- this.render();
3169
- }
3170
- activate() {
3171
- if (this.value === true) return this.bell();
3172
- this.value = true;
3173
- this.render();
3174
- }
3175
- delete() {
3176
- this.deactivate();
3177
- }
3178
- left() {
3179
- this.deactivate();
3180
- }
3181
- right() {
3182
- this.activate();
3183
- }
3184
- down() {
3185
- this.deactivate();
3186
- }
3187
- up() {
3188
- this.activate();
3189
- }
3190
- next() {
3191
- this.value = !this.value;
3192
- this.fire();
3193
- this.render();
3194
- }
3195
- _(c2, key) {
3196
- if (c2 === " ") {
3197
- this.value = !this.value;
3198
- } else if (c2 === "1") {
3199
- this.value = true;
3200
- } else if (c2 === "0") {
3201
- this.value = false;
3202
- } else return this.bell();
3203
- this.render();
3204
- }
3205
- render() {
3206
- if (this.closed) return;
3207
- if (this.firstRender) this.out.write(cursor$6.hide);
3208
- else this.out.write(clear$6(this.outputText, this.out.columns));
3209
- super.render();
3210
- this.outputText = [
3211
- style$6.symbol(this.done, this.aborted),
3212
- color$6.bold(this.msg),
3213
- style$6.delimiter(this.done),
3214
- this.value ? this.inactive : color$6.cyan().underline(this.inactive),
3215
- color$6.gray("/"),
3216
- this.value ? color$6.cyan().underline(this.active) : this.active
3217
- ].join(" ");
3218
- this.out.write(erase$4.line + cursor$6.to(0) + this.outputText);
3219
- }
3220
- };
3221
- var toggle = TogglePrompt;
3222
- var DatePart$9 = class DatePart {
3223
- constructor({ token, date: date2, parts, locales }) {
3224
- this.token = token;
3225
- this.date = date2 || /* @__PURE__ */ new Date();
3226
- this.parts = parts || [this];
3227
- this.locales = locales || {};
3228
- }
3229
- up() {
3230
- }
3231
- down() {
3232
- }
3233
- next() {
3234
- const currentIdx = this.parts.indexOf(this);
3235
- return this.parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
3236
- }
3237
- setTo(val) {
3238
- }
3239
- prev() {
3240
- let parts = [].concat(this.parts).reverse();
3241
- const currentIdx = parts.indexOf(this);
3242
- return parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
3243
- }
3244
- toString() {
3245
- return String(this.date);
3246
- }
3247
- };
3248
- var datepart = DatePart$9;
3249
- var DatePart$8 = datepart;
3250
- var Meridiem$1 = class Meridiem extends DatePart$8 {
3251
- constructor(opts = {}) {
3252
- super(opts);
3253
- }
3254
- up() {
3255
- this.date.setHours((this.date.getHours() + 12) % 24);
3256
- }
3257
- down() {
3258
- this.up();
3259
- }
3260
- toString() {
3261
- let meridiem2 = this.date.getHours() > 12 ? "pm" : "am";
3262
- return /\A/.test(this.token) ? meridiem2.toUpperCase() : meridiem2;
3263
- }
3264
- };
3265
- var meridiem = Meridiem$1;
3266
- var DatePart$7 = datepart;
3267
- var pos = (n) => {
3268
- n = n % 10;
3269
- return n === 1 ? "st" : n === 2 ? "nd" : n === 3 ? "rd" : "th";
3270
- };
3271
- var Day$1 = class Day extends DatePart$7 {
3272
- constructor(opts = {}) {
3273
- super(opts);
3274
- }
3275
- up() {
3276
- this.date.setDate(this.date.getDate() + 1);
3277
- }
3278
- down() {
3279
- this.date.setDate(this.date.getDate() - 1);
3280
- }
3281
- setTo(val) {
3282
- this.date.setDate(parseInt(val.substr(-2)));
3283
- }
3284
- toString() {
3285
- let date2 = this.date.getDate();
3286
- let day2 = this.date.getDay();
3287
- return this.token === "DD" ? String(date2).padStart(2, "0") : this.token === "Do" ? date2 + pos(date2) : this.token === "d" ? day2 + 1 : this.token === "ddd" ? this.locales.weekdaysShort[day2] : this.token === "dddd" ? this.locales.weekdays[day2] : date2;
3288
- }
3289
- };
3290
- var day = Day$1;
3291
- var DatePart$6 = datepart;
3292
- var Hours$1 = class Hours extends DatePart$6 {
3293
- constructor(opts = {}) {
3294
- super(opts);
3295
- }
3296
- up() {
3297
- this.date.setHours(this.date.getHours() + 1);
3298
- }
3299
- down() {
3300
- this.date.setHours(this.date.getHours() - 1);
3301
- }
3302
- setTo(val) {
3303
- this.date.setHours(parseInt(val.substr(-2)));
3304
- }
3305
- toString() {
3306
- let hours2 = this.date.getHours();
3307
- if (/h/.test(this.token))
3308
- hours2 = hours2 % 12 || 12;
3309
- return this.token.length > 1 ? String(hours2).padStart(2, "0") : hours2;
3310
- }
3311
- };
3312
- var hours = Hours$1;
3313
- var DatePart$5 = datepart;
3314
- var Milliseconds$1 = class Milliseconds extends DatePart$5 {
3315
- constructor(opts = {}) {
3316
- super(opts);
3317
- }
3318
- up() {
3319
- this.date.setMilliseconds(this.date.getMilliseconds() + 1);
3320
- }
3321
- down() {
3322
- this.date.setMilliseconds(this.date.getMilliseconds() - 1);
3323
- }
3324
- setTo(val) {
3325
- this.date.setMilliseconds(parseInt(val.substr(-this.token.length)));
3326
- }
3327
- toString() {
3328
- return String(this.date.getMilliseconds()).padStart(4, "0").substr(0, this.token.length);
3329
- }
3330
- };
3331
- var milliseconds = Milliseconds$1;
3332
- var DatePart$4 = datepart;
3333
- var Minutes$1 = class Minutes extends DatePart$4 {
3334
- constructor(opts = {}) {
3335
- super(opts);
3336
- }
3337
- up() {
3338
- this.date.setMinutes(this.date.getMinutes() + 1);
3339
- }
3340
- down() {
3341
- this.date.setMinutes(this.date.getMinutes() - 1);
3342
- }
3343
- setTo(val) {
3344
- this.date.setMinutes(parseInt(val.substr(-2)));
3345
- }
3346
- toString() {
3347
- let m = this.date.getMinutes();
3348
- return this.token.length > 1 ? String(m).padStart(2, "0") : m;
3349
- }
3350
- };
3351
- var minutes = Minutes$1;
3352
- var DatePart$3 = datepart;
3353
- var Month$1 = class Month extends DatePart$3 {
3354
- constructor(opts = {}) {
3355
- super(opts);
3356
- }
3357
- up() {
3358
- this.date.setMonth(this.date.getMonth() + 1);
3359
- }
3360
- down() {
3361
- this.date.setMonth(this.date.getMonth() - 1);
3362
- }
3363
- setTo(val) {
3364
- val = parseInt(val.substr(-2)) - 1;
3365
- this.date.setMonth(val < 0 ? 0 : val);
3366
- }
3367
- toString() {
3368
- let month2 = this.date.getMonth();
3369
- let tl = this.token.length;
3370
- return tl === 2 ? String(month2 + 1).padStart(2, "0") : tl === 3 ? this.locales.monthsShort[month2] : tl === 4 ? this.locales.months[month2] : String(month2 + 1);
3371
- }
3372
- };
3373
- var month = Month$1;
3374
- var DatePart$2 = datepart;
3375
- var Seconds$1 = class Seconds extends DatePart$2 {
3376
- constructor(opts = {}) {
3377
- super(opts);
3378
- }
3379
- up() {
3380
- this.date.setSeconds(this.date.getSeconds() + 1);
3381
- }
3382
- down() {
3383
- this.date.setSeconds(this.date.getSeconds() - 1);
3384
- }
3385
- setTo(val) {
3386
- this.date.setSeconds(parseInt(val.substr(-2)));
3387
- }
3388
- toString() {
3389
- let s = this.date.getSeconds();
3390
- return this.token.length > 1 ? String(s).padStart(2, "0") : s;
3391
- }
3392
- };
3393
- var seconds = Seconds$1;
3394
- var DatePart$1 = datepart;
3395
- var Year$1 = class Year extends DatePart$1 {
3396
- constructor(opts = {}) {
3397
- super(opts);
3398
- }
3399
- up() {
3400
- this.date.setFullYear(this.date.getFullYear() + 1);
3401
- }
3402
- down() {
3403
- this.date.setFullYear(this.date.getFullYear() - 1);
3404
- }
3405
- setTo(val) {
3406
- this.date.setFullYear(val.substr(-4));
3407
- }
3408
- toString() {
3409
- let year2 = String(this.date.getFullYear()).padStart(4, "0");
3410
- return this.token.length === 2 ? year2.substr(-2) : year2;
3411
- }
3412
- };
3413
- var year = Year$1;
3414
- var dateparts = {
3415
- DatePart: datepart,
3416
- Meridiem: meridiem,
3417
- Day: day,
3418
- Hours: hours,
3419
- Milliseconds: milliseconds,
3420
- Minutes: minutes,
3421
- Month: month,
3422
- Seconds: seconds,
3423
- Year: year
3424
- };
3425
- var color$5 = kleur;
3426
- var Prompt$4 = prompt$1;
3427
- var { style: style$5, clear: clear$5, figures: figures$4 } = util;
3428
- var { erase: erase$3, cursor: cursor$5 } = src;
3429
- var { DatePart: DatePart2, Meridiem: Meridiem2, Day: Day2, Hours: Hours2, Milliseconds: Milliseconds2, Minutes: Minutes2, Month: Month2, Seconds: Seconds2, Year: Year2 } = dateparts;
3430
- var regex = /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g;
3431
- var regexGroups = {
3432
- 1: ({ token }) => token.replace(/\\(.)/g, "$1"),
3433
- 2: (opts) => new Day2(opts),
3434
- // Day // TODO
3435
- 3: (opts) => new Month2(opts),
3436
- // Month
3437
- 4: (opts) => new Year2(opts),
3438
- // Year
3439
- 5: (opts) => new Meridiem2(opts),
3440
- // AM/PM // TODO (special)
3441
- 6: (opts) => new Hours2(opts),
3442
- // Hours
3443
- 7: (opts) => new Minutes2(opts),
3444
- // Minutes
3445
- 8: (opts) => new Seconds2(opts),
3446
- // Seconds
3447
- 9: (opts) => new Milliseconds2(opts)
3448
- // Fractional seconds
3449
- };
3450
- var dfltLocales = {
3451
- months: "January,February,March,April,May,June,July,August,September,October,November,December".split(","),
3452
- monthsShort: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),
3453
- weekdays: "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),
3454
- weekdaysShort: "Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")
3455
- };
3456
- var DatePrompt = class extends Prompt$4 {
3457
- constructor(opts = {}) {
3458
- super(opts);
3459
- this.msg = opts.message;
3460
- this.cursor = 0;
3461
- this.typed = "";
3462
- this.locales = Object.assign(dfltLocales, opts.locales);
3463
- this._date = opts.initial || /* @__PURE__ */ new Date();
3464
- this.errorMsg = opts.error || "Please Enter A Valid Value";
3465
- this.validator = opts.validate || (() => true);
3466
- this.mask = opts.mask || "YYYY-MM-DD HH:mm:ss";
3467
- this.clear = clear$5("", this.out.columns);
3468
- this.render();
3469
- }
3470
- get value() {
3471
- return this.date;
3472
- }
3473
- get date() {
3474
- return this._date;
3475
- }
3476
- set date(date2) {
3477
- if (date2) this._date.setTime(date2.getTime());
3478
- }
3479
- set mask(mask) {
3480
- let result;
3481
- this.parts = [];
3482
- while (result = regex.exec(mask)) {
3483
- let match = result.shift();
3484
- let idx = result.findIndex((gr) => gr != null);
3485
- this.parts.push(idx in regexGroups ? regexGroups[idx]({ token: result[idx] || match, date: this.date, parts: this.parts, locales: this.locales }) : result[idx] || match);
3486
- }
3487
- let parts = this.parts.reduce((arr, i) => {
3488
- if (typeof i === "string" && typeof arr[arr.length - 1] === "string")
3489
- arr[arr.length - 1] += i;
3490
- else arr.push(i);
3491
- return arr;
3492
- }, []);
3493
- this.parts.splice(0);
3494
- this.parts.push(...parts);
3495
- this.reset();
3496
- }
3497
- moveCursor(n) {
3498
- this.typed = "";
3499
- this.cursor = n;
3500
- this.fire();
3501
- }
3502
- reset() {
3503
- this.moveCursor(this.parts.findIndex((p) => p instanceof DatePart2));
3504
- this.fire();
3505
- this.render();
3506
- }
3507
- exit() {
3508
- this.abort();
3509
- }
3510
- abort() {
3511
- this.done = this.aborted = true;
3512
- this.error = false;
3513
- this.fire();
3514
- this.render();
3515
- this.out.write("\n");
3516
- this.close();
3517
- }
3518
- async validate() {
3519
- let valid = await this.validator(this.value);
3520
- if (typeof valid === "string") {
3521
- this.errorMsg = valid;
3522
- valid = false;
3523
- }
3524
- this.error = !valid;
3525
- }
3526
- async submit() {
3527
- await this.validate();
3528
- if (this.error) {
3529
- this.color = "red";
3530
- this.fire();
3531
- this.render();
3532
- return;
3533
- }
3534
- this.done = true;
3535
- this.aborted = false;
3536
- this.fire();
3537
- this.render();
3538
- this.out.write("\n");
3539
- this.close();
3540
- }
3541
- up() {
3542
- this.typed = "";
3543
- this.parts[this.cursor].up();
3544
- this.render();
3545
- }
3546
- down() {
3547
- this.typed = "";
3548
- this.parts[this.cursor].down();
3549
- this.render();
3550
- }
3551
- left() {
3552
- let prev = this.parts[this.cursor].prev();
3553
- if (prev == null) return this.bell();
3554
- this.moveCursor(this.parts.indexOf(prev));
3555
- this.render();
3556
- }
3557
- right() {
3558
- let next = this.parts[this.cursor].next();
3559
- if (next == null) return this.bell();
3560
- this.moveCursor(this.parts.indexOf(next));
3561
- this.render();
3562
- }
3563
- next() {
3564
- let next = this.parts[this.cursor].next();
3565
- this.moveCursor(next ? this.parts.indexOf(next) : this.parts.findIndex((part) => part instanceof DatePart2));
3566
- this.render();
3567
- }
3568
- _(c2) {
3569
- if (/\d/.test(c2)) {
3570
- this.typed += c2;
3571
- this.parts[this.cursor].setTo(this.typed);
3572
- this.render();
3573
- }
3574
- }
3575
- render() {
3576
- if (this.closed) return;
3577
- if (this.firstRender) this.out.write(cursor$5.hide);
3578
- else this.out.write(clear$5(this.outputText, this.out.columns));
3579
- super.render();
3580
- this.outputText = [
3581
- style$5.symbol(this.done, this.aborted),
3582
- color$5.bold(this.msg),
3583
- style$5.delimiter(false),
3584
- this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color$5.cyan().underline(p.toString()) : p), []).join("")
3585
- ].join(" ");
3586
- if (this.error) {
3587
- this.outputText += this.errorMsg.split("\n").reduce(
3588
- (a, l, i) => a + `
3589
- ${i ? ` ` : figures$4.pointerSmall} ${color$5.red().italic(l)}`,
3590
- ``
3591
- );
3592
- }
3593
- this.out.write(erase$3.line + cursor$5.to(0) + this.outputText);
3594
- }
3595
- };
3596
- var date = DatePrompt;
3597
- var color$4 = kleur;
3598
- var Prompt$3 = prompt$1;
3599
- var { cursor: cursor$4, erase: erase$2 } = src;
3600
- var { style: style$4, figures: figures$3, clear: clear$4, lines } = util;
3601
- var isNumber = /[0-9]/;
3602
- var isDef = (any) => any !== void 0;
3603
- var round = (number2, precision) => {
3604
- let factor = Math.pow(10, precision);
3605
- return Math.round(number2 * factor) / factor;
3606
- };
3607
- var NumberPrompt = class extends Prompt$3 {
3608
- constructor(opts = {}) {
3609
- super(opts);
3610
- this.transform = style$4.render(opts.style);
3611
- this.msg = opts.message;
3612
- this.initial = isDef(opts.initial) ? opts.initial : "";
3613
- this.float = !!opts.float;
3614
- this.round = opts.round || 2;
3615
- this.inc = opts.increment || 1;
3616
- this.min = isDef(opts.min) ? opts.min : -Infinity;
3617
- this.max = isDef(opts.max) ? opts.max : Infinity;
3618
- this.errorMsg = opts.error || `Please Enter A Valid Value`;
3619
- this.validator = opts.validate || (() => true);
3620
- this.color = `cyan`;
3621
- this.value = ``;
3622
- this.typed = ``;
3623
- this.lastHit = 0;
3624
- this.render();
3625
- }
3626
- set value(v) {
3627
- if (!v && v !== 0) {
3628
- this.placeholder = true;
3629
- this.rendered = color$4.gray(this.transform.render(`${this.initial}`));
3630
- this._value = ``;
3631
- } else {
3632
- this.placeholder = false;
3633
- this.rendered = this.transform.render(`${round(v, this.round)}`);
3634
- this._value = round(v, this.round);
3635
- }
3636
- this.fire();
3637
- }
3638
- get value() {
3639
- return this._value;
3640
- }
3641
- parse(x) {
3642
- return this.float ? parseFloat(x) : parseInt(x);
3643
- }
3644
- valid(c2) {
3645
- return c2 === `-` || c2 === `.` && this.float || isNumber.test(c2);
3646
- }
3647
- reset() {
3648
- this.typed = ``;
3649
- this.value = ``;
3650
- this.fire();
3651
- this.render();
3652
- }
3653
- exit() {
3654
- this.abort();
3655
- }
3656
- abort() {
3657
- let x = this.value;
3658
- this.value = x !== `` ? x : this.initial;
3659
- this.done = this.aborted = true;
3660
- this.error = false;
3661
- this.fire();
3662
- this.render();
3663
- this.out.write(`
3664
- `);
3665
- this.close();
3666
- }
3667
- async validate() {
3668
- let valid = await this.validator(this.value);
3669
- if (typeof valid === `string`) {
3670
- this.errorMsg = valid;
3671
- valid = false;
3672
- }
3673
- this.error = !valid;
3674
- }
3675
- async submit() {
3676
- await this.validate();
3677
- if (this.error) {
3678
- this.color = `red`;
3679
- this.fire();
3680
- this.render();
3681
- return;
3682
- }
3683
- let x = this.value;
3684
- this.value = x !== `` ? x : this.initial;
3685
- this.done = true;
3686
- this.aborted = false;
3687
- this.error = false;
3688
- this.fire();
3689
- this.render();
3690
- this.out.write(`
3691
- `);
3692
- this.close();
3693
- }
3694
- up() {
3695
- this.typed = ``;
3696
- if (this.value === "") {
3697
- this.value = this.min - this.inc;
3698
- }
3699
- if (this.value >= this.max) return this.bell();
3700
- this.value += this.inc;
3701
- this.color = `cyan`;
3702
- this.fire();
3703
- this.render();
3704
- }
3705
- down() {
3706
- this.typed = ``;
3707
- if (this.value === "") {
3708
- this.value = this.min + this.inc;
3709
- }
3710
- if (this.value <= this.min) return this.bell();
3711
- this.value -= this.inc;
3712
- this.color = `cyan`;
3713
- this.fire();
3714
- this.render();
3715
- }
3716
- delete() {
3717
- let val = this.value.toString();
3718
- if (val.length === 0) return this.bell();
3719
- this.value = this.parse(val = val.slice(0, -1)) || ``;
3720
- if (this.value !== "" && this.value < this.min) {
3721
- this.value = this.min;
3722
- }
3723
- this.color = `cyan`;
3724
- this.fire();
3725
- this.render();
3726
- }
3727
- next() {
3728
- this.value = this.initial;
3729
- this.fire();
3730
- this.render();
3731
- }
3732
- _(c2, key) {
3733
- if (!this.valid(c2)) return this.bell();
3734
- const now = Date.now();
3735
- if (now - this.lastHit > 1e3) this.typed = ``;
3736
- this.typed += c2;
3737
- this.lastHit = now;
3738
- this.color = `cyan`;
3739
- if (c2 === `.`) return this.fire();
3740
- this.value = Math.min(this.parse(this.typed), this.max);
3741
- if (this.value > this.max) this.value = this.max;
3742
- if (this.value < this.min) this.value = this.min;
3743
- this.fire();
3744
- this.render();
3745
- }
3746
- render() {
3747
- if (this.closed) return;
3748
- if (!this.firstRender) {
3749
- if (this.outputError)
3750
- this.out.write(cursor$4.down(lines(this.outputError, this.out.columns) - 1) + clear$4(this.outputError, this.out.columns));
3751
- this.out.write(clear$4(this.outputText, this.out.columns));
3752
- }
3753
- super.render();
3754
- this.outputError = "";
3755
- this.outputText = [
3756
- style$4.symbol(this.done, this.aborted),
3757
- color$4.bold(this.msg),
3758
- style$4.delimiter(this.done),
3759
- !this.done || !this.done && !this.placeholder ? color$4[this.color]().underline(this.rendered) : this.rendered
3760
- ].join(` `);
3761
- if (this.error) {
3762
- this.outputError += this.errorMsg.split(`
3763
- `).reduce((a, l, i) => a + `
3764
- ${i ? ` ` : figures$3.pointerSmall} ${color$4.red().italic(l)}`, ``);
3765
- }
3766
- this.out.write(erase$2.line + cursor$4.to(0) + this.outputText + cursor$4.save + this.outputError + cursor$4.restore);
3767
- }
3768
- };
3769
- var number = NumberPrompt;
3770
- var color$3 = kleur;
3771
- var { cursor: cursor$3 } = src;
3772
- var Prompt$2 = prompt$1;
3773
- var { clear: clear$3, figures: figures$2, style: style$3, wrap: wrap$1, entriesToDisplay: entriesToDisplay$1 } = util;
3774
- var MultiselectPrompt$1 = class MultiselectPrompt extends Prompt$2 {
3775
- constructor(opts = {}) {
3776
- super(opts);
3777
- this.msg = opts.message;
3778
- this.cursor = opts.cursor || 0;
3779
- this.scrollIndex = opts.cursor || 0;
3780
- this.hint = opts.hint || "";
3781
- this.warn = opts.warn || "- This option is disabled -";
3782
- this.minSelected = opts.min;
3783
- this.showMinError = false;
3784
- this.maxChoices = opts.max;
3785
- this.instructions = opts.instructions;
3786
- this.optionsPerPage = opts.optionsPerPage || 10;
3787
- this.value = opts.choices.map((ch, idx) => {
3788
- if (typeof ch === "string")
3789
- ch = { title: ch, value: idx };
3790
- return {
3791
- title: ch && (ch.title || ch.value || ch),
3792
- description: ch && ch.description,
3793
- value: ch && (ch.value === void 0 ? idx : ch.value),
3794
- selected: ch && ch.selected,
3795
- disabled: ch && ch.disabled
3796
- };
3797
- });
3798
- this.clear = clear$3("", this.out.columns);
3799
- if (!opts.overrideRender) {
3800
- this.render();
3801
- }
3802
- }
3803
- reset() {
3804
- this.value.map((v) => !v.selected);
3805
- this.cursor = 0;
3806
- this.fire();
3807
- this.render();
3808
- }
3809
- selected() {
3810
- return this.value.filter((v) => v.selected);
3811
- }
3812
- exit() {
3813
- this.abort();
3814
- }
3815
- abort() {
3816
- this.done = this.aborted = true;
3817
- this.fire();
3818
- this.render();
3819
- this.out.write("\n");
3820
- this.close();
3821
- }
3822
- submit() {
3823
- const selected = this.value.filter((e) => e.selected);
3824
- if (this.minSelected && selected.length < this.minSelected) {
3825
- this.showMinError = true;
3826
- this.render();
3827
- } else {
3828
- this.done = true;
3829
- this.aborted = false;
3830
- this.fire();
3831
- this.render();
3832
- this.out.write("\n");
3833
- this.close();
3834
- }
3835
- }
3836
- first() {
3837
- this.cursor = 0;
3838
- this.render();
3839
- }
3840
- last() {
3841
- this.cursor = this.value.length - 1;
3842
- this.render();
3843
- }
3844
- next() {
3845
- this.cursor = (this.cursor + 1) % this.value.length;
3846
- this.render();
3847
- }
3848
- up() {
3849
- if (this.cursor === 0) {
3850
- this.cursor = this.value.length - 1;
3851
- } else {
3852
- this.cursor--;
3853
- }
3854
- this.render();
3855
- }
3856
- down() {
3857
- if (this.cursor === this.value.length - 1) {
3858
- this.cursor = 0;
3859
- } else {
3860
- this.cursor++;
3861
- }
3862
- this.render();
3863
- }
3864
- left() {
3865
- this.value[this.cursor].selected = false;
3866
- this.render();
3867
- }
3868
- right() {
3869
- if (this.value.filter((e) => e.selected).length >= this.maxChoices) return this.bell();
3870
- this.value[this.cursor].selected = true;
3871
- this.render();
3872
- }
3873
- handleSpaceToggle() {
3874
- const v = this.value[this.cursor];
3875
- if (v.selected) {
3876
- v.selected = false;
3877
- this.render();
3878
- } else if (v.disabled || this.value.filter((e) => e.selected).length >= this.maxChoices) {
3879
- return this.bell();
3880
- } else {
3881
- v.selected = true;
3882
- this.render();
3883
- }
3884
- }
3885
- toggleAll() {
3886
- if (this.maxChoices !== void 0 || this.value[this.cursor].disabled) {
3887
- return this.bell();
3888
- }
3889
- const newSelected = !this.value[this.cursor].selected;
3890
- this.value.filter((v) => !v.disabled).forEach((v) => v.selected = newSelected);
3891
- this.render();
3892
- }
3893
- _(c2, key) {
3894
- if (c2 === " ") {
3895
- this.handleSpaceToggle();
3896
- } else if (c2 === "a") {
3897
- this.toggleAll();
3898
- } else {
3899
- return this.bell();
3900
- }
3901
- }
3902
- renderInstructions() {
3903
- if (this.instructions === void 0 || this.instructions) {
3904
- if (typeof this.instructions === "string") {
3905
- return this.instructions;
3906
- }
3907
- return `
3908
- Instructions:
3909
- ${figures$2.arrowUp}/${figures$2.arrowDown}: Highlight option
3910
- ${figures$2.arrowLeft}/${figures$2.arrowRight}/[space]: Toggle selection
3911
- ` + (this.maxChoices === void 0 ? ` a: Toggle all
3912
- ` : "") + ` enter/return: Complete answer`;
3913
- }
3914
- return "";
3915
- }
3916
- renderOption(cursor2, v, i, arrowIndicator) {
3917
- const prefix = (v.selected ? color$3.green(figures$2.radioOn) : figures$2.radioOff) + " " + arrowIndicator + " ";
3918
- let title, desc;
3919
- if (v.disabled) {
3920
- title = cursor2 === i ? color$3.gray().underline(v.title) : color$3.strikethrough().gray(v.title);
3921
- } else {
3922
- title = cursor2 === i ? color$3.cyan().underline(v.title) : v.title;
3923
- if (cursor2 === i && v.description) {
3924
- desc = ` - ${v.description}`;
3925
- if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
3926
- desc = "\n" + wrap$1(v.description, { margin: prefix.length, width: this.out.columns });
3927
- }
3928
- }
3929
- }
3930
- return prefix + title + color$3.gray(desc || "");
3931
- }
3932
- // shared with autocompleteMultiselect
3933
- paginateOptions(options2) {
3934
- if (options2.length === 0) {
3935
- return color$3.red("No matches for this query.");
3936
- }
3937
- let { startIndex, endIndex } = entriesToDisplay$1(this.cursor, options2.length, this.optionsPerPage);
3938
- let prefix, styledOptions = [];
3939
- for (let i = startIndex; i < endIndex; i++) {
3940
- if (i === startIndex && startIndex > 0) {
3941
- prefix = figures$2.arrowUp;
3942
- } else if (i === endIndex - 1 && endIndex < options2.length) {
3943
- prefix = figures$2.arrowDown;
3944
- } else {
3945
- prefix = " ";
3946
- }
3947
- styledOptions.push(this.renderOption(this.cursor, options2[i], i, prefix));
3948
- }
3949
- return "\n" + styledOptions.join("\n");
3950
- }
3951
- // shared with autocomleteMultiselect
3952
- renderOptions(options2) {
3953
- if (!this.done) {
3954
- return this.paginateOptions(options2);
3955
- }
3956
- return "";
3957
- }
3958
- renderDoneOrInstructions() {
3959
- if (this.done) {
3960
- return this.value.filter((e) => e.selected).map((v) => v.title).join(", ");
3961
- }
3962
- const output = [color$3.gray(this.hint), this.renderInstructions()];
3963
- if (this.value[this.cursor].disabled) {
3964
- output.push(color$3.yellow(this.warn));
3965
- }
3966
- return output.join(" ");
3967
- }
3968
- render() {
3969
- if (this.closed) return;
3970
- if (this.firstRender) this.out.write(cursor$3.hide);
3971
- super.render();
3972
- let prompt2 = [
3973
- style$3.symbol(this.done, this.aborted),
3974
- color$3.bold(this.msg),
3975
- style$3.delimiter(false),
3976
- this.renderDoneOrInstructions()
3977
- ].join(" ");
3978
- if (this.showMinError) {
3979
- prompt2 += color$3.red(`You must select a minimum of ${this.minSelected} choices.`);
3980
- this.showMinError = false;
3981
- }
3982
- prompt2 += this.renderOptions(this.value);
3983
- this.out.write(this.clear + prompt2);
3984
- this.clear = clear$3(prompt2, this.out.columns);
3985
- }
3986
- };
3987
- var multiselect = MultiselectPrompt$1;
3988
- var color$2 = kleur;
3989
- var Prompt$1 = prompt$1;
3990
- var { erase: erase$1, cursor: cursor$2 } = src;
3991
- var { style: style$2, clear: clear$2, figures: figures$1, wrap, entriesToDisplay } = util;
3992
- var getVal = (arr, i) => arr[i] && (arr[i].value || arr[i].title || arr[i]);
3993
- var getTitle = (arr, i) => arr[i] && (arr[i].title || arr[i].value || arr[i]);
3994
- var getIndex = (arr, valOrTitle) => {
3995
- const index = arr.findIndex((el) => el.value === valOrTitle || el.title === valOrTitle);
3996
- return index > -1 ? index : void 0;
3997
- };
3998
- var AutocompletePrompt = class extends Prompt$1 {
3999
- constructor(opts = {}) {
4000
- super(opts);
4001
- this.msg = opts.message;
4002
- this.suggest = opts.suggest;
4003
- this.choices = opts.choices;
4004
- this.initial = typeof opts.initial === "number" ? opts.initial : getIndex(opts.choices, opts.initial);
4005
- this.select = this.initial || opts.cursor || 0;
4006
- this.i18n = { noMatches: opts.noMatches || "no matches found" };
4007
- this.fallback = opts.fallback || this.initial;
4008
- this.clearFirst = opts.clearFirst || false;
4009
- this.suggestions = [];
4010
- this.input = "";
4011
- this.limit = opts.limit || 10;
4012
- this.cursor = 0;
4013
- this.transform = style$2.render(opts.style);
4014
- this.scale = this.transform.scale;
4015
- this.render = this.render.bind(this);
4016
- this.complete = this.complete.bind(this);
4017
- this.clear = clear$2("", this.out.columns);
4018
- this.complete(this.render);
4019
- this.render();
4020
- }
4021
- set fallback(fb) {
4022
- this._fb = Number.isSafeInteger(parseInt(fb)) ? parseInt(fb) : fb;
4023
- }
4024
- get fallback() {
4025
- let choice;
4026
- if (typeof this._fb === "number")
4027
- choice = this.choices[this._fb];
4028
- else if (typeof this._fb === "string")
4029
- choice = { title: this._fb };
4030
- return choice || this._fb || { title: this.i18n.noMatches };
4031
- }
4032
- moveSelect(i) {
4033
- this.select = i;
4034
- if (this.suggestions.length > 0)
4035
- this.value = getVal(this.suggestions, i);
4036
- else this.value = this.fallback.value;
4037
- this.fire();
4038
- }
4039
- async complete(cb) {
4040
- const p = this.completing = this.suggest(this.input, this.choices);
4041
- const suggestions = await p;
4042
- if (this.completing !== p) return;
4043
- this.suggestions = suggestions.map((s, i, arr) => ({ title: getTitle(arr, i), value: getVal(arr, i), description: s.description }));
4044
- this.completing = false;
4045
- const l = Math.max(suggestions.length - 1, 0);
4046
- this.moveSelect(Math.min(l, this.select));
4047
- cb && cb();
4048
- }
4049
- reset() {
4050
- this.input = "";
4051
- this.complete(() => {
4052
- this.moveSelect(this.initial !== void 0 ? this.initial : 0);
4053
- this.render();
4054
- });
4055
- this.render();
4056
- }
4057
- exit() {
4058
- if (this.clearFirst && this.input.length > 0) {
4059
- this.reset();
4060
- } else {
4061
- this.done = this.exited = true;
4062
- this.aborted = false;
4063
- this.fire();
4064
- this.render();
4065
- this.out.write("\n");
4066
- this.close();
4067
- }
4068
- }
4069
- abort() {
4070
- this.done = this.aborted = true;
4071
- this.exited = false;
4072
- this.fire();
4073
- this.render();
4074
- this.out.write("\n");
4075
- this.close();
4076
- }
4077
- submit() {
4078
- this.done = true;
4079
- this.aborted = this.exited = false;
4080
- this.fire();
4081
- this.render();
4082
- this.out.write("\n");
4083
- this.close();
4084
- }
4085
- _(c2, key) {
4086
- let s1 = this.input.slice(0, this.cursor);
4087
- let s2 = this.input.slice(this.cursor);
4088
- this.input = `${s1}${c2}${s2}`;
4089
- this.cursor = s1.length + 1;
4090
- this.complete(this.render);
4091
- this.render();
4092
- }
4093
- delete() {
4094
- if (this.cursor === 0) return this.bell();
4095
- let s1 = this.input.slice(0, this.cursor - 1);
4096
- let s2 = this.input.slice(this.cursor);
4097
- this.input = `${s1}${s2}`;
4098
- this.complete(this.render);
4099
- this.cursor = this.cursor - 1;
4100
- this.render();
4101
- }
4102
- deleteForward() {
4103
- if (this.cursor * this.scale >= this.rendered.length) return this.bell();
4104
- let s1 = this.input.slice(0, this.cursor);
4105
- let s2 = this.input.slice(this.cursor + 1);
4106
- this.input = `${s1}${s2}`;
4107
- this.complete(this.render);
4108
- this.render();
4109
- }
4110
- first() {
4111
- this.moveSelect(0);
4112
- this.render();
4113
- }
4114
- last() {
4115
- this.moveSelect(this.suggestions.length - 1);
4116
- this.render();
4117
- }
4118
- up() {
4119
- if (this.select === 0) {
4120
- this.moveSelect(this.suggestions.length - 1);
4121
- } else {
4122
- this.moveSelect(this.select - 1);
4123
- }
4124
- this.render();
4125
- }
4126
- down() {
4127
- if (this.select === this.suggestions.length - 1) {
4128
- this.moveSelect(0);
4129
- } else {
4130
- this.moveSelect(this.select + 1);
4131
- }
4132
- this.render();
4133
- }
4134
- next() {
4135
- if (this.select === this.suggestions.length - 1) {
4136
- this.moveSelect(0);
4137
- } else this.moveSelect(this.select + 1);
4138
- this.render();
4139
- }
4140
- nextPage() {
4141
- this.moveSelect(Math.min(this.select + this.limit, this.suggestions.length - 1));
4142
- this.render();
4143
- }
4144
- prevPage() {
4145
- this.moveSelect(Math.max(this.select - this.limit, 0));
4146
- this.render();
4147
- }
4148
- left() {
4149
- if (this.cursor <= 0) return this.bell();
4150
- this.cursor = this.cursor - 1;
4151
- this.render();
4152
- }
4153
- right() {
4154
- if (this.cursor * this.scale >= this.rendered.length) return this.bell();
4155
- this.cursor = this.cursor + 1;
4156
- this.render();
4157
- }
4158
- renderOption(v, hovered, isStart, isEnd) {
4159
- let desc;
4160
- let prefix = isStart ? figures$1.arrowUp : isEnd ? figures$1.arrowDown : " ";
4161
- let title = hovered ? color$2.cyan().underline(v.title) : v.title;
4162
- prefix = (hovered ? color$2.cyan(figures$1.pointer) + " " : " ") + prefix;
4163
- if (v.description) {
4164
- desc = ` - ${v.description}`;
4165
- if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
4166
- desc = "\n" + wrap(v.description, { margin: 3, width: this.out.columns });
4167
- }
4168
- }
4169
- return prefix + " " + title + color$2.gray(desc || "");
4170
- }
4171
- render() {
4172
- if (this.closed) return;
4173
- if (this.firstRender) this.out.write(cursor$2.hide);
4174
- else this.out.write(clear$2(this.outputText, this.out.columns));
4175
- super.render();
4176
- let { startIndex, endIndex } = entriesToDisplay(this.select, this.choices.length, this.limit);
4177
- this.outputText = [
4178
- style$2.symbol(this.done, this.aborted, this.exited),
4179
- color$2.bold(this.msg),
4180
- style$2.delimiter(this.completing),
4181
- this.done && this.suggestions[this.select] ? this.suggestions[this.select].title : this.rendered = this.transform.render(this.input)
4182
- ].join(" ");
4183
- if (!this.done) {
4184
- const suggestions = this.suggestions.slice(startIndex, endIndex).map((item2, i) => this.renderOption(
4185
- item2,
4186
- this.select === i + startIndex,
4187
- i === 0 && startIndex > 0,
4188
- i + startIndex === endIndex - 1 && endIndex < this.choices.length
4189
- )).join("\n");
4190
- this.outputText += `
4191
- ` + (suggestions || color$2.gray(this.fallback.title));
4192
- }
4193
- this.out.write(erase$1.line + cursor$2.to(0) + this.outputText);
4194
- }
4195
- };
4196
- var autocomplete = AutocompletePrompt;
4197
- var color$1 = kleur;
4198
- var { cursor: cursor$1 } = src;
4199
- var MultiselectPrompt2 = multiselect;
4200
- var { clear: clear$1, style: style$1, figures } = util;
4201
- var AutocompleteMultiselectPrompt = class extends MultiselectPrompt2 {
4202
- constructor(opts = {}) {
4203
- opts.overrideRender = true;
4204
- super(opts);
4205
- this.inputValue = "";
4206
- this.clear = clear$1("", this.out.columns);
4207
- this.filteredOptions = this.value;
4208
- this.render();
4209
- }
4210
- last() {
4211
- this.cursor = this.filteredOptions.length - 1;
4212
- this.render();
4213
- }
4214
- next() {
4215
- this.cursor = (this.cursor + 1) % this.filteredOptions.length;
4216
- this.render();
4217
- }
4218
- up() {
4219
- if (this.cursor === 0) {
4220
- this.cursor = this.filteredOptions.length - 1;
4221
- } else {
4222
- this.cursor--;
4223
- }
4224
- this.render();
4225
- }
4226
- down() {
4227
- if (this.cursor === this.filteredOptions.length - 1) {
4228
- this.cursor = 0;
4229
- } else {
4230
- this.cursor++;
4231
- }
4232
- this.render();
4233
- }
4234
- left() {
4235
- this.filteredOptions[this.cursor].selected = false;
4236
- this.render();
4237
- }
4238
- right() {
4239
- if (this.value.filter((e) => e.selected).length >= this.maxChoices) return this.bell();
4240
- this.filteredOptions[this.cursor].selected = true;
4241
- this.render();
4242
- }
4243
- delete() {
4244
- if (this.inputValue.length) {
4245
- this.inputValue = this.inputValue.substr(0, this.inputValue.length - 1);
4246
- this.updateFilteredOptions();
4247
- }
4248
- }
4249
- updateFilteredOptions() {
4250
- const currentHighlight = this.filteredOptions[this.cursor];
4251
- this.filteredOptions = this.value.filter((v) => {
4252
- if (this.inputValue) {
4253
- if (typeof v.title === "string") {
4254
- if (v.title.toLowerCase().includes(this.inputValue.toLowerCase())) {
4255
- return true;
4256
- }
4257
- }
4258
- if (typeof v.value === "string") {
4259
- if (v.value.toLowerCase().includes(this.inputValue.toLowerCase())) {
4260
- return true;
4261
- }
4262
- }
4263
- return false;
4264
- }
4265
- return true;
4266
- });
4267
- const newHighlightIndex = this.filteredOptions.findIndex((v) => v === currentHighlight);
4268
- this.cursor = newHighlightIndex < 0 ? 0 : newHighlightIndex;
4269
- this.render();
4270
- }
4271
- handleSpaceToggle() {
4272
- const v = this.filteredOptions[this.cursor];
4273
- if (v.selected) {
4274
- v.selected = false;
4275
- this.render();
4276
- } else if (v.disabled || this.value.filter((e) => e.selected).length >= this.maxChoices) {
4277
- return this.bell();
4278
- } else {
4279
- v.selected = true;
4280
- this.render();
4281
- }
4282
- }
4283
- handleInputChange(c2) {
4284
- this.inputValue = this.inputValue + c2;
4285
- this.updateFilteredOptions();
4286
- }
4287
- _(c2, key) {
4288
- if (c2 === " ") {
4289
- this.handleSpaceToggle();
4290
- } else {
4291
- this.handleInputChange(c2);
4292
- }
4293
- }
4294
- renderInstructions() {
4295
- if (this.instructions === void 0 || this.instructions) {
4296
- if (typeof this.instructions === "string") {
4297
- return this.instructions;
4298
- }
4299
- return `
4300
- Instructions:
4301
- ${figures.arrowUp}/${figures.arrowDown}: Highlight option
4302
- ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
4303
- [a,b,c]/delete: Filter choices
4304
- enter/return: Complete answer
4305
- `;
4306
- }
4307
- return "";
4308
- }
4309
- renderCurrentInput() {
4310
- return `
4311
- Filtered results for: ${this.inputValue ? this.inputValue : color$1.gray("Enter something to filter")}
4312
- `;
4313
- }
4314
- renderOption(cursor2, v, i, arrowIndicator) {
4315
- const prefix = (v.selected ? color$1.green(figures.radioOn) : figures.radioOff) + " " + arrowIndicator + " ";
4316
- let title;
4317
- if (v.disabled) title = cursor2 === i ? color$1.gray().underline(v.title) : color$1.strikethrough().gray(v.title);
4318
- else title = cursor2 === i ? color$1.cyan().underline(v.title) : v.title;
4319
- return prefix + title;
4320
- }
4321
- renderDoneOrInstructions() {
4322
- if (this.done) {
4323
- return this.value.filter((e) => e.selected).map((v) => v.title).join(", ");
4324
- }
4325
- const output = [color$1.gray(this.hint), this.renderInstructions(), this.renderCurrentInput()];
4326
- if (this.filteredOptions.length && this.filteredOptions[this.cursor].disabled) {
4327
- output.push(color$1.yellow(this.warn));
4328
- }
4329
- return output.join(" ");
4330
- }
4331
- render() {
4332
- if (this.closed) return;
4333
- if (this.firstRender) this.out.write(cursor$1.hide);
4334
- super.render();
4335
- let prompt2 = [
4336
- style$1.symbol(this.done, this.aborted),
4337
- color$1.bold(this.msg),
4338
- style$1.delimiter(false),
4339
- this.renderDoneOrInstructions()
4340
- ].join(" ");
4341
- if (this.showMinError) {
4342
- prompt2 += color$1.red(`You must select a minimum of ${this.minSelected} choices.`);
4343
- this.showMinError = false;
4344
- }
4345
- prompt2 += this.renderOptions(this.filteredOptions);
4346
- this.out.write(this.clear + prompt2);
4347
- this.clear = clear$1(prompt2, this.out.columns);
4348
- }
4349
- };
4350
- var autocompleteMultiselect = AutocompleteMultiselectPrompt;
4351
- var color = kleur;
4352
- var Prompt2 = prompt$1;
4353
- var { style, clear } = util;
4354
- var { erase, cursor } = src;
4355
- var ConfirmPrompt = class extends Prompt2 {
4356
- constructor(opts = {}) {
4357
- super(opts);
4358
- this.msg = opts.message;
4359
- this.value = opts.initial;
4360
- this.initialValue = !!opts.initial;
4361
- this.yesMsg = opts.yes || "yes";
4362
- this.yesOption = opts.yesOption || "(Y/n)";
4363
- this.noMsg = opts.no || "no";
4364
- this.noOption = opts.noOption || "(y/N)";
4365
- this.render();
4366
- }
4367
- reset() {
4368
- this.value = this.initialValue;
4369
- this.fire();
4370
- this.render();
4371
- }
4372
- exit() {
4373
- this.abort();
4374
- }
4375
- abort() {
4376
- this.done = this.aborted = true;
4377
- this.fire();
4378
- this.render();
4379
- this.out.write("\n");
4380
- this.close();
4381
- }
4382
- submit() {
4383
- this.value = this.value || false;
4384
- this.done = true;
4385
- this.aborted = false;
4386
- this.fire();
4387
- this.render();
4388
- this.out.write("\n");
4389
- this.close();
4390
- }
4391
- _(c2, key) {
4392
- if (c2.toLowerCase() === "y") {
4393
- this.value = true;
4394
- return this.submit();
4395
- }
4396
- if (c2.toLowerCase() === "n") {
4397
- this.value = false;
4398
- return this.submit();
4399
- }
4400
- return this.bell();
4401
- }
4402
- render() {
4403
- if (this.closed) return;
4404
- if (this.firstRender) this.out.write(cursor.hide);
4405
- else this.out.write(clear(this.outputText, this.out.columns));
4406
- super.render();
4407
- this.outputText = [
4408
- style.symbol(this.done, this.aborted),
4409
- color.bold(this.msg),
4410
- style.delimiter(this.done),
4411
- this.done ? this.value ? this.yesMsg : this.noMsg : color.gray(this.initialValue ? this.yesOption : this.noOption)
4412
- ].join(" ");
4413
- this.out.write(erase.line + cursor.to(0) + this.outputText);
4414
- }
4415
- };
4416
- var confirm = ConfirmPrompt;
4417
- var elements = {
4418
- TextPrompt: text,
4419
- SelectPrompt: select,
4420
- TogglePrompt: toggle,
4421
- DatePrompt: date,
4422
- NumberPrompt: number,
4423
- MultiselectPrompt: multiselect,
4424
- AutocompletePrompt: autocomplete,
4425
- AutocompleteMultiselectPrompt: autocompleteMultiselect,
4426
- ConfirmPrompt: confirm
4427
- };
4428
- (function(exports) {
4429
- const $2 = exports;
4430
- const el = elements;
4431
- const noop2 = (v) => v;
4432
- function toPrompt(type, args, opts = {}) {
4433
- return new Promise((res, rej) => {
4434
- const p = new el[type](args);
4435
- const onAbort = opts.onAbort || noop2;
4436
- const onSubmit = opts.onSubmit || noop2;
4437
- const onExit2 = opts.onExit || noop2;
4438
- p.on("state", args.onState || noop2);
4439
- p.on("submit", (x) => res(onSubmit(x)));
4440
- p.on("exit", (x) => res(onExit2(x)));
4441
- p.on("abort", (x) => rej(onAbort(x)));
4442
- });
4443
- }
4444
- $2.text = (args) => toPrompt("TextPrompt", args);
4445
- $2.password = (args) => {
4446
- args.style = "password";
4447
- return $2.text(args);
4448
- };
4449
- $2.invisible = (args) => {
4450
- args.style = "invisible";
4451
- return $2.text(args);
4452
- };
4453
- $2.number = (args) => toPrompt("NumberPrompt", args);
4454
- $2.date = (args) => toPrompt("DatePrompt", args);
4455
- $2.confirm = (args) => toPrompt("ConfirmPrompt", args);
4456
- $2.list = (args) => {
4457
- const sep2 = args.separator || ",";
4458
- return toPrompt("TextPrompt", args, {
4459
- onSubmit: (str) => str.split(sep2).map((s) => s.trim())
4460
- });
4461
- };
4462
- $2.toggle = (args) => toPrompt("TogglePrompt", args);
4463
- $2.select = (args) => toPrompt("SelectPrompt", args);
4464
- $2.multiselect = (args) => {
4465
- args.choices = [].concat(args.choices || []);
4466
- const toSelected = (items) => items.filter((item2) => item2.selected).map((item2) => item2.value);
4467
- return toPrompt("MultiselectPrompt", args, {
4468
- onAbort: toSelected,
4469
- onSubmit: toSelected
4470
- });
4471
- };
4472
- $2.autocompleteMultiselect = (args) => {
4473
- args.choices = [].concat(args.choices || []);
4474
- const toSelected = (items) => items.filter((item2) => item2.selected).map((item2) => item2.value);
4475
- return toPrompt("AutocompleteMultiselectPrompt", args, {
4476
- onAbort: toSelected,
4477
- onSubmit: toSelected
4478
- });
4479
- };
4480
- const byTitle = (input, choices) => Promise.resolve(
4481
- choices.filter((item2) => item2.title.slice(0, input.length).toLowerCase() === input.toLowerCase())
4482
- );
4483
- $2.autocomplete = (args) => {
4484
- args.suggest = args.suggest || byTitle;
4485
- args.choices = [].concat(args.choices || []);
4486
- return toPrompt("AutocompletePrompt", args);
4487
- };
4488
- })(prompts$3);
4489
- var prompts$2 = prompts$3;
4490
- var passOn = ["suggest", "format", "onState", "validate", "onRender", "type"];
4491
- var noop = () => {
4492
- };
4493
- async function prompt(questions = [], { onSubmit = noop, onCancel = noop } = {}) {
4494
- const answers = {};
4495
- const override2 = prompt._override || {};
4496
- questions = [].concat(questions);
4497
- let answer, question, quit, name, type, lastPrompt;
4498
- const getFormattedAnswer = async (question2, answer2, skipValidation = false) => {
4499
- if (!skipValidation && question2.validate && question2.validate(answer2) !== true) {
4500
- return;
4501
- }
4502
- return question2.format ? await question2.format(answer2, answers) : answer2;
4503
- };
4504
- for (question of questions) {
4505
- ({ name, type } = question);
4506
- if (typeof type === "function") {
4507
- type = await type(answer, { ...answers }, question);
4508
- question["type"] = type;
4509
- }
4510
- if (!type) continue;
4511
- for (let key in question) {
4512
- if (passOn.includes(key)) continue;
4513
- let value = question[key];
4514
- question[key] = typeof value === "function" ? await value(answer, { ...answers }, lastPrompt) : value;
4515
- }
4516
- lastPrompt = question;
4517
- if (typeof question.message !== "string") {
4518
- throw new Error("prompt message is required");
4519
- }
4520
- ({ name, type } = question);
4521
- if (prompts$2[type] === void 0) {
4522
- throw new Error(`prompt type (${type}) is not defined`);
4523
- }
4524
- if (override2[question.name] !== void 0) {
4525
- answer = await getFormattedAnswer(question, override2[question.name]);
4526
- if (answer !== void 0) {
4527
- answers[name] = answer;
4528
- continue;
4529
- }
4530
- }
4531
- try {
4532
- answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : await prompts$2[type](question);
4533
- answers[name] = answer = await getFormattedAnswer(question, answer, true);
4534
- quit = await onSubmit(question, answer, answers);
4535
- } catch (err) {
4536
- quit = !await onCancel(question, answers);
4537
- }
4538
- if (quit) return answers;
4539
- }
4540
- return answers;
4541
- }
4542
- function getInjectedAnswer(injected, deafultValue) {
4543
- const answer = injected.shift();
4544
- if (answer instanceof Error) {
4545
- throw answer;
4546
- }
4547
- return answer === void 0 ? deafultValue : answer;
4548
- }
4549
- function inject(answers) {
4550
- prompt._injected = (prompt._injected || []).concat(answers);
4551
- }
4552
- function override(answers) {
4553
- prompt._override = Object.assign({}, answers);
4554
- }
4555
- var lib$1 = Object.assign(prompt, { prompt, prompts: prompts$2, inject, override });
4556
- var prompts = lib$1;
4557
- var prompts$1 = /* @__PURE__ */ getDefaultExportFromCjs(prompts);
4558
- var cjs = {};
4559
- var posix$1 = {};
4560
- Object.defineProperty(posix$1, "__esModule", { value: true });
4561
- posix$1.sync = posix$1.isexe = void 0;
4562
- var fs_1$1 = import_fs.default;
4563
- var promises_1$1 = import_promises2.default;
4564
- var isexe$2 = async (path2, options2 = {}) => {
4565
- const { ignoreErrors = false } = options2;
4566
- try {
4567
- return checkStat$1(await (0, promises_1$1.stat)(path2), options2);
4568
- } catch (e) {
4569
- const er = e;
4570
- if (ignoreErrors || er.code === "EACCES")
4571
- return false;
4572
- throw er;
4573
- }
4574
- };
4575
- posix$1.isexe = isexe$2;
4576
- var sync$1 = (path2, options2 = {}) => {
4577
- const { ignoreErrors = false } = options2;
4578
- try {
4579
- return checkStat$1((0, fs_1$1.statSync)(path2), options2);
4580
- } catch (e) {
4581
- const er = e;
4582
- if (ignoreErrors || er.code === "EACCES")
4583
- return false;
4584
- throw er;
4585
- }
4586
- };
4587
- posix$1.sync = sync$1;
4588
- var checkStat$1 = (stat, options2) => stat.isFile() && checkMode(stat, options2);
4589
- var checkMode = (stat, options2) => {
4590
- const myUid = options2.uid ?? process.getuid?.();
4591
- const myGroups = options2.groups ?? process.getgroups?.() ?? [];
4592
- const myGid = options2.gid ?? process.getgid?.() ?? myGroups[0];
4593
- if (myUid === void 0 || myGid === void 0) {
4594
- throw new Error("cannot get uid or gid");
4595
- }
4596
- const groups = /* @__PURE__ */ new Set([myGid, ...myGroups]);
4597
- const mod = stat.mode;
4598
- const uid = stat.uid;
4599
- const gid = stat.gid;
4600
- const u = parseInt("100", 8);
4601
- const g = parseInt("010", 8);
4602
- const o = parseInt("001", 8);
4603
- const ug = u | g;
4604
- return !!(mod & o || mod & g && groups.has(gid) || mod & u && uid === myUid || mod & ug && myUid === 0);
4605
- };
4606
- var win32 = {};
4607
- Object.defineProperty(win32, "__esModule", { value: true });
4608
- win32.sync = win32.isexe = void 0;
4609
- var fs_1 = import_fs.default;
4610
- var promises_1 = import_promises2.default;
4611
- var isexe$1 = async (path2, options2 = {}) => {
4612
- const { ignoreErrors = false } = options2;
4613
- try {
4614
- return checkStat(await (0, promises_1.stat)(path2), path2, options2);
4615
- } catch (e) {
4616
- const er = e;
4617
- if (ignoreErrors || er.code === "EACCES")
4618
- return false;
4619
- throw er;
4620
- }
4621
- };
4622
- win32.isexe = isexe$1;
4623
- var sync = (path2, options2 = {}) => {
4624
- const { ignoreErrors = false } = options2;
4625
- try {
4626
- return checkStat((0, fs_1.statSync)(path2), path2, options2);
4627
- } catch (e) {
4628
- const er = e;
4629
- if (ignoreErrors || er.code === "EACCES")
4630
- return false;
4631
- throw er;
4632
- }
4633
- };
4634
- win32.sync = sync;
4635
- var checkPathExt = (path2, options2) => {
4636
- const { pathExt = process.env.PATHEXT || "" } = options2;
4637
- const peSplit = pathExt.split(";");
4638
- if (peSplit.indexOf("") !== -1) {
4639
- return true;
4640
- }
4641
- for (let i = 0; i < peSplit.length; i++) {
4642
- const p = peSplit[i].toLowerCase();
4643
- const ext = path2.substring(path2.length - p.length).toLowerCase();
4644
- if (p && ext === p) {
4645
- return true;
4646
- }
4647
- }
4648
- return false;
4649
- };
4650
- var checkStat = (stat, path2, options2) => stat.isFile() && checkPathExt(path2, options2);
4651
- var options = {};
4652
- Object.defineProperty(options, "__esModule", { value: true });
4653
- (function(exports) {
4654
- var __createBinding = commonjsGlobal && commonjsGlobal.__createBinding || (Object.create ? function(o, m, k, k2) {
4655
- if (k2 === void 0) k2 = k;
4656
- var desc = Object.getOwnPropertyDescriptor(m, k);
4657
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4658
- desc = { enumerable: true, get: function() {
4659
- return m[k];
4660
- } };
4661
- }
4662
- Object.defineProperty(o, k2, desc);
4663
- } : function(o, m, k, k2) {
4664
- if (k2 === void 0) k2 = k;
4665
- o[k2] = m[k];
4666
- });
4667
- var __setModuleDefault = commonjsGlobal && commonjsGlobal.__setModuleDefault || (Object.create ? function(o, v) {
4668
- Object.defineProperty(o, "default", { enumerable: true, value: v });
4669
- } : function(o, v) {
4670
- o["default"] = v;
4671
- });
4672
- var __importStar = commonjsGlobal && commonjsGlobal.__importStar || function(mod) {
4673
- if (mod && mod.__esModule) return mod;
4674
- var result = {};
4675
- if (mod != null) {
4676
- for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
4677
- }
4678
- __setModuleDefault(result, mod);
4679
- return result;
4680
- };
4681
- var __exportStar = commonjsGlobal && commonjsGlobal.__exportStar || function(m, exports2) {
4682
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
4683
- };
4684
- Object.defineProperty(exports, "__esModule", { value: true });
4685
- exports.sync = exports.isexe = exports.posix = exports.win32 = void 0;
4686
- const posix2 = __importStar(posix$1);
4687
- exports.posix = posix2;
4688
- const win32$1 = __importStar(win32);
4689
- exports.win32 = win32$1;
4690
- __exportStar(options, exports);
4691
- const platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
4692
- const impl = platform === "win32" ? win32$1 : posix2;
4693
- exports.isexe = impl.isexe;
4694
- exports.sync = impl.sync;
4695
- })(cjs);
4696
- var { isexe, sync: isexeSync } = cjs;
4697
- var { join, delimiter, sep, posix } = import_path.default;
4698
- var isWindows = process.platform === "win32";
4699
- var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
4700
- var rRel = new RegExp(`^\\.${rSlash.source}`);
4701
- var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
4702
- var getPathInfo = (cmd, {
4703
- path: optPath = process.env.PATH,
4704
- pathExt: optPathExt = process.env.PATHEXT,
4705
- delimiter: optDelimiter = delimiter
4706
- }) => {
4707
- const pathEnv = cmd.match(rSlash) ? [""] : [
4708
- // windows always checks the cwd first
4709
- ...isWindows ? [process.cwd()] : [],
4710
- ...(optPath || /* istanbul ignore next: very unusual */
4711
- "").split(optDelimiter)
4712
- ];
4713
- if (isWindows) {
4714
- const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
4715
- const pathExt = pathExtExe.split(optDelimiter).flatMap((item2) => [item2, item2.toLowerCase()]);
4716
- if (cmd.includes(".") && pathExt[0] !== "") {
4717
- pathExt.unshift("");
4718
- }
4719
- return { pathEnv, pathExt, pathExtExe };
4720
- }
4721
- return { pathEnv, pathExt: [""] };
4722
- };
4723
- var getPathPart = (raw, cmd) => {
4724
- const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
4725
- const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
4726
- return prefix + join(pathPart, cmd);
4727
- };
4728
- var which = async (cmd, opt = {}) => {
4729
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
4730
- const found = [];
4731
- for (const envPart of pathEnv) {
4732
- const p = getPathPart(envPart, cmd);
4733
- for (const ext of pathExt) {
4734
- const withExt = p + ext;
4735
- const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
4736
- if (is) {
4737
- if (!opt.all) {
4738
- return withExt;
4739
- }
4740
- found.push(withExt);
4741
- }
4742
- }
4743
- }
4744
- if (opt.all && found.length) {
4745
- return found;
4746
- }
4747
- if (opt.nothrow) {
4748
- return null;
4749
- }
4750
- throw getNotFoundError(cmd);
4751
- };
4752
- var whichSync = (cmd, opt = {}) => {
4753
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
4754
- const found = [];
4755
- for (const pathEnvPart of pathEnv) {
4756
- const p = getPathPart(pathEnvPart, cmd);
4757
- for (const ext of pathExt) {
4758
- const withExt = p + ext;
4759
- const is = isexeSync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
4760
- if (is) {
4761
- if (!opt.all) {
4762
- return withExt;
4763
- }
4764
- found.push(withExt);
4765
- }
4766
- }
4767
- }
4768
- if (opt.all && found.length) {
4769
- return found;
4770
- }
4771
- if (opt.nothrow) {
4772
- return null;
4773
- }
4774
- throw getNotFoundError(cmd);
4775
- };
4776
- var lib = which;
4777
- which.sync = whichSync;
4778
- var which$1 = /* @__PURE__ */ getDefaultExportFromCjs(lib);
4779
- var CLI_TEMP_DIR = (0, import_node_path.join)(import_node_os.default.tmpdir(), "antfu-ni");
4780
- function cmdExists(cmd) {
4781
- return which$1.sync(cmd, { nothrow: true }) !== null;
4782
- }
4783
- async function detect({ autoInstall, programmatic, cwd } = {}) {
4784
- let agent = null;
4785
- let version = null;
4786
- const lockPath = await findUp(Object.keys(LOCKS), { cwd });
4787
- let packageJsonPath;
4788
- if (lockPath)
4789
- packageJsonPath = import_node_path.default.resolve(lockPath, "../package.json");
4790
- else
4791
- packageJsonPath = await findUp("package.json", { cwd });
4792
- if (packageJsonPath && import_node_fs.default.existsSync(packageJsonPath)) {
4793
- try {
4794
- const pkg = JSON.parse(import_node_fs.default.readFileSync(packageJsonPath, "utf8"));
4795
- if (typeof pkg.packageManager === "string") {
4796
- const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
4797
- version = ver;
4798
- if (name === "yarn" && Number.parseInt(ver) > 1) {
4799
- agent = "yarn@berry";
4800
- version = "berry";
4801
- } else if (name === "pnpm" && Number.parseInt(ver) < 7) {
4802
- agent = "pnpm@6";
4803
- } else if (name in AGENTS) {
4804
- agent = name;
4805
- } else if (!programmatic) {
4806
- console.warn("[ni] Unknown packageManager:", pkg.packageManager);
4807
- }
4808
- }
4809
- } catch {
4810
- }
4811
- }
4812
- if (!agent && lockPath)
4813
- agent = LOCKS[import_node_path.default.basename(lockPath)];
4814
- if (agent && !cmdExists(agent.split("@")[0]) && !programmatic) {
4815
- if (!autoInstall) {
4816
- console.warn(`[ni] Detected ${agent} but it doesn't seem to be installed.
4817
- `);
4818
- if (import_node_process.default.env.CI)
4819
- import_node_process.default.exit(1);
4820
- const link = terminalLink(agent, INSTALL_PAGE[agent]);
4821
- const { tryInstall } = await prompts$1({
4822
- name: "tryInstall",
4823
- type: "confirm",
4824
- message: `Would you like to globally install ${link}?`
4825
- });
4826
- if (!tryInstall)
4827
- import_node_process.default.exit(1);
4828
- }
4829
- await execaCommand(`npm i -g ${agent.split("@")[0]}${version ? `@${version}` : ""}`, { stdio: "inherit", cwd });
4830
- }
4831
- return agent;
4832
- }
4833
- var customRcPath = import_node_process.default.env.NI_CONFIG_FILE;
4834
- var home = import_node_process.default.platform === "win32" ? import_node_process.default.env.USERPROFILE : import_node_process.default.env.HOME;
4835
- var defaultRcPath = import_node_path.default.join(home || "~/", ".nirc");
4836
- var UnsupportedCommand = class extends Error {
4837
- constructor({ agent, command }) {
4838
- super(`Command "${command}" is not support by agent "${agent}"`);
4839
- }
4840
- };
4841
- function getCommand(agent, command, args = []) {
4842
- if (!(agent in AGENTS))
4843
- throw new Error(`Unsupported agent "${agent}"`);
4844
- const c2 = AGENTS[agent][command];
4845
- if (typeof c2 === "function")
4846
- return c2(args);
4847
- if (!c2)
4848
- throw new UnsupportedCommand({ agent, command });
4849
- const quote = (arg) => !arg.startsWith("--") && arg.includes(" ") ? JSON.stringify(arg) : arg;
4850
- return c2.replace("{0}", args.map(quote).join(" ")).trim();
4851
- }
4852
- var FORCE_COLOR;
4853
- var NODE_DISABLE_COLORS;
4854
- var NO_COLOR;
4855
- var TERM;
4856
- var isTTY = true;
4857
- if (typeof process !== "undefined") {
4858
- ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
4859
- isTTY = process.stdout && process.stdout.isTTY;
4860
- }
4861
- var $ = {
4862
- enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY),
4863
- // modifiers
4864
- reset: init(0, 0),
4865
- bold: init(1, 22),
4866
- dim: init(2, 22),
4867
- italic: init(3, 23),
4868
- underline: init(4, 24),
4869
- inverse: init(7, 27),
4870
- hidden: init(8, 28),
4871
- strikethrough: init(9, 29),
4872
- // colors
4873
- black: init(30, 39),
4874
- red: init(31, 39),
4875
- green: init(32, 39),
4876
- yellow: init(33, 39),
4877
- blue: init(34, 39),
4878
- magenta: init(35, 39),
4879
- cyan: init(36, 39),
4880
- white: init(37, 39),
4881
- gray: init(90, 39),
4882
- grey: init(90, 39),
4883
- // background colors
4884
- bgBlack: init(40, 49),
4885
- bgRed: init(41, 49),
4886
- bgGreen: init(42, 49),
4887
- bgYellow: init(43, 49),
4888
- bgBlue: init(44, 49),
4889
- bgMagenta: init(45, 49),
4890
- bgCyan: init(46, 49),
4891
- bgWhite: init(47, 49)
4892
- };
4893
- function run$1(arr, str) {
4894
- let i = 0, tmp, beg = "", end = "";
4895
- for (; i < arr.length; i++) {
4896
- tmp = arr[i];
4897
- beg += tmp.open;
4898
- end += tmp.close;
4899
- if (!!~str.indexOf(tmp.close)) {
4900
- str = str.replace(tmp.rgx, tmp.close + tmp.open);
4901
- }
4902
- }
4903
- return beg + str + end;
4904
- }
4905
- function chain(has, keys) {
4906
- let ctx = { has, keys };
4907
- ctx.reset = $.reset.bind(ctx);
4908
- ctx.bold = $.bold.bind(ctx);
4909
- ctx.dim = $.dim.bind(ctx);
4910
- ctx.italic = $.italic.bind(ctx);
4911
- ctx.underline = $.underline.bind(ctx);
4912
- ctx.inverse = $.inverse.bind(ctx);
4913
- ctx.hidden = $.hidden.bind(ctx);
4914
- ctx.strikethrough = $.strikethrough.bind(ctx);
4915
- ctx.black = $.black.bind(ctx);
4916
- ctx.red = $.red.bind(ctx);
4917
- ctx.green = $.green.bind(ctx);
4918
- ctx.yellow = $.yellow.bind(ctx);
4919
- ctx.blue = $.blue.bind(ctx);
4920
- ctx.magenta = $.magenta.bind(ctx);
4921
- ctx.cyan = $.cyan.bind(ctx);
4922
- ctx.white = $.white.bind(ctx);
4923
- ctx.gray = $.gray.bind(ctx);
4924
- ctx.grey = $.grey.bind(ctx);
4925
- ctx.bgBlack = $.bgBlack.bind(ctx);
4926
- ctx.bgRed = $.bgRed.bind(ctx);
4927
- ctx.bgGreen = $.bgGreen.bind(ctx);
4928
- ctx.bgYellow = $.bgYellow.bind(ctx);
4929
- ctx.bgBlue = $.bgBlue.bind(ctx);
4930
- ctx.bgMagenta = $.bgMagenta.bind(ctx);
4931
- ctx.bgCyan = $.bgCyan.bind(ctx);
4932
- ctx.bgWhite = $.bgWhite.bind(ctx);
4933
- return ctx;
4934
- }
4935
- function init(open, close) {
4936
- let blk = {
4937
- open: `\x1B[${open}m`,
4938
- close: `\x1B[${close}m`,
4939
- rgx: new RegExp(`\\x1b\\[${close}m`, "g")
4940
- };
4941
- return function(txt) {
4942
- if (this !== void 0 && this.has !== void 0) {
4943
- !!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
4944
- return txt === void 0 ? this : $.enabled ? run$1(this.keys, txt + "") : txt + "";
4945
- }
4946
- return txt === void 0 ? chain([open], [blk]) : $.enabled ? run$1([blk], txt + "") : txt + "";
4947
- };
4948
- }