@modern-js/utils 2.10.0 → 2.12.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/CHANGELOG.md +42 -0
- package/compiled/commander/index.js +1 -1
- package/compiled/commander/package.json +1 -1
- package/compiled/commander/typings/index.d.ts +145 -29
- package/dist/analyzeProject.js +3 -2
- package/dist/chainId.d.ts +0 -17
- package/dist/chainId.js +1 -18
- package/dist/commands.d.ts +2 -0
- package/dist/commands.js +12 -1
- package/dist/constants.d.ts +16 -11
- package/dist/constants.js +14 -9
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/prettyInstructions.d.ts +4 -3
- package/dist/prettyInstructions.js +13 -16
- package/dist/{tryResolve.d.ts → resolve.d.ts} +2 -1
- package/dist/{tryResolve.js → resolve.js} +16 -3
- package/dist/universal/constants.d.ts +9 -0
- package/dist/universal/constants.js +30 -0
- package/dist/{format.js → universal/formatWebpack.js} +3 -3
- package/dist/{nestedRoutes.d.ts → universal/nestedRoutes.d.ts} +1 -4
- package/dist/{nestedRoutes.js → universal/nestedRoutes.js} +2 -2
- package/dist/{remix-router.js → universal/remixRouter.js} +3 -3
- package/package.json +27 -23
- /package/dist/{format.d.ts → universal/formatWebpack.d.ts} +0 -0
- /package/dist/{remix-router.d.ts → universal/remixRouter.d.ts} +0 -0
- /package/dist/{serialize.d.ts → universal/serialize.d.ts} +0 -0
- /package/dist/{serialize.js → universal/serialize.js} +0 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,47 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 2.12.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- c2ca6c8: fix(app-tools): failed to restart CLI
|
8
|
+
|
9
|
+
fix(app-tools): 修复 CLI 重启失败的问题
|
10
|
+
|
11
|
+
- 6d86e34: feat(doc-tools): print dev server URLs with base
|
12
|
+
|
13
|
+
feat(doc-tools): 输出 dev server 的 URLs 时补全 base 信息
|
14
|
+
|
15
|
+
## 2.11.0
|
16
|
+
|
17
|
+
### Patch Changes
|
18
|
+
|
19
|
+
- cfb058f: fix(builder): remove duplicated babel-plugin-import
|
20
|
+
|
21
|
+
fix(builder): 移除重复注册的 babel-plugin-import
|
22
|
+
|
23
|
+
- 0bd018b: feat: support use node api run dev & build & deploy command
|
24
|
+
feat: 支持通过 node api 运行 dev & build & deploy 命令
|
25
|
+
- 5d624fd: feat: assets and data prefetching is supported
|
26
|
+
feat: 支持资源和数据预加载
|
27
|
+
- e2466a1: fix: remove nestedRoutes file from @modern-js/utils
|
28
|
+
fix: 将 nestedRoutes 从 @modern-js/utils 中移除
|
29
|
+
- 02bb383: fix: fix lost props when using nested route in micro-front-end mode
|
30
|
+
修复嵌套路由在微前端场景下主子应用传递 props 丢失问题
|
31
|
+
- 381a3b9: feat(utils): move universal utils to the universal folder
|
32
|
+
|
33
|
+
feat(utils): 将运行时使用的 utils 移动到 universal 目录
|
34
|
+
|
35
|
+
- 7a60f10: chore(utils): bump commander from v8 to v10
|
36
|
+
|
37
|
+
chore(utils): 将 commander 从 v8 升级到 v10
|
38
|
+
|
39
|
+
- 274b2e5: fix: For rspack-provider can use `tools.babel` configuration, inline the `@babel/preset-typescript` to handle ts syntax in rspack-provider.
|
40
|
+
fix: 为了 rspack-provider 能给使用 `tools.babel` 配置项,将 `@babel/preset-typescript` 内置进 rspack-provider 去处理 ts 语法。
|
41
|
+
- b9e1c54: fix(utils): remove useless oneOf chainId,avoid user usage error.
|
42
|
+
|
43
|
+
fix(utils): 移除无用的 oneOf chainId,防止用户使用异常
|
44
|
+
|
3
45
|
## 2.10.0
|
4
46
|
|
5
47
|
### Patch Changes
|
@@ -1 +1 @@
|
|
1
|
-
(()=>{var e={81:e=>{"use strict";e.exports=require("child_process")},361:e=>{"use strict";e.exports=require("events")},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")},922:(e,t,i)=>{const{Argument:n}=i(969);const{Command:s}=i(694);const{CommanderError:r,InvalidArgumentError:o}=i(967);const{Help:a}=i(34);const{Option:h}=i(278);t=e.exports=new s;t.program=t;t.Argument=n;t.Command=s;t.CommanderError=r;t.Help=a;t.InvalidArgumentError=o;t.InvalidOptionArgumentError=o;t.Option=h},969:(e,t,i)=>{const{InvalidArgumentError:n}=i(967);class Argument{constructor(e,t){this.description=t||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(e[0]){case"<":this.required=true;this._name=e.slice(1,-1);break;case"[":this.required=false;this._name=e.slice(1,-1);break;default:this.required=true;this._name=e;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(e,t){if(t===this.defaultValue||!Array.isArray(t)){return[e]}return t.concat(e)}default(e,t){this.defaultValue=e;this.defaultValueDescription=t;return this}argParser(e){this.parseArg=e;return this}choices(e){this.argChoices=e;this.parseArg=(t,i)=>{if(!e.includes(t)){throw new n(`Allowed choices are ${e.join(", ")}.`)}if(this.variadic){return this._concatValue(t,i)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(e){const t=e.name()+(e.variadic===true?"...":"");return e.required?"<"+t+">":"["+t+"]"}t.Argument=Argument;t.humanReadableArgName=humanReadableArgName},694:(e,t,i)=>{const n=i(361).EventEmitter;const s=i(81);const r=i(17);const o=i(147);const{Argument:a,humanReadableArgName:h}=i(969);const{CommanderError:l}=i(967);const{Help:u}=i(34);const{Option:c,splitOptionFlags:p}=i(278);const{suggestSimilar:m}=i(461);class Command extends n{constructor(e){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this._args=[];this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=e||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=false;this._outputConfiguration={writeOut:e=>process.stdout.write(e),writeErr:e=>process.stderr.write(e),getOutHelpWidth:()=>process.stdout.isTTY?process.stdout.columns:undefined,getErrHelpWidth:()=>process.stderr.isTTY?process.stderr.columns:undefined,outputError:(e,t)=>t(e)};this._hidden=false;this._hasHelpOption=true;this._helpFlags="-h, --help";this._helpDescription="display help for command";this._helpShortFlag="-h";this._helpLongFlag="--help";this._addImplicitHelpCommand=undefined;this._helpCommandName="help";this._helpCommandnameAndArgs="help [command]";this._helpCommandDescription="display help for command";this._helpConfiguration={}}copyInheritedSettings(e){this._outputConfiguration=e._outputConfiguration;this._hasHelpOption=e._hasHelpOption;this._helpFlags=e._helpFlags;this._helpDescription=e._helpDescription;this._helpShortFlag=e._helpShortFlag;this._helpLongFlag=e._helpLongFlag;this._helpCommandName=e._helpCommandName;this._helpCommandnameAndArgs=e._helpCommandnameAndArgs;this._helpCommandDescription=e._helpCommandDescription;this._helpConfiguration=e._helpConfiguration;this._exitCallback=e._exitCallback;this._storeOptionsAsProperties=e._storeOptionsAsProperties;this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue;this._allowExcessArguments=e._allowExcessArguments;this._enablePositionalOptions=e._enablePositionalOptions;this._showHelpAfterError=e._showHelpAfterError;this._showSuggestionAfterError=e._showSuggestionAfterError;return this}command(e,t,i){let n=t;let s=i;if(typeof n==="object"&&n!==null){s=n;n=null}s=s||{};const[,r,o]=e.match(/([^ ]+) *(.*)/);const a=this.createCommand(r);if(n){a.description(n);a._executableHandler=true}if(s.isDefault)this._defaultCommandName=a._name;a._hidden=!!(s.noHelp||s.hidden);a._executableFile=s.executableFile||null;if(o)a.arguments(o);this.commands.push(a);a.parent=this;a.copyInheritedSettings(this);if(n)return this;return a}createCommand(e){return new Command(e)}createHelp(){return Object.assign(new u,this.configureHelp())}configureHelp(e){if(e===undefined)return this._helpConfiguration;this._helpConfiguration=e;return this}configureOutput(e){if(e===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,e);return this}showHelpAfterError(e=true){if(typeof e!=="string")e=!!e;this._showHelpAfterError=e;return this}showSuggestionAfterError(e=true){this._showSuggestionAfterError=!!e;return this}addCommand(e,t){if(!e._name)throw new Error("Command passed to .addCommand() must have a name");function checkExplicitNames(e){e.forEach((e=>{if(e._executableHandler&&!e._executableFile){throw new Error(`Must specify executableFile for deeply nested executable: ${e.name()}`)}checkExplicitNames(e.commands)}))}checkExplicitNames(e.commands);t=t||{};if(t.isDefault)this._defaultCommandName=e._name;if(t.noHelp||t.hidden)e._hidden=true;this.commands.push(e);e.parent=this;return this}createArgument(e,t){return new a(e,t)}argument(e,t,i,n){const s=this.createArgument(e,t);if(typeof i==="function"){s.default(n).argParser(i)}else{s.default(i)}this.addArgument(s);return this}arguments(e){e.split(/ +/).forEach((e=>{this.argument(e)}));return this}addArgument(e){const t=this._args.slice(-1)[0];if(t&&t.variadic){throw new Error(`only the last argument can be variadic '${t.name()}'`)}if(e.required&&e.defaultValue!==undefined&&e.parseArg===undefined){throw new Error(`a default value for a required argument is never used: '${e.name()}'`)}this._args.push(e);return this}addHelpCommand(e,t){if(e===false){this._addImplicitHelpCommand=false}else{this._addImplicitHelpCommand=true;if(typeof e==="string"){this._helpCommandName=e.split(" ")[0];this._helpCommandnameAndArgs=e}this._helpCommandDescription=t||this._helpCommandDescription}return this}_hasImplicitHelpCommand(){if(this._addImplicitHelpCommand===undefined){return this.commands.length&&!this._actionHandler&&!this._findCommand("help")}return this._addImplicitHelpCommand}hook(e,t){const i=["preAction","postAction"];if(!i.includes(e)){throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${i.join("', '")}'`)}if(this._lifeCycleHooks[e]){this._lifeCycleHooks[e].push(t)}else{this._lifeCycleHooks[e]=[t]}return this}exitOverride(e){if(e){this._exitCallback=e}else{this._exitCallback=e=>{if(e.code!=="commander.executeSubCommandAsync"){throw e}else{}}}return this}_exit(e,t,i){if(this._exitCallback){this._exitCallback(new l(e,t,i))}process.exit(e)}action(e){const listener=t=>{const i=this._args.length;const n=t.slice(0,i);if(this._storeOptionsAsProperties){n[i]=this}else{n[i]=this.opts()}n.push(this);return e.apply(this,n)};this._actionHandler=listener;return this}createOption(e,t){return new c(e,t)}addOption(e){const t=e.name();const i=e.attributeName();let n=e.defaultValue;if(e.negate||e.optional||e.required||typeof n==="boolean"){if(e.negate){const t=e.long.replace(/^--no-/,"--");n=this._findOption(t)?this.getOptionValue(i):true}if(n!==undefined){this.setOptionValueWithSource(i,n,"default")}}this.options.push(e);const handleOptionValue=(t,s,r)=>{const o=this.getOptionValue(i);if(t!==null&&e.parseArg){try{t=e.parseArg(t,o===undefined?n:o)}catch(e){if(e.code==="commander.invalidArgument"){const t=`${s} ${e.message}`;this._displayError(e.exitCode,e.code,t)}throw e}}else if(t!==null&&e.variadic){t=e._concatValue(t,o)}if(typeof o==="boolean"||typeof o==="undefined"){if(t==null){this.setOptionValueWithSource(i,e.negate?false:n||true,r)}else{this.setOptionValueWithSource(i,t,r)}}else if(t!==null){this.setOptionValueWithSource(i,e.negate?false:t,r)}};this.on("option:"+t,(t=>{const i=`error: option '${e.flags}' argument '${t}' is invalid.`;handleOptionValue(t,i,"cli")}));if(e.envVar){this.on("optionEnv:"+t,(t=>{const i=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;handleOptionValue(t,i,"env")}))}return this}_optionEx(e,t,i,n,s){const r=this.createOption(t,i);r.makeOptionMandatory(!!e.mandatory);if(typeof n==="function"){r.default(s).argParser(n)}else if(n instanceof RegExp){const e=n;n=(t,i)=>{const n=e.exec(t);return n?n[0]:i};r.default(s).argParser(n)}else{r.default(n)}return this.addOption(r)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:true},e,t,i,n)}combineFlagAndOptionalValue(e=true){this._combineFlagAndOptionalValue=!!e;return this}allowUnknownOption(e=true){this._allowUnknownOption=!!e;return this}allowExcessArguments(e=true){this._allowExcessArguments=!!e;return this}enablePositionalOptions(e=true){this._enablePositionalOptions=!!e;return this}passThroughOptions(e=true){this._passThroughOptions=!!e;if(!!this.parent&&e&&!this.parent._enablePositionalOptions){throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)")}return this}storeOptionsAsProperties(e=true){this._storeOptionsAsProperties=!!e;if(this.options.length){throw new Error("call .storeOptionsAsProperties() before adding options")}return this}getOptionValue(e){if(this._storeOptionsAsProperties){return this[e]}return this._optionValues[e]}setOptionValue(e,t){if(this._storeOptionsAsProperties){this[e]=t}else{this._optionValues[e]=t}return this}setOptionValueWithSource(e,t,i){this.setOptionValue(e,t);this._optionValueSources[e]=i;return this}getOptionValueSource(e){return this._optionValueSources[e]}_prepareUserArgs(e,t){if(e!==undefined&&!Array.isArray(e)){throw new Error("first parameter to parse must be array or undefined")}t=t||{};if(e===undefined){e=process.argv;if(process.versions&&process.versions.electron){t.from="electron"}}this.rawArgs=e.slice();let i;switch(t.from){case undefined:case"node":this._scriptPath=e[1];i=e.slice(2);break;case"electron":if(process.defaultApp){this._scriptPath=e[1];i=e.slice(2)}else{i=e.slice(1)}break;case"user":i=e.slice(0);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}if(!this._scriptPath&&require.main){this._scriptPath=require.main.filename}this._name=this._name||this._scriptPath&&r.basename(this._scriptPath,r.extname(this._scriptPath));return i}parse(e,t){const i=this._prepareUserArgs(e,t);this._parseCommand([],i);return this}async parseAsync(e,t){const i=this._prepareUserArgs(e,t);await this._parseCommand([],i);return this}_executeSubCommand(e,t){t=t.slice();let i=false;const n=[".js",".ts",".tsx",".mjs",".cjs"];this._checkForMissingMandatoryOptions();let a=this._scriptPath;if(!a&&require.main){a=require.main.filename}let h;try{const e=o.realpathSync(a);h=r.dirname(e)}catch(e){h="."}let u=r.basename(a,r.extname(a))+"-"+e._name;if(e._executableFile){u=e._executableFile}const c=r.join(h,u);if(o.existsSync(c)){u=c}else{n.forEach((e=>{if(o.existsSync(`${c}${e}`)){u=`${c}${e}`}}))}i=n.includes(r.extname(u));let p;if(process.platform!=="win32"){if(i){t.unshift(u);t=incrementNodeInspectorPort(process.execArgv).concat(t);p=s.spawn(process.argv[0],t,{stdio:"inherit"})}else{p=s.spawn(u,t,{stdio:"inherit"})}}else{t.unshift(u);t=incrementNodeInspectorPort(process.execArgv).concat(t);p=s.spawn(process.execPath,t,{stdio:"inherit"})}const m=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];m.forEach((e=>{process.on(e,(()=>{if(p.killed===false&&p.exitCode===null){p.kill(e)}}))}));const d=this._exitCallback;if(!d){p.on("close",process.exit.bind(process))}else{p.on("close",(()=>{d(new l(process.exitCode||0,"commander.executeSubCommandAsync","(close)"))}))}p.on("error",(t=>{if(t.code==="ENOENT"){const t=`'${u}' does not exist\n - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name`;throw new Error(t)}else if(t.code==="EACCES"){throw new Error(`'${u}' not executable`)}if(!d){process.exit(1)}else{const e=new l(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t;d(e)}}));this.runningCommand=p}_dispatchSubcommand(e,t,i){const n=this._findCommand(e);if(!n)this.help({error:true});if(n._executableHandler){this._executeSubCommand(n,t.concat(i))}else{return n._parseCommand(t,i)}}_checkNumberOfArguments(){this._args.forEach(((e,t)=>{if(e.required&&this.args[t]==null){this.missingArgument(e.name())}}));if(this._args.length>0&&this._args[this._args.length-1].variadic){return}if(this.args.length>this._args.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(e,t,i)=>{let n=t;if(t!==null&&e.parseArg){try{n=e.parseArg(t,i)}catch(i){if(i.code==="commander.invalidArgument"){const n=`error: command-argument value '${t}' is invalid for argument '${e.name()}'. ${i.message}`;this._displayError(i.exitCode,i.code,n)}throw i}}return n};this._checkNumberOfArguments();const e=[];this._args.forEach(((t,i)=>{let n=t.defaultValue;if(t.variadic){if(i<this.args.length){n=this.args.slice(i);if(t.parseArg){n=n.reduce(((e,i)=>myParseArg(t,i,e)),t.defaultValue)}}else if(n===undefined){n=[]}}else if(i<this.args.length){n=this.args[i];if(t.parseArg){n=myParseArg(t,n,t.defaultValue)}}e[i]=n}));this.processedArgs=e}_chainOrCall(e,t){if(e&&e.then&&typeof e.then==="function"){return e.then((()=>t()))}return t()}_chainOrCallHooks(e,t){let i=e;const n=[];getCommandAndParents(this).reverse().filter((e=>e._lifeCycleHooks[t]!==undefined)).forEach((e=>{e._lifeCycleHooks[t].forEach((t=>{n.push({hookedCommand:e,callback:t})}))}));if(t==="postAction"){n.reverse()}n.forEach((e=>{i=this._chainOrCall(i,(()=>e.callback(e.hookedCommand,this)))}));return i}_parseCommand(e,t){const i=this.parseOptions(t);this._parseOptionsEnv();e=e.concat(i.operands);t=i.unknown;this.args=e.concat(t);if(e&&this._findCommand(e[0])){return this._dispatchSubcommand(e[0],e.slice(1),t)}if(this._hasImplicitHelpCommand()&&e[0]===this._helpCommandName){if(e.length===1){this.help()}return this._dispatchSubcommand(e[1],[],[this._helpLongFlag])}if(this._defaultCommandName){outputHelpIfRequested(this,t);return this._dispatchSubcommand(this._defaultCommandName,e,t)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}outputHelpIfRequested(this,i.unknown);this._checkForMissingMandatoryOptions();const checkForUnknownOptions=()=>{if(i.unknown.length>0){this.unknownOption(i.unknown[0])}};const n=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let i;i=this._chainOrCallHooks(i,"preAction");i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs)));if(this.parent)this.parent.emit(n,e,t);i=this._chainOrCallHooks(i,"postAction");return i}if(this.parent&&this.parent.listenerCount(n)){checkForUnknownOptions();this._processArguments();this.parent.emit(n,e,t)}else if(e.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",e,t)}if(this.listenerCount("command:*")){this.emit("command:*",e,t)}else if(this.commands.length){this.unknownCommand()}else{checkForUnknownOptions();this._processArguments()}}else if(this.commands.length){checkForUnknownOptions();this.help({error:true})}else{checkForUnknownOptions();this._processArguments()}}_findCommand(e){if(!e)return undefined;return this.commands.find((t=>t._name===e||t._aliases.includes(e)))}_findOption(e){return this.options.find((t=>t.is(e)))}_checkForMissingMandatoryOptions(){for(let e=this;e;e=e.parent){e.options.forEach((t=>{if(t.mandatory&&e.getOptionValue(t.attributeName())===undefined){e.missingMandatoryOptionValue(t)}}))}}parseOptions(e){const t=[];const i=[];let n=t;const s=e.slice();function maybeOption(e){return e.length>1&&e[0]==="-"}let r=null;while(s.length){const e=s.shift();if(e==="--"){if(n===i)n.push(e);n.push(...s);break}if(r&&!maybeOption(e)){this.emit(`option:${r.name()}`,e);continue}r=null;if(maybeOption(e)){const t=this._findOption(e);if(t){if(t.required){const e=s.shift();if(e===undefined)this.optionMissingArgument(t);this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;if(s.length>0&&!maybeOption(s[0])){e=s.shift()}this.emit(`option:${t.name()}`,e)}else{this.emit(`option:${t.name()}`)}r=t.variadic?t:null;continue}}if(e.length>2&&e[0]==="-"&&e[1]!=="-"){const t=this._findOption(`-${e[1]}`);if(t){if(t.required||t.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${t.name()}`,e.slice(2))}else{this.emit(`option:${t.name()}`);s.unshift(`-${e.slice(2)}`)}continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("=");const i=this._findOption(e.slice(0,t));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,e.slice(t+1));continue}}if(maybeOption(e)){n=i}if((this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(e)){t.push(e);if(s.length>0)i.push(...s);break}else if(e===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(e);if(s.length>0)t.push(...s);break}else if(this._defaultCommandName){i.push(e);if(s.length>0)i.push(...s);break}}if(this._passThroughOptions){n.push(e);if(s.length>0)n.push(...s);break}n.push(e)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){const e={};const t=this.options.length;for(let i=0;i<t;i++){const t=this.options[i].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}_displayError(e,t,i){this._outputConfiguration.outputError(`${i}\n`,this._outputConfiguration.writeErr);if(typeof this._showHelpAfterError==="string"){this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`)}else if(this._showHelpAfterError){this._outputConfiguration.writeErr("\n");this.outputHelp({error:true})}this._exit(e,t,i)}_parseOptionsEnv(){this.options.forEach((e=>{if(e.envVar&&e.envVar in process.env){const t=e.attributeName();if(this.getOptionValue(t)===undefined||["default","config","env"].includes(this.getOptionValueSource(t))){if(e.required||e.optional){this.emit(`optionEnv:${e.name()}`,process.env[e.envVar])}else{this.emit(`optionEnv:${e.name()}`)}}}}))}missingArgument(e){const t=`error: missing required argument '${e}'`;this._displayError(1,"commander.missingArgument",t)}optionMissingArgument(e){const t=`error: option '${e.flags}' argument missing`;this._displayError(1,"commander.optionMissingArgument",t)}missingMandatoryOptionValue(e){const t=`error: required option '${e.flags}' not specified`;this._displayError(1,"commander.missingMandatoryOptionValue",t)}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[];let n=this;do{const e=n.createHelp().visibleOptions(n).filter((e=>e.long)).map((e=>e.long));i=i.concat(e);n=n.parent}while(n&&!n._enablePositionalOptions);t=m(e,i)}const i=`error: unknown option '${e}'${t}`;this._displayError(1,"commander.unknownOption",i)}_excessArguments(e){if(this._allowExcessArguments)return;const t=this._args.length;const i=t===1?"":"s";const n=this.parent?` for '${this.name()}'`:"";const s=`error: too many arguments${n}. Expected ${t} argument${i} but got ${e.length}.`;this._displayError(1,"commander.excessArguments",s)}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((e=>{i.push(e.name());if(e.alias())i.push(e.alias())}));t=m(e,i)}const i=`error: unknown command '${e}'${t}`;this._displayError(1,"commander.unknownCommand",i)}version(e,t,i){if(e===undefined)return this._version;this._version=e;t=t||"-V, --version";i=i||"output the version number";const n=this.createOption(t,i);this._versionOptionName=n.attributeName();this.options.push(n);this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${e}\n`);this._exit(0,"commander.version",e)}));return this}description(e,t){if(e===undefined&&t===undefined)return this._description;this._description=e;if(t){this._argsDescription=t}return this}alias(e){if(e===undefined)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){t=this.commands[this.commands.length-1]}if(e===t._name)throw new Error("Command alias can't be the same as its name");t._aliases.push(e);return this}aliases(e){if(e===undefined)return this._aliases;e.forEach((e=>this.alias(e)));return this}usage(e){if(e===undefined){if(this._usage)return this._usage;const e=this._args.map((e=>h(e)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?e:[]).join(" ")}this._usage=e;return this}name(e){if(e===undefined)return this._name;this._name=e;return this}helpInformation(e){const t=this.createHelp();if(t.helpWidth===undefined){t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return t.formatHelp(this,t)}_getHelpContext(e){e=e||{};const t={error:!!e.error};let i;if(t.error){i=e=>this._outputConfiguration.writeErr(e)}else{i=e=>this._outputConfiguration.writeOut(e)}t.write=e.write||i;t.command=this;return t}outputHelp(e){let t;if(typeof e==="function"){t=e;e=undefined}const i=this._getHelpContext(e);getCommandAndParents(this).reverse().forEach((e=>e.emit("beforeAllHelp",i)));this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t){n=t(n);if(typeof n!=="string"&&!Buffer.isBuffer(n)){throw new Error("outputHelp callback must return a string or a Buffer")}}i.write(n);this.emit(this._helpLongFlag);this.emit("afterHelp",i);getCommandAndParents(this).forEach((e=>e.emit("afterAllHelp",i)))}helpOption(e,t){if(typeof e==="boolean"){this._hasHelpOption=e;return this}this._helpFlags=e||this._helpFlags;this._helpDescription=t||this._helpDescription;const i=p(this._helpFlags);this._helpShortFlag=i.shortFlag;this._helpLongFlag=i.longFlag;return this}help(e){this.outputHelp(e);let t=process.exitCode||0;if(t===0&&e&&typeof e!=="function"&&e.error){t=1}this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const i=["beforeAll","before","after","afterAll"];if(!i.includes(e)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`)}const n=`${e}Help`;this.on(n,(e=>{let i;if(typeof t==="function"){i=t({error:e.error,command:e.command})}else{i=t}if(i){e.write(`${i}\n`)}}));return this}}function outputHelpIfRequested(e,t){const i=e._hasHelpOption&&t.find((t=>t===e._helpLongFlag||t===e._helpShortFlag));if(i){e.outputHelp();e._exit(0,"commander.helpDisplayed","(outputHelp)")}}function incrementNodeInspectorPort(e){return e.map((e=>{if(!e.startsWith("--inspect")){return e}let t;let i="127.0.0.1";let n="9229";let s;if((s=e.match(/^(--inspect(-brk)?)$/))!==null){t=s[1]}else if((s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){t=s[1];if(/^\d+$/.test(s[3])){n=s[3]}else{i=s[3]}}else if((s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){t=s[1];i=s[3];n=s[4]}if(t&&n!=="0"){return`${t}=${i}:${parseInt(n)+1}`}return e}))}function getCommandAndParents(e){const t=[];for(let i=e;i;i=i.parent){t.push(i)}return t}t.Command=Command},967:(e,t)=>{class CommanderError extends Error{constructor(e,t,i){super(i);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=t;this.exitCode=e;this.nestedError=undefined}}class InvalidArgumentError extends CommanderError{constructor(e){super(1,"commander.invalidArgument",e);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name}}t.CommanderError=CommanderError;t.InvalidArgumentError=InvalidArgumentError},34:(e,t,i)=>{const{humanReadableArgName:n}=i(969);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false}visibleCommands(e){const t=e.commands.filter((e=>!e._hidden));if(e._hasImplicitHelpCommand()){const[,i,n]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);const s=e.createCommand(i).helpOption(false);s.description(e._helpCommandDescription);if(n)s.arguments(n);t.push(s)}if(this.sortSubcommands){t.sort(((e,t)=>e.name().localeCompare(t.name())))}return t}visibleOptions(e){const t=e.options.filter((e=>!e.hidden));const i=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag);const n=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(i||n){let s;if(!i){s=e.createOption(e._helpLongFlag,e._helpDescription)}else if(!n){s=e.createOption(e._helpShortFlag,e._helpDescription)}else{s=e.createOption(e._helpFlags,e._helpDescription)}t.push(s)}if(this.sortOptions){const getSortKey=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");t.sort(((e,t)=>getSortKey(e).localeCompare(getSortKey(t))))}return t}visibleArguments(e){if(e._argsDescription){e._args.forEach((t=>{t.description=t.description||e._argsDescription[t.name()]||""}))}if(e._args.find((e=>e.description))){return e._args}return[]}subcommandTerm(e){const t=e._args.map((e=>n(e))).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce(((e,i)=>Math.max(e,t.subcommandTerm(i).length)),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce(((e,i)=>Math.max(e,t.optionTerm(i).length)),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce(((e,i)=>Math.max(e,t.argumentTerm(i).length)),0)}commandUsage(e){let t=e._name;if(e._aliases[0]){t=t+"|"+e._aliases[0]}let i="";for(let t=e.parent;t;t=t.parent){i=t.name()+" "+i}return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.description()}optionDescription(e){const t=[];if(e.argChoices&&!e.negate){t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`)}if(e.defaultValue!==undefined&&!e.negate){t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(e.envVar!==undefined){t.push(`env: ${e.envVar}`)}if(t.length>0){return`${e.description} (${t.join(", ")})`}return e.description}argumentDescription(e){const t=[];if(e.argChoices){t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`)}if(e.defaultValue!==undefined){t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(t.length>0){const i=`(${t.join(", ")})`;if(e.description){return`${e.description} ${i}`}return i}return e.description}formatHelp(e,t){const i=t.padWidth(e,t);const n=t.helpWidth||80;const s=2;const r=2;function formatItem(e,o){if(o){const a=`${e.padEnd(i+r)}${o}`;return t.wrap(a,n-s,i+r)}return e}function formatList(e){return e.join("\n").replace(/^/gm," ".repeat(s))}let o=[`Usage: ${t.commandUsage(e)}`,""];const a=t.commandDescription(e);if(a.length>0){o=o.concat([a,""])}const h=t.visibleArguments(e).map((e=>formatItem(t.argumentTerm(e),t.argumentDescription(e))));if(h.length>0){o=o.concat(["Arguments:",formatList(h),""])}const l=t.visibleOptions(e).map((e=>formatItem(t.optionTerm(e),t.optionDescription(e))));if(l.length>0){o=o.concat(["Options:",formatList(l),""])}const u=t.visibleCommands(e).map((e=>formatItem(t.subcommandTerm(e),t.subcommandDescription(e))));if(u.length>0){o=o.concat(["Commands:",formatList(u),""])}return o.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){if(e.match(/[\n]\s+/))return e;const s=t-i;if(s<n)return e;const r=e.substr(0,i);const o=e.substr(i);const a=" ".repeat(i);const h=new RegExp(".{1,"+(s-1)+"}([\\s]|$)|[^\\s]+?([\\s]|$)","g");const l=o.match(h)||[];return r+l.map(((e,t)=>{if(e.slice(-1)==="\n"){e=e.slice(0,e.length-1)}return(t>0?a:"")+e.trimRight()})).join("\n")}}t.Help=Help},278:(e,t,i)=>{const{InvalidArgumentError:n}=i(967);class Option{constructor(e,t){this.flags=e;this.description=t||"";this.required=e.includes("<");this.optional=e.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(e);this.mandatory=false;const i=splitOptionFlags(e);this.short=i.shortFlag;this.long=i.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined}default(e,t){this.defaultValue=e;this.defaultValueDescription=t;return this}env(e){this.envVar=e;return this}argParser(e){this.parseArg=e;return this}makeOptionMandatory(e=true){this.mandatory=!!e;return this}hideHelp(e=true){this.hidden=!!e;return this}_concatValue(e,t){if(t===this.defaultValue||!Array.isArray(t)){return[e]}return t.concat(e)}choices(e){this.argChoices=e;this.parseArg=(t,i)=>{if(!e.includes(t)){throw new n(`Allowed choices are ${e.join(", ")}.`)}if(this.variadic){return this._concatValue(t,i)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}}function camelcase(e){return e.split("-").reduce(((e,t)=>e+t[0].toUpperCase()+t.slice(1)))}function splitOptionFlags(e){let t;let i;const n=e.split(/[ |,]+/);if(n.length>1&&!/^[[<]/.test(n[1]))t=n.shift();i=n.shift();if(!t&&/^-[^-]$/.test(i)){t=i;i=undefined}return{shortFlag:t,longFlag:i}}t.Option=Option;t.splitOptionFlags=splitOptionFlags},461:(e,t)=>{const i=3;function editDistance(e,t){if(Math.abs(e.length-t.length)>i)return Math.max(e.length,t.length);const n=[];for(let t=0;t<=e.length;t++){n[t]=[t]}for(let e=0;e<=t.length;e++){n[0][e]=e}for(let i=1;i<=t.length;i++){for(let s=1;s<=e.length;s++){let r=1;if(e[s-1]===t[i-1]){r=0}else{r=1}n[s][i]=Math.min(n[s-1][i]+1,n[s][i-1]+1,n[s-1][i-1]+r);if(s>1&&i>1&&e[s-1]===t[i-2]&&e[s-2]===t[i-1]){n[s][i]=Math.min(n[s][i],n[s-2][i-2]+1)}}}return n[e.length][t.length]}function suggestSimilar(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));const n=e.startsWith("--");if(n){e=e.slice(2);t=t.map((e=>e.slice(2)))}let s=[];let r=i;const o=.4;t.forEach((t=>{if(t.length<=1)return;const i=editDistance(e,t);const n=Math.max(e.length,t.length);const a=(n-i)/n;if(a>o){if(i<r){r=i;s=[t]}else if(i===r){s.push(t)}}}));s.sort(((e,t)=>e.localeCompare(t)));if(n){s=s.map((e=>`--${e}`))}if(s.length>1){return`\n(Did you mean one of ${s.join(", ")}?)`}if(s.length===1){return`\n(Did you mean ${s[0]}?)`}return""}t.suggestSimilar=suggestSimilar}};var t={};function __nccwpck_require__(i){var n=t[i];if(n!==undefined){return n.exports}var s=t[i]={exports:{}};var r=true;try{e[i](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete t[i]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(922);module.exports=i})();
|
1
|
+
(()=>{var t={81:t=>{"use strict";t.exports=require("child_process")},361:t=>{"use strict";t.exports=require("events")},147:t=>{"use strict";t.exports=require("fs")},17:t=>{"use strict";t.exports=require("path")},282:t=>{"use strict";t.exports=require("process")},632:(t,e,i)=>{const{Argument:n}=i(535);const{Command:s}=i(302);const{CommanderError:r,InvalidArgumentError:o}=i(796);const{Help:a}=i(519);const{Option:l}=i(437);e=t.exports=new s;e.program=e;e.Argument=n;e.Command=s;e.CommanderError=r;e.Help=a;e.InvalidArgumentError=o;e.InvalidOptionArgumentError=o;e.Option=l},535:(t,e,i)=>{const{InvalidArgumentError:n}=i(796);class Argument{constructor(t,e){this.description=e||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(t[0]){case"<":this.required=true;this._name=t.slice(1,-1);break;case"[":this.required=false;this._name=t.slice(1,-1);break;default:this.required=true;this._name=t;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(t,e){if(e===this.defaultValue||!Array.isArray(e)){return[t]}return e.concat(t)}default(t,e){this.defaultValue=t;this.defaultValueDescription=e;return this}argParser(t){this.parseArg=t;return this}choices(t){this.argChoices=t.slice();this.parseArg=(t,e)=>{if(!this.argChoices.includes(t)){throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,e)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(t){const e=t.name()+(t.variadic===true?"...":"");return t.required?"<"+e+">":"["+e+"]"}e.Argument=Argument;e.humanReadableArgName=humanReadableArgName},302:(t,e,i)=>{const n=i(361).EventEmitter;const s=i(81);const r=i(17);const o=i(147);const a=i(282);const{Argument:l,humanReadableArgName:h}=i(535);const{CommanderError:u}=i(796);const{Help:c}=i(519);const{Option:p,splitOptionFlags:m,DualOptions:d}=i(437);const{suggestSimilar:f}=i(860);class Command extends n{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this._args=[];this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=t||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._executableDir=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._summary="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=true;this._outputConfiguration={writeOut:t=>a.stdout.write(t),writeErr:t=>a.stderr.write(t),getOutHelpWidth:()=>a.stdout.isTTY?a.stdout.columns:undefined,getErrHelpWidth:()=>a.stderr.isTTY?a.stderr.columns:undefined,outputError:(t,e)=>e(t)};this._hidden=false;this._hasHelpOption=true;this._helpFlags="-h, --help";this._helpDescription="display help for command";this._helpShortFlag="-h";this._helpLongFlag="--help";this._addImplicitHelpCommand=undefined;this._helpCommandName="help";this._helpCommandnameAndArgs="help [command]";this._helpCommandDescription="display help for command";this._helpConfiguration={}}copyInheritedSettings(t){this._outputConfiguration=t._outputConfiguration;this._hasHelpOption=t._hasHelpOption;this._helpFlags=t._helpFlags;this._helpDescription=t._helpDescription;this._helpShortFlag=t._helpShortFlag;this._helpLongFlag=t._helpLongFlag;this._helpCommandName=t._helpCommandName;this._helpCommandnameAndArgs=t._helpCommandnameAndArgs;this._helpCommandDescription=t._helpCommandDescription;this._helpConfiguration=t._helpConfiguration;this._exitCallback=t._exitCallback;this._storeOptionsAsProperties=t._storeOptionsAsProperties;this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue;this._allowExcessArguments=t._allowExcessArguments;this._enablePositionalOptions=t._enablePositionalOptions;this._showHelpAfterError=t._showHelpAfterError;this._showSuggestionAfterError=t._showSuggestionAfterError;return this}command(t,e,i){let n=e;let s=i;if(typeof n==="object"&&n!==null){s=n;n=null}s=s||{};const[,r,o]=t.match(/([^ ]+) *(.*)/);const a=this.createCommand(r);if(n){a.description(n);a._executableHandler=true}if(s.isDefault)this._defaultCommandName=a._name;a._hidden=!!(s.noHelp||s.hidden);a._executableFile=s.executableFile||null;if(o)a.arguments(o);this.commands.push(a);a.parent=this;a.copyInheritedSettings(this);if(n)return this;return a}createCommand(t){return new Command(t)}createHelp(){return Object.assign(new c,this.configureHelp())}configureHelp(t){if(t===undefined)return this._helpConfiguration;this._helpConfiguration=t;return this}configureOutput(t){if(t===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,t);return this}showHelpAfterError(t=true){if(typeof t!=="string")t=!!t;this._showHelpAfterError=t;return this}showSuggestionAfterError(t=true){this._showSuggestionAfterError=!!t;return this}addCommand(t,e){if(!t._name){throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`)}e=e||{};if(e.isDefault)this._defaultCommandName=t._name;if(e.noHelp||e.hidden)t._hidden=true;this.commands.push(t);t.parent=this;return this}createArgument(t,e){return new l(t,e)}argument(t,e,i,n){const s=this.createArgument(t,e);if(typeof i==="function"){s.default(n).argParser(i)}else{s.default(i)}this.addArgument(s);return this}arguments(t){t.split(/ +/).forEach((t=>{this.argument(t)}));return this}addArgument(t){const e=this._args.slice(-1)[0];if(e&&e.variadic){throw new Error(`only the last argument can be variadic '${e.name()}'`)}if(t.required&&t.defaultValue!==undefined&&t.parseArg===undefined){throw new Error(`a default value for a required argument is never used: '${t.name()}'`)}this._args.push(t);return this}addHelpCommand(t,e){if(t===false){this._addImplicitHelpCommand=false}else{this._addImplicitHelpCommand=true;if(typeof t==="string"){this._helpCommandName=t.split(" ")[0];this._helpCommandnameAndArgs=t}this._helpCommandDescription=e||this._helpCommandDescription}return this}_hasImplicitHelpCommand(){if(this._addImplicitHelpCommand===undefined){return this.commands.length&&!this._actionHandler&&!this._findCommand("help")}return this._addImplicitHelpCommand}hook(t,e){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t)){throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`)}if(this._lifeCycleHooks[t]){this._lifeCycleHooks[t].push(e)}else{this._lifeCycleHooks[t]=[e]}return this}exitOverride(t){if(t){this._exitCallback=t}else{this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync"){throw t}else{}}}return this}_exit(t,e,i){if(this._exitCallback){this._exitCallback(new u(t,e,i))}a.exit(t)}action(t){const listener=e=>{const i=this._args.length;const n=e.slice(0,i);if(this._storeOptionsAsProperties){n[i]=this}else{n[i]=this.opts()}n.push(this);return t.apply(this,n)};this._actionHandler=listener;return this}createOption(t,e){return new p(t,e)}addOption(t){const e=t.name();const i=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");if(!this._findOption(e)){this.setOptionValueWithSource(i,t.defaultValue===undefined?true:t.defaultValue,"default")}}else if(t.defaultValue!==undefined){this.setOptionValueWithSource(i,t.defaultValue,"default")}this.options.push(t);const handleOptionValue=(e,n,s)=>{if(e==null&&t.presetArg!==undefined){e=t.presetArg}const r=this.getOptionValue(i);if(e!==null&&t.parseArg){try{e=t.parseArg(e,r)}catch(t){if(t.code==="commander.invalidArgument"){const e=`${n} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}else if(e!==null&&t.variadic){e=t._concatValue(e,r)}if(e==null){if(t.negate){e=false}else if(t.isBoolean()||t.optional){e=true}else{e=""}}this.setOptionValueWithSource(i,e,s)};this.on("option:"+e,(e=>{const i=`error: option '${t.flags}' argument '${e}' is invalid.`;handleOptionValue(e,i,"cli")}));if(t.envVar){this.on("optionEnv:"+e,(e=>{const i=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;handleOptionValue(e,i,"env")}))}return this}_optionEx(t,e,i,n,s){if(typeof e==="object"&&e instanceof p){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const r=this.createOption(e,i);r.makeOptionMandatory(!!t.mandatory);if(typeof n==="function"){r.default(s).argParser(n)}else if(n instanceof RegExp){const t=n;n=(e,i)=>{const n=t.exec(e);return n?n[0]:i};r.default(s).argParser(n)}else{r.default(n)}return this.addOption(r)}option(t,e,i,n){return this._optionEx({},t,e,i,n)}requiredOption(t,e,i,n){return this._optionEx({mandatory:true},t,e,i,n)}combineFlagAndOptionalValue(t=true){this._combineFlagAndOptionalValue=!!t;return this}allowUnknownOption(t=true){this._allowUnknownOption=!!t;return this}allowExcessArguments(t=true){this._allowExcessArguments=!!t;return this}enablePositionalOptions(t=true){this._enablePositionalOptions=!!t;return this}passThroughOptions(t=true){this._passThroughOptions=!!t;if(!!this.parent&&t&&!this.parent._enablePositionalOptions){throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)")}return this}storeOptionsAsProperties(t=true){this._storeOptionsAsProperties=!!t;if(this.options.length){throw new Error("call .storeOptionsAsProperties() before adding options")}return this}getOptionValue(t){if(this._storeOptionsAsProperties){return this[t]}return this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,undefined)}setOptionValueWithSource(t,e,i){if(this._storeOptionsAsProperties){this[t]=e}else{this._optionValues[t]=e}this._optionValueSources[t]=i;return this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;getCommandAndParents(this).forEach((i=>{if(i.getOptionValueSource(t)!==undefined){e=i.getOptionValueSource(t)}}));return e}_prepareUserArgs(t,e){if(t!==undefined&&!Array.isArray(t)){throw new Error("first parameter to parse must be array or undefined")}e=e||{};if(t===undefined){t=a.argv;if(a.versions&&a.versions.electron){e.from="electron"}}this.rawArgs=t.slice();let i;switch(e.from){case undefined:case"node":this._scriptPath=t[1];i=t.slice(2);break;case"electron":if(a.defaultApp){this._scriptPath=t[1];i=t.slice(2)}else{i=t.slice(1)}break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);this._name=this._name||"program";return i}parse(t,e){const i=this._prepareUserArgs(t,e);this._parseCommand([],i);return this}async parseAsync(t,e){const i=this._prepareUserArgs(t,e);await this._parseCommand([],i);return this}_executeSubCommand(t,e){e=e.slice();let i=false;const n=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,e){const i=r.resolve(t,e);if(o.existsSync(i))return i;if(n.includes(r.extname(e)))return undefined;const s=n.find((t=>o.existsSync(`${i}${t}`)));if(s)return`${i}${s}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let l=t._executableFile||`${this._name}-${t._name}`;let h=this._executableDir||"";if(this._scriptPath){let t;try{t=o.realpathSync(this._scriptPath)}catch(e){t=this._scriptPath}h=r.resolve(r.dirname(t),h)}if(h){let e=findFile(h,l);if(!e&&!t._executableFile&&this._scriptPath){const i=r.basename(this._scriptPath,r.extname(this._scriptPath));if(i!==this._name){e=findFile(h,`${i}-${t._name}`)}}l=e||l}i=n.includes(r.extname(l));let c;if(a.platform!=="win32"){if(i){e.unshift(l);e=incrementNodeInspectorPort(a.execArgv).concat(e);c=s.spawn(a.argv[0],e,{stdio:"inherit"})}else{c=s.spawn(l,e,{stdio:"inherit"})}}else{e.unshift(l);e=incrementNodeInspectorPort(a.execArgv).concat(e);c=s.spawn(a.execPath,e,{stdio:"inherit"})}if(!c.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{a.on(t,(()=>{if(c.killed===false&&c.exitCode===null){c.kill(t)}}))}))}const p=this._exitCallback;if(!p){c.on("close",a.exit.bind(a))}else{c.on("close",(()=>{p(new u(a.exitCode||0,"commander.executeSubCommandAsync","(close)"))}))}c.on("error",(e=>{if(e.code==="ENOENT"){const e=h?`searched for local subcommand relative to directory '${h}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const i=`'${l}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${e}`;throw new Error(i)}else if(e.code==="EACCES"){throw new Error(`'${l}' not executable`)}if(!p){a.exit(1)}else{const t=new u(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e;p(t)}}));this.runningCommand=c}_dispatchSubcommand(t,e,i){const n=this._findCommand(t);if(!n)this.help({error:true});let s;s=this._chainOrCallSubCommandHook(s,n,"preSubcommand");s=this._chainOrCall(s,(()=>{if(n._executableHandler){this._executeSubCommand(n,e.concat(i))}else{return n._parseCommand(e,i)}}));return s}_checkNumberOfArguments(){this._args.forEach(((t,e)=>{if(t.required&&this.args[e]==null){this.missingArgument(t.name())}}));if(this._args.length>0&&this._args[this._args.length-1].variadic){return}if(this.args.length>this._args.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(t,e,i)=>{let n=e;if(e!==null&&t.parseArg){try{n=t.parseArg(e,i)}catch(i){if(i.code==="commander.invalidArgument"){const n=`error: command-argument value '${e}' is invalid for argument '${t.name()}'. ${i.message}`;this.error(n,{exitCode:i.exitCode,code:i.code})}throw i}}return n};this._checkNumberOfArguments();const t=[];this._args.forEach(((e,i)=>{let n=e.defaultValue;if(e.variadic){if(i<this.args.length){n=this.args.slice(i);if(e.parseArg){n=n.reduce(((t,i)=>myParseArg(e,i,t)),e.defaultValue)}}else if(n===undefined){n=[]}}else if(i<this.args.length){n=this.args[i];if(e.parseArg){n=myParseArg(e,n,e.defaultValue)}}t[i]=n}));this.processedArgs=t}_chainOrCall(t,e){if(t&&t.then&&typeof t.then==="function"){return t.then((()=>e()))}return e()}_chainOrCallHooks(t,e){let i=t;const n=[];getCommandAndParents(this).reverse().filter((t=>t._lifeCycleHooks[e]!==undefined)).forEach((t=>{t._lifeCycleHooks[e].forEach((e=>{n.push({hookedCommand:t,callback:e})}))}));if(e==="postAction"){n.reverse()}n.forEach((t=>{i=this._chainOrCall(i,(()=>t.callback(t.hookedCommand,this)))}));return i}_chainOrCallSubCommandHook(t,e,i){let n=t;if(this._lifeCycleHooks[i]!==undefined){this._lifeCycleHooks[i].forEach((t=>{n=this._chainOrCall(n,(()=>t(this,e)))}))}return n}_parseCommand(t,e){const i=this.parseOptions(e);this._parseOptionsEnv();this._parseOptionsImplied();t=t.concat(i.operands);e=i.unknown;this.args=t.concat(e);if(t&&this._findCommand(t[0])){return this._dispatchSubcommand(t[0],t.slice(1),e)}if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName){if(t.length===1){this.help()}return this._dispatchSubcommand(t[1],[],[this._helpLongFlag])}if(this._defaultCommandName){outputHelpIfRequested(this,e);return this._dispatchSubcommand(this._defaultCommandName,t,e)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}outputHelpIfRequested(this,i.unknown);this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();const checkForUnknownOptions=()=>{if(i.unknown.length>0){this.unknownOption(i.unknown[0])}};const n=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let i;i=this._chainOrCallHooks(i,"preAction");i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs)));if(this.parent){i=this._chainOrCall(i,(()=>{this.parent.emit(n,t,e)}))}i=this._chainOrCallHooks(i,"postAction");return i}if(this.parent&&this.parent.listenerCount(n)){checkForUnknownOptions();this._processArguments();this.parent.emit(n,t,e)}else if(t.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",t,e)}if(this.listenerCount("command:*")){this.emit("command:*",t,e)}else if(this.commands.length){this.unknownCommand()}else{checkForUnknownOptions();this._processArguments()}}else if(this.commands.length){checkForUnknownOptions();this.help({error:true})}else{checkForUnknownOptions();this._processArguments()}}_findCommand(t){if(!t)return undefined;return this.commands.find((e=>e._name===t||e._aliases.includes(t)))}_findOption(t){return this.options.find((e=>e.is(t)))}_checkForMissingMandatoryOptions(){for(let t=this;t;t=t.parent){t.options.forEach((e=>{if(e.mandatory&&t.getOptionValue(e.attributeName())===undefined){t.missingMandatoryOptionValue(e)}}))}}_checkForConflictingLocalOptions(){const t=this.options.filter((t=>{const e=t.attributeName();if(this.getOptionValue(e)===undefined){return false}return this.getOptionValueSource(e)!=="default"}));const e=t.filter((t=>t.conflictsWith.length>0));e.forEach((e=>{const i=t.find((t=>e.conflictsWith.includes(t.attributeName())));if(i){this._conflictingOption(e,i)}}))}_checkForConflictingOptions(){for(let t=this;t;t=t.parent){t._checkForConflictingLocalOptions()}}parseOptions(t){const e=[];const i=[];let n=e;const s=t.slice();function maybeOption(t){return t.length>1&&t[0]==="-"}let r=null;while(s.length){const t=s.shift();if(t==="--"){if(n===i)n.push(t);n.push(...s);break}if(r&&!maybeOption(t)){this.emit(`option:${r.name()}`,t);continue}r=null;if(maybeOption(t)){const e=this._findOption(t);if(e){if(e.required){const t=s.shift();if(t===undefined)this.optionMissingArgument(e);this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;if(s.length>0&&!maybeOption(s[0])){t=s.shift()}this.emit(`option:${e.name()}`,t)}else{this.emit(`option:${e.name()}`)}r=e.variadic?e:null;continue}}if(t.length>2&&t[0]==="-"&&t[1]!=="-"){const e=this._findOption(`-${t[1]}`);if(e){if(e.required||e.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${e.name()}`,t.slice(2))}else{this.emit(`option:${e.name()}`);s.unshift(`-${t.slice(2)}`)}continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("=");const i=this._findOption(t.slice(0,e));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(e+1));continue}}if(maybeOption(t)){n=i}if((this._enablePositionalOptions||this._passThroughOptions)&&e.length===0&&i.length===0){if(this._findCommand(t)){e.push(t);if(s.length>0)i.push(...s);break}else if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){e.push(t);if(s.length>0)e.push(...s);break}else if(this._defaultCommandName){i.push(t);if(s.length>0)i.push(...s);break}}if(this._passThroughOptions){n.push(t);if(s.length>0)n.push(...s);break}n.push(t)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={};const e=this.options.length;for(let i=0;i<e;i++){const e=this.options[i].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return getCommandAndParents(this).reduce(((t,e)=>Object.assign(t,e.opts())),{})}error(t,e){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr);if(typeof this._showHelpAfterError==="string"){this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`)}else if(this._showHelpAfterError){this._outputConfiguration.writeErr("\n");this.outputHelp({error:true})}const i=e||{};const n=i.exitCode||1;const s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in a.env){const e=t.attributeName();if(this.getOptionValue(e)===undefined||["default","config","env"].includes(this.getOptionValueSource(e))){if(t.required||t.optional){this.emit(`optionEnv:${t.name()}`,a.env[t.envVar])}else{this.emit(`optionEnv:${t.name()}`)}}}}))}_parseOptionsImplied(){const t=new d(this.options);const hasCustomOptionValue=t=>this.getOptionValue(t)!==undefined&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter((e=>e.implied!==undefined&&hasCustomOptionValue(e.attributeName())&&t.valueFromOption(this.getOptionValue(e.attributeName()),e))).forEach((t=>{Object.keys(t.implied).filter((t=>!hasCustomOptionValue(t))).forEach((e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")}))}))}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const findBestOptionFromValue=t=>{const e=t.attributeName();const i=this.getOptionValue(e);const n=this.options.find((t=>t.negate&&e===t.attributeName()));const s=this.options.find((t=>!t.negate&&e===t.attributeName()));if(n&&(n.presetArg===undefined&&i===false||n.presetArg!==undefined&&i===n.presetArg)){return n}return s||t};const getErrorMessage=t=>{const e=findBestOptionFromValue(t);const i=e.attributeName();const n=this.getOptionValueSource(i);if(n==="env"){return`environment variable '${e.envVar}'`}return`option '${e.flags}'`};const i=`error: ${getErrorMessage(t)} cannot be used with ${getErrorMessage(e)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[];let n=this;do{const t=n.createHelp().visibleOptions(n).filter((t=>t.long)).map((t=>t.long));i=i.concat(t);n=n.parent}while(n&&!n._enablePositionalOptions);e=f(t,i)}const i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this._args.length;const i=e===1?"":"s";const n=this.parent?` for '${this.name()}'`:"";const s=`error: too many arguments${n}. Expected ${e} argument${i} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((t=>{i.push(t.name());if(t.alias())i.push(t.alias())}));e=f(t,i)}const i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(t===undefined)return this._version;this._version=t;e=e||"-V, --version";i=i||"output the version number";const n=this.createOption(e,i);this._versionOptionName=n.attributeName();this.options.push(n);this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`);this._exit(0,"commander.version",t)}));return this}description(t,e){if(t===undefined&&e===undefined)return this._description;this._description=t;if(e){this._argsDescription=e}return this}summary(t){if(t===undefined)return this._summary;this._summary=t;return this}alias(t){if(t===undefined)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){e=this.commands[this.commands.length-1]}if(t===e._name)throw new Error("Command alias can't be the same as its name");e._aliases.push(t);return this}aliases(t){if(t===undefined)return this._aliases;t.forEach((t=>this.alias(t)));return this}usage(t){if(t===undefined){if(this._usage)return this._usage;const t=this._args.map((t=>h(t)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}this._usage=t;return this}name(t){if(t===undefined)return this._name;this._name=t;return this}nameFromFilename(t){this._name=r.basename(t,r.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const e=this.createHelp();if(e.helpWidth===undefined){e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return e.formatHelp(this,e)}_getHelpContext(t){t=t||{};const e={error:!!t.error};let i;if(e.error){i=t=>this._outputConfiguration.writeErr(t)}else{i=t=>this._outputConfiguration.writeOut(t)}e.write=t.write||i;e.command=this;return e}outputHelp(t){let e;if(typeof t==="function"){e=t;t=undefined}const i=this._getHelpContext(t);getCommandAndParents(this).reverse().forEach((t=>t.emit("beforeAllHelp",i)));this.emit("beforeHelp",i);let n=this.helpInformation(i);if(e){n=e(n);if(typeof n!=="string"&&!Buffer.isBuffer(n)){throw new Error("outputHelp callback must return a string or a Buffer")}}i.write(n);this.emit(this._helpLongFlag);this.emit("afterHelp",i);getCommandAndParents(this).forEach((t=>t.emit("afterAllHelp",i)))}helpOption(t,e){if(typeof t==="boolean"){this._hasHelpOption=t;return this}this._helpFlags=t||this._helpFlags;this._helpDescription=e||this._helpDescription;const i=m(this._helpFlags);this._helpShortFlag=i.shortFlag;this._helpLongFlag=i.longFlag;return this}help(t){this.outputHelp(t);let e=a.exitCode||0;if(e===0&&t&&typeof t!=="function"&&t.error){e=1}this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`)}const n=`${t}Help`;this.on(n,(t=>{let i;if(typeof e==="function"){i=e({error:t.error,command:t.command})}else{i=e}if(i){t.write(`${i}\n`)}}));return this}}function outputHelpIfRequested(t,e){const i=t._hasHelpOption&&e.find((e=>e===t._helpLongFlag||e===t._helpShortFlag));if(i){t.outputHelp();t._exit(0,"commander.helpDisplayed","(outputHelp)")}}function incrementNodeInspectorPort(t){return t.map((t=>{if(!t.startsWith("--inspect")){return t}let e;let i="127.0.0.1";let n="9229";let s;if((s=t.match(/^(--inspect(-brk)?)$/))!==null){e=s[1]}else if((s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){e=s[1];if(/^\d+$/.test(s[3])){n=s[3]}else{i=s[3]}}else if((s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){e=s[1];i=s[3];n=s[4]}if(e&&n!=="0"){return`${e}=${i}:${parseInt(n)+1}`}return t}))}function getCommandAndParents(t){const e=[];for(let i=t;i;i=i.parent){e.push(i)}return e}e.Command=Command},796:(t,e)=>{class CommanderError extends Error{constructor(t,e,i){super(i);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=e;this.exitCode=t;this.nestedError=undefined}}class InvalidArgumentError extends CommanderError{constructor(t){super(1,"commander.invalidArgument",t);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name}}e.CommanderError=CommanderError;e.InvalidArgumentError=InvalidArgumentError},519:(t,e,i)=>{const{humanReadableArgName:n}=i(535);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false;this.showGlobalOptions=false}visibleCommands(t){const e=t.commands.filter((t=>!t._hidden));if(t._hasImplicitHelpCommand()){const[,i,n]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);const s=t.createCommand(i).helpOption(false);s.description(t._helpCommandDescription);if(n)s.arguments(n);e.push(s)}if(this.sortSubcommands){e.sort(((t,e)=>t.name().localeCompare(e.name())))}return e}compareOptions(t,e){const getSortKey=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return getSortKey(t).localeCompare(getSortKey(e))}visibleOptions(t){const e=t.options.filter((t=>!t.hidden));const i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag);const n=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||n){let s;if(!i){s=t.createOption(t._helpLongFlag,t._helpDescription)}else if(!n){s=t.createOption(t._helpShortFlag,t._helpDescription)}else{s=t.createOption(t._helpFlags,t._helpDescription)}e.push(s)}if(this.sortOptions){e.sort(this.compareOptions)}return e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let i=t.parent;i;i=i.parent){const t=i.options.filter((t=>!t.hidden));e.push(...t)}if(this.sortOptions){e.sort(this.compareOptions)}return e}visibleArguments(t){if(t._argsDescription){t._args.forEach((e=>{e.description=e.description||t._argsDescription[e.name()]||""}))}if(t._args.find((t=>t.description))){return t._args}return[]}subcommandTerm(t){const e=t._args.map((t=>n(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce(((t,i)=>Math.max(t,e.subcommandTerm(i).length)),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce(((t,i)=>Math.max(t,e.optionTerm(i).length)),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce(((t,i)=>Math.max(t,e.optionTerm(i).length)),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce(((t,i)=>Math.max(t,e.argumentTerm(i).length)),0)}commandUsage(t){let e=t._name;if(t._aliases[0]){e=e+"|"+t._aliases[0]}let i="";for(let e=t.parent;e;e=e.parent){i=e.name()+" "+i}return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices){e.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){const i=t.required||t.optional||t.isBoolean()&&typeof t.defaultValue==="boolean";if(i){e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}}if(t.presetArg!==undefined&&t.optional){e.push(`preset: ${JSON.stringify(t.presetArg)}`)}if(t.envVar!==undefined){e.push(`env: ${t.envVar}`)}if(e.length>0){return`${t.description} (${e.join(", ")})`}return t.description}argumentDescription(t){const e=[];if(t.argChoices){e.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}if(e.length>0){const i=`(${e.join(", ")})`;if(t.description){return`${t.description} ${i}`}return i}return t.description}formatHelp(t,e){const i=e.padWidth(t,e);const n=e.helpWidth||80;const s=2;const r=2;function formatItem(t,o){if(o){const a=`${t.padEnd(i+r)}${o}`;return e.wrap(a,n-s,i+r)}return t}function formatList(t){return t.join("\n").replace(/^/gm," ".repeat(s))}let o=[`Usage: ${e.commandUsage(t)}`,""];const a=e.commandDescription(t);if(a.length>0){o=o.concat([e.wrap(a,n,0),""])}const l=e.visibleArguments(t).map((t=>formatItem(e.argumentTerm(t),e.argumentDescription(t))));if(l.length>0){o=o.concat(["Arguments:",formatList(l),""])}const h=e.visibleOptions(t).map((t=>formatItem(e.optionTerm(t),e.optionDescription(t))));if(h.length>0){o=o.concat(["Options:",formatList(h),""])}if(this.showGlobalOptions){const i=e.visibleGlobalOptions(t).map((t=>formatItem(e.optionTerm(t),e.optionDescription(t))));if(i.length>0){o=o.concat(["Global Options:",formatList(i),""])}}const u=e.visibleCommands(t).map((t=>formatItem(e.subcommandTerm(t),e.subcommandDescription(t))));if(u.length>0){o=o.concat(["Commands:",formatList(u),""])}return o.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,n=40){const s=" \\f\\t\\v - \ufeff";const r=new RegExp(`[\\n][${s}]+`);if(t.match(r))return t;const o=e-i;if(o<n)return t;const a=t.slice(0,i);const l=t.slice(i).replace("\r\n","\n");const h=" ".repeat(i);const u="";const c=`\\s${u}`;const p=new RegExp(`\n|.{1,${o-1}}([${c}]|$)|[^${c}]+?([${c}]|$)`,"g");const m=l.match(p)||[];return a+m.map(((t,e)=>{if(t==="\n")return"";return(e>0?h:"")+t.trimEnd()})).join("\n")}}e.Help=Help},437:(t,e,i)=>{const{InvalidArgumentError:n}=i(796);class Option{constructor(t,e){this.flags=t;this.description=e||"";this.required=t.includes("<");this.optional=t.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(t);this.mandatory=false;const i=splitOptionFlags(t);this.short=i.shortFlag;this.long=i.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.presetArg=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined;this.conflictsWith=[];this.implied=undefined}default(t,e){this.defaultValue=t;this.defaultValueDescription=e;return this}preset(t){this.presetArg=t;return this}conflicts(t){this.conflictsWith=this.conflictsWith.concat(t);return this}implies(t){this.implied=Object.assign(this.implied||{},t);return this}env(t){this.envVar=t;return this}argParser(t){this.parseArg=t;return this}makeOptionMandatory(t=true){this.mandatory=!!t;return this}hideHelp(t=true){this.hidden=!!t;return this}_concatValue(t,e){if(e===this.defaultValue||!Array.isArray(e)){return[t]}return e.concat(t)}choices(t){this.argChoices=t.slice();this.parseArg=(t,e)=>{if(!this.argChoices.includes(t)){throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,e)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class DualOptions{constructor(t){this.positiveOptions=new Map;this.negativeOptions=new Map;this.dualOptions=new Set;t.forEach((t=>{if(t.negate){this.negativeOptions.set(t.attributeName(),t)}else{this.positiveOptions.set(t.attributeName(),t)}}));this.negativeOptions.forEach(((t,e)=>{if(this.positiveOptions.has(e)){this.dualOptions.add(e)}}))}valueFromOption(t,e){const i=e.attributeName();if(!this.dualOptions.has(i))return true;const n=this.negativeOptions.get(i).presetArg;const s=n!==undefined?n:false;return e.negate===(s===t)}}function camelcase(t){return t.split("-").reduce(((t,e)=>t+e[0].toUpperCase()+e.slice(1)))}function splitOptionFlags(t){let e;let i;const n=t.split(/[ |,]+/);if(n.length>1&&!/^[[<]/.test(n[1]))e=n.shift();i=n.shift();if(!e&&/^-[^-]$/.test(i)){e=i;i=undefined}return{shortFlag:e,longFlag:i}}e.Option=Option;e.splitOptionFlags=splitOptionFlags;e.DualOptions=DualOptions},860:(t,e)=>{const i=3;function editDistance(t,e){if(Math.abs(t.length-e.length)>i)return Math.max(t.length,e.length);const n=[];for(let e=0;e<=t.length;e++){n[e]=[e]}for(let t=0;t<=e.length;t++){n[0][t]=t}for(let i=1;i<=e.length;i++){for(let s=1;s<=t.length;s++){let r=1;if(t[s-1]===e[i-1]){r=0}else{r=1}n[s][i]=Math.min(n[s-1][i]+1,n[s][i-1]+1,n[s-1][i-1]+r);if(s>1&&i>1&&t[s-1]===e[i-2]&&t[s-2]===e[i-1]){n[s][i]=Math.min(n[s][i],n[s-2][i-2]+1)}}}return n[t.length][e.length]}function suggestSimilar(t,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));const n=t.startsWith("--");if(n){t=t.slice(2);e=e.map((t=>t.slice(2)))}let s=[];let r=i;const o=.4;e.forEach((e=>{if(e.length<=1)return;const i=editDistance(t,e);const n=Math.max(t.length,e.length);const a=(n-i)/n;if(a>o){if(i<r){r=i;s=[e]}else if(i===r){s.push(e)}}}));s.sort(((t,e)=>t.localeCompare(e)));if(n){s=s.map((t=>`--${t}`))}if(s.length>1){return`\n(Did you mean one of ${s.join(", ")}?)`}if(s.length===1){return`\n(Did you mean ${s[0]}?)`}return""}e.suggestSimilar=suggestSimilar}};var e={};function __nccwpck_require__(i){var n=e[i];if(n!==undefined){return n.exports}var s=e[i]={exports:{}};var r=true;try{t[i](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete e[i]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(632);module.exports=i})();
|
@@ -1 +1 @@
|
|
1
|
-
{"name":"commander","author":"TJ Holowaychuk <tj@vision-media.ca>","version":"
|
1
|
+
{"name":"commander","author":"TJ Holowaychuk <tj@vision-media.ca>","version":"10.0.0","license":"MIT","types":"typings/index.d.ts"}
|
@@ -31,6 +31,13 @@ export class InvalidArgumentError extends CommanderError {
|
|
31
31
|
}
|
32
32
|
export { InvalidArgumentError as InvalidOptionArgumentError }; // deprecated old name
|
33
33
|
|
34
|
+
export interface ErrorOptions { // optional parameter for error()
|
35
|
+
/** an id string representing the error */
|
36
|
+
code?: string;
|
37
|
+
/** suggested exit code which could be used with process.exit */
|
38
|
+
exitCode?: number;
|
39
|
+
}
|
40
|
+
|
34
41
|
export class Argument {
|
35
42
|
description: string;
|
36
43
|
required: boolean;
|
@@ -61,18 +68,18 @@ export class Argument {
|
|
61
68
|
/**
|
62
69
|
* Only allow argument value to be one of choices.
|
63
70
|
*/
|
64
|
-
choices(values: string[]): this;
|
71
|
+
choices(values: readonly string[]): this;
|
65
72
|
|
66
73
|
/**
|
67
|
-
* Make
|
74
|
+
* Make argument required.
|
68
75
|
*/
|
69
76
|
argRequired(): this;
|
70
77
|
|
71
78
|
/**
|
72
|
-
* Make
|
79
|
+
* Make argument optional.
|
73
80
|
*/
|
74
81
|
argOptional(): this;
|
75
|
-
|
82
|
+
}
|
76
83
|
|
77
84
|
export class Option {
|
78
85
|
flags: string;
|
@@ -99,9 +106,47 @@ export class Option {
|
|
99
106
|
*/
|
100
107
|
default(value: unknown, description?: string): this;
|
101
108
|
|
109
|
+
/**
|
110
|
+
* Preset to use when option used without option-argument, especially optional but also boolean and negated.
|
111
|
+
* The custom processing (parseArg) is called.
|
112
|
+
*
|
113
|
+
* @example
|
114
|
+
* ```ts
|
115
|
+
* new Option('--color').default('GREYSCALE').preset('RGB');
|
116
|
+
* new Option('--donate [amount]').preset('20').argParser(parseFloat);
|
117
|
+
* ```
|
118
|
+
*/
|
119
|
+
preset(arg: unknown): this;
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Add option name(s) that conflict with this option.
|
123
|
+
* An error will be displayed if conflicting options are found during parsing.
|
124
|
+
*
|
125
|
+
* @example
|
126
|
+
* ```ts
|
127
|
+
* new Option('--rgb').conflicts('cmyk');
|
128
|
+
* new Option('--js').conflicts(['ts', 'jsx']);
|
129
|
+
* ```
|
130
|
+
*/
|
131
|
+
conflicts(names: string | string[]): this;
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Specify implied option values for when this option is set and the implied options are not.
|
135
|
+
*
|
136
|
+
* The custom processing (parseArg) is not called on the implied values.
|
137
|
+
*
|
138
|
+
* @example
|
139
|
+
* program
|
140
|
+
* .addOption(new Option('--log', 'write logging information to file'))
|
141
|
+
* .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
|
142
|
+
*/
|
143
|
+
implies(optionValues: OptionValues): this;
|
144
|
+
|
102
145
|
/**
|
103
146
|
* Set environment variable to check for option value.
|
104
|
-
*
|
147
|
+
*
|
148
|
+
* An environment variables is only used if when processed the current option value is
|
149
|
+
* undefined, or the source of the current value is 'default' or 'config' or 'env'.
|
105
150
|
*/
|
106
151
|
env(name: string): this;
|
107
152
|
|
@@ -128,7 +173,7 @@ export class Option {
|
|
128
173
|
/**
|
129
174
|
* Only allow option value to be one of choices.
|
130
175
|
*/
|
131
|
-
choices(values: string[]): this;
|
176
|
+
choices(values: readonly string[]): this;
|
132
177
|
|
133
178
|
/**
|
134
179
|
* Return option name.
|
@@ -140,6 +185,13 @@ export class Option {
|
|
140
185
|
* as a object attribute key.
|
141
186
|
*/
|
142
187
|
attributeName(): string;
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Return whether a boolean option.
|
191
|
+
*
|
192
|
+
* Options are one of boolean, negated, required argument, or optional argument.
|
193
|
+
*/
|
194
|
+
isBoolean(): boolean;
|
143
195
|
}
|
144
196
|
|
145
197
|
export class Help {
|
@@ -147,12 +199,13 @@ export class Help {
|
|
147
199
|
helpWidth?: number;
|
148
200
|
sortSubcommands: boolean;
|
149
201
|
sortOptions: boolean;
|
202
|
+
showGlobalOptions: boolean;
|
150
203
|
|
151
204
|
constructor();
|
152
205
|
|
153
206
|
/** Get the command term to show in the list of subcommands. */
|
154
207
|
subcommandTerm(cmd: Command): string;
|
155
|
-
/** Get the command
|
208
|
+
/** Get the command summary to show in the list of subcommands. */
|
156
209
|
subcommandDescription(cmd: Command): string;
|
157
210
|
/** Get the option term to show in the list of options. */
|
158
211
|
optionTerm(option: Option): string;
|
@@ -172,6 +225,8 @@ export class Help {
|
|
172
225
|
visibleCommands(cmd: Command): Command[];
|
173
226
|
/** Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one. */
|
174
227
|
visibleOptions(cmd: Command): Option[];
|
228
|
+
/** Get an array of the visible global options. (Not including help.) */
|
229
|
+
visibleGlobalOptions(cmd: Command): Option[];
|
175
230
|
/** Get an array of the arguments which have descriptions. */
|
176
231
|
visibleArguments(cmd: Command): Argument[];
|
177
232
|
|
@@ -179,6 +234,8 @@ export class Help {
|
|
179
234
|
longestSubcommandTermLength(cmd: Command, helper: Help): number;
|
180
235
|
/** Get the longest option term length. */
|
181
236
|
longestOptionTermLength(cmd: Command, helper: Help): number;
|
237
|
+
/** Get the longest global option term length. */
|
238
|
+
longestGlobalOptionTermLength(cmd: Command, helper: Help): number;
|
182
239
|
/** Get the longest argument term length. */
|
183
240
|
longestArgumentTermLength(cmd: Command, helper: Help): number;
|
184
241
|
/** Calculate the pad width from the maximum term length. */
|
@@ -215,17 +272,16 @@ export interface OutputConfiguration {
|
|
215
272
|
}
|
216
273
|
|
217
274
|
export type AddHelpTextPosition = 'beforeAll' | 'before' | 'after' | 'afterAll';
|
218
|
-
export type HookEvent = 'preAction' | 'postAction';
|
219
|
-
export type OptionValueSource = 'default' | '
|
275
|
+
export type HookEvent = 'preSubcommand' | 'preAction' | 'postAction';
|
276
|
+
export type OptionValueSource = 'default' | 'config' | 'env' | 'cli' | 'implied';
|
220
277
|
|
221
|
-
export
|
222
|
-
[key: string]: any;
|
223
|
-
}
|
278
|
+
export type OptionValues = Record<string, any>;
|
224
279
|
|
225
280
|
export class Command {
|
226
281
|
args: string[];
|
227
282
|
processedArgs: any[];
|
228
|
-
commands: Command[];
|
283
|
+
readonly commands: readonly Command[];
|
284
|
+
readonly options: readonly Option[];
|
229
285
|
parent: Command | null;
|
230
286
|
|
231
287
|
constructor(name?: string);
|
@@ -320,8 +376,8 @@ export class Command {
|
|
320
376
|
*
|
321
377
|
* @returns `this` command for chaining
|
322
378
|
*/
|
323
|
-
|
324
|
-
|
379
|
+
argument<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
|
380
|
+
argument(name: string, description?: string, defaultValue?: unknown): this;
|
325
381
|
|
326
382
|
/**
|
327
383
|
* Define argument syntax for command, adding a prepared argument.
|
@@ -366,7 +422,12 @@ export class Command {
|
|
366
422
|
/**
|
367
423
|
* Register callback to use as replacement for calling process.exit.
|
368
424
|
*/
|
369
|
-
exitOverride(callback?: (err: CommanderError) => never|void): this;
|
425
|
+
exitOverride(callback?: (err: CommanderError) => never | void): this;
|
426
|
+
|
427
|
+
/**
|
428
|
+
* Display error message and exit (or call exitOverride).
|
429
|
+
*/
|
430
|
+
error(message: string, errorOptions?: ErrorOptions): never;
|
370
431
|
|
371
432
|
/**
|
372
433
|
* You can customise the help with a subclass of Help by overriding createHelp,
|
@@ -419,7 +480,7 @@ export class Command {
|
|
419
480
|
*/
|
420
481
|
showSuggestionAfterError(displaySuggestion?: boolean): this;
|
421
482
|
|
422
|
-
|
483
|
+
/**
|
423
484
|
* Register callback `fn` for the command.
|
424
485
|
*
|
425
486
|
* @example
|
@@ -480,10 +541,10 @@ export class Command {
|
|
480
541
|
*
|
481
542
|
* @returns `this` command for chaining
|
482
543
|
*/
|
483
|
-
option(flags: string, description?: string, defaultValue?: string | boolean): this;
|
544
|
+
option(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
|
484
545
|
option<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
|
485
546
|
/** @deprecated since v7, instead use choices or a custom function */
|
486
|
-
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;
|
547
|
+
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
|
487
548
|
|
488
549
|
/**
|
489
550
|
* Define a required option, which must have a value after parsing. This usually means
|
@@ -491,10 +552,10 @@ export class Command {
|
|
491
552
|
*
|
492
553
|
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
|
493
554
|
*/
|
494
|
-
requiredOption(flags: string, description?: string, defaultValue?: string | boolean): this;
|
555
|
+
requiredOption(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
|
495
556
|
requiredOption<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
|
496
557
|
/** @deprecated since v7, instead use choices or a custom function */
|
497
|
-
requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;
|
558
|
+
requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
|
498
559
|
|
499
560
|
/**
|
500
561
|
* Factory routine to create a new unattached option.
|
@@ -538,11 +599,16 @@ export class Command {
|
|
538
599
|
setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this;
|
539
600
|
|
540
601
|
/**
|
541
|
-
*
|
602
|
+
* Get source of option value.
|
603
|
+
*/
|
604
|
+
getOptionValueSource(key: string): OptionValueSource | undefined;
|
605
|
+
|
606
|
+
/**
|
607
|
+
* Get source of option value. See also .optsWithGlobals().
|
542
608
|
*/
|
543
|
-
|
609
|
+
getOptionValueSourceWithGlobals(key: string): OptionValueSource | undefined;
|
544
610
|
|
545
|
-
|
611
|
+
/**
|
546
612
|
* Alter parsing of short flags with optional values.
|
547
613
|
*
|
548
614
|
* @example
|
@@ -606,7 +672,7 @@ export class Command {
|
|
606
672
|
*
|
607
673
|
* @returns `this` command for chaining
|
608
674
|
*/
|
609
|
-
parse(argv?: string[], options?: ParseOptions): this;
|
675
|
+
parse(argv?: readonly string[], options?: ParseOptions): this;
|
610
676
|
|
611
677
|
/**
|
612
678
|
* Parse `argv`, setting options and invoking commands when defined.
|
@@ -625,7 +691,7 @@ export class Command {
|
|
625
691
|
*
|
626
692
|
* @returns Promise
|
627
693
|
*/
|
628
|
-
parseAsync(argv?: string[], options?: ParseOptions): Promise<this>;
|
694
|
+
parseAsync(argv?: readonly string[], options?: ParseOptions): Promise<this>;
|
629
695
|
|
630
696
|
/**
|
631
697
|
* Parse options from `argv` removing known options,
|
@@ -640,10 +706,15 @@ export class Command {
|
|
640
706
|
parseOptions(argv: string[]): ParseOptionsResult;
|
641
707
|
|
642
708
|
/**
|
643
|
-
* Return an object containing
|
709
|
+
* Return an object containing local option values as key-value pairs
|
644
710
|
*/
|
645
711
|
opts<T extends OptionValues>(): T;
|
646
712
|
|
713
|
+
/**
|
714
|
+
* Return an object containing merged local and global option values as key-value pairs.
|
715
|
+
*/
|
716
|
+
optsWithGlobals<T extends OptionValues>(): T;
|
717
|
+
|
647
718
|
/**
|
648
719
|
* Set the description.
|
649
720
|
*
|
@@ -652,12 +723,24 @@ export class Command {
|
|
652
723
|
|
653
724
|
description(str: string): this;
|
654
725
|
/** @deprecated since v8, instead use .argument to add command argument with description */
|
655
|
-
description(str: string, argsDescription:
|
726
|
+
description(str: string, argsDescription: Record<string, string>): this;
|
656
727
|
/**
|
657
728
|
* Get the description.
|
658
729
|
*/
|
659
730
|
description(): string;
|
660
731
|
|
732
|
+
/**
|
733
|
+
* Set the summary. Used when listed as subcommand of parent.
|
734
|
+
*
|
735
|
+
* @returns `this` command for chaining
|
736
|
+
*/
|
737
|
+
|
738
|
+
summary(str: string): this;
|
739
|
+
/**
|
740
|
+
* Get the summary.
|
741
|
+
*/
|
742
|
+
summary(): string;
|
743
|
+
|
661
744
|
/**
|
662
745
|
* Set an alias for the command.
|
663
746
|
*
|
@@ -678,7 +761,7 @@ export class Command {
|
|
678
761
|
*
|
679
762
|
* @returns `this` command for chaining
|
680
763
|
*/
|
681
|
-
aliases(aliases: string[]): this;
|
764
|
+
aliases(aliases: readonly string[]): this;
|
682
765
|
/**
|
683
766
|
* Get aliases for the command.
|
684
767
|
*/
|
@@ -706,6 +789,39 @@ export class Command {
|
|
706
789
|
*/
|
707
790
|
name(): string;
|
708
791
|
|
792
|
+
/**
|
793
|
+
* Set the name of the command from script filename, such as process.argv[1],
|
794
|
+
* or require.main.filename, or __filename.
|
795
|
+
*
|
796
|
+
* (Used internally and public although not documented in README.)
|
797
|
+
*
|
798
|
+
* @example
|
799
|
+
* ```ts
|
800
|
+
* program.nameFromFilename(require.main.filename);
|
801
|
+
* ```
|
802
|
+
*
|
803
|
+
* @returns `this` command for chaining
|
804
|
+
*/
|
805
|
+
nameFromFilename(filename: string): this;
|
806
|
+
|
807
|
+
/**
|
808
|
+
* Set the directory for searching for executable subcommands of this command.
|
809
|
+
*
|
810
|
+
* @example
|
811
|
+
* ```ts
|
812
|
+
* program.executableDir(__dirname);
|
813
|
+
* // or
|
814
|
+
* program.executableDir('subcommands');
|
815
|
+
* ```
|
816
|
+
*
|
817
|
+
* @returns `this` command for chaining
|
818
|
+
*/
|
819
|
+
executableDir(path: string): this;
|
820
|
+
/**
|
821
|
+
* Get the executable search directory.
|
822
|
+
*/
|
823
|
+
executableDir(): string;
|
824
|
+
|
709
825
|
/**
|
710
826
|
* Output help information for this command.
|
711
827
|
*
|
package/dist/analyzeProject.js
CHANGED
@@ -52,15 +52,16 @@ __export(analyzeProject_exports, {
|
|
52
52
|
});
|
53
53
|
module.exports = __toCommonJS(analyzeProject_exports);
|
54
54
|
var path = __toESM(require("path"));
|
55
|
+
var import_commands = require("./commands");
|
55
56
|
var import_compiled = require("./compiled");
|
56
57
|
const isApiOnly = (appDirectory, entryDir) => __async(void 0, null, function* () {
|
57
58
|
const srcDir = path.join(appDirectory, entryDir != null ? entryDir : "src");
|
58
59
|
const existSrc = yield import_compiled.fs.pathExists(srcDir);
|
59
|
-
const options = (0, import_compiled.minimist)(
|
60
|
+
const options = (0, import_compiled.minimist)((0, import_commands.getArgv)());
|
60
61
|
return !existSrc || Boolean(options["api-only"]);
|
61
62
|
});
|
62
63
|
const isWebOnly = () => __async(void 0, null, function* () {
|
63
|
-
const options = (0, import_compiled.minimist)(
|
64
|
+
const options = (0, import_compiled.minimist)((0, import_commands.getArgv)());
|
64
65
|
return Boolean(options["web-only"]);
|
65
66
|
});
|
66
67
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/chainId.d.ts
CHANGED
@@ -55,27 +55,10 @@ export declare const CHAIN_ID: {
|
|
55
55
|
/** Predefined rule groups */
|
56
56
|
|
57
57
|
readonly ONE_OF: {
|
58
|
-
readonly JS: "js";
|
59
|
-
readonly TS: "ts";
|
60
|
-
readonly CSS: "css";
|
61
|
-
readonly LESS: "less";
|
62
|
-
readonly SASS: "sass";
|
63
|
-
readonly YAML: "yml";
|
64
|
-
readonly TOML: "toml";
|
65
|
-
readonly FALLBACK: "fallback";
|
66
|
-
readonly MARKDOWN: "markdown";
|
67
|
-
readonly BFF_CLIENT: "bff-client";
|
68
|
-
readonly CSS_MODULES: "css-modules";
|
69
|
-
readonly LESS_MODULES: "less-modules";
|
70
|
-
readonly SASS_MODULES: "sass-modules";
|
71
58
|
readonly SVG: "svg";
|
72
59
|
readonly SVG_URL: "svg-url";
|
73
60
|
readonly SVG_ASSET: "svg-asset";
|
74
61
|
readonly SVG_INLINE: "svg-inline";
|
75
|
-
readonly ASSETS: "assets";
|
76
|
-
readonly ASSETS_URL: "assets-url";
|
77
|
-
readonly ASSETS_INLINE: "assets-inline";
|
78
|
-
readonly IMAGE_COMPRESS: "image-compress";
|
79
62
|
};
|
80
63
|
/** Predefined loaders */
|
81
64
|
|
package/dist/chainId.js
CHANGED
@@ -60,27 +60,10 @@ const CHAIN_ID = {
|
|
60
60
|
},
|
61
61
|
/** Predefined rule groups */
|
62
62
|
ONE_OF: {
|
63
|
-
JS: "js",
|
64
|
-
TS: "ts",
|
65
|
-
CSS: "css",
|
66
|
-
LESS: "less",
|
67
|
-
SASS: "sass",
|
68
|
-
YAML: "yml",
|
69
|
-
TOML: "toml",
|
70
|
-
FALLBACK: "fallback",
|
71
|
-
MARKDOWN: "markdown",
|
72
|
-
BFF_CLIENT: "bff-client",
|
73
|
-
CSS_MODULES: "css-modules",
|
74
|
-
LESS_MODULES: "less-modules",
|
75
|
-
SASS_MODULES: "sass-modules",
|
76
63
|
SVG: "svg",
|
77
64
|
SVG_URL: "svg-url",
|
78
65
|
SVG_ASSET: "svg-asset",
|
79
|
-
SVG_INLINE: "svg-inline"
|
80
|
-
ASSETS: "assets",
|
81
|
-
ASSETS_URL: "assets-url",
|
82
|
-
ASSETS_INLINE: "assets-inline",
|
83
|
-
IMAGE_COMPRESS: "image-compress"
|
66
|
+
SVG_INLINE: "svg-inline"
|
84
67
|
},
|
85
68
|
/** Predefined loaders */
|
86
69
|
USE: {
|
package/dist/commands.d.ts
CHANGED
package/dist/commands.js
CHANGED
@@ -17,12 +17,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
18
|
var commands_exports = {};
|
19
19
|
__export(commands_exports, {
|
20
|
+
getArgv: () => getArgv,
|
20
21
|
getCommand: () => getCommand,
|
22
|
+
getFullArgv: () => getFullArgv,
|
21
23
|
isDevCommand: () => isDevCommand
|
22
24
|
});
|
23
25
|
module.exports = __toCommonJS(commands_exports);
|
26
|
+
const getFullArgv = () => {
|
27
|
+
var _a;
|
28
|
+
return ((_a = process.env.MODERN_ARGV) == null ? void 0 : _a.split(" ")) || process.argv;
|
29
|
+
};
|
30
|
+
const getArgv = () => {
|
31
|
+
return getFullArgv().slice(2);
|
32
|
+
};
|
24
33
|
const getCommand = () => {
|
25
|
-
const args =
|
34
|
+
const args = getArgv();
|
26
35
|
const command = args[0];
|
27
36
|
return command;
|
28
37
|
};
|
@@ -32,6 +41,8 @@ const isDevCommand = () => {
|
|
32
41
|
};
|
33
42
|
// Annotate the CommonJS export names for ESM import in node:
|
34
43
|
0 && (module.exports = {
|
44
|
+
getArgv,
|
35
45
|
getCommand,
|
46
|
+
getFullArgv,
|
36
47
|
isDevCommand
|
37
48
|
});
|
package/dist/constants.d.ts
CHANGED
@@ -1,9 +1,4 @@
|
|
1
1
|
import { InternalPlugins } from '@modern-js/types';
|
2
|
-
/**
|
3
|
-
* hmr socket connect path
|
4
|
-
*/
|
5
|
-
|
6
|
-
export declare const HMR_SOCK_PATH = "/webpack-hmr";
|
7
2
|
/**
|
8
3
|
* route specification file
|
9
4
|
*/
|
@@ -71,12 +66,7 @@ export declare const DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
|
|
71
66
|
* Routes manifest filename
|
72
67
|
*/
|
73
68
|
|
74
|
-
export declare const
|
75
|
-
/**
|
76
|
-
* Property mounted on window that describes route manifest
|
77
|
-
*/
|
78
|
-
|
79
|
-
export declare const ROUTE_MANIFEST = "_MODERNJS_ROUTE_MANIFEST";
|
69
|
+
export declare const ROUTE_MANIFEST_FILE = "routes-manifest.json";
|
80
70
|
/**
|
81
71
|
* directory name for loader routes
|
82
72
|
*/
|
@@ -236,4 +226,19 @@ export declare const PLUGIN_SCHEMAS: {
|
|
236
226
|
};
|
237
227
|
}[];
|
238
228
|
'@modern-js/plugin-nocode': never[];
|
229
|
+
};
|
230
|
+
/**
|
231
|
+
* The `@babel/preset-typescript` default options.
|
232
|
+
*
|
233
|
+
* for:
|
234
|
+
* - `@modern-js/builder-rspack-provider`
|
235
|
+
* - `@modern-js/babel-preset-base`
|
236
|
+
*/
|
237
|
+
|
238
|
+
export declare const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS: {
|
239
|
+
allowNamespaces: boolean;
|
240
|
+
allExtensions: boolean;
|
241
|
+
allowDeclareFields: boolean;
|
242
|
+
optimizeConstEnums: boolean;
|
243
|
+
isTSX: boolean;
|
239
244
|
};
|
package/dist/constants.js
CHANGED
@@ -20,10 +20,10 @@ __export(constants_exports, {
|
|
20
20
|
API_DIR: () => API_DIR,
|
21
21
|
CONFIG_CACHE_DIR: () => CONFIG_CACHE_DIR,
|
22
22
|
CONFIG_FILE_EXTENSIONS: () => CONFIG_FILE_EXTENSIONS,
|
23
|
+
DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS: () => DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS,
|
23
24
|
DEFAULT_DEV_HOST: () => DEFAULT_DEV_HOST,
|
24
25
|
DEFAULT_SERVER_CONFIG: () => DEFAULT_SERVER_CONFIG,
|
25
26
|
ENTRY_NAME_PATTERN: () => ENTRY_NAME_PATTERN,
|
26
|
-
HMR_SOCK_PATH: () => HMR_SOCK_PATH,
|
27
27
|
INTERNAL_APP_TOOLS_PLUGINS: () => INTERNAL_APP_TOOLS_PLUGINS,
|
28
28
|
INTERNAL_APP_TOOLS_RUNTIME_PLUGINS: () => INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
|
29
29
|
INTERNAL_CLI_PLUGINS: () => INTERNAL_CLI_PLUGINS,
|
@@ -37,8 +37,7 @@ __export(constants_exports, {
|
|
37
37
|
MAIN_ENTRY_NAME: () => MAIN_ENTRY_NAME,
|
38
38
|
OUTPUT_CONFIG_FILE: () => OUTPUT_CONFIG_FILE,
|
39
39
|
PLUGIN_SCHEMAS: () => PLUGIN_SCHEMAS,
|
40
|
-
|
41
|
-
ROUTE_MINIFEST_FILE: () => ROUTE_MINIFEST_FILE,
|
40
|
+
ROUTE_MANIFEST_FILE: () => ROUTE_MANIFEST_FILE,
|
42
41
|
ROUTE_SPEC_FILE: () => ROUTE_SPEC_FILE,
|
43
42
|
SERVER_BUNDLE_DIRECTORY: () => SERVER_BUNDLE_DIRECTORY,
|
44
43
|
SERVER_DIR: () => SERVER_DIR,
|
@@ -54,7 +53,6 @@ __export(constants_exports, {
|
|
54
53
|
SHARED_DIR: () => SHARED_DIR
|
55
54
|
});
|
56
55
|
module.exports = __toCommonJS(constants_exports);
|
57
|
-
const HMR_SOCK_PATH = "/webpack-hmr";
|
58
56
|
const ROUTE_SPEC_FILE = "route.json";
|
59
57
|
const MAIN_ENTRY_NAME = "main";
|
60
58
|
const LAUNCH_EDITOR_ENDPOINT = "/__open-stack-frame-in-editor";
|
@@ -70,8 +68,7 @@ const CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
|
|
70
68
|
const CONFIG_FILE_EXTENSIONS = [".js", ".ts", ".mjs"];
|
71
69
|
const OUTPUT_CONFIG_FILE = "modern.config.json";
|
72
70
|
const DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
|
73
|
-
const
|
74
|
-
const ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
|
71
|
+
const ROUTE_MANIFEST_FILE = "routes-manifest.json";
|
75
72
|
const LOADER_ROUTES_DIR = `loader-routes`;
|
76
73
|
const DEFAULT_DEV_HOST = "0.0.0.0";
|
77
74
|
const INTERNAL_APP_TOOLS_PLUGINS = {
|
@@ -275,15 +272,24 @@ const PLUGIN_SCHEMAS = {
|
|
275
272
|
],
|
276
273
|
"@modern-js/plugin-nocode": []
|
277
274
|
};
|
275
|
+
const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
276
|
+
allowNamespaces: true,
|
277
|
+
allExtensions: true,
|
278
|
+
allowDeclareFields: true,
|
279
|
+
// aligns Babel's behavior with TypeScript's default behavior.
|
280
|
+
// https://babeljs.io/docs/en/babel-preset-typescript#optimizeconstenums
|
281
|
+
optimizeConstEnums: true,
|
282
|
+
isTSX: true
|
283
|
+
};
|
278
284
|
// Annotate the CommonJS export names for ESM import in node:
|
279
285
|
0 && (module.exports = {
|
280
286
|
API_DIR,
|
281
287
|
CONFIG_CACHE_DIR,
|
282
288
|
CONFIG_FILE_EXTENSIONS,
|
289
|
+
DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS,
|
283
290
|
DEFAULT_DEV_HOST,
|
284
291
|
DEFAULT_SERVER_CONFIG,
|
285
292
|
ENTRY_NAME_PATTERN,
|
286
|
-
HMR_SOCK_PATH,
|
287
293
|
INTERNAL_APP_TOOLS_PLUGINS,
|
288
294
|
INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
|
289
295
|
INTERNAL_CLI_PLUGINS,
|
@@ -297,8 +303,7 @@ const PLUGIN_SCHEMAS = {
|
|
297
303
|
MAIN_ENTRY_NAME,
|
298
304
|
OUTPUT_CONFIG_FILE,
|
299
305
|
PLUGIN_SCHEMAS,
|
300
|
-
|
301
|
-
ROUTE_MINIFEST_FILE,
|
306
|
+
ROUTE_MANIFEST_FILE,
|
302
307
|
ROUTE_SPEC_FILE,
|
303
308
|
SERVER_BUNDLE_DIRECTORY,
|
304
309
|
SERVER_DIR,
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
export * from './compiled';
|
2
2
|
export * from './commands';
|
3
|
-
export * from './format';
|
4
3
|
export * from './FileSizeReporter';
|
5
4
|
export * from './printBuildError';
|
6
5
|
export * from './debug';
|
@@ -32,7 +31,7 @@ export * from './nodeEnv';
|
|
32
31
|
export * from './wait';
|
33
32
|
export * from './emptyDir';
|
34
33
|
export * from './getServerConfig';
|
35
|
-
export * from './
|
34
|
+
export * from './resolve';
|
36
35
|
export * from './analyzeProject';
|
37
36
|
export * from './chainId';
|
38
37
|
export * from './version';
|
package/dist/index.js
CHANGED
@@ -16,7 +16,6 @@ var src_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(src_exports);
|
17
17
|
__reExport(src_exports, require("./compiled"), module.exports);
|
18
18
|
__reExport(src_exports, require("./commands"), module.exports);
|
19
|
-
__reExport(src_exports, require("./format"), module.exports);
|
20
19
|
__reExport(src_exports, require("./FileSizeReporter"), module.exports);
|
21
20
|
__reExport(src_exports, require("./printBuildError"), module.exports);
|
22
21
|
__reExport(src_exports, require("./debug"), module.exports);
|
@@ -48,7 +47,7 @@ __reExport(src_exports, require("./nodeEnv"), module.exports);
|
|
48
47
|
__reExport(src_exports, require("./wait"), module.exports);
|
49
48
|
__reExport(src_exports, require("./emptyDir"), module.exports);
|
50
49
|
__reExport(src_exports, require("./getServerConfig"), module.exports);
|
51
|
-
__reExport(src_exports, require("./
|
50
|
+
__reExport(src_exports, require("./resolve"), module.exports);
|
52
51
|
__reExport(src_exports, require("./analyzeProject"), module.exports);
|
53
52
|
__reExport(src_exports, require("./chainId"), module.exports);
|
54
53
|
__reExport(src_exports, require("./version"), module.exports);
|
@@ -1,8 +1,9 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import os from 'os';
|
3
3
|
export declare const getIpv4Interfaces: () => os.NetworkInterfaceInfo[];
|
4
|
-
export
|
5
|
-
|
4
|
+
export type AddressUrl = {
|
5
|
+
label: string;
|
6
6
|
url: string;
|
7
|
-
}
|
7
|
+
};
|
8
|
+
export declare const getAddressUrls: (protocol: string | undefined, port: number) => AddressUrl[];
|
8
9
|
export declare const prettyInstructions: (appContext: any, config: any) => string;
|
@@ -51,19 +51,16 @@ const getIpv4Interfaces = () => {
|
|
51
51
|
};
|
52
52
|
const getAddressUrls = (protocol = "http", port) => {
|
53
53
|
const ipv4Interfaces = getIpv4Interfaces();
|
54
|
-
return ipv4Interfaces.reduce(
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
},
|
65
|
-
[]
|
66
|
-
);
|
54
|
+
return ipv4Interfaces.reduce((memo, detail) => {
|
55
|
+
let label = "Network: ";
|
56
|
+
let url = `${protocol}://${detail.address}:${port}`;
|
57
|
+
if (detail.address.includes(`localhost`) || detail.internal) {
|
58
|
+
label = "Local: ";
|
59
|
+
url = `${protocol}://localhost:${port}`;
|
60
|
+
}
|
61
|
+
memo.push({ label, url });
|
62
|
+
return memo;
|
63
|
+
}, []);
|
67
64
|
};
|
68
65
|
const prettyInstructions = (appContext, config) => {
|
69
66
|
const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
|
@@ -75,15 +72,15 @@ const prettyInstructions = (appContext, config) => {
|
|
75
72
|
let message = "App running at:\n\n";
|
76
73
|
if ((0, import_is.isSingleEntry)(entrypoints) || apiOnly) {
|
77
74
|
message += urls.map(
|
78
|
-
({
|
75
|
+
({ label, url }) => ` ${import_compiled.chalk.bold(`> ${label.padEnd(10)}`)}${import_compiled.chalk.cyanBright(
|
79
76
|
normalizeUrl(`${url}/${routes[0].urlPath}`)
|
80
77
|
)}
|
81
78
|
`
|
82
79
|
).join("");
|
83
80
|
} else {
|
84
81
|
const maxNameLength = Math.max(...routes.map((r) => r.entryName.length));
|
85
|
-
urls.forEach(({
|
86
|
-
message += ` ${import_compiled.chalk.bold(`> ${
|
82
|
+
urls.forEach(({ label, url }) => {
|
83
|
+
message += ` ${import_compiled.chalk.bold(`> ${label}`)}
|
87
84
|
`;
|
88
85
|
routes.forEach(({ entryName, urlPath, isSSR }) => {
|
89
86
|
if (!checkedEntries.includes(entryName)) {
|
@@ -9,4 +9,5 @@ export declare const tryResolve: (name: string, resolvePath: string) => string;
|
|
9
9
|
* Try to resolve npm package, return true if package is installed.
|
10
10
|
*/
|
11
11
|
|
12
|
-
export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
|
12
|
+
export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
|
13
|
+
export declare const getAntdMajorVersion: (appDirectory: string) => number | null;
|
@@ -15,12 +15,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var
|
19
|
-
__export(
|
18
|
+
var resolve_exports = {};
|
19
|
+
__export(resolve_exports, {
|
20
|
+
getAntdMajorVersion: () => getAntdMajorVersion,
|
20
21
|
isPackageInstalled: () => isPackageInstalled,
|
21
22
|
tryResolve: () => tryResolve
|
22
23
|
});
|
23
|
-
module.exports = __toCommonJS(
|
24
|
+
module.exports = __toCommonJS(resolve_exports);
|
24
25
|
var import_ensureArray = require("./ensureArray");
|
25
26
|
const tryResolve = (name, resolvePath) => {
|
26
27
|
let filePath = "";
|
@@ -43,8 +44,20 @@ const isPackageInstalled = (name, resolvePaths) => {
|
|
43
44
|
return false;
|
44
45
|
}
|
45
46
|
};
|
47
|
+
const getAntdMajorVersion = (appDirectory) => {
|
48
|
+
try {
|
49
|
+
const pkgJsonPath = require.resolve("antd/package.json", {
|
50
|
+
paths: [appDirectory]
|
51
|
+
});
|
52
|
+
const { version } = require(pkgJsonPath);
|
53
|
+
return Number(version.split(".")[0]);
|
54
|
+
} catch (err) {
|
55
|
+
return null;
|
56
|
+
}
|
57
|
+
};
|
46
58
|
// Annotate the CommonJS export names for ESM import in node:
|
47
59
|
0 && (module.exports = {
|
60
|
+
getAntdMajorVersion,
|
48
61
|
isPackageInstalled,
|
49
62
|
tryResolve
|
50
63
|
});
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var constants_exports = {};
|
19
|
+
__export(constants_exports, {
|
20
|
+
HMR_SOCK_PATH: () => HMR_SOCK_PATH,
|
21
|
+
ROUTE_MANIFEST: () => ROUTE_MANIFEST
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(constants_exports);
|
24
|
+
const ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
|
25
|
+
const HMR_SOCK_PATH = "/webpack-hmr";
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
27
|
+
0 && (module.exports = {
|
28
|
+
HMR_SOCK_PATH,
|
29
|
+
ROUTE_MANIFEST
|
30
|
+
});
|
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var
|
19
|
-
__export(
|
18
|
+
var formatWebpack_exports = {};
|
19
|
+
__export(formatWebpack_exports, {
|
20
20
|
formatWebpackMessages: () => formatWebpackMessages
|
21
21
|
});
|
22
|
-
module.exports = __toCommonJS(
|
22
|
+
module.exports = __toCommonJS(formatWebpack_exports);
|
23
23
|
const friendlySyntaxErrorLabel = "SyntaxError:";
|
24
24
|
function isLikelyASyntaxError(message) {
|
25
25
|
return message.includes(friendlySyntaxErrorLabel);
|
@@ -1,11 +1,8 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
|
3
|
-
/**
|
4
|
-
* runtime utils for nested routes generating
|
5
|
-
*/
|
6
2
|
import type { NestedRoute } from '@modern-js/types';
|
7
3
|
export declare const transformNestedRoutes: (routes: NestedRoute[]) => import("react-router-dom").RouteObject[];
|
8
4
|
export declare const renderNestedRoute: (nestedRoute: NestedRoute, options?: {
|
9
5
|
parent?: NestedRoute;
|
10
6
|
DeferredDataComponent?: () => JSX.Element | null;
|
7
|
+
props?: Record<string, any>;
|
11
8
|
}) => JSX.Element;
|
@@ -52,7 +52,7 @@ const transformNestedRoutes = (routes) => {
|
|
52
52
|
const renderNestedRoute = (nestedRoute, options = {}) => {
|
53
53
|
const { children, index, id, component, isRoot, lazyImport } = nestedRoute;
|
54
54
|
const Component = component;
|
55
|
-
const { parent, DeferredDataComponent } = options;
|
55
|
+
const { parent, DeferredDataComponent, props = {} } = options;
|
56
56
|
const routeProps = {
|
57
57
|
caseSensitive: nestedRoute.caseSensitive,
|
58
58
|
path: nestedRoute.path,
|
@@ -83,7 +83,7 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
|
|
83
83
|
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
|
84
84
|
} else if (isRoot) {
|
85
85
|
element = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
86
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}),
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadValues({}, props)),
|
87
87
|
typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeferredDataComponent, {})
|
88
88
|
] });
|
89
89
|
} else if (lazyImport) {
|
@@ -12,6 +12,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
12
12
|
};
|
13
13
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
15
|
-
var
|
16
|
-
module.exports = __toCommonJS(
|
17
|
-
__reExport(
|
15
|
+
var remixRouter_exports = {};
|
16
|
+
module.exports = __toCommonJS(remixRouter_exports);
|
17
|
+
__reExport(remixRouter_exports, require("@remix-run/router"), module.exports);
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.
|
14
|
+
"version": "2.12.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/index.d.ts",
|
17
17
|
"main": "./dist/index.js",
|
@@ -20,13 +20,10 @@
|
|
20
20
|
"exports": {
|
21
21
|
".": "./dist/index.js",
|
22
22
|
"./ssr": "./dist/ssr.js",
|
23
|
-
"./
|
23
|
+
"./babel": "./dist/babel.js",
|
24
24
|
"./logger": "./dist/logger.js",
|
25
|
+
"./chain-id": "./dist/chainId.js",
|
25
26
|
"./constants": "./dist/constants.js",
|
26
|
-
"./serialize": "./dist/serialize.js",
|
27
|
-
"./nestedRoutes": "./dist/nestedRoutes.js",
|
28
|
-
"./remix-router": "./dist/remix-router.js",
|
29
|
-
"./babel": "./dist/babel.js",
|
30
27
|
"./ajv": "./compiled/ajv/index.js",
|
31
28
|
"./glob": "./compiled/glob/index.js",
|
32
29
|
"./chalk": "./compiled/chalk/index.js",
|
@@ -45,7 +42,11 @@
|
|
45
42
|
"./tsconfig-paths": "./compiled/tsconfig-paths/index.js",
|
46
43
|
"./better-ajv-errors": "./compiled/better-ajv-errors/index.js",
|
47
44
|
"./webpack-dev-middleware": "./compiled/webpack-dev-middleware/index.js",
|
48
|
-
"./
|
45
|
+
"./universal/constants": "./dist/universal/constants.js",
|
46
|
+
"./universal/serialize": "./dist/universal/serialize.js",
|
47
|
+
"./universal/remix-router": "./dist/universal/remixRouter.js",
|
48
|
+
"./universal/format-webpack": "./dist/universal/formatWebpack.js",
|
49
|
+
"./universal/nestedRoutes": "./dist/universal/nestedRoutes.js"
|
49
50
|
},
|
50
51
|
"publishConfig": {
|
51
52
|
"registry": "https://registry.npmjs.org/",
|
@@ -56,21 +57,12 @@
|
|
56
57
|
"ssr": [
|
57
58
|
"./dist/ssr.d.ts"
|
58
59
|
],
|
59
|
-
"format": [
|
60
|
-
"./dist/format.d.ts"
|
61
|
-
],
|
62
60
|
"logger": [
|
63
61
|
"./dist/logger.d.ts"
|
64
62
|
],
|
65
63
|
"constants": [
|
66
64
|
"./dist/constants.d.ts"
|
67
65
|
],
|
68
|
-
"serialize": [
|
69
|
-
"./dist/serialize.d.ts"
|
70
|
-
],
|
71
|
-
"nestedRoutes": [
|
72
|
-
"./dist/nestedRoutes.d.ts"
|
73
|
-
],
|
74
66
|
"babel": [
|
75
67
|
"./dist/babel.d.ts"
|
76
68
|
],
|
@@ -89,6 +81,9 @@
|
|
89
81
|
"json5": [
|
90
82
|
"./compiled/json5/index.d.ts"
|
91
83
|
],
|
84
|
+
"chain-id": [
|
85
|
+
"./dist/chainId.d.ts"
|
86
|
+
],
|
92
87
|
"semver": [
|
93
88
|
"./compiled/semver/index.d.ts"
|
94
89
|
],
|
@@ -131,11 +126,20 @@
|
|
131
126
|
"webpack-dev-middleware": [
|
132
127
|
"./compiled/webpack-dev-middleware/types/index.d.ts"
|
133
128
|
],
|
134
|
-
"
|
135
|
-
"./dist/
|
129
|
+
"universal/constants": [
|
130
|
+
"./dist/universal/constants.d.ts"
|
131
|
+
],
|
132
|
+
"universal/serialize": [
|
133
|
+
"./dist/universal/serialize.d.ts"
|
134
|
+
],
|
135
|
+
"universal/remix-router": [
|
136
|
+
"./dist/universal/remixRouter.d.ts"
|
137
|
+
],
|
138
|
+
"universal/format-webpack": [
|
139
|
+
"./dist/universal/formatWebpack.d.ts"
|
136
140
|
],
|
137
|
-
"
|
138
|
-
"./dist/
|
141
|
+
"universal/nestedRoutes": [
|
142
|
+
"./dist/universal/nestedRoutes.d.ts"
|
139
143
|
]
|
140
144
|
}
|
141
145
|
},
|
@@ -171,9 +175,9 @@
|
|
171
175
|
"typescript": "^4",
|
172
176
|
"webpack": "^5.76.2",
|
173
177
|
"@types/serialize-javascript": "^5.0.1",
|
174
|
-
"@modern-js/types": "2.
|
175
|
-
"@scripts/
|
176
|
-
"@scripts/
|
178
|
+
"@modern-js/types": "2.12.0",
|
179
|
+
"@scripts/build": "2.12.0",
|
180
|
+
"@scripts/jest-config": "2.12.0"
|
177
181
|
},
|
178
182
|
"sideEffects": false,
|
179
183
|
"scripts": {
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|