@rsbuild/core 1.1.12 → 1.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/chokidar/index.d.ts +24 -6
- package/compiled/chokidar/index.js +16 -13
- package/compiled/chokidar/package.json +1 -1
- package/compiled/css-loader/index.js +20 -20
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/jiti/index.js +56 -31
- package/compiled/jiti/package.json +1 -1
- package/compiled/postcss-load-config/index.js +10 -10
- package/compiled/postcss-loader/index.js +8 -8
- package/compiled/rspack-manifest-plugin/index.d.ts +1 -1
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/rspack-manifest-plugin/package.json +1 -1
- package/dist/client/hmr.js +8 -69
- package/dist/client/overlay.js +9 -156
- package/dist/index.cjs +761 -1270
- package/dist/index.js +814 -1321
- package/dist-types/client/hmr.d.ts +1 -1
- package/dist-types/helpers/index.d.ts +2 -0
- package/dist-types/helpers/path.d.ts +2 -0
- package/dist-types/index.d.ts +0 -7
- package/dist-types/plugins/cleanOutput.d.ts +0 -1
- package/dist-types/server/ansiHTML.d.ts +5 -0
- package/dist-types/server/helper.d.ts +6 -0
- package/dist-types/server/overlay.d.ts +2 -0
- package/dist-types/server/socketServer.d.ts +7 -5
- package/dist-types/types/config.d.ts +50 -5
- package/dist-types/types/rsbuild.d.ts +2 -0
- package/package.json +8 -8
- /package/dist-types/{client → helpers}/format.d.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -57,23 +57,33 @@ var __webpack_modules__ = {
|
|
|
57
57
|
};
|
|
58
58
|
module.exports = deepmerge;
|
|
59
59
|
},
|
|
60
|
-
"../../node_modules/.pnpm/dotenv-expand@
|
|
60
|
+
"../../node_modules/.pnpm/dotenv-expand@12.0.1/node_modules/dotenv-expand/lib/main.js": function(module) {
|
|
61
61
|
"use strict";
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return value.replace(DOTENV_SUBSTITUTION_REGEX, (match, escaped, dollarSign, openBrace, key, defaultValue, closeBrace)=>{
|
|
65
|
-
if ('\\' === escaped) return match.slice(1);
|
|
66
|
-
if (processEnv[key]) return processEnv[key] === parsed[key] ? processEnv[key] : interpolate(processEnv[key], processEnv, parsed);
|
|
67
|
-
if (parsed[key] && parsed[key] !== value) return interpolate(parsed[key], processEnv, parsed);
|
|
68
|
-
if (defaultValue) return defaultValue.startsWith('$') ? interpolate(defaultValue, processEnv, parsed) : defaultValue;
|
|
69
|
-
return '';
|
|
70
|
-
});
|
|
62
|
+
function _resolveEscapeSequences(value) {
|
|
63
|
+
return value.replace(/\\\$/g, '$');
|
|
71
64
|
}
|
|
72
65
|
module.exports.expand = function(options) {
|
|
73
|
-
let processEnv = process.env;
|
|
66
|
+
let runningParsed = {}, processEnv = process.env;
|
|
74
67
|
for(let key in options && null != options.processEnv && (processEnv = options.processEnv), options.parsed){
|
|
75
68
|
let value = options.parsed[key];
|
|
76
|
-
value =
|
|
69
|
+
value = processEnv[key] && processEnv[key] !== value ? processEnv[key] : function(value, processEnv, runningParsed) {
|
|
70
|
+
let match;
|
|
71
|
+
let env = {
|
|
72
|
+
...runningParsed,
|
|
73
|
+
...processEnv
|
|
74
|
+
}, regex = /(?<!\\)\${([^{}]+)}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g, result = value, seen = new Set();
|
|
75
|
+
for(; null !== (match = regex.exec(result));){
|
|
76
|
+
let defaultValue, value;
|
|
77
|
+
seen.add(result);
|
|
78
|
+
let [template, bracedExpression, unbracedExpression] = match, expression = bracedExpression || unbracedExpression, opRegex = /(:\+|\+|:-|-)/, opMatch = expression.match(opRegex), splitter = opMatch ? opMatch[0] : null, r = expression.split(splitter), key = r.shift();
|
|
79
|
+
if ([
|
|
80
|
+
':+',
|
|
81
|
+
'+'
|
|
82
|
+
].includes(splitter) ? (defaultValue = env[key] ? r.join(splitter) : '', value = null) : (defaultValue = r.join(splitter), value = env[key]), (result = value ? seen.has(value) ? result.replace(template, defaultValue) : result.replace(template, value) : result.replace(template, defaultValue)) === runningParsed[key]) break;
|
|
83
|
+
regex.lastIndex = 0;
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}(value, processEnv, runningParsed), options.parsed[key] = _resolveEscapeSequences(value), runningParsed[key] = _resolveEscapeSequences(value);
|
|
77
87
|
}
|
|
78
88
|
for(let processKey in options.parsed)processEnv[processKey] = options.parsed[processKey];
|
|
79
89
|
return options;
|
|
@@ -240,26 +250,6 @@ var __webpack_modules__ = {
|
|
|
240
250
|
"use strict";
|
|
241
251
|
module.exports = require("fs");
|
|
242
252
|
},
|
|
243
|
-
"node:child_process": function(module) {
|
|
244
|
-
"use strict";
|
|
245
|
-
module.exports = require("node:child_process");
|
|
246
|
-
},
|
|
247
|
-
"node:events": function(module) {
|
|
248
|
-
"use strict";
|
|
249
|
-
module.exports = require("node:events");
|
|
250
|
-
},
|
|
251
|
-
"node:fs": function(module) {
|
|
252
|
-
"use strict";
|
|
253
|
-
module.exports = require("node:fs");
|
|
254
|
-
},
|
|
255
|
-
"node:path": function(module) {
|
|
256
|
-
"use strict";
|
|
257
|
-
module.exports = require("node:path");
|
|
258
|
-
},
|
|
259
|
-
"node:process": function(module) {
|
|
260
|
-
"use strict";
|
|
261
|
-
module.exports = require("node:process");
|
|
262
|
-
},
|
|
263
253
|
os: function(module) {
|
|
264
254
|
"use strict";
|
|
265
255
|
module.exports = require("os");
|
|
@@ -348,1055 +338,6 @@ var __webpack_modules__ = {
|
|
|
348
338
|
"use strict";
|
|
349
339
|
module.exports = import("node:https");
|
|
350
340
|
},
|
|
351
|
-
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/index.js": function(__unused_webpack_module, exports1, __webpack_require__) {
|
|
352
|
-
let { Argument } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/argument.js"), { Command } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js"), { CommanderError, InvalidArgumentError } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/error.js"), { Help } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/help.js"), { Option } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/option.js");
|
|
353
|
-
exports1.program = new Command(), exports1.createCommand = (name)=>new Command(name), exports1.createOption = (flags, description)=>new Option(flags, description), exports1.createArgument = (name, description)=>new Argument(name, description), exports1.Command = Command, exports1.Option = Option, exports1.Argument = Argument, exports1.Help = Help, exports1.CommanderError = CommanderError, exports1.InvalidArgumentError = InvalidArgumentError, exports1.InvalidOptionArgumentError = InvalidArgumentError;
|
|
354
|
-
},
|
|
355
|
-
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/argument.js": function(__unused_webpack_module, exports1, __webpack_require__) {
|
|
356
|
-
let { InvalidArgumentError } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/error.js");
|
|
357
|
-
exports1.Argument = class Argument {
|
|
358
|
-
constructor(name, description){
|
|
359
|
-
switch(this.description = description || '', this.variadic = !1, this.parseArg = void 0, this.defaultValue = void 0, this.defaultValueDescription = void 0, this.argChoices = void 0, name[0]){
|
|
360
|
-
case '<':
|
|
361
|
-
this.required = !0, this._name = name.slice(1, -1);
|
|
362
|
-
break;
|
|
363
|
-
case '[':
|
|
364
|
-
this.required = !1, this._name = name.slice(1, -1);
|
|
365
|
-
break;
|
|
366
|
-
default:
|
|
367
|
-
this.required = !0, this._name = name;
|
|
368
|
-
}
|
|
369
|
-
this._name.length > 3 && '...' === this._name.slice(-3) && (this.variadic = !0, this._name = this._name.slice(0, -3));
|
|
370
|
-
}
|
|
371
|
-
name() {
|
|
372
|
-
return this._name;
|
|
373
|
-
}
|
|
374
|
-
_concatValue(value, previous) {
|
|
375
|
-
return previous !== this.defaultValue && Array.isArray(previous) ? previous.concat(value) : [
|
|
376
|
-
value
|
|
377
|
-
];
|
|
378
|
-
}
|
|
379
|
-
default(value, description) {
|
|
380
|
-
return this.defaultValue = value, this.defaultValueDescription = description, this;
|
|
381
|
-
}
|
|
382
|
-
argParser(fn) {
|
|
383
|
-
return this.parseArg = fn, this;
|
|
384
|
-
}
|
|
385
|
-
choices(values) {
|
|
386
|
-
return this.argChoices = values.slice(), this.parseArg = (arg, previous)=>{
|
|
387
|
-
if (!this.argChoices.includes(arg)) throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(', ')}.`);
|
|
388
|
-
return this.variadic ? this._concatValue(arg, previous) : arg;
|
|
389
|
-
}, this;
|
|
390
|
-
}
|
|
391
|
-
argRequired() {
|
|
392
|
-
return this.required = !0, this;
|
|
393
|
-
}
|
|
394
|
-
argOptional() {
|
|
395
|
-
return this.required = !1, this;
|
|
396
|
-
}
|
|
397
|
-
}, exports1.humanReadableArgName = function(arg) {
|
|
398
|
-
let nameOutput = arg.name() + (!0 === arg.variadic ? '...' : '');
|
|
399
|
-
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
|
|
400
|
-
};
|
|
401
|
-
},
|
|
402
|
-
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js": function(__unused_webpack_module, exports1, __webpack_require__) {
|
|
403
|
-
let EventEmitter = __webpack_require__("node:events").EventEmitter, childProcess = __webpack_require__("node:child_process"), path = __webpack_require__("node:path"), fs = __webpack_require__("node:fs"), process1 = __webpack_require__("node:process"), { Argument, humanReadableArgName } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/argument.js"), { CommanderError } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/error.js"), { Help } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/help.js"), { Option, DualOptions } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/option.js"), { suggestSimilar } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/suggestSimilar.js");
|
|
404
|
-
class Command extends EventEmitter {
|
|
405
|
-
constructor(name){
|
|
406
|
-
super(), this.commands = [], this.options = [], this.parent = null, this._allowUnknownOption = !1, this._allowExcessArguments = !0, this.registeredArguments = [], this._args = this.registeredArguments, this.args = [], this.rawArgs = [], this.processedArgs = [], this._scriptPath = null, this._name = name || '', this._optionValues = {}, this._optionValueSources = {}, this._storeOptionsAsProperties = !1, this._actionHandler = null, this._executableHandler = !1, this._executableFile = null, this._executableDir = null, this._defaultCommandName = null, this._exitCallback = null, this._aliases = [], this._combineFlagAndOptionalValue = !0, this._description = '', this._summary = '', this._argsDescription = void 0, this._enablePositionalOptions = !1, this._passThroughOptions = !1, this._lifeCycleHooks = {}, this._showHelpAfterError = !1, this._showSuggestionAfterError = !0, this._outputConfiguration = {
|
|
407
|
-
writeOut: (str)=>process1.stdout.write(str),
|
|
408
|
-
writeErr: (str)=>process1.stderr.write(str),
|
|
409
|
-
getOutHelpWidth: ()=>process1.stdout.isTTY ? process1.stdout.columns : void 0,
|
|
410
|
-
getErrHelpWidth: ()=>process1.stderr.isTTY ? process1.stderr.columns : void 0,
|
|
411
|
-
outputError: (str, write)=>write(str)
|
|
412
|
-
}, this._hidden = !1, this._helpOption = void 0, this._addImplicitHelpCommand = void 0, this._helpCommand = void 0, this._helpConfiguration = {};
|
|
413
|
-
}
|
|
414
|
-
copyInheritedSettings(sourceCommand) {
|
|
415
|
-
return this._outputConfiguration = sourceCommand._outputConfiguration, this._helpOption = sourceCommand._helpOption, this._helpCommand = sourceCommand._helpCommand, this._helpConfiguration = sourceCommand._helpConfiguration, this._exitCallback = sourceCommand._exitCallback, this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties, this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue, this._allowExcessArguments = sourceCommand._allowExcessArguments, this._enablePositionalOptions = sourceCommand._enablePositionalOptions, this._showHelpAfterError = sourceCommand._showHelpAfterError, this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError, this;
|
|
416
|
-
}
|
|
417
|
-
_getCommandAndAncestors() {
|
|
418
|
-
let result = [];
|
|
419
|
-
for(let command = this; command; command = command.parent)result.push(command);
|
|
420
|
-
return result;
|
|
421
|
-
}
|
|
422
|
-
command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
|
|
423
|
-
let desc = actionOptsOrExecDesc, opts = execOpts;
|
|
424
|
-
'object' == typeof desc && null !== desc && (opts = desc, desc = null), opts = opts || {};
|
|
425
|
-
let [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/), cmd = this.createCommand(name);
|
|
426
|
-
return (desc && (cmd.description(desc), cmd._executableHandler = !0), opts.isDefault && (this._defaultCommandName = cmd._name), cmd._hidden = !!(opts.noHelp || opts.hidden), cmd._executableFile = opts.executableFile || null, args && cmd.arguments(args), this._registerCommand(cmd), cmd.parent = this, cmd.copyInheritedSettings(this), desc) ? this : cmd;
|
|
427
|
-
}
|
|
428
|
-
createCommand(name) {
|
|
429
|
-
return new Command(name);
|
|
430
|
-
}
|
|
431
|
-
createHelp() {
|
|
432
|
-
return Object.assign(new Help(), this.configureHelp());
|
|
433
|
-
}
|
|
434
|
-
configureHelp(configuration) {
|
|
435
|
-
return void 0 === configuration ? this._helpConfiguration : (this._helpConfiguration = configuration, this);
|
|
436
|
-
}
|
|
437
|
-
configureOutput(configuration) {
|
|
438
|
-
return void 0 === configuration ? this._outputConfiguration : (Object.assign(this._outputConfiguration, configuration), this);
|
|
439
|
-
}
|
|
440
|
-
showHelpAfterError(displayHelp = !0) {
|
|
441
|
-
return 'string' != typeof displayHelp && (displayHelp = !!displayHelp), this._showHelpAfterError = displayHelp, this;
|
|
442
|
-
}
|
|
443
|
-
showSuggestionAfterError(displaySuggestion = !0) {
|
|
444
|
-
return this._showSuggestionAfterError = !!displaySuggestion, this;
|
|
445
|
-
}
|
|
446
|
-
addCommand(cmd, opts) {
|
|
447
|
-
if (!cmd._name) throw Error(`Command passed to .addCommand() must have a name
|
|
448
|
-
- specify the name in Command constructor or using .name()`);
|
|
449
|
-
return (opts = opts || {}).isDefault && (this._defaultCommandName = cmd._name), (opts.noHelp || opts.hidden) && (cmd._hidden = !0), this._registerCommand(cmd), cmd.parent = this, cmd._checkForBrokenPassThrough(), this;
|
|
450
|
-
}
|
|
451
|
-
createArgument(name, description) {
|
|
452
|
-
return new Argument(name, description);
|
|
453
|
-
}
|
|
454
|
-
argument(name, description, fn, defaultValue) {
|
|
455
|
-
let argument = this.createArgument(name, description);
|
|
456
|
-
return 'function' == typeof fn ? argument.default(defaultValue).argParser(fn) : argument.default(fn), this.addArgument(argument), this;
|
|
457
|
-
}
|
|
458
|
-
arguments(names) {
|
|
459
|
-
return names.trim().split(/ +/).forEach((detail)=>{
|
|
460
|
-
this.argument(detail);
|
|
461
|
-
}), this;
|
|
462
|
-
}
|
|
463
|
-
addArgument(argument) {
|
|
464
|
-
let previousArgument = this.registeredArguments.slice(-1)[0];
|
|
465
|
-
if (previousArgument && previousArgument.variadic) throw Error(`only the last argument can be variadic '${previousArgument.name()}'`);
|
|
466
|
-
if (argument.required && void 0 !== argument.defaultValue && void 0 === argument.parseArg) throw Error(`a default value for a required argument is never used: '${argument.name()}'`);
|
|
467
|
-
return this.registeredArguments.push(argument), this;
|
|
468
|
-
}
|
|
469
|
-
helpCommand(enableOrNameAndArgs, description) {
|
|
470
|
-
if ('boolean' == typeof enableOrNameAndArgs) return this._addImplicitHelpCommand = enableOrNameAndArgs, this;
|
|
471
|
-
let [, helpName, helpArgs] = (enableOrNameAndArgs = enableOrNameAndArgs ?? 'help [command]').match(/([^ ]+) *(.*)/), helpDescription = description ?? 'display help for command', helpCommand = this.createCommand(helpName);
|
|
472
|
-
return helpCommand.helpOption(!1), helpArgs && helpCommand.arguments(helpArgs), helpDescription && helpCommand.description(helpDescription), this._addImplicitHelpCommand = !0, this._helpCommand = helpCommand, this;
|
|
473
|
-
}
|
|
474
|
-
addHelpCommand(helpCommand, deprecatedDescription) {
|
|
475
|
-
return 'object' != typeof helpCommand ? (this.helpCommand(helpCommand, deprecatedDescription), this) : (this._addImplicitHelpCommand = !0, this._helpCommand = helpCommand, this);
|
|
476
|
-
}
|
|
477
|
-
_getHelpCommand() {
|
|
478
|
-
return this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand('help')) ? (void 0 === this._helpCommand && this.helpCommand(void 0, void 0), this._helpCommand) : null;
|
|
479
|
-
}
|
|
480
|
-
hook(event, listener) {
|
|
481
|
-
let allowedValues = [
|
|
482
|
-
'preSubcommand',
|
|
483
|
-
'preAction',
|
|
484
|
-
'postAction'
|
|
485
|
-
];
|
|
486
|
-
if (!allowedValues.includes(event)) throw Error(`Unexpected value for event passed to hook : '${event}'.
|
|
487
|
-
Expecting one of '${allowedValues.join("', '")}'`);
|
|
488
|
-
return this._lifeCycleHooks[event] ? this._lifeCycleHooks[event].push(listener) : this._lifeCycleHooks[event] = [
|
|
489
|
-
listener
|
|
490
|
-
], this;
|
|
491
|
-
}
|
|
492
|
-
exitOverride(fn) {
|
|
493
|
-
return fn ? this._exitCallback = fn : this._exitCallback = (err)=>{
|
|
494
|
-
if ('commander.executeSubCommandAsync' !== err.code) throw err;
|
|
495
|
-
}, this;
|
|
496
|
-
}
|
|
497
|
-
_exit(exitCode, code, message) {
|
|
498
|
-
this._exitCallback && this._exitCallback(new CommanderError(exitCode, code, message)), process1.exit(exitCode);
|
|
499
|
-
}
|
|
500
|
-
action(fn) {
|
|
501
|
-
return this._actionHandler = (args)=>{
|
|
502
|
-
let expectedArgsCount = this.registeredArguments.length, actionArgs = args.slice(0, expectedArgsCount);
|
|
503
|
-
return this._storeOptionsAsProperties ? actionArgs[expectedArgsCount] = this : actionArgs[expectedArgsCount] = this.opts(), actionArgs.push(this), fn.apply(this, actionArgs);
|
|
504
|
-
}, this;
|
|
505
|
-
}
|
|
506
|
-
createOption(flags, description) {
|
|
507
|
-
return new Option(flags, description);
|
|
508
|
-
}
|
|
509
|
-
_callParseArg(target, value, previous, invalidArgumentMessage) {
|
|
510
|
-
try {
|
|
511
|
-
return target.parseArg(value, previous);
|
|
512
|
-
} catch (err) {
|
|
513
|
-
if ('commander.invalidArgument' === err.code) {
|
|
514
|
-
let message = `${invalidArgumentMessage} ${err.message}`;
|
|
515
|
-
this.error(message, {
|
|
516
|
-
exitCode: err.exitCode,
|
|
517
|
-
code: err.code
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
throw err;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
_registerOption(option) {
|
|
524
|
-
let matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
|
|
525
|
-
if (matchingOption) {
|
|
526
|
-
let matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
|
|
527
|
-
throw Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
|
|
528
|
-
- already used by option '${matchingOption.flags}'`);
|
|
529
|
-
}
|
|
530
|
-
this.options.push(option);
|
|
531
|
-
}
|
|
532
|
-
_registerCommand(command) {
|
|
533
|
-
let knownBy = (cmd)=>[
|
|
534
|
-
cmd.name()
|
|
535
|
-
].concat(cmd.aliases()), alreadyUsed = knownBy(command).find((name)=>this._findCommand(name));
|
|
536
|
-
if (alreadyUsed) {
|
|
537
|
-
let existingCmd = knownBy(this._findCommand(alreadyUsed)).join('|'), newCmd = knownBy(command).join('|');
|
|
538
|
-
throw Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
|
|
539
|
-
}
|
|
540
|
-
this.commands.push(command);
|
|
541
|
-
}
|
|
542
|
-
addOption(option) {
|
|
543
|
-
this._registerOption(option);
|
|
544
|
-
let oname = option.name(), name = option.attributeName();
|
|
545
|
-
if (option.negate) {
|
|
546
|
-
let positiveLongFlag = option.long.replace(/^--no-/, '--');
|
|
547
|
-
!this._findOption(positiveLongFlag) && this.setOptionValueWithSource(name, void 0 === option.defaultValue || option.defaultValue, 'default');
|
|
548
|
-
} else void 0 !== option.defaultValue && this.setOptionValueWithSource(name, option.defaultValue, 'default');
|
|
549
|
-
let handleOptionValue = (val, invalidValueMessage, valueSource)=>{
|
|
550
|
-
null == val && void 0 !== option.presetArg && (val = option.presetArg);
|
|
551
|
-
let oldValue = this.getOptionValue(name);
|
|
552
|
-
null !== val && option.parseArg ? val = this._callParseArg(option, val, oldValue, invalidValueMessage) : null !== val && option.variadic && (val = option._concatValue(val, oldValue)), null == val && (val = !option.negate && (!!option.isBoolean() || !!option.optional || '')), this.setOptionValueWithSource(name, val, valueSource);
|
|
553
|
-
};
|
|
554
|
-
return this.on('option:' + oname, (val)=>{
|
|
555
|
-
let invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
|
|
556
|
-
handleOptionValue(val, invalidValueMessage, 'cli');
|
|
557
|
-
}), option.envVar && this.on('optionEnv:' + oname, (val)=>{
|
|
558
|
-
let invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
|
|
559
|
-
handleOptionValue(val, invalidValueMessage, 'env');
|
|
560
|
-
}), this;
|
|
561
|
-
}
|
|
562
|
-
_optionEx(config, flags, description, fn, defaultValue) {
|
|
563
|
-
if ('object' == typeof flags && flags instanceof Option) throw Error('To add an Option object use addOption() instead of option() or requiredOption()');
|
|
564
|
-
let option = this.createOption(flags, description);
|
|
565
|
-
if (option.makeOptionMandatory(!!config.mandatory), 'function' == typeof fn) option.default(defaultValue).argParser(fn);
|
|
566
|
-
else if (fn instanceof RegExp) {
|
|
567
|
-
let regex = fn;
|
|
568
|
-
fn = (val, def)=>{
|
|
569
|
-
let m = regex.exec(val);
|
|
570
|
-
return m ? m[0] : def;
|
|
571
|
-
}, option.default(defaultValue).argParser(fn);
|
|
572
|
-
} else option.default(fn);
|
|
573
|
-
return this.addOption(option);
|
|
574
|
-
}
|
|
575
|
-
option(flags, description, parseArg, defaultValue) {
|
|
576
|
-
return this._optionEx({}, flags, description, parseArg, defaultValue);
|
|
577
|
-
}
|
|
578
|
-
requiredOption(flags, description, parseArg, defaultValue) {
|
|
579
|
-
return this._optionEx({
|
|
580
|
-
mandatory: !0
|
|
581
|
-
}, flags, description, parseArg, defaultValue);
|
|
582
|
-
}
|
|
583
|
-
combineFlagAndOptionalValue(combine = !0) {
|
|
584
|
-
return this._combineFlagAndOptionalValue = !!combine, this;
|
|
585
|
-
}
|
|
586
|
-
allowUnknownOption(allowUnknown = !0) {
|
|
587
|
-
return this._allowUnknownOption = !!allowUnknown, this;
|
|
588
|
-
}
|
|
589
|
-
allowExcessArguments(allowExcess = !0) {
|
|
590
|
-
return this._allowExcessArguments = !!allowExcess, this;
|
|
591
|
-
}
|
|
592
|
-
enablePositionalOptions(positional = !0) {
|
|
593
|
-
return this._enablePositionalOptions = !!positional, this;
|
|
594
|
-
}
|
|
595
|
-
passThroughOptions(passThrough = !0) {
|
|
596
|
-
return this._passThroughOptions = !!passThrough, this._checkForBrokenPassThrough(), this;
|
|
597
|
-
}
|
|
598
|
-
_checkForBrokenPassThrough() {
|
|
599
|
-
if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
|
|
600
|
-
}
|
|
601
|
-
storeOptionsAsProperties(storeAsProperties = !0) {
|
|
602
|
-
if (this.options.length) throw Error('call .storeOptionsAsProperties() before adding options');
|
|
603
|
-
if (Object.keys(this._optionValues).length) throw Error('call .storeOptionsAsProperties() before setting option values');
|
|
604
|
-
return this._storeOptionsAsProperties = !!storeAsProperties, this;
|
|
605
|
-
}
|
|
606
|
-
getOptionValue(key) {
|
|
607
|
-
return this._storeOptionsAsProperties ? this[key] : this._optionValues[key];
|
|
608
|
-
}
|
|
609
|
-
setOptionValue(key, value) {
|
|
610
|
-
return this.setOptionValueWithSource(key, value, void 0);
|
|
611
|
-
}
|
|
612
|
-
setOptionValueWithSource(key, value, source) {
|
|
613
|
-
return this._storeOptionsAsProperties ? this[key] = value : this._optionValues[key] = value, this._optionValueSources[key] = source, this;
|
|
614
|
-
}
|
|
615
|
-
getOptionValueSource(key) {
|
|
616
|
-
return this._optionValueSources[key];
|
|
617
|
-
}
|
|
618
|
-
getOptionValueSourceWithGlobals(key) {
|
|
619
|
-
let source;
|
|
620
|
-
return this._getCommandAndAncestors().forEach((cmd)=>{
|
|
621
|
-
void 0 !== cmd.getOptionValueSource(key) && (source = cmd.getOptionValueSource(key));
|
|
622
|
-
}), source;
|
|
623
|
-
}
|
|
624
|
-
_prepareUserArgs(argv, parseOptions) {
|
|
625
|
-
let userArgs;
|
|
626
|
-
if (void 0 !== argv && !Array.isArray(argv)) throw Error('first parameter to parse must be array or undefined');
|
|
627
|
-
if (parseOptions = parseOptions || {}, void 0 === argv && void 0 === parseOptions.from) {
|
|
628
|
-
process1.versions?.electron && (parseOptions.from = 'electron');
|
|
629
|
-
let execArgv = process1.execArgv ?? [];
|
|
630
|
-
(execArgv.includes('-e') || execArgv.includes('--eval') || execArgv.includes('-p') || execArgv.includes('--print')) && (parseOptions.from = 'eval');
|
|
631
|
-
}
|
|
632
|
-
switch(void 0 === argv && (argv = process1.argv), this.rawArgs = argv.slice(), parseOptions.from){
|
|
633
|
-
case void 0:
|
|
634
|
-
case 'node':
|
|
635
|
-
this._scriptPath = argv[1], userArgs = argv.slice(2);
|
|
636
|
-
break;
|
|
637
|
-
case 'electron':
|
|
638
|
-
process1.defaultApp ? (this._scriptPath = argv[1], userArgs = argv.slice(2)) : userArgs = argv.slice(1);
|
|
639
|
-
break;
|
|
640
|
-
case 'user':
|
|
641
|
-
userArgs = argv.slice(0);
|
|
642
|
-
break;
|
|
643
|
-
case 'eval':
|
|
644
|
-
userArgs = argv.slice(1);
|
|
645
|
-
break;
|
|
646
|
-
default:
|
|
647
|
-
throw Error(`unexpected parse option { from: '${parseOptions.from}' }`);
|
|
648
|
-
}
|
|
649
|
-
return !this._name && this._scriptPath && this.nameFromFilename(this._scriptPath), this._name = this._name || 'program', userArgs;
|
|
650
|
-
}
|
|
651
|
-
parse(argv, parseOptions) {
|
|
652
|
-
let userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
653
|
-
return this._parseCommand([], userArgs), this;
|
|
654
|
-
}
|
|
655
|
-
async parseAsync(argv, parseOptions) {
|
|
656
|
-
let userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
657
|
-
return await this._parseCommand([], userArgs), this;
|
|
658
|
-
}
|
|
659
|
-
_executeSubCommand(subcommand, args) {
|
|
660
|
-
let proc;
|
|
661
|
-
args = args.slice();
|
|
662
|
-
let launchWithNode = !1, sourceExt = [
|
|
663
|
-
'.js',
|
|
664
|
-
'.ts',
|
|
665
|
-
'.tsx',
|
|
666
|
-
'.mjs',
|
|
667
|
-
'.cjs'
|
|
668
|
-
];
|
|
669
|
-
function findFile(baseDir, baseName) {
|
|
670
|
-
let localBin = path.resolve(baseDir, baseName);
|
|
671
|
-
if (fs.existsSync(localBin)) return localBin;
|
|
672
|
-
if (sourceExt.includes(path.extname(baseName))) return;
|
|
673
|
-
let foundExt = sourceExt.find((ext)=>fs.existsSync(`${localBin}${ext}`));
|
|
674
|
-
if (foundExt) return `${localBin}${foundExt}`;
|
|
675
|
-
}
|
|
676
|
-
this._checkForMissingMandatoryOptions(), this._checkForConflictingOptions();
|
|
677
|
-
let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`, executableDir = this._executableDir || '';
|
|
678
|
-
if (this._scriptPath) {
|
|
679
|
-
let resolvedScriptPath;
|
|
680
|
-
try {
|
|
681
|
-
resolvedScriptPath = fs.realpathSync(this._scriptPath);
|
|
682
|
-
} catch (err) {
|
|
683
|
-
resolvedScriptPath = this._scriptPath;
|
|
684
|
-
}
|
|
685
|
-
executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
|
|
686
|
-
}
|
|
687
|
-
if (executableDir) {
|
|
688
|
-
let localFile = findFile(executableDir, executableFile);
|
|
689
|
-
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
690
|
-
let legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
|
|
691
|
-
legacyName !== this._name && (localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`));
|
|
692
|
-
}
|
|
693
|
-
executableFile = localFile || executableFile;
|
|
694
|
-
}
|
|
695
|
-
launchWithNode = sourceExt.includes(path.extname(executableFile)), 'win32' !== process1.platform ? launchWithNode ? (args.unshift(executableFile), args = incrementNodeInspectorPort(process1.execArgv).concat(args), proc = childProcess.spawn(process1.argv[0], args, {
|
|
696
|
-
stdio: 'inherit'
|
|
697
|
-
})) : proc = childProcess.spawn(executableFile, args, {
|
|
698
|
-
stdio: 'inherit'
|
|
699
|
-
}) : (args.unshift(executableFile), args = incrementNodeInspectorPort(process1.execArgv).concat(args), proc = childProcess.spawn(process1.execPath, args, {
|
|
700
|
-
stdio: 'inherit'
|
|
701
|
-
})), !proc.killed && [
|
|
702
|
-
'SIGUSR1',
|
|
703
|
-
'SIGUSR2',
|
|
704
|
-
'SIGTERM',
|
|
705
|
-
'SIGINT',
|
|
706
|
-
'SIGHUP'
|
|
707
|
-
].forEach((signal)=>{
|
|
708
|
-
process1.on(signal, ()=>{
|
|
709
|
-
!1 === proc.killed && null === proc.exitCode && proc.kill(signal);
|
|
710
|
-
});
|
|
711
|
-
});
|
|
712
|
-
let exitCallback = this._exitCallback;
|
|
713
|
-
proc.on('close', (code)=>{
|
|
714
|
-
code = code ?? 1, exitCallback ? exitCallback(new CommanderError(code, 'commander.executeSubCommandAsync', '(close)')) : process1.exit(code);
|
|
715
|
-
}), proc.on('error', (err)=>{
|
|
716
|
-
if ('ENOENT' === err.code) {
|
|
717
|
-
let executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : 'no directory for search for local subcommand, use .executableDir() to supply a custom directory';
|
|
718
|
-
throw Error(`'${executableFile}' does not exist
|
|
719
|
-
- if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
720
|
-
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
721
|
-
- ${executableDirMessage}`);
|
|
722
|
-
}
|
|
723
|
-
if ('EACCES' === err.code) throw Error(`'${executableFile}' not executable`);
|
|
724
|
-
if (exitCallback) {
|
|
725
|
-
let wrappedError = new CommanderError(1, 'commander.executeSubCommandAsync', '(error)');
|
|
726
|
-
wrappedError.nestedError = err, exitCallback(wrappedError);
|
|
727
|
-
} else process1.exit(1);
|
|
728
|
-
}), this.runningCommand = proc;
|
|
729
|
-
}
|
|
730
|
-
_dispatchSubcommand(commandName, operands, unknown) {
|
|
731
|
-
let promiseChain;
|
|
732
|
-
let subCommand = this._findCommand(commandName);
|
|
733
|
-
return !subCommand && this.help({
|
|
734
|
-
error: !0
|
|
735
|
-
}), promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, 'preSubcommand'), promiseChain = this._chainOrCall(promiseChain, ()=>{
|
|
736
|
-
if (!subCommand._executableHandler) return subCommand._parseCommand(operands, unknown);
|
|
737
|
-
this._executeSubCommand(subCommand, operands.concat(unknown));
|
|
738
|
-
});
|
|
739
|
-
}
|
|
740
|
-
_dispatchHelpCommand(subcommandName) {
|
|
741
|
-
!subcommandName && this.help();
|
|
742
|
-
let subCommand = this._findCommand(subcommandName);
|
|
743
|
-
return subCommand && !subCommand._executableHandler && subCommand.help(), this._dispatchSubcommand(subcommandName, [], [
|
|
744
|
-
this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? '--help'
|
|
745
|
-
]);
|
|
746
|
-
}
|
|
747
|
-
_checkNumberOfArguments() {
|
|
748
|
-
if (this.registeredArguments.forEach((arg, i)=>{
|
|
749
|
-
arg.required && null == this.args[i] && this.missingArgument(arg.name());
|
|
750
|
-
}), !(this.registeredArguments.length > 0) || !this.registeredArguments[this.registeredArguments.length - 1].variadic) this.args.length > this.registeredArguments.length && this._excessArguments(this.args);
|
|
751
|
-
}
|
|
752
|
-
_processArguments() {
|
|
753
|
-
let myParseArg = (argument, value, previous)=>{
|
|
754
|
-
let parsedValue = value;
|
|
755
|
-
if (null !== value && argument.parseArg) {
|
|
756
|
-
let invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
|
|
757
|
-
parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
|
|
758
|
-
}
|
|
759
|
-
return parsedValue;
|
|
760
|
-
};
|
|
761
|
-
this._checkNumberOfArguments();
|
|
762
|
-
let processedArgs = [];
|
|
763
|
-
this.registeredArguments.forEach((declaredArg, index)=>{
|
|
764
|
-
let value = declaredArg.defaultValue;
|
|
765
|
-
declaredArg.variadic ? index < this.args.length ? (value = this.args.slice(index), declaredArg.parseArg && (value = value.reduce((processed, v)=>myParseArg(declaredArg, v, processed), declaredArg.defaultValue))) : void 0 === value && (value = []) : index < this.args.length && (value = this.args[index], declaredArg.parseArg && (value = myParseArg(declaredArg, value, declaredArg.defaultValue))), processedArgs[index] = value;
|
|
766
|
-
}), this.processedArgs = processedArgs;
|
|
767
|
-
}
|
|
768
|
-
_chainOrCall(promise, fn) {
|
|
769
|
-
return promise && promise.then && 'function' == typeof promise.then ? promise.then(()=>fn()) : fn();
|
|
770
|
-
}
|
|
771
|
-
_chainOrCallHooks(promise, event) {
|
|
772
|
-
let result = promise, hooks = [];
|
|
773
|
-
return this._getCommandAndAncestors().reverse().filter((cmd)=>void 0 !== cmd._lifeCycleHooks[event]).forEach((hookedCommand)=>{
|
|
774
|
-
hookedCommand._lifeCycleHooks[event].forEach((callback)=>{
|
|
775
|
-
hooks.push({
|
|
776
|
-
hookedCommand,
|
|
777
|
-
callback
|
|
778
|
-
});
|
|
779
|
-
});
|
|
780
|
-
}), 'postAction' === event && hooks.reverse(), hooks.forEach((hookDetail)=>{
|
|
781
|
-
result = this._chainOrCall(result, ()=>hookDetail.callback(hookDetail.hookedCommand, this));
|
|
782
|
-
}), result;
|
|
783
|
-
}
|
|
784
|
-
_chainOrCallSubCommandHook(promise, subCommand, event) {
|
|
785
|
-
let result = promise;
|
|
786
|
-
return void 0 !== this._lifeCycleHooks[event] && this._lifeCycleHooks[event].forEach((hook)=>{
|
|
787
|
-
result = this._chainOrCall(result, ()=>hook(this, subCommand));
|
|
788
|
-
}), result;
|
|
789
|
-
}
|
|
790
|
-
_parseCommand(operands, unknown) {
|
|
791
|
-
let parsed = this.parseOptions(unknown);
|
|
792
|
-
if (this._parseOptionsEnv(), this._parseOptionsImplied(), operands = operands.concat(parsed.operands), unknown = parsed.unknown, this.args = operands.concat(unknown), operands && this._findCommand(operands[0])) return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
|
|
793
|
-
if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) return this._dispatchHelpCommand(operands[1]);
|
|
794
|
-
if (this._defaultCommandName) return this._outputHelpIfRequested(unknown), this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
|
|
795
|
-
this.commands.length && 0 === this.args.length && !this._actionHandler && !this._defaultCommandName && this.help({
|
|
796
|
-
error: !0
|
|
797
|
-
}), this._outputHelpIfRequested(parsed.unknown), this._checkForMissingMandatoryOptions(), this._checkForConflictingOptions();
|
|
798
|
-
let checkForUnknownOptions = ()=>{
|
|
799
|
-
parsed.unknown.length > 0 && this.unknownOption(parsed.unknown[0]);
|
|
800
|
-
}, commandEvent = `command:${this.name()}`;
|
|
801
|
-
if (this._actionHandler) {
|
|
802
|
-
let promiseChain;
|
|
803
|
-
return checkForUnknownOptions(), this._processArguments(), promiseChain = this._chainOrCallHooks(promiseChain, 'preAction'), promiseChain = this._chainOrCall(promiseChain, ()=>this._actionHandler(this.processedArgs)), this.parent && (promiseChain = this._chainOrCall(promiseChain, ()=>{
|
|
804
|
-
this.parent.emit(commandEvent, operands, unknown);
|
|
805
|
-
})), promiseChain = this._chainOrCallHooks(promiseChain, 'postAction');
|
|
806
|
-
}
|
|
807
|
-
if (this.parent && this.parent.listenerCount(commandEvent)) checkForUnknownOptions(), this._processArguments(), this.parent.emit(commandEvent, operands, unknown);
|
|
808
|
-
else if (operands.length) {
|
|
809
|
-
if (this._findCommand('*')) return this._dispatchSubcommand('*', operands, unknown);
|
|
810
|
-
this.listenerCount('command:*') ? this.emit('command:*', operands, unknown) : this.commands.length ? this.unknownCommand() : (checkForUnknownOptions(), this._processArguments());
|
|
811
|
-
} else this.commands.length ? (checkForUnknownOptions(), this.help({
|
|
812
|
-
error: !0
|
|
813
|
-
})) : (checkForUnknownOptions(), this._processArguments());
|
|
814
|
-
}
|
|
815
|
-
_findCommand(name) {
|
|
816
|
-
if (name) return this.commands.find((cmd)=>cmd._name === name || cmd._aliases.includes(name));
|
|
817
|
-
}
|
|
818
|
-
_findOption(arg) {
|
|
819
|
-
return this.options.find((option)=>option.is(arg));
|
|
820
|
-
}
|
|
821
|
-
_checkForMissingMandatoryOptions() {
|
|
822
|
-
this._getCommandAndAncestors().forEach((cmd)=>{
|
|
823
|
-
cmd.options.forEach((anOption)=>{
|
|
824
|
-
anOption.mandatory && void 0 === cmd.getOptionValue(anOption.attributeName()) && cmd.missingMandatoryOptionValue(anOption);
|
|
825
|
-
});
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
_checkForConflictingLocalOptions() {
|
|
829
|
-
let definedNonDefaultOptions = this.options.filter((option)=>{
|
|
830
|
-
let optionKey = option.attributeName();
|
|
831
|
-
return void 0 !== this.getOptionValue(optionKey) && 'default' !== this.getOptionValueSource(optionKey);
|
|
832
|
-
});
|
|
833
|
-
definedNonDefaultOptions.filter((option)=>option.conflictsWith.length > 0).forEach((option)=>{
|
|
834
|
-
let conflictingAndDefined = definedNonDefaultOptions.find((defined)=>option.conflictsWith.includes(defined.attributeName()));
|
|
835
|
-
conflictingAndDefined && this._conflictingOption(option, conflictingAndDefined);
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
_checkForConflictingOptions() {
|
|
839
|
-
this._getCommandAndAncestors().forEach((cmd)=>{
|
|
840
|
-
cmd._checkForConflictingLocalOptions();
|
|
841
|
-
});
|
|
842
|
-
}
|
|
843
|
-
parseOptions(argv) {
|
|
844
|
-
let operands = [], unknown = [], dest = operands, args = argv.slice();
|
|
845
|
-
function maybeOption(arg) {
|
|
846
|
-
return arg.length > 1 && '-' === arg[0];
|
|
847
|
-
}
|
|
848
|
-
let activeVariadicOption = null;
|
|
849
|
-
for(; args.length;){
|
|
850
|
-
let arg = args.shift();
|
|
851
|
-
if ('--' === arg) {
|
|
852
|
-
dest === unknown && dest.push(arg), dest.push(...args);
|
|
853
|
-
break;
|
|
854
|
-
}
|
|
855
|
-
if (activeVariadicOption && !maybeOption(arg)) {
|
|
856
|
-
this.emit(`option:${activeVariadicOption.name()}`, arg);
|
|
857
|
-
continue;
|
|
858
|
-
}
|
|
859
|
-
if (activeVariadicOption = null, maybeOption(arg)) {
|
|
860
|
-
let option = this._findOption(arg);
|
|
861
|
-
if (option) {
|
|
862
|
-
if (option.required) {
|
|
863
|
-
let value = args.shift();
|
|
864
|
-
void 0 === value && this.optionMissingArgument(option), this.emit(`option:${option.name()}`, value);
|
|
865
|
-
} else if (option.optional) {
|
|
866
|
-
let value = null;
|
|
867
|
-
args.length > 0 && !maybeOption(args[0]) && (value = args.shift()), this.emit(`option:${option.name()}`, value);
|
|
868
|
-
} else this.emit(`option:${option.name()}`);
|
|
869
|
-
activeVariadicOption = option.variadic ? option : null;
|
|
870
|
-
continue;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
if (arg.length > 2 && '-' === arg[0] && '-' !== arg[1]) {
|
|
874
|
-
let option = this._findOption(`-${arg[1]}`);
|
|
875
|
-
if (option) {
|
|
876
|
-
option.required || option.optional && this._combineFlagAndOptionalValue ? this.emit(`option:${option.name()}`, arg.slice(2)) : (this.emit(`option:${option.name()}`), args.unshift(`-${arg.slice(2)}`));
|
|
877
|
-
continue;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
if (/^--[^=]+=/.test(arg)) {
|
|
881
|
-
let index = arg.indexOf('='), option = this._findOption(arg.slice(0, index));
|
|
882
|
-
if (option && (option.required || option.optional)) {
|
|
883
|
-
this.emit(`option:${option.name()}`, arg.slice(index + 1));
|
|
884
|
-
continue;
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
if (maybeOption(arg) && (dest = unknown), (this._enablePositionalOptions || this._passThroughOptions) && 0 === operands.length && 0 === unknown.length) {
|
|
888
|
-
if (this._findCommand(arg)) {
|
|
889
|
-
operands.push(arg), args.length > 0 && unknown.push(...args);
|
|
890
|
-
break;
|
|
891
|
-
}
|
|
892
|
-
if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
|
|
893
|
-
operands.push(arg), args.length > 0 && operands.push(...args);
|
|
894
|
-
break;
|
|
895
|
-
} else if (this._defaultCommandName) {
|
|
896
|
-
unknown.push(arg), args.length > 0 && unknown.push(...args);
|
|
897
|
-
break;
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
if (this._passThroughOptions) {
|
|
901
|
-
dest.push(arg), args.length > 0 && dest.push(...args);
|
|
902
|
-
break;
|
|
903
|
-
}
|
|
904
|
-
dest.push(arg);
|
|
905
|
-
}
|
|
906
|
-
return {
|
|
907
|
-
operands,
|
|
908
|
-
unknown
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
opts() {
|
|
912
|
-
if (this._storeOptionsAsProperties) {
|
|
913
|
-
let result = {}, len = this.options.length;
|
|
914
|
-
for(let i = 0; i < len; i++){
|
|
915
|
-
let key = this.options[i].attributeName();
|
|
916
|
-
result[key] = key === this._versionOptionName ? this._version : this[key];
|
|
917
|
-
}
|
|
918
|
-
return result;
|
|
919
|
-
}
|
|
920
|
-
return this._optionValues;
|
|
921
|
-
}
|
|
922
|
-
optsWithGlobals() {
|
|
923
|
-
return this._getCommandAndAncestors().reduce((combinedOptions, cmd)=>Object.assign(combinedOptions, cmd.opts()), {});
|
|
924
|
-
}
|
|
925
|
-
error(message, errorOptions) {
|
|
926
|
-
this._outputConfiguration.outputError(`${message}\n`, this._outputConfiguration.writeErr), 'string' == typeof this._showHelpAfterError ? this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`) : this._showHelpAfterError && (this._outputConfiguration.writeErr('\n'), this.outputHelp({
|
|
927
|
-
error: !0
|
|
928
|
-
}));
|
|
929
|
-
let config = errorOptions || {}, exitCode = config.exitCode || 1, code = config.code || 'commander.error';
|
|
930
|
-
this._exit(exitCode, code, message);
|
|
931
|
-
}
|
|
932
|
-
_parseOptionsEnv() {
|
|
933
|
-
this.options.forEach((option)=>{
|
|
934
|
-
if (option.envVar && option.envVar in process1.env) {
|
|
935
|
-
let optionKey = option.attributeName();
|
|
936
|
-
(void 0 === this.getOptionValue(optionKey) || [
|
|
937
|
-
'default',
|
|
938
|
-
'config',
|
|
939
|
-
'env'
|
|
940
|
-
].includes(this.getOptionValueSource(optionKey))) && (option.required || option.optional ? this.emit(`optionEnv:${option.name()}`, process1.env[option.envVar]) : this.emit(`optionEnv:${option.name()}`));
|
|
941
|
-
}
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
_parseOptionsImplied() {
|
|
945
|
-
let dualHelper = new DualOptions(this.options), hasCustomOptionValue = (optionKey)=>void 0 !== this.getOptionValue(optionKey) && ![
|
|
946
|
-
'default',
|
|
947
|
-
'implied'
|
|
948
|
-
].includes(this.getOptionValueSource(optionKey));
|
|
949
|
-
this.options.filter((option)=>void 0 !== option.implied && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option)=>{
|
|
950
|
-
Object.keys(option.implied).filter((impliedKey)=>!hasCustomOptionValue(impliedKey)).forEach((impliedKey)=>{
|
|
951
|
-
this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], 'implied');
|
|
952
|
-
});
|
|
953
|
-
});
|
|
954
|
-
}
|
|
955
|
-
missingArgument(name) {
|
|
956
|
-
let message = `error: missing required argument '${name}'`;
|
|
957
|
-
this.error(message, {
|
|
958
|
-
code: 'commander.missingArgument'
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
optionMissingArgument(option) {
|
|
962
|
-
let message = `error: option '${option.flags}' argument missing`;
|
|
963
|
-
this.error(message, {
|
|
964
|
-
code: 'commander.optionMissingArgument'
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
|
-
missingMandatoryOptionValue(option) {
|
|
968
|
-
let message = `error: required option '${option.flags}' not specified`;
|
|
969
|
-
this.error(message, {
|
|
970
|
-
code: 'commander.missingMandatoryOptionValue'
|
|
971
|
-
});
|
|
972
|
-
}
|
|
973
|
-
_conflictingOption(option, conflictingOption) {
|
|
974
|
-
let findBestOptionFromValue = (option)=>{
|
|
975
|
-
let optionKey = option.attributeName(), optionValue = this.getOptionValue(optionKey), negativeOption = this.options.find((target)=>target.negate && optionKey === target.attributeName()), positiveOption = this.options.find((target)=>!target.negate && optionKey === target.attributeName());
|
|
976
|
-
return negativeOption && (void 0 === negativeOption.presetArg && !1 === optionValue || void 0 !== negativeOption.presetArg && optionValue === negativeOption.presetArg) ? negativeOption : positiveOption || option;
|
|
977
|
-
}, getErrorMessage = (option)=>{
|
|
978
|
-
let bestOption = findBestOptionFromValue(option), optionKey = bestOption.attributeName();
|
|
979
|
-
return 'env' === this.getOptionValueSource(optionKey) ? `environment variable '${bestOption.envVar}'` : `option '${bestOption.flags}'`;
|
|
980
|
-
}, message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
|
|
981
|
-
this.error(message, {
|
|
982
|
-
code: 'commander.conflictingOption'
|
|
983
|
-
});
|
|
984
|
-
}
|
|
985
|
-
unknownOption(flag) {
|
|
986
|
-
if (this._allowUnknownOption) return;
|
|
987
|
-
let suggestion = '';
|
|
988
|
-
if (flag.startsWith('--') && this._showSuggestionAfterError) {
|
|
989
|
-
let candidateFlags = [], command = this;
|
|
990
|
-
do {
|
|
991
|
-
let moreFlags = command.createHelp().visibleOptions(command).filter((option)=>option.long).map((option)=>option.long);
|
|
992
|
-
candidateFlags = candidateFlags.concat(moreFlags), command = command.parent;
|
|
993
|
-
}while (command && !command._enablePositionalOptions);
|
|
994
|
-
suggestion = suggestSimilar(flag, candidateFlags);
|
|
995
|
-
}
|
|
996
|
-
let message = `error: unknown option '${flag}'${suggestion}`;
|
|
997
|
-
this.error(message, {
|
|
998
|
-
code: 'commander.unknownOption'
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
_excessArguments(receivedArgs) {
|
|
1002
|
-
if (this._allowExcessArguments) return;
|
|
1003
|
-
let expected = this.registeredArguments.length, forSubcommand = this.parent ? ` for '${this.name()}'` : '', message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${1 === expected ? '' : 's'} but got ${receivedArgs.length}.`;
|
|
1004
|
-
this.error(message, {
|
|
1005
|
-
code: 'commander.excessArguments'
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
unknownCommand() {
|
|
1009
|
-
let unknownName = this.args[0], suggestion = '';
|
|
1010
|
-
if (this._showSuggestionAfterError) {
|
|
1011
|
-
let candidateNames = [];
|
|
1012
|
-
this.createHelp().visibleCommands(this).forEach((command)=>{
|
|
1013
|
-
candidateNames.push(command.name()), command.alias() && candidateNames.push(command.alias());
|
|
1014
|
-
}), suggestion = suggestSimilar(unknownName, candidateNames);
|
|
1015
|
-
}
|
|
1016
|
-
let message = `error: unknown command '${unknownName}'${suggestion}`;
|
|
1017
|
-
this.error(message, {
|
|
1018
|
-
code: 'commander.unknownCommand'
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
version(str, flags, description) {
|
|
1022
|
-
if (void 0 === str) return this._version;
|
|
1023
|
-
this._version = str, flags = flags || '-V, --version', description = description || 'output the version number';
|
|
1024
|
-
let versionOption = this.createOption(flags, description);
|
|
1025
|
-
return this._versionOptionName = versionOption.attributeName(), this._registerOption(versionOption), this.on('option:' + versionOption.name(), ()=>{
|
|
1026
|
-
this._outputConfiguration.writeOut(`${str}\n`), this._exit(0, 'commander.version', str);
|
|
1027
|
-
}), this;
|
|
1028
|
-
}
|
|
1029
|
-
description(str, argsDescription) {
|
|
1030
|
-
return void 0 === str && void 0 === argsDescription ? this._description : (this._description = str, argsDescription && (this._argsDescription = argsDescription), this);
|
|
1031
|
-
}
|
|
1032
|
-
summary(str) {
|
|
1033
|
-
return void 0 === str ? this._summary : (this._summary = str, this);
|
|
1034
|
-
}
|
|
1035
|
-
alias(alias) {
|
|
1036
|
-
if (void 0 === alias) return this._aliases[0];
|
|
1037
|
-
let command = this;
|
|
1038
|
-
if (0 !== this.commands.length && this.commands[this.commands.length - 1]._executableHandler && (command = this.commands[this.commands.length - 1]), alias === command._name) throw Error("Command alias can't be the same as its name");
|
|
1039
|
-
let matchingCommand = this.parent?._findCommand(alias);
|
|
1040
|
-
if (matchingCommand) {
|
|
1041
|
-
let existingCmd = [
|
|
1042
|
-
matchingCommand.name()
|
|
1043
|
-
].concat(matchingCommand.aliases()).join('|');
|
|
1044
|
-
throw Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
|
|
1045
|
-
}
|
|
1046
|
-
return command._aliases.push(alias), this;
|
|
1047
|
-
}
|
|
1048
|
-
aliases(aliases) {
|
|
1049
|
-
return void 0 === aliases ? this._aliases : (aliases.forEach((alias)=>this.alias(alias)), this);
|
|
1050
|
-
}
|
|
1051
|
-
usage(str) {
|
|
1052
|
-
if (void 0 === str) {
|
|
1053
|
-
if (this._usage) return this._usage;
|
|
1054
|
-
let args = this.registeredArguments.map((arg)=>humanReadableArgName(arg));
|
|
1055
|
-
return [].concat(this.options.length || null !== this._helpOption ? '[options]' : [], this.commands.length ? '[command]' : [], this.registeredArguments.length ? args : []).join(' ');
|
|
1056
|
-
}
|
|
1057
|
-
return this._usage = str, this;
|
|
1058
|
-
}
|
|
1059
|
-
name(str) {
|
|
1060
|
-
return void 0 === str ? this._name : (this._name = str, this);
|
|
1061
|
-
}
|
|
1062
|
-
nameFromFilename(filename) {
|
|
1063
|
-
return this._name = path.basename(filename, path.extname(filename)), this;
|
|
1064
|
-
}
|
|
1065
|
-
executableDir(path) {
|
|
1066
|
-
return void 0 === path ? this._executableDir : (this._executableDir = path, this);
|
|
1067
|
-
}
|
|
1068
|
-
helpInformation(contextOptions) {
|
|
1069
|
-
let helper = this.createHelp();
|
|
1070
|
-
return void 0 === helper.helpWidth && (helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth()), helper.formatHelp(this, helper);
|
|
1071
|
-
}
|
|
1072
|
-
_getHelpContext(contextOptions) {
|
|
1073
|
-
let write;
|
|
1074
|
-
let context = {
|
|
1075
|
-
error: !!(contextOptions = contextOptions || {}).error
|
|
1076
|
-
};
|
|
1077
|
-
return write = context.error ? (arg)=>this._outputConfiguration.writeErr(arg) : (arg)=>this._outputConfiguration.writeOut(arg), context.write = contextOptions.write || write, context.command = this, context;
|
|
1078
|
-
}
|
|
1079
|
-
outputHelp(contextOptions) {
|
|
1080
|
-
let deprecatedCallback;
|
|
1081
|
-
'function' == typeof contextOptions && (deprecatedCallback = contextOptions, contextOptions = void 0);
|
|
1082
|
-
let context = this._getHelpContext(contextOptions);
|
|
1083
|
-
this._getCommandAndAncestors().reverse().forEach((command)=>command.emit('beforeAllHelp', context)), this.emit('beforeHelp', context);
|
|
1084
|
-
let helpInformation = this.helpInformation(context);
|
|
1085
|
-
if (deprecatedCallback && 'string' != typeof (helpInformation = deprecatedCallback(helpInformation)) && !Buffer.isBuffer(helpInformation)) throw Error('outputHelp callback must return a string or a Buffer');
|
|
1086
|
-
context.write(helpInformation), this._getHelpOption()?.long && this.emit(this._getHelpOption().long), this.emit('afterHelp', context), this._getCommandAndAncestors().forEach((command)=>command.emit('afterAllHelp', context));
|
|
1087
|
-
}
|
|
1088
|
-
helpOption(flags, description) {
|
|
1089
|
-
return 'boolean' == typeof flags ? (flags ? this._helpOption = this._helpOption ?? void 0 : this._helpOption = null, this) : (flags = flags ?? '-h, --help', description = description ?? 'display help for command', this._helpOption = this.createOption(flags, description), this);
|
|
1090
|
-
}
|
|
1091
|
-
_getHelpOption() {
|
|
1092
|
-
return void 0 === this._helpOption && this.helpOption(void 0, void 0), this._helpOption;
|
|
1093
|
-
}
|
|
1094
|
-
addHelpOption(option) {
|
|
1095
|
-
return this._helpOption = option, this;
|
|
1096
|
-
}
|
|
1097
|
-
help(contextOptions) {
|
|
1098
|
-
this.outputHelp(contextOptions);
|
|
1099
|
-
let exitCode = process1.exitCode || 0;
|
|
1100
|
-
0 === exitCode && contextOptions && 'function' != typeof contextOptions && contextOptions.error && (exitCode = 1), this._exit(exitCode, 'commander.help', '(outputHelp)');
|
|
1101
|
-
}
|
|
1102
|
-
addHelpText(position, text) {
|
|
1103
|
-
let allowedValues = [
|
|
1104
|
-
'beforeAll',
|
|
1105
|
-
'before',
|
|
1106
|
-
'after',
|
|
1107
|
-
'afterAll'
|
|
1108
|
-
];
|
|
1109
|
-
if (!allowedValues.includes(position)) throw Error(`Unexpected value for position to addHelpText.
|
|
1110
|
-
Expecting one of '${allowedValues.join("', '")}'`);
|
|
1111
|
-
let helpEvent = `${position}Help`;
|
|
1112
|
-
return this.on(helpEvent, (context)=>{
|
|
1113
|
-
let helpStr;
|
|
1114
|
-
(helpStr = 'function' == typeof text ? text({
|
|
1115
|
-
error: context.error,
|
|
1116
|
-
command: context.command
|
|
1117
|
-
}) : text) && context.write(`${helpStr}\n`);
|
|
1118
|
-
}), this;
|
|
1119
|
-
}
|
|
1120
|
-
_outputHelpIfRequested(args) {
|
|
1121
|
-
let helpOption = this._getHelpOption();
|
|
1122
|
-
helpOption && args.find((arg)=>helpOption.is(arg)) && (this.outputHelp(), this._exit(0, 'commander.helpDisplayed', '(outputHelp)'));
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
function incrementNodeInspectorPort(args) {
|
|
1126
|
-
return args.map((arg)=>{
|
|
1127
|
-
let debugOption, match;
|
|
1128
|
-
if (!arg.startsWith('--inspect')) return arg;
|
|
1129
|
-
let debugHost = '127.0.0.1', debugPort = '9229';
|
|
1130
|
-
return (null !== (match = arg.match(/^(--inspect(-brk)?)$/)) ? debugOption = match[1] : null !== (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) ? (debugOption = match[1], /^\d+$/.test(match[3]) ? debugPort = match[3] : debugHost = match[3]) : null !== (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) && (debugOption = match[1], debugHost = match[3], debugPort = match[4]), debugOption && '0' !== debugPort) ? `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}` : arg;
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
1133
|
-
exports1.Command = Command;
|
|
1134
|
-
},
|
|
1135
|
-
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/error.js": function(__unused_webpack_module, exports1) {
|
|
1136
|
-
class CommanderError extends Error {
|
|
1137
|
-
constructor(exitCode, code, message){
|
|
1138
|
-
super(message), Error.captureStackTrace(this, this.constructor), this.name = this.constructor.name, this.code = code, this.exitCode = exitCode, this.nestedError = void 0;
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
exports1.CommanderError = CommanderError, exports1.InvalidArgumentError = class InvalidArgumentError extends CommanderError {
|
|
1142
|
-
constructor(message){
|
|
1143
|
-
super(1, 'commander.invalidArgument', message), Error.captureStackTrace(this, this.constructor), this.name = this.constructor.name;
|
|
1144
|
-
}
|
|
1145
|
-
};
|
|
1146
|
-
},
|
|
1147
|
-
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/help.js": function(__unused_webpack_module, exports1, __webpack_require__) {
|
|
1148
|
-
let { humanReadableArgName } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/argument.js");
|
|
1149
|
-
exports1.Help = class Help {
|
|
1150
|
-
constructor(){
|
|
1151
|
-
this.helpWidth = void 0, this.sortSubcommands = !1, this.sortOptions = !1, this.showGlobalOptions = !1;
|
|
1152
|
-
}
|
|
1153
|
-
visibleCommands(cmd) {
|
|
1154
|
-
let visibleCommands = cmd.commands.filter((cmd)=>!cmd._hidden), helpCommand = cmd._getHelpCommand();
|
|
1155
|
-
return helpCommand && !helpCommand._hidden && visibleCommands.push(helpCommand), this.sortSubcommands && visibleCommands.sort((a, b)=>a.name().localeCompare(b.name())), visibleCommands;
|
|
1156
|
-
}
|
|
1157
|
-
compareOptions(a, b) {
|
|
1158
|
-
let getSortKey = (option)=>option.short ? option.short.replace(/^-/, '') : option.long.replace(/^--/, '');
|
|
1159
|
-
return getSortKey(a).localeCompare(getSortKey(b));
|
|
1160
|
-
}
|
|
1161
|
-
visibleOptions(cmd) {
|
|
1162
|
-
let visibleOptions = cmd.options.filter((option)=>!option.hidden), helpOption = cmd._getHelpOption();
|
|
1163
|
-
if (helpOption && !helpOption.hidden) {
|
|
1164
|
-
let removeShort = helpOption.short && cmd._findOption(helpOption.short), removeLong = helpOption.long && cmd._findOption(helpOption.long);
|
|
1165
|
-
removeShort || removeLong ? helpOption.long && !removeLong ? visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description)) : helpOption.short && !removeShort && visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description)) : visibleOptions.push(helpOption);
|
|
1166
|
-
}
|
|
1167
|
-
return this.sortOptions && visibleOptions.sort(this.compareOptions), visibleOptions;
|
|
1168
|
-
}
|
|
1169
|
-
visibleGlobalOptions(cmd) {
|
|
1170
|
-
if (!this.showGlobalOptions) return [];
|
|
1171
|
-
let globalOptions = [];
|
|
1172
|
-
for(let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent){
|
|
1173
|
-
let visibleOptions = ancestorCmd.options.filter((option)=>!option.hidden);
|
|
1174
|
-
globalOptions.push(...visibleOptions);
|
|
1175
|
-
}
|
|
1176
|
-
return this.sortOptions && globalOptions.sort(this.compareOptions), globalOptions;
|
|
1177
|
-
}
|
|
1178
|
-
visibleArguments(cmd) {
|
|
1179
|
-
return (cmd._argsDescription && cmd.registeredArguments.forEach((argument)=>{
|
|
1180
|
-
argument.description = argument.description || cmd._argsDescription[argument.name()] || '';
|
|
1181
|
-
}), cmd.registeredArguments.find((argument)=>argument.description)) ? cmd.registeredArguments : [];
|
|
1182
|
-
}
|
|
1183
|
-
subcommandTerm(cmd) {
|
|
1184
|
-
let args = cmd.registeredArguments.map((arg)=>humanReadableArgName(arg)).join(' ');
|
|
1185
|
-
return cmd._name + (cmd._aliases[0] ? '|' + cmd._aliases[0] : '') + (cmd.options.length ? ' [options]' : '') + (args ? ' ' + args : '');
|
|
1186
|
-
}
|
|
1187
|
-
optionTerm(option) {
|
|
1188
|
-
return option.flags;
|
|
1189
|
-
}
|
|
1190
|
-
argumentTerm(argument) {
|
|
1191
|
-
return argument.name();
|
|
1192
|
-
}
|
|
1193
|
-
longestSubcommandTermLength(cmd, helper) {
|
|
1194
|
-
return helper.visibleCommands(cmd).reduce((max, command)=>Math.max(max, helper.subcommandTerm(command).length), 0);
|
|
1195
|
-
}
|
|
1196
|
-
longestOptionTermLength(cmd, helper) {
|
|
1197
|
-
return helper.visibleOptions(cmd).reduce((max, option)=>Math.max(max, helper.optionTerm(option).length), 0);
|
|
1198
|
-
}
|
|
1199
|
-
longestGlobalOptionTermLength(cmd, helper) {
|
|
1200
|
-
return helper.visibleGlobalOptions(cmd).reduce((max, option)=>Math.max(max, helper.optionTerm(option).length), 0);
|
|
1201
|
-
}
|
|
1202
|
-
longestArgumentTermLength(cmd, helper) {
|
|
1203
|
-
return helper.visibleArguments(cmd).reduce((max, argument)=>Math.max(max, helper.argumentTerm(argument).length), 0);
|
|
1204
|
-
}
|
|
1205
|
-
commandUsage(cmd) {
|
|
1206
|
-
let cmdName = cmd._name;
|
|
1207
|
-
cmd._aliases[0] && (cmdName = cmdName + '|' + cmd._aliases[0]);
|
|
1208
|
-
let ancestorCmdNames = '';
|
|
1209
|
-
for(let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent)ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;
|
|
1210
|
-
return ancestorCmdNames + cmdName + ' ' + cmd.usage();
|
|
1211
|
-
}
|
|
1212
|
-
commandDescription(cmd) {
|
|
1213
|
-
return cmd.description();
|
|
1214
|
-
}
|
|
1215
|
-
subcommandDescription(cmd) {
|
|
1216
|
-
return cmd.summary() || cmd.description();
|
|
1217
|
-
}
|
|
1218
|
-
optionDescription(option) {
|
|
1219
|
-
let extraInfo = [];
|
|
1220
|
-
return (option.argChoices && extraInfo.push(`choices: ${option.argChoices.map((choice)=>JSON.stringify(choice)).join(', ')}`), void 0 !== option.defaultValue && (option.required || option.optional || option.isBoolean() && 'boolean' == typeof option.defaultValue) && extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`), void 0 !== option.presetArg && option.optional && extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`), void 0 !== option.envVar && extraInfo.push(`env: ${option.envVar}`), extraInfo.length > 0) ? `${option.description} (${extraInfo.join(', ')})` : option.description;
|
|
1221
|
-
}
|
|
1222
|
-
argumentDescription(argument) {
|
|
1223
|
-
let extraInfo = [];
|
|
1224
|
-
if (argument.argChoices && extraInfo.push(`choices: ${argument.argChoices.map((choice)=>JSON.stringify(choice)).join(', ')}`), void 0 !== argument.defaultValue && extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`), extraInfo.length > 0) {
|
|
1225
|
-
let extraDescripton = `(${extraInfo.join(', ')})`;
|
|
1226
|
-
return argument.description ? `${argument.description} ${extraDescripton}` : extraDescripton;
|
|
1227
|
-
}
|
|
1228
|
-
return argument.description;
|
|
1229
|
-
}
|
|
1230
|
-
formatHelp(cmd, helper) {
|
|
1231
|
-
let termWidth = helper.padWidth(cmd, helper), helpWidth = helper.helpWidth || 80;
|
|
1232
|
-
function formatItem(term, description) {
|
|
1233
|
-
if (description) {
|
|
1234
|
-
let fullText = `${term.padEnd(termWidth + 2)}${description}`;
|
|
1235
|
-
return helper.wrap(fullText, helpWidth - 2, termWidth + 2);
|
|
1236
|
-
}
|
|
1237
|
-
return term;
|
|
1238
|
-
}
|
|
1239
|
-
function formatList(textArray) {
|
|
1240
|
-
return textArray.join('\n').replace(/^/gm, ' '.repeat(2));
|
|
1241
|
-
}
|
|
1242
|
-
let output = [
|
|
1243
|
-
`Usage: ${helper.commandUsage(cmd)}`,
|
|
1244
|
-
''
|
|
1245
|
-
], commandDescription = helper.commandDescription(cmd);
|
|
1246
|
-
commandDescription.length > 0 && (output = output.concat([
|
|
1247
|
-
helper.wrap(commandDescription, helpWidth, 0),
|
|
1248
|
-
''
|
|
1249
|
-
]));
|
|
1250
|
-
let argumentList = helper.visibleArguments(cmd).map((argument)=>formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument)));
|
|
1251
|
-
argumentList.length > 0 && (output = output.concat([
|
|
1252
|
-
'Arguments:',
|
|
1253
|
-
formatList(argumentList),
|
|
1254
|
-
''
|
|
1255
|
-
]));
|
|
1256
|
-
let optionList = helper.visibleOptions(cmd).map((option)=>formatItem(helper.optionTerm(option), helper.optionDescription(option)));
|
|
1257
|
-
if (optionList.length > 0 && (output = output.concat([
|
|
1258
|
-
'Options:',
|
|
1259
|
-
formatList(optionList),
|
|
1260
|
-
''
|
|
1261
|
-
])), this.showGlobalOptions) {
|
|
1262
|
-
let globalOptionList = helper.visibleGlobalOptions(cmd).map((option)=>formatItem(helper.optionTerm(option), helper.optionDescription(option)));
|
|
1263
|
-
globalOptionList.length > 0 && (output = output.concat([
|
|
1264
|
-
'Global Options:',
|
|
1265
|
-
formatList(globalOptionList),
|
|
1266
|
-
''
|
|
1267
|
-
]));
|
|
1268
|
-
}
|
|
1269
|
-
let commandList = helper.visibleCommands(cmd).map((cmd)=>formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd)));
|
|
1270
|
-
return commandList.length > 0 && (output = output.concat([
|
|
1271
|
-
'Commands:',
|
|
1272
|
-
formatList(commandList),
|
|
1273
|
-
''
|
|
1274
|
-
])), output.join('\n');
|
|
1275
|
-
}
|
|
1276
|
-
padWidth(cmd, helper) {
|
|
1277
|
-
return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
|
|
1278
|
-
}
|
|
1279
|
-
wrap(str, width, indent, minColumnWidth = 40) {
|
|
1280
|
-
let manualIndent = RegExp(`[\\n][ \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]+`);
|
|
1281
|
-
if (str.match(manualIndent)) return str;
|
|
1282
|
-
let columnWidth = width - indent;
|
|
1283
|
-
if (columnWidth < minColumnWidth) return str;
|
|
1284
|
-
let leadingStr = str.slice(0, indent), columnText = str.slice(indent).replace('\r\n', '\n'), indentString = ' '.repeat(indent), breaks = `\\s\u200B`, regex = RegExp(`\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, 'g');
|
|
1285
|
-
return leadingStr + (columnText.match(regex) || []).map((line, i)=>'\n' === line ? '' : (i > 0 ? indentString : '') + line.trimEnd()).join('\n');
|
|
1286
|
-
}
|
|
1287
|
-
};
|
|
1288
|
-
},
|
|
1289
|
-
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/option.js": function(__unused_webpack_module, exports1, __webpack_require__) {
|
|
1290
|
-
let { InvalidArgumentError } = __webpack_require__("../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/error.js");
|
|
1291
|
-
exports1.Option = class Option {
|
|
1292
|
-
constructor(flags, description){
|
|
1293
|
-
this.flags = flags, this.description = description || '', this.required = flags.includes('<'), this.optional = flags.includes('['), this.variadic = /\w\.\.\.[>\]]$/.test(flags), this.mandatory = !1;
|
|
1294
|
-
let optionFlags = function(flags) {
|
|
1295
|
-
let shortFlag, longFlag;
|
|
1296
|
-
let flagParts = flags.split(/[ |,]+/);
|
|
1297
|
-
return flagParts.length > 1 && !/^[[<]/.test(flagParts[1]) && (shortFlag = flagParts.shift()), longFlag = flagParts.shift(), !shortFlag && /^-[^-]$/.test(longFlag) && (shortFlag = longFlag, longFlag = void 0), {
|
|
1298
|
-
shortFlag,
|
|
1299
|
-
longFlag
|
|
1300
|
-
};
|
|
1301
|
-
}(flags);
|
|
1302
|
-
this.short = optionFlags.shortFlag, this.long = optionFlags.longFlag, this.negate = !1, this.long && (this.negate = this.long.startsWith('--no-')), this.defaultValue = void 0, this.defaultValueDescription = void 0, this.presetArg = void 0, this.envVar = void 0, this.parseArg = void 0, this.hidden = !1, this.argChoices = void 0, this.conflictsWith = [], this.implied = void 0;
|
|
1303
|
-
}
|
|
1304
|
-
default(value, description) {
|
|
1305
|
-
return this.defaultValue = value, this.defaultValueDescription = description, this;
|
|
1306
|
-
}
|
|
1307
|
-
preset(arg) {
|
|
1308
|
-
return this.presetArg = arg, this;
|
|
1309
|
-
}
|
|
1310
|
-
conflicts(names) {
|
|
1311
|
-
return this.conflictsWith = this.conflictsWith.concat(names), this;
|
|
1312
|
-
}
|
|
1313
|
-
implies(impliedOptionValues) {
|
|
1314
|
-
let newImplied = impliedOptionValues;
|
|
1315
|
-
return 'string' == typeof impliedOptionValues && (newImplied = {
|
|
1316
|
-
[impliedOptionValues]: !0
|
|
1317
|
-
}), this.implied = Object.assign(this.implied || {}, newImplied), this;
|
|
1318
|
-
}
|
|
1319
|
-
env(name) {
|
|
1320
|
-
return this.envVar = name, this;
|
|
1321
|
-
}
|
|
1322
|
-
argParser(fn) {
|
|
1323
|
-
return this.parseArg = fn, this;
|
|
1324
|
-
}
|
|
1325
|
-
makeOptionMandatory(mandatory = !0) {
|
|
1326
|
-
return this.mandatory = !!mandatory, this;
|
|
1327
|
-
}
|
|
1328
|
-
hideHelp(hide = !0) {
|
|
1329
|
-
return this.hidden = !!hide, this;
|
|
1330
|
-
}
|
|
1331
|
-
_concatValue(value, previous) {
|
|
1332
|
-
return previous !== this.defaultValue && Array.isArray(previous) ? previous.concat(value) : [
|
|
1333
|
-
value
|
|
1334
|
-
];
|
|
1335
|
-
}
|
|
1336
|
-
choices(values) {
|
|
1337
|
-
return this.argChoices = values.slice(), this.parseArg = (arg, previous)=>{
|
|
1338
|
-
if (!this.argChoices.includes(arg)) throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(', ')}.`);
|
|
1339
|
-
return this.variadic ? this._concatValue(arg, previous) : arg;
|
|
1340
|
-
}, this;
|
|
1341
|
-
}
|
|
1342
|
-
name() {
|
|
1343
|
-
return this.long ? this.long.replace(/^--/, '') : this.short.replace(/^-/, '');
|
|
1344
|
-
}
|
|
1345
|
-
attributeName() {
|
|
1346
|
-
return function(str) {
|
|
1347
|
-
return str.split('-').reduce((str, word)=>str + word[0].toUpperCase() + word.slice(1));
|
|
1348
|
-
}(this.name().replace(/^no-/, ''));
|
|
1349
|
-
}
|
|
1350
|
-
is(arg) {
|
|
1351
|
-
return this.short === arg || this.long === arg;
|
|
1352
|
-
}
|
|
1353
|
-
isBoolean() {
|
|
1354
|
-
return !this.required && !this.optional && !this.negate;
|
|
1355
|
-
}
|
|
1356
|
-
}, exports1.DualOptions = class DualOptions {
|
|
1357
|
-
constructor(options){
|
|
1358
|
-
this.positiveOptions = new Map(), this.negativeOptions = new Map(), this.dualOptions = new Set(), options.forEach((option)=>{
|
|
1359
|
-
option.negate ? this.negativeOptions.set(option.attributeName(), option) : this.positiveOptions.set(option.attributeName(), option);
|
|
1360
|
-
}), this.negativeOptions.forEach((value, key)=>{
|
|
1361
|
-
this.positiveOptions.has(key) && this.dualOptions.add(key);
|
|
1362
|
-
});
|
|
1363
|
-
}
|
|
1364
|
-
valueFromOption(value, option) {
|
|
1365
|
-
let optionKey = option.attributeName();
|
|
1366
|
-
if (!this.dualOptions.has(optionKey)) return !0;
|
|
1367
|
-
let preset = this.negativeOptions.get(optionKey).presetArg;
|
|
1368
|
-
return option.negate === ((void 0 !== preset && preset) === value);
|
|
1369
|
-
}
|
|
1370
|
-
};
|
|
1371
|
-
},
|
|
1372
|
-
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/suggestSimilar.js": function(__unused_webpack_module, exports1) {
|
|
1373
|
-
exports1.suggestSimilar = function(word, candidates) {
|
|
1374
|
-
if (!candidates || 0 === candidates.length) return '';
|
|
1375
|
-
candidates = Array.from(new Set(candidates));
|
|
1376
|
-
let searchingOptions = word.startsWith('--');
|
|
1377
|
-
searchingOptions && (word = word.slice(2), candidates = candidates.map((candidate)=>candidate.slice(2)));
|
|
1378
|
-
let similar = [], bestDistance = 3;
|
|
1379
|
-
return (candidates.forEach((candidate)=>{
|
|
1380
|
-
if (candidate.length <= 1) return;
|
|
1381
|
-
let distance = function(a, b) {
|
|
1382
|
-
if (Math.abs(a.length - b.length) > 3) return Math.max(a.length, b.length);
|
|
1383
|
-
let d = [];
|
|
1384
|
-
for(let i = 0; i <= a.length; i++)d[i] = [
|
|
1385
|
-
i
|
|
1386
|
-
];
|
|
1387
|
-
for(let j = 0; j <= b.length; j++)d[0][j] = j;
|
|
1388
|
-
for(let j = 1; j <= b.length; j++)for(let i = 1; i <= a.length; i++){
|
|
1389
|
-
let cost = 1;
|
|
1390
|
-
cost = a[i - 1] === b[j - 1] ? 0 : 1, d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost), i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1] && (d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1));
|
|
1391
|
-
}
|
|
1392
|
-
return d[a.length][b.length];
|
|
1393
|
-
}(word, candidate), length = Math.max(word.length, candidate.length);
|
|
1394
|
-
(length - distance) / length > 0.4 && (distance < bestDistance ? (bestDistance = distance, similar = [
|
|
1395
|
-
candidate
|
|
1396
|
-
]) : distance === bestDistance && similar.push(candidate));
|
|
1397
|
-
}), similar.sort((a, b)=>a.localeCompare(b)), searchingOptions && (similar = similar.map((candidate)=>`--${candidate}`)), similar.length > 1) ? `\n(Did you mean one of ${similar.join(', ')}?)` : 1 === similar.length ? `\n(Did you mean ${similar[0]}?)` : '';
|
|
1398
|
-
};
|
|
1399
|
-
},
|
|
1400
341
|
"../../node_modules/.pnpm/dotenv@16.4.7/node_modules/dotenv/package.json": function(module) {
|
|
1401
342
|
"use strict";
|
|
1402
343
|
module.exports = JSON.parse('{"name":"dotenv","version":"16.4.7","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","pretest":"npm run lint && npm run dts-check","test":"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=lcov","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/motdotla/dotenv.git"},"funding":"https://dotenvx.com","keywords":["dotenv","env",".env","environment","variables","config","settings"],"readmeFilename":"README.md","license":"BSD-2-Clause","devDependencies":{"@types/node":"^18.11.3","decache":"^4.6.2","sinon":"^14.0.1","standard":"^17.0.0","standard-version":"^9.5.0","tap":"^19.2.0","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false}}');
|
|
@@ -1436,25 +377,20 @@ __webpack_require__.n = function(module) {
|
|
|
1436
377
|
var __webpack_exports__ = {};
|
|
1437
378
|
(()=>{
|
|
1438
379
|
"use strict";
|
|
1439
|
-
let pluginHelper_htmlPlugin, cssExtractPlugin
|
|
380
|
+
let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
|
|
1440
381
|
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
1441
|
-
|
|
382
|
+
ensureAssetPrefix: ()=>ensureAssetPrefix,
|
|
1442
383
|
PLUGIN_CSS_NAME: ()=>PLUGIN_CSS_NAME,
|
|
1443
384
|
mergeRsbuildConfig: ()=>mergeRsbuildConfig,
|
|
1444
385
|
logger: ()=>rslog_index_js_namespaceObject.logger,
|
|
1445
|
-
createRsbuild: ()=>createRsbuild,
|
|
1446
|
-
__internalHelper: ()=>internal_namespaceObject,
|
|
1447
386
|
loadEnv: ()=>loadEnv,
|
|
387
|
+
createRsbuild: ()=>createRsbuild,
|
|
1448
388
|
rspack: ()=>core_namespaceObject.rspack,
|
|
1449
389
|
runCLI: ()=>runCLI,
|
|
1450
390
|
version: ()=>src_rslib_entry_version,
|
|
1451
391
|
PLUGIN_SWC_NAME: ()=>PLUGIN_SWC_NAME,
|
|
1452
392
|
loadConfig: ()=>config_loadConfig,
|
|
1453
|
-
|
|
1454
|
-
});
|
|
1455
|
-
var internal_namespaceObject = {};
|
|
1456
|
-
__webpack_require__.r(internal_namespaceObject), __webpack_require__.d(internal_namespaceObject, {
|
|
1457
|
-
setHTMLPlugin: ()=>setHTMLPlugin
|
|
393
|
+
defineConfig: ()=>defineConfig
|
|
1458
394
|
});
|
|
1459
395
|
var provider_helpers_namespaceObject = {};
|
|
1460
396
|
__webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(provider_helpers_namespaceObject, {
|
|
@@ -1478,17 +414,15 @@ var __webpack_exports__ = {};
|
|
|
1478
414
|
});
|
|
1479
415
|
let core_namespaceObject = require("@rspack/core");
|
|
1480
416
|
var core_default = __webpack_require__.n(core_namespaceObject);
|
|
1481
|
-
let
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
var
|
|
417
|
+
let external_node_fs_namespaceObject = require("node:fs");
|
|
418
|
+
var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
|
|
419
|
+
let external_node_path_namespaceObject = require("node:path");
|
|
420
|
+
var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject), main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.7/node_modules/dotenv/lib/main.js"), lib_main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@12.0.1/node_modules/dotenv-expand/lib/main.js");
|
|
421
|
+
let external_node_url_namespaceObject = require("node:url");
|
|
422
|
+
var cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs);
|
|
1487
423
|
let index_js_namespaceObject = require("../compiled/picocolors/index.js");
|
|
1488
424
|
var index_js_default = __webpack_require__.n(index_js_namespaceObject);
|
|
1489
|
-
let external_node_url_namespaceObject =
|
|
1490
|
-
var external_node_url_default = __webpack_require__.n(external_node_url_namespaceObject);
|
|
1491
|
-
let constants_filename = (0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__), constants_dirname = (0, external_node_path_.dirname)(constants_filename), ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, external_node_path_.join)(constants_dirname), STATIC_PATH = (0, external_node_path_.join)(constants_dirname, '../static'), COMPILED_PATH = (0, external_node_path_.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
|
|
425
|
+
let constants_filename = (0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__), constants_dirname = (0, external_node_path_namespaceObject.dirname)(constants_filename), ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, external_node_path_namespaceObject.join)(constants_dirname), STATIC_PATH = (0, external_node_path_namespaceObject.join)(constants_dirname, '../static'), COMPILED_PATH = (0, external_node_path_namespaceObject.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
|
|
1492
426
|
'chrome >= 87',
|
|
1493
427
|
'edge >= 88',
|
|
1494
428
|
'firefox >= 78',
|
|
@@ -1594,55 +528,19 @@ var __webpack_exports__ = {};
|
|
|
1594
528
|
}
|
|
1595
529
|
}
|
|
1596
530
|
function getAbsolutePath(base, filepath) {
|
|
1597
|
-
return (0,
|
|
531
|
+
return (0, external_node_path_namespaceObject.isAbsolute)(filepath) ? filepath : (0, external_node_path_namespaceObject.join)(base, filepath);
|
|
1598
532
|
}
|
|
1599
|
-
let getCompiledPath = (packageName)=>(0,
|
|
533
|
+
let getCompiledPath = (packageName)=>(0, external_node_path_namespaceObject.join)(COMPILED_PATH, packageName, 'index.js'), ensureAbsolutePath = (base, filePath)=>(0, external_node_path_namespaceObject.isAbsolute)(filePath) ? filePath : (0, external_node_path_namespaceObject.resolve)(base, filePath), pathnameParse = (publicPath)=>{
|
|
1600
534
|
try {
|
|
1601
535
|
return publicPath ? new URL(publicPath).pathname : publicPath;
|
|
1602
536
|
} catch (err) {
|
|
1603
537
|
return publicPath;
|
|
1604
538
|
}
|
|
1605
|
-
}
|
|
1606
|
-
function formatMessage(stats, verbose) {
|
|
1607
|
-
let message, lines = [];
|
|
1608
|
-
if ('object' == typeof stats) {
|
|
1609
|
-
let fileName = function(stats) {
|
|
1610
|
-
if (stats.moduleIdentifier) {
|
|
1611
|
-
let matched = stats.moduleIdentifier.match(/(?:\!|^)([^!]+)$/);
|
|
1612
|
-
if (matched) {
|
|
1613
|
-
let fileName = matched.pop();
|
|
1614
|
-
if (fileName) return `File: ${fileName}:1:1\n`;
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
let file = stats.file || stats.moduleName;
|
|
1618
|
-
return file ? `File: ${file}\n` : '';
|
|
1619
|
-
}(stats), mainMessage = stats.message, details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '', stack = verbose && stats.stack ? `\n${stats.stack}` : '', moduleTrace = function(stats) {
|
|
1620
|
-
let traceStr = '';
|
|
1621
|
-
if (stats.moduleTrace) for (let trace of stats.moduleTrace)trace.originName && (traceStr += `\n @ ${trace.originName}`);
|
|
1622
|
-
return traceStr;
|
|
1623
|
-
}(stats);
|
|
1624
|
-
message = `${fileName}${mainMessage}${details}${stack}${moduleTrace}`;
|
|
1625
|
-
} else message = stats;
|
|
1626
|
-
message = (lines = (lines = (message = function(message) {
|
|
1627
|
-
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
1628
|
-
return -1 === message.indexOf(hint) ? message : /File: .+\.s(c|a)ss/.test(message) ? message.replace(hint, 'To enable support for Sass, use "@rsbuild/plugin-sass".') : /File: .+\.less/.test(message) ? message.replace(hint, 'To enable support for Less, use "@rsbuild/plugin-less".') : /File: .+\.styl(us)?/.test(message) ? message.replace(hint, 'To enable support for Stylus, use "@rsbuild/plugin-stylus".') : message;
|
|
1629
|
-
}(message)).split('\n')).filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim())).join('\n');
|
|
1630
|
-
let innerError = '-- inner error --';
|
|
1631
|
-
return !verbose && message.includes(innerError) && (message = message.split(innerError)[0]), message.trim();
|
|
1632
|
-
}
|
|
1633
|
-
function formatStatsMessages(stats, verbose) {
|
|
1634
|
-
var _stats_errors, _stats_warnings;
|
|
1635
|
-
let formattedErrors = (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [];
|
|
1636
|
-
return {
|
|
1637
|
-
errors: formattedErrors,
|
|
1638
|
-
warnings: (null === (_stats_warnings = stats.warnings) || void 0 === _stats_warnings ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || []
|
|
1639
|
-
};
|
|
1640
|
-
}
|
|
1641
|
-
let hintNodePolyfill = (message)=>{
|
|
539
|
+
}, dedupeNestedPaths = (paths)=>paths.sort((p1, p2)=>p2.length > p1.length ? -1 : 1).reduce((prev, curr)=>prev.find((p)=>curr.startsWith(p) || curr === p) ? prev : prev.concat(curr), []), hintNodePolyfill = (message)=>{
|
|
1642
540
|
let getTips = (moduleName)=>{
|
|
1643
541
|
let tips = [
|
|
1644
542
|
`Tip: "${moduleName}" is a built-in Node.js module. It cannot be imported in client-side code.`,
|
|
1645
|
-
`Check if you need to import Node.js module. If needed, you can use ${index_js_default().cyan('@rsbuild/plugin-node-polyfill')}.`
|
|
543
|
+
`Check if you need to import Node.js module. If needed, you can use "${index_js_default().cyan('@rsbuild/plugin-node-polyfill')}" to polyfill it.`
|
|
1646
544
|
];
|
|
1647
545
|
return `${message}\n\n${index_js_default().yellow(tips.join('\n'))}`;
|
|
1648
546
|
};
|
|
@@ -1691,7 +589,77 @@ var __webpack_exports__ = {};
|
|
|
1691
589
|
'vm',
|
|
1692
590
|
'zlib'
|
|
1693
591
|
].includes(moduleName) ? getTips(moduleName) : message;
|
|
1694
|
-
}
|
|
592
|
+
};
|
|
593
|
+
function formatMessage(stats, verbose) {
|
|
594
|
+
let message, lines = [];
|
|
595
|
+
if ('object' == typeof stats) {
|
|
596
|
+
let fileName = function(stats) {
|
|
597
|
+
if (stats.moduleIdentifier) {
|
|
598
|
+
let matched = stats.moduleIdentifier.match(/(?:\!|^)([^!]+)$/);
|
|
599
|
+
if (matched) {
|
|
600
|
+
let fileName = matched.pop();
|
|
601
|
+
if (fileName) return `File: ${fileName}:1:1\n`;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
let file = stats.file || stats.moduleName;
|
|
605
|
+
return file ? `File: ${file}\n` : '';
|
|
606
|
+
}(stats), mainMessage = stats.message, details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '', stack = verbose && stats.stack ? `\n${stats.stack}` : '', moduleTrace = function(stats) {
|
|
607
|
+
let traceStr = '';
|
|
608
|
+
if (stats.moduleTrace) for (let trace of stats.moduleTrace)trace.originName && (traceStr += `\n @ ${trace.originName}`);
|
|
609
|
+
return traceStr;
|
|
610
|
+
}(stats);
|
|
611
|
+
message = `${fileName}${mainMessage}${details}${stack}${moduleTrace}`;
|
|
612
|
+
} else message = stats;
|
|
613
|
+
let innerError = '-- inner error --';
|
|
614
|
+
return !verbose && message.includes(innerError) && (message = message.split(innerError)[0]), (message = (lines = (lines = (message = hintNodePolyfill(message = function(message) {
|
|
615
|
+
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
616
|
+
if (-1 === message.indexOf(hint)) return message;
|
|
617
|
+
for (let plugin of [
|
|
618
|
+
{
|
|
619
|
+
test: /File: .+\.s(c|a)ss/,
|
|
620
|
+
hint: `To enable support for Sass, use "${index_js_default().yellow('@rsbuild/plugin-sass')}".`
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
test: /File: .+\.less/,
|
|
624
|
+
hint: `To enable support for Less, use "${index_js_default().yellow('@rsbuild/plugin-less')}".`
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
test: /File: .+\.styl(us)?/,
|
|
628
|
+
hint: `To enable support for Stylus, use "${index_js_default().yellow('@rsbuild/plugin-stylus')}".`
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
test: /File: .+\.vue?/,
|
|
632
|
+
hint: `To enable support for Vue, use "${index_js_default().yellow('@rsbuild/plugin-vue')}".`
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
test: /File: .+\.svelte?/,
|
|
636
|
+
hint: `To enable support for Svelte, use "${index_js_default().yellow('@rsbuild/plugin-svelte')}".`
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
test: /File: .+\.mdx/,
|
|
640
|
+
hint: `To enable support for MDX, use "${index_js_default().yellow('@rsbuild/plugin-mdx')}".`
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
test: /File: .+\.toml/,
|
|
644
|
+
hint: `To enable support for TOML, use "${index_js_default().yellow('@rsbuild/plugin-toml')}".`
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
test: /File: .+\.yaml/,
|
|
648
|
+
hint: `To enable support for YAML, use "${index_js_default().yellow('@rsbuild/plugin-yaml')}".`
|
|
649
|
+
}
|
|
650
|
+
])if (plugin.test.test(message)) return message.replace(hint, plugin.hint);
|
|
651
|
+
return message;
|
|
652
|
+
}(message))).split('\n')).filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim())).join('\n')).trim();
|
|
653
|
+
}
|
|
654
|
+
function formatStatsMessages(stats, verbose) {
|
|
655
|
+
var _stats_errors, _stats_warnings;
|
|
656
|
+
let formattedErrors = (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [];
|
|
657
|
+
return {
|
|
658
|
+
errors: formattedErrors,
|
|
659
|
+
warnings: (null === (_stats_warnings = stats.warnings) || void 0 === _stats_warnings ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || []
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
let getAllStatsErrors = (statsData)=>{
|
|
1695
663
|
var _statsData_errors, _statsData_children;
|
|
1696
664
|
return statsData.errorsCount && (null === (_statsData_errors = statsData.errors) || void 0 === _statsData_errors ? void 0 : _statsData_errors.length) === 0 ? null === (_statsData_children = statsData.children) || void 0 === _statsData_children ? void 0 : _statsData_children.reduce((errors, curr)=>errors.concat(curr.errors || []), []) : statsData.errors;
|
|
1697
665
|
}, getAllStatsWarnings = (statsData)=>{
|
|
@@ -1716,9 +684,9 @@ var __webpack_exports__ = {};
|
|
|
1716
684
|
}, verbose);
|
|
1717
685
|
return {
|
|
1718
686
|
message: function(errors) {
|
|
1719
|
-
let
|
|
687
|
+
let title = index_js_default().bold(index_js_default().red('Compile error: '));
|
|
1720
688
|
if (!errors.length) return `${title}\n${index_js_default().yellow("For more details, please setting 'stats.errors: true' ")}`;
|
|
1721
|
-
let tip = index_js_default().yellow('Failed to compile, check the errors for troubleshooting.')
|
|
689
|
+
let tip = index_js_default().yellow('Failed to compile, check the errors for troubleshooting.'), text = `${errors.join('\n\n')}\n`;
|
|
1722
690
|
return `${title}\n${tip}\n${text}`;
|
|
1723
691
|
}(errors),
|
|
1724
692
|
level: 'error'
|
|
@@ -1763,14 +731,20 @@ var __webpack_exports__ = {};
|
|
|
1763
731
|
return DEFAULT_ASSET_PREFIX;
|
|
1764
732
|
}, urlJoin = (base, path)=>{
|
|
1765
733
|
let [urlProtocol, baseUrl] = base.split('://');
|
|
1766
|
-
return `${urlProtocol}://${
|
|
734
|
+
return `${urlProtocol}://${external_node_path_namespaceObject.posix.join(baseUrl, path)}`;
|
|
1767
735
|
}, canParse = (url)=>{
|
|
1768
736
|
try {
|
|
1769
|
-
return new URL(url), !0;
|
|
737
|
+
return new external_node_url_namespaceObject.URL(url), !0;
|
|
1770
738
|
} catch {
|
|
1771
739
|
return !1;
|
|
1772
740
|
}
|
|
1773
|
-
},
|
|
741
|
+
}, parseUrl = (url)=>{
|
|
742
|
+
try {
|
|
743
|
+
return new external_node_url_namespaceObject.URL(url);
|
|
744
|
+
} catch {
|
|
745
|
+
return null;
|
|
746
|
+
}
|
|
747
|
+
}, ensureAssetPrefix = (url, assetPrefix = DEFAULT_ASSET_PREFIX)=>url.startsWith('//') || canParse(url) || 'auto' === assetPrefix || 'function' == typeof assetPrefix ? url : assetPrefix.startsWith('http') ? urlJoin(assetPrefix, url) : assetPrefix.startsWith('//') ? urlJoin(`https:${assetPrefix}`, url).replace('https:', '') : external_node_path_namespaceObject.posix.join(assetPrefix, url);
|
|
1774
748
|
function getFilename(config, type, isProd, isServer) {
|
|
1775
749
|
let { filename, filenameHash } = config.output, hash = 'string' == typeof filenameHash ? filenameHash ? `.[${filenameHash}]` : '' : filenameHash ? '.[contenthash:8]' : '';
|
|
1776
750
|
switch(type){
|
|
@@ -1817,7 +791,7 @@ var __webpack_exports__ = {};
|
|
|
1817
791
|
'.env.local',
|
|
1818
792
|
`.env.${mode}`,
|
|
1819
793
|
`.env.${mode}.local`
|
|
1820
|
-
].map((filename)=>(0,
|
|
794
|
+
].map((filename)=>(0, external_node_path_namespaceObject.join)(cwd, filename)).filter(isFileSync), parsed = {};
|
|
1821
795
|
for (let envPath of filePaths)Object.assign(parsed, (0, main.parse)(external_node_fs_default().readFileSync(envPath)));
|
|
1822
796
|
parsed.NODE_ENV && (process.env.NODE_ENV = parsed.NODE_ENV), (0, lib_main.expand)({
|
|
1823
797
|
parsed
|
|
@@ -1859,11 +833,11 @@ var __webpack_exports__ = {};
|
|
|
1859
833
|
let isFileCache = {};
|
|
1860
834
|
function isFile(file) {
|
|
1861
835
|
if (file in isFileCache) return isFileCache[file];
|
|
1862
|
-
let result =
|
|
836
|
+
let result = external_node_fs_namespaceObject.existsSync(file) && external_node_fs_namespaceObject.statSync(file).isFile();
|
|
1863
837
|
return isFileCache[file] = result, result;
|
|
1864
838
|
}
|
|
1865
839
|
function parsePackage(file) {
|
|
1866
|
-
let config = JSON.parse(
|
|
840
|
+
let config = JSON.parse(external_node_fs_namespaceObject.readFileSync(file).toString().replace(/^\uFEFF/m, ''));
|
|
1867
841
|
if (config.browserlist && !config.browserslist) throw new BrowserslistError(`\`browserlist\` key instead of \`browserslist\` in ${file}`);
|
|
1868
842
|
let list = config.browserslist;
|
|
1869
843
|
for(let i in Array.isArray(list) && (list = {
|
|
@@ -1894,9 +868,9 @@ var __webpack_exports__ = {};
|
|
|
1894
868
|
}), result;
|
|
1895
869
|
}
|
|
1896
870
|
function parsePackageOrReadConfig(file) {
|
|
1897
|
-
return 'package.json' ===
|
|
871
|
+
return 'package.json' === external_node_path_namespaceObject.basename(file) ? parsePackage(file) : function(file) {
|
|
1898
872
|
if (!isFile(file)) throw new BrowserslistError(`Can't read ${file} config`);
|
|
1899
|
-
return parseConfig(
|
|
873
|
+
return parseConfig(external_node_fs_namespaceObject.readFileSync(file, 'utf-8'));
|
|
1900
874
|
}(file);
|
|
1901
875
|
}
|
|
1902
876
|
function pickEnv(config, opts) {
|
|
@@ -1904,13 +878,13 @@ var __webpack_exports__ = {};
|
|
|
1904
878
|
return 'object' != typeof config ? config : ('string' == typeof opts.env ? name = opts.env : process.env.BROWSERSLIST_ENV ? name = process.env.BROWSERSLIST_ENV : process.env.NODE_ENV ? name = process.env.NODE_ENV : name = 'production', config[name] || config.defaults);
|
|
1905
879
|
}
|
|
1906
880
|
function eachParent(file, callback) {
|
|
1907
|
-
let dir = isFile(file) ?
|
|
881
|
+
let dir = isFile(file) ? external_node_path_namespaceObject.dirname(file) : file, loc = external_node_path_namespaceObject.resolve(dir);
|
|
1908
882
|
do {
|
|
1909
883
|
let result = callback(loc);
|
|
1910
884
|
if (void 0 !== result) return result;
|
|
1911
|
-
}while (loc !== (loc =
|
|
885
|
+
}while (loc !== (loc = external_node_path_namespaceObject.dirname(loc)));
|
|
1912
886
|
}
|
|
1913
|
-
let configCache = {}, rspack_chain_index_js_namespaceObject = require("../compiled/rspack-chain/index.js");
|
|
887
|
+
let configCache = {}, external_node_module_namespaceObject = require("node:module"), rspack_chain_index_js_namespaceObject = require("../compiled/rspack-chain/index.js");
|
|
1914
888
|
var rspack_chain_index_js_default = __webpack_require__.n(rspack_chain_index_js_namespaceObject);
|
|
1915
889
|
let OVERRIDE_PATHS = [
|
|
1916
890
|
'performance.removeConsole',
|
|
@@ -2191,7 +1165,7 @@ var __webpack_exports__ = {};
|
|
|
2191
1165
|
exportLocalsConvention: 'camelCase'
|
|
2192
1166
|
},
|
|
2193
1167
|
emitAssets: !0
|
|
2194
|
-
}), getDefaultResolveConfig = ()=>(!swcHelpersPath && (swcHelpersPath = (0,
|
|
1168
|
+
}), getDefaultResolveConfig = ()=>(!swcHelpersPath && (swcHelpersPath = (0, external_node_path_namespaceObject.dirname)(config_require.resolve('@swc/helpers/package.json'))), {
|
|
2195
1169
|
alias: {
|
|
2196
1170
|
'@swc/helpers': swcHelpersPath
|
|
2197
1171
|
},
|
|
@@ -2219,7 +1193,7 @@ var __webpack_exports__ = {};
|
|
|
2219
1193
|
var _merged_server, _config_dev, _config_output;
|
|
2220
1194
|
let merged = mergeRsbuildConfig(createDefaultConfig(), config);
|
|
2221
1195
|
if (merged.root ||= rootPath, merged.source ||= {}, (null === (_merged_server = merged.server) || void 0 === _merged_server ? void 0 : _merged_server.base) && ((null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.assetPrefix) === void 0 && (merged.dev ||= {}, merged.dev.assetPrefix = merged.server.base), (null === (_config_output = config.output) || void 0 === _config_output ? void 0 : _config_output.assetPrefix) === void 0 && (merged.output ||= {}, merged.output.assetPrefix = merged.server.base)), !merged.source.tsconfigPath) {
|
|
2222
|
-
let tsconfigPath = (0,
|
|
1196
|
+
let tsconfigPath = (0, external_node_path_namespaceObject.join)(rootPath, 'tsconfig.json');
|
|
2223
1197
|
await isFileExists(tsconfigPath) && (merged.source.tsconfigPath = tsconfigPath);
|
|
2224
1198
|
}
|
|
2225
1199
|
return merged;
|
|
@@ -2236,7 +1210,7 @@ var __webpack_exports__ = {};
|
|
|
2236
1210
|
}
|
|
2237
1211
|
let resolveConfigPath = (root, customConfig)=>{
|
|
2238
1212
|
if (customConfig) {
|
|
2239
|
-
let customConfigPath = (0,
|
|
1213
|
+
let customConfigPath = (0, external_node_path_namespaceObject.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_namespaceObject.join)(root, customConfig);
|
|
2240
1214
|
if (external_node_fs_default().existsSync(customConfigPath)) return customConfigPath;
|
|
2241
1215
|
rslog_index_js_namespaceObject.logger.warn(`Cannot find config file: ${index_js_default().dim(customConfigPath)}\n`);
|
|
2242
1216
|
}
|
|
@@ -2248,7 +1222,7 @@ var __webpack_exports__ = {};
|
|
|
2248
1222
|
'rsbuild.config.mts',
|
|
2249
1223
|
'rsbuild.config.cts'
|
|
2250
1224
|
]){
|
|
2251
|
-
let configFile = (0,
|
|
1225
|
+
let configFile = (0, external_node_path_namespaceObject.join)(root, file);
|
|
2252
1226
|
if (external_node_fs_default().existsSync(configFile)) return configFile;
|
|
2253
1227
|
}
|
|
2254
1228
|
return null;
|
|
@@ -2356,19 +1330,19 @@ var __webpack_exports__ = {};
|
|
|
2356
1330
|
let { outputPath } = inspectOptions, files = [
|
|
2357
1331
|
...rawEnvironmentConfigs.map(({ name, content })=>{
|
|
2358
1332
|
if (1 === rawEnvironmentConfigs.length) return {
|
|
2359
|
-
path: (0,
|
|
1333
|
+
path: (0, external_node_path_namespaceObject.join)(outputPath, 'rsbuild.config.mjs'),
|
|
2360
1334
|
label: 'Rsbuild Config',
|
|
2361
1335
|
content
|
|
2362
1336
|
};
|
|
2363
1337
|
let outputFile = `rsbuild.config.${name}.mjs`;
|
|
2364
1338
|
return {
|
|
2365
|
-
path: (0,
|
|
1339
|
+
path: (0, external_node_path_namespaceObject.join)(outputPath, outputFile),
|
|
2366
1340
|
label: `Rsbuild Config (${name})`,
|
|
2367
1341
|
content
|
|
2368
1342
|
};
|
|
2369
1343
|
}),
|
|
2370
1344
|
...rawBundlerConfigs.map(({ name, content })=>{
|
|
2371
|
-
let outputFile = `${configType}.config.${name}.mjs`, outputFilePath = (0,
|
|
1345
|
+
let outputFile = `${configType}.config.${name}.mjs`, outputFilePath = (0, external_node_path_namespaceObject.join)(outputPath, outputFile);
|
|
2372
1346
|
return external_node_fs_default().existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
|
|
2373
1347
|
path: outputFilePath,
|
|
2374
1348
|
label: `${upperFirst(configType)} Config (${name})`,
|
|
@@ -2391,7 +1365,7 @@ var __webpack_exports__ = {};
|
|
|
2391
1365
|
if (!1 === publicDir) return [];
|
|
2392
1366
|
let defaultConfig = {
|
|
2393
1367
|
name: 'public',
|
|
2394
|
-
copyOnBuild:
|
|
1368
|
+
copyOnBuild: 'auto',
|
|
2395
1369
|
watch: !1
|
|
2396
1370
|
};
|
|
2397
1371
|
return void 0 === publicDir ? [
|
|
@@ -2668,11 +1642,11 @@ var __webpack_exports__ = {};
|
|
|
2668
1642
|
if (opts.path) {
|
|
2669
1643
|
let config = function(from) {
|
|
2670
1644
|
let resolved;
|
|
2671
|
-
let fromDir = isFile(from =
|
|
1645
|
+
let fromDir = isFile(from = external_node_path_namespaceObject.resolve(from)) ? external_node_path_namespaceObject.dirname(from) : from;
|
|
2672
1646
|
if (fromDir in configCache) return configCache[fromDir];
|
|
2673
1647
|
let configFile = eachParent(from, (dir)=>{
|
|
2674
1648
|
let pkgBrowserslist;
|
|
2675
|
-
let config =
|
|
1649
|
+
let config = external_node_path_namespaceObject.join(dir, 'browserslist'), pkg = external_node_path_namespaceObject.join(dir, 'package.json'), rc = external_node_path_namespaceObject.join(dir, '.browserslistrc');
|
|
2676
1650
|
if (isFile(pkg)) try {
|
|
2677
1651
|
pkgBrowserslist = parsePackage(pkg);
|
|
2678
1652
|
} catch (e) {
|
|
@@ -2685,7 +1659,7 @@ var __webpack_exports__ = {};
|
|
|
2685
1659
|
return isFile(config) ? config : isFile(rc) ? rc : pkgBrowserslist ? pkg : void 0;
|
|
2686
1660
|
});
|
|
2687
1661
|
configFile && (resolved = parsePackageOrReadConfig(configFile));
|
|
2688
|
-
let configDir = configFile &&
|
|
1662
|
+
let configDir = configFile && external_node_path_namespaceObject.dirname(configFile);
|
|
2689
1663
|
return eachParent(from, (dir)=>{
|
|
2690
1664
|
if (resolved && (configCache[dir] = resolved), dir === configDir) return null;
|
|
2691
1665
|
}), resolved;
|
|
@@ -2714,7 +1688,7 @@ var __webpack_exports__ = {};
|
|
|
2714
1688
|
let filename;
|
|
2715
1689
|
filename = config.output.filename.html ? config.output.filename.html.replace('[name]', entryName) : 'flat' === config.html.outputStructure ? `${entryName}.html` : `${entryName}/index.html`;
|
|
2716
1690
|
let prefix = config.output.distPath.html;
|
|
2717
|
-
return prefix.startsWith('/') && rslog_index_js_namespaceObject.logger.warn(`Absolute path is not recommended at \`output.distPath.html\`: "${prefix}", please use relative path instead.`), removeLeadingSlash(
|
|
1691
|
+
return prefix.startsWith('/') && rslog_index_js_namespaceObject.logger.warn(`Absolute path is not recommended at \`output.distPath.html\`: "${prefix}", please use relative path instead.`), removeLeadingSlash(external_node_path_namespaceObject.posix.join(prefix, filename));
|
|
2718
1692
|
}(key, config)), prev;
|
|
2719
1693
|
}, {});
|
|
2720
1694
|
async function updateEnvironmentContext(context, configs) {
|
|
@@ -2739,9 +1713,9 @@ var __webpack_exports__ = {};
|
|
|
2739
1713
|
}
|
|
2740
1714
|
}
|
|
2741
1715
|
async function createContext(options, userConfig, bundlerType) {
|
|
2742
|
-
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0,
|
|
1716
|
+
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_namespaceObject.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
2743
1717
|
return {
|
|
2744
|
-
version: "1.
|
|
1718
|
+
version: "1.2.0-alpha.0",
|
|
2745
1719
|
rootPath,
|
|
2746
1720
|
distPath: '',
|
|
2747
1721
|
cachePath,
|
|
@@ -2774,7 +1748,7 @@ var __webpack_exports__ = {};
|
|
|
2774
1748
|
...rsbuildConfig
|
|
2775
1749
|
},
|
|
2776
1750
|
originalConfig: userConfig,
|
|
2777
|
-
specifiedEnvironments
|
|
1751
|
+
specifiedEnvironments
|
|
2778
1752
|
};
|
|
2779
1753
|
}
|
|
2780
1754
|
let external_node_util_namespaceObject = require("node:util"), mrmime_index_js_namespaceObject = require("../compiled/mrmime/index.js"), pluginAppIcon = ()=>({
|
|
@@ -2955,7 +1929,7 @@ var __webpack_exports__ = {};
|
|
|
2955
1929
|
}, external_node_crypto_namespaceObject = require("node:crypto");
|
|
2956
1930
|
var external_node_crypto_default = __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
2957
1931
|
async function validateCache(cacheDirectory, buildDependencies) {
|
|
2958
|
-
let configFile = (0,
|
|
1932
|
+
let configFile = (0, external_node_path_namespaceObject.join)(cacheDirectory, 'buildDependencies.json');
|
|
2959
1933
|
if (await isFileExists(configFile)) {
|
|
2960
1934
|
if (JSON.stringify(JSON.parse(await external_node_fs_default().promises.readFile(configFile, 'utf-8'))) === JSON.stringify(buildDependencies)) return;
|
|
2961
1935
|
await external_node_fs_default().promises.rm(cacheDirectory, {
|
|
@@ -2969,7 +1943,7 @@ var __webpack_exports__ = {};
|
|
|
2969
1943
|
}
|
|
2970
1944
|
async function getBuildDependencies(context, config, environmentContext) {
|
|
2971
1945
|
var _config__privateMeta;
|
|
2972
|
-
let rootPackageJson = (0,
|
|
1946
|
+
let rootPackageJson = (0, external_node_path_namespaceObject.join)(context.rootPath, 'package.json'), browserslistConfig = (0, external_node_path_namespaceObject.join)(context.rootPath, '.browserslistrc'), buildDependencies = {};
|
|
2973
1947
|
await isFileExists(rootPackageJson) && (buildDependencies.packageJson = [
|
|
2974
1948
|
rootPackageJson
|
|
2975
1949
|
]);
|
|
@@ -2986,7 +1960,7 @@ var __webpack_exports__ = {};
|
|
|
2986
1960
|
'js',
|
|
2987
1961
|
'cjs',
|
|
2988
1962
|
'mjs'
|
|
2989
|
-
].map((ext)=>(0,
|
|
1963
|
+
].map((ext)=>(0, external_node_path_namespaceObject.join)(context.rootPath, `tailwind.config.${ext}`)));
|
|
2990
1964
|
return tailwindConfig && (buildDependencies.tailwindcss = [
|
|
2991
1965
|
tailwindConfig
|
|
2992
1966
|
]), buildDependencies;
|
|
@@ -3002,7 +1976,7 @@ var __webpack_exports__ = {};
|
|
|
3002
1976
|
return;
|
|
3003
1977
|
}
|
|
3004
1978
|
let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = function({ cacheDirectory }, context) {
|
|
3005
|
-
return cacheDirectory ? (0,
|
|
1979
|
+
return cacheDirectory ? (0, external_node_path_namespaceObject.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, external_node_path_namespaceObject.join)(context.rootPath, cacheDirectory) : (0, external_node_path_namespaceObject.join)(context.cachePath, context.bundlerType);
|
|
3006
1980
|
}(cacheConfig, context), buildDependencies = await getBuildDependencies(context, config, environment);
|
|
3007
1981
|
await validateCache(cacheDirectory, buildDependencies);
|
|
3008
1982
|
let useDigest = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length;
|
|
@@ -3014,21 +1988,21 @@ var __webpack_exports__ = {};
|
|
|
3014
1988
|
});
|
|
3015
1989
|
});
|
|
3016
1990
|
}
|
|
3017
|
-
}), addTrailingSep = (dir)=>dir.endsWith(
|
|
1991
|
+
}), addTrailingSep = (dir)=>dir.endsWith(external_node_path_namespaceObject.sep) ? dir : dir + external_node_path_namespaceObject.sep, isStrictSubdir = (parent, child)=>{
|
|
3018
1992
|
let parentDir = addTrailingSep(parent), childDir = addTrailingSep(child);
|
|
3019
1993
|
return parentDir !== childDir && childDir.startsWith(parentDir);
|
|
3020
|
-
},
|
|
1994
|
+
}, pluginCleanOutput = ()=>({
|
|
3021
1995
|
name: 'rsbuild:clean-output',
|
|
3022
1996
|
setup (api) {
|
|
3023
1997
|
let getRsbuildCleanPath = ()=>{
|
|
3024
|
-
let { rootPath, distPath } = api.context, config = api.getNormalizedConfig(), cleanPath = (0,
|
|
1998
|
+
let { rootPath, distPath } = api.context, config = api.getNormalizedConfig(), cleanPath = (0, external_node_path_namespaceObject.join)(distPath, RSBUILD_OUTPUTS_PATH), { cleanDistPath } = config.output;
|
|
3025
1999
|
if (!0 === cleanDistPath || 'auto' === cleanDistPath && isStrictSubdir(rootPath, cleanPath)) return cleanPath;
|
|
3026
2000
|
}, getCleanPath = (environment)=>{
|
|
3027
2001
|
let { rootPath } = api.context, { config, distPath } = environment, { cleanDistPath } = config.output;
|
|
3028
2002
|
if ('auto' === cleanDistPath && !(cleanDistPath = isStrictSubdir(rootPath, distPath)) && (rslog_index_js_namespaceObject.logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), rslog_index_js_namespaceObject.logger.warn(`Please set ${index_js_default().yellow('`output.cleanDistPath`')} config manually.`), rslog_index_js_namespaceObject.logger.warn(`Current root path: ${index_js_default().dim(rootPath)}`), rslog_index_js_namespaceObject.logger.warn(`Current dist path: ${index_js_default().dim(distPath)}`)), cleanDistPath) return distPath;
|
|
3029
2003
|
}, cleanAll = async (params)=>{
|
|
3030
2004
|
let cleanPaths = Object.values(params.environments).reduce((total, curr)=>(!total.find((t)=>t.distPath === curr.distPath) && total.push(curr), total), []).map((e)=>getCleanPath(e)).concat(getRsbuildCleanPath()).filter((p)=>!!p);
|
|
3031
|
-
await Promise.all(
|
|
2005
|
+
await Promise.all(dedupeNestedPaths(cleanPaths).map((p)=>emptyDir(p)));
|
|
3032
2006
|
};
|
|
3033
2007
|
api.onBeforeBuild(async ({ isFirstCompile, environments })=>{
|
|
3034
2008
|
isFirstCompile && await cleanAll({
|
|
@@ -3071,7 +2045,11 @@ var __webpack_exports__ = {};
|
|
|
3071
2045
|
mergeFn
|
|
3072
2046
|
}), initial) : config ?? initial;
|
|
3073
2047
|
}
|
|
3074
|
-
let
|
|
2048
|
+
let pluginHelper_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), setHTMLPlugin = (plugin)=>{
|
|
2049
|
+
plugin && (pluginHelper_htmlPlugin = plugin);
|
|
2050
|
+
}, getHTMLPlugin = ()=>(!pluginHelper_htmlPlugin && (pluginHelper_htmlPlugin = pluginHelper_require('../compiled/html-rspack-plugin/index.js')), pluginHelper_htmlPlugin), setCssExtractPlugin = (plugin)=>{
|
|
2051
|
+
cssExtractPlugin = plugin;
|
|
2052
|
+
}, getCssExtractPlugin = ()=>cssExtractPlugin ? cssExtractPlugin : core_default().CssExtractRspackPlugin, getCSSModulesLocalIdentName = (config, isProd)=>config.output.cssModules.localIdentName || (isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'), normalizeCssLoaderOptions = (options, exportOnlyLocals)=>{
|
|
3075
2053
|
if (options.modules && exportOnlyLocals) {
|
|
3076
2054
|
let { modules } = options;
|
|
3077
2055
|
return modules = !0 === modules ? {
|
|
@@ -3483,7 +2461,7 @@ var __webpack_exports__ = {};
|
|
|
3483
2461
|
href.endsWith('.svg') && (tag.attributes.type = 'image/svg+xml'), headTags.unshift(tag);
|
|
3484
2462
|
};
|
|
3485
2463
|
compiler.hooks.compilation.tap(this.name, (compilation)=>{
|
|
3486
|
-
getHTMLPlugin().
|
|
2464
|
+
getHTMLPlugin().getCompilationHooks(compilation).alterAssetTagGroups.tapPromise(this.name, async (data)=>{
|
|
3487
2465
|
var _data_plugin_options, _data_plugin_options1;
|
|
3488
2466
|
let entryName = null === (_data_plugin_options = data.plugin.options) || void 0 === _data_plugin_options ? void 0 : _data_plugin_options.entryName;
|
|
3489
2467
|
if (!entryName) return data;
|
|
@@ -3523,7 +2501,7 @@ var __webpack_exports__ = {};
|
|
|
3523
2501
|
templatePath: void 0,
|
|
3524
2502
|
templateContent: getDefaultTemplateContent(config.html.mountId)
|
|
3525
2503
|
};
|
|
3526
|
-
let absolutePath = (0,
|
|
2504
|
+
let absolutePath = (0, external_node_path_namespaceObject.isAbsolute)(templatePath) ? templatePath : external_node_path_default().resolve(rootPath, templatePath);
|
|
3527
2505
|
if (!existTemplatePath.has(absolutePath)) {
|
|
3528
2506
|
if (!await isFileExists(absolutePath)) throw Error(`[rsbuild:html] Failed to resolve HTML template, please check if the file exists: ${index_js_default().cyan(absolutePath)}`);
|
|
3529
2507
|
existTemplatePath.add(absolutePath);
|
|
@@ -3783,7 +2761,7 @@ var __webpack_exports__ = {};
|
|
|
3783
2761
|
})(chunkGroup)).filter((name)=>!!name))
|
|
3784
2762
|
];
|
|
3785
2763
|
}
|
|
3786
|
-
let generateManifest = (htmlPaths)=>(_seed, files)=>{
|
|
2764
|
+
let generateManifest = (htmlPaths, manifestOptions)=>(_seed, files)=>{
|
|
3787
2765
|
let chunkEntries = new Map(), licenseMap = new Map(), allFiles = files.map((file)=>{
|
|
3788
2766
|
if (file.chunk) for (let name of recursiveChunkEntryNames(file.chunk))chunkEntries.set(name, [
|
|
3789
2767
|
file,
|
|
@@ -3820,22 +2798,42 @@ var __webpack_exports__ = {};
|
|
|
3820
2798
|
css: asyncCSS
|
|
3821
2799
|
}), entries[name] = entryManifest;
|
|
3822
2800
|
}
|
|
3823
|
-
|
|
2801
|
+
let manifestData = {
|
|
3824
2802
|
allFiles,
|
|
3825
2803
|
entries
|
|
3826
2804
|
};
|
|
2805
|
+
if (manifestOptions.generate) {
|
|
2806
|
+
let generatedManifest = manifestOptions.generate({
|
|
2807
|
+
files,
|
|
2808
|
+
manifestData
|
|
2809
|
+
});
|
|
2810
|
+
if (isObject(generatedManifest)) return generatedManifest;
|
|
2811
|
+
throw Error('[rsbuild:manifest] `manifest.generate` function must return a valid manifest object.');
|
|
2812
|
+
}
|
|
2813
|
+
return manifestData;
|
|
3827
2814
|
}, pluginManifest = ()=>({
|
|
3828
2815
|
name: 'rsbuild:manifest',
|
|
3829
2816
|
setup (api) {
|
|
3830
2817
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
|
|
3831
2818
|
let { output: { manifest }, dev: { writeToDisk } } = environment.config;
|
|
3832
2819
|
if (!1 === manifest) return;
|
|
3833
|
-
let
|
|
2820
|
+
let manifestOptions = function(manifest) {
|
|
2821
|
+
if ('string' == typeof manifest) return {
|
|
2822
|
+
filename: manifest
|
|
2823
|
+
};
|
|
2824
|
+
let defaultOptions = {
|
|
2825
|
+
filename: 'manifest.json'
|
|
2826
|
+
};
|
|
2827
|
+
return 'boolean' == typeof manifest ? defaultOptions : {
|
|
2828
|
+
...defaultOptions,
|
|
2829
|
+
...manifest
|
|
2830
|
+
};
|
|
2831
|
+
}(manifest), { RspackManifestPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/rspack-manifest-plugin/index.js")), { htmlPaths } = environment;
|
|
3834
2832
|
chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
|
|
3835
2833
|
{
|
|
3836
|
-
fileName:
|
|
2834
|
+
fileName: manifestOptions.filename,
|
|
3837
2835
|
writeToFileEmit: isDev && !0 !== writeToDisk,
|
|
3838
|
-
generate: generateManifest(htmlPaths)
|
|
2836
|
+
generate: generateManifest(htmlPaths, manifestOptions)
|
|
3839
2837
|
}
|
|
3840
2838
|
]);
|
|
3841
2839
|
});
|
|
@@ -4011,9 +3009,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4011
3009
|
}
|
|
4012
3010
|
});
|
|
4013
3011
|
}
|
|
4014
|
-
});
|
|
4015
|
-
var external_node_child_process_ = __webpack_require__("node:child_process");
|
|
4016
|
-
let external_node_net_namespaceObject = require("node:net");
|
|
3012
|
+
}), external_node_child_process_namespaceObject = require("node:child_process"), external_node_net_namespaceObject = require("node:net");
|
|
4017
3013
|
var external_node_net_default = __webpack_require__.n(external_node_net_namespaceObject);
|
|
4018
3014
|
let external_node_os_namespaceObject = require("node:os");
|
|
4019
3015
|
var external_node_os_default = __webpack_require__.n(external_node_os_namespaceObject);
|
|
@@ -4027,7 +3023,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4027
3023
|
let trailingSlashBase = addTrailingSlash(base);
|
|
4028
3024
|
return path.startsWith(trailingSlashBase) ? path.slice(trailingSlashBase.length - 1) : path;
|
|
4029
3025
|
}, getRoutes = (context)=>Object.values(context.environments).reduce((prev, environmentContext)=>{
|
|
4030
|
-
let { distPath, config } = environmentContext, distPrefix = (0,
|
|
3026
|
+
let { distPath, config } = environmentContext, distPrefix = (0, external_node_path_namespaceObject.relative)(context.distPath, distPath).split(external_node_path_namespaceObject.sep).join('/'), routes = formatRoutes(environmentContext.htmlPaths, context.normalizedConfig.server.base, external_node_path_namespaceObject.posix.join(distPrefix, config.output.distPath.html), config.html.outputStructure);
|
|
4031
3027
|
return prev.concat(...routes);
|
|
4032
3028
|
}, []), formatRoutes = (entry, base, distPathPrefix, outputStructure)=>{
|
|
4033
3029
|
let prefix = joinUrlSegments(base, formatPrefix(distPathPrefix));
|
|
@@ -4167,7 +3163,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4167
3163
|
listened ? server.close((err)=>err ? reject(err) : resolve()) : resolve();
|
|
4168
3164
|
});
|
|
4169
3165
|
}
|
|
4170
|
-
let execAsync = (0, external_node_util_namespaceObject.promisify)(
|
|
3166
|
+
let execAsync = (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.exec), supportedChromiumBrowsers = [
|
|
4171
3167
|
'Google Chrome Canary',
|
|
4172
3168
|
'Google Chrome Dev',
|
|
4173
3169
|
'Google Chrome Beta',
|
|
@@ -4253,11 +3249,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4253
3249
|
}), jsPath = config.output.distPath.js, jsAsyncPath = getJsAsyncPath(jsPath, isServer, config.output.distPath.jsAsync), jsFilename = getFilename(config, 'js', isProd, isServer), isJsFilenameFn = 'function' == typeof jsFilename;
|
|
4254
3250
|
if (chain.output.path(distPath).filename(isJsFilenameFn ? (...args)=>{
|
|
4255
3251
|
let name = jsFilename(...args);
|
|
4256
|
-
return
|
|
4257
|
-
} :
|
|
3252
|
+
return external_node_path_namespaceObject.posix.join(jsPath, name);
|
|
3253
|
+
} : external_node_path_namespaceObject.posix.join(jsPath, jsFilename)).chunkFilename(isJsFilenameFn ? (...args)=>{
|
|
4258
3254
|
let name = jsFilename(...args);
|
|
4259
|
-
return
|
|
4260
|
-
} :
|
|
3255
|
+
return external_node_path_namespaceObject.posix.join(jsAsyncPath, name);
|
|
3256
|
+
} : external_node_path_namespaceObject.posix.join(jsAsyncPath, jsFilename)).publicPath(publicPath).pathinfo(!1).hashFunction('xxhash64'), isServer && chain.output.library({
|
|
4261
3257
|
type: 'commonjs2',
|
|
4262
3258
|
...chain.output.get('library') || {}
|
|
4263
3259
|
}), config.output.copy && 'rspack' === api.context.bundlerType) {
|
|
@@ -4275,12 +3271,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4275
3271
|
{
|
|
4276
3272
|
filename: isCssFilenameFn ? (...args)=>{
|
|
4277
3273
|
let name = cssFilename(...args);
|
|
4278
|
-
return
|
|
4279
|
-
} :
|
|
3274
|
+
return external_node_path_namespaceObject.posix.join(cssPath, name);
|
|
3275
|
+
} : external_node_path_namespaceObject.posix.join(cssPath, cssFilename),
|
|
4280
3276
|
chunkFilename: isCssFilenameFn ? (...args)=>{
|
|
4281
3277
|
let name = cssFilename(...args);
|
|
4282
|
-
return
|
|
4283
|
-
} :
|
|
3278
|
+
return external_node_path_namespaceObject.posix.join(cssAsyncPath, name);
|
|
3279
|
+
} : external_node_path_namespaceObject.posix.join(cssAsyncPath, cssFilename),
|
|
4284
3280
|
...extractPluginOptions
|
|
4285
3281
|
}
|
|
4286
3282
|
]);
|
|
@@ -4361,7 +3357,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4361
3357
|
continue;
|
|
4362
3358
|
}
|
|
4363
3359
|
try {
|
|
4364
|
-
pkgPath = (0,
|
|
3360
|
+
pkgPath = (0, external_node_path_namespaceObject.dirname)(resolve_require.resolve(`${pkgName}/package.json`, {
|
|
4365
3361
|
paths: [
|
|
4366
3362
|
rootPath
|
|
4367
3363
|
]
|
|
@@ -4376,8 +3372,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4376
3372
|
let trailing = [
|
|
4377
3373
|
'node_modules',
|
|
4378
3374
|
...pkgName.split('/')
|
|
4379
|
-
].join(
|
|
4380
|
-
for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (0,
|
|
3375
|
+
].join(external_node_path_namespaceObject.sep);
|
|
3376
|
+
for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (0, external_node_path_namespaceObject.dirname)(pkgPath);
|
|
4381
3377
|
} catch (e) {
|
|
4382
3378
|
rslog_index_js_namespaceObject.logger.debug(`[rsbuild:resolve] The package "${pkgName}" is not resolved in the project, dedupe option for "${pkgName}" will be ignored.`);
|
|
4383
3379
|
continue;
|
|
@@ -4639,16 +3635,18 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4639
3635
|
});
|
|
4640
3636
|
}
|
|
4641
3637
|
};
|
|
4642
|
-
api.onAfterStartDevServer(onStartServer), api.onAfterStartProdServer(onStartServer), api.onBeforeBuild(async ({ isFirstCompile })=>{
|
|
3638
|
+
api.onAfterStartDevServer(onStartServer), api.onAfterStartProdServer(onStartServer), api.onBeforeBuild(async ({ isFirstCompile, environments })=>{
|
|
4643
3639
|
if (!!isFirstCompile) for (let publicDir of normalizePublicDirs(api.getNormalizedConfig().server.publicDir)){
|
|
4644
3640
|
let { name, copyOnBuild } = publicDir;
|
|
4645
|
-
if (!copyOnBuild || !name) continue;
|
|
4646
|
-
let normalizedPath = (0,
|
|
4647
|
-
if (
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
3641
|
+
if (!1 === copyOnBuild || !name) continue;
|
|
3642
|
+
let normalizedPath = (0, external_node_path_namespaceObject.isAbsolute)(name) ? name : (0, external_node_path_namespaceObject.join)(api.context.rootPath, name);
|
|
3643
|
+
if (!external_node_fs_default().existsSync(normalizedPath)) continue;
|
|
3644
|
+
let distPaths = dedupeNestedPaths(Object.values(environments).filter(({ config })=>!0 === copyOnBuild || 'auto' === copyOnBuild && 'node' !== config.output.target).map(({ distPath })=>distPath));
|
|
3645
|
+
try {
|
|
3646
|
+
await Promise.all(distPaths.map((distPath)=>external_node_fs_default().promises.cp(normalizedPath, distPath, {
|
|
3647
|
+
recursive: !0,
|
|
3648
|
+
dereference: !0
|
|
3649
|
+
})));
|
|
4652
3650
|
} catch (err) {
|
|
4653
3651
|
throw err instanceof Error && (err.message = `Copy public dir (${normalizedPath}) to dist failed:\n${err.message}`), err;
|
|
4654
3652
|
}
|
|
@@ -5003,7 +4001,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5003
4001
|
...chain.get('experiments'),
|
|
5004
4002
|
asyncWebAssembly: !0
|
|
5005
4003
|
});
|
|
5006
|
-
let wasmFilename =
|
|
4004
|
+
let wasmFilename = external_node_path_namespaceObject.posix.join(distPath, '[hash].module.wasm');
|
|
5007
4005
|
chain.output.merge({
|
|
5008
4006
|
webassemblyModuleFilename: wasmFilename
|
|
5009
4007
|
}), chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).merge({
|
|
@@ -5014,8 +4012,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5014
4012
|
});
|
|
5015
4013
|
}
|
|
5016
4014
|
}), getInspectOutputPath = (context, inspectOptions)=>{
|
|
5017
|
-
if (inspectOptions.outputPath) return (0,
|
|
5018
|
-
return (0,
|
|
4015
|
+
if (inspectOptions.outputPath) return (0, external_node_path_namespaceObject.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, external_node_path_namespaceObject.join)(context.distPath, inspectOptions.outputPath);
|
|
4016
|
+
return (0, external_node_path_namespaceObject.join)(context.distPath, RSBUILD_OUTPUTS_PATH);
|
|
5019
4017
|
};
|
|
5020
4018
|
async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions = {} }) {
|
|
5021
4019
|
inspectOptions.mode ? setNodeEnv(inspectOptions.mode) : !getNodeEnv() && setNodeEnv('development');
|
|
@@ -5263,7 +4261,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5263
4261
|
'jsx',
|
|
5264
4262
|
'mjs',
|
|
5265
4263
|
'cjs'
|
|
5266
|
-
].map((ext)=>(0,
|
|
4264
|
+
].map((ext)=>(0, external_node_path_namespaceObject.join)(root, `src/index.${ext}`)));
|
|
5267
4265
|
return entryFile ? {
|
|
5268
4266
|
index: entryFile
|
|
5269
4267
|
} : {};
|
|
@@ -5334,13 +4332,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5334
4332
|
...new Set(paths)
|
|
5335
4333
|
];
|
|
5336
4334
|
if (1 === uniquePaths.length) return uniquePaths[0];
|
|
5337
|
-
let [first, ...rest] = uniquePaths.map((p)=>p.split(
|
|
4335
|
+
let [first, ...rest] = uniquePaths.map((p)=>p.split(external_node_path_namespaceObject.sep)), common = [];
|
|
5338
4336
|
for(let i = 0; i < first.length; i++){
|
|
5339
4337
|
let segment = first[i];
|
|
5340
4338
|
if (rest.every((p)=>p[i] === segment)) common.push(segment);
|
|
5341
4339
|
else break;
|
|
5342
4340
|
}
|
|
5343
|
-
return common.join(
|
|
4341
|
+
return common.join(external_node_path_namespaceObject.sep);
|
|
5344
4342
|
}(distPaths);
|
|
5345
4343
|
}(context), context.normalizedConfig;
|
|
5346
4344
|
}
|
|
@@ -5354,8 +4352,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5354
4352
|
environment
|
|
5355
4353
|
})));
|
|
5356
4354
|
if (isDebug()) {
|
|
5357
|
-
let inspect = ()=>{
|
|
5358
|
-
inspectConfig({
|
|
4355
|
+
let inspect = async ()=>{
|
|
4356
|
+
await inspectConfig({
|
|
5359
4357
|
context,
|
|
5360
4358
|
pluginManager,
|
|
5361
4359
|
inspectOptions: {
|
|
@@ -5366,8 +4364,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5366
4364
|
bundlerConfigs: rspackConfigs
|
|
5367
4365
|
});
|
|
5368
4366
|
};
|
|
5369
|
-
context.hooks.onBeforeBuild.tap(({ isFirstCompile })=>{
|
|
5370
|
-
isFirstCompile && inspect();
|
|
4367
|
+
context.hooks.onBeforeBuild.tap(async ({ isFirstCompile })=>{
|
|
4368
|
+
isFirstCompile && await inspect();
|
|
5371
4369
|
}), context.hooks.onAfterStartDevServer.tap(inspect);
|
|
5372
4370
|
}
|
|
5373
4371
|
return {
|
|
@@ -5467,7 +4465,43 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5467
4465
|
}), setupServerHooks(compiler, callbacks);
|
|
5468
4466
|
}), rsbuildDevMiddleware(multiCompiler, restOptions);
|
|
5469
4467
|
};
|
|
5470
|
-
}, external_node_querystring_namespaceObject = require("node:querystring")
|
|
4468
|
+
}, external_node_querystring_namespaceObject = require("node:querystring"), styles = {
|
|
4469
|
+
1: 'font-weight:bold',
|
|
4470
|
+
2: 'opacity:0.5',
|
|
4471
|
+
3: 'font-style:italic',
|
|
4472
|
+
4: 'text-decoration:underline;text-underline-offset:3px',
|
|
4473
|
+
8: 'display:none',
|
|
4474
|
+
9: 'text-decoration:line-through',
|
|
4475
|
+
30: 'color:#000',
|
|
4476
|
+
31: 'color:#fb6a6a',
|
|
4477
|
+
32: 'color:#6ef790',
|
|
4478
|
+
33: 'color:#eff986',
|
|
4479
|
+
34: 'color:#6eb2f7',
|
|
4480
|
+
35: 'color:#f76ebe',
|
|
4481
|
+
36: 'color:#6eecf7',
|
|
4482
|
+
37: 'color:#f0f0f0',
|
|
4483
|
+
90: 'color:#888'
|
|
4484
|
+
};
|
|
4485
|
+
for(let i = 91; i <= 97; i++)styles[i] = styles[i - 60];
|
|
4486
|
+
let closeCode = [
|
|
4487
|
+
0,
|
|
4488
|
+
21,
|
|
4489
|
+
22,
|
|
4490
|
+
23,
|
|
4491
|
+
24,
|
|
4492
|
+
27,
|
|
4493
|
+
28,
|
|
4494
|
+
29,
|
|
4495
|
+
39,
|
|
4496
|
+
49
|
|
4497
|
+
], server_ansiHTML = function(text) {
|
|
4498
|
+
let ansiCodes = [], ret = text.replace(/\x1B\[([0-9;]+)m/g, (_match, sequences)=>{
|
|
4499
|
+
let style = '';
|
|
4500
|
+
for (let seq of sequences.split(';'))styles[seq] && (style += `${styles[seq]};`);
|
|
4501
|
+
return style ? (ansiCodes.push(sequences), `<span style="${style}">`) : closeCode.includes(Number(sequences)) && ansiCodes.length > 0 ? (ansiCodes.pop(), '</span>') : '';
|
|
4502
|
+
});
|
|
4503
|
+
return ansiCodes.length > 0 && (ret += Array(ansiCodes.length + 1).join('</span>')), ret;
|
|
4504
|
+
};
|
|
5471
4505
|
function socketServer_define_property(obj, key, value) {
|
|
5472
4506
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
5473
4507
|
value: value,
|
|
@@ -5555,6 +4589,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5555
4589
|
});
|
|
5556
4590
|
}
|
|
5557
4591
|
sendStats({ force = !1, compilationId }) {
|
|
4592
|
+
var a, b;
|
|
5558
4593
|
let stats = this.getStats(compilationId);
|
|
5559
4594
|
if (!stats) return null;
|
|
5560
4595
|
let newInitialChunks = new Set();
|
|
@@ -5564,30 +4599,178 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5564
4599
|
if (!!chunkName) newInitialChunks.add(String(chunkName));
|
|
5565
4600
|
}
|
|
5566
4601
|
}
|
|
5567
|
-
let initialChunks = this.initialChunks[compilationId]
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
type: 'content-changed',
|
|
4602
|
+
let initialChunks = this.initialChunks[compilationId];
|
|
4603
|
+
let shouldReload = !!stats.entrypoints && !!initialChunks && (a = initialChunks, b = newInitialChunks, !(a.size === b.size && [
|
|
4604
|
+
...a
|
|
4605
|
+
].every((value)=>b.has(value))));
|
|
4606
|
+
if (this.initialChunks[compilationId] = newInitialChunks, shouldReload) return this.sockWrite({
|
|
4607
|
+
type: 'static-changed',
|
|
5574
4608
|
compilationId
|
|
5575
|
-
})
|
|
4609
|
+
});
|
|
4610
|
+
if (!force && stats && !stats.errorsCount && stats.assets && stats.assets.every((asset)=>!asset.emitted)) return this.sockWrite({
|
|
5576
4611
|
type: 'still-ok',
|
|
5577
4612
|
compilationId
|
|
5578
|
-
})
|
|
4613
|
+
});
|
|
4614
|
+
if (this.sockWrite({
|
|
5579
4615
|
type: 'hash',
|
|
5580
4616
|
compilationId,
|
|
5581
4617
|
data: stats.hash
|
|
5582
|
-
}), stats.errorsCount)
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
4618
|
+
}), stats.errorsCount) {
|
|
4619
|
+
let { errors: formattedErrors } = formatStatsMessages({
|
|
4620
|
+
errors: getAllStatsErrors(stats),
|
|
4621
|
+
warnings: []
|
|
4622
|
+
});
|
|
4623
|
+
return this.sockWrite({
|
|
4624
|
+
type: 'errors',
|
|
4625
|
+
compilationId,
|
|
4626
|
+
data: {
|
|
4627
|
+
text: formattedErrors,
|
|
4628
|
+
html: function(errors) {
|
|
4629
|
+
let htmlItems = errors.map((item)=>{
|
|
4630
|
+
var text;
|
|
4631
|
+
return server_ansiHTML((text = item) ? text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') : '').replace(/(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g, (file)=>{
|
|
4632
|
+
let hasClosingSpan = file.includes('</span>') && !file.includes('<span'), filePath = hasClosingSpan ? file.replace('</span>', '') : file;
|
|
4633
|
+
return `<a class="file-link" data-file="${filePath}">${filePath}</a>${hasClosingSpan ? '</span>' : ''}`;
|
|
4634
|
+
});
|
|
4635
|
+
});
|
|
4636
|
+
return `
|
|
4637
|
+
<style>
|
|
4638
|
+
.root {
|
|
4639
|
+
position: fixed;
|
|
4640
|
+
z-index: 9999;
|
|
4641
|
+
top: 0;
|
|
4642
|
+
left: 0;
|
|
4643
|
+
width: 100%;
|
|
4644
|
+
height: 100%;
|
|
4645
|
+
overflow-y: scroll;
|
|
4646
|
+
margin: 0;
|
|
4647
|
+
background: rgba(0, 0, 0, 0.66);
|
|
4648
|
+
cursor: pointer;
|
|
4649
|
+
}
|
|
4650
|
+
.container {
|
|
4651
|
+
font-family: Menlo, Consolas, monospace;
|
|
4652
|
+
line-height: 1.6;
|
|
4653
|
+
width: 960px;
|
|
4654
|
+
max-width: 85%;
|
|
4655
|
+
color: #d8d8d8;
|
|
4656
|
+
margin: 32px auto;
|
|
4657
|
+
padding: 32px 40px;
|
|
4658
|
+
position: relative;
|
|
4659
|
+
background: #181818;
|
|
4660
|
+
border-radius: 24px;
|
|
4661
|
+
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
|
|
4662
|
+
overflow: hidden;
|
|
4663
|
+
direction: ltr;
|
|
4664
|
+
text-align: left;
|
|
4665
|
+
box-sizing: border-box;
|
|
4666
|
+
cursor: default;
|
|
4667
|
+
}
|
|
4668
|
+
.title {
|
|
4669
|
+
margin: 0 0 20px;
|
|
4670
|
+
padding-bottom: 12px;
|
|
4671
|
+
font-size: 17px;
|
|
4672
|
+
font-weight: 600;
|
|
4673
|
+
color: #fb6a6a;
|
|
4674
|
+
border-bottom: 2px solid rgba(252,94,94,.66);
|
|
4675
|
+
}
|
|
4676
|
+
.content {
|
|
4677
|
+
margin: 0;
|
|
4678
|
+
font-size: 14px;
|
|
4679
|
+
font-family: inherit;
|
|
4680
|
+
overflow-x: scroll;
|
|
4681
|
+
scrollbar-width: none;
|
|
4682
|
+
}
|
|
4683
|
+
.content::-webkit-scrollbar {
|
|
4684
|
+
display: none;
|
|
4685
|
+
}
|
|
4686
|
+
.file-link {
|
|
4687
|
+
cursor: pointer;
|
|
4688
|
+
color: #6eecf7;
|
|
4689
|
+
text-decoration: underline;
|
|
4690
|
+
text-underline-offset: 3px;
|
|
4691
|
+
&:hover {
|
|
4692
|
+
opacity: 0.8;
|
|
4693
|
+
}
|
|
4694
|
+
&:active {
|
|
4695
|
+
opacity: 0.6;
|
|
4696
|
+
}
|
|
4697
|
+
}
|
|
4698
|
+
.close {
|
|
4699
|
+
position: absolute;
|
|
4700
|
+
top: 27px;
|
|
4701
|
+
right: 32px;
|
|
4702
|
+
width: 32px;
|
|
4703
|
+
height: 32px;
|
|
4704
|
+
cursor: pointer;
|
|
4705
|
+
}
|
|
4706
|
+
.close:hover {
|
|
4707
|
+
opacity: 0.8;
|
|
4708
|
+
}
|
|
4709
|
+
.close:active {
|
|
4710
|
+
opacity: 0.6;
|
|
4711
|
+
}
|
|
4712
|
+
.close:before,
|
|
4713
|
+
.close:after {
|
|
4714
|
+
position: absolute;
|
|
4715
|
+
left: 16px;
|
|
4716
|
+
top: 8px;
|
|
4717
|
+
content: ' ';
|
|
4718
|
+
height: 18px;
|
|
4719
|
+
width: 2px;
|
|
4720
|
+
border-radius: 4px;
|
|
4721
|
+
background-color: #b8b8b8;
|
|
4722
|
+
}
|
|
4723
|
+
.close:before {
|
|
4724
|
+
transform: rotate(45deg);
|
|
4725
|
+
}
|
|
4726
|
+
.close:after {
|
|
4727
|
+
transform: rotate(-45deg);
|
|
4728
|
+
}
|
|
4729
|
+
.footer {
|
|
4730
|
+
font-size: 12px;
|
|
4731
|
+
color: #7e6a92;
|
|
4732
|
+
margin-top: 20px;
|
|
4733
|
+
padding-top: 12px;
|
|
4734
|
+
border-top: 2px solid rgba(126,106,146,.6);
|
|
4735
|
+
}
|
|
4736
|
+
.footer p {
|
|
4737
|
+
margin: 4px 0 0;
|
|
4738
|
+
}
|
|
4739
|
+
.footer span {
|
|
4740
|
+
color: #a88dc3;
|
|
4741
|
+
}
|
|
4742
|
+
</style>
|
|
4743
|
+
|
|
4744
|
+
<div class="root">
|
|
4745
|
+
<div class="container">
|
|
4746
|
+
<div class="close"></div>
|
|
4747
|
+
<p class="title">Build failed</p>
|
|
4748
|
+
<pre class="content">${htmlItems.join('\n\n').trim()}</pre>
|
|
4749
|
+
<footer class="footer">
|
|
4750
|
+
<p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>
|
|
4751
|
+
<p>Disable overlay by setting Rsbuild's <span>dev.client.overlay</span> config to false.<p>
|
|
4752
|
+
</footer>
|
|
4753
|
+
</div>
|
|
4754
|
+
</div>
|
|
4755
|
+
`;
|
|
4756
|
+
}(formattedErrors)
|
|
4757
|
+
}
|
|
4758
|
+
});
|
|
4759
|
+
}
|
|
4760
|
+
if (stats.warningsCount) {
|
|
4761
|
+
let { warnings: formattedWarnings } = formatStatsMessages({
|
|
4762
|
+
warnings: getAllStatsWarnings(stats),
|
|
4763
|
+
errors: []
|
|
4764
|
+
});
|
|
4765
|
+
return this.sockWrite({
|
|
4766
|
+
type: 'warnings',
|
|
4767
|
+
compilationId,
|
|
4768
|
+
data: {
|
|
4769
|
+
text: formattedWarnings
|
|
4770
|
+
}
|
|
4771
|
+
});
|
|
4772
|
+
}
|
|
4773
|
+
return this.sockWrite({
|
|
5591
4774
|
type: 'ok',
|
|
5592
4775
|
compilationId
|
|
5593
4776
|
});
|
|
@@ -5607,13 +4790,19 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5607
4790
|
writable: !0
|
|
5608
4791
|
}) : obj[key] = value, obj;
|
|
5609
4792
|
}
|
|
5610
|
-
let compilerDevMiddleware_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), formatDevConfig = (config, environments)=>
|
|
4793
|
+
let compilerDevMiddleware_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), formatDevConfig = (config, environments)=>{
|
|
4794
|
+
let writeToDiskValues = Object.values(environments).map((env)=>env.config.dev.writeToDisk);
|
|
4795
|
+
return 1 === new Set(writeToDiskValues).size ? {
|
|
4796
|
+
...config,
|
|
4797
|
+
writeToDisk: writeToDiskValues[0]
|
|
4798
|
+
} : {
|
|
5611
4799
|
...config,
|
|
5612
4800
|
writeToDisk (filePath, compilationName) {
|
|
5613
4801
|
let { writeToDisk } = config;
|
|
5614
4802
|
return compilationName && environments[compilationName] && (writeToDisk = environments[compilationName].config.dev.writeToDisk ?? writeToDisk), 'function' == typeof writeToDisk ? writeToDisk(filePath) : writeToDisk;
|
|
5615
4803
|
}
|
|
5616
4804
|
};
|
|
4805
|
+
};
|
|
5617
4806
|
class CompilerDevMiddleware {
|
|
5618
4807
|
async init() {
|
|
5619
4808
|
let devMiddleware = await getDevMiddleware(this.compiler);
|
|
@@ -5648,7 +4837,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5648
4837
|
onInvalid: (compilationId, fileName)=>{
|
|
5649
4838
|
if ('string' == typeof fileName && HTML_REGEX.test(fileName)) {
|
|
5650
4839
|
this.socketServer.sockWrite({
|
|
5651
|
-
type: '
|
|
4840
|
+
type: 'static-changed',
|
|
5652
4841
|
compilationId
|
|
5653
4842
|
});
|
|
5654
4843
|
return;
|
|
@@ -5891,7 +5080,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5891
5080
|
}(this, "name", void 0), this.name = name;
|
|
5892
5081
|
}
|
|
5893
5082
|
}
|
|
5894
|
-
let
|
|
5083
|
+
let runner_run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>new BasicRunnerFactory(bundlePath).create(compilerOptions, outputPath, readFileSync).run(bundlePath), loadBundle = async (stats, entryName, utils)=>{
|
|
5895
5084
|
let { chunks, entrypoints, outputPath } = stats.toJson({
|
|
5896
5085
|
all: !1,
|
|
5897
5086
|
chunks: !0,
|
|
@@ -5908,11 +5097,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5908
5097
|
}, []);
|
|
5909
5098
|
if (0 === files.length) throw Error(`[rsbuild:loadBundle] Failed to get bundle by entryName: "${entryName}"`);
|
|
5910
5099
|
if (files.length > 1) throw Error(`[rsbuild:loadBundle] Only support load single entry chunk, but got ${files.length}: ${files.join(',')}`);
|
|
5911
|
-
return await
|
|
5100
|
+
return await runner_run(files[0], outputPath, stats.compilation.options, utils.readFileSync);
|
|
5912
5101
|
}, getTransformedHtml = async (entryName, utils)=>{
|
|
5913
5102
|
let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
|
|
5914
5103
|
if (!htmlPath) throw Error(`[rsbuild:getTransformedHtml] Failed to get HTML file by entryName: "${entryName}"`);
|
|
5915
|
-
let fileName = (0,
|
|
5104
|
+
let fileName = (0, external_node_path_namespaceObject.join)(distPath, htmlPath);
|
|
5916
5105
|
return utils.readFileSync(fileName);
|
|
5917
5106
|
}, createCacheableFunction = (getter)=>{
|
|
5918
5107
|
let cache = new WeakMap();
|
|
@@ -6126,8 +5315,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6126
5315
|
}, applyDefaultMiddlewares = async ({ middlewares, server, compileMiddlewareAPI, output, pwd, outputFileSystem, environments })=>{
|
|
6127
5316
|
let upgradeEvents = [];
|
|
6128
5317
|
if (server.compress && middlewares.push(gzipMiddleware()), middlewares.push((req, res, next)=>{
|
|
5318
|
+
var _parseUrl;
|
|
6129
5319
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
6130
|
-
let path = req.url ?
|
|
5320
|
+
let path = req.url ? null === (_parseUrl = parseUrl(req.url)) || void 0 === _parseUrl ? void 0 : _parseUrl.pathname : '';
|
|
6131
5321
|
(null == path ? void 0 : path.includes('hot-update')) && res.setHeader('Access-Control-Allow-Credentials', 'false');
|
|
6132
5322
|
let confHeaders = server.headers;
|
|
6133
5323
|
if (confHeaders) for (let [key, value] of Object.entries(confHeaders))res.setHeader(key, value);
|
|
@@ -6153,13 +5343,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6153
5343
|
var _req_url;
|
|
6154
5344
|
(null === (_req_url = req.url) || void 0 === _req_url ? void 0 : _req_url.endsWith('.hot-update.json')) && 'OPTIONS' !== req.method ? (res.statusCode = 404, res.end()) : next();
|
|
6155
5345
|
}));
|
|
6156
|
-
let distPath = (0,
|
|
5346
|
+
let distPath = (0, external_node_path_namespaceObject.isAbsolute)(output.distPath) ? output.distPath : (0, external_node_path_namespaceObject.join)(pwd, output.distPath);
|
|
6157
5347
|
for (let publicDir of (compileMiddlewareAPI && middlewares.push(getHtmlCompletionMiddleware({
|
|
6158
5348
|
distPath,
|
|
6159
5349
|
callback: compileMiddlewareAPI.middleware,
|
|
6160
5350
|
outputFileSystem
|
|
6161
5351
|
})), normalizePublicDirs(null == server ? void 0 : server.publicDir))){
|
|
6162
|
-
let { default: sirv } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/sirv/index.js")), { name } = publicDir, assetMiddleware = sirv((0,
|
|
5352
|
+
let { default: sirv } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/sirv/index.js")), { name } = publicDir, assetMiddleware = sirv((0, external_node_path_namespaceObject.isAbsolute)(name) ? name : (0, external_node_path_namespaceObject.join)(pwd, name), {
|
|
6163
5353
|
etag: !0,
|
|
6164
5354
|
dev: !0
|
|
6165
5355
|
});
|
|
@@ -6888,7 +6078,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6888
6078
|
if (descriptor.targets && !descriptor.targets.includes(target) || descriptor.environments && !descriptor.environments.includes(environment.name)) return;
|
|
6889
6079
|
let rule = chain.module.rule(id);
|
|
6890
6080
|
descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer);
|
|
6891
|
-
let loaderName = descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs', loaderPath = (0,
|
|
6081
|
+
let loaderName = descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs', loaderPath = (0, external_node_path_namespaceObject.join)(LOADER_PATH, loaderName);
|
|
6892
6082
|
rule.use(id).loader(loaderPath).options({
|
|
6893
6083
|
id,
|
|
6894
6084
|
getEnvironment: ()=>environment
|
|
@@ -6986,7 +6176,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6986
6176
|
pluginManager
|
|
6987
6177
|
}), { distPath } = context, { checkDistDir = !0 } = options;
|
|
6988
6178
|
if (checkDistDir) {
|
|
6989
|
-
if (!(0,
|
|
6179
|
+
if (!(0, external_node_fs_namespaceObject.existsSync)(distPath)) throw Error(`[rsbuild:preview] The output directory ${index_js_default().yellow(distPath)} does not exist, please build the project before previewing.`);
|
|
6990
6180
|
if (function(path) {
|
|
6991
6181
|
let files = external_node_fs_default().readdirSync(path);
|
|
6992
6182
|
return 0 === files.length || 1 === files.length && '.git' === files[0];
|
|
@@ -7006,6 +6196,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7006
6196
|
build,
|
|
7007
6197
|
preview,
|
|
7008
6198
|
startDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.startDevServer(...args)),
|
|
6199
|
+
createCompiler: (...args)=>(!context.command && (context.command = 'development' === getNodeEnv() ? 'dev' : 'build'), providerInstance.createCompiler(...args)),
|
|
7009
6200
|
createDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.createDevServer(...args)),
|
|
7010
6201
|
...pick(pluginManager, [
|
|
7011
6202
|
'addPlugins',
|
|
@@ -7032,8 +6223,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7032
6223
|
]),
|
|
7033
6224
|
...pick(providerInstance, [
|
|
7034
6225
|
'initConfigs',
|
|
7035
|
-
'inspectConfig'
|
|
7036
|
-
'createCompiler'
|
|
6226
|
+
'inspectConfig'
|
|
7037
6227
|
])
|
|
7038
6228
|
}, getFlattenedPlugins = async (pluginOptions)=>{
|
|
7039
6229
|
let plugins = pluginOptions;
|
|
@@ -7055,10 +6245,319 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7055
6245
|
}
|
|
7056
6246
|
})), rsbuild;
|
|
7057
6247
|
}
|
|
7058
|
-
let
|
|
7059
|
-
|
|
6248
|
+
let external_events_namespaceObject = require("events");
|
|
6249
|
+
function toArr(any) {
|
|
6250
|
+
return null == any ? [] : Array.isArray(any) ? any : [
|
|
6251
|
+
any
|
|
6252
|
+
];
|
|
6253
|
+
}
|
|
6254
|
+
let removeBrackets = (v)=>v.replace(/[<[].+/, "").trim(), findAllBrackets = (v)=>{
|
|
6255
|
+
let angledMatch, squareMatch;
|
|
6256
|
+
let ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g, SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g, res = [], parse = (match)=>{
|
|
6257
|
+
let variadic = !1, value = match[1];
|
|
6258
|
+
return value.startsWith("...") && (value = value.slice(3), variadic = !0), {
|
|
6259
|
+
required: match[0].startsWith("<"),
|
|
6260
|
+
value,
|
|
6261
|
+
variadic
|
|
6262
|
+
};
|
|
6263
|
+
};
|
|
6264
|
+
for(; angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v);)res.push(parse(angledMatch));
|
|
6265
|
+
for(; squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v);)res.push(parse(squareMatch));
|
|
6266
|
+
return res;
|
|
6267
|
+
}, getMriOptions = (options)=>{
|
|
6268
|
+
let result = {
|
|
6269
|
+
alias: {},
|
|
6270
|
+
boolean: []
|
|
6271
|
+
};
|
|
6272
|
+
for (let [index, option] of options.entries())option.names.length > 1 && (result.alias[option.names[0]] = option.names.slice(1)), option.isBoolean && (option.negated ? !options.some((o, i)=>i !== index && o.names.some((name)=>option.names.includes(name)) && "boolean" == typeof o.required) && result.boolean.push(option.names[0]) : result.boolean.push(option.names[0]));
|
|
6273
|
+
return result;
|
|
6274
|
+
}, findLongest = (arr)=>arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0], padRight = (str, length)=>str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`, camelcase = (input)=>input.replace(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase()), setDotProp = (obj, keys, val)=>{
|
|
6275
|
+
let x, i = 0, length = keys.length, t = obj;
|
|
6276
|
+
for(; i < length; ++i)x = t[keys[i]], t = t[keys[i]] = i === length - 1 ? val : null != x ? x : ~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
|
|
6277
|
+
}, setByType = (obj, transforms)=>{
|
|
6278
|
+
for (let key of Object.keys(transforms)){
|
|
6279
|
+
let transform = transforms[key];
|
|
6280
|
+
transform.shouldTransform && (obj[key] = Array.prototype.concat.call([], obj[key]), "function" == typeof transform.transformFunction && (obj[key] = obj[key].map(transform.transformFunction)));
|
|
6281
|
+
}
|
|
6282
|
+
}, getFileName = (input)=>{
|
|
6283
|
+
let m = /([^\\\/]+)$/.exec(input);
|
|
6284
|
+
return m ? m[1] : "";
|
|
6285
|
+
}, camelcaseOptionName = (name)=>name.split(".").map((v, i)=>0 === i ? camelcase(v) : v).join(".");
|
|
6286
|
+
class CACError extends Error {
|
|
6287
|
+
constructor(message){
|
|
6288
|
+
super(message), this.name = this.constructor.name, "function" == typeof Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = Error(message).stack;
|
|
6289
|
+
}
|
|
6290
|
+
}
|
|
6291
|
+
class Option {
|
|
6292
|
+
constructor(rawName, description, config){
|
|
6293
|
+
this.rawName = rawName, this.description = description, this.config = Object.assign({}, config), rawName = rawName.replace(/\.\*/g, ""), this.negated = !1, this.names = removeBrackets(rawName).split(",").map((v)=>{
|
|
6294
|
+
let name = v.trim().replace(/^-{1,2}/, "");
|
|
6295
|
+
return name.startsWith("no-") && (this.negated = !0, name = name.replace(/^no-/, "")), camelcaseOptionName(name);
|
|
6296
|
+
}).sort((a, b)=>a.length > b.length ? 1 : -1), this.name = this.names[this.names.length - 1], this.negated && null == this.config.default && (this.config.default = !0), rawName.includes("<") ? this.required = !0 : rawName.includes("[") ? this.required = !1 : this.isBoolean = !0;
|
|
6297
|
+
}
|
|
6298
|
+
}
|
|
6299
|
+
let processArgs = process.argv, platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
6300
|
+
class Command {
|
|
6301
|
+
constructor(rawName, description, config = {}, cli){
|
|
6302
|
+
this.rawName = rawName, this.description = description, this.config = config, this.cli = cli, this.options = [], this.aliasNames = [], this.name = removeBrackets(rawName), this.args = findAllBrackets(rawName), this.examples = [];
|
|
6303
|
+
}
|
|
6304
|
+
usage(text) {
|
|
6305
|
+
return this.usageText = text, this;
|
|
6306
|
+
}
|
|
6307
|
+
allowUnknownOptions() {
|
|
6308
|
+
return this.config.allowUnknownOptions = !0, this;
|
|
6309
|
+
}
|
|
6310
|
+
ignoreOptionDefaultValue() {
|
|
6311
|
+
return this.config.ignoreOptionDefaultValue = !0, this;
|
|
6312
|
+
}
|
|
6313
|
+
version(version, customFlags = "-v, --version") {
|
|
6314
|
+
return this.versionNumber = version, this.option(customFlags, "Display version number"), this;
|
|
6315
|
+
}
|
|
6316
|
+
example(example) {
|
|
6317
|
+
return this.examples.push(example), this;
|
|
6318
|
+
}
|
|
6319
|
+
option(rawName, description, config) {
|
|
6320
|
+
let option = new Option(rawName, description, config);
|
|
6321
|
+
return this.options.push(option), this;
|
|
6322
|
+
}
|
|
6323
|
+
alias(name) {
|
|
6324
|
+
return this.aliasNames.push(name), this;
|
|
6325
|
+
}
|
|
6326
|
+
action(callback) {
|
|
6327
|
+
return this.commandAction = callback, this;
|
|
6328
|
+
}
|
|
6329
|
+
isMatched(name) {
|
|
6330
|
+
return this.name === name || this.aliasNames.includes(name);
|
|
6331
|
+
}
|
|
6332
|
+
get isDefaultCommand() {
|
|
6333
|
+
return "" === this.name || this.aliasNames.includes("!");
|
|
6334
|
+
}
|
|
6335
|
+
get isGlobalCommand() {
|
|
6336
|
+
return this instanceof GlobalCommand;
|
|
6337
|
+
}
|
|
6338
|
+
hasOption(name) {
|
|
6339
|
+
return name = name.split(".")[0], this.options.find((option)=>option.names.includes(name));
|
|
6340
|
+
}
|
|
6341
|
+
outputHelp() {
|
|
6342
|
+
let { name, commands } = this.cli, { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand, sections = [
|
|
6343
|
+
{
|
|
6344
|
+
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
6345
|
+
}
|
|
6346
|
+
];
|
|
6347
|
+
if (sections.push({
|
|
6348
|
+
title: "Usage",
|
|
6349
|
+
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
6350
|
+
}), (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0) {
|
|
6351
|
+
let longestCommandName = findLongest(commands.map((command)=>command.rawName));
|
|
6352
|
+
sections.push({
|
|
6353
|
+
title: "Commands",
|
|
6354
|
+
body: commands.map((command)=>` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`).join("\n")
|
|
6355
|
+
}), sections.push({
|
|
6356
|
+
title: "For more info, run any command with the `--help` flag",
|
|
6357
|
+
body: commands.map((command)=>` $ ${name}${"" === command.name ? "" : ` ${command.name}`} --help`).join("\n")
|
|
6358
|
+
});
|
|
6359
|
+
}
|
|
6360
|
+
let options = this.isGlobalCommand ? globalOptions : [
|
|
6361
|
+
...this.options,
|
|
6362
|
+
...globalOptions || []
|
|
6363
|
+
];
|
|
6364
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand && (options = options.filter((option)=>"version" !== option.name)), options.length > 0) {
|
|
6365
|
+
let longestOptionName = findLongest(options.map((option)=>option.rawName));
|
|
6366
|
+
sections.push({
|
|
6367
|
+
title: "Options",
|
|
6368
|
+
body: options.map((option)=>` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${void 0 === option.config.default ? "" : `(default: ${option.config.default})`}`).join("\n")
|
|
6369
|
+
});
|
|
6370
|
+
}
|
|
6371
|
+
this.examples.length > 0 && sections.push({
|
|
6372
|
+
title: "Examples",
|
|
6373
|
+
body: this.examples.map((example)=>"function" == typeof example ? example(name) : example).join("\n")
|
|
6374
|
+
}), helpCallback && (sections = helpCallback(sections) || sections), console.log(sections.map((section)=>section.title ? `${section.title}:
|
|
6375
|
+
${section.body}` : section.body).join("\n\n"));
|
|
6376
|
+
}
|
|
6377
|
+
outputVersion() {
|
|
6378
|
+
let { name } = this.cli, { versionNumber } = this.cli.globalCommand;
|
|
6379
|
+
versionNumber && console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
6380
|
+
}
|
|
6381
|
+
checkRequiredArgs() {
|
|
6382
|
+
let minimalArgsCount = this.args.filter((arg)=>arg.required).length;
|
|
6383
|
+
if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
6384
|
+
}
|
|
6385
|
+
checkUnknownOptions() {
|
|
6386
|
+
let { options, globalCommand } = this.cli;
|
|
6387
|
+
if (!this.config.allowUnknownOptions) {
|
|
6388
|
+
for (let name of Object.keys(options))if ("--" !== name && !this.hasOption(name) && !globalCommand.hasOption(name)) throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
6389
|
+
}
|
|
6390
|
+
}
|
|
6391
|
+
checkOptionValue() {
|
|
6392
|
+
let { options: parsedOptions, globalCommand } = this.cli, options = [
|
|
6393
|
+
...globalCommand.options,
|
|
6394
|
+
...this.options
|
|
6395
|
+
];
|
|
6396
|
+
for (let option of options){
|
|
6397
|
+
let value = parsedOptions[option.name.split(".")[0]];
|
|
6398
|
+
if (option.required) {
|
|
6399
|
+
let hasNegated = options.some((o)=>o.negated && o.names.includes(option.name));
|
|
6400
|
+
if (!0 === value || !1 === value && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
6401
|
+
}
|
|
6402
|
+
}
|
|
6403
|
+
}
|
|
6404
|
+
}
|
|
6405
|
+
class GlobalCommand extends Command {
|
|
6406
|
+
constructor(cli){
|
|
6407
|
+
super("@@global@@", "", {}, cli);
|
|
6408
|
+
}
|
|
6409
|
+
}
|
|
6410
|
+
var __assign = Object.assign;
|
|
6411
|
+
class CAC extends external_events_namespaceObject.EventEmitter {
|
|
6412
|
+
constructor(name = ""){
|
|
6413
|
+
super(), this.name = name, this.commands = [], this.rawArgs = [], this.args = [], this.options = {}, this.globalCommand = new GlobalCommand(this), this.globalCommand.usage("<command> [options]");
|
|
6414
|
+
}
|
|
6415
|
+
usage(text) {
|
|
6416
|
+
return this.globalCommand.usage(text), this;
|
|
6417
|
+
}
|
|
6418
|
+
command(rawName, description, config) {
|
|
6419
|
+
let command = new Command(rawName, description || "", config, this);
|
|
6420
|
+
return command.globalCommand = this.globalCommand, this.commands.push(command), command;
|
|
6421
|
+
}
|
|
6422
|
+
option(rawName, description, config) {
|
|
6423
|
+
return this.globalCommand.option(rawName, description, config), this;
|
|
6424
|
+
}
|
|
6425
|
+
help(callback) {
|
|
6426
|
+
return this.globalCommand.option("-h, --help", "Display this message"), this.globalCommand.helpCallback = callback, this.showHelpOnExit = !0, this;
|
|
6427
|
+
}
|
|
6428
|
+
version(version, customFlags = "-v, --version") {
|
|
6429
|
+
return this.globalCommand.version(version, customFlags), this.showVersionOnExit = !0, this;
|
|
6430
|
+
}
|
|
6431
|
+
example(example) {
|
|
6432
|
+
return this.globalCommand.example(example), this;
|
|
6433
|
+
}
|
|
6434
|
+
outputHelp() {
|
|
6435
|
+
this.matchedCommand ? this.matchedCommand.outputHelp() : this.globalCommand.outputHelp();
|
|
6436
|
+
}
|
|
6437
|
+
outputVersion() {
|
|
6438
|
+
this.globalCommand.outputVersion();
|
|
6439
|
+
}
|
|
6440
|
+
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
6441
|
+
return this.args = args, this.options = options, matchedCommand && (this.matchedCommand = matchedCommand), matchedCommandName && (this.matchedCommandName = matchedCommandName), this;
|
|
6442
|
+
}
|
|
6443
|
+
unsetMatchedCommand() {
|
|
6444
|
+
this.matchedCommand = void 0, this.matchedCommandName = void 0;
|
|
6445
|
+
}
|
|
6446
|
+
parse(argv = processArgs, { run = !0 } = {}) {
|
|
6447
|
+
this.rawArgs = argv, !this.name && (this.name = argv[1] ? getFileName(argv[1]) : "cli");
|
|
6448
|
+
let shouldParse = !0;
|
|
6449
|
+
for (let command of this.commands){
|
|
6450
|
+
let parsed = this.mri(argv.slice(2), command), commandName = parsed.args[0];
|
|
6451
|
+
if (command.isMatched(commandName)) {
|
|
6452
|
+
shouldParse = !1;
|
|
6453
|
+
let parsedInfo = __assign(__assign({}, parsed), {
|
|
6454
|
+
args: parsed.args.slice(1)
|
|
6455
|
+
});
|
|
6456
|
+
this.setParsedInfo(parsedInfo, command, commandName), this.emit(`command:${commandName}`, command);
|
|
6457
|
+
}
|
|
6458
|
+
}
|
|
6459
|
+
if (shouldParse) {
|
|
6460
|
+
for (let command of this.commands)if ("" === command.name) {
|
|
6461
|
+
shouldParse = !1;
|
|
6462
|
+
let parsed = this.mri(argv.slice(2), command);
|
|
6463
|
+
this.setParsedInfo(parsed, command), this.emit("command:!", command);
|
|
6464
|
+
}
|
|
6465
|
+
}
|
|
6466
|
+
if (shouldParse) {
|
|
6467
|
+
let parsed = this.mri(argv.slice(2));
|
|
6468
|
+
this.setParsedInfo(parsed);
|
|
6469
|
+
}
|
|
6470
|
+
this.options.help && this.showHelpOnExit && (this.outputHelp(), run = !1, this.unsetMatchedCommand()), this.options.version && this.showVersionOnExit && null == this.matchedCommandName && (this.outputVersion(), run = !1, this.unsetMatchedCommand());
|
|
6471
|
+
let parsedArgv = {
|
|
6472
|
+
args: this.args,
|
|
6473
|
+
options: this.options
|
|
6474
|
+
};
|
|
6475
|
+
return run && this.runMatchedCommand(), !this.matchedCommand && this.args[0] && this.emit("command:*"), parsedArgv;
|
|
6476
|
+
}
|
|
6477
|
+
mri(argv, command) {
|
|
6478
|
+
let cliOptions = [
|
|
6479
|
+
...this.globalCommand.options,
|
|
6480
|
+
...command ? command.options : []
|
|
6481
|
+
], mriOptions = getMriOptions(cliOptions), argsAfterDoubleDashes = [], doubleDashesIndex = argv.indexOf("--");
|
|
6482
|
+
doubleDashesIndex > -1 && (argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1), argv = argv.slice(0, doubleDashesIndex));
|
|
6483
|
+
let parsed = function(args, opts) {
|
|
6484
|
+
opts = opts || {};
|
|
6485
|
+
var k, arr, arg, name, val, out = {
|
|
6486
|
+
_: []
|
|
6487
|
+
}, i = 0, j = 0, idx = 0, len = (args = args || []).length;
|
|
6488
|
+
let alibi = void 0 !== opts.alias, strict = void 0 !== opts.unknown, defaults = void 0 !== opts.default;
|
|
6489
|
+
if (opts.alias = opts.alias || {}, opts.string = toArr(opts.string), opts.boolean = toArr(opts.boolean), alibi) for(k in opts.alias)for(i = 0, arr = opts.alias[k] = toArr(opts.alias[k]); i < arr.length; i++)(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
6490
|
+
for(i = opts.boolean.length; i-- > 0;)for(j = (arr = opts.alias[opts.boolean[i]] || []).length; j-- > 0;)opts.boolean.push(arr[j]);
|
|
6491
|
+
for(i = opts.string.length; i-- > 0;)for(j = (arr = opts.alias[opts.string[i]] || []).length; j-- > 0;)opts.string.push(arr[j]);
|
|
6492
|
+
if (defaults) {
|
|
6493
|
+
for(k in opts.default)if (name = typeof opts.default[k], arr = opts.alias[k] = opts.alias[k] || [], void 0 !== opts[name]) for(opts[name].push(k), i = 0; i < arr.length; i++)opts[name].push(arr[i]);
|
|
6494
|
+
}
|
|
6495
|
+
let keys = strict ? Object.keys(opts.alias) : [];
|
|
6496
|
+
for(i = 0; i < len; i++){
|
|
6497
|
+
if ('--' === (arg = args[i])) {
|
|
6498
|
+
out._ = out._.concat(args.slice(++i));
|
|
6499
|
+
break;
|
|
6500
|
+
}
|
|
6501
|
+
for(j = 0; j < arg.length && 45 === arg.charCodeAt(j); j++);
|
|
6502
|
+
if (0 === j) out._.push(arg);
|
|
6503
|
+
else if ('no-' === arg.substring(j, j + 3)) {
|
|
6504
|
+
if (name = arg.substring(j + 3), strict && !~keys.indexOf(name)) return opts.unknown(arg);
|
|
6505
|
+
out[name] = !1;
|
|
6506
|
+
} else {
|
|
6507
|
+
for(idx = j + 1; idx < arg.length && 61 !== arg.charCodeAt(idx); idx++);
|
|
6508
|
+
for(name = arg.substring(j, idx), val = arg.substring(++idx) || i + 1 === len || 45 === ('' + args[i + 1]).charCodeAt(0) || args[++i], arr = 2 === j ? [
|
|
6509
|
+
name
|
|
6510
|
+
] : name, idx = 0; idx < arr.length; idx++){
|
|
6511
|
+
if (name = arr[idx], strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
|
6512
|
+
!function(out, key, val, opts) {
|
|
6513
|
+
var x, old = out[key], nxt = ~opts.string.indexOf(key) ? null == val || !0 === val ? '' : String(val) : 'boolean' == typeof val ? val : ~opts.boolean.indexOf(key) ? 'false' !== val && ('true' === val || (out._.push(0 * (x = +val) == 0 ? x : val), !!val)) : 0 * (x = +val) == 0 ? x : val;
|
|
6514
|
+
out[key] = null == old ? nxt : Array.isArray(old) ? old.concat(nxt) : [
|
|
6515
|
+
old,
|
|
6516
|
+
nxt
|
|
6517
|
+
];
|
|
6518
|
+
}(out, name, idx + 1 < arr.length || val, opts);
|
|
6519
|
+
}
|
|
6520
|
+
}
|
|
6521
|
+
}
|
|
6522
|
+
if (defaults) for(k in opts.default)void 0 === out[k] && (out[k] = opts.default[k]);
|
|
6523
|
+
if (alibi) for(k in out)for(arr = opts.alias[k] || []; arr.length > 0;)out[arr.shift()] = out[k];
|
|
6524
|
+
return out;
|
|
6525
|
+
}(argv, mriOptions), args = (parsed = Object.keys(parsed).reduce((res, name)=>__assign(__assign({}, res), {
|
|
6526
|
+
[camelcaseOptionName(name)]: parsed[name]
|
|
6527
|
+
}), {
|
|
6528
|
+
_: []
|
|
6529
|
+
}))._, options = {
|
|
6530
|
+
"--": argsAfterDoubleDashes
|
|
6531
|
+
}, ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue, transforms = Object.create(null);
|
|
6532
|
+
for (let cliOption of cliOptions){
|
|
6533
|
+
if (!ignoreDefault && void 0 !== cliOption.config.default) for (let name of cliOption.names)options[name] = cliOption.config.default;
|
|
6534
|
+
Array.isArray(cliOption.config.type) && void 0 === transforms[cliOption.name] && (transforms[cliOption.name] = Object.create(null), transforms[cliOption.name].shouldTransform = !0, transforms[cliOption.name].transformFunction = cliOption.config.type[0]);
|
|
6535
|
+
}
|
|
6536
|
+
for (let key of Object.keys(parsed))"_" !== key && (setDotProp(options, key.split("."), parsed[key]), setByType(options, transforms));
|
|
6537
|
+
return {
|
|
6538
|
+
args,
|
|
6539
|
+
options
|
|
6540
|
+
};
|
|
6541
|
+
}
|
|
6542
|
+
runMatchedCommand() {
|
|
6543
|
+
let { args, options, matchedCommand: command } = this;
|
|
6544
|
+
if (!command || !command.commandAction) return;
|
|
6545
|
+
command.checkUnknownOptions(), command.checkOptionValue(), command.checkRequiredArgs();
|
|
6546
|
+
let actionArgs = [];
|
|
6547
|
+
return command.args.forEach((arg, index)=>{
|
|
6548
|
+
arg.variadic ? actionArgs.push(args.slice(index)) : actionArgs.push(args[index]);
|
|
6549
|
+
}), actionArgs.push(options), command.commandAction.apply(this, actionArgs);
|
|
6550
|
+
}
|
|
6551
|
+
}
|
|
6552
|
+
let cac_dist = (name = "")=>new CAC(name), applyCommonOptions = (cli)=>{
|
|
6553
|
+
cli.option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
|
|
6554
|
+
type: [
|
|
6555
|
+
String
|
|
6556
|
+
],
|
|
6557
|
+
default: []
|
|
6558
|
+
}).option('--env-dir <dir>', 'specify the directory to load `.env` files');
|
|
7060
6559
|
}, applyServerOptions = (command)=>{
|
|
7061
|
-
command.option('-o --open [url]', 'open the page in browser on startup').option('--port <port>', 'specify a port number for server to listen').option('--host <host>', 'specify the host that the server listens to');
|
|
6560
|
+
command.option('-o, --open [url]', 'open the page in browser on startup').option('--port <port>', 'specify a port number for server to listen').option('--host <host>', 'specify the host that the server listens to');
|
|
7062
6561
|
};
|
|
7063
6562
|
async function runCLI() {
|
|
7064
6563
|
!function() {
|
|
@@ -7072,21 +6571,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7072
6571
|
}
|
|
7073
6572
|
}(), process.title = 'rsbuild-node';
|
|
7074
6573
|
let { npm_execpath } = process.env;
|
|
7075
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.
|
|
6574
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.0-alpha.0\n`);
|
|
7076
6575
|
}();
|
|
7077
6576
|
try {
|
|
7078
6577
|
!function() {
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
buildCommand,
|
|
7084
|
-
previewCommand,
|
|
7085
|
-
inspectCommand
|
|
7086
|
-
].forEach(applyCommonOptions), [
|
|
7087
|
-
devCommand,
|
|
7088
|
-
previewCommand
|
|
7089
|
-
].forEach(applyServerOptions), devCommand.description('starting the dev server').action(async (options)=>{
|
|
6578
|
+
let cli = cac_dist('rsbuild');
|
|
6579
|
+
cli.help(), cli.version("1.2.0-alpha.0"), applyCommonOptions(cli);
|
|
6580
|
+
let devCommand = cli.command('dev', 'starting the dev server'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
|
|
6581
|
+
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7090
6582
|
try {
|
|
7091
6583
|
let rsbuild = await init({
|
|
7092
6584
|
cliOptions: options
|
|
@@ -7095,7 +6587,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7095
6587
|
} catch (err) {
|
|
7096
6588
|
rslog_index_js_namespaceObject.logger.error('Failed to start dev server.'), rslog_index_js_namespaceObject.logger.error(err), process.exit(1);
|
|
7097
6589
|
}
|
|
7098
|
-
}), buildCommand.option('-w --watch', 'turn on watch mode, watch for changes and rebuild').
|
|
6590
|
+
}), buildCommand.option('-w, --watch', 'turn on watch mode, watch for changes and rebuild').action(async (options)=>{
|
|
7099
6591
|
try {
|
|
7100
6592
|
let rsbuild = await init({
|
|
7101
6593
|
cliOptions: options,
|
|
@@ -7107,7 +6599,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7107
6599
|
} catch (err) {
|
|
7108
6600
|
rslog_index_js_namespaceObject.logger.error('Failed to build.'), rslog_index_js_namespaceObject.logger.error(err), process.exit(1);
|
|
7109
6601
|
}
|
|
7110
|
-
}), previewCommand.
|
|
6602
|
+
}), previewCommand.action(async (options)=>{
|
|
7111
6603
|
try {
|
|
7112
6604
|
let rsbuild = await init({
|
|
7113
6605
|
cliOptions: options
|
|
@@ -7116,7 +6608,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7116
6608
|
} catch (err) {
|
|
7117
6609
|
rslog_index_js_namespaceObject.logger.error('Failed to start preview server.'), rslog_index_js_namespaceObject.logger.error(err), process.exit(1);
|
|
7118
6610
|
}
|
|
7119
|
-
}), inspectCommand.
|
|
6611
|
+
}), inspectCommand.option('--output <output>', 'specify inspect content output path').option('--verbose', 'show full function definitions in output').action(async (options)=>{
|
|
7120
6612
|
try {
|
|
7121
6613
|
let rsbuild = await init({
|
|
7122
6614
|
cliOptions: options
|
|
@@ -7129,13 +6621,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7129
6621
|
} catch (err) {
|
|
7130
6622
|
rslog_index_js_namespaceObject.logger.error('Failed to inspect config.'), rslog_index_js_namespaceObject.logger.error(err), process.exit(1);
|
|
7131
6623
|
}
|
|
7132
|
-
}),
|
|
6624
|
+
}), cli.parse();
|
|
7133
6625
|
}();
|
|
7134
6626
|
} catch (err) {
|
|
7135
6627
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
7136
6628
|
}
|
|
7137
6629
|
}
|
|
7138
|
-
let src_rslib_entry_version = "1.
|
|
6630
|
+
let src_rslib_entry_version = "1.2.0-alpha.0";
|
|
7139
6631
|
})();
|
|
7140
6632
|
var __webpack_export_target__ = exports;
|
|
7141
6633
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
@@ -7147,7 +6639,6 @@ __webpack_exports__.__esModule && Object.defineProperty(__webpack_export_target_
|
|
|
7147
6639
|
0 && (module.exports = {
|
|
7148
6640
|
PLUGIN_CSS_NAME,
|
|
7149
6641
|
PLUGIN_SWC_NAME,
|
|
7150
|
-
__internalHelper,
|
|
7151
6642
|
createRsbuild,
|
|
7152
6643
|
defineConfig,
|
|
7153
6644
|
ensureAssetPrefix,
|