vitest 3.2.0-beta.1 → 3.2.0-beta.3
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 -232
- package/dist/browser.d.ts +5 -3
- package/dist/browser.js +3 -4
- package/dist/chunks/{base.SfTiRNZf.js → base.D4119yLM.js} +4 -3
- package/dist/chunks/{benchmark.BoF7jW0Q.js → benchmark.Cf_PACH1.js} +1 -1
- package/dist/chunks/{cac.TfX2-DVH.js → cac.DWaWHIIE.js} +21 -16
- package/dist/chunks/{cli-api.2970Nj9J.js → cli-api.CnmEXkxs.js} +292 -59
- package/dist/chunks/{config.d.UqE-KR0o.d.ts → config.d.D2ROskhv.d.ts} +2 -0
- package/dist/chunks/{console.K1NMVOSc.js → console.Cwr-MFPV.js} +3 -2
- package/dist/chunks/{constants.BZZyIeIE.js → constants.DnKduX2e.js} +1 -0
- package/dist/chunks/{coverage.z0LVMxgb.js → coverage.C73DaDgS.js} +241 -4226
- package/dist/chunks/{creator.CuL7xDWI.js → creator.C8WKy2eW.js} +26 -44
- package/dist/chunks/{date.CDOsz-HY.js → date.ByMsSlOr.js} +25 -0
- package/dist/chunks/{defaults.DSxsTG0h.js → defaults.DpVH7vbg.js} +1 -0
- package/dist/chunks/{environment.d.D8YDy2v5.d.ts → environment.d.cL3nLXbE.d.ts} +1 -0
- package/dist/chunks/{execute.BpmIjFTD.js → execute.B3q-2LPV.js} +28 -5
- package/dist/chunks/{global.d.BCOHQEpR.d.ts → global.d.BNLIi6yo.d.ts} +13 -11
- package/dist/chunks/{globals.Cg4NtV4P.js → globals.CI21aWXF.js} +7 -7
- package/dist/chunks/{index.DFXFpH3w.js → index.2jgTs_Q5.js} +19 -1
- package/dist/chunks/{index.CUacZlWG.js → index.Bter3jj9.js} +954 -954
- package/dist/chunks/{index.DbWBPwtH.js → index.CbT4iuwc.js} +7 -4
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/{index.BPc7M5ni.js → index.DNgLEKsQ.js} +5 -15
- package/dist/chunks/index.JOzufsrU.js +276 -0
- package/dist/chunks/{index.DBIGubLC.js → index.X0nbfr6-.js} +7 -7
- package/dist/chunks/{inspector.DbDkSkFn.js → inspector.BFsh5KO0.js} +3 -0
- package/dist/chunks/{node.3xsWotC9.js → node.Be-ntJnD.js} +1 -1
- package/dist/chunks/{reporters.d.DGm4k1Wx.d.ts → reporters.d.Bt4IGtsa.d.ts} +41 -6
- package/dist/chunks/{rpc.D9_013TY.js → rpc.BKExFSRG.js} +2 -1
- package/dist/chunks/{runBaseTests.CguliJB5.js → runBaseTests.B_M1TTsK.js} +19 -11
- package/dist/chunks/{setup-common.BP6KrF_Z.js → setup-common.CF-O-dZX.js} +2 -3
- package/dist/chunks/typechecker.BgzF-6iO.js +954 -0
- package/dist/chunks/{utils.CgTj3MsC.js → utils.BlI4TC7Y.js} +1 -0
- package/dist/chunks/{utils.BfxieIyZ.js → utils.DPCq3gzW.js} +3 -0
- package/dist/chunks/{vi.BFR5YIgu.js → vi.pkoYCV6A.js} +25 -2
- package/dist/chunks/{vite.d.DjP_ALCZ.d.ts → vite.d.B-Kx3KCF.d.ts} +3 -1
- package/dist/chunks/{vm.CuLHT1BG.js → vm.DPYem2so.js} +72 -4
- package/dist/chunks/{worker.d.CoCI7hzP.d.ts → worker.d.BKbBp2ga.d.ts} +2 -2
- package/dist/chunks/{worker.d.D5Xdi-Zr.d.ts → worker.d.Bl1O4kuf.d.ts} +1 -1
- package/dist/cli.js +21 -2
- package/dist/config.cjs +2 -0
- package/dist/config.d.ts +7 -6
- package/dist/config.js +2 -2
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +7 -10
- package/dist/environments.d.ts +6 -2
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +9 -3
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +25 -35
- package/dist/index.js +5 -6
- package/dist/node.d.ts +18 -10
- package/dist/node.js +22 -22
- package/dist/reporters.d.ts +4 -4
- package/dist/reporters.js +14 -14
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +13 -5
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +9 -5
- package/dist/workers/forks.js +6 -4
- package/dist/workers/runVmTests.js +14 -10
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +6 -6
- package/dist/workers/vmThreads.js +6 -6
- package/dist/workers.d.ts +4 -4
- package/dist/workers.js +10 -10
- package/package.json +22 -26
- package/dist/chunks/index.Bw6JxgX8.js +0 -143
- package/dist/chunks/run-once.Dimr7O9f.js +0 -47
- package/dist/chunks/typechecker.DYQbn8uK.js +0 -956
- package/dist/chunks/utils.8gfOgtry.js +0 -207
- package/dist/utils.d.ts +0 -3
- package/dist/utils.js +0 -2
|
@@ -6,30 +6,29 @@ import util from 'node:util';
|
|
|
6
6
|
import { startTests, collectTests } from '@vitest/runner';
|
|
7
7
|
import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
|
|
8
8
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
|
-
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/index.
|
|
10
|
-
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.
|
|
11
|
-
import { V as VitestIndex } from '../chunks/index.
|
|
12
|
-
import { c as closeInspector } from '../chunks/inspector.
|
|
13
|
-
import { g as getWorkerState } from '../chunks/utils.
|
|
9
|
+
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/index.CbT4iuwc.js';
|
|
10
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.CF-O-dZX.js';
|
|
11
|
+
import { V as VitestIndex } from '../chunks/index.DNgLEKsQ.js';
|
|
12
|
+
import { c as closeInspector } from '../chunks/inspector.BFsh5KO0.js';
|
|
13
|
+
import { g as getWorkerState } from '../chunks/utils.BlI4TC7Y.js';
|
|
14
14
|
import 'chai';
|
|
15
15
|
import 'node:path';
|
|
16
16
|
import '../path.js';
|
|
17
17
|
import 'node:url';
|
|
18
|
-
import '../chunks/rpc.
|
|
18
|
+
import '../chunks/rpc.BKExFSRG.js';
|
|
19
19
|
import '@vitest/utils';
|
|
20
20
|
import '../chunks/index.CJ0plNrh.js';
|
|
21
21
|
import '../chunks/coverage.0iPg4Wrz.js';
|
|
22
22
|
import '@vitest/snapshot';
|
|
23
|
-
import '../chunks/
|
|
24
|
-
import '../chunks/vi.BFR5YIgu.js';
|
|
23
|
+
import '../chunks/vi.pkoYCV6A.js';
|
|
25
24
|
import '@vitest/expect';
|
|
26
25
|
import '@vitest/runner/utils';
|
|
27
26
|
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
28
27
|
import '@vitest/utils/error';
|
|
29
28
|
import '@vitest/spy';
|
|
30
29
|
import '@vitest/utils/source-map';
|
|
31
|
-
import '../chunks/date.
|
|
32
|
-
import '../chunks/benchmark.
|
|
30
|
+
import '../chunks/date.ByMsSlOr.js';
|
|
31
|
+
import '../chunks/benchmark.Cf_PACH1.js';
|
|
33
32
|
import 'expect-type';
|
|
34
33
|
|
|
35
34
|
async function run(method, files, config, executor) {
|
|
@@ -41,10 +40,12 @@ async function run(method, files, config, executor) {
|
|
|
41
40
|
});
|
|
42
41
|
if (workerState.environment.transformMode === "web") {
|
|
43
42
|
const _require = createRequire(import.meta.url);
|
|
43
|
+
// always mock "required" `css` files, because we cannot process them
|
|
44
44
|
_require.extensions[".css"] = resolveCss;
|
|
45
45
|
_require.extensions[".scss"] = resolveCss;
|
|
46
46
|
_require.extensions[".sass"] = resolveCss;
|
|
47
47
|
_require.extensions[".less"] = resolveCss;
|
|
48
|
+
// since we are using Vite, we can assume how these will be resolved
|
|
48
49
|
KNOWN_ASSET_TYPES.forEach((type) => {
|
|
49
50
|
_require.extensions[`.${type}`] = resolveAsset;
|
|
50
51
|
});
|
|
@@ -52,6 +53,7 @@ async function run(method, files, config, executor) {
|
|
|
52
53
|
} else {
|
|
53
54
|
process.env.SSR = "1";
|
|
54
55
|
}
|
|
56
|
+
// @ts-expect-error not typed global for patched timers
|
|
55
57
|
globalThis.__vitest_required__ = {
|
|
56
58
|
util,
|
|
57
59
|
timers,
|
|
@@ -77,7 +79,9 @@ async function run(method, files, config, executor) {
|
|
|
77
79
|
} else {
|
|
78
80
|
await collectTests([file], runner);
|
|
79
81
|
}
|
|
82
|
+
// reset after tests, because user might call `vi.setConfig` in setupFile
|
|
80
83
|
vi.resetConfig();
|
|
84
|
+
// mocks should not affect different files
|
|
81
85
|
vi.restoreAllMocks();
|
|
82
86
|
}
|
|
83
87
|
await stopCoverageInsideWorker(config.coverage, executor, { isolate: false });
|
package/dist/workers/threads.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as runBaseTests } from '../chunks/base.
|
|
2
|
-
import { a as createThreadsRpcOptions } from '../chunks/utils.
|
|
1
|
+
import { r as runBaseTests } from '../chunks/base.D4119yLM.js';
|
|
2
|
+
import { a as createThreadsRpcOptions } from '../chunks/utils.DPCq3gzW.js';
|
|
3
3
|
import 'vite-node/client';
|
|
4
|
-
import '../chunks/execute.
|
|
4
|
+
import '../chunks/execute.B3q-2LPV.js';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'node:url';
|
|
7
7
|
import 'node:vm';
|
|
@@ -13,7 +13,7 @@ import 'node:path';
|
|
|
13
13
|
import '@vitest/mocker';
|
|
14
14
|
import 'node:module';
|
|
15
15
|
import '@vitest/utils';
|
|
16
|
-
import '../chunks/utils.
|
|
16
|
+
import '../chunks/utils.BlI4TC7Y.js';
|
|
17
17
|
|
|
18
18
|
class ThreadsBaseWorker {
|
|
19
19
|
getRpcOptions(ctx) {
|
package/dist/workers/vmForks.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
|
-
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.
|
|
3
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
2
|
+
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.DPCq3gzW.js';
|
|
3
|
+
import { r as runVmTests } from '../chunks/vm.DPYem2so.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
import 'node:url';
|
|
6
6
|
import 'node:vm';
|
|
7
7
|
import 'pathe';
|
|
8
8
|
import '../path.js';
|
|
9
9
|
import 'node:path';
|
|
10
|
-
import '../chunks/console.
|
|
10
|
+
import '../chunks/console.Cwr-MFPV.js';
|
|
11
11
|
import 'node:console';
|
|
12
12
|
import 'node:stream';
|
|
13
13
|
import 'tinyrainbow';
|
|
14
|
-
import '../chunks/date.
|
|
15
|
-
import '../chunks/utils.
|
|
16
|
-
import '../chunks/execute.
|
|
14
|
+
import '../chunks/date.ByMsSlOr.js';
|
|
15
|
+
import '../chunks/utils.BlI4TC7Y.js';
|
|
16
|
+
import '../chunks/execute.B3q-2LPV.js';
|
|
17
17
|
import 'node:fs';
|
|
18
18
|
import '@vitest/utils/error';
|
|
19
19
|
import 'vite-node/client';
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { a as createThreadsRpcOptions } from '../chunks/utils.
|
|
2
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
1
|
+
import { a as createThreadsRpcOptions } from '../chunks/utils.DPCq3gzW.js';
|
|
2
|
+
import { r as runVmTests } from '../chunks/vm.DPYem2so.js';
|
|
3
3
|
import '@vitest/utils';
|
|
4
4
|
import 'node:url';
|
|
5
5
|
import 'node:vm';
|
|
6
6
|
import 'pathe';
|
|
7
7
|
import '../path.js';
|
|
8
8
|
import 'node:path';
|
|
9
|
-
import '../chunks/console.
|
|
9
|
+
import '../chunks/console.Cwr-MFPV.js';
|
|
10
10
|
import 'node:console';
|
|
11
11
|
import 'node:stream';
|
|
12
12
|
import 'tinyrainbow';
|
|
13
|
-
import '../chunks/date.
|
|
14
|
-
import '../chunks/utils.
|
|
15
|
-
import '../chunks/execute.
|
|
13
|
+
import '../chunks/date.ByMsSlOr.js';
|
|
14
|
+
import '../chunks/utils.BlI4TC7Y.js';
|
|
15
|
+
import '../chunks/execute.B3q-2LPV.js';
|
|
16
16
|
import 'node:fs';
|
|
17
17
|
import '@vitest/utils/error';
|
|
18
18
|
import 'vite-node/client';
|
package/dist/workers.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.
|
|
1
|
+
import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.BKbBp2ga.js';
|
|
2
2
|
import { Awaitable } from '@vitest/utils';
|
|
3
3
|
import * as v8 from 'v8';
|
|
4
|
-
import { a as SerializedConfig } from './chunks/config.d.
|
|
5
|
-
import { W as WorkerContext } from './chunks/worker.d.
|
|
4
|
+
import { a as SerializedConfig } from './chunks/config.d.D2ROskhv.js';
|
|
5
|
+
import { W as WorkerContext } from './chunks/worker.d.Bl1O4kuf.js';
|
|
6
6
|
import '@vitest/runner';
|
|
7
7
|
import 'vite-node';
|
|
8
|
-
import './chunks/environment.d.
|
|
8
|
+
import './chunks/environment.d.cL3nLXbE.js';
|
|
9
9
|
import 'vitest/optional-types.js';
|
|
10
10
|
import '@vitest/snapshot';
|
|
11
11
|
import '@vitest/pretty-format';
|
package/dist/workers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { p as provideWorkerState } from './chunks/utils.
|
|
1
|
+
export { p as provideWorkerState } from './chunks/utils.BlI4TC7Y.js';
|
|
2
2
|
export { collect as collectVitestWorkerTests, run as runVitestWorker } from './worker.js';
|
|
3
|
-
export { r as runBaseTests } from './chunks/base.
|
|
4
|
-
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.
|
|
5
|
-
export { r as runVmTests } from './chunks/vm.
|
|
3
|
+
export { r as runBaseTests } from './chunks/base.D4119yLM.js';
|
|
4
|
+
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.DPCq3gzW.js';
|
|
5
|
+
export { r as runVmTests } from './chunks/vm.DPYem2so.js';
|
|
6
6
|
import '@vitest/utils';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import '@vitest/utils/source-map';
|
|
@@ -10,21 +10,21 @@ import 'tinypool';
|
|
|
10
10
|
import 'vite-node/client';
|
|
11
11
|
import 'node:fs';
|
|
12
12
|
import 'pathe';
|
|
13
|
-
import './chunks/index.
|
|
13
|
+
import './chunks/index.2jgTs_Q5.js';
|
|
14
14
|
import 'node:console';
|
|
15
|
-
import './chunks/inspector.
|
|
15
|
+
import './chunks/inspector.BFsh5KO0.js';
|
|
16
16
|
import 'node:module';
|
|
17
|
-
import './chunks/rpc.
|
|
17
|
+
import './chunks/rpc.BKExFSRG.js';
|
|
18
18
|
import './chunks/index.CJ0plNrh.js';
|
|
19
|
-
import './chunks/execute.
|
|
19
|
+
import './chunks/execute.B3q-2LPV.js';
|
|
20
20
|
import 'node:vm';
|
|
21
21
|
import '@vitest/utils/error';
|
|
22
22
|
import 'vite-node/utils';
|
|
23
23
|
import './path.js';
|
|
24
24
|
import 'node:path';
|
|
25
25
|
import '@vitest/mocker';
|
|
26
|
-
import './chunks/console.
|
|
26
|
+
import './chunks/console.Cwr-MFPV.js';
|
|
27
27
|
import 'node:stream';
|
|
28
28
|
import 'tinyrainbow';
|
|
29
|
-
import './chunks/date.
|
|
29
|
+
import './chunks/date.ByMsSlOr.js';
|
|
30
30
|
import 'vite-node/constants';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.2.0-beta.
|
|
4
|
+
"version": "3.2.0-beta.3",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"types": "./dist/workers.d.ts",
|
|
59
59
|
"import": "./dist/workers.js"
|
|
60
60
|
},
|
|
61
|
-
"./browser": {
|
|
61
|
+
"./internal/browser": {
|
|
62
62
|
"types": "./dist/browser.d.ts",
|
|
63
63
|
"default": "./dist/browser.js"
|
|
64
64
|
},
|
|
@@ -74,10 +74,6 @@
|
|
|
74
74
|
"types": "./dist/environments.d.ts",
|
|
75
75
|
"default": "./dist/environments.js"
|
|
76
76
|
},
|
|
77
|
-
"./utils": {
|
|
78
|
-
"types": "./dist/utils.d.ts",
|
|
79
|
-
"default": "./dist/utils.js"
|
|
80
|
-
},
|
|
81
77
|
"./config": {
|
|
82
78
|
"types": "./config.d.ts",
|
|
83
79
|
"require": "./dist/config.cjs",
|
|
@@ -123,8 +119,8 @@
|
|
|
123
119
|
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
|
|
124
120
|
"happy-dom": "*",
|
|
125
121
|
"jsdom": "*",
|
|
126
|
-
"@vitest/browser": "3.2.0-beta.
|
|
127
|
-
"@vitest/ui": "3.2.0-beta.
|
|
122
|
+
"@vitest/browser": "3.2.0-beta.3",
|
|
123
|
+
"@vitest/ui": "3.2.0-beta.3"
|
|
128
124
|
},
|
|
129
125
|
"peerDependenciesMeta": {
|
|
130
126
|
"@edge-runtime/vm": {
|
|
@@ -150,31 +146,33 @@
|
|
|
150
146
|
}
|
|
151
147
|
},
|
|
152
148
|
"dependencies": {
|
|
149
|
+
"@types/chai": "^5.2.2",
|
|
153
150
|
"chai": "^5.2.0",
|
|
154
|
-
"debug": "^4.4.
|
|
151
|
+
"debug": "^4.4.1",
|
|
155
152
|
"expect-type": "^1.2.1",
|
|
156
153
|
"magic-string": "^0.30.17",
|
|
157
154
|
"pathe": "^2.0.3",
|
|
155
|
+
"picomatch": "^4.0.2",
|
|
158
156
|
"std-env": "^3.9.0",
|
|
159
157
|
"tinybench": "^2.9.0",
|
|
160
158
|
"tinyexec": "^0.3.2",
|
|
161
|
-
"tinyglobby": "^0.2.
|
|
159
|
+
"tinyglobby": "^0.2.14",
|
|
162
160
|
"tinypool": "^1.0.2",
|
|
163
161
|
"tinyrainbow": "^2.0.0",
|
|
164
|
-
"vite": "^5.0.0 || ^6.0.0",
|
|
162
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0",
|
|
165
163
|
"why-is-node-running": "^2.3.0",
|
|
166
|
-
"@vitest/
|
|
167
|
-
"@vitest/
|
|
168
|
-
"@vitest/
|
|
169
|
-
"@vitest/
|
|
170
|
-
"@vitest/spy": "3.2.0-beta.
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
"@vitest/
|
|
164
|
+
"@vitest/expect": "3.2.0-beta.3",
|
|
165
|
+
"@vitest/mocker": "3.2.0-beta.3",
|
|
166
|
+
"@vitest/snapshot": "3.2.0-beta.3",
|
|
167
|
+
"@vitest/utils": "3.2.0-beta.3",
|
|
168
|
+
"@vitest/spy": "3.2.0-beta.3",
|
|
169
|
+
"vite-node": "3.2.0-beta.3",
|
|
170
|
+
"@vitest/pretty-format": "^3.2.0-beta.3",
|
|
171
|
+
"@vitest/runner": "3.2.0-beta.3"
|
|
174
172
|
},
|
|
175
173
|
"devDependencies": {
|
|
176
174
|
"@ampproject/remapping": "^2.3.0",
|
|
177
|
-
"@antfu/install-pkg": "^1.
|
|
175
|
+
"@antfu/install-pkg": "^1.1.0",
|
|
178
176
|
"@edge-runtime/vm": "^5.0.0",
|
|
179
177
|
"@sinonjs/fake-timers": "14.0.0",
|
|
180
178
|
"@types/debug": "^4.1.12",
|
|
@@ -182,8 +180,8 @@
|
|
|
182
180
|
"@types/istanbul-lib-coverage": "^2.0.6",
|
|
183
181
|
"@types/istanbul-reports": "^3.0.4",
|
|
184
182
|
"@types/jsdom": "^21.1.7",
|
|
185
|
-
"@types/
|
|
186
|
-
"@types/
|
|
183
|
+
"@types/node": "^22.15.21",
|
|
184
|
+
"@types/picomatch": "^4.0.0",
|
|
187
185
|
"@types/prompts": "^2.4.9",
|
|
188
186
|
"@types/sinonjs__fake-timers": "^8.1.5",
|
|
189
187
|
"acorn-walk": "^8.3.4",
|
|
@@ -192,15 +190,13 @@
|
|
|
192
190
|
"chai-subset": "^1.6.0",
|
|
193
191
|
"find-up": "^6.3.0",
|
|
194
192
|
"flatted": "^3.3.3",
|
|
195
|
-
"
|
|
196
|
-
"happy-dom": "^17.4.4",
|
|
193
|
+
"happy-dom": "^17.4.7",
|
|
197
194
|
"jsdom": "^26.1.0",
|
|
198
195
|
"local-pkg": "^1.1.1",
|
|
199
|
-
"micromatch": "^4.0.8",
|
|
200
196
|
"pretty-format": "^29.7.0",
|
|
201
197
|
"prompts": "^2.4.2",
|
|
202
198
|
"strip-literal": "^3.0.0",
|
|
203
|
-
"ws": "^8.18.
|
|
199
|
+
"ws": "^8.18.2"
|
|
204
200
|
},
|
|
205
201
|
"scripts": {
|
|
206
202
|
"build": "rimraf dist && rollup -c",
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import process from 'node:process';
|
|
2
|
-
import fs, { existsSync } from 'node:fs';
|
|
3
|
-
import fsPromises from 'node:fs/promises';
|
|
4
|
-
import p, { resolve } from 'node:path';
|
|
5
|
-
import { x } from 'tinyexec';
|
|
6
|
-
|
|
7
|
-
const AGENTS = [
|
|
8
|
-
"npm",
|
|
9
|
-
"yarn",
|
|
10
|
-
"yarn@berry",
|
|
11
|
-
"pnpm",
|
|
12
|
-
"pnpm@6",
|
|
13
|
-
"bun",
|
|
14
|
-
"deno"
|
|
15
|
-
];
|
|
16
|
-
const LOCKS = {
|
|
17
|
-
"bun.lock": "bun",
|
|
18
|
-
"bun.lockb": "bun",
|
|
19
|
-
"deno.lock": "deno",
|
|
20
|
-
"pnpm-lock.yaml": "pnpm",
|
|
21
|
-
"yarn.lock": "yarn",
|
|
22
|
-
"package-lock.json": "npm",
|
|
23
|
-
"npm-shrinkwrap.json": "npm"
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
async function detect(options = {}) {
|
|
27
|
-
const { cwd, onUnknown } = options;
|
|
28
|
-
for (const directory of lookup(cwd)) {
|
|
29
|
-
for (const lock of Object.keys(LOCKS)) {
|
|
30
|
-
if (await fileExists(p.join(directory, lock))) {
|
|
31
|
-
const name = LOCKS[lock];
|
|
32
|
-
const result2 = await parsePackageJson(p.join(directory, "package.json"), onUnknown);
|
|
33
|
-
if (result2)
|
|
34
|
-
return result2;
|
|
35
|
-
else
|
|
36
|
-
return { name, agent: name };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const result = await parsePackageJson(p.join(directory, "package.json"), onUnknown);
|
|
40
|
-
if (result)
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
function* lookup(cwd = process.cwd()) {
|
|
46
|
-
let directory = p.resolve(cwd);
|
|
47
|
-
const { root } = p.parse(directory);
|
|
48
|
-
while (directory && directory !== root) {
|
|
49
|
-
yield directory;
|
|
50
|
-
directory = p.dirname(directory);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async function parsePackageJson(filepath, onUnknown) {
|
|
54
|
-
return !filepath || !await fileExists(filepath) ? null : handlePackageManager(filepath, onUnknown);
|
|
55
|
-
}
|
|
56
|
-
function handlePackageManager(filepath, onUnknown) {
|
|
57
|
-
try {
|
|
58
|
-
const pkg = JSON.parse(fs.readFileSync(filepath, "utf8"));
|
|
59
|
-
let agent;
|
|
60
|
-
if (typeof pkg.packageManager === "string") {
|
|
61
|
-
const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
|
|
62
|
-
let version = ver;
|
|
63
|
-
if (name === "yarn" && Number.parseInt(ver) > 1) {
|
|
64
|
-
agent = "yarn@berry";
|
|
65
|
-
version = "berry";
|
|
66
|
-
return { name, agent, version };
|
|
67
|
-
} else if (name === "pnpm" && Number.parseInt(ver) < 7) {
|
|
68
|
-
agent = "pnpm@6";
|
|
69
|
-
return { name, agent, version };
|
|
70
|
-
} else if (AGENTS.includes(name)) {
|
|
71
|
-
agent = name;
|
|
72
|
-
return { name, agent, version };
|
|
73
|
-
} else {
|
|
74
|
-
return onUnknown?.(pkg.packageManager) ?? null;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
} catch {
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
async function fileExists(filePath) {
|
|
82
|
-
try {
|
|
83
|
-
const stats = await fsPromises.stat(filePath);
|
|
84
|
-
if (stats.isFile()) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
} catch {
|
|
88
|
-
}
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// src/detect.ts
|
|
93
|
-
async function detectPackageManager(cwd = process.cwd()) {
|
|
94
|
-
const result = await detect({
|
|
95
|
-
cwd,
|
|
96
|
-
onUnknown(packageManager) {
|
|
97
|
-
console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
|
|
98
|
-
return void 0;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
return result?.agent || null;
|
|
102
|
-
}
|
|
103
|
-
async function installPackage(names, options = {}) {
|
|
104
|
-
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
|
105
|
-
const [agent] = detectedAgent.split("@");
|
|
106
|
-
if (!Array.isArray(names))
|
|
107
|
-
names = [names];
|
|
108
|
-
const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
|
|
109
|
-
if (options.preferOffline) {
|
|
110
|
-
if (detectedAgent === "yarn@berry")
|
|
111
|
-
args.unshift("--cached");
|
|
112
|
-
else
|
|
113
|
-
args.unshift("--prefer-offline");
|
|
114
|
-
}
|
|
115
|
-
if (agent === "pnpm" && existsSync(resolve(options.cwd ?? process.cwd(), "pnpm-workspace.yaml"))) {
|
|
116
|
-
args.unshift(
|
|
117
|
-
"-w",
|
|
118
|
-
/**
|
|
119
|
-
* Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`
|
|
120
|
-
* @see https://pnpm.io/cli/install#--prod--p
|
|
121
|
-
*/
|
|
122
|
-
"--prod=false"
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
return x(
|
|
126
|
-
agent,
|
|
127
|
-
[
|
|
128
|
-
agent === "yarn" ? "add" : "install",
|
|
129
|
-
options.dev ? "-D" : "",
|
|
130
|
-
...args,
|
|
131
|
-
...names
|
|
132
|
-
].filter(Boolean),
|
|
133
|
-
{
|
|
134
|
-
nodeOptions: {
|
|
135
|
-
stdio: options.silent ? "ignore" : "inherit",
|
|
136
|
-
cwd: options.cwd
|
|
137
|
-
},
|
|
138
|
-
throwOnError: true
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export { detectPackageManager, installPackage };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { g as getWorkerState } from './utils.CgTj3MsC.js';
|
|
2
|
-
|
|
3
|
-
const filesCount = new Map();
|
|
4
|
-
const cache = new Map();
|
|
5
|
-
/**
|
|
6
|
-
* This utils allows computational intensive tasks to only be ran once
|
|
7
|
-
* across test reruns to improve the watch mode performance.
|
|
8
|
-
*
|
|
9
|
-
* Currently only works with `poolOptions.<pool>.isolate: false`
|
|
10
|
-
*
|
|
11
|
-
* @experimental
|
|
12
|
-
*/
|
|
13
|
-
function runOnce(fn, key) {
|
|
14
|
-
const filepath = getWorkerState().filepath || "__unknown_files__";
|
|
15
|
-
if (!key) {
|
|
16
|
-
filesCount.set(filepath, (filesCount.get(filepath) || 0) + 1);
|
|
17
|
-
key = String(filesCount.get(filepath));
|
|
18
|
-
}
|
|
19
|
-
const id = `${filepath}:${key}`;
|
|
20
|
-
if (!cache.has(id)) {
|
|
21
|
-
cache.set(id, fn());
|
|
22
|
-
}
|
|
23
|
-
return cache.get(id);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Get a boolean indicates whether the task is running in the first time.
|
|
27
|
-
* Could only be `false` in watch mode.
|
|
28
|
-
*
|
|
29
|
-
* Currently only works with `isolate: false`
|
|
30
|
-
*
|
|
31
|
-
* @experimental
|
|
32
|
-
*/
|
|
33
|
-
function isFirstRun() {
|
|
34
|
-
let firstRun = false;
|
|
35
|
-
runOnce(() => {
|
|
36
|
-
firstRun = true;
|
|
37
|
-
}, "__vitest_first_run__");
|
|
38
|
-
return firstRun;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
function resetRunOnceCounter() {
|
|
44
|
-
filesCount.clear();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export { runOnce as a, isFirstRun as i, resetRunOnceCounter as r };
|