vitest 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +0 -17
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/child.js +3 -3
- package/dist/chunks/install-pkg.LE8oaA1t.js +319 -0
- package/dist/chunks/{integrations-globals.eip0xL77.js → integrations-globals.8mr2ENps.js} +2 -2
- package/dist/cli.js +3 -3
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/entry-vm.js +2 -2
- package/dist/entry.js +2 -2
- package/dist/environments.d.ts +2 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/dist/{reporters-LLiOBu3g.d.ts → reporters-3OMQDZar.d.ts} +1 -1
- package/dist/reporters.d.ts +1 -1
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +1 -1
- package/dist/{suite-SvxfaIxW.d.ts → suite-yBB1jXl9.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/vendor/{environments.hTqxBFDN.js → environments.v4R4vGad.js} +10 -5
- package/dist/vendor/{execute.ILey0jnF.js → execute.1R_t2FPL.js} +3 -1
- package/dist/vendor/{index.VL3WbvjT.js → index.uQelX_YY.js} +1 -1
- package/dist/vendor/{loader.w8KTtIkD.js → loader.zIj6SiI8.js} +1 -1
- package/dist/vendor/{node.qmjq0bgY.js → node.hPXN4l9e.js} +15 -10
- package/dist/vendor/{vi.JXuS6emb.js → vi.pk4NToBt.js} +2 -0
- package/dist/vm.js +3 -3
- package/dist/worker.js +3 -3
- package/package.json +11 -11
- package/dist/chunks/install-pkg.ORGzQeqb.js +0 -457
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
import require$$0 from 'fs';
|
|
2
|
-
import p from 'path';
|
|
3
|
-
import { g as getDefaultExportFromCjs } from '../vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
4
|
-
import require$$0$1 from 'util';
|
|
5
|
-
import execa from 'execa';
|
|
6
|
-
|
|
7
|
-
var findUp$1 = {exports: {}};
|
|
8
|
-
|
|
9
|
-
var locatePath = {exports: {}};
|
|
10
|
-
|
|
11
|
-
class Node {
|
|
12
|
-
/// value;
|
|
13
|
-
/// next;
|
|
14
|
-
|
|
15
|
-
constructor(value) {
|
|
16
|
-
this.value = value;
|
|
17
|
-
|
|
18
|
-
// TODO: Remove this when targeting Node.js 12.
|
|
19
|
-
this.next = undefined;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let Queue$1 = class Queue {
|
|
24
|
-
// TODO: Use private class fields when targeting Node.js 12.
|
|
25
|
-
// #_head;
|
|
26
|
-
// #_tail;
|
|
27
|
-
// #_size;
|
|
28
|
-
|
|
29
|
-
constructor() {
|
|
30
|
-
this.clear();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
enqueue(value) {
|
|
34
|
-
const node = new Node(value);
|
|
35
|
-
|
|
36
|
-
if (this._head) {
|
|
37
|
-
this._tail.next = node;
|
|
38
|
-
this._tail = node;
|
|
39
|
-
} else {
|
|
40
|
-
this._head = node;
|
|
41
|
-
this._tail = node;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
this._size++;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
dequeue() {
|
|
48
|
-
const current = this._head;
|
|
49
|
-
if (!current) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
this._head = this._head.next;
|
|
54
|
-
this._size--;
|
|
55
|
-
return current.value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
clear() {
|
|
59
|
-
this._head = undefined;
|
|
60
|
-
this._tail = undefined;
|
|
61
|
-
this._size = 0;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
get size() {
|
|
65
|
-
return this._size;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
* [Symbol.iterator]() {
|
|
69
|
-
let current = this._head;
|
|
70
|
-
|
|
71
|
-
while (current) {
|
|
72
|
-
yield current.value;
|
|
73
|
-
current = current.next;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
var yoctoQueue = Queue$1;
|
|
79
|
-
|
|
80
|
-
const Queue = yoctoQueue;
|
|
81
|
-
|
|
82
|
-
const pLimit$1 = concurrency => {
|
|
83
|
-
if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
|
|
84
|
-
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const queue = new Queue();
|
|
88
|
-
let activeCount = 0;
|
|
89
|
-
|
|
90
|
-
const next = () => {
|
|
91
|
-
activeCount--;
|
|
92
|
-
|
|
93
|
-
if (queue.size > 0) {
|
|
94
|
-
queue.dequeue()();
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const run = async (fn, resolve, ...args) => {
|
|
99
|
-
activeCount++;
|
|
100
|
-
|
|
101
|
-
const result = (async () => fn(...args))();
|
|
102
|
-
|
|
103
|
-
resolve(result);
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
await result;
|
|
107
|
-
} catch {}
|
|
108
|
-
|
|
109
|
-
next();
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const enqueue = (fn, resolve, ...args) => {
|
|
113
|
-
queue.enqueue(run.bind(null, fn, resolve, ...args));
|
|
114
|
-
|
|
115
|
-
(async () => {
|
|
116
|
-
// This function needs to wait until the next microtask before comparing
|
|
117
|
-
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
118
|
-
// when the run function is dequeued and called. The comparison in the if-statement
|
|
119
|
-
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
120
|
-
await Promise.resolve();
|
|
121
|
-
|
|
122
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
123
|
-
queue.dequeue()();
|
|
124
|
-
}
|
|
125
|
-
})();
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const generator = (fn, ...args) => new Promise(resolve => {
|
|
129
|
-
enqueue(fn, resolve, ...args);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
Object.defineProperties(generator, {
|
|
133
|
-
activeCount: {
|
|
134
|
-
get: () => activeCount
|
|
135
|
-
},
|
|
136
|
-
pendingCount: {
|
|
137
|
-
get: () => queue.size
|
|
138
|
-
},
|
|
139
|
-
clearQueue: {
|
|
140
|
-
value: () => {
|
|
141
|
-
queue.clear();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
return generator;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
var pLimit_1 = pLimit$1;
|
|
150
|
-
|
|
151
|
-
const pLimit = pLimit_1;
|
|
152
|
-
|
|
153
|
-
class EndError extends Error {
|
|
154
|
-
constructor(value) {
|
|
155
|
-
super();
|
|
156
|
-
this.value = value;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// The input can also be a promise, so we await it
|
|
161
|
-
const testElement = async (element, tester) => tester(await element);
|
|
162
|
-
|
|
163
|
-
// The input can also be a promise, so we `Promise.all()` them both
|
|
164
|
-
const finder = async element => {
|
|
165
|
-
const values = await Promise.all(element);
|
|
166
|
-
if (values[1] === true) {
|
|
167
|
-
throw new EndError(values[0]);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return false;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
const pLocate$1 = async (iterable, tester, options) => {
|
|
174
|
-
options = {
|
|
175
|
-
concurrency: Infinity,
|
|
176
|
-
preserveOrder: true,
|
|
177
|
-
...options
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const limit = pLimit(options.concurrency);
|
|
181
|
-
|
|
182
|
-
// Start all the promises concurrently with optional limit
|
|
183
|
-
const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
|
|
184
|
-
|
|
185
|
-
// Check the promises either serially or concurrently
|
|
186
|
-
const checkLimit = pLimit(options.preserveOrder ? 1 : Infinity);
|
|
187
|
-
|
|
188
|
-
try {
|
|
189
|
-
await Promise.all(items.map(element => checkLimit(finder, element)));
|
|
190
|
-
} catch (error) {
|
|
191
|
-
if (error instanceof EndError) {
|
|
192
|
-
return error.value;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
throw error;
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
var pLocate_1 = pLocate$1;
|
|
200
|
-
|
|
201
|
-
const path = p;
|
|
202
|
-
const fs$1 = require$$0;
|
|
203
|
-
const {promisify: promisify$1} = require$$0$1;
|
|
204
|
-
const pLocate = pLocate_1;
|
|
205
|
-
|
|
206
|
-
const fsStat = promisify$1(fs$1.stat);
|
|
207
|
-
const fsLStat = promisify$1(fs$1.lstat);
|
|
208
|
-
|
|
209
|
-
const typeMappings = {
|
|
210
|
-
directory: 'isDirectory',
|
|
211
|
-
file: 'isFile'
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
function checkType({type}) {
|
|
215
|
-
if (type in typeMappings) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
throw new Error(`Invalid type specified: ${type}`);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const matchType = (type, stat) => type === undefined || stat[typeMappings[type]]();
|
|
223
|
-
|
|
224
|
-
locatePath.exports = async (paths, options) => {
|
|
225
|
-
options = {
|
|
226
|
-
cwd: process.cwd(),
|
|
227
|
-
type: 'file',
|
|
228
|
-
allowSymlinks: true,
|
|
229
|
-
...options
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
checkType(options);
|
|
233
|
-
|
|
234
|
-
const statFn = options.allowSymlinks ? fsStat : fsLStat;
|
|
235
|
-
|
|
236
|
-
return pLocate(paths, async path_ => {
|
|
237
|
-
try {
|
|
238
|
-
const stat = await statFn(path.resolve(options.cwd, path_));
|
|
239
|
-
return matchType(options.type, stat);
|
|
240
|
-
} catch {
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
}, options);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
locatePath.exports.sync = (paths, options) => {
|
|
247
|
-
options = {
|
|
248
|
-
cwd: process.cwd(),
|
|
249
|
-
allowSymlinks: true,
|
|
250
|
-
type: 'file',
|
|
251
|
-
...options
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
checkType(options);
|
|
255
|
-
|
|
256
|
-
const statFn = options.allowSymlinks ? fs$1.statSync : fs$1.lstatSync;
|
|
257
|
-
|
|
258
|
-
for (const path_ of paths) {
|
|
259
|
-
try {
|
|
260
|
-
const stat = statFn(path.resolve(options.cwd, path_));
|
|
261
|
-
|
|
262
|
-
if (matchType(options.type, stat)) {
|
|
263
|
-
return path_;
|
|
264
|
-
}
|
|
265
|
-
} catch {}
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
var locatePathExports = locatePath.exports;
|
|
270
|
-
|
|
271
|
-
var pathExists = {exports: {}};
|
|
272
|
-
|
|
273
|
-
const fs = require$$0;
|
|
274
|
-
const {promisify} = require$$0$1;
|
|
275
|
-
|
|
276
|
-
const pAccess = promisify(fs.access);
|
|
277
|
-
|
|
278
|
-
pathExists.exports = async path => {
|
|
279
|
-
try {
|
|
280
|
-
await pAccess(path);
|
|
281
|
-
return true;
|
|
282
|
-
} catch (_) {
|
|
283
|
-
return false;
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
pathExists.exports.sync = path => {
|
|
288
|
-
try {
|
|
289
|
-
fs.accessSync(path);
|
|
290
|
-
return true;
|
|
291
|
-
} catch (_) {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
var pathExistsExports = pathExists.exports;
|
|
297
|
-
|
|
298
|
-
(function (module) {
|
|
299
|
-
const path = p;
|
|
300
|
-
const locatePath = locatePathExports;
|
|
301
|
-
const pathExists = pathExistsExports;
|
|
302
|
-
|
|
303
|
-
const stop = Symbol('findUp.stop');
|
|
304
|
-
|
|
305
|
-
module.exports = async (name, options = {}) => {
|
|
306
|
-
let directory = path.resolve(options.cwd || '');
|
|
307
|
-
const {root} = path.parse(directory);
|
|
308
|
-
const paths = [].concat(name);
|
|
309
|
-
|
|
310
|
-
const runMatcher = async locateOptions => {
|
|
311
|
-
if (typeof name !== 'function') {
|
|
312
|
-
return locatePath(paths, locateOptions);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const foundPath = await name(locateOptions.cwd);
|
|
316
|
-
if (typeof foundPath === 'string') {
|
|
317
|
-
return locatePath([foundPath], locateOptions);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
return foundPath;
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
// eslint-disable-next-line no-constant-condition
|
|
324
|
-
while (true) {
|
|
325
|
-
// eslint-disable-next-line no-await-in-loop
|
|
326
|
-
const foundPath = await runMatcher({...options, cwd: directory});
|
|
327
|
-
|
|
328
|
-
if (foundPath === stop) {
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (foundPath) {
|
|
333
|
-
return path.resolve(directory, foundPath);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (directory === root) {
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
directory = path.dirname(directory);
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
module.exports.sync = (name, options = {}) => {
|
|
345
|
-
let directory = path.resolve(options.cwd || '');
|
|
346
|
-
const {root} = path.parse(directory);
|
|
347
|
-
const paths = [].concat(name);
|
|
348
|
-
|
|
349
|
-
const runMatcher = locateOptions => {
|
|
350
|
-
if (typeof name !== 'function') {
|
|
351
|
-
return locatePath.sync(paths, locateOptions);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const foundPath = name(locateOptions.cwd);
|
|
355
|
-
if (typeof foundPath === 'string') {
|
|
356
|
-
return locatePath.sync([foundPath], locateOptions);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return foundPath;
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
// eslint-disable-next-line no-constant-condition
|
|
363
|
-
while (true) {
|
|
364
|
-
const foundPath = runMatcher({...options, cwd: directory});
|
|
365
|
-
|
|
366
|
-
if (foundPath === stop) {
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
if (foundPath) {
|
|
371
|
-
return path.resolve(directory, foundPath);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (directory === root) {
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
directory = path.dirname(directory);
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
module.exports.exists = pathExists;
|
|
383
|
-
|
|
384
|
-
module.exports.sync.exists = pathExists.sync;
|
|
385
|
-
|
|
386
|
-
module.exports.stop = stop;
|
|
387
|
-
} (findUp$1));
|
|
388
|
-
|
|
389
|
-
var findUpExports = findUp$1.exports;
|
|
390
|
-
var findUp = /*@__PURE__*/getDefaultExportFromCjs(findUpExports);
|
|
391
|
-
|
|
392
|
-
// src/detect.ts
|
|
393
|
-
var AGENTS = ["pnpm", "yarn", "npm", "pnpm@6", "yarn@berry", "bun"];
|
|
394
|
-
var LOCKS = {
|
|
395
|
-
"bun.lockb": "bun",
|
|
396
|
-
"pnpm-lock.yaml": "pnpm",
|
|
397
|
-
"yarn.lock": "yarn",
|
|
398
|
-
"package-lock.json": "npm",
|
|
399
|
-
"npm-shrinkwrap.json": "npm"
|
|
400
|
-
};
|
|
401
|
-
async function detectPackageManager(cwd = process.cwd()) {
|
|
402
|
-
let agent = null;
|
|
403
|
-
const lockPath = await findUp(Object.keys(LOCKS), { cwd });
|
|
404
|
-
let packageJsonPath;
|
|
405
|
-
if (lockPath)
|
|
406
|
-
packageJsonPath = p.resolve(lockPath, "../package.json");
|
|
407
|
-
else
|
|
408
|
-
packageJsonPath = await findUp("package.json", { cwd });
|
|
409
|
-
if (packageJsonPath && require$$0.existsSync(packageJsonPath)) {
|
|
410
|
-
try {
|
|
411
|
-
const pkg = JSON.parse(require$$0.readFileSync(packageJsonPath, "utf8"));
|
|
412
|
-
if (typeof pkg.packageManager === "string") {
|
|
413
|
-
const [name, version] = pkg.packageManager.split("@");
|
|
414
|
-
if (name === "yarn" && parseInt(version) > 1)
|
|
415
|
-
agent = "yarn@berry";
|
|
416
|
-
else if (name === "pnpm" && parseInt(version) < 7)
|
|
417
|
-
agent = "pnpm@6";
|
|
418
|
-
else if (name in AGENTS)
|
|
419
|
-
agent = name;
|
|
420
|
-
else
|
|
421
|
-
console.warn("[ni] Unknown packageManager:", pkg.packageManager);
|
|
422
|
-
}
|
|
423
|
-
} catch {
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
if (!agent && lockPath)
|
|
427
|
-
agent = LOCKS[p.basename(lockPath)];
|
|
428
|
-
return agent;
|
|
429
|
-
}
|
|
430
|
-
async function installPackage(names, options = {}) {
|
|
431
|
-
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
|
432
|
-
const [agent] = detectedAgent.split("@");
|
|
433
|
-
if (!Array.isArray(names))
|
|
434
|
-
names = [names];
|
|
435
|
-
const args = options.additionalArgs || [];
|
|
436
|
-
if (options.preferOffline) {
|
|
437
|
-
if (detectedAgent === "yarn@berry")
|
|
438
|
-
args.unshift("--cached");
|
|
439
|
-
else
|
|
440
|
-
args.unshift("--prefer-offline");
|
|
441
|
-
}
|
|
442
|
-
return execa(
|
|
443
|
-
agent,
|
|
444
|
-
[
|
|
445
|
-
agent === "yarn" ? "add" : "install",
|
|
446
|
-
options.dev ? "-D" : "",
|
|
447
|
-
...args,
|
|
448
|
-
...names
|
|
449
|
-
].filter(Boolean),
|
|
450
|
-
{
|
|
451
|
-
stdio: options.silent ? "ignore" : "inherit",
|
|
452
|
-
cwd: options.cwd
|
|
453
|
-
}
|
|
454
|
-
);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
export { detectPackageManager, installPackage };
|