@rstest/core 0.1.3 → 0.2.1
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 +26 -0
- package/bin/rstest.js +1 -1
- package/dist/25.js +91 -0
- package/dist/285.js +4 -3
- package/dist/355.js +1 -1
- package/dist/359.js +10 -6
- package/dist/64.js +1 -1
- package/dist/668.js +1439 -0
- package/dist/668.js.LICENSE.txt +1 -0
- package/dist/813.js +1 -1
- package/dist/854.js +6 -3
- package/dist/867.js +1 -1
- package/dist/920.js +170 -57
- package/dist/{cli.js → index.js} +681 -606
- package/dist/worker.js +2 -2
- package/dist-types/{public.d.ts → index.d.ts} +13 -5
- package/dist-types/worker.d.ts +4 -0
- package/package.json +7 -10
- package/dist/node.js +0 -2
- package/dist/public.js +0 -6
- package/dist-types/cli.d.ts +0 -3
- package/dist-types/node.d.ts +0 -450
package/dist/{cli.js → index.js}
RENAMED
|
@@ -3,6 +3,8 @@ const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.ur
|
|
|
3
3
|
import node_process from "node:process";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_birpc__ from "birpc";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE_events__ from "events";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE_fs_promises_400951f8__ from "fs/promises";
|
|
6
8
|
import * as __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__ from "node:events";
|
|
7
9
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
8
10
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
|
|
@@ -10,6 +12,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_inspector_dd9822d6__ from "node:inspe
|
|
|
10
12
|
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
11
13
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
12
14
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
15
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_stream_444d1c2b__ from "node:stream";
|
|
13
16
|
import * as __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__ from "node:tty";
|
|
14
17
|
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
15
18
|
import * as __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__ from "node:util";
|
|
@@ -17,7 +20,6 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__ from "node:v8";
|
|
|
17
20
|
import * as __WEBPACK_EXTERNAL_MODULE_pathe__ from "pathe";
|
|
18
21
|
import * as __WEBPACK_EXTERNAL_MODULE_std_env_1c7b8267__ from "std-env";
|
|
19
22
|
import * as __WEBPACK_EXTERNAL_MODULE_tinypool__ from "tinypool";
|
|
20
|
-
import { EventEmitter } from "events";
|
|
21
23
|
var __webpack_modules__ = {
|
|
22
24
|
"../../node_modules/.pnpm/fdir@6.4.4_picomatch@4.0.2/node_modules/fdir/dist/api/async.js": function(__unused_webpack_module, exports, __webpack_require__) {
|
|
23
25
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -235,7 +237,7 @@ var __webpack_modules__ = {
|
|
|
235
237
|
value: true
|
|
236
238
|
});
|
|
237
239
|
exports.build = void 0;
|
|
238
|
-
const fs_1 = __importDefault(__webpack_require__("fs"));
|
|
240
|
+
const fs_1 = __importDefault(__webpack_require__("node:fs"));
|
|
239
241
|
const path_1 = __webpack_require__("node:path");
|
|
240
242
|
const resolveSymlinksAsync = function(path, state, callback) {
|
|
241
243
|
const { queue, options: { suppressErrors } } = state;
|
|
@@ -294,7 +296,7 @@ var __webpack_modules__ = {
|
|
|
294
296
|
value: true
|
|
295
297
|
});
|
|
296
298
|
exports.build = void 0;
|
|
297
|
-
const fs_1 = __importDefault(__webpack_require__("fs"));
|
|
299
|
+
const fs_1 = __importDefault(__webpack_require__("node:fs"));
|
|
298
300
|
const readdirOpts = {
|
|
299
301
|
withFileTypes: true
|
|
300
302
|
};
|
|
@@ -2177,12 +2179,652 @@ var __webpack_modules__ = {
|
|
|
2177
2179
|
return last;
|
|
2178
2180
|
};
|
|
2179
2181
|
},
|
|
2182
|
+
"./src/cli/commands.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2183
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
2184
|
+
mR: ()=>runRest,
|
|
2185
|
+
X_: ()=>setupCommands
|
|
2186
|
+
});
|
|
2187
|
+
var external_events_ = __webpack_require__("events");
|
|
2188
|
+
function toArr(any) {
|
|
2189
|
+
return null == any ? [] : Array.isArray(any) ? any : [
|
|
2190
|
+
any
|
|
2191
|
+
];
|
|
2192
|
+
}
|
|
2193
|
+
function toVal(out, key, val, opts) {
|
|
2194
|
+
var x, old = out[key], nxt = ~opts.string.indexOf(key) ? null == val || true === val ? '' : String(val) : 'boolean' == typeof val ? val : ~opts.boolean.indexOf(key) ? 'false' === val ? false : 'true' === val || (out._.push((x = +val, 0 * x === 0) ? x : val), !!val) : (x = +val, 0 * x === 0) ? x : val;
|
|
2195
|
+
out[key] = null == old ? nxt : Array.isArray(old) ? old.concat(nxt) : [
|
|
2196
|
+
old,
|
|
2197
|
+
nxt
|
|
2198
|
+
];
|
|
2199
|
+
}
|
|
2200
|
+
function mri2(args, opts) {
|
|
2201
|
+
args = args || [];
|
|
2202
|
+
opts = opts || {};
|
|
2203
|
+
var k, arr, arg, name, val, out = {
|
|
2204
|
+
_: []
|
|
2205
|
+
};
|
|
2206
|
+
var i = 0, j = 0, idx = 0, len = args.length;
|
|
2207
|
+
const alibi = void 0 !== opts.alias;
|
|
2208
|
+
const strict = void 0 !== opts.unknown;
|
|
2209
|
+
const defaults = void 0 !== opts.default;
|
|
2210
|
+
opts.alias = opts.alias || {};
|
|
2211
|
+
opts.string = toArr(opts.string);
|
|
2212
|
+
opts.boolean = toArr(opts.boolean);
|
|
2213
|
+
if (alibi) for(k in opts.alias){
|
|
2214
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
2215
|
+
for(i = 0; i < arr.length; i++)(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
2216
|
+
}
|
|
2217
|
+
for(i = opts.boolean.length; i-- > 0;){
|
|
2218
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
2219
|
+
for(j = arr.length; j-- > 0;)opts.boolean.push(arr[j]);
|
|
2220
|
+
}
|
|
2221
|
+
for(i = opts.string.length; i-- > 0;){
|
|
2222
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
2223
|
+
for(j = arr.length; j-- > 0;)opts.string.push(arr[j]);
|
|
2224
|
+
}
|
|
2225
|
+
if (defaults) for(k in opts.default){
|
|
2226
|
+
name = typeof opts.default[k];
|
|
2227
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
2228
|
+
if (void 0 !== opts[name]) {
|
|
2229
|
+
opts[name].push(k);
|
|
2230
|
+
for(i = 0; i < arr.length; i++)opts[name].push(arr[i]);
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
2234
|
+
for(i = 0; i < len; i++){
|
|
2235
|
+
arg = args[i];
|
|
2236
|
+
if ('--' === arg) {
|
|
2237
|
+
out._ = out._.concat(args.slice(++i));
|
|
2238
|
+
break;
|
|
2239
|
+
}
|
|
2240
|
+
for(j = 0; j < arg.length && 45 === arg.charCodeAt(j); j++);
|
|
2241
|
+
if (0 === j) out._.push(arg);
|
|
2242
|
+
else if ('no-' === arg.substring(j, j + 3)) {
|
|
2243
|
+
name = arg.substring(j + 3);
|
|
2244
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
|
|
2245
|
+
out[name] = false;
|
|
2246
|
+
} else {
|
|
2247
|
+
for(idx = j + 1; idx < arg.length && 61 !== arg.charCodeAt(idx); idx++);
|
|
2248
|
+
name = arg.substring(j, idx);
|
|
2249
|
+
val = arg.substring(++idx) || i + 1 === len || 45 === ('' + args[i + 1]).charCodeAt(0) || args[++i];
|
|
2250
|
+
arr = 2 === j ? [
|
|
2251
|
+
name
|
|
2252
|
+
] : name;
|
|
2253
|
+
for(idx = 0; idx < arr.length; idx++){
|
|
2254
|
+
name = arr[idx];
|
|
2255
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
|
2256
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
if (defaults) {
|
|
2261
|
+
for(k in opts.default)if (void 0 === out[k]) out[k] = opts.default[k];
|
|
2262
|
+
}
|
|
2263
|
+
if (alibi) for(k in out){
|
|
2264
|
+
arr = opts.alias[k] || [];
|
|
2265
|
+
while(arr.length > 0)out[arr.shift()] = out[k];
|
|
2266
|
+
}
|
|
2267
|
+
return out;
|
|
2268
|
+
}
|
|
2269
|
+
const removeBrackets = (v)=>v.replace(/[<[].+/, "").trim();
|
|
2270
|
+
const findAllBrackets = (v)=>{
|
|
2271
|
+
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
2272
|
+
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
2273
|
+
const res = [];
|
|
2274
|
+
const parse = (match)=>{
|
|
2275
|
+
let variadic = false;
|
|
2276
|
+
let value = match[1];
|
|
2277
|
+
if (value.startsWith("...")) {
|
|
2278
|
+
value = value.slice(3);
|
|
2279
|
+
variadic = true;
|
|
2280
|
+
}
|
|
2281
|
+
return {
|
|
2282
|
+
required: match[0].startsWith("<"),
|
|
2283
|
+
value,
|
|
2284
|
+
variadic
|
|
2285
|
+
};
|
|
2286
|
+
};
|
|
2287
|
+
let angledMatch;
|
|
2288
|
+
while(angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v))res.push(parse(angledMatch));
|
|
2289
|
+
let squareMatch;
|
|
2290
|
+
while(squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v))res.push(parse(squareMatch));
|
|
2291
|
+
return res;
|
|
2292
|
+
};
|
|
2293
|
+
const getMriOptions = (options)=>{
|
|
2294
|
+
const result = {
|
|
2295
|
+
alias: {},
|
|
2296
|
+
boolean: []
|
|
2297
|
+
};
|
|
2298
|
+
for (const [index, option] of options.entries()){
|
|
2299
|
+
if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
|
|
2300
|
+
if (option.isBoolean) if (option.negated) {
|
|
2301
|
+
const hasStringTypeOption = options.some((o, i)=>i !== index && o.names.some((name)=>option.names.includes(name)) && "boolean" == typeof o.required);
|
|
2302
|
+
if (!hasStringTypeOption) result.boolean.push(option.names[0]);
|
|
2303
|
+
} else result.boolean.push(option.names[0]);
|
|
2304
|
+
}
|
|
2305
|
+
return result;
|
|
2306
|
+
};
|
|
2307
|
+
const findLongest = (arr)=>arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0];
|
|
2308
|
+
const padRight = (str, length)=>str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
2309
|
+
const camelcase = (input)=>input.replace(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
|
|
2310
|
+
const setDotProp = (obj, keys, val)=>{
|
|
2311
|
+
let i = 0;
|
|
2312
|
+
let length = keys.length;
|
|
2313
|
+
let t = obj;
|
|
2314
|
+
let x;
|
|
2315
|
+
for(; i < length; ++i){
|
|
2316
|
+
x = t[keys[i]];
|
|
2317
|
+
t = t[keys[i]] = i === length - 1 ? val : null != x ? x : !~keys[i + 1].indexOf(".") && +keys[i + 1] > -1 ? [] : {};
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
const setByType = (obj, transforms)=>{
|
|
2321
|
+
for (const key of Object.keys(transforms)){
|
|
2322
|
+
const transform = transforms[key];
|
|
2323
|
+
if (transform.shouldTransform) {
|
|
2324
|
+
obj[key] = Array.prototype.concat.call([], obj[key]);
|
|
2325
|
+
if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
};
|
|
2329
|
+
const getFileName = (input)=>{
|
|
2330
|
+
const m = /([^\\\/]+)$/.exec(input);
|
|
2331
|
+
return m ? m[1] : "";
|
|
2332
|
+
};
|
|
2333
|
+
const camelcaseOptionName = (name)=>name.split(".").map((v, i)=>0 === i ? camelcase(v) : v).join(".");
|
|
2334
|
+
class CACError extends Error {
|
|
2335
|
+
constructor(message){
|
|
2336
|
+
super(message);
|
|
2337
|
+
this.name = this.constructor.name;
|
|
2338
|
+
if ("function" == typeof Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
2339
|
+
else this.stack = new Error(message).stack;
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
class Option {
|
|
2343
|
+
constructor(rawName, description, config){
|
|
2344
|
+
this.rawName = rawName;
|
|
2345
|
+
this.description = description;
|
|
2346
|
+
this.config = Object.assign({}, config);
|
|
2347
|
+
rawName = rawName.replace(/\.\*/g, "");
|
|
2348
|
+
this.negated = false;
|
|
2349
|
+
this.names = removeBrackets(rawName).split(",").map((v)=>{
|
|
2350
|
+
let name = v.trim().replace(/^-{1,2}/, "");
|
|
2351
|
+
if (name.startsWith("no-")) {
|
|
2352
|
+
this.negated = true;
|
|
2353
|
+
name = name.replace(/^no-/, "");
|
|
2354
|
+
}
|
|
2355
|
+
return camelcaseOptionName(name);
|
|
2356
|
+
}).sort((a, b)=>a.length > b.length ? 1 : -1);
|
|
2357
|
+
this.name = this.names[this.names.length - 1];
|
|
2358
|
+
if (this.negated && null == this.config.default) this.config.default = true;
|
|
2359
|
+
if (rawName.includes("<")) this.required = true;
|
|
2360
|
+
else if (rawName.includes("[")) this.required = false;
|
|
2361
|
+
else this.isBoolean = true;
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
const processArgs = process.argv;
|
|
2365
|
+
const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
2366
|
+
class Command {
|
|
2367
|
+
constructor(rawName, description, config = {}, cli){
|
|
2368
|
+
this.rawName = rawName;
|
|
2369
|
+
this.description = description;
|
|
2370
|
+
this.config = config;
|
|
2371
|
+
this.cli = cli;
|
|
2372
|
+
this.options = [];
|
|
2373
|
+
this.aliasNames = [];
|
|
2374
|
+
this.name = removeBrackets(rawName);
|
|
2375
|
+
this.args = findAllBrackets(rawName);
|
|
2376
|
+
this.examples = [];
|
|
2377
|
+
}
|
|
2378
|
+
usage(text) {
|
|
2379
|
+
this.usageText = text;
|
|
2380
|
+
return this;
|
|
2381
|
+
}
|
|
2382
|
+
allowUnknownOptions() {
|
|
2383
|
+
this.config.allowUnknownOptions = true;
|
|
2384
|
+
return this;
|
|
2385
|
+
}
|
|
2386
|
+
ignoreOptionDefaultValue() {
|
|
2387
|
+
this.config.ignoreOptionDefaultValue = true;
|
|
2388
|
+
return this;
|
|
2389
|
+
}
|
|
2390
|
+
version(version, customFlags = "-v, --version") {
|
|
2391
|
+
this.versionNumber = version;
|
|
2392
|
+
this.option(customFlags, "Display version number");
|
|
2393
|
+
return this;
|
|
2394
|
+
}
|
|
2395
|
+
example(example) {
|
|
2396
|
+
this.examples.push(example);
|
|
2397
|
+
return this;
|
|
2398
|
+
}
|
|
2399
|
+
option(rawName, description, config) {
|
|
2400
|
+
const option = new Option(rawName, description, config);
|
|
2401
|
+
this.options.push(option);
|
|
2402
|
+
return this;
|
|
2403
|
+
}
|
|
2404
|
+
alias(name) {
|
|
2405
|
+
this.aliasNames.push(name);
|
|
2406
|
+
return this;
|
|
2407
|
+
}
|
|
2408
|
+
action(callback) {
|
|
2409
|
+
this.commandAction = callback;
|
|
2410
|
+
return this;
|
|
2411
|
+
}
|
|
2412
|
+
isMatched(name) {
|
|
2413
|
+
return this.name === name || this.aliasNames.includes(name);
|
|
2414
|
+
}
|
|
2415
|
+
get isDefaultCommand() {
|
|
2416
|
+
return "" === this.name || this.aliasNames.includes("!");
|
|
2417
|
+
}
|
|
2418
|
+
get isGlobalCommand() {
|
|
2419
|
+
return this instanceof GlobalCommand;
|
|
2420
|
+
}
|
|
2421
|
+
hasOption(name) {
|
|
2422
|
+
name = name.split(".")[0];
|
|
2423
|
+
return this.options.find((option)=>option.names.includes(name));
|
|
2424
|
+
}
|
|
2425
|
+
outputHelp() {
|
|
2426
|
+
const { name, commands } = this.cli;
|
|
2427
|
+
const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
|
|
2428
|
+
let sections = [
|
|
2429
|
+
{
|
|
2430
|
+
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
2431
|
+
}
|
|
2432
|
+
];
|
|
2433
|
+
sections.push({
|
|
2434
|
+
title: "Usage",
|
|
2435
|
+
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
2436
|
+
});
|
|
2437
|
+
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
2438
|
+
if (showCommands) {
|
|
2439
|
+
const longestCommandName = findLongest(commands.map((command)=>command.rawName));
|
|
2440
|
+
sections.push({
|
|
2441
|
+
title: "Commands",
|
|
2442
|
+
body: commands.map((command)=>` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`).join("\n")
|
|
2443
|
+
});
|
|
2444
|
+
sections.push({
|
|
2445
|
+
title: "For more info, run any command with the `--help` flag",
|
|
2446
|
+
body: commands.map((command)=>` $ ${name}${"" === command.name ? "" : ` ${command.name}`} --help`).join("\n")
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
let options = this.isGlobalCommand ? globalOptions : [
|
|
2450
|
+
...this.options,
|
|
2451
|
+
...globalOptions || []
|
|
2452
|
+
];
|
|
2453
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand) options = options.filter((option)=>"version" !== option.name);
|
|
2454
|
+
if (options.length > 0) {
|
|
2455
|
+
const longestOptionName = findLongest(options.map((option)=>option.rawName));
|
|
2456
|
+
sections.push({
|
|
2457
|
+
title: "Options",
|
|
2458
|
+
body: options.map((option)=>` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${void 0 === option.config.default ? "" : `(default: ${option.config.default})`}`).join("\n")
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
if (this.examples.length > 0) sections.push({
|
|
2462
|
+
title: "Examples",
|
|
2463
|
+
body: this.examples.map((example)=>{
|
|
2464
|
+
if ("function" == typeof example) return example(name);
|
|
2465
|
+
return example;
|
|
2466
|
+
}).join("\n")
|
|
2467
|
+
});
|
|
2468
|
+
if (helpCallback) sections = helpCallback(sections) || sections;
|
|
2469
|
+
console.log(sections.map((section)=>section.title ? `${section.title}:
|
|
2470
|
+
${section.body}` : section.body).join("\n\n"));
|
|
2471
|
+
}
|
|
2472
|
+
outputVersion() {
|
|
2473
|
+
const { name } = this.cli;
|
|
2474
|
+
const { versionNumber } = this.cli.globalCommand;
|
|
2475
|
+
if (versionNumber) console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
2476
|
+
}
|
|
2477
|
+
checkRequiredArgs() {
|
|
2478
|
+
const minimalArgsCount = this.args.filter((arg)=>arg.required).length;
|
|
2479
|
+
if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
2480
|
+
}
|
|
2481
|
+
checkUnknownOptions() {
|
|
2482
|
+
const { options, globalCommand } = this.cli;
|
|
2483
|
+
if (!this.config.allowUnknownOptions) {
|
|
2484
|
+
for (const name of Object.keys(options))if ("--" !== name && !this.hasOption(name) && !globalCommand.hasOption(name)) throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
checkOptionValue() {
|
|
2488
|
+
const { options: parsedOptions, globalCommand } = this.cli;
|
|
2489
|
+
const options = [
|
|
2490
|
+
...globalCommand.options,
|
|
2491
|
+
...this.options
|
|
2492
|
+
];
|
|
2493
|
+
for (const option of options){
|
|
2494
|
+
const value = parsedOptions[option.name.split(".")[0]];
|
|
2495
|
+
if (option.required) {
|
|
2496
|
+
const hasNegated = options.some((o)=>o.negated && o.names.includes(option.name));
|
|
2497
|
+
if (true === value || false === value && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
class GlobalCommand extends Command {
|
|
2503
|
+
constructor(cli){
|
|
2504
|
+
super("@@global@@", "", {}, cli);
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
var __assign = Object.assign;
|
|
2508
|
+
class CAC extends external_events_.EventEmitter {
|
|
2509
|
+
constructor(name = ""){
|
|
2510
|
+
super();
|
|
2511
|
+
this.name = name;
|
|
2512
|
+
this.commands = [];
|
|
2513
|
+
this.rawArgs = [];
|
|
2514
|
+
this.args = [];
|
|
2515
|
+
this.options = {};
|
|
2516
|
+
this.globalCommand = new GlobalCommand(this);
|
|
2517
|
+
this.globalCommand.usage("<command> [options]");
|
|
2518
|
+
}
|
|
2519
|
+
usage(text) {
|
|
2520
|
+
this.globalCommand.usage(text);
|
|
2521
|
+
return this;
|
|
2522
|
+
}
|
|
2523
|
+
command(rawName, description, config) {
|
|
2524
|
+
const command = new Command(rawName, description || "", config, this);
|
|
2525
|
+
command.globalCommand = this.globalCommand;
|
|
2526
|
+
this.commands.push(command);
|
|
2527
|
+
return command;
|
|
2528
|
+
}
|
|
2529
|
+
option(rawName, description, config) {
|
|
2530
|
+
this.globalCommand.option(rawName, description, config);
|
|
2531
|
+
return this;
|
|
2532
|
+
}
|
|
2533
|
+
help(callback) {
|
|
2534
|
+
this.globalCommand.option("-h, --help", "Display this message");
|
|
2535
|
+
this.globalCommand.helpCallback = callback;
|
|
2536
|
+
this.showHelpOnExit = true;
|
|
2537
|
+
return this;
|
|
2538
|
+
}
|
|
2539
|
+
version(version, customFlags = "-v, --version") {
|
|
2540
|
+
this.globalCommand.version(version, customFlags);
|
|
2541
|
+
this.showVersionOnExit = true;
|
|
2542
|
+
return this;
|
|
2543
|
+
}
|
|
2544
|
+
example(example) {
|
|
2545
|
+
this.globalCommand.example(example);
|
|
2546
|
+
return this;
|
|
2547
|
+
}
|
|
2548
|
+
outputHelp() {
|
|
2549
|
+
if (this.matchedCommand) this.matchedCommand.outputHelp();
|
|
2550
|
+
else this.globalCommand.outputHelp();
|
|
2551
|
+
}
|
|
2552
|
+
outputVersion() {
|
|
2553
|
+
this.globalCommand.outputVersion();
|
|
2554
|
+
}
|
|
2555
|
+
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
2556
|
+
this.args = args;
|
|
2557
|
+
this.options = options;
|
|
2558
|
+
if (matchedCommand) this.matchedCommand = matchedCommand;
|
|
2559
|
+
if (matchedCommandName) this.matchedCommandName = matchedCommandName;
|
|
2560
|
+
return this;
|
|
2561
|
+
}
|
|
2562
|
+
unsetMatchedCommand() {
|
|
2563
|
+
this.matchedCommand = void 0;
|
|
2564
|
+
this.matchedCommandName = void 0;
|
|
2565
|
+
}
|
|
2566
|
+
parse(argv = processArgs, { run = true } = {}) {
|
|
2567
|
+
this.rawArgs = argv;
|
|
2568
|
+
if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
2569
|
+
let shouldParse = true;
|
|
2570
|
+
for (const command of this.commands){
|
|
2571
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
2572
|
+
const commandName = parsed.args[0];
|
|
2573
|
+
if (command.isMatched(commandName)) {
|
|
2574
|
+
shouldParse = false;
|
|
2575
|
+
const parsedInfo = __assign(__assign({}, parsed), {
|
|
2576
|
+
args: parsed.args.slice(1)
|
|
2577
|
+
});
|
|
2578
|
+
this.setParsedInfo(parsedInfo, command, commandName);
|
|
2579
|
+
this.emit(`command:${commandName}`, command);
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
if (shouldParse) {
|
|
2583
|
+
for (const command of this.commands)if ("" === command.name) {
|
|
2584
|
+
shouldParse = false;
|
|
2585
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
2586
|
+
this.setParsedInfo(parsed, command);
|
|
2587
|
+
this.emit("command:!", command);
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
if (shouldParse) {
|
|
2591
|
+
const parsed = this.mri(argv.slice(2));
|
|
2592
|
+
this.setParsedInfo(parsed);
|
|
2593
|
+
}
|
|
2594
|
+
if (this.options.help && this.showHelpOnExit) {
|
|
2595
|
+
this.outputHelp();
|
|
2596
|
+
run = false;
|
|
2597
|
+
this.unsetMatchedCommand();
|
|
2598
|
+
}
|
|
2599
|
+
if (this.options.version && this.showVersionOnExit && null == this.matchedCommandName) {
|
|
2600
|
+
this.outputVersion();
|
|
2601
|
+
run = false;
|
|
2602
|
+
this.unsetMatchedCommand();
|
|
2603
|
+
}
|
|
2604
|
+
const parsedArgv = {
|
|
2605
|
+
args: this.args,
|
|
2606
|
+
options: this.options
|
|
2607
|
+
};
|
|
2608
|
+
if (run) this.runMatchedCommand();
|
|
2609
|
+
if (!this.matchedCommand && this.args[0]) this.emit("command:*");
|
|
2610
|
+
return parsedArgv;
|
|
2611
|
+
}
|
|
2612
|
+
mri(argv, command) {
|
|
2613
|
+
const cliOptions = [
|
|
2614
|
+
...this.globalCommand.options,
|
|
2615
|
+
...command ? command.options : []
|
|
2616
|
+
];
|
|
2617
|
+
const mriOptions = getMriOptions(cliOptions);
|
|
2618
|
+
let argsAfterDoubleDashes = [];
|
|
2619
|
+
const doubleDashesIndex = argv.indexOf("--");
|
|
2620
|
+
if (doubleDashesIndex > -1) {
|
|
2621
|
+
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
2622
|
+
argv = argv.slice(0, doubleDashesIndex);
|
|
2623
|
+
}
|
|
2624
|
+
let parsed = mri2(argv, mriOptions);
|
|
2625
|
+
parsed = Object.keys(parsed).reduce((res, name)=>__assign(__assign({}, res), {
|
|
2626
|
+
[camelcaseOptionName(name)]: parsed[name]
|
|
2627
|
+
}), {
|
|
2628
|
+
_: []
|
|
2629
|
+
});
|
|
2630
|
+
const args = parsed._;
|
|
2631
|
+
const options = {
|
|
2632
|
+
"--": argsAfterDoubleDashes
|
|
2633
|
+
};
|
|
2634
|
+
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
2635
|
+
let transforms = Object.create(null);
|
|
2636
|
+
for (const cliOption of cliOptions){
|
|
2637
|
+
if (!ignoreDefault && void 0 !== cliOption.config.default) for (const name of cliOption.names)options[name] = cliOption.config.default;
|
|
2638
|
+
if (Array.isArray(cliOption.config.type)) {
|
|
2639
|
+
if (void 0 === transforms[cliOption.name]) {
|
|
2640
|
+
transforms[cliOption.name] = Object.create(null);
|
|
2641
|
+
transforms[cliOption.name]["shouldTransform"] = true;
|
|
2642
|
+
transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
for (const key of Object.keys(parsed))if ("_" !== key) {
|
|
2647
|
+
const keys = key.split(".");
|
|
2648
|
+
setDotProp(options, keys, parsed[key]);
|
|
2649
|
+
setByType(options, transforms);
|
|
2650
|
+
}
|
|
2651
|
+
return {
|
|
2652
|
+
args,
|
|
2653
|
+
options
|
|
2654
|
+
};
|
|
2655
|
+
}
|
|
2656
|
+
runMatchedCommand() {
|
|
2657
|
+
const { args, options, matchedCommand: command } = this;
|
|
2658
|
+
if (!command || !command.commandAction) return;
|
|
2659
|
+
command.checkUnknownOptions();
|
|
2660
|
+
command.checkOptionValue();
|
|
2661
|
+
command.checkRequiredArgs();
|
|
2662
|
+
const actionArgs = [];
|
|
2663
|
+
command.args.forEach((arg, index)=>{
|
|
2664
|
+
if (arg.variadic) actionArgs.push(args.slice(index));
|
|
2665
|
+
else actionArgs.push(args[index]);
|
|
2666
|
+
});
|
|
2667
|
+
actionArgs.push(options);
|
|
2668
|
+
return command.commandAction.apply(this, actionArgs);
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
const cac = (name = "")=>new CAC(name);
|
|
2672
|
+
const dist = cac;
|
|
2673
|
+
var external_pathe_ = __webpack_require__("pathe");
|
|
2674
|
+
var src_config = __webpack_require__("./src/config.ts");
|
|
2675
|
+
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
2676
|
+
var logger = __webpack_require__("./src/utils/logger.ts");
|
|
2677
|
+
var prepare = __webpack_require__("./src/cli/prepare.ts");
|
|
2678
|
+
const applyCommonOptions = (cli)=>{
|
|
2679
|
+
cli.option('-c, --config <config>', 'Specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'Specify the loader to load the config file, can be `jiti` or `native`', {
|
|
2680
|
+
default: 'jiti'
|
|
2681
|
+
}).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--include <include>', 'Match test files').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('--reporter <reporter>', 'Specify the reporter to use').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
|
|
2682
|
+
};
|
|
2683
|
+
async function initCli(options) {
|
|
2684
|
+
const cwd = process.cwd();
|
|
2685
|
+
const root = options.root ? (0, helper.ZY)(cwd, options.root) : cwd;
|
|
2686
|
+
const { content: config, filePath: configFilePath } = await (0, src_config.ME)({
|
|
2687
|
+
cwd: root,
|
|
2688
|
+
path: options.config,
|
|
2689
|
+
configLoader: options.configLoader
|
|
2690
|
+
});
|
|
2691
|
+
const keys = [
|
|
2692
|
+
'root',
|
|
2693
|
+
'globals',
|
|
2694
|
+
'isolate',
|
|
2695
|
+
'passWithNoTests',
|
|
2696
|
+
'update',
|
|
2697
|
+
'testNamePattern',
|
|
2698
|
+
'testTimeout',
|
|
2699
|
+
'hookTimeout',
|
|
2700
|
+
'clearMocks',
|
|
2701
|
+
'resetMocks',
|
|
2702
|
+
'restoreMocks',
|
|
2703
|
+
'unstubEnvs',
|
|
2704
|
+
'unstubGlobals',
|
|
2705
|
+
'retry',
|
|
2706
|
+
'slowTestThreshold',
|
|
2707
|
+
'maxConcurrency',
|
|
2708
|
+
'printConsoleTrace',
|
|
2709
|
+
'disableConsoleIntercept',
|
|
2710
|
+
'testEnvironment'
|
|
2711
|
+
];
|
|
2712
|
+
for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
|
|
2713
|
+
if (options.exclude) config.exclude = (0, helper.XQ)(options.exclude);
|
|
2714
|
+
if (options.reporter) config.reporters = (0, helper.XQ)(options.reporter);
|
|
2715
|
+
if (options.include) config.include = (0, helper.XQ)(options.include);
|
|
2716
|
+
return {
|
|
2717
|
+
config,
|
|
2718
|
+
configFilePath: configFilePath ?? void 0
|
|
2719
|
+
};
|
|
2720
|
+
}
|
|
2721
|
+
const runRest = async ({ options, filters, command })=>{
|
|
2722
|
+
let rstest;
|
|
2723
|
+
try {
|
|
2724
|
+
const { config, configFilePath } = await initCli(options);
|
|
2725
|
+
const { createRstest } = await __webpack_require__.e("359").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
2726
|
+
rstest = createRstest({
|
|
2727
|
+
config,
|
|
2728
|
+
configFilePath
|
|
2729
|
+
}, command, filters.map(external_pathe_.normalize));
|
|
2730
|
+
if ('watch' === command && configFilePath) {
|
|
2731
|
+
const { watchFilesForRestart } = await __webpack_require__.e("25").then(__webpack_require__.bind(__webpack_require__, "./src/core/restart.ts"));
|
|
2732
|
+
watchFilesForRestart({
|
|
2733
|
+
rstest,
|
|
2734
|
+
options,
|
|
2735
|
+
filters
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
await rstest.runTests();
|
|
2739
|
+
} catch (err) {
|
|
2740
|
+
for (const reporter of rstest?.context.reporters || [])reporter.onExit?.();
|
|
2741
|
+
logger.k.error('Failed to run Rstest.');
|
|
2742
|
+
logger.k.error((0, helper.Z)(err));
|
|
2743
|
+
process.exit(1);
|
|
2744
|
+
}
|
|
2745
|
+
};
|
|
2746
|
+
function setupCommands() {
|
|
2747
|
+
const cli = dist('rstest');
|
|
2748
|
+
cli.help();
|
|
2749
|
+
cli.version("0.2.1");
|
|
2750
|
+
applyCommonOptions(cli);
|
|
2751
|
+
cli.command('[...filters]', 'run tests').option('--watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
2752
|
+
(0, prepare.U)();
|
|
2753
|
+
if (options.watch) await runRest({
|
|
2754
|
+
options,
|
|
2755
|
+
filters,
|
|
2756
|
+
command: 'watch'
|
|
2757
|
+
});
|
|
2758
|
+
else await runRest({
|
|
2759
|
+
options,
|
|
2760
|
+
filters,
|
|
2761
|
+
command: 'run'
|
|
2762
|
+
});
|
|
2763
|
+
});
|
|
2764
|
+
cli.command('run [...filters]', 'run tests without watch mode').action(async (filters, options)=>{
|
|
2765
|
+
(0, prepare.U)();
|
|
2766
|
+
await runRest({
|
|
2767
|
+
options,
|
|
2768
|
+
filters,
|
|
2769
|
+
command: 'run'
|
|
2770
|
+
});
|
|
2771
|
+
});
|
|
2772
|
+
cli.command('watch [...filters]', 'run tests in watch mode').action(async (filters, options)=>{
|
|
2773
|
+
(0, prepare.U)();
|
|
2774
|
+
await runRest({
|
|
2775
|
+
options,
|
|
2776
|
+
filters,
|
|
2777
|
+
command: 'watch'
|
|
2778
|
+
});
|
|
2779
|
+
});
|
|
2780
|
+
cli.command('list [...filters]', 'lists all test files that Rstest will run').option('--filesOnly', 'only list the test files').option('--json [boolean/path]', 'print tests as JSON or write to a file').action(async (filters, options)=>{
|
|
2781
|
+
try {
|
|
2782
|
+
const { config, configFilePath } = await initCli(options);
|
|
2783
|
+
const { createRstest } = await __webpack_require__.e("359").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
2784
|
+
const rstest = createRstest({
|
|
2785
|
+
config,
|
|
2786
|
+
configFilePath
|
|
2787
|
+
}, 'list', filters.map(external_pathe_.normalize));
|
|
2788
|
+
await rstest.listTests({
|
|
2789
|
+
filesOnly: options.filesOnly,
|
|
2790
|
+
json: options.json
|
|
2791
|
+
});
|
|
2792
|
+
} catch (err) {
|
|
2793
|
+
logger.k.error('Failed to run Rstest list.');
|
|
2794
|
+
logger.k.error((0, helper.Z)(err));
|
|
2795
|
+
process.exit(1);
|
|
2796
|
+
}
|
|
2797
|
+
});
|
|
2798
|
+
cli.parse();
|
|
2799
|
+
}
|
|
2800
|
+
},
|
|
2801
|
+
"./src/cli/prepare.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2802
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
2803
|
+
U: ()=>showRstest,
|
|
2804
|
+
n: ()=>prepareCli
|
|
2805
|
+
});
|
|
2806
|
+
var _utils_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/logger.ts");
|
|
2807
|
+
function initNodeEnv() {
|
|
2808
|
+
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'test';
|
|
2809
|
+
}
|
|
2810
|
+
function prepareCli() {
|
|
2811
|
+
initNodeEnv();
|
|
2812
|
+
process.env.RSTEST = 'true';
|
|
2813
|
+
const { npm_execpath } = process.env;
|
|
2814
|
+
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
2815
|
+
}
|
|
2816
|
+
function showRstest() {
|
|
2817
|
+
_utils_logger__WEBPACK_IMPORTED_MODULE_0__.k.greet(" Rstest v0.2.1");
|
|
2818
|
+
_utils_logger__WEBPACK_IMPORTED_MODULE_0__.k.log('');
|
|
2819
|
+
}
|
|
2820
|
+
},
|
|
2180
2821
|
"./src/config.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2181
2822
|
__webpack_require__.d(__webpack_exports__, {
|
|
2182
2823
|
ME: ()=>loadConfig,
|
|
2824
|
+
en: ()=>mergeRstestConfig,
|
|
2183
2825
|
hY: ()=>withDefaultConfig
|
|
2184
2826
|
});
|
|
2185
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
|
|
2827
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
2186
2828
|
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
2187
2829
|
var pathe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("pathe");
|
|
2188
2830
|
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
|
@@ -2471,7 +3113,7 @@ var __webpack_modules__ = {
|
|
|
2471
3113
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
2472
3114
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
2473
3115
|
var logger = __webpack_require__("./src/utils/logger.ts");
|
|
2474
|
-
var external_node_fs_ = __webpack_require__("fs");
|
|
3116
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
2475
3117
|
var promises_ = __webpack_require__("node:fs/promises");
|
|
2476
3118
|
var external_node_module_ = __webpack_require__("node:module");
|
|
2477
3119
|
var external_pathe_ = __webpack_require__("pathe");
|
|
@@ -2491,7 +3133,7 @@ var __webpack_modules__ = {
|
|
|
2491
3133
|
const hasInSourceTestCode = (code)=>code.includes('import.meta.rstest');
|
|
2492
3134
|
const formatTestEntryName = (name)=>name.replace(/\.*[/\\]/g, '_').replace(/\./g, '~');
|
|
2493
3135
|
const getTestEntries = async ({ include, exclude, root, fileFilters, includeSource })=>{
|
|
2494
|
-
const testFiles = await (0, dist.
|
|
3136
|
+
const testFiles = await (0, dist.glob)(include, {
|
|
2495
3137
|
cwd: root,
|
|
2496
3138
|
absolute: true,
|
|
2497
3139
|
ignore: exclude,
|
|
@@ -2499,7 +3141,7 @@ var __webpack_modules__ = {
|
|
|
2499
3141
|
expandDirectories: false
|
|
2500
3142
|
});
|
|
2501
3143
|
if (includeSource?.length) {
|
|
2502
|
-
const sourceFiles = await (0, dist.
|
|
3144
|
+
const sourceFiles = await (0, dist.glob)(includeSource, {
|
|
2503
3145
|
cwd: root,
|
|
2504
3146
|
absolute: true,
|
|
2505
3147
|
ignore: exclude,
|
|
@@ -2851,10 +3493,16 @@ var __webpack_modules__ = {
|
|
|
2851
3493
|
birpc: function(module) {
|
|
2852
3494
|
module.exports = __WEBPACK_EXTERNAL_MODULE_birpc__;
|
|
2853
3495
|
},
|
|
3496
|
+
events: function(module) {
|
|
3497
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_events__;
|
|
3498
|
+
},
|
|
3499
|
+
"fs/promises": function(module) {
|
|
3500
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_fs_promises_400951f8__;
|
|
3501
|
+
},
|
|
2854
3502
|
"node:events": function(module) {
|
|
2855
3503
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__;
|
|
2856
3504
|
},
|
|
2857
|
-
fs: function(module) {
|
|
3505
|
+
"node:fs": function(module) {
|
|
2858
3506
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
2859
3507
|
},
|
|
2860
3508
|
"node:fs/promises": function(module) {
|
|
@@ -2872,6 +3520,9 @@ var __webpack_modules__ = {
|
|
|
2872
3520
|
"node:path": function(module) {
|
|
2873
3521
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
|
|
2874
3522
|
},
|
|
3523
|
+
"node:stream": function(module) {
|
|
3524
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_stream_444d1c2b__;
|
|
3525
|
+
},
|
|
2875
3526
|
"node:tty": function(module) {
|
|
2876
3527
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__;
|
|
2877
3528
|
},
|
|
@@ -2895,7 +3546,7 @@ var __webpack_modules__ = {
|
|
|
2895
3546
|
},
|
|
2896
3547
|
"../../node_modules/.pnpm/tinyglobby@0.2.14/node_modules/tinyglobby/dist/index.mjs": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
2897
3548
|
__webpack_require__.d(__webpack_exports__, {
|
|
2898
|
-
|
|
3549
|
+
glob: ()=>glob
|
|
2899
3550
|
});
|
|
2900
3551
|
var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:path");
|
|
2901
3552
|
var fdir__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/fdir@6.4.4_picomatch@4.0.2/node_modules/fdir/dist/index.js");
|
|
@@ -3162,9 +3813,19 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
3162
3813
|
(()=>{
|
|
3163
3814
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
3164
3815
|
})();
|
|
3816
|
+
(()=>{
|
|
3817
|
+
__webpack_require__.r = (exports)=>{
|
|
3818
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
3819
|
+
value: 'Module'
|
|
3820
|
+
});
|
|
3821
|
+
Object.defineProperty(exports, '__esModule', {
|
|
3822
|
+
value: true
|
|
3823
|
+
});
|
|
3824
|
+
};
|
|
3825
|
+
})();
|
|
3165
3826
|
(()=>{
|
|
3166
3827
|
var installedChunks = {
|
|
3167
|
-
|
|
3828
|
+
980: 0
|
|
3168
3829
|
};
|
|
3169
3830
|
var installChunk = (data)=>{
|
|
3170
3831
|
var __webpack_ids__ = data.__webpack_ids__;
|
|
@@ -3200,606 +3861,20 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
3200
3861
|
};
|
|
3201
3862
|
})();
|
|
3202
3863
|
var logger = __webpack_require__("./src/utils/logger.ts");
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
any
|
|
3206
|
-
];
|
|
3207
|
-
}
|
|
3208
|
-
function toVal(out, key, val, opts) {
|
|
3209
|
-
var x, old = out[key], nxt = ~opts.string.indexOf(key) ? null == val || true === val ? '' : String(val) : 'boolean' == typeof val ? val : ~opts.boolean.indexOf(key) ? 'false' === val ? false : 'true' === val || (out._.push((x = +val, 0 * x === 0) ? x : val), !!val) : (x = +val, 0 * x === 0) ? x : val;
|
|
3210
|
-
out[key] = null == old ? nxt : Array.isArray(old) ? old.concat(nxt) : [
|
|
3211
|
-
old,
|
|
3212
|
-
nxt
|
|
3213
|
-
];
|
|
3214
|
-
}
|
|
3215
|
-
function mri2(args, opts) {
|
|
3216
|
-
args = args || [];
|
|
3217
|
-
opts = opts || {};
|
|
3218
|
-
var k, arr, arg, name, val, out = {
|
|
3219
|
-
_: []
|
|
3220
|
-
};
|
|
3221
|
-
var i = 0, j = 0, idx = 0, len = args.length;
|
|
3222
|
-
const alibi = void 0 !== opts.alias;
|
|
3223
|
-
const strict = void 0 !== opts.unknown;
|
|
3224
|
-
const defaults = void 0 !== opts.default;
|
|
3225
|
-
opts.alias = opts.alias || {};
|
|
3226
|
-
opts.string = toArr(opts.string);
|
|
3227
|
-
opts.boolean = toArr(opts.boolean);
|
|
3228
|
-
if (alibi) for(k in opts.alias){
|
|
3229
|
-
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
3230
|
-
for(i = 0; i < arr.length; i++)(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
3231
|
-
}
|
|
3232
|
-
for(i = opts.boolean.length; i-- > 0;){
|
|
3233
|
-
arr = opts.alias[opts.boolean[i]] || [];
|
|
3234
|
-
for(j = arr.length; j-- > 0;)opts.boolean.push(arr[j]);
|
|
3235
|
-
}
|
|
3236
|
-
for(i = opts.string.length; i-- > 0;){
|
|
3237
|
-
arr = opts.alias[opts.string[i]] || [];
|
|
3238
|
-
for(j = arr.length; j-- > 0;)opts.string.push(arr[j]);
|
|
3239
|
-
}
|
|
3240
|
-
if (defaults) for(k in opts.default){
|
|
3241
|
-
name = typeof opts.default[k];
|
|
3242
|
-
arr = opts.alias[k] = opts.alias[k] || [];
|
|
3243
|
-
if (void 0 !== opts[name]) {
|
|
3244
|
-
opts[name].push(k);
|
|
3245
|
-
for(i = 0; i < arr.length; i++)opts[name].push(arr[i]);
|
|
3246
|
-
}
|
|
3247
|
-
}
|
|
3248
|
-
const keys = strict ? Object.keys(opts.alias) : [];
|
|
3249
|
-
for(i = 0; i < len; i++){
|
|
3250
|
-
arg = args[i];
|
|
3251
|
-
if ('--' === arg) {
|
|
3252
|
-
out._ = out._.concat(args.slice(++i));
|
|
3253
|
-
break;
|
|
3254
|
-
}
|
|
3255
|
-
for(j = 0; j < arg.length && 45 === arg.charCodeAt(j); j++);
|
|
3256
|
-
if (0 === j) out._.push(arg);
|
|
3257
|
-
else if ('no-' === arg.substring(j, j + 3)) {
|
|
3258
|
-
name = arg.substring(j + 3);
|
|
3259
|
-
if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
|
|
3260
|
-
out[name] = false;
|
|
3261
|
-
} else {
|
|
3262
|
-
for(idx = j + 1; idx < arg.length && 61 !== arg.charCodeAt(idx); idx++);
|
|
3263
|
-
name = arg.substring(j, idx);
|
|
3264
|
-
val = arg.substring(++idx) || i + 1 === len || 45 === ('' + args[i + 1]).charCodeAt(0) || args[++i];
|
|
3265
|
-
arr = 2 === j ? [
|
|
3266
|
-
name
|
|
3267
|
-
] : name;
|
|
3268
|
-
for(idx = 0; idx < arr.length; idx++){
|
|
3269
|
-
name = arr[idx];
|
|
3270
|
-
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
|
3271
|
-
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
}
|
|
3275
|
-
if (defaults) {
|
|
3276
|
-
for(k in opts.default)if (void 0 === out[k]) out[k] = opts.default[k];
|
|
3277
|
-
}
|
|
3278
|
-
if (alibi) for(k in out){
|
|
3279
|
-
arr = opts.alias[k] || [];
|
|
3280
|
-
while(arr.length > 0)out[arr.shift()] = out[k];
|
|
3281
|
-
}
|
|
3282
|
-
return out;
|
|
3283
|
-
}
|
|
3284
|
-
const removeBrackets = (v)=>v.replace(/[<[].+/, "").trim();
|
|
3285
|
-
const findAllBrackets = (v)=>{
|
|
3286
|
-
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
3287
|
-
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
3288
|
-
const res = [];
|
|
3289
|
-
const parse = (match)=>{
|
|
3290
|
-
let variadic = false;
|
|
3291
|
-
let value = match[1];
|
|
3292
|
-
if (value.startsWith("...")) {
|
|
3293
|
-
value = value.slice(3);
|
|
3294
|
-
variadic = true;
|
|
3295
|
-
}
|
|
3296
|
-
return {
|
|
3297
|
-
required: match[0].startsWith("<"),
|
|
3298
|
-
value,
|
|
3299
|
-
variadic
|
|
3300
|
-
};
|
|
3301
|
-
};
|
|
3302
|
-
let angledMatch;
|
|
3303
|
-
while(angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v))res.push(parse(angledMatch));
|
|
3304
|
-
let squareMatch;
|
|
3305
|
-
while(squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v))res.push(parse(squareMatch));
|
|
3306
|
-
return res;
|
|
3307
|
-
};
|
|
3308
|
-
const getMriOptions = (options)=>{
|
|
3309
|
-
const result = {
|
|
3310
|
-
alias: {},
|
|
3311
|
-
boolean: []
|
|
3312
|
-
};
|
|
3313
|
-
for (const [index, option] of options.entries()){
|
|
3314
|
-
if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
|
|
3315
|
-
if (option.isBoolean) if (option.negated) {
|
|
3316
|
-
const hasStringTypeOption = options.some((o, i)=>i !== index && o.names.some((name)=>option.names.includes(name)) && "boolean" == typeof o.required);
|
|
3317
|
-
if (!hasStringTypeOption) result.boolean.push(option.names[0]);
|
|
3318
|
-
} else result.boolean.push(option.names[0]);
|
|
3319
|
-
}
|
|
3320
|
-
return result;
|
|
3321
|
-
};
|
|
3322
|
-
const findLongest = (arr)=>arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0];
|
|
3323
|
-
const padRight = (str, length)=>str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
3324
|
-
const camelcase = (input)=>input.replace(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
|
|
3325
|
-
const setDotProp = (obj, keys, val)=>{
|
|
3326
|
-
let i = 0;
|
|
3327
|
-
let length = keys.length;
|
|
3328
|
-
let t = obj;
|
|
3329
|
-
let x;
|
|
3330
|
-
for(; i < length; ++i){
|
|
3331
|
-
x = t[keys[i]];
|
|
3332
|
-
t = t[keys[i]] = i === length - 1 ? val : null != x ? x : !~keys[i + 1].indexOf(".") && +keys[i + 1] > -1 ? [] : {};
|
|
3333
|
-
}
|
|
3334
|
-
};
|
|
3335
|
-
const setByType = (obj, transforms)=>{
|
|
3336
|
-
for (const key of Object.keys(transforms)){
|
|
3337
|
-
const transform = transforms[key];
|
|
3338
|
-
if (transform.shouldTransform) {
|
|
3339
|
-
obj[key] = Array.prototype.concat.call([], obj[key]);
|
|
3340
|
-
if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
|
|
3341
|
-
}
|
|
3342
|
-
}
|
|
3343
|
-
};
|
|
3344
|
-
const getFileName = (input)=>{
|
|
3345
|
-
const m = /([^\\\/]+)$/.exec(input);
|
|
3346
|
-
return m ? m[1] : "";
|
|
3347
|
-
};
|
|
3348
|
-
const camelcaseOptionName = (name)=>name.split(".").map((v, i)=>0 === i ? camelcase(v) : v).join(".");
|
|
3349
|
-
class CACError extends Error {
|
|
3350
|
-
constructor(message){
|
|
3351
|
-
super(message);
|
|
3352
|
-
this.name = this.constructor.name;
|
|
3353
|
-
if ("function" == typeof Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
3354
|
-
else this.stack = new Error(message).stack;
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
3357
|
-
class Option {
|
|
3358
|
-
constructor(rawName, description, config){
|
|
3359
|
-
this.rawName = rawName;
|
|
3360
|
-
this.description = description;
|
|
3361
|
-
this.config = Object.assign({}, config);
|
|
3362
|
-
rawName = rawName.replace(/\.\*/g, "");
|
|
3363
|
-
this.negated = false;
|
|
3364
|
-
this.names = removeBrackets(rawName).split(",").map((v)=>{
|
|
3365
|
-
let name = v.trim().replace(/^-{1,2}/, "");
|
|
3366
|
-
if (name.startsWith("no-")) {
|
|
3367
|
-
this.negated = true;
|
|
3368
|
-
name = name.replace(/^no-/, "");
|
|
3369
|
-
}
|
|
3370
|
-
return camelcaseOptionName(name);
|
|
3371
|
-
}).sort((a, b)=>a.length > b.length ? 1 : -1);
|
|
3372
|
-
this.name = this.names[this.names.length - 1];
|
|
3373
|
-
if (this.negated && null == this.config.default) this.config.default = true;
|
|
3374
|
-
if (rawName.includes("<")) this.required = true;
|
|
3375
|
-
else if (rawName.includes("[")) this.required = false;
|
|
3376
|
-
else this.isBoolean = true;
|
|
3377
|
-
}
|
|
3378
|
-
}
|
|
3379
|
-
const processArgs = process.argv;
|
|
3380
|
-
const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
3381
|
-
class Command {
|
|
3382
|
-
constructor(rawName, description, config = {}, cli){
|
|
3383
|
-
this.rawName = rawName;
|
|
3384
|
-
this.description = description;
|
|
3385
|
-
this.config = config;
|
|
3386
|
-
this.cli = cli;
|
|
3387
|
-
this.options = [];
|
|
3388
|
-
this.aliasNames = [];
|
|
3389
|
-
this.name = removeBrackets(rawName);
|
|
3390
|
-
this.args = findAllBrackets(rawName);
|
|
3391
|
-
this.examples = [];
|
|
3392
|
-
}
|
|
3393
|
-
usage(text) {
|
|
3394
|
-
this.usageText = text;
|
|
3395
|
-
return this;
|
|
3396
|
-
}
|
|
3397
|
-
allowUnknownOptions() {
|
|
3398
|
-
this.config.allowUnknownOptions = true;
|
|
3399
|
-
return this;
|
|
3400
|
-
}
|
|
3401
|
-
ignoreOptionDefaultValue() {
|
|
3402
|
-
this.config.ignoreOptionDefaultValue = true;
|
|
3403
|
-
return this;
|
|
3404
|
-
}
|
|
3405
|
-
version(version, customFlags = "-v, --version") {
|
|
3406
|
-
this.versionNumber = version;
|
|
3407
|
-
this.option(customFlags, "Display version number");
|
|
3408
|
-
return this;
|
|
3409
|
-
}
|
|
3410
|
-
example(example) {
|
|
3411
|
-
this.examples.push(example);
|
|
3412
|
-
return this;
|
|
3413
|
-
}
|
|
3414
|
-
option(rawName, description, config) {
|
|
3415
|
-
const option = new Option(rawName, description, config);
|
|
3416
|
-
this.options.push(option);
|
|
3417
|
-
return this;
|
|
3418
|
-
}
|
|
3419
|
-
alias(name) {
|
|
3420
|
-
this.aliasNames.push(name);
|
|
3421
|
-
return this;
|
|
3422
|
-
}
|
|
3423
|
-
action(callback) {
|
|
3424
|
-
this.commandAction = callback;
|
|
3425
|
-
return this;
|
|
3426
|
-
}
|
|
3427
|
-
isMatched(name) {
|
|
3428
|
-
return this.name === name || this.aliasNames.includes(name);
|
|
3429
|
-
}
|
|
3430
|
-
get isDefaultCommand() {
|
|
3431
|
-
return "" === this.name || this.aliasNames.includes("!");
|
|
3432
|
-
}
|
|
3433
|
-
get isGlobalCommand() {
|
|
3434
|
-
return this instanceof GlobalCommand;
|
|
3435
|
-
}
|
|
3436
|
-
hasOption(name) {
|
|
3437
|
-
name = name.split(".")[0];
|
|
3438
|
-
return this.options.find((option)=>option.names.includes(name));
|
|
3439
|
-
}
|
|
3440
|
-
outputHelp() {
|
|
3441
|
-
const { name, commands } = this.cli;
|
|
3442
|
-
const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
|
|
3443
|
-
let sections = [
|
|
3444
|
-
{
|
|
3445
|
-
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
3446
|
-
}
|
|
3447
|
-
];
|
|
3448
|
-
sections.push({
|
|
3449
|
-
title: "Usage",
|
|
3450
|
-
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
3451
|
-
});
|
|
3452
|
-
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
3453
|
-
if (showCommands) {
|
|
3454
|
-
const longestCommandName = findLongest(commands.map((command)=>command.rawName));
|
|
3455
|
-
sections.push({
|
|
3456
|
-
title: "Commands",
|
|
3457
|
-
body: commands.map((command)=>` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`).join("\n")
|
|
3458
|
-
});
|
|
3459
|
-
sections.push({
|
|
3460
|
-
title: "For more info, run any command with the `--help` flag",
|
|
3461
|
-
body: commands.map((command)=>` $ ${name}${"" === command.name ? "" : ` ${command.name}`} --help`).join("\n")
|
|
3462
|
-
});
|
|
3463
|
-
}
|
|
3464
|
-
let options = this.isGlobalCommand ? globalOptions : [
|
|
3465
|
-
...this.options,
|
|
3466
|
-
...globalOptions || []
|
|
3467
|
-
];
|
|
3468
|
-
if (!this.isGlobalCommand && !this.isDefaultCommand) options = options.filter((option)=>"version" !== option.name);
|
|
3469
|
-
if (options.length > 0) {
|
|
3470
|
-
const longestOptionName = findLongest(options.map((option)=>option.rawName));
|
|
3471
|
-
sections.push({
|
|
3472
|
-
title: "Options",
|
|
3473
|
-
body: options.map((option)=>` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${void 0 === option.config.default ? "" : `(default: ${option.config.default})`}`).join("\n")
|
|
3474
|
-
});
|
|
3475
|
-
}
|
|
3476
|
-
if (this.examples.length > 0) sections.push({
|
|
3477
|
-
title: "Examples",
|
|
3478
|
-
body: this.examples.map((example)=>{
|
|
3479
|
-
if ("function" == typeof example) return example(name);
|
|
3480
|
-
return example;
|
|
3481
|
-
}).join("\n")
|
|
3482
|
-
});
|
|
3483
|
-
if (helpCallback) sections = helpCallback(sections) || sections;
|
|
3484
|
-
console.log(sections.map((section)=>section.title ? `${section.title}:
|
|
3485
|
-
${section.body}` : section.body).join("\n\n"));
|
|
3486
|
-
}
|
|
3487
|
-
outputVersion() {
|
|
3488
|
-
const { name } = this.cli;
|
|
3489
|
-
const { versionNumber } = this.cli.globalCommand;
|
|
3490
|
-
if (versionNumber) console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
3491
|
-
}
|
|
3492
|
-
checkRequiredArgs() {
|
|
3493
|
-
const minimalArgsCount = this.args.filter((arg)=>arg.required).length;
|
|
3494
|
-
if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
3495
|
-
}
|
|
3496
|
-
checkUnknownOptions() {
|
|
3497
|
-
const { options, globalCommand } = this.cli;
|
|
3498
|
-
if (!this.config.allowUnknownOptions) {
|
|
3499
|
-
for (const name of Object.keys(options))if ("--" !== name && !this.hasOption(name) && !globalCommand.hasOption(name)) throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
3500
|
-
}
|
|
3501
|
-
}
|
|
3502
|
-
checkOptionValue() {
|
|
3503
|
-
const { options: parsedOptions, globalCommand } = this.cli;
|
|
3504
|
-
const options = [
|
|
3505
|
-
...globalCommand.options,
|
|
3506
|
-
...this.options
|
|
3507
|
-
];
|
|
3508
|
-
for (const option of options){
|
|
3509
|
-
const value = parsedOptions[option.name.split(".")[0]];
|
|
3510
|
-
if (option.required) {
|
|
3511
|
-
const hasNegated = options.some((o)=>o.negated && o.names.includes(option.name));
|
|
3512
|
-
if (true === value || false === value && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
3513
|
-
}
|
|
3514
|
-
}
|
|
3515
|
-
}
|
|
3516
|
-
}
|
|
3517
|
-
class GlobalCommand extends Command {
|
|
3518
|
-
constructor(cli){
|
|
3519
|
-
super("@@global@@", "", {}, cli);
|
|
3520
|
-
}
|
|
3521
|
-
}
|
|
3522
|
-
var __assign = Object.assign;
|
|
3523
|
-
class CAC extends EventEmitter {
|
|
3524
|
-
constructor(name = ""){
|
|
3525
|
-
super();
|
|
3526
|
-
this.name = name;
|
|
3527
|
-
this.commands = [];
|
|
3528
|
-
this.rawArgs = [];
|
|
3529
|
-
this.args = [];
|
|
3530
|
-
this.options = {};
|
|
3531
|
-
this.globalCommand = new GlobalCommand(this);
|
|
3532
|
-
this.globalCommand.usage("<command> [options]");
|
|
3533
|
-
}
|
|
3534
|
-
usage(text) {
|
|
3535
|
-
this.globalCommand.usage(text);
|
|
3536
|
-
return this;
|
|
3537
|
-
}
|
|
3538
|
-
command(rawName, description, config) {
|
|
3539
|
-
const command = new Command(rawName, description || "", config, this);
|
|
3540
|
-
command.globalCommand = this.globalCommand;
|
|
3541
|
-
this.commands.push(command);
|
|
3542
|
-
return command;
|
|
3543
|
-
}
|
|
3544
|
-
option(rawName, description, config) {
|
|
3545
|
-
this.globalCommand.option(rawName, description, config);
|
|
3546
|
-
return this;
|
|
3547
|
-
}
|
|
3548
|
-
help(callback) {
|
|
3549
|
-
this.globalCommand.option("-h, --help", "Display this message");
|
|
3550
|
-
this.globalCommand.helpCallback = callback;
|
|
3551
|
-
this.showHelpOnExit = true;
|
|
3552
|
-
return this;
|
|
3553
|
-
}
|
|
3554
|
-
version(version, customFlags = "-v, --version") {
|
|
3555
|
-
this.globalCommand.version(version, customFlags);
|
|
3556
|
-
this.showVersionOnExit = true;
|
|
3557
|
-
return this;
|
|
3558
|
-
}
|
|
3559
|
-
example(example) {
|
|
3560
|
-
this.globalCommand.example(example);
|
|
3561
|
-
return this;
|
|
3562
|
-
}
|
|
3563
|
-
outputHelp() {
|
|
3564
|
-
if (this.matchedCommand) this.matchedCommand.outputHelp();
|
|
3565
|
-
else this.globalCommand.outputHelp();
|
|
3566
|
-
}
|
|
3567
|
-
outputVersion() {
|
|
3568
|
-
this.globalCommand.outputVersion();
|
|
3569
|
-
}
|
|
3570
|
-
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
3571
|
-
this.args = args;
|
|
3572
|
-
this.options = options;
|
|
3573
|
-
if (matchedCommand) this.matchedCommand = matchedCommand;
|
|
3574
|
-
if (matchedCommandName) this.matchedCommandName = matchedCommandName;
|
|
3575
|
-
return this;
|
|
3576
|
-
}
|
|
3577
|
-
unsetMatchedCommand() {
|
|
3578
|
-
this.matchedCommand = void 0;
|
|
3579
|
-
this.matchedCommandName = void 0;
|
|
3580
|
-
}
|
|
3581
|
-
parse(argv = processArgs, { run = true } = {}) {
|
|
3582
|
-
this.rawArgs = argv;
|
|
3583
|
-
if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
3584
|
-
let shouldParse = true;
|
|
3585
|
-
for (const command of this.commands){
|
|
3586
|
-
const parsed = this.mri(argv.slice(2), command);
|
|
3587
|
-
const commandName = parsed.args[0];
|
|
3588
|
-
if (command.isMatched(commandName)) {
|
|
3589
|
-
shouldParse = false;
|
|
3590
|
-
const parsedInfo = __assign(__assign({}, parsed), {
|
|
3591
|
-
args: parsed.args.slice(1)
|
|
3592
|
-
});
|
|
3593
|
-
this.setParsedInfo(parsedInfo, command, commandName);
|
|
3594
|
-
this.emit(`command:${commandName}`, command);
|
|
3595
|
-
}
|
|
3596
|
-
}
|
|
3597
|
-
if (shouldParse) {
|
|
3598
|
-
for (const command of this.commands)if ("" === command.name) {
|
|
3599
|
-
shouldParse = false;
|
|
3600
|
-
const parsed = this.mri(argv.slice(2), command);
|
|
3601
|
-
this.setParsedInfo(parsed, command);
|
|
3602
|
-
this.emit("command:!", command);
|
|
3603
|
-
}
|
|
3604
|
-
}
|
|
3605
|
-
if (shouldParse) {
|
|
3606
|
-
const parsed = this.mri(argv.slice(2));
|
|
3607
|
-
this.setParsedInfo(parsed);
|
|
3608
|
-
}
|
|
3609
|
-
if (this.options.help && this.showHelpOnExit) {
|
|
3610
|
-
this.outputHelp();
|
|
3611
|
-
run = false;
|
|
3612
|
-
this.unsetMatchedCommand();
|
|
3613
|
-
}
|
|
3614
|
-
if (this.options.version && this.showVersionOnExit && null == this.matchedCommandName) {
|
|
3615
|
-
this.outputVersion();
|
|
3616
|
-
run = false;
|
|
3617
|
-
this.unsetMatchedCommand();
|
|
3618
|
-
}
|
|
3619
|
-
const parsedArgv = {
|
|
3620
|
-
args: this.args,
|
|
3621
|
-
options: this.options
|
|
3622
|
-
};
|
|
3623
|
-
if (run) this.runMatchedCommand();
|
|
3624
|
-
if (!this.matchedCommand && this.args[0]) this.emit("command:*");
|
|
3625
|
-
return parsedArgv;
|
|
3626
|
-
}
|
|
3627
|
-
mri(argv, command) {
|
|
3628
|
-
const cliOptions = [
|
|
3629
|
-
...this.globalCommand.options,
|
|
3630
|
-
...command ? command.options : []
|
|
3631
|
-
];
|
|
3632
|
-
const mriOptions = getMriOptions(cliOptions);
|
|
3633
|
-
let argsAfterDoubleDashes = [];
|
|
3634
|
-
const doubleDashesIndex = argv.indexOf("--");
|
|
3635
|
-
if (doubleDashesIndex > -1) {
|
|
3636
|
-
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
3637
|
-
argv = argv.slice(0, doubleDashesIndex);
|
|
3638
|
-
}
|
|
3639
|
-
let parsed = mri2(argv, mriOptions);
|
|
3640
|
-
parsed = Object.keys(parsed).reduce((res, name)=>__assign(__assign({}, res), {
|
|
3641
|
-
[camelcaseOptionName(name)]: parsed[name]
|
|
3642
|
-
}), {
|
|
3643
|
-
_: []
|
|
3644
|
-
});
|
|
3645
|
-
const args = parsed._;
|
|
3646
|
-
const options = {
|
|
3647
|
-
"--": argsAfterDoubleDashes
|
|
3648
|
-
};
|
|
3649
|
-
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
3650
|
-
let transforms = Object.create(null);
|
|
3651
|
-
for (const cliOption of cliOptions){
|
|
3652
|
-
if (!ignoreDefault && void 0 !== cliOption.config.default) for (const name of cliOption.names)options[name] = cliOption.config.default;
|
|
3653
|
-
if (Array.isArray(cliOption.config.type)) {
|
|
3654
|
-
if (void 0 === transforms[cliOption.name]) {
|
|
3655
|
-
transforms[cliOption.name] = Object.create(null);
|
|
3656
|
-
transforms[cliOption.name]["shouldTransform"] = true;
|
|
3657
|
-
transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
|
|
3658
|
-
}
|
|
3659
|
-
}
|
|
3660
|
-
}
|
|
3661
|
-
for (const key of Object.keys(parsed))if ("_" !== key) {
|
|
3662
|
-
const keys = key.split(".");
|
|
3663
|
-
setDotProp(options, keys, parsed[key]);
|
|
3664
|
-
setByType(options, transforms);
|
|
3665
|
-
}
|
|
3666
|
-
return {
|
|
3667
|
-
args,
|
|
3668
|
-
options
|
|
3669
|
-
};
|
|
3670
|
-
}
|
|
3671
|
-
runMatchedCommand() {
|
|
3672
|
-
const { args, options, matchedCommand: command } = this;
|
|
3673
|
-
if (!command || !command.commandAction) return;
|
|
3674
|
-
command.checkUnknownOptions();
|
|
3675
|
-
command.checkOptionValue();
|
|
3676
|
-
command.checkRequiredArgs();
|
|
3677
|
-
const actionArgs = [];
|
|
3678
|
-
command.args.forEach((arg, index)=>{
|
|
3679
|
-
if (arg.variadic) actionArgs.push(args.slice(index));
|
|
3680
|
-
else actionArgs.push(args[index]);
|
|
3681
|
-
});
|
|
3682
|
-
actionArgs.push(options);
|
|
3683
|
-
return command.commandAction.apply(this, actionArgs);
|
|
3684
|
-
}
|
|
3685
|
-
}
|
|
3686
|
-
const cac = (name = "")=>new CAC(name);
|
|
3687
|
-
const dist = cac;
|
|
3688
|
-
var external_pathe_ = __webpack_require__("pathe");
|
|
3689
|
-
var src_config = __webpack_require__("./src/config.ts");
|
|
3690
|
-
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
3691
|
-
function initNodeEnv() {
|
|
3692
|
-
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'test';
|
|
3693
|
-
}
|
|
3694
|
-
function prepareCli() {
|
|
3695
|
-
initNodeEnv();
|
|
3696
|
-
process.env.RSTEST = 'true';
|
|
3697
|
-
const { npm_execpath } = process.env;
|
|
3698
|
-
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
3699
|
-
}
|
|
3700
|
-
function showRstest() {
|
|
3701
|
-
logger.k.greet(" Rstest v0.1.3");
|
|
3702
|
-
logger.k.log('');
|
|
3703
|
-
}
|
|
3704
|
-
const applyCommonOptions = (cli)=>{
|
|
3705
|
-
cli.option('-c, --config <config>', 'Specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'Specify the loader to load the config file, can be `jiti` or `native`', {
|
|
3706
|
-
default: 'jiti'
|
|
3707
|
-
}).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--include <include>', 'Match test files').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('--reporter <reporter>', 'Specify the reporter to use').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
|
|
3708
|
-
};
|
|
3709
|
-
async function initCli(options) {
|
|
3710
|
-
const cwd = process.cwd();
|
|
3711
|
-
const root = options.root ? (0, helper.ZY)(cwd, options.root) : cwd;
|
|
3712
|
-
const { content: config, filePath: configFilePath } = await (0, src_config.ME)({
|
|
3713
|
-
cwd: root,
|
|
3714
|
-
path: options.config,
|
|
3715
|
-
configLoader: options.configLoader
|
|
3716
|
-
});
|
|
3717
|
-
const keys = [
|
|
3718
|
-
'root',
|
|
3719
|
-
'globals',
|
|
3720
|
-
'isolate',
|
|
3721
|
-
'passWithNoTests',
|
|
3722
|
-
'update',
|
|
3723
|
-
'testNamePattern',
|
|
3724
|
-
'testTimeout',
|
|
3725
|
-
'hookTimeout',
|
|
3726
|
-
'clearMocks',
|
|
3727
|
-
'resetMocks',
|
|
3728
|
-
'restoreMocks',
|
|
3729
|
-
'unstubEnvs',
|
|
3730
|
-
'unstubGlobals',
|
|
3731
|
-
'retry',
|
|
3732
|
-
'slowTestThreshold',
|
|
3733
|
-
'maxConcurrency',
|
|
3734
|
-
'printConsoleTrace',
|
|
3735
|
-
'disableConsoleIntercept',
|
|
3736
|
-
'testEnvironment'
|
|
3737
|
-
];
|
|
3738
|
-
for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
|
|
3739
|
-
if (options.exclude) config.exclude = (0, helper.XQ)(options.exclude);
|
|
3740
|
-
if (options.reporter) config.reporters = (0, helper.XQ)(options.reporter);
|
|
3741
|
-
if (options.include) config.include = (0, helper.XQ)(options.include);
|
|
3742
|
-
return {
|
|
3743
|
-
config,
|
|
3744
|
-
configFilePath
|
|
3745
|
-
};
|
|
3746
|
-
}
|
|
3747
|
-
function setupCommands() {
|
|
3748
|
-
const cli = dist('rstest');
|
|
3749
|
-
cli.help();
|
|
3750
|
-
cli.version("0.1.3");
|
|
3751
|
-
applyCommonOptions(cli);
|
|
3752
|
-
cli.command('[...filters]', 'run tests').option('--watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
3753
|
-
showRstest();
|
|
3754
|
-
if (options.watch) await runRest(options, filters, 'watch');
|
|
3755
|
-
else await runRest(options, filters, 'run');
|
|
3756
|
-
});
|
|
3757
|
-
const runRest = async (options, filters, command)=>{
|
|
3758
|
-
let rstest;
|
|
3759
|
-
try {
|
|
3760
|
-
const { config } = await initCli(options);
|
|
3761
|
-
const { createRstest } = await __webpack_require__.e("359").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
3762
|
-
rstest = createRstest(config, command, filters.map(external_pathe_.normalize));
|
|
3763
|
-
await rstest.runTests();
|
|
3764
|
-
} catch (err) {
|
|
3765
|
-
for (const reporter of rstest?.context.reporters || [])reporter.onExit?.();
|
|
3766
|
-
logger.k.error('Failed to run Rstest.');
|
|
3767
|
-
logger.k.error((0, helper.Z)(err));
|
|
3768
|
-
process.exit(1);
|
|
3769
|
-
}
|
|
3770
|
-
};
|
|
3771
|
-
cli.command('run [...filters]', 'run tests without watch mode').action(async (filters, options)=>{
|
|
3772
|
-
showRstest();
|
|
3773
|
-
await runRest(options, filters, 'run');
|
|
3774
|
-
});
|
|
3775
|
-
cli.command('watch [...filters]', 'run tests in watch mode').action(async (filters, options)=>{
|
|
3776
|
-
showRstest();
|
|
3777
|
-
await runRest(options, filters, 'watch');
|
|
3778
|
-
});
|
|
3779
|
-
cli.command('list [...filters]', 'lists all test files that Rstest will run').option('--filesOnly', 'only list the test files').option('--json [boolean/path]', 'print tests as JSON or write to a file').action(async (filters, options)=>{
|
|
3780
|
-
try {
|
|
3781
|
-
const { config } = await initCli(options);
|
|
3782
|
-
const { createRstest } = await __webpack_require__.e("359").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
3783
|
-
const rstest = createRstest(config, 'list', filters.map(external_pathe_.normalize));
|
|
3784
|
-
await rstest.listTests({
|
|
3785
|
-
filesOnly: options.filesOnly,
|
|
3786
|
-
json: options.json
|
|
3787
|
-
});
|
|
3788
|
-
} catch (err) {
|
|
3789
|
-
logger.k.error('Failed to run Rstest list.');
|
|
3790
|
-
logger.k.error((0, helper.Z)(err));
|
|
3791
|
-
process.exit(1);
|
|
3792
|
-
}
|
|
3793
|
-
});
|
|
3794
|
-
cli.parse();
|
|
3795
|
-
}
|
|
3864
|
+
var commands = __webpack_require__("./src/cli/commands.ts");
|
|
3865
|
+
var prepare = __webpack_require__("./src/cli/prepare.ts");
|
|
3796
3866
|
async function runCLI() {
|
|
3797
|
-
|
|
3867
|
+
(0, prepare.n)();
|
|
3798
3868
|
try {
|
|
3799
|
-
|
|
3869
|
+
(0, commands.X_)();
|
|
3800
3870
|
} catch (err) {
|
|
3801
3871
|
logger.k.error('Failed to start Rstest CLI.');
|
|
3802
3872
|
logger.k.error(err);
|
|
3803
3873
|
}
|
|
3804
3874
|
}
|
|
3805
|
-
|
|
3875
|
+
var src_config = __webpack_require__("./src/config.ts");
|
|
3876
|
+
function defineConfig(config) {
|
|
3877
|
+
return config;
|
|
3878
|
+
}
|
|
3879
|
+
var __webpack_exports__mergeRstestConfig = src_config.en;
|
|
3880
|
+
export { defineConfig, runCLI, __webpack_exports__mergeRstestConfig as mergeRstestConfig };
|