vitest 2.1.0-beta.6 → 2.1.0

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 (56) hide show
  1. package/LICENSE.md +52 -342
  2. package/dist/browser.d.ts +4 -2
  3. package/dist/browser.js +1 -1
  4. package/dist/chunks/{RandomSequencer.CjkAy_bL.js → RandomSequencer.Bh5-tlNJ.js} +10 -37
  5. package/dist/chunks/{base.BH-FAiX7.js → base.BlXpj3e_.js} +1 -29
  6. package/dist/chunks/{base.B-9RAXb6.js → base.CsQmmYBA.js} +2 -4
  7. package/dist/chunks/{cac.BZlOqtiQ.js → cac.Ce8UWvQp.js} +25 -16
  8. package/dist/chunks/{cli-api.B-2f6g4d.js → cli-api.KmLFBnKP.js} +2778 -3488
  9. package/dist/chunks/{creator.D0TxjnLa.js → creator.zfBZSJzo.js} +8 -11
  10. package/dist/chunks/{execute.DT9BA6zp.js → execute._eQQfgI8.js} +322 -232
  11. package/dist/chunks/{git.ZtkbKc8u.js → git.B5SDxu-n.js} +5 -5
  12. package/dist/chunks/{globals.Br36EZIp.js → globals.C03P0O1a.js} +3 -3
  13. package/dist/chunks/{index.CM5UI-4O.js → index.Bn75ITYg.js} +3 -3
  14. package/dist/chunks/index.CPD77dLA.js +133 -0
  15. package/dist/chunks/{index.dWDhoZDV.js → index.DkN6V87F.js} +1 -1
  16. package/dist/chunks/{index.m3Xip5Zz.js → index.iyKRMe3s.js} +1 -1
  17. package/dist/chunks/{index.C4LZENmc.js → index.zPibhCkV.js} +43 -45
  18. package/dist/chunks/mocker.cRtM890J.d.ts +17 -0
  19. package/dist/chunks/{reporters.B0Ao6Zu1.d.ts → reporters.WnPwkmgA.d.ts} +30 -22
  20. package/dist/chunks/{resolveConfig.C0vpvVRF.js → resolveConfig.-K5hHm0S.js} +19 -6
  21. package/dist/chunks/{runBaseTests.Cf8lGnUq.js → runBaseTests.9YDrdSI4.js} +6 -6
  22. package/dist/chunks/{setup-common.B7uEQsGB.js → setup-common.DV1PI68g.js} +1 -1
  23. package/dist/chunks/{utils.C3_cBsyn.js → utils.Cn0zI1t3.js} +16 -3
  24. package/dist/chunks/{utils.DO38lwfj.js → utils.Dbnmsfq1.js} +1 -1
  25. package/dist/chunks/{vi.DBepMgvg.js → vi.D6IHiKAI.js} +40 -46
  26. package/dist/chunks/{vite.Bvz2vSw0.d.ts → vite.D2yAwzwa.d.ts} +1 -1
  27. package/dist/chunks/{vm.kl9T_5ai.js → vm.CPXwWp4C.js} +1 -2
  28. package/dist/chunks/{worker.DTM-0OlZ.d.ts → worker.Bws9Zuxu.d.ts} +1 -1
  29. package/dist/chunks/{worker.CTdJUeeB.d.ts → worker.CmPmTxgH.d.ts} +1 -14
  30. package/dist/cli.js +2 -2
  31. package/dist/config.d.ts +2 -2
  32. package/dist/coverage.d.ts +1 -1
  33. package/dist/coverage.js +4 -4
  34. package/dist/execute.d.ts +12 -13
  35. package/dist/execute.js +3 -2
  36. package/dist/index.d.ts +17 -15
  37. package/dist/index.js +4 -4
  38. package/dist/mocker.d.ts +1 -0
  39. package/dist/mocker.js +1 -0
  40. package/dist/node.d.ts +15 -7
  41. package/dist/node.js +18 -16
  42. package/dist/reporters.d.ts +1 -1
  43. package/dist/reporters.js +5 -5
  44. package/dist/runners.js +2 -2
  45. package/dist/utils.d.ts +1 -0
  46. package/dist/worker.js +3 -2
  47. package/dist/workers/forks.js +5 -4
  48. package/dist/workers/runVmTests.js +5 -5
  49. package/dist/workers/threads.js +5 -4
  50. package/dist/workers/vmForks.js +4 -4
  51. package/dist/workers/vmThreads.js +4 -4
  52. package/dist/workers.d.ts +2 -2
  53. package/dist/workers.js +6 -5
  54. package/mocker.d.ts +1 -0
  55. package/package.json +22 -17
  56. package/dist/chunks/index.CWhwfxXK.js +0 -835
@@ -1,835 +0,0 @@
1
- import W, { existsSync, promises } from 'fs';
2
- import p, { normalize, delimiter, resolve, dirname } from 'path';
3
- import process$1, { cwd } from 'process';
4
- import { fileURLToPath } from 'url';
5
- import { createRequire } from 'node:module';
6
- import { spawn } from 'child_process';
7
- import { PassThrough } from 'stream';
8
- import require$$0 from 'readline';
9
-
10
- const require = createRequire(import.meta.url);
11
- var Ct = Object.create;
12
- var R = Object.defineProperty;
13
- var St = Object.getOwnPropertyDescriptor;
14
- var kt = Object.getOwnPropertyNames;
15
- var Tt = Object.getPrototypeOf, At = Object.prototype.hasOwnProperty;
16
- var m = /* @__PURE__ */ ((t) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(t, {
17
- get: (e, n) => (typeof require < "u" ? require : e)[n]
18
- }) : t)(function(t) {
19
- if (typeof require < "u") return require.apply(this, arguments);
20
- throw Error('Dynamic require of "' + t + '" is not supported');
21
- });
22
- var l = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports);
23
- var Rt = (t, e, n, r) => {
24
- if (e && typeof e == "object" || typeof e == "function")
25
- for (let s of kt(e))
26
- !At.call(t, s) && s !== n && R(t, s, { get: () => e[s], enumerable: !(r = St(e, s)) || r.enumerable });
27
- return t;
28
- };
29
- var $t = (t, e, n) => (n = t != null ? Ct(Tt(t)) : {}, Rt(
30
- // If the importer is in node compatibility mode or this is not an ESM
31
- // file that has been converted to a CommonJS file using a Babel-
32
- // compatible transform (i.e. "__esModule" has not been set), then set
33
- // "default" to the CommonJS "module.exports" for node compatibility.
34
- R(n, "default", { value: t, enumerable: !0 }) ,
35
- t
36
- ));
37
-
38
- // node_modules/isexe/windows.js
39
- var z = l((Ce, H) => {
40
- H.exports = F;
41
- F.sync = zt;
42
- var L = m("fs");
43
- function Ht(t, e) {
44
- var n = e.pathExt !== void 0 ? e.pathExt : process.env.PATHEXT;
45
- if (!n || (n = n.split(";"), n.indexOf("") !== -1))
46
- return !0;
47
- for (var r = 0; r < n.length; r++) {
48
- var s = n[r].toLowerCase();
49
- if (s && t.substr(-s.length).toLowerCase() === s)
50
- return !0;
51
- }
52
- return !1;
53
- }
54
- function j(t, e, n) {
55
- return !t.isSymbolicLink() && !t.isFile() ? !1 : Ht(e, n);
56
- }
57
- function F(t, e, n) {
58
- L.stat(t, function(r, s) {
59
- n(r, r ? !1 : j(s, t, e));
60
- });
61
- }
62
- function zt(t, e) {
63
- return j(L.statSync(t), t, e);
64
- }
65
- });
66
-
67
- // node_modules/isexe/mode.js
68
- var B = l((Se, M) => {
69
- M.exports = D;
70
- D.sync = Wt;
71
- var W = m("fs");
72
- function D(t, e, n) {
73
- W.stat(t, function(r, s) {
74
- n(r, r ? !1 : K(s, e));
75
- });
76
- }
77
- function Wt(t, e) {
78
- return K(W.statSync(t), e);
79
- }
80
- function K(t, e) {
81
- return t.isFile() && Dt(t, e);
82
- }
83
- function Dt(t, e) {
84
- var n = t.mode, r = t.uid, s = t.gid, o = e.uid !== void 0 ? e.uid : process.getuid && process.getuid(), i = e.gid !== void 0 ? e.gid : process.getgid && process.getgid(), u = parseInt("100", 8), c = parseInt("010", 8), a = parseInt("001", 8), f = u | c, p = n & a || n & c && s === i || n & u && r === o || n & f && o === 0;
85
- return p;
86
- }
87
- });
88
-
89
- // node_modules/isexe/index.js
90
- var G = l((Te, X) => {
91
- m("fs"); var w;
92
- process.platform === "win32" || global.TESTING_WINDOWS ? w = z() : w = B();
93
- X.exports = b;
94
- b.sync = Kt;
95
- function b(t, e, n) {
96
- if (typeof e == "function" && (n = e, e = {}), !n) {
97
- if (typeof Promise != "function")
98
- throw new TypeError("callback not provided");
99
- return new Promise(function(r, s) {
100
- b(t, e || {}, function(o, i) {
101
- o ? s(o) : r(i);
102
- });
103
- });
104
- }
105
- w(t, e || {}, function(r, s) {
106
- r && (r.code === "EACCES" || e && e.ignoreErrors) && (r = null, s = !1), n(r, s);
107
- });
108
- }
109
- function Kt(t, e) {
110
- try {
111
- return w.sync(t, e || {});
112
- } catch (n) {
113
- if (e && e.ignoreErrors || n.code === "EACCES")
114
- return !1;
115
- throw n;
116
- }
117
- }
118
- });
119
-
120
- // node_modules/which/which.js
121
- var tt = l((Ae, Z) => {
122
- var g = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", U = m("path"), Mt = g ? ";" : ":", Y = G(), V = (t) => Object.assign(new Error(`not found: ${t}`), { code: "ENOENT" }), J = (t, e) => {
123
- let n = e.colon || Mt, r = t.match(/\//) || g && t.match(/\\/) ? [""] : [
124
- // windows always checks the cwd first
125
- ...g ? [process.cwd()] : [],
126
- ...(e.path || process.env.PATH || /* istanbul ignore next: very unusual */
127
- "").split(n)
128
- ], s = g ? e.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "", o = g ? s.split(n) : [""];
129
- return g && t.indexOf(".") !== -1 && o[0] !== "" && o.unshift(""), {
130
- pathEnv: r,
131
- pathExt: o,
132
- pathExtExe: s
133
- };
134
- }, Q = (t, e, n) => {
135
- typeof e == "function" && (n = e, e = {}), e || (e = {});
136
- let { pathEnv: r, pathExt: s, pathExtExe: o } = J(t, e), i = [], u = (a) => new Promise((f, p) => {
137
- if (a === r.length)
138
- return e.all && i.length ? f(i) : p(V(t));
139
- let d = r[a], v = /^".*"$/.test(d) ? d.slice(1, -1) : d, h = U.join(v, t), x = !v && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + h : h;
140
- f(c(x, a, 0));
141
- }), c = (a, f, p) => new Promise((d, v) => {
142
- if (p === s.length)
143
- return d(u(f + 1));
144
- let h = s[p];
145
- Y(a + h, { pathExt: o }, (x, Ot) => {
146
- if (!x && Ot)
147
- if (e.all)
148
- i.push(a + h);
149
- else
150
- return d(a + h);
151
- return d(c(a, f, p + 1));
152
- });
153
- });
154
- return n ? u(0).then((a) => n(null, a), n) : u(0);
155
- }, Bt = (t, e) => {
156
- e = e || {};
157
- let { pathEnv: n, pathExt: r, pathExtExe: s } = J(t, e), o = [];
158
- for (let i = 0; i < n.length; i++) {
159
- let u = n[i], c = /^".*"$/.test(u) ? u.slice(1, -1) : u, a = U.join(c, t), f = !c && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + a : a;
160
- for (let p = 0; p < r.length; p++) {
161
- let d = f + r[p];
162
- try {
163
- if (Y.sync(d, { pathExt: s }))
164
- if (e.all)
165
- o.push(d);
166
- else
167
- return d;
168
- } catch {
169
- }
170
- }
171
- }
172
- if (e.all && o.length)
173
- return o;
174
- if (e.nothrow)
175
- return null;
176
- throw V(t);
177
- };
178
- Z.exports = Q;
179
- Q.sync = Bt;
180
- });
181
-
182
- // node_modules/path-key/index.js
183
- var nt = l((Re, y) => {
184
- var et = (t = {}) => {
185
- let e = t.env || process.env;
186
- return (t.platform || process.platform) !== "win32" ? "PATH" : Object.keys(e).reverse().find((r) => r.toUpperCase() === "PATH") || "Path";
187
- };
188
- y.exports = et;
189
- y.exports.default = et;
190
- });
191
-
192
- // node_modules/cross-spawn/lib/util/resolveCommand.js
193
- var it = l(($e, ot) => {
194
- var rt = m("path"), Xt = tt(), Gt = nt();
195
- function st(t, e) {
196
- let n = t.options.env || process.env, r = process.cwd(), s = t.options.cwd != null, o = s && process.chdir !== void 0 && !process.chdir.disabled;
197
- if (o)
198
- try {
199
- process.chdir(t.options.cwd);
200
- } catch {
201
- }
202
- let i;
203
- try {
204
- i = Xt.sync(t.command, {
205
- path: n[Gt({ env: n })],
206
- pathExt: e ? rt.delimiter : void 0
207
- });
208
- } catch {
209
- } finally {
210
- o && process.chdir(r);
211
- }
212
- return i && (i = rt.resolve(s ? t.options.cwd : "", i)), i;
213
- }
214
- function Ut(t) {
215
- return st(t) || st(t, !0);
216
- }
217
- ot.exports = Ut;
218
- });
219
-
220
- // node_modules/cross-spawn/lib/util/escape.js
221
- var ct = l((Ne, P) => {
222
- var _ = /([()\][%!^"`<>&|;, *?])/g;
223
- function Yt(t) {
224
- return t = t.replace(_, "^$1"), t;
225
- }
226
- function Vt(t, e) {
227
- return t = `${t}`, t = t.replace(/(\\*)"/g, '$1$1\\"'), t = t.replace(/(\\*)$/, "$1$1"), t = `"${t}"`, t = t.replace(_, "^$1"), e && (t = t.replace(_, "^$1")), t;
228
- }
229
- P.exports.command = Yt;
230
- P.exports.argument = Vt;
231
- });
232
-
233
- // node_modules/shebang-regex/index.js
234
- var ut = l((qe, at) => {
235
- at.exports = /^#!(.*)/;
236
- });
237
-
238
- // node_modules/shebang-command/index.js
239
- var pt = l((Ie, lt) => {
240
- var Jt = ut();
241
- lt.exports = (t = "") => {
242
- let e = t.match(Jt);
243
- if (!e)
244
- return null;
245
- let [n, r] = e[0].replace(/#! ?/, "").split(" "), s = n.split("/").pop();
246
- return s === "env" ? r : r ? `${s} ${r}` : s;
247
- };
248
- });
249
-
250
- // node_modules/cross-spawn/lib/util/readShebang.js
251
- var ft = l((Le, dt) => {
252
- var O = m("fs"), Qt = pt();
253
- function Zt(t) {
254
- let n = Buffer.alloc(150), r;
255
- try {
256
- r = O.openSync(t, "r"), O.readSync(r, n, 0, 150, 0), O.closeSync(r);
257
- } catch {
258
- }
259
- return Qt(n.toString());
260
- }
261
- dt.exports = Zt;
262
- });
263
-
264
- // node_modules/cross-spawn/lib/parse.js
265
- var Et = l((je, gt) => {
266
- var te = m("path"), mt = it(), ht = ct(), ee = ft(), ne = process.platform === "win32", re = /\.(?:com|exe)$/i, se = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
267
- function oe(t) {
268
- t.file = mt(t);
269
- let e = t.file && ee(t.file);
270
- return e ? (t.args.unshift(t.file), t.command = e, mt(t)) : t.file;
271
- }
272
- function ie(t) {
273
- if (!ne)
274
- return t;
275
- let e = oe(t), n = !re.test(e);
276
- if (t.options.forceShell || n) {
277
- let r = se.test(e);
278
- t.command = te.normalize(t.command), t.command = ht.command(t.command), t.args = t.args.map((o) => ht.argument(o, r));
279
- let s = [t.command].concat(t.args).join(" ");
280
- t.args = ["/d", "/s", "/c", `"${s}"`], t.command = process.env.comspec || "cmd.exe", t.options.windowsVerbatimArguments = !0;
281
- }
282
- return t;
283
- }
284
- function ce(t, e, n) {
285
- e && !Array.isArray(e) && (n = e, e = null), e = e ? e.slice(0) : [], n = Object.assign({}, n);
286
- let r = {
287
- command: t,
288
- args: e,
289
- options: n,
290
- file: void 0,
291
- original: {
292
- command: t,
293
- args: e
294
- }
295
- };
296
- return n.shell ? r : ie(r);
297
- }
298
- gt.exports = ce;
299
- });
300
-
301
- // node_modules/cross-spawn/lib/enoent.js
302
- var xt = l((Fe, wt) => {
303
- var C = process.platform === "win32";
304
- function S(t, e) {
305
- return Object.assign(new Error(`${e} ${t.command} ENOENT`), {
306
- code: "ENOENT",
307
- errno: "ENOENT",
308
- syscall: `${e} ${t.command}`,
309
- path: t.command,
310
- spawnargs: t.args
311
- });
312
- }
313
- function ae(t, e) {
314
- if (!C)
315
- return;
316
- let n = t.emit;
317
- t.emit = function(r, s) {
318
- if (r === "exit") {
319
- let o = vt(s, e);
320
- if (o)
321
- return n.call(t, "error", o);
322
- }
323
- return n.apply(t, arguments);
324
- };
325
- }
326
- function vt(t, e) {
327
- return C && t === 1 && !e.file ? S(e.original, "spawn") : null;
328
- }
329
- function ue(t, e) {
330
- return C && t === 1 && !e.file ? S(e.original, "spawnSync") : null;
331
- }
332
- wt.exports = {
333
- hookChildProcess: ae,
334
- verifyENOENT: vt,
335
- verifyENOENTSync: ue,
336
- notFoundError: S
337
- };
338
- });
339
-
340
- // node_modules/cross-spawn/index.js
341
- var _t = l((He, E) => {
342
- var bt = m("child_process"), k = Et(), T = xt();
343
- function yt(t, e, n) {
344
- let r = k(t, e, n), s = bt.spawn(r.command, r.args, r.options);
345
- return T.hookChildProcess(s, r), s;
346
- }
347
- function le(t, e, n) {
348
- let r = k(t, e, n), s = bt.spawnSync(r.command, r.args, r.options);
349
- return s.error = s.error || T.verifyENOENTSync(s.status, r), s;
350
- }
351
- E.exports = yt;
352
- E.exports.spawn = yt;
353
- E.exports.sync = le;
354
- E.exports._parse = k;
355
- E.exports._enoent = T;
356
- });
357
- var It = /^path$/i, N = { key: "PATH", value: "" };
358
- function Lt(t) {
359
- for (let e in t) {
360
- if (!Object.prototype.hasOwnProperty.call(t, e) || !It.test(e))
361
- continue;
362
- let n = t[e];
363
- return n ? { key: e, value: n } : N;
364
- }
365
- return N;
366
- }
367
- function jt(t, e) {
368
- let n = e.value.split(delimiter), r = t, s;
369
- do
370
- n.push(resolve(r, "node_modules", ".bin")), s = r, r = dirname(r);
371
- while (r !== s);
372
- return { key: e.key, value: n.join(delimiter) };
373
- }
374
- function q(t, e) {
375
- let n = {
376
- ...process.env,
377
- ...e
378
- }, r = jt(t, Lt(n));
379
- return n[r.key] = r.value, n;
380
- }
381
- var I = (t) => {
382
- let e = t.length, n = new PassThrough(), r = () => {
383
- --e === 0 && n.emit("end");
384
- };
385
- for (let s of t)
386
- s.pipe(n, { end: !1 }), s.on("end", r);
387
- return n;
388
- };
389
-
390
- // src/main.ts
391
- var Pt = $t(_t());
392
- var he = {
393
- timeout: 4e3,
394
- persist: !1
395
- }, ge = {
396
- windowsHide: !0
397
- };
398
- function Ee(t, e) {
399
- return {
400
- command: normalize(t),
401
- args: e ?? []
402
- };
403
- }
404
- function ve(t) {
405
- let e = new AbortController();
406
- for (let n of t) {
407
- if (n.aborted)
408
- return e.abort(), n;
409
- let r = () => {
410
- e.abort(n.reason);
411
- };
412
- n.addEventListener("abort", r, {
413
- signal: e.signal
414
- });
415
- }
416
- return e.signal;
417
- }
418
- var A = class {
419
- _process;
420
- _aborted = !1;
421
- _options;
422
- _command;
423
- _args;
424
- _resolveClose;
425
- _processClosed;
426
- _thrownError;
427
- get process() {
428
- return this._process;
429
- }
430
- get pid() {
431
- return this._process?.pid;
432
- }
433
- get exitCode() {
434
- if (this._process && this._process.exitCode !== null)
435
- return this._process.exitCode;
436
- }
437
- constructor(e, n, r) {
438
- this._options = {
439
- ...he,
440
- ...r
441
- }, this._command = e, this._args = n ?? [], this._processClosed = new Promise((s) => {
442
- this._resolveClose = s;
443
- });
444
- }
445
- kill(e) {
446
- return this._process?.kill(e) === !0;
447
- }
448
- get aborted() {
449
- return this._aborted;
450
- }
451
- get killed() {
452
- return this._process?.killed === !0;
453
- }
454
- pipe(e, n, r) {
455
- return xe(e, n, {
456
- ...r,
457
- stdin: this
458
- });
459
- }
460
- async *[Symbol.asyncIterator]() {
461
- let e = this._process;
462
- if (!e)
463
- return;
464
- let n = [];
465
- this._streamErr && n.push(this._streamErr), this._streamOut && n.push(this._streamOut);
466
- let r = I(n), s = require$$0.createInterface({
467
- input: r
468
- });
469
- for await (let o of s)
470
- yield o.toString();
471
- if (await this._processClosed, e.removeAllListeners(), this._thrownError)
472
- throw this._thrownError;
473
- }
474
- async _waitForOutput() {
475
- let e = this._process;
476
- if (!e)
477
- throw new Error("No process was started");
478
- let n = "", r = "";
479
- if (this._streamErr)
480
- for await (let o of this._streamErr)
481
- n += o.toString();
482
- if (this._streamOut)
483
- for await (let o of this._streamOut)
484
- r += o.toString();
485
- if (await this._processClosed, this._options?.stdin && await this._options.stdin, e.removeAllListeners(), this._thrownError)
486
- throw this._thrownError;
487
- return {
488
- stderr: n,
489
- stdout: r
490
- };
491
- }
492
- then(e, n) {
493
- return this._waitForOutput().then(e, n);
494
- }
495
- _streamOut;
496
- _streamErr;
497
- spawn() {
498
- let e = cwd(), n = this._options, r = {
499
- ...ge,
500
- ...n.nodeOptions
501
- }, s = [];
502
- this._resetState(), n.timeout !== void 0 && s.push(AbortSignal.timeout(n.timeout)), n.signal !== void 0 && s.push(n.signal), n.persist === !0 && (r.detached = !0), s.length > 0 && (r.signal = ve(s)), r.env = q(e, r.env);
503
- let { command: o, args: i } = Ee(this._command, this._args), u = (0, Pt._parse)(o, i, r), c = spawn(
504
- u.command,
505
- u.args,
506
- u.options
507
- );
508
- if (c.stderr && (this._streamErr = c.stderr), c.stdout && (this._streamOut = c.stdout), this._process = c, c.once("error", this._onError), c.once("close", this._onClose), n.stdin !== void 0 && c.stdin && n.stdin.process) {
509
- let { stdout: a } = n.stdin.process;
510
- a && a.pipe(c.stdin);
511
- }
512
- }
513
- _resetState() {
514
- this._aborted = !1, this._processClosed = new Promise((e) => {
515
- this._resolveClose = e;
516
- }), this._thrownError = void 0;
517
- }
518
- _onError = (e) => {
519
- if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
520
- this._aborted = !0;
521
- return;
522
- }
523
- this._thrownError = e;
524
- };
525
- _onClose = () => {
526
- this._resolveClose && this._resolveClose();
527
- };
528
- }, we = (t, e, n) => {
529
- let r = new A(t, e, n);
530
- return r.spawn(), r;
531
- }, xe = we;
532
-
533
- var __defProp = Object.defineProperty;
534
- var __typeError = (msg) => {
535
- throw TypeError(msg);
536
- };
537
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
538
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
539
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
540
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
541
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
542
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
543
- var __privateWrapper = (obj, member, setter, getter) => ({
544
- set _(value) {
545
- __privateSet(obj, member, value);
546
- },
547
- get _() {
548
- return __privateGet(obj, member, getter);
549
- }
550
- });
551
-
552
- // node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
553
- var Node = class {
554
- constructor(value) {
555
- __publicField(this, "value");
556
- __publicField(this, "next");
557
- this.value = value;
558
- }
559
- };
560
- var _head, _tail, _size;
561
- var Queue = class {
562
- constructor() {
563
- __privateAdd(this, _head);
564
- __privateAdd(this, _tail);
565
- __privateAdd(this, _size);
566
- this.clear();
567
- }
568
- enqueue(value) {
569
- const node = new Node(value);
570
- if (__privateGet(this, _head)) {
571
- __privateGet(this, _tail).next = node;
572
- __privateSet(this, _tail, node);
573
- } else {
574
- __privateSet(this, _head, node);
575
- __privateSet(this, _tail, node);
576
- }
577
- __privateWrapper(this, _size)._++;
578
- }
579
- dequeue() {
580
- const current = __privateGet(this, _head);
581
- if (!current) {
582
- return;
583
- }
584
- __privateSet(this, _head, __privateGet(this, _head).next);
585
- __privateWrapper(this, _size)._--;
586
- return current.value;
587
- }
588
- clear() {
589
- __privateSet(this, _head, void 0);
590
- __privateSet(this, _tail, void 0);
591
- __privateSet(this, _size, 0);
592
- }
593
- get size() {
594
- return __privateGet(this, _size);
595
- }
596
- *[Symbol.iterator]() {
597
- let current = __privateGet(this, _head);
598
- while (current) {
599
- yield current.value;
600
- current = current.next;
601
- }
602
- }
603
- };
604
- _head = new WeakMap();
605
- _tail = new WeakMap();
606
- _size = new WeakMap();
607
-
608
- // node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
609
- function pLimit(concurrency) {
610
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
611
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
612
- }
613
- const queue = new Queue();
614
- let activeCount = 0;
615
- const next = () => {
616
- activeCount--;
617
- if (queue.size > 0) {
618
- queue.dequeue()();
619
- }
620
- };
621
- const run = async (fn, resolve2, args) => {
622
- activeCount++;
623
- const result = (async () => fn(...args))();
624
- resolve2(result);
625
- try {
626
- await result;
627
- } catch {
628
- }
629
- next();
630
- };
631
- const enqueue = (fn, resolve2, args) => {
632
- queue.enqueue(run.bind(void 0, fn, resolve2, args));
633
- (async () => {
634
- await Promise.resolve();
635
- if (activeCount < concurrency && queue.size > 0) {
636
- queue.dequeue()();
637
- }
638
- })();
639
- };
640
- const generator = (fn, ...args) => new Promise((resolve2) => {
641
- enqueue(fn, resolve2, args);
642
- });
643
- Object.defineProperties(generator, {
644
- activeCount: {
645
- get: () => activeCount
646
- },
647
- pendingCount: {
648
- get: () => queue.size
649
- },
650
- clearQueue: {
651
- value: () => {
652
- queue.clear();
653
- }
654
- }
655
- });
656
- return generator;
657
- }
658
-
659
- // node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
660
- var EndError = class extends Error {
661
- constructor(value) {
662
- super();
663
- this.value = value;
664
- }
665
- };
666
- var testElement = async (element, tester) => tester(await element);
667
- var finder = async (element) => {
668
- const values = await Promise.all(element);
669
- if (values[1] === true) {
670
- throw new EndError(values[0]);
671
- }
672
- return false;
673
- };
674
- async function pLocate(iterable, tester, {
675
- concurrency = Number.POSITIVE_INFINITY,
676
- preserveOrder = true
677
- } = {}) {
678
- const limit = pLimit(concurrency);
679
- const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
680
- const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
681
- try {
682
- await Promise.all(items.map((element) => checkLimit(finder, element)));
683
- } catch (error) {
684
- if (error instanceof EndError) {
685
- return error.value;
686
- }
687
- throw error;
688
- }
689
- }
690
-
691
- // node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
692
- var typeMappings = {
693
- directory: "isDirectory",
694
- file: "isFile"
695
- };
696
- function checkType(type) {
697
- if (Object.hasOwnProperty.call(typeMappings, type)) {
698
- return;
699
- }
700
- throw new Error(`Invalid type specified: ${type}`);
701
- }
702
- var matchType = (type, stat) => stat[typeMappings[type]]();
703
- var toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
704
- async function locatePath(paths, {
705
- cwd = process$1.cwd(),
706
- type = "file",
707
- allowSymlinks = true,
708
- concurrency,
709
- preserveOrder
710
- } = {}) {
711
- checkType(type);
712
- cwd = toPath(cwd);
713
- const statFunction = allowSymlinks ? promises.stat : promises.lstat;
714
- return pLocate(paths, async (path_) => {
715
- try {
716
- const stat = await statFunction(p.resolve(cwd, path_));
717
- return matchType(type, stat);
718
- } catch {
719
- return false;
720
- }
721
- }, { concurrency, preserveOrder });
722
- }
723
- function toPath2(urlOrPath) {
724
- return urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
725
- }
726
-
727
- // node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
728
- var findUpStop = Symbol("findUpStop");
729
- async function findUpMultiple(name, options = {}) {
730
- let directory = p.resolve(toPath2(options.cwd) ?? "");
731
- const { root } = p.parse(directory);
732
- const stopAt = p.resolve(directory, toPath2(options.stopAt ?? root));
733
- const limit = options.limit ?? Number.POSITIVE_INFINITY;
734
- const paths = [name].flat();
735
- const runMatcher = async (locateOptions) => {
736
- if (typeof name !== "function") {
737
- return locatePath(paths, locateOptions);
738
- }
739
- const foundPath = await name(locateOptions.cwd);
740
- if (typeof foundPath === "string") {
741
- return locatePath([foundPath], locateOptions);
742
- }
743
- return foundPath;
744
- };
745
- const matches = [];
746
- while (true) {
747
- const foundPath = await runMatcher({ ...options, cwd: directory });
748
- if (foundPath === findUpStop) {
749
- break;
750
- }
751
- if (foundPath) {
752
- matches.push(p.resolve(directory, foundPath));
753
- }
754
- if (directory === stopAt || matches.length >= limit) {
755
- break;
756
- }
757
- directory = p.dirname(directory);
758
- }
759
- return matches;
760
- }
761
- async function findUp(name, options = {}) {
762
- const matches = await findUpMultiple(name, { ...options, limit: 1 });
763
- return matches[0];
764
- }
765
-
766
- // src/detect.ts
767
- var AGENTS = ["pnpm", "yarn", "npm", "pnpm@6", "yarn@berry", "bun"];
768
- var LOCKS = {
769
- "bun.lockb": "bun",
770
- "pnpm-lock.yaml": "pnpm",
771
- "yarn.lock": "yarn",
772
- "package-lock.json": "npm",
773
- "npm-shrinkwrap.json": "npm"
774
- };
775
- async function detectPackageManager(cwd = process$1.cwd()) {
776
- let agent = null;
777
- const lockPath = await findUp(Object.keys(LOCKS), { cwd });
778
- let packageJsonPath;
779
- if (lockPath)
780
- packageJsonPath = p.resolve(lockPath, "../package.json");
781
- else
782
- packageJsonPath = await findUp("package.json", { cwd });
783
- if (packageJsonPath && W.existsSync(packageJsonPath)) {
784
- try {
785
- const pkg = JSON.parse(W.readFileSync(packageJsonPath, "utf8"));
786
- if (typeof pkg.packageManager === "string") {
787
- const [name, version] = pkg.packageManager.split("@");
788
- if (name === "yarn" && Number.parseInt(version) > 1)
789
- agent = "yarn@berry";
790
- else if (name === "pnpm" && Number.parseInt(version) < 7)
791
- agent = "pnpm@6";
792
- else if (AGENTS.includes(name))
793
- agent = name;
794
- else
795
- console.warn("[ni] Unknown packageManager:", pkg.packageManager);
796
- }
797
- } catch {
798
- }
799
- }
800
- if (!agent && lockPath)
801
- agent = LOCKS[p.basename(lockPath)];
802
- return agent;
803
- }
804
- async function installPackage(names, options = {}) {
805
- const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
806
- const [agent] = detectedAgent.split("@");
807
- if (!Array.isArray(names))
808
- names = [names];
809
- const args = options.additionalArgs || [];
810
- if (options.preferOffline) {
811
- if (detectedAgent === "yarn@berry")
812
- args.unshift("--cached");
813
- else
814
- args.unshift("--prefer-offline");
815
- }
816
- if (agent === "pnpm" && existsSync(resolve(options.cwd ?? process$1.cwd(), "pnpm-workspace.yaml")))
817
- args.unshift("-w");
818
- return we(
819
- agent,
820
- [
821
- agent === "yarn" ? "add" : "install",
822
- options.dev ? "-D" : "",
823
- ...args,
824
- ...names
825
- ].filter(Boolean),
826
- {
827
- nodeOptions: {
828
- stdio: options.silent ? "ignore" : "inherit",
829
- cwd: options.cwd
830
- }
831
- }
832
- );
833
- }
834
-
835
- export { detectPackageManager, installPackage };