vitest 0.0.65 → 0.0.66
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/dist/{chunk-NK2VTQLQ.js → chunk-5TNYWP3O.js} +1 -1
- package/dist/{chunk-LRXUKIDM.js → chunk-ANPMHBIF.js} +16 -9
- package/dist/{chunk-3GMBTS5G.js → chunk-APGELTDH.js} +1 -1
- package/dist/{chunk-RNHB4AXG.js → chunk-R2SMNEBL.js} +1 -34
- package/dist/{chunk-SF66BJ42.js → chunk-VLGIKNLC.js} +1 -1
- package/dist/chunk-XUIDSY4V.js +35 -0
- package/dist/{chunk-VAUJEKEW.js → chunk-YPKHVZRP.js} +2 -2
- package/dist/{global-OS2VOPCA.js → global-PRFYLY7P.js} +7 -5
- package/dist/index.d.ts +6 -6
- package/dist/index.js +4 -4
- package/dist/node/cli.d.ts +0 -10
- package/dist/node/cli.js +627 -18
- package/dist/{options-652352ad.d.ts → options-63a726fa.d.ts} +3 -0
- package/dist/runtime/entry.d.ts +1 -1
- package/dist/runtime/entry.js +6 -6
- package/dist/runtime/worker.d.ts +1 -1
- package/dist/runtime/worker.js +6 -4
- package/package.json +2 -2
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
nanoid
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-APGELTDH.js";
|
|
4
4
|
import {
|
|
5
|
-
defaultHookTimeout,
|
|
6
|
-
defaultTestTimeout,
|
|
7
5
|
init_esm_shims
|
|
8
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-R2SMNEBL.js";
|
|
9
7
|
|
|
10
8
|
// src/runtime/suite.ts
|
|
11
9
|
init_esm_shims();
|
|
@@ -40,6 +38,14 @@ var defaultSuite = suite("");
|
|
|
40
38
|
function getCurrentSuite() {
|
|
41
39
|
return context.currentSuite || defaultSuite;
|
|
42
40
|
}
|
|
41
|
+
var getDefaultTestTimeout = () => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
return ((_b = (_a = process.__vitest_worker__) == null ? void 0 : _a.config) == null ? void 0 : _b.testTimeout) ?? 5e3;
|
|
44
|
+
};
|
|
45
|
+
var getDefaultHookTimeout = () => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
return ((_b = (_a = process.__vitest_worker__) == null ? void 0 : _a.config) == null ? void 0 : _b.hookTimeout) ?? 5e3;
|
|
48
|
+
};
|
|
43
49
|
function createSuiteHooks() {
|
|
44
50
|
return {
|
|
45
51
|
beforeAll: [],
|
|
@@ -204,16 +210,17 @@ function createSuite() {
|
|
|
204
210
|
}
|
|
205
211
|
var describe = suite;
|
|
206
212
|
var it = test;
|
|
207
|
-
var beforeAll = (fn, timeout
|
|
208
|
-
var afterAll = (fn, timeout
|
|
209
|
-
var beforeEach = (fn, timeout
|
|
210
|
-
var afterEach = (fn, timeout
|
|
213
|
+
var beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
214
|
+
var afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
215
|
+
var beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
216
|
+
var afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
211
217
|
function clearContext() {
|
|
212
218
|
context.tasks.length = 0;
|
|
213
219
|
defaultSuite.clear();
|
|
214
220
|
context.currentSuite = defaultSuite;
|
|
215
221
|
}
|
|
216
|
-
function withTimeout(fn,
|
|
222
|
+
function withTimeout(fn, _timeout) {
|
|
223
|
+
const timeout = _timeout ?? getDefaultTestTimeout();
|
|
217
224
|
if (timeout <= 0 || timeout === Infinity)
|
|
218
225
|
return fn;
|
|
219
226
|
return (...args) => {
|
|
@@ -81,33 +81,6 @@ var init_esm_shims = __esm({
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
// src/constants.ts
|
|
85
|
-
init_esm_shims();
|
|
86
|
-
import { resolve } from "path";
|
|
87
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
88
|
-
var distDir = resolve(fileURLToPath2(import.meta.url), "../../dist");
|
|
89
|
-
var defaultTestTimeout = 5e3;
|
|
90
|
-
var defaultHookTimeout = 5e3;
|
|
91
|
-
var defaultIncludes = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
92
|
-
var defaultExcludes = ["**/node_modules/**", "**/dist/**"];
|
|
93
|
-
var globalApis = [
|
|
94
|
-
"suite",
|
|
95
|
-
"test",
|
|
96
|
-
"describe",
|
|
97
|
-
"it",
|
|
98
|
-
"chai",
|
|
99
|
-
"expect",
|
|
100
|
-
"assert",
|
|
101
|
-
"sinon",
|
|
102
|
-
"spy",
|
|
103
|
-
"mock",
|
|
104
|
-
"stub",
|
|
105
|
-
"beforeAll",
|
|
106
|
-
"afterAll",
|
|
107
|
-
"beforeEach",
|
|
108
|
-
"afterEach"
|
|
109
|
-
];
|
|
110
|
-
|
|
111
84
|
export {
|
|
112
85
|
__spreadValues,
|
|
113
86
|
__spreadProps,
|
|
@@ -118,11 +91,5 @@ export {
|
|
|
118
91
|
__privateAdd,
|
|
119
92
|
__privateSet,
|
|
120
93
|
__privateWrapper,
|
|
121
|
-
init_esm_shims
|
|
122
|
-
distDir,
|
|
123
|
-
defaultTestTimeout,
|
|
124
|
-
defaultHookTimeout,
|
|
125
|
-
defaultIncludes,
|
|
126
|
-
defaultExcludes,
|
|
127
|
-
globalApis
|
|
94
|
+
init_esm_shims
|
|
128
95
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_esm_shims
|
|
3
|
+
} from "./chunk-R2SMNEBL.js";
|
|
4
|
+
|
|
5
|
+
// src/constants.ts
|
|
6
|
+
init_esm_shims();
|
|
7
|
+
import { resolve } from "path";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
var distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
|
|
10
|
+
var defaultIncludes = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
11
|
+
var defaultExcludes = ["**/node_modules/**", "**/dist/**"];
|
|
12
|
+
var globalApis = [
|
|
13
|
+
"suite",
|
|
14
|
+
"test",
|
|
15
|
+
"describe",
|
|
16
|
+
"it",
|
|
17
|
+
"chai",
|
|
18
|
+
"expect",
|
|
19
|
+
"assert",
|
|
20
|
+
"sinon",
|
|
21
|
+
"spy",
|
|
22
|
+
"mock",
|
|
23
|
+
"stub",
|
|
24
|
+
"beforeAll",
|
|
25
|
+
"afterAll",
|
|
26
|
+
"beforeEach",
|
|
27
|
+
"afterEach"
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
distDir,
|
|
32
|
+
defaultIncludes,
|
|
33
|
+
defaultExcludes,
|
|
34
|
+
globalApis
|
|
35
|
+
};
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
it,
|
|
11
11
|
suite,
|
|
12
12
|
test
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ANPMHBIF.js";
|
|
14
14
|
import {
|
|
15
15
|
__export,
|
|
16
16
|
init_esm_shims
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-R2SMNEBL.js";
|
|
18
18
|
|
|
19
19
|
// src/index.ts
|
|
20
20
|
var src_exports = {};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
src_exports
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
3
|
+
} from "./chunk-YPKHVZRP.js";
|
|
4
|
+
import {
|
|
5
|
+
globalApis
|
|
6
|
+
} from "./chunk-XUIDSY4V.js";
|
|
7
|
+
import "./chunk-ANPMHBIF.js";
|
|
8
|
+
import "./chunk-APGELTDH.js";
|
|
6
9
|
import {
|
|
7
|
-
globalApis,
|
|
8
10
|
init_esm_shims
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-R2SMNEBL.js";
|
|
10
12
|
|
|
11
13
|
// src/integrations/global.ts
|
|
12
14
|
init_esm_shims();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ResolvedConfig, F as File, T as TaskResultPack, S as SnapshotResult, a as TestFactory, b as SuiteCollector, c as TestFunction, d as SuiteHooks, U as UserOptions } from './options-
|
|
2
|
-
export { u as Arrayable, A as Awaitable, C as CliOptions, g as ComputeMode, v as Environment, E as EnvironmentReturn, F as File, G as GlobalContext, H as HookListener, M as ModuleCache, N as Nullable, n as Reporter, R as ResolvedConfig, e as RunMode, o as SnapshotData, r as SnapshotMatchOptions, S as SnapshotResult, q as SnapshotStateOptions, t as SnapshotSummary, p as SnapshotUpdateState, j as Suite, b as SuiteCollector, d as SuiteHooks, l as Task, h as TaskBase, i as TaskResult, T as TaskResultPack, f as TaskState, k as Test, m as TestCollector, a as TestFactory, c as TestFunction, s as UncheckedSnapshot, U as UserOptions, V as VitestContext } from './options-
|
|
1
|
+
import { R as ResolvedConfig, F as File, T as TaskResultPack, S as SnapshotResult, a as TestFactory, b as SuiteCollector, c as TestFunction, d as SuiteHooks, U as UserOptions } from './options-63a726fa';
|
|
2
|
+
export { u as Arrayable, A as Awaitable, C as CliOptions, g as ComputeMode, v as Environment, E as EnvironmentReturn, F as File, G as GlobalContext, H as HookListener, M as ModuleCache, N as Nullable, n as Reporter, R as ResolvedConfig, e as RunMode, o as SnapshotData, r as SnapshotMatchOptions, S as SnapshotResult, q as SnapshotStateOptions, t as SnapshotSummary, p as SnapshotUpdateState, j as Suite, b as SuiteCollector, d as SuiteHooks, l as Task, h as TaskBase, i as TaskResult, T as TaskResultPack, f as TaskState, k as Test, m as TestCollector, a as TestFactory, c as TestFunction, s as UncheckedSnapshot, U as UserOptions, V as VitestContext } from './options-63a726fa';
|
|
3
3
|
import { MessagePort } from 'worker_threads';
|
|
4
4
|
import { TransformResult } from 'vite';
|
|
5
5
|
export { assert, default as chai, expect, should } from 'chai';
|
|
@@ -122,10 +122,10 @@ declare const it: {
|
|
|
122
122
|
concurrent(name: string): void;
|
|
123
123
|
};
|
|
124
124
|
};
|
|
125
|
-
declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number) => void;
|
|
126
|
-
declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number) => void;
|
|
127
|
-
declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number) => void;
|
|
128
|
-
declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number) => void;
|
|
125
|
+
declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number | undefined) => void;
|
|
126
|
+
declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number | undefined) => void;
|
|
127
|
+
declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number | undefined) => void;
|
|
128
|
+
declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number | undefined) => void;
|
|
129
129
|
declare function clearContext(): void;
|
|
130
130
|
|
|
131
131
|
declare const mock: sinon.SinonMockStatic;
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
sinon,
|
|
8
8
|
spy,
|
|
9
9
|
stub
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YPKHVZRP.js";
|
|
11
11
|
import {
|
|
12
12
|
afterAll,
|
|
13
13
|
afterEach,
|
|
@@ -20,9 +20,9 @@ import {
|
|
|
20
20
|
it,
|
|
21
21
|
suite,
|
|
22
22
|
test
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-ANPMHBIF.js";
|
|
24
|
+
import "./chunk-APGELTDH.js";
|
|
25
|
+
import "./chunk-R2SMNEBL.js";
|
|
26
26
|
export {
|
|
27
27
|
afterAll,
|
|
28
28
|
afterEach,
|
package/dist/node/cli.d.ts
CHANGED
package/dist/node/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addSnapshotResult,
|
|
3
3
|
emptySummary
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-VLGIKNLC.js";
|
|
5
5
|
import {
|
|
6
6
|
getNames,
|
|
7
7
|
getSuites,
|
|
@@ -10,7 +10,12 @@ import {
|
|
|
10
10
|
notNullish,
|
|
11
11
|
slash,
|
|
12
12
|
toArray
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-5TNYWP3O.js";
|
|
14
|
+
import {
|
|
15
|
+
defaultExcludes,
|
|
16
|
+
defaultIncludes,
|
|
17
|
+
distDir
|
|
18
|
+
} from "../chunk-XUIDSY4V.js";
|
|
14
19
|
import {
|
|
15
20
|
__commonJS,
|
|
16
21
|
__privateAdd,
|
|
@@ -20,11 +25,8 @@ import {
|
|
|
20
25
|
__spreadProps,
|
|
21
26
|
__spreadValues,
|
|
22
27
|
__toModule,
|
|
23
|
-
defaultExcludes,
|
|
24
|
-
defaultIncludes,
|
|
25
|
-
distDir,
|
|
26
28
|
init_esm_shims
|
|
27
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-R2SMNEBL.js";
|
|
28
30
|
|
|
29
31
|
// node_modules/.pnpm/emoji-regex@9.2.2/node_modules/emoji-regex/index.js
|
|
30
32
|
var require_emoji_regex = __commonJS({
|
|
@@ -39,11 +41,604 @@ var require_emoji_regex = __commonJS({
|
|
|
39
41
|
|
|
40
42
|
// src/node/cli.ts
|
|
41
43
|
init_esm_shims();
|
|
42
|
-
|
|
44
|
+
|
|
45
|
+
// node_modules/.pnpm/cac@6.7.12/node_modules/cac/dist/index.mjs
|
|
46
|
+
init_esm_shims();
|
|
47
|
+
import { EventEmitter } from "events";
|
|
48
|
+
function toArr(any) {
|
|
49
|
+
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
50
|
+
}
|
|
51
|
+
function toVal(out, key, val, opts) {
|
|
52
|
+
var x, old = out[key], nxt = !!~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : !!~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
53
|
+
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
54
|
+
}
|
|
55
|
+
function mri2(args, opts) {
|
|
56
|
+
args = args || [];
|
|
57
|
+
opts = opts || {};
|
|
58
|
+
var k, arr, arg, name, val, out = { _: [] };
|
|
59
|
+
var i = 0, j = 0, idx = 0, len = args.length;
|
|
60
|
+
const alibi = opts.alias !== void 0;
|
|
61
|
+
const strict = opts.unknown !== void 0;
|
|
62
|
+
const defaults = opts.default !== void 0;
|
|
63
|
+
opts.alias = opts.alias || {};
|
|
64
|
+
opts.string = toArr(opts.string);
|
|
65
|
+
opts.boolean = toArr(opts.boolean);
|
|
66
|
+
if (alibi) {
|
|
67
|
+
for (k in opts.alias) {
|
|
68
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
69
|
+
for (i = 0; i < arr.length; i++) {
|
|
70
|
+
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (i = opts.boolean.length; i-- > 0; ) {
|
|
75
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
76
|
+
for (j = arr.length; j-- > 0; )
|
|
77
|
+
opts.boolean.push(arr[j]);
|
|
78
|
+
}
|
|
79
|
+
for (i = opts.string.length; i-- > 0; ) {
|
|
80
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
81
|
+
for (j = arr.length; j-- > 0; )
|
|
82
|
+
opts.string.push(arr[j]);
|
|
83
|
+
}
|
|
84
|
+
if (defaults) {
|
|
85
|
+
for (k in opts.default) {
|
|
86
|
+
name = typeof opts.default[k];
|
|
87
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
88
|
+
if (opts[name] !== void 0) {
|
|
89
|
+
opts[name].push(k);
|
|
90
|
+
for (i = 0; i < arr.length; i++) {
|
|
91
|
+
opts[name].push(arr[i]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
97
|
+
for (i = 0; i < len; i++) {
|
|
98
|
+
arg = args[i];
|
|
99
|
+
if (arg === "--") {
|
|
100
|
+
out._ = out._.concat(args.slice(++i));
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
for (j = 0; j < arg.length; j++) {
|
|
104
|
+
if (arg.charCodeAt(j) !== 45)
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
if (j === 0) {
|
|
108
|
+
out._.push(arg);
|
|
109
|
+
} else if (arg.substring(j, j + 3) === "no-") {
|
|
110
|
+
name = arg.substring(j + 3);
|
|
111
|
+
if (strict && !~keys.indexOf(name)) {
|
|
112
|
+
return opts.unknown(arg);
|
|
113
|
+
}
|
|
114
|
+
out[name] = false;
|
|
115
|
+
} else {
|
|
116
|
+
for (idx = j + 1; idx < arg.length; idx++) {
|
|
117
|
+
if (arg.charCodeAt(idx) === 61)
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
name = arg.substring(j, idx);
|
|
121
|
+
val = arg.substring(++idx) || (i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i]);
|
|
122
|
+
arr = j === 2 ? [name] : name;
|
|
123
|
+
for (idx = 0; idx < arr.length; idx++) {
|
|
124
|
+
name = arr[idx];
|
|
125
|
+
if (strict && !~keys.indexOf(name))
|
|
126
|
+
return opts.unknown("-".repeat(j) + name);
|
|
127
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (defaults) {
|
|
132
|
+
for (k in opts.default) {
|
|
133
|
+
if (out[k] === void 0) {
|
|
134
|
+
out[k] = opts.default[k];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (alibi) {
|
|
139
|
+
for (k in out) {
|
|
140
|
+
arr = opts.alias[k] || [];
|
|
141
|
+
while (arr.length > 0) {
|
|
142
|
+
out[arr.shift()] = out[k];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
var removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
|
|
149
|
+
var findAllBrackets = (v) => {
|
|
150
|
+
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
151
|
+
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
152
|
+
const res = [];
|
|
153
|
+
const parse = (match) => {
|
|
154
|
+
let variadic = false;
|
|
155
|
+
let value = match[1];
|
|
156
|
+
if (value.startsWith("...")) {
|
|
157
|
+
value = value.slice(3);
|
|
158
|
+
variadic = true;
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
required: match[0].startsWith("<"),
|
|
162
|
+
value,
|
|
163
|
+
variadic
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
let angledMatch;
|
|
167
|
+
while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
|
|
168
|
+
res.push(parse(angledMatch));
|
|
169
|
+
}
|
|
170
|
+
let squareMatch;
|
|
171
|
+
while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
|
|
172
|
+
res.push(parse(squareMatch));
|
|
173
|
+
}
|
|
174
|
+
return res;
|
|
175
|
+
};
|
|
176
|
+
var getMriOptions = (options) => {
|
|
177
|
+
const result = { alias: {}, boolean: [] };
|
|
178
|
+
for (const [index, option] of options.entries()) {
|
|
179
|
+
if (option.names.length > 1) {
|
|
180
|
+
result.alias[option.names[0]] = option.names.slice(1);
|
|
181
|
+
}
|
|
182
|
+
if (option.isBoolean) {
|
|
183
|
+
if (option.negated) {
|
|
184
|
+
const hasStringTypeOption = options.some((o, i) => {
|
|
185
|
+
return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
|
|
186
|
+
});
|
|
187
|
+
if (!hasStringTypeOption) {
|
|
188
|
+
result.boolean.push(option.names[0]);
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
result.boolean.push(option.names[0]);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
};
|
|
197
|
+
var findLongest = (arr) => {
|
|
198
|
+
return arr.sort((a, b) => {
|
|
199
|
+
return a.length > b.length ? -1 : 1;
|
|
200
|
+
})[0];
|
|
201
|
+
};
|
|
202
|
+
var padRight = (str, length) => {
|
|
203
|
+
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
204
|
+
};
|
|
205
|
+
var camelcase = (input) => {
|
|
206
|
+
return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
|
|
207
|
+
return p1 + p2.toUpperCase();
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
var setDotProp = (obj, keys, val) => {
|
|
211
|
+
let i = 0;
|
|
212
|
+
let length = keys.length;
|
|
213
|
+
let t = obj;
|
|
214
|
+
let x;
|
|
215
|
+
for (; i < length; ++i) {
|
|
216
|
+
x = t[keys[i]];
|
|
217
|
+
t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
var setByType = (obj, transforms) => {
|
|
221
|
+
for (const key of Object.keys(transforms)) {
|
|
222
|
+
const transform = transforms[key];
|
|
223
|
+
if (transform.shouldTransform) {
|
|
224
|
+
obj[key] = Array.prototype.concat.call([], obj[key]);
|
|
225
|
+
if (typeof transform.transformFunction === "function") {
|
|
226
|
+
obj[key] = obj[key].map(transform.transformFunction);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
var getFileName = (input) => {
|
|
232
|
+
const m = /([^\\\/]+)$/.exec(input);
|
|
233
|
+
return m ? m[1] : "";
|
|
234
|
+
};
|
|
235
|
+
var camelcaseOptionName = (name) => {
|
|
236
|
+
return name.split(".").map((v, i) => {
|
|
237
|
+
return i === 0 ? camelcase(v) : v;
|
|
238
|
+
}).join(".");
|
|
239
|
+
};
|
|
240
|
+
var CACError = class extends Error {
|
|
241
|
+
constructor(message) {
|
|
242
|
+
super(message);
|
|
243
|
+
this.name = this.constructor.name;
|
|
244
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
245
|
+
Error.captureStackTrace(this, this.constructor);
|
|
246
|
+
} else {
|
|
247
|
+
this.stack = new Error(message).stack;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
var Option = class {
|
|
252
|
+
constructor(rawName, description, config) {
|
|
253
|
+
this.rawName = rawName;
|
|
254
|
+
this.description = description;
|
|
255
|
+
this.config = Object.assign({}, config);
|
|
256
|
+
rawName = rawName.replace(/\.\*/g, "");
|
|
257
|
+
this.negated = false;
|
|
258
|
+
this.names = removeBrackets(rawName).split(",").map((v) => {
|
|
259
|
+
let name = v.trim().replace(/^-{1,2}/, "");
|
|
260
|
+
if (name.startsWith("no-")) {
|
|
261
|
+
this.negated = true;
|
|
262
|
+
name = name.replace(/^no-/, "");
|
|
263
|
+
}
|
|
264
|
+
return camelcaseOptionName(name);
|
|
265
|
+
}).sort((a, b) => a.length > b.length ? 1 : -1);
|
|
266
|
+
this.name = this.names[this.names.length - 1];
|
|
267
|
+
if (this.negated && this.config.default == null) {
|
|
268
|
+
this.config.default = true;
|
|
269
|
+
}
|
|
270
|
+
if (rawName.includes("<")) {
|
|
271
|
+
this.required = true;
|
|
272
|
+
} else if (rawName.includes("[")) {
|
|
273
|
+
this.required = false;
|
|
274
|
+
} else {
|
|
275
|
+
this.isBoolean = true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
var processArgs = process.argv;
|
|
280
|
+
var platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
281
|
+
var Command = class {
|
|
282
|
+
constructor(rawName, description, config = {}, cli2) {
|
|
283
|
+
this.rawName = rawName;
|
|
284
|
+
this.description = description;
|
|
285
|
+
this.config = config;
|
|
286
|
+
this.cli = cli2;
|
|
287
|
+
this.options = [];
|
|
288
|
+
this.aliasNames = [];
|
|
289
|
+
this.name = removeBrackets(rawName);
|
|
290
|
+
this.args = findAllBrackets(rawName);
|
|
291
|
+
this.examples = [];
|
|
292
|
+
}
|
|
293
|
+
usage(text) {
|
|
294
|
+
this.usageText = text;
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
allowUnknownOptions() {
|
|
298
|
+
this.config.allowUnknownOptions = true;
|
|
299
|
+
return this;
|
|
300
|
+
}
|
|
301
|
+
ignoreOptionDefaultValue() {
|
|
302
|
+
this.config.ignoreOptionDefaultValue = true;
|
|
303
|
+
return this;
|
|
304
|
+
}
|
|
305
|
+
version(version2, customFlags = "-v, --version") {
|
|
306
|
+
this.versionNumber = version2;
|
|
307
|
+
this.option(customFlags, "Display version number");
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
example(example) {
|
|
311
|
+
this.examples.push(example);
|
|
312
|
+
return this;
|
|
313
|
+
}
|
|
314
|
+
option(rawName, description, config) {
|
|
315
|
+
const option = new Option(rawName, description, config);
|
|
316
|
+
this.options.push(option);
|
|
317
|
+
return this;
|
|
318
|
+
}
|
|
319
|
+
alias(name) {
|
|
320
|
+
this.aliasNames.push(name);
|
|
321
|
+
return this;
|
|
322
|
+
}
|
|
323
|
+
action(callback) {
|
|
324
|
+
this.commandAction = callback;
|
|
325
|
+
return this;
|
|
326
|
+
}
|
|
327
|
+
isMatched(name) {
|
|
328
|
+
return this.name === name || this.aliasNames.includes(name);
|
|
329
|
+
}
|
|
330
|
+
get isDefaultCommand() {
|
|
331
|
+
return this.name === "" || this.aliasNames.includes("!");
|
|
332
|
+
}
|
|
333
|
+
get isGlobalCommand() {
|
|
334
|
+
return this instanceof GlobalCommand;
|
|
335
|
+
}
|
|
336
|
+
hasOption(name) {
|
|
337
|
+
name = name.split(".")[0];
|
|
338
|
+
return this.options.find((option) => {
|
|
339
|
+
return option.names.includes(name);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
outputHelp() {
|
|
343
|
+
const { name, commands } = this.cli;
|
|
344
|
+
const {
|
|
345
|
+
versionNumber,
|
|
346
|
+
options: globalOptions,
|
|
347
|
+
helpCallback
|
|
348
|
+
} = this.cli.globalCommand;
|
|
349
|
+
let sections = [
|
|
350
|
+
{
|
|
351
|
+
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
352
|
+
}
|
|
353
|
+
];
|
|
354
|
+
sections.push({
|
|
355
|
+
title: "Usage",
|
|
356
|
+
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
357
|
+
});
|
|
358
|
+
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
359
|
+
if (showCommands) {
|
|
360
|
+
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
361
|
+
sections.push({
|
|
362
|
+
title: "Commands",
|
|
363
|
+
body: commands.map((command) => {
|
|
364
|
+
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
365
|
+
}).join("\n")
|
|
366
|
+
});
|
|
367
|
+
sections.push({
|
|
368
|
+
title: `For more info, run any command with the \`--help\` flag`,
|
|
369
|
+
body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
|
|
373
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand) {
|
|
374
|
+
options = options.filter((option) => option.name !== "version");
|
|
375
|
+
}
|
|
376
|
+
if (options.length > 0) {
|
|
377
|
+
const longestOptionName = findLongest(options.map((option) => option.rawName));
|
|
378
|
+
sections.push({
|
|
379
|
+
title: "Options",
|
|
380
|
+
body: options.map((option) => {
|
|
381
|
+
return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === void 0 ? "" : `(default: ${option.config.default})`}`;
|
|
382
|
+
}).join("\n")
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
if (this.examples.length > 0) {
|
|
386
|
+
sections.push({
|
|
387
|
+
title: "Examples",
|
|
388
|
+
body: this.examples.map((example) => {
|
|
389
|
+
if (typeof example === "function") {
|
|
390
|
+
return example(name);
|
|
391
|
+
}
|
|
392
|
+
return example;
|
|
393
|
+
}).join("\n")
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
if (helpCallback) {
|
|
397
|
+
sections = helpCallback(sections) || sections;
|
|
398
|
+
}
|
|
399
|
+
console.log(sections.map((section) => {
|
|
400
|
+
return section.title ? `${section.title}:
|
|
401
|
+
${section.body}` : section.body;
|
|
402
|
+
}).join("\n\n"));
|
|
403
|
+
}
|
|
404
|
+
outputVersion() {
|
|
405
|
+
const { name } = this.cli;
|
|
406
|
+
const { versionNumber } = this.cli.globalCommand;
|
|
407
|
+
if (versionNumber) {
|
|
408
|
+
console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
checkRequiredArgs() {
|
|
412
|
+
const minimalArgsCount = this.args.filter((arg) => arg.required).length;
|
|
413
|
+
if (this.cli.args.length < minimalArgsCount) {
|
|
414
|
+
throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
checkUnknownOptions() {
|
|
418
|
+
const { options, globalCommand } = this.cli;
|
|
419
|
+
if (!this.config.allowUnknownOptions) {
|
|
420
|
+
for (const name of Object.keys(options)) {
|
|
421
|
+
if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
|
|
422
|
+
throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
checkOptionValue() {
|
|
428
|
+
const { options: parsedOptions, globalCommand } = this.cli;
|
|
429
|
+
const options = [...globalCommand.options, ...this.options];
|
|
430
|
+
for (const option of options) {
|
|
431
|
+
const value = parsedOptions[option.name.split(".")[0]];
|
|
432
|
+
if (option.required) {
|
|
433
|
+
const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
|
|
434
|
+
if (value === true || value === false && !hasNegated) {
|
|
435
|
+
throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
var GlobalCommand = class extends Command {
|
|
442
|
+
constructor(cli2) {
|
|
443
|
+
super("@@global@@", "", {}, cli2);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
var __assign = Object.assign;
|
|
447
|
+
var CAC = class extends EventEmitter {
|
|
448
|
+
constructor(name = "") {
|
|
449
|
+
super();
|
|
450
|
+
this.name = name;
|
|
451
|
+
this.commands = [];
|
|
452
|
+
this.rawArgs = [];
|
|
453
|
+
this.args = [];
|
|
454
|
+
this.options = {};
|
|
455
|
+
this.globalCommand = new GlobalCommand(this);
|
|
456
|
+
this.globalCommand.usage("<command> [options]");
|
|
457
|
+
}
|
|
458
|
+
usage(text) {
|
|
459
|
+
this.globalCommand.usage(text);
|
|
460
|
+
return this;
|
|
461
|
+
}
|
|
462
|
+
command(rawName, description, config) {
|
|
463
|
+
const command = new Command(rawName, description || "", config, this);
|
|
464
|
+
command.globalCommand = this.globalCommand;
|
|
465
|
+
this.commands.push(command);
|
|
466
|
+
return command;
|
|
467
|
+
}
|
|
468
|
+
option(rawName, description, config) {
|
|
469
|
+
this.globalCommand.option(rawName, description, config);
|
|
470
|
+
return this;
|
|
471
|
+
}
|
|
472
|
+
help(callback) {
|
|
473
|
+
this.globalCommand.option("-h, --help", "Display this message");
|
|
474
|
+
this.globalCommand.helpCallback = callback;
|
|
475
|
+
this.showHelpOnExit = true;
|
|
476
|
+
return this;
|
|
477
|
+
}
|
|
478
|
+
version(version2, customFlags = "-v, --version") {
|
|
479
|
+
this.globalCommand.version(version2, customFlags);
|
|
480
|
+
this.showVersionOnExit = true;
|
|
481
|
+
return this;
|
|
482
|
+
}
|
|
483
|
+
example(example) {
|
|
484
|
+
this.globalCommand.example(example);
|
|
485
|
+
return this;
|
|
486
|
+
}
|
|
487
|
+
outputHelp() {
|
|
488
|
+
if (this.matchedCommand) {
|
|
489
|
+
this.matchedCommand.outputHelp();
|
|
490
|
+
} else {
|
|
491
|
+
this.globalCommand.outputHelp();
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
outputVersion() {
|
|
495
|
+
this.globalCommand.outputVersion();
|
|
496
|
+
}
|
|
497
|
+
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
498
|
+
this.args = args;
|
|
499
|
+
this.options = options;
|
|
500
|
+
if (matchedCommand) {
|
|
501
|
+
this.matchedCommand = matchedCommand;
|
|
502
|
+
}
|
|
503
|
+
if (matchedCommandName) {
|
|
504
|
+
this.matchedCommandName = matchedCommandName;
|
|
505
|
+
}
|
|
506
|
+
return this;
|
|
507
|
+
}
|
|
508
|
+
unsetMatchedCommand() {
|
|
509
|
+
this.matchedCommand = void 0;
|
|
510
|
+
this.matchedCommandName = void 0;
|
|
511
|
+
}
|
|
512
|
+
parse(argv = processArgs, {
|
|
513
|
+
run: run2 = true
|
|
514
|
+
} = {}) {
|
|
515
|
+
this.rawArgs = argv;
|
|
516
|
+
if (!this.name) {
|
|
517
|
+
this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
518
|
+
}
|
|
519
|
+
let shouldParse = true;
|
|
520
|
+
for (const command of this.commands) {
|
|
521
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
522
|
+
const commandName = parsed.args[0];
|
|
523
|
+
if (command.isMatched(commandName)) {
|
|
524
|
+
shouldParse = false;
|
|
525
|
+
const parsedInfo = __assign(__assign({}, parsed), {
|
|
526
|
+
args: parsed.args.slice(1)
|
|
527
|
+
});
|
|
528
|
+
this.setParsedInfo(parsedInfo, command, commandName);
|
|
529
|
+
this.emit(`command:${commandName}`, command);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (shouldParse) {
|
|
533
|
+
for (const command of this.commands) {
|
|
534
|
+
if (command.name === "") {
|
|
535
|
+
shouldParse = false;
|
|
536
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
537
|
+
this.setParsedInfo(parsed, command);
|
|
538
|
+
this.emit(`command:!`, command);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (shouldParse) {
|
|
543
|
+
const parsed = this.mri(argv.slice(2));
|
|
544
|
+
this.setParsedInfo(parsed);
|
|
545
|
+
}
|
|
546
|
+
if (this.options.help && this.showHelpOnExit) {
|
|
547
|
+
this.outputHelp();
|
|
548
|
+
run2 = false;
|
|
549
|
+
this.unsetMatchedCommand();
|
|
550
|
+
}
|
|
551
|
+
if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
|
|
552
|
+
this.outputVersion();
|
|
553
|
+
run2 = false;
|
|
554
|
+
this.unsetMatchedCommand();
|
|
555
|
+
}
|
|
556
|
+
const parsedArgv = { args: this.args, options: this.options };
|
|
557
|
+
if (run2) {
|
|
558
|
+
this.runMatchedCommand();
|
|
559
|
+
}
|
|
560
|
+
if (!this.matchedCommand && this.args[0]) {
|
|
561
|
+
this.emit("command:*");
|
|
562
|
+
}
|
|
563
|
+
return parsedArgv;
|
|
564
|
+
}
|
|
565
|
+
mri(argv, command) {
|
|
566
|
+
const cliOptions = [
|
|
567
|
+
...this.globalCommand.options,
|
|
568
|
+
...command ? command.options : []
|
|
569
|
+
];
|
|
570
|
+
const mriOptions = getMriOptions(cliOptions);
|
|
571
|
+
let argsAfterDoubleDashes = [];
|
|
572
|
+
const doubleDashesIndex = argv.indexOf("--");
|
|
573
|
+
if (doubleDashesIndex > -1) {
|
|
574
|
+
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
575
|
+
argv = argv.slice(0, doubleDashesIndex);
|
|
576
|
+
}
|
|
577
|
+
let parsed = mri2(argv, mriOptions);
|
|
578
|
+
parsed = Object.keys(parsed).reduce((res, name) => {
|
|
579
|
+
return __assign(__assign({}, res), {
|
|
580
|
+
[camelcaseOptionName(name)]: parsed[name]
|
|
581
|
+
});
|
|
582
|
+
}, { _: [] });
|
|
583
|
+
const args = parsed._;
|
|
584
|
+
const options = {
|
|
585
|
+
"--": argsAfterDoubleDashes
|
|
586
|
+
};
|
|
587
|
+
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
588
|
+
let transforms = Object.create(null);
|
|
589
|
+
for (const cliOption of cliOptions) {
|
|
590
|
+
if (!ignoreDefault && cliOption.config.default !== void 0) {
|
|
591
|
+
for (const name of cliOption.names) {
|
|
592
|
+
options[name] = cliOption.config.default;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (Array.isArray(cliOption.config.type)) {
|
|
596
|
+
if (transforms[cliOption.name] === void 0) {
|
|
597
|
+
transforms[cliOption.name] = Object.create(null);
|
|
598
|
+
transforms[cliOption.name]["shouldTransform"] = true;
|
|
599
|
+
transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
for (const key of Object.keys(parsed)) {
|
|
604
|
+
if (key !== "_") {
|
|
605
|
+
const keys = key.split(".");
|
|
606
|
+
setDotProp(options, keys, parsed[key]);
|
|
607
|
+
setByType(options, transforms);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return {
|
|
611
|
+
args,
|
|
612
|
+
options
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
runMatchedCommand() {
|
|
616
|
+
const { args, options, matchedCommand: command } = this;
|
|
617
|
+
if (!command || !command.commandAction)
|
|
618
|
+
return;
|
|
619
|
+
command.checkUnknownOptions();
|
|
620
|
+
command.checkOptionValue();
|
|
621
|
+
command.checkRequiredArgs();
|
|
622
|
+
const actionArgs = [];
|
|
623
|
+
command.args.forEach((arg, index) => {
|
|
624
|
+
if (arg.variadic) {
|
|
625
|
+
actionArgs.push(args.slice(index));
|
|
626
|
+
} else {
|
|
627
|
+
actionArgs.push(args[index]);
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
actionArgs.push(options);
|
|
631
|
+
return command.commandAction.apply(this, actionArgs);
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
var cac = (name = "") => new CAC(name);
|
|
635
|
+
var dist_default = cac;
|
|
636
|
+
|
|
637
|
+
// src/node/cli.ts
|
|
43
638
|
import c4 from "picocolors";
|
|
44
639
|
|
|
45
640
|
// package.json
|
|
46
|
-
var version = "0.0.
|
|
641
|
+
var version = "0.0.66";
|
|
47
642
|
|
|
48
643
|
// src/reporters/default.ts
|
|
49
644
|
init_esm_shims();
|
|
@@ -1282,8 +1877,9 @@ var isTTY = process.stdout.isTTY && !process.env.CI;
|
|
|
1282
1877
|
var DefaultReporter = class {
|
|
1283
1878
|
constructor(ctx) {
|
|
1284
1879
|
this.ctx = ctx;
|
|
1285
|
-
|
|
1286
|
-
|
|
1880
|
+
const mode = ctx.config.watch ? c3.yellow(" DEV ") : c3.cyan(" RUN ");
|
|
1881
|
+
console.log(`${c3.inverse(c3.bold(mode))} ${c3.gray(this.ctx.config.root)}
|
|
1882
|
+
`);
|
|
1287
1883
|
this.start = performance.now();
|
|
1288
1884
|
}
|
|
1289
1885
|
start = 0;
|
|
@@ -1507,7 +2103,7 @@ function pLimit(concurrency) {
|
|
|
1507
2103
|
queue.dequeue()();
|
|
1508
2104
|
}
|
|
1509
2105
|
};
|
|
1510
|
-
const
|
|
2106
|
+
const run2 = async (fn, resolve2, args) => {
|
|
1511
2107
|
activeCount++;
|
|
1512
2108
|
const result = (async () => fn(...args))();
|
|
1513
2109
|
resolve2(result);
|
|
@@ -1518,7 +2114,7 @@ function pLimit(concurrency) {
|
|
|
1518
2114
|
next();
|
|
1519
2115
|
};
|
|
1520
2116
|
const enqueue = (fn, resolve2, args) => {
|
|
1521
|
-
queue.enqueue(
|
|
2117
|
+
queue.enqueue(run2.bind(void 0, fn, resolve2, args));
|
|
1522
2118
|
(async () => {
|
|
1523
2119
|
await Promise.resolve();
|
|
1524
2120
|
if (activeCount < concurrency && queue.size > 0) {
|
|
@@ -1665,6 +2261,8 @@ async function initViteServer(options = {}) {
|
|
|
1665
2261
|
var _a, _b;
|
|
1666
2262
|
const root = resolve(options.root || process.cwd());
|
|
1667
2263
|
process.chdir(root);
|
|
2264
|
+
if (options.dom)
|
|
2265
|
+
options.environment = "happy-dom";
|
|
1668
2266
|
const configPath = options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
1669
2267
|
const resolved = __spreadValues({}, options);
|
|
1670
2268
|
resolved.config = configPath;
|
|
@@ -1738,7 +2336,7 @@ function createPool(ctx) {
|
|
|
1738
2336
|
var workerPath = new URL("./dist/runtime/worker.js", pathToFileURL(distDir)).href;
|
|
1739
2337
|
function createFakePool(ctx) {
|
|
1740
2338
|
const runTestFiles = async (files, invalidates) => {
|
|
1741
|
-
const { default:
|
|
2339
|
+
const { default: run2 } = await import(workerPath);
|
|
1742
2340
|
const { workerPort, port } = createChannel(ctx);
|
|
1743
2341
|
const data = {
|
|
1744
2342
|
port: workerPort,
|
|
@@ -1746,7 +2344,7 @@ function createFakePool(ctx) {
|
|
|
1746
2344
|
files,
|
|
1747
2345
|
invalidates
|
|
1748
2346
|
};
|
|
1749
|
-
await
|
|
2347
|
+
await run2(data, { transferList: [workerPort] });
|
|
1750
2348
|
port.close();
|
|
1751
2349
|
workerPort.close();
|
|
1752
2350
|
};
|
|
@@ -1976,12 +2574,23 @@ var StateManager = class {
|
|
|
1976
2574
|
};
|
|
1977
2575
|
|
|
1978
2576
|
// src/node/cli.ts
|
|
1979
|
-
|
|
2577
|
+
var cli = dist_default("vitest");
|
|
2578
|
+
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
|
|
2579
|
+
default: "node"
|
|
2580
|
+
}).help();
|
|
2581
|
+
cli.command("run [...filters]").action(run);
|
|
2582
|
+
cli.command("watch [...filters]").action(dev);
|
|
2583
|
+
cli.command("dev [...filters]").action(dev);
|
|
2584
|
+
cli.command("[...filters]").action(dev);
|
|
2585
|
+
cli.parse();
|
|
2586
|
+
async function dev(cliFilters, argv) {
|
|
2587
|
+
argv.watch = !process.env.CI;
|
|
2588
|
+
await run(cliFilters, argv);
|
|
2589
|
+
}
|
|
2590
|
+
async function run(cliFilters, argv) {
|
|
1980
2591
|
process.env.VITEST = "true";
|
|
1981
2592
|
console.log(c4.magenta(c4.bold("\nVitest is in closed beta exclusively for Sponsors")));
|
|
1982
2593
|
console.log(c4.yellow("Learn more at https://vitest.dev\n"));
|
|
1983
|
-
if (argv.dom)
|
|
1984
|
-
argv.environment = "happy-dom";
|
|
1985
2594
|
const { config, server } = await initViteServer(__spreadProps(__spreadValues({}, argv), { cliFilters }));
|
|
1986
2595
|
const ctx = process.__vitest__ = {
|
|
1987
2596
|
server,
|
|
@@ -2000,4 +2609,4 @@ sade("vitest [filter]", true).version(version).describe("A blazing fast unit tes
|
|
|
2000
2609
|
if (!config.watch)
|
|
2001
2610
|
await server.close();
|
|
2002
2611
|
}
|
|
2003
|
-
}
|
|
2612
|
+
}
|
|
@@ -263,6 +263,8 @@ interface UserOptions {
|
|
|
263
263
|
*/
|
|
264
264
|
minThreads?: number;
|
|
265
265
|
interpretDefault?: boolean;
|
|
266
|
+
testTimeout?: number;
|
|
267
|
+
hookTimeout?: number;
|
|
266
268
|
}
|
|
267
269
|
interface CliOptions extends UserOptions {
|
|
268
270
|
/**
|
|
@@ -279,6 +281,7 @@ interface CliOptions extends UserOptions {
|
|
|
279
281
|
* - `vite.config.ts`
|
|
280
282
|
*/
|
|
281
283
|
config?: string | undefined;
|
|
284
|
+
dom?: boolean;
|
|
282
285
|
}
|
|
283
286
|
interface ResolvedConfig extends Omit<Required<CliOptions>, 'config' | 'filters'> {
|
|
284
287
|
config?: string;
|
package/dist/runtime/entry.d.ts
CHANGED
package/dist/runtime/entry.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
packSnapshotState
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-VLGIKNLC.js";
|
|
4
4
|
import {
|
|
5
5
|
getNames,
|
|
6
6
|
hasFailed,
|
|
7
7
|
hasTests,
|
|
8
8
|
interpretOnlyMode,
|
|
9
9
|
partitionSuiteChildren
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-5TNYWP3O.js";
|
|
11
11
|
import {
|
|
12
12
|
clearContext,
|
|
13
13
|
context,
|
|
@@ -16,16 +16,16 @@ import {
|
|
|
16
16
|
getFn,
|
|
17
17
|
getHooks,
|
|
18
18
|
setHooks
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-ANPMHBIF.js";
|
|
20
20
|
import {
|
|
21
21
|
nanoid
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-APGELTDH.js";
|
|
23
23
|
import {
|
|
24
24
|
__commonJS,
|
|
25
25
|
__spreadValues,
|
|
26
26
|
__toModule,
|
|
27
27
|
init_esm_shims
|
|
28
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-R2SMNEBL.js";
|
|
29
29
|
|
|
30
30
|
// node_modules/.pnpm/natural-compare@1.4.0/node_modules/natural-compare/index.js
|
|
31
31
|
var require_natural_compare = __commonJS({
|
|
@@ -2336,7 +2336,7 @@ async function setupChai() {
|
|
|
2336
2336
|
async function setupGlobalEnv(config) {
|
|
2337
2337
|
await setupChai();
|
|
2338
2338
|
if (config.global)
|
|
2339
|
-
(await import("../global-
|
|
2339
|
+
(await import("../global-PRFYLY7P.js")).registerApiGlobally();
|
|
2340
2340
|
}
|
|
2341
2341
|
async function withEnv(name, fn) {
|
|
2342
2342
|
const env = await environments[name].setup(globalThis);
|
package/dist/runtime/worker.d.ts
CHANGED
package/dist/runtime/worker.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
slash
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-5TNYWP3O.js";
|
|
4
|
+
import {
|
|
5
|
+
distDir
|
|
6
|
+
} from "../chunk-XUIDSY4V.js";
|
|
4
7
|
import {
|
|
5
8
|
nanoid
|
|
6
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-APGELTDH.js";
|
|
7
10
|
import {
|
|
8
|
-
distDir,
|
|
9
11
|
init_esm_shims
|
|
10
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-R2SMNEBL.js";
|
|
11
13
|
|
|
12
14
|
// src/runtime/worker.ts
|
|
13
15
|
init_esm_shims();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.66",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
"micromatch": "^4.0.4",
|
|
65
65
|
"picocolors": "^1.0.0",
|
|
66
66
|
"piscina": "^3.2.0",
|
|
67
|
-
"sade": "^1.7.4",
|
|
68
67
|
"sinon": "^12.0.1",
|
|
69
68
|
"sinon-chai": "^3.7.0",
|
|
70
69
|
"source-map": "^0.7.3"
|
|
@@ -82,6 +81,7 @@
|
|
|
82
81
|
"@types/sinon": "^10.0.6",
|
|
83
82
|
"bumpp": "^7.1.1",
|
|
84
83
|
"c8": "^7.10.0",
|
|
84
|
+
"cac": "^6.7.12",
|
|
85
85
|
"cli-truncate": "^3.1.0",
|
|
86
86
|
"diff": "^5.0.0",
|
|
87
87
|
"eslint": "^8.4.1",
|