vitest 4.1.12 → 5.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.
- package/LICENSE.md +192 -10
- package/browser/context.d.ts +7 -1
- package/browser/context.js +5 -5
- package/config.d.ts +0 -2
- package/dist/browser.d.ts +52 -21
- package/dist/browser.js +12 -13
- package/dist/chunks/{acorn.B2iPLyUM.js → acorn.C1kjbUFw.js} +30 -30
- package/dist/chunks/{base.B6Opl8PE.js → base.Cof-UHJf.js} +81 -52
- package/dist/chunks/{browser.d.BcoexmFG.d.ts → browser.d.C7tWgUvw.d.ts} +17 -14
- package/dist/chunks/{cac.DzDtg8hz.js → cac.BYbt0aJp.js} +143 -87
- package/dist/chunks/{cli-api.B0Pz1_R7.js → cli-api.COfZo8lK.js} +7160 -7189
- package/dist/chunks/config.d.B3YV4t0O.d.ts +3873 -0
- package/dist/chunks/{console.3WNpx0tS.js → console.CQZ877Hi.js} +69 -63
- package/dist/chunks/{constants.CPYnjOGj.js → constants.DLYM6cZY.js} +2 -2
- package/dist/chunks/coverage.9iqXE2gN.js +26 -0
- package/dist/chunks/{coverage.CTzCuANN.js → coverage.jGCktcGP.js} +7 -2
- package/dist/chunks/{creator.DgVhQm5q.js → creator.DHWmytIK.js} +65 -28
- package/dist/chunks/{defaults.9aQKnqFk.js → defaults.B1FCaFfh.js} +16 -9
- package/dist/chunks/display.BlTmubjj.js +194 -0
- package/dist/chunks/doctor.B-oPbwps.js +465 -0
- package/dist/chunks/{env.D4Lgay0q.js → env.BKKtU2WC.js} +2 -1
- package/dist/chunks/{environment.d.CrsxCzP1.d.ts → environment.d.BFQtFKdZ.d.ts} +9 -1
- package/dist/chunks/globals.ZKtKSkEf.js +29 -0
- package/dist/chunks/index.Bi0NXYPf.js +1708 -0
- package/dist/chunks/{index.CMESou6r.js → index.BoyTG_B7.js} +82 -81
- package/dist/chunks/index.CZzC1gGg.js +8501 -0
- package/dist/chunks/index.D0heQG4v.js +1318 -0
- package/dist/chunks/index.Di8au7q4.js +15665 -0
- package/dist/chunks/{index.Chj8NDwU.js → index.DmDMHCg8.js} +6 -12
- package/dist/chunks/{index.DXx9Dtk7.js → index.w_oBZ9N8.js} +25 -12
- package/dist/chunks/{init-forks.H5ZuobOQ.js → init-forks.BaDXQSD8.js} +7 -10
- package/dist/chunks/{init-threads.6kl1khcL.js → init-threads.ZX_Vov0z.js} +1 -1
- package/dist/chunks/{init.k9zZ9sLh.js → init.CO4AB7HZ.js} +113 -38
- package/dist/chunks/module-dependencies._2Eei3FO.js +71 -0
- package/dist/chunks/{native.DPzPHdi5.js → native.upB-V0CK.js} +50 -37
- package/dist/chunks/{nativeModuleMocker.BkNfQMkH.js → nativeModuleMocker.Dh5azSB4.js} +48 -19
- package/dist/chunks/{index.BCY_7LL2.js → nativeModuleRunner.9xPIMzi7.js} +110 -42
- package/dist/chunks/node.B9mkVmLH.js +47 -0
- package/dist/chunks/offset.Dy-5Fdfn.js +24 -0
- package/dist/chunks/pathe.M-eThtNZ.zq3TM4NT.js +492 -0
- package/dist/chunks/{reporters.d.DtoKVV2s.d.ts → plugin.d.LRFSN46m.d.ts} +2573 -1453
- package/dist/chunks/plugins.DPQHVT0p.js +37 -0
- package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
- package/dist/chunks/resolver.BzpmeQeT.js +48 -0
- package/dist/chunks/rpc.Uhkwr2NM.js +93 -0
- package/dist/chunks/rpc.d.3FOhdFx8.d.ts +75 -0
- package/dist/chunks/run.CjdgFZiW.js +4231 -0
- package/dist/chunks/setup-common.CqAQCXzx.js +36 -0
- package/dist/chunks/source-map.DakdQc29.js +1788 -0
- package/dist/chunks/source-map.d.BkG8YK_3.d.ts +89 -0
- package/dist/chunks/spy.DDMXghXv.js +509 -0
- package/dist/chunks/task-utils.d.D-gFPNFi.d.ts +144 -0
- package/dist/chunks/tinyrainbow.Do8I1XRG.js +88 -0
- package/dist/chunks/{utils.BS4fH3nR.js → utils.BBk_icFG.js} +50 -52
- package/dist/chunks/{utils.BX5Fg8C4.js → utils.DYj33du9.js} +1 -17
- package/dist/chunks/vm.b4MbCAJQ.js +1329 -0
- package/dist/chunks/{worker.d.ZpHpO4yb.d.ts → worker.d.CyJRpyfZ.d.ts} +34 -19
- package/dist/cli.js +5 -6
- package/dist/config.cjs +9 -6
- package/dist/config.d.ts +27 -25
- package/dist/config.js +3 -3
- package/dist/index.d.ts +471 -38
- package/dist/index.js +18 -19
- package/dist/module-evaluator.d.ts +64 -5
- package/dist/module-evaluator.js +122 -62
- package/dist/node.d.ts +355 -87
- package/dist/node.js +49 -73
- package/dist/runtime.d.ts +43 -6
- package/dist/runtime.js +7 -9
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +290 -0
- package/dist/{chunks/traces.DT5aQ62U.js → traces.js} +3 -2
- package/dist/worker.d.ts +8 -10
- package/dist/worker.js +33 -43
- package/dist/workers/forks.js +30 -40
- package/dist/workers/runVmTests.js +66 -43
- package/dist/workers/threads.js +30 -40
- package/dist/workers/vmForks.js +19 -20
- package/dist/workers/vmThreads.js +19 -20
- package/globals.d.ts +19 -19
- package/index.cjs +3 -3
- package/optional-runtime-types.d.ts +1 -1
- package/optional-types.d.ts +1 -1
- package/package.json +59 -74
- package/suppress-warnings.cjs +1 -1
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
- package/dist/chunks/benchmark.CX_oY03V.js +0 -40
- package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +0 -24
- package/dist/chunks/config.d.A1h_Y6Jt.d.ts +0 -232
- package/dist/chunks/coverage.DM_a_rWm.js +0 -1087
- package/dist/chunks/coverage.d.BZtK59WP.d.ts +0 -37
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +0 -17
- package/dist/chunks/global.d.DVsSRdQ5.d.ts +0 -100
- package/dist/chunks/globals.Dj1TGiMC.js +0 -31
- package/dist/chunks/index.DC7d2Pf8.js +0 -729
- package/dist/chunks/index.DdgEv5B1.js +0 -42
- package/dist/chunks/index.UpGiHP7g.js +0 -4255
- package/dist/chunks/index.og1WyBLx.js +0 -6358
- package/dist/chunks/nativeModuleRunner.BIakptoF.js +0 -36
- package/dist/chunks/node.COQbm6gK.js +0 -14
- package/dist/chunks/plugin.d.DwFIiJ7i.d.ts +0 -38
- package/dist/chunks/rpc.MzXet3jl.js +0 -144
- package/dist/chunks/rpc.d.B_8sPU0w.d.ts +0 -30
- package/dist/chunks/setup-common.DYx3LtFI.js +0 -60
- package/dist/chunks/startVitestModuleRunner.DB-7oCpn.js +0 -740
- package/dist/chunks/suite.d.udJtyAgw.d.ts +0 -10
- package/dist/chunks/test.DNmyFkvJ.js +0 -4430
- package/dist/chunks/traces.d.D2T_R8rx.d.ts +0 -60
- package/dist/chunks/vm.CXMd5FHa.js +0 -785
- package/dist/coverage.d.ts +0 -123
- package/dist/coverage.js +0 -27
- package/dist/environments.d.ts +0 -22
- package/dist/environments.js +0 -5
- package/dist/reporters.d.ts +0 -27
- package/dist/reporters.js +0 -26
- package/dist/runners.d.ts +0 -70
- package/dist/runners.js +0 -19
- package/dist/snapshot.d.ts +0 -9
- package/dist/snapshot.js +0 -6
- package/dist/suite.d.ts +0 -5
- package/dist/suite.js +0 -8
|
@@ -10,13 +10,19 @@ const AGENTS = [
|
|
|
10
10
|
"yarn@berry",
|
|
11
11
|
"pnpm",
|
|
12
12
|
"pnpm@6",
|
|
13
|
+
"pnpm-rush",
|
|
13
14
|
"bun",
|
|
14
|
-
"deno"
|
|
15
|
+
"deno",
|
|
16
|
+
"nub",
|
|
17
|
+
"aube"
|
|
15
18
|
];
|
|
16
19
|
const LOCKS = {
|
|
20
|
+
"aube-lock.yaml": "aube",
|
|
21
|
+
"aube-workspace.yaml": "aube",
|
|
17
22
|
"bun.lock": "bun",
|
|
18
23
|
"bun.lockb": "bun",
|
|
19
24
|
"deno.lock": "deno",
|
|
25
|
+
"nub.lock": "nub",
|
|
20
26
|
"pnpm-lock.yaml": "pnpm",
|
|
21
27
|
"pnpm-workspace.yaml": "pnpm",
|
|
22
28
|
"yarn.lock": "yarn",
|
|
@@ -24,6 +30,7 @@ const LOCKS = {
|
|
|
24
30
|
"npm-shrinkwrap.json": "npm"
|
|
25
31
|
};
|
|
26
32
|
const INSTALL_METADATA = {
|
|
33
|
+
"node_modules/.aube/": "aube",
|
|
27
34
|
"node_modules/.deno/": "deno",
|
|
28
35
|
"node_modules/.pnpm/": "pnpm",
|
|
29
36
|
"node_modules/.yarn-state.yml": "yarn",
|
|
@@ -55,14 +62,15 @@ function* lookup(cwd = process.cwd()) {
|
|
|
55
62
|
directory = path.dirname(directory);
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
|
-
async function parsePackageJson(filepath,
|
|
59
|
-
|
|
65
|
+
async function parsePackageJson(filepath, options) {
|
|
66
|
+
if (!filepath || !await pathExists(filepath, "file"))
|
|
67
|
+
return null;
|
|
68
|
+
return await handlePackageManager(filepath, options);
|
|
60
69
|
}
|
|
61
70
|
async function detect(options = {}) {
|
|
62
71
|
const {
|
|
63
72
|
cwd,
|
|
64
|
-
strategies = ["lockfile", "packageManager-field", "devEngines-field"]
|
|
65
|
-
onUnknown
|
|
73
|
+
strategies = ["lockfile", "packageManager-field", "devEngines-field"]
|
|
66
74
|
} = options;
|
|
67
75
|
let stopDir;
|
|
68
76
|
if (typeof options.stopDir === "string") {
|
|
@@ -75,10 +83,13 @@ async function detect(options = {}) {
|
|
|
75
83
|
for (const strategy of strategies) {
|
|
76
84
|
switch (strategy) {
|
|
77
85
|
case "lockfile": {
|
|
86
|
+
if (await pathExists(path.join(directory, "rush.json"), "file")) {
|
|
87
|
+
return { name: "pnpm", agent: "pnpm-rush" };
|
|
88
|
+
}
|
|
78
89
|
for (const lock of Object.keys(LOCKS)) {
|
|
79
90
|
if (await pathExists(path.join(directory, lock), "file")) {
|
|
80
91
|
const name = LOCKS[lock];
|
|
81
|
-
const result = await parsePackageJson(path.join(directory, "package.json"),
|
|
92
|
+
const result = await parsePackageJson(path.join(directory, "package.json"), options);
|
|
82
93
|
if (result)
|
|
83
94
|
return result;
|
|
84
95
|
else
|
|
@@ -89,7 +100,7 @@ async function detect(options = {}) {
|
|
|
89
100
|
}
|
|
90
101
|
case "packageManager-field":
|
|
91
102
|
case "devEngines-field": {
|
|
92
|
-
const result = await parsePackageJson(path.join(directory, "package.json"),
|
|
103
|
+
const result = await parsePackageJson(path.join(directory, "package.json"), options);
|
|
93
104
|
if (result)
|
|
94
105
|
return result;
|
|
95
106
|
break;
|
|
@@ -126,9 +137,10 @@ function getNameAndVer(pkg) {
|
|
|
126
137
|
}
|
|
127
138
|
return void 0;
|
|
128
139
|
}
|
|
129
|
-
async function handlePackageManager(filepath,
|
|
140
|
+
async function handlePackageManager(filepath, options) {
|
|
130
141
|
try {
|
|
131
|
-
const
|
|
142
|
+
const content = await fs.readFile(filepath, "utf8");
|
|
143
|
+
const pkg = options.packageJsonParser ? await options.packageJsonParser(content, filepath) : JSON.parse(content);
|
|
132
144
|
let agent;
|
|
133
145
|
const nameAndVer = getNameAndVer(pkg);
|
|
134
146
|
if (nameAndVer) {
|
|
@@ -146,7 +158,7 @@ async function handlePackageManager(filepath, onUnknown) {
|
|
|
146
158
|
agent = name;
|
|
147
159
|
return { name, agent, version };
|
|
148
160
|
} else {
|
|
149
|
-
return onUnknown?.(pkg.packageManager) ?? null;
|
|
161
|
+
return options.onUnknown?.(pkg.packageManager) ?? null;
|
|
150
162
|
}
|
|
151
163
|
}
|
|
152
164
|
} catch {
|
|
@@ -157,82 +169,71 @@ function isMetadataYarnClassic(metadataPath) {
|
|
|
157
169
|
return metadataPath.endsWith(".yarn_integrity");
|
|
158
170
|
}
|
|
159
171
|
|
|
160
|
-
|
|
172
|
+
//#region src/detect.ts
|
|
161
173
|
async function detectPackageManager(cwd = process.cwd()) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
});
|
|
169
|
-
return result?.agent || null;
|
|
174
|
+
return (await detect({
|
|
175
|
+
cwd,
|
|
176
|
+
onUnknown(packageManager) {
|
|
177
|
+
console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
|
|
178
|
+
}
|
|
179
|
+
}))?.agent || null;
|
|
170
180
|
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/install.ts
|
|
171
183
|
async function installPackage(names, options = {}) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
stdio: options.silent ? "ignore" : "inherit",
|
|
206
|
-
cwd: options.cwd
|
|
207
|
-
},
|
|
208
|
-
throwOnError: true
|
|
209
|
-
}
|
|
210
|
-
);
|
|
184
|
+
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
|
185
|
+
const [agent] = detectedAgent.split("@");
|
|
186
|
+
if (!Array.isArray(names)) names = [names];
|
|
187
|
+
const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
|
|
188
|
+
if (options.preferOffline) {
|
|
189
|
+
if (detectedAgent === "yarn@berry") args.unshift("--cached");
|
|
190
|
+
else args.unshift("--prefer-offline");
|
|
191
|
+
}
|
|
192
|
+
if (agent === "pnpm") {
|
|
193
|
+
args.unshift(
|
|
194
|
+
/**
|
|
195
|
+
* Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`.
|
|
196
|
+
* Uses the `--config.` escape hatch instead of `--prod=false` because pnpm >=12.4.1
|
|
197
|
+
* routes `install <pkg>` through its `add`-compatible parser, which rejects `--prod`.
|
|
198
|
+
* @see https://pnpm.io/cli/install#--prod--p
|
|
199
|
+
* @see https://github.com/pnpm/pnpm/issues/14868
|
|
200
|
+
*/
|
|
201
|
+
"--config.prod=false"
|
|
202
|
+
);
|
|
203
|
+
if (existsSync(resolve(options.cwd ?? process.cwd(), "pnpm-workspace.yaml"))) args.unshift("-w");
|
|
204
|
+
}
|
|
205
|
+
return x(agent, [
|
|
206
|
+
agent === "yarn" ? "add" : "install",
|
|
207
|
+
options.dev ? "-D" : "",
|
|
208
|
+
...args,
|
|
209
|
+
...names
|
|
210
|
+
].filter(Boolean), {
|
|
211
|
+
nodeOptions: {
|
|
212
|
+
stdio: options.silent ? "ignore" : "inherit",
|
|
213
|
+
cwd: options.cwd
|
|
214
|
+
},
|
|
215
|
+
throwOnError: true
|
|
216
|
+
});
|
|
211
217
|
}
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/uninstall.ts
|
|
212
220
|
async function uninstallPackage(names, options = {}) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
nodeOptions: {
|
|
230
|
-
stdio: options.silent ? "ignore" : "inherit",
|
|
231
|
-
cwd: options.cwd
|
|
232
|
-
},
|
|
233
|
-
throwOnError: true
|
|
234
|
-
}
|
|
235
|
-
);
|
|
221
|
+
const [agent] = (options.packageManager || await detectPackageManager(options.cwd) || "npm").split("@");
|
|
222
|
+
if (!Array.isArray(names)) names = [names];
|
|
223
|
+
const args = options.additionalArgs || [];
|
|
224
|
+
if (agent === "pnpm" && existsSync(resolve(options.cwd ?? process.cwd(), "pnpm-workspace.yaml"))) args.unshift("-w");
|
|
225
|
+
return x(agent, [
|
|
226
|
+
agent === "yarn" ? "remove" : "uninstall",
|
|
227
|
+
options.dev ? "-D" : "",
|
|
228
|
+
...args,
|
|
229
|
+
...names
|
|
230
|
+
].filter(Boolean), {
|
|
231
|
+
nodeOptions: {
|
|
232
|
+
stdio: options.silent ? "ignore" : "inherit",
|
|
233
|
+
cwd: options.cwd
|
|
234
|
+
},
|
|
235
|
+
throwOnError: true
|
|
236
|
+
});
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
export { detectPackageManager, installPackage, uninstallPackage };
|