@modern-js/utils 2.69.7 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/dist/cjs/cli/alias.js +76 -70
  2. package/dist/cjs/cli/applyOptionsChain.js +44 -45
  3. package/dist/cjs/cli/babel.js +100 -119
  4. package/dist/cjs/cli/commands.js +61 -59
  5. package/dist/cjs/cli/common.js +45 -37
  6. package/dist/cjs/cli/config.js +36 -30
  7. package/dist/cjs/cli/constants.js +124 -161
  8. package/dist/cjs/cli/ensure.js +52 -45
  9. package/dist/cjs/cli/fs.js +41 -38
  10. package/dist/cjs/cli/get/config.js +43 -38
  11. package/dist/cjs/cli/get/data.js +108 -125
  12. package/dist/cjs/cli/get/index.js +109 -58
  13. package/dist/cjs/cli/index.js +202 -63
  14. package/dist/cjs/cli/is/config.js +75 -71
  15. package/dist/cjs/cli/is/env.js +49 -37
  16. package/dist/cjs/cli/is/index.js +76 -25
  17. package/dist/cjs/cli/is/project.js +139 -135
  18. package/dist/cjs/cli/is/type.js +65 -49
  19. package/dist/cjs/cli/logger.js +36 -27
  20. package/dist/cjs/cli/monorepo.js +100 -96
  21. package/dist/cjs/cli/package.js +85 -82
  22. package/dist/cjs/cli/path.js +101 -82
  23. package/dist/cjs/cli/port.js +71 -74
  24. package/dist/cjs/cli/prettyInstructions.js +106 -116
  25. package/dist/cjs/cli/require.js +116 -136
  26. package/dist/cjs/cli/route.js +67 -77
  27. package/dist/cjs/cli/runtimeExports.js +16 -70
  28. package/dist/cjs/cli/version.js +53 -42
  29. package/dist/cjs/cli/watch.js +79 -72
  30. package/dist/cjs/compiled.js +199 -128
  31. package/dist/cjs/import.js +58 -33
  32. package/dist/cjs/index.js +69 -23
  33. package/dist/cjs/universal/constants.js +77 -67
  34. package/dist/cjs/universal/index.js +33 -25
  35. package/dist/cjs/universal/path.js +33 -27
  36. package/dist/cjs/universal/pluginDagSort.js +69 -68
  37. package/dist/compiled/address/index.js +171 -1
  38. package/dist/compiled/browserslist/index.js +1329 -1
  39. package/dist/compiled/chalk/index.js +2368 -1
  40. package/dist/compiled/chokidar/index.js +4138 -16
  41. package/dist/compiled/chokidar/index.js.LICENSE.txt +41 -0
  42. package/dist/compiled/commander/index.js +1540 -1
  43. package/dist/compiled/debug/index.js +621 -1
  44. package/dist/compiled/dotenv/index.js +101 -1
  45. package/dist/compiled/dotenv-expand/index.js +54 -1
  46. package/dist/compiled/execa/index.js +1738 -1
  47. package/dist/compiled/fast-glob/index.js +4645 -17
  48. package/dist/compiled/fast-glob/index.js.LICENSE.txt +38 -0
  49. package/dist/compiled/filesize/index.js +193 -4
  50. package/dist/compiled/filesize/index.js.LICENSE.txt +7 -0
  51. package/dist/compiled/fs-extra/index.js +2222 -1
  52. package/dist/compiled/glob/index.js +2011 -1
  53. package/dist/compiled/globby/index.js +690 -1
  54. package/dist/compiled/gzip-size/index.js +157 -1
  55. package/dist/compiled/import-lazy/index.js +45 -1
  56. package/dist/compiled/inquirer/index.js +20162 -4
  57. package/dist/compiled/inquirer/index.js.LICENSE.txt +7 -0
  58. package/dist/compiled/js-yaml/index.js +2188 -1
  59. package/dist/compiled/json5/index.js +983 -1
  60. package/dist/compiled/lodash/index.js +0 -4
  61. package/dist/compiled/mime-types/index.js +108 -6
  62. package/dist/compiled/mime-types/index.js.LICENSE.txt +13 -0
  63. package/dist/compiled/minimist/index.js +202 -1
  64. package/dist/compiled/nanoid/index.js +83 -1
  65. package/dist/compiled/ora/index.js +3936 -3
  66. package/dist/compiled/ora/index.js.LICENSE.txt +1 -0
  67. package/dist/compiled/pkg-up/index.js +177 -1
  68. package/dist/compiled/semver/index.js +1779 -1
  69. package/dist/compiled/signale/index.js +1704 -1
  70. package/dist/compiled/slash/index.js +32 -1
  71. package/dist/compiled/strip-ansi/index.js +34 -1
  72. package/dist/compiled/tsconfig-paths/index.js +629 -1
  73. package/dist/compiled/upath/index.js +135 -1
  74. package/dist/compiled/url-join/index.js +61 -1
  75. package/dist/compiled/webpack-chain/index.js +1475 -1
  76. package/dist/esm/cli/alias.mjs +31 -0
  77. package/dist/esm/cli/applyOptionsChain.mjs +16 -0
  78. package/dist/esm/cli/babel.mjs +76 -0
  79. package/dist/esm/cli/commands.mjs +23 -0
  80. package/dist/esm/cli/common.mjs +11 -0
  81. package/dist/esm/cli/config.mjs +5 -0
  82. package/dist/esm/cli/constants.mjs +29 -0
  83. package/dist/esm/cli/ensure.mjs +9 -0
  84. package/dist/esm/cli/fs.mjs +9 -0
  85. package/dist/esm/cli/get/config.mjs +14 -0
  86. package/dist/esm/cli/get/data.mjs +57 -0
  87. package/dist/esm/cli/get/index.mjs +18 -0
  88. package/dist/{esm-node/cli/index.js → esm/cli/index.mjs} +0 -1
  89. package/dist/esm/cli/is/config.mjs +34 -0
  90. package/dist/esm/cli/is/env.mjs +6 -0
  91. package/dist/esm/cli/is/project.mjs +104 -0
  92. package/dist/esm/cli/is/type.mjs +26 -0
  93. package/dist/esm/cli/logger.mjs +2 -0
  94. package/dist/esm/cli/monorepo.mjs +50 -0
  95. package/dist/esm/cli/package.mjs +51 -0
  96. package/dist/esm/cli/path.mjs +35 -0
  97. package/dist/esm/cli/port.mjs +35 -0
  98. package/dist/esm/cli/prettyInstructions.mjs +68 -0
  99. package/dist/esm/cli/require.mjs +79 -0
  100. package/dist/esm/cli/route.mjs +36 -0
  101. package/dist/esm/cli/runtimeExports.mjs +0 -0
  102. package/dist/esm/cli/version.mjs +21 -0
  103. package/dist/esm/cli/watch.mjs +40 -0
  104. package/dist/esm/compiled.mjs +115 -0
  105. package/dist/esm/import.mjs +25 -0
  106. package/dist/esm/universal/constants.mjs +13 -0
  107. package/dist/{esm-node/universal/index.js → esm/universal/index.mjs} +1 -3
  108. package/dist/esm/universal/path.mjs +2 -0
  109. package/dist/esm/universal/pluginDagSort.mjs +41 -0
  110. package/dist/esm-node/cli/alias.mjs +31 -0
  111. package/dist/esm-node/cli/applyOptionsChain.mjs +16 -0
  112. package/dist/esm-node/cli/babel.mjs +76 -0
  113. package/dist/esm-node/cli/commands.mjs +23 -0
  114. package/dist/esm-node/cli/common.mjs +11 -0
  115. package/dist/esm-node/cli/config.mjs +5 -0
  116. package/dist/esm-node/cli/constants.mjs +29 -0
  117. package/dist/esm-node/cli/ensure.mjs +9 -0
  118. package/dist/esm-node/cli/fs.mjs +9 -0
  119. package/dist/esm-node/cli/get/config.mjs +14 -0
  120. package/dist/esm-node/cli/get/data.mjs +57 -0
  121. package/dist/esm-node/cli/get/index.mjs +18 -0
  122. package/dist/esm-node/cli/index.mjs +22 -0
  123. package/dist/esm-node/cli/is/config.mjs +34 -0
  124. package/dist/esm-node/cli/is/env.mjs +6 -0
  125. package/dist/esm-node/cli/is/index.mjs +4 -0
  126. package/dist/esm-node/cli/is/project.mjs +104 -0
  127. package/dist/esm-node/cli/is/type.mjs +26 -0
  128. package/dist/esm-node/cli/logger.mjs +2 -0
  129. package/dist/esm-node/cli/monorepo.mjs +50 -0
  130. package/dist/esm-node/cli/package.mjs +51 -0
  131. package/dist/esm-node/cli/path.mjs +35 -0
  132. package/dist/esm-node/cli/port.mjs +35 -0
  133. package/dist/esm-node/cli/prettyInstructions.mjs +68 -0
  134. package/dist/esm-node/cli/require.mjs +79 -0
  135. package/dist/esm-node/cli/route.mjs +36 -0
  136. package/dist/esm-node/cli/runtimeExports.mjs +0 -0
  137. package/dist/esm-node/cli/version.mjs +21 -0
  138. package/dist/esm-node/cli/watch.mjs +40 -0
  139. package/dist/esm-node/compiled.mjs +115 -0
  140. package/dist/esm-node/import.mjs +25 -0
  141. package/dist/esm-node/index.mjs +3 -0
  142. package/dist/esm-node/universal/constants.mjs +13 -0
  143. package/dist/esm-node/universal/index.mjs +2 -0
  144. package/dist/esm-node/universal/path.mjs +2 -0
  145. package/dist/esm-node/universal/pluginDagSort.mjs +41 -0
  146. package/dist/types/cli/constants.d.ts +2 -26
  147. package/dist/types/cli/get/data.d.ts +0 -1
  148. package/dist/types/cli/index.d.ts +0 -1
  149. package/dist/types/cli/is/config.d.ts +1 -1
  150. package/dist/types/cli/runtimeExports.d.ts +1 -4
  151. package/dist/types/cli/watch.d.ts +1 -1
  152. package/dist/types/compiled.d.ts +0 -5
  153. package/dist/types/universal/constants.d.ts +4 -7
  154. package/package.json +27 -27
  155. package/rslib.config.mts +140 -0
  156. package/dist/cjs/cli/action.js +0 -55
  157. package/dist/cjs/universal/formatWebpack.js +0 -127
  158. package/dist/esm/cli/action.js +0 -68
  159. package/dist/esm/cli/alias.js +0 -43
  160. package/dist/esm/cli/applyOptionsChain.js +0 -29
  161. package/dist/esm/cli/babel.js +0 -122
  162. package/dist/esm/cli/commands.js +0 -39
  163. package/dist/esm/cli/common.js +0 -20
  164. package/dist/esm/cli/config.js +0 -11
  165. package/dist/esm/cli/constants.js +0 -114
  166. package/dist/esm/cli/ensure.js +0 -16
  167. package/dist/esm/cli/fs.js +0 -65
  168. package/dist/esm/cli/get/config.js +0 -19
  169. package/dist/esm/cli/get/data.js +0 -143
  170. package/dist/esm/cli/get/index.js +0 -38
  171. package/dist/esm/cli/index.js +0 -23
  172. package/dist/esm/cli/is/config.js +0 -70
  173. package/dist/esm/cli/is/env.js +0 -22
  174. package/dist/esm/cli/is/index.js +0 -4
  175. package/dist/esm/cli/is/project.js +0 -146
  176. package/dist/esm/cli/is/type.js +0 -39
  177. package/dist/esm/cli/logger.js +0 -5
  178. package/dist/esm/cli/monorepo.js +0 -82
  179. package/dist/esm/cli/package.js +0 -203
  180. package/dist/esm/cli/path.js +0 -66
  181. package/dist/esm/cli/port.js +0 -97
  182. package/dist/esm/cli/prettyInstructions.js +0 -102
  183. package/dist/esm/cli/require.js +0 -235
  184. package/dist/esm/cli/route.js +0 -64
  185. package/dist/esm/cli/runtimeExports.js +0 -44
  186. package/dist/esm/cli/version.js +0 -26
  187. package/dist/esm/cli/watch.js +0 -112
  188. package/dist/esm/compiled.js +0 -66
  189. package/dist/esm/import.js +0 -11
  190. package/dist/esm/index.js +0 -3
  191. package/dist/esm/universal/constants.js +0 -32
  192. package/dist/esm/universal/formatWebpack.js +0 -95
  193. package/dist/esm/universal/index.js +0 -4
  194. package/dist/esm/universal/path.js +0 -6
  195. package/dist/esm/universal/pluginDagSort.js +0 -73
  196. package/dist/esm-node/cli/action.js +0 -30
  197. package/dist/esm-node/cli/alias.js +0 -40
  198. package/dist/esm-node/cli/applyOptionsChain.js +0 -27
  199. package/dist/esm-node/cli/babel.js +0 -107
  200. package/dist/esm-node/cli/commands.js +0 -39
  201. package/dist/esm-node/cli/common.js +0 -15
  202. package/dist/esm-node/cli/config.js +0 -9
  203. package/dist/esm-node/cli/constants.js +0 -114
  204. package/dist/esm-node/cli/ensure.js +0 -14
  205. package/dist/esm-node/cli/fs.js +0 -18
  206. package/dist/esm-node/cli/get/config.js +0 -19
  207. package/dist/esm-node/cli/get/data.js +0 -96
  208. package/dist/esm-node/cli/get/index.js +0 -22
  209. package/dist/esm-node/cli/is/config.js +0 -50
  210. package/dist/esm-node/cli/is/env.js +0 -12
  211. package/dist/esm-node/cli/is/project.js +0 -105
  212. package/dist/esm-node/cli/is/type.js +0 -36
  213. package/dist/esm-node/cli/logger.js +0 -5
  214. package/dist/esm-node/cli/monorepo.js +0 -67
  215. package/dist/esm-node/cli/package.js +0 -66
  216. package/dist/esm-node/cli/path.js +0 -48
  217. package/dist/esm-node/cli/port.js +0 -48
  218. package/dist/esm-node/cli/prettyInstructions.js +0 -90
  219. package/dist/esm-node/cli/require.js +0 -111
  220. package/dist/esm-node/cli/route.js +0 -60
  221. package/dist/esm-node/cli/runtimeExports.js +0 -38
  222. package/dist/esm-node/cli/version.js +0 -26
  223. package/dist/esm-node/cli/watch.js +0 -45
  224. package/dist/esm-node/compiled.js +0 -66
  225. package/dist/esm-node/import.js +0 -11
  226. package/dist/esm-node/universal/constants.js +0 -32
  227. package/dist/esm-node/universal/formatWebpack.js +0 -102
  228. package/dist/esm-node/universal/path.js +0 -6
  229. package/dist/esm-node/universal/pluginDagSort.js +0 -50
  230. package/dist/types/cli/action.d.ts +0 -2
  231. package/dist/types/universal/formatWebpack.d.ts +0 -26
  232. /package/dist/{esm-node/cli/is/index.js → esm/cli/is/index.mjs} +0 -0
  233. /package/dist/{esm-node/index.js → esm/index.mjs} +0 -0
@@ -1 +1,1540 @@
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
+ (()=>{
2
+ var t = {
3
+ 81: (t)=>{
4
+ "use strict";
5
+ t.exports = require("child_process");
6
+ },
7
+ 361: (t)=>{
8
+ "use strict";
9
+ t.exports = require("events");
10
+ },
11
+ 147: (t)=>{
12
+ "use strict";
13
+ t.exports = require("fs");
14
+ },
15
+ 17: (t)=>{
16
+ "use strict";
17
+ t.exports = require("path");
18
+ },
19
+ 282: (t)=>{
20
+ "use strict";
21
+ t.exports = require("process");
22
+ },
23
+ 632: (t, e, i)=>{
24
+ const { Argument: n } = i(535);
25
+ const { Command: s } = i(302);
26
+ const { CommanderError: r, InvalidArgumentError: o } = i(796);
27
+ const { Help: a } = i(519);
28
+ const { Option: l } = i(437);
29
+ e = t.exports = new s;
30
+ e.program = e;
31
+ e.Argument = n;
32
+ e.Command = s;
33
+ e.CommanderError = r;
34
+ e.Help = a;
35
+ e.InvalidArgumentError = o;
36
+ e.InvalidOptionArgumentError = o;
37
+ e.Option = l;
38
+ },
39
+ 535: (t, e, i)=>{
40
+ const { InvalidArgumentError: n } = i(796);
41
+ class Argument {
42
+ constructor(t, e){
43
+ this.description = e || "";
44
+ this.variadic = false;
45
+ this.parseArg = void 0;
46
+ this.defaultValue = void 0;
47
+ this.defaultValueDescription = void 0;
48
+ this.argChoices = void 0;
49
+ switch(t[0]){
50
+ case "<":
51
+ this.required = true;
52
+ this._name = t.slice(1, -1);
53
+ break;
54
+ case "[":
55
+ this.required = false;
56
+ this._name = t.slice(1, -1);
57
+ break;
58
+ default:
59
+ this.required = true;
60
+ this._name = t;
61
+ break;
62
+ }
63
+ if (this._name.length > 3 && "..." === this._name.slice(-3)) {
64
+ this.variadic = true;
65
+ this._name = this._name.slice(0, -3);
66
+ }
67
+ }
68
+ name() {
69
+ return this._name;
70
+ }
71
+ _concatValue(t, e) {
72
+ if (e === this.defaultValue || !Array.isArray(e)) return [
73
+ t
74
+ ];
75
+ return e.concat(t);
76
+ }
77
+ default(t, e) {
78
+ this.defaultValue = t;
79
+ this.defaultValueDescription = e;
80
+ return this;
81
+ }
82
+ argParser(t) {
83
+ this.parseArg = t;
84
+ return this;
85
+ }
86
+ choices(t) {
87
+ this.argChoices = t.slice();
88
+ this.parseArg = (t, e)=>{
89
+ if (!this.argChoices.includes(t)) throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`);
90
+ if (this.variadic) return this._concatValue(t, e);
91
+ return t;
92
+ };
93
+ return this;
94
+ }
95
+ argRequired() {
96
+ this.required = true;
97
+ return this;
98
+ }
99
+ argOptional() {
100
+ this.required = false;
101
+ return this;
102
+ }
103
+ }
104
+ function humanReadableArgName(t) {
105
+ const e = t.name() + (true === t.variadic ? "..." : "");
106
+ return t.required ? "<" + e + ">" : "[" + e + "]";
107
+ }
108
+ e.Argument = Argument;
109
+ e.humanReadableArgName = humanReadableArgName;
110
+ },
111
+ 302: (t, e, i)=>{
112
+ const n = i(361).EventEmitter;
113
+ const s = i(81);
114
+ const r = i(17);
115
+ const o = i(147);
116
+ const a = i(282);
117
+ const { Argument: l, humanReadableArgName: h } = i(535);
118
+ const { CommanderError: u } = i(796);
119
+ const { Help: c } = i(519);
120
+ const { Option: p, splitOptionFlags: m, DualOptions: d } = i(437);
121
+ const { suggestSimilar: f } = i(860);
122
+ class Command extends n {
123
+ constructor(t){
124
+ super();
125
+ this.commands = [];
126
+ this.options = [];
127
+ this.parent = null;
128
+ this._allowUnknownOption = false;
129
+ this._allowExcessArguments = true;
130
+ this._args = [];
131
+ this.args = [];
132
+ this.rawArgs = [];
133
+ this.processedArgs = [];
134
+ this._scriptPath = null;
135
+ this._name = t || "";
136
+ this._optionValues = {};
137
+ this._optionValueSources = {};
138
+ this._storeOptionsAsProperties = false;
139
+ this._actionHandler = null;
140
+ this._executableHandler = false;
141
+ this._executableFile = null;
142
+ this._executableDir = null;
143
+ this._defaultCommandName = null;
144
+ this._exitCallback = null;
145
+ this._aliases = [];
146
+ this._combineFlagAndOptionalValue = true;
147
+ this._description = "";
148
+ this._summary = "";
149
+ this._argsDescription = void 0;
150
+ this._enablePositionalOptions = false;
151
+ this._passThroughOptions = false;
152
+ this._lifeCycleHooks = {};
153
+ this._showHelpAfterError = false;
154
+ this._showSuggestionAfterError = true;
155
+ this._outputConfiguration = {
156
+ writeOut: (t)=>a.stdout.write(t),
157
+ writeErr: (t)=>a.stderr.write(t),
158
+ getOutHelpWidth: ()=>a.stdout.isTTY ? a.stdout.columns : void 0,
159
+ getErrHelpWidth: ()=>a.stderr.isTTY ? a.stderr.columns : void 0,
160
+ outputError: (t, e)=>e(t)
161
+ };
162
+ this._hidden = false;
163
+ this._hasHelpOption = true;
164
+ this._helpFlags = "-h, --help";
165
+ this._helpDescription = "display help for command";
166
+ this._helpShortFlag = "-h";
167
+ this._helpLongFlag = "--help";
168
+ this._addImplicitHelpCommand = void 0;
169
+ this._helpCommandName = "help";
170
+ this._helpCommandnameAndArgs = "help [command]";
171
+ this._helpCommandDescription = "display help for command";
172
+ this._helpConfiguration = {};
173
+ }
174
+ copyInheritedSettings(t) {
175
+ this._outputConfiguration = t._outputConfiguration;
176
+ this._hasHelpOption = t._hasHelpOption;
177
+ this._helpFlags = t._helpFlags;
178
+ this._helpDescription = t._helpDescription;
179
+ this._helpShortFlag = t._helpShortFlag;
180
+ this._helpLongFlag = t._helpLongFlag;
181
+ this._helpCommandName = t._helpCommandName;
182
+ this._helpCommandnameAndArgs = t._helpCommandnameAndArgs;
183
+ this._helpCommandDescription = t._helpCommandDescription;
184
+ this._helpConfiguration = t._helpConfiguration;
185
+ this._exitCallback = t._exitCallback;
186
+ this._storeOptionsAsProperties = t._storeOptionsAsProperties;
187
+ this._combineFlagAndOptionalValue = t._combineFlagAndOptionalValue;
188
+ this._allowExcessArguments = t._allowExcessArguments;
189
+ this._enablePositionalOptions = t._enablePositionalOptions;
190
+ this._showHelpAfterError = t._showHelpAfterError;
191
+ this._showSuggestionAfterError = t._showSuggestionAfterError;
192
+ return this;
193
+ }
194
+ command(t, e, i) {
195
+ let n = e;
196
+ let s = i;
197
+ if ("object" == typeof n && null !== n) {
198
+ s = n;
199
+ n = null;
200
+ }
201
+ s = s || {};
202
+ const [, r, o] = t.match(/([^ ]+) *(.*)/);
203
+ const a = this.createCommand(r);
204
+ if (n) {
205
+ a.description(n);
206
+ a._executableHandler = true;
207
+ }
208
+ if (s.isDefault) this._defaultCommandName = a._name;
209
+ a._hidden = !!(s.noHelp || s.hidden);
210
+ a._executableFile = s.executableFile || null;
211
+ if (o) a.arguments(o);
212
+ this.commands.push(a);
213
+ a.parent = this;
214
+ a.copyInheritedSettings(this);
215
+ if (n) return this;
216
+ return a;
217
+ }
218
+ createCommand(t) {
219
+ return new Command(t);
220
+ }
221
+ createHelp() {
222
+ return Object.assign(new c, this.configureHelp());
223
+ }
224
+ configureHelp(t) {
225
+ if (void 0 === t) return this._helpConfiguration;
226
+ this._helpConfiguration = t;
227
+ return this;
228
+ }
229
+ configureOutput(t) {
230
+ if (void 0 === t) return this._outputConfiguration;
231
+ Object.assign(this._outputConfiguration, t);
232
+ return this;
233
+ }
234
+ showHelpAfterError(t = true) {
235
+ if ("string" != typeof t) t = !!t;
236
+ this._showHelpAfterError = t;
237
+ return this;
238
+ }
239
+ showSuggestionAfterError(t = true) {
240
+ this._showSuggestionAfterError = !!t;
241
+ return this;
242
+ }
243
+ addCommand(t, e) {
244
+ if (!t._name) throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`);
245
+ e = e || {};
246
+ if (e.isDefault) this._defaultCommandName = t._name;
247
+ if (e.noHelp || e.hidden) t._hidden = true;
248
+ this.commands.push(t);
249
+ t.parent = this;
250
+ return this;
251
+ }
252
+ createArgument(t, e) {
253
+ return new l(t, e);
254
+ }
255
+ argument(t, e, i, n) {
256
+ const s = this.createArgument(t, e);
257
+ if ("function" == typeof i) s.default(n).argParser(i);
258
+ else s.default(i);
259
+ this.addArgument(s);
260
+ return this;
261
+ }
262
+ arguments(t) {
263
+ t.split(/ +/).forEach((t)=>{
264
+ this.argument(t);
265
+ });
266
+ return this;
267
+ }
268
+ addArgument(t) {
269
+ const e = this._args.slice(-1)[0];
270
+ if (e && e.variadic) throw new Error(`only the last argument can be variadic '${e.name()}'`);
271
+ if (t.required && void 0 !== t.defaultValue && void 0 === t.parseArg) throw new Error(`a default value for a required argument is never used: '${t.name()}'`);
272
+ this._args.push(t);
273
+ return this;
274
+ }
275
+ addHelpCommand(t, e) {
276
+ if (false === t) this._addImplicitHelpCommand = false;
277
+ else {
278
+ this._addImplicitHelpCommand = true;
279
+ if ("string" == typeof t) {
280
+ this._helpCommandName = t.split(" ")[0];
281
+ this._helpCommandnameAndArgs = t;
282
+ }
283
+ this._helpCommandDescription = e || this._helpCommandDescription;
284
+ }
285
+ return this;
286
+ }
287
+ _hasImplicitHelpCommand() {
288
+ if (void 0 === this._addImplicitHelpCommand) return this.commands.length && !this._actionHandler && !this._findCommand("help");
289
+ return this._addImplicitHelpCommand;
290
+ }
291
+ hook(t, e) {
292
+ const i = [
293
+ "preSubcommand",
294
+ "preAction",
295
+ "postAction"
296
+ ];
297
+ if (!i.includes(t)) throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`);
298
+ if (this._lifeCycleHooks[t]) this._lifeCycleHooks[t].push(e);
299
+ else this._lifeCycleHooks[t] = [
300
+ e
301
+ ];
302
+ return this;
303
+ }
304
+ exitOverride(t) {
305
+ if (t) this._exitCallback = t;
306
+ else this._exitCallback = (t)=>{
307
+ if ("commander.executeSubCommandAsync" !== t.code) throw t;
308
+ };
309
+ return this;
310
+ }
311
+ _exit(t, e, i) {
312
+ if (this._exitCallback) this._exitCallback(new u(t, e, i));
313
+ a.exit(t);
314
+ }
315
+ action(t) {
316
+ const listener = (e)=>{
317
+ const i = this._args.length;
318
+ const n = e.slice(0, i);
319
+ if (this._storeOptionsAsProperties) n[i] = this;
320
+ else n[i] = this.opts();
321
+ n.push(this);
322
+ return t.apply(this, n);
323
+ };
324
+ this._actionHandler = listener;
325
+ return this;
326
+ }
327
+ createOption(t, e) {
328
+ return new p(t, e);
329
+ }
330
+ addOption(t) {
331
+ const e = t.name();
332
+ const i = t.attributeName();
333
+ if (t.negate) {
334
+ const e = t.long.replace(/^--no-/, "--");
335
+ if (!this._findOption(e)) this.setOptionValueWithSource(i, void 0 === t.defaultValue ? true : t.defaultValue, "default");
336
+ } else if (void 0 !== t.defaultValue) this.setOptionValueWithSource(i, t.defaultValue, "default");
337
+ this.options.push(t);
338
+ const handleOptionValue = (e, n, s)=>{
339
+ if (null == e && void 0 !== t.presetArg) e = t.presetArg;
340
+ const r = this.getOptionValue(i);
341
+ if (null !== e && t.parseArg) try {
342
+ e = t.parseArg(e, r);
343
+ } catch (t) {
344
+ if ("commander.invalidArgument" === t.code) {
345
+ const e = `${n} ${t.message}`;
346
+ this.error(e, {
347
+ exitCode: t.exitCode,
348
+ code: t.code
349
+ });
350
+ }
351
+ throw t;
352
+ }
353
+ else if (null !== e && t.variadic) e = t._concatValue(e, r);
354
+ if (null == e) e = t.negate ? false : t.isBoolean() || t.optional ? true : "";
355
+ this.setOptionValueWithSource(i, e, s);
356
+ };
357
+ this.on("option:" + e, (e)=>{
358
+ const i = `error: option '${t.flags}' argument '${e}' is invalid.`;
359
+ handleOptionValue(e, i, "cli");
360
+ });
361
+ if (t.envVar) this.on("optionEnv:" + e, (e)=>{
362
+ const i = `error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;
363
+ handleOptionValue(e, i, "env");
364
+ });
365
+ return this;
366
+ }
367
+ _optionEx(t, e, i, n, s) {
368
+ if ("object" == typeof e && e instanceof p) throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
369
+ const r = this.createOption(e, i);
370
+ r.makeOptionMandatory(!!t.mandatory);
371
+ if ("function" == typeof n) r.default(s).argParser(n);
372
+ else if (n instanceof RegExp) {
373
+ const t = n;
374
+ n = (e, i)=>{
375
+ const n = t.exec(e);
376
+ return n ? n[0] : i;
377
+ };
378
+ r.default(s).argParser(n);
379
+ } else r.default(n);
380
+ return this.addOption(r);
381
+ }
382
+ option(t, e, i, n) {
383
+ return this._optionEx({}, t, e, i, n);
384
+ }
385
+ requiredOption(t, e, i, n) {
386
+ return this._optionEx({
387
+ mandatory: true
388
+ }, t, e, i, n);
389
+ }
390
+ combineFlagAndOptionalValue(t = true) {
391
+ this._combineFlagAndOptionalValue = !!t;
392
+ return this;
393
+ }
394
+ allowUnknownOption(t = true) {
395
+ this._allowUnknownOption = !!t;
396
+ return this;
397
+ }
398
+ allowExcessArguments(t = true) {
399
+ this._allowExcessArguments = !!t;
400
+ return this;
401
+ }
402
+ enablePositionalOptions(t = true) {
403
+ this._enablePositionalOptions = !!t;
404
+ return this;
405
+ }
406
+ passThroughOptions(t = true) {
407
+ this._passThroughOptions = !!t;
408
+ if (!!this.parent && t && !this.parent._enablePositionalOptions) throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");
409
+ return this;
410
+ }
411
+ storeOptionsAsProperties(t = true) {
412
+ this._storeOptionsAsProperties = !!t;
413
+ if (this.options.length) throw new Error("call .storeOptionsAsProperties() before adding options");
414
+ return this;
415
+ }
416
+ getOptionValue(t) {
417
+ if (this._storeOptionsAsProperties) return this[t];
418
+ return this._optionValues[t];
419
+ }
420
+ setOptionValue(t, e) {
421
+ return this.setOptionValueWithSource(t, e, void 0);
422
+ }
423
+ setOptionValueWithSource(t, e, i) {
424
+ if (this._storeOptionsAsProperties) this[t] = e;
425
+ else this._optionValues[t] = e;
426
+ this._optionValueSources[t] = i;
427
+ return this;
428
+ }
429
+ getOptionValueSource(t) {
430
+ return this._optionValueSources[t];
431
+ }
432
+ getOptionValueSourceWithGlobals(t) {
433
+ let e;
434
+ getCommandAndParents(this).forEach((i)=>{
435
+ if (void 0 !== i.getOptionValueSource(t)) e = i.getOptionValueSource(t);
436
+ });
437
+ return e;
438
+ }
439
+ _prepareUserArgs(t, e) {
440
+ if (void 0 !== t && !Array.isArray(t)) throw new Error("first parameter to parse must be array or undefined");
441
+ e = e || {};
442
+ if (void 0 === t) {
443
+ t = a.argv;
444
+ if (a.versions && a.versions.electron) e.from = "electron";
445
+ }
446
+ this.rawArgs = t.slice();
447
+ let i;
448
+ switch(e.from){
449
+ case void 0:
450
+ case "node":
451
+ this._scriptPath = t[1];
452
+ i = t.slice(2);
453
+ break;
454
+ case "electron":
455
+ if (a.defaultApp) {
456
+ this._scriptPath = t[1];
457
+ i = t.slice(2);
458
+ } else i = t.slice(1);
459
+ break;
460
+ case "user":
461
+ i = t.slice(0);
462
+ break;
463
+ default:
464
+ throw new Error(`unexpected parse option { from: '${e.from}' }`);
465
+ }
466
+ if (!this._name && this._scriptPath) this.nameFromFilename(this._scriptPath);
467
+ this._name = this._name || "program";
468
+ return i;
469
+ }
470
+ parse(t, e) {
471
+ const i = this._prepareUserArgs(t, e);
472
+ this._parseCommand([], i);
473
+ return this;
474
+ }
475
+ async parseAsync(t, e) {
476
+ const i = this._prepareUserArgs(t, e);
477
+ await this._parseCommand([], i);
478
+ return this;
479
+ }
480
+ _executeSubCommand(t, e) {
481
+ e = e.slice();
482
+ let i = false;
483
+ const n = [
484
+ ".js",
485
+ ".ts",
486
+ ".tsx",
487
+ ".mjs",
488
+ ".cjs"
489
+ ];
490
+ function findFile(t, e) {
491
+ const i = r.resolve(t, e);
492
+ if (o.existsSync(i)) return i;
493
+ if (n.includes(r.extname(e))) return;
494
+ const s = n.find((t)=>o.existsSync(`${i}${t}`));
495
+ if (s) return `${i}${s}`;
496
+ }
497
+ this._checkForMissingMandatoryOptions();
498
+ this._checkForConflictingOptions();
499
+ let l = t._executableFile || `${this._name}-${t._name}`;
500
+ let h = this._executableDir || "";
501
+ if (this._scriptPath) {
502
+ let t;
503
+ try {
504
+ t = o.realpathSync(this._scriptPath);
505
+ } catch (e) {
506
+ t = this._scriptPath;
507
+ }
508
+ h = r.resolve(r.dirname(t), h);
509
+ }
510
+ if (h) {
511
+ let e = findFile(h, l);
512
+ if (!e && !t._executableFile && this._scriptPath) {
513
+ const i = r.basename(this._scriptPath, r.extname(this._scriptPath));
514
+ if (i !== this._name) e = findFile(h, `${i}-${t._name}`);
515
+ }
516
+ l = e || l;
517
+ }
518
+ i = n.includes(r.extname(l));
519
+ let c;
520
+ if ("win32" !== a.platform) if (i) {
521
+ e.unshift(l);
522
+ e = incrementNodeInspectorPort(a.execArgv).concat(e);
523
+ c = s.spawn(a.argv[0], e, {
524
+ stdio: "inherit"
525
+ });
526
+ } else c = s.spawn(l, e, {
527
+ stdio: "inherit"
528
+ });
529
+ else {
530
+ e.unshift(l);
531
+ e = incrementNodeInspectorPort(a.execArgv).concat(e);
532
+ c = s.spawn(a.execPath, e, {
533
+ stdio: "inherit"
534
+ });
535
+ }
536
+ if (!c.killed) {
537
+ const t = [
538
+ "SIGUSR1",
539
+ "SIGUSR2",
540
+ "SIGTERM",
541
+ "SIGINT",
542
+ "SIGHUP"
543
+ ];
544
+ t.forEach((t)=>{
545
+ a.on(t, ()=>{
546
+ if (false === c.killed && null === c.exitCode) c.kill(t);
547
+ });
548
+ });
549
+ }
550
+ const p = this._exitCallback;
551
+ if (p) c.on("close", ()=>{
552
+ p(new u(a.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
553
+ });
554
+ else c.on("close", a.exit.bind(a));
555
+ c.on("error", (e)=>{
556
+ if ("ENOENT" === e.code) {
557
+ 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";
558
+ 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}`;
559
+ throw new Error(i);
560
+ }
561
+ if ("EACCES" === e.code) throw new Error(`'${l}' not executable`);
562
+ if (p) {
563
+ const t = new u(1, "commander.executeSubCommandAsync", "(error)");
564
+ t.nestedError = e;
565
+ p(t);
566
+ } else a.exit(1);
567
+ });
568
+ this.runningCommand = c;
569
+ }
570
+ _dispatchSubcommand(t, e, i) {
571
+ const n = this._findCommand(t);
572
+ if (!n) this.help({
573
+ error: true
574
+ });
575
+ let s;
576
+ s = this._chainOrCallSubCommandHook(s, n, "preSubcommand");
577
+ s = this._chainOrCall(s, ()=>{
578
+ if (!n._executableHandler) return n._parseCommand(e, i);
579
+ this._executeSubCommand(n, e.concat(i));
580
+ });
581
+ return s;
582
+ }
583
+ _checkNumberOfArguments() {
584
+ this._args.forEach((t, e)=>{
585
+ if (t.required && null == this.args[e]) this.missingArgument(t.name());
586
+ });
587
+ if (this._args.length > 0 && this._args[this._args.length - 1].variadic) return;
588
+ if (this.args.length > this._args.length) this._excessArguments(this.args);
589
+ }
590
+ _processArguments() {
591
+ const myParseArg = (t, e, i)=>{
592
+ let n = e;
593
+ if (null !== e && t.parseArg) try {
594
+ n = t.parseArg(e, i);
595
+ } catch (i) {
596
+ if ("commander.invalidArgument" === i.code) {
597
+ const n = `error: command-argument value '${e}' is invalid for argument '${t.name()}'. ${i.message}`;
598
+ this.error(n, {
599
+ exitCode: i.exitCode,
600
+ code: i.code
601
+ });
602
+ }
603
+ throw i;
604
+ }
605
+ return n;
606
+ };
607
+ this._checkNumberOfArguments();
608
+ const t = [];
609
+ this._args.forEach((e, i)=>{
610
+ let n = e.defaultValue;
611
+ if (e.variadic) {
612
+ if (i < this.args.length) {
613
+ n = this.args.slice(i);
614
+ if (e.parseArg) n = n.reduce((t, i)=>myParseArg(e, i, t), e.defaultValue);
615
+ } else if (void 0 === n) n = [];
616
+ } else if (i < this.args.length) {
617
+ n = this.args[i];
618
+ if (e.parseArg) n = myParseArg(e, n, e.defaultValue);
619
+ }
620
+ t[i] = n;
621
+ });
622
+ this.processedArgs = t;
623
+ }
624
+ _chainOrCall(t, e) {
625
+ if (t && t.then && "function" == typeof t.then) return t.then(()=>e());
626
+ return e();
627
+ }
628
+ _chainOrCallHooks(t, e) {
629
+ let i = t;
630
+ const n = [];
631
+ getCommandAndParents(this).reverse().filter((t)=>void 0 !== t._lifeCycleHooks[e]).forEach((t)=>{
632
+ t._lifeCycleHooks[e].forEach((e)=>{
633
+ n.push({
634
+ hookedCommand: t,
635
+ callback: e
636
+ });
637
+ });
638
+ });
639
+ if ("postAction" === e) n.reverse();
640
+ n.forEach((t)=>{
641
+ i = this._chainOrCall(i, ()=>t.callback(t.hookedCommand, this));
642
+ });
643
+ return i;
644
+ }
645
+ _chainOrCallSubCommandHook(t, e, i) {
646
+ let n = t;
647
+ if (void 0 !== this._lifeCycleHooks[i]) this._lifeCycleHooks[i].forEach((t)=>{
648
+ n = this._chainOrCall(n, ()=>t(this, e));
649
+ });
650
+ return n;
651
+ }
652
+ _parseCommand(t, e) {
653
+ const i = this.parseOptions(e);
654
+ this._parseOptionsEnv();
655
+ this._parseOptionsImplied();
656
+ t = t.concat(i.operands);
657
+ e = i.unknown;
658
+ this.args = t.concat(e);
659
+ if (t && this._findCommand(t[0])) return this._dispatchSubcommand(t[0], t.slice(1), e);
660
+ if (this._hasImplicitHelpCommand() && t[0] === this._helpCommandName) {
661
+ if (1 === t.length) this.help();
662
+ return this._dispatchSubcommand(t[1], [], [
663
+ this._helpLongFlag
664
+ ]);
665
+ }
666
+ if (this._defaultCommandName) {
667
+ outputHelpIfRequested(this, e);
668
+ return this._dispatchSubcommand(this._defaultCommandName, t, e);
669
+ }
670
+ if (this.commands.length && 0 === this.args.length && !this._actionHandler && !this._defaultCommandName) this.help({
671
+ error: true
672
+ });
673
+ outputHelpIfRequested(this, i.unknown);
674
+ this._checkForMissingMandatoryOptions();
675
+ this._checkForConflictingOptions();
676
+ const checkForUnknownOptions = ()=>{
677
+ if (i.unknown.length > 0) this.unknownOption(i.unknown[0]);
678
+ };
679
+ const n = `command:${this.name()}`;
680
+ if (this._actionHandler) {
681
+ checkForUnknownOptions();
682
+ this._processArguments();
683
+ let i;
684
+ i = this._chainOrCallHooks(i, "preAction");
685
+ i = this._chainOrCall(i, ()=>this._actionHandler(this.processedArgs));
686
+ if (this.parent) i = this._chainOrCall(i, ()=>{
687
+ this.parent.emit(n, t, e);
688
+ });
689
+ i = this._chainOrCallHooks(i, "postAction");
690
+ return i;
691
+ }
692
+ if (this.parent && this.parent.listenerCount(n)) {
693
+ checkForUnknownOptions();
694
+ this._processArguments();
695
+ this.parent.emit(n, t, e);
696
+ } else if (t.length) {
697
+ if (this._findCommand("*")) return this._dispatchSubcommand("*", t, e);
698
+ if (this.listenerCount("command:*")) this.emit("command:*", t, e);
699
+ else if (this.commands.length) this.unknownCommand();
700
+ else {
701
+ checkForUnknownOptions();
702
+ this._processArguments();
703
+ }
704
+ } else if (this.commands.length) {
705
+ checkForUnknownOptions();
706
+ this.help({
707
+ error: true
708
+ });
709
+ } else {
710
+ checkForUnknownOptions();
711
+ this._processArguments();
712
+ }
713
+ }
714
+ _findCommand(t) {
715
+ if (!t) return;
716
+ return this.commands.find((e)=>e._name === t || e._aliases.includes(t));
717
+ }
718
+ _findOption(t) {
719
+ return this.options.find((e)=>e.is(t));
720
+ }
721
+ _checkForMissingMandatoryOptions() {
722
+ for(let t = this; t; t = t.parent)t.options.forEach((e)=>{
723
+ if (e.mandatory && void 0 === t.getOptionValue(e.attributeName())) t.missingMandatoryOptionValue(e);
724
+ });
725
+ }
726
+ _checkForConflictingLocalOptions() {
727
+ const t = this.options.filter((t)=>{
728
+ const e = t.attributeName();
729
+ if (void 0 === this.getOptionValue(e)) return false;
730
+ return "default" !== this.getOptionValueSource(e);
731
+ });
732
+ const e = t.filter((t)=>t.conflictsWith.length > 0);
733
+ e.forEach((e)=>{
734
+ const i = t.find((t)=>e.conflictsWith.includes(t.attributeName()));
735
+ if (i) this._conflictingOption(e, i);
736
+ });
737
+ }
738
+ _checkForConflictingOptions() {
739
+ for(let t = this; t; t = t.parent)t._checkForConflictingLocalOptions();
740
+ }
741
+ parseOptions(t) {
742
+ const e = [];
743
+ const i = [];
744
+ let n = e;
745
+ const s = t.slice();
746
+ function maybeOption(t) {
747
+ return t.length > 1 && "-" === t[0];
748
+ }
749
+ let r = null;
750
+ while(s.length){
751
+ const t = s.shift();
752
+ if ("--" === t) {
753
+ if (n === i) n.push(t);
754
+ n.push(...s);
755
+ break;
756
+ }
757
+ if (r && !maybeOption(t)) {
758
+ this.emit(`option:${r.name()}`, t);
759
+ continue;
760
+ }
761
+ r = null;
762
+ if (maybeOption(t)) {
763
+ const e = this._findOption(t);
764
+ if (e) {
765
+ if (e.required) {
766
+ const t = s.shift();
767
+ if (void 0 === t) this.optionMissingArgument(e);
768
+ this.emit(`option:${e.name()}`, t);
769
+ } else if (e.optional) {
770
+ let t = null;
771
+ if (s.length > 0 && !maybeOption(s[0])) t = s.shift();
772
+ this.emit(`option:${e.name()}`, t);
773
+ } else this.emit(`option:${e.name()}`);
774
+ r = e.variadic ? e : null;
775
+ continue;
776
+ }
777
+ }
778
+ if (t.length > 2 && "-" === t[0] && "-" !== t[1]) {
779
+ const e = this._findOption(`-${t[1]}`);
780
+ if (e) {
781
+ if (e.required || e.optional && this._combineFlagAndOptionalValue) this.emit(`option:${e.name()}`, t.slice(2));
782
+ else {
783
+ this.emit(`option:${e.name()}`);
784
+ s.unshift(`-${t.slice(2)}`);
785
+ }
786
+ continue;
787
+ }
788
+ }
789
+ if (/^--[^=]+=/.test(t)) {
790
+ const e = t.indexOf("=");
791
+ const i = this._findOption(t.slice(0, e));
792
+ if (i && (i.required || i.optional)) {
793
+ this.emit(`option:${i.name()}`, t.slice(e + 1));
794
+ continue;
795
+ }
796
+ }
797
+ if (maybeOption(t)) n = i;
798
+ if ((this._enablePositionalOptions || this._passThroughOptions) && 0 === e.length && 0 === i.length) {
799
+ if (this._findCommand(t)) {
800
+ e.push(t);
801
+ if (s.length > 0) i.push(...s);
802
+ break;
803
+ } else if (t === this._helpCommandName && this._hasImplicitHelpCommand()) {
804
+ e.push(t);
805
+ if (s.length > 0) e.push(...s);
806
+ break;
807
+ } else if (this._defaultCommandName) {
808
+ i.push(t);
809
+ if (s.length > 0) i.push(...s);
810
+ break;
811
+ }
812
+ }
813
+ if (this._passThroughOptions) {
814
+ n.push(t);
815
+ if (s.length > 0) n.push(...s);
816
+ break;
817
+ }
818
+ n.push(t);
819
+ }
820
+ return {
821
+ operands: e,
822
+ unknown: i
823
+ };
824
+ }
825
+ opts() {
826
+ if (this._storeOptionsAsProperties) {
827
+ const t = {};
828
+ const e = this.options.length;
829
+ for(let i = 0; i < e; i++){
830
+ const e = this.options[i].attributeName();
831
+ t[e] = e === this._versionOptionName ? this._version : this[e];
832
+ }
833
+ return t;
834
+ }
835
+ return this._optionValues;
836
+ }
837
+ optsWithGlobals() {
838
+ return getCommandAndParents(this).reduce((t, e)=>Object.assign(t, e.opts()), {});
839
+ }
840
+ error(t, e) {
841
+ this._outputConfiguration.outputError(`${t}\n`, this._outputConfiguration.writeErr);
842
+ if ("string" == typeof this._showHelpAfterError) this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`);
843
+ else if (this._showHelpAfterError) {
844
+ this._outputConfiguration.writeErr("\n");
845
+ this.outputHelp({
846
+ error: true
847
+ });
848
+ }
849
+ const i = e || {};
850
+ const n = i.exitCode || 1;
851
+ const s = i.code || "commander.error";
852
+ this._exit(n, s, t);
853
+ }
854
+ _parseOptionsEnv() {
855
+ this.options.forEach((t)=>{
856
+ if (t.envVar && t.envVar in a.env) {
857
+ const e = t.attributeName();
858
+ if (void 0 === this.getOptionValue(e) || [
859
+ "default",
860
+ "config",
861
+ "env"
862
+ ].includes(this.getOptionValueSource(e))) if (t.required || t.optional) this.emit(`optionEnv:${t.name()}`, a.env[t.envVar]);
863
+ else this.emit(`optionEnv:${t.name()}`);
864
+ }
865
+ });
866
+ }
867
+ _parseOptionsImplied() {
868
+ const t = new d(this.options);
869
+ const hasCustomOptionValue = (t)=>void 0 !== this.getOptionValue(t) && ![
870
+ "default",
871
+ "implied"
872
+ ].includes(this.getOptionValueSource(t));
873
+ this.options.filter((e)=>void 0 !== e.implied && hasCustomOptionValue(e.attributeName()) && t.valueFromOption(this.getOptionValue(e.attributeName()), e)).forEach((t)=>{
874
+ Object.keys(t.implied).filter((t)=>!hasCustomOptionValue(t)).forEach((e)=>{
875
+ this.setOptionValueWithSource(e, t.implied[e], "implied");
876
+ });
877
+ });
878
+ }
879
+ missingArgument(t) {
880
+ const e = `error: missing required argument '${t}'`;
881
+ this.error(e, {
882
+ code: "commander.missingArgument"
883
+ });
884
+ }
885
+ optionMissingArgument(t) {
886
+ const e = `error: option '${t.flags}' argument missing`;
887
+ this.error(e, {
888
+ code: "commander.optionMissingArgument"
889
+ });
890
+ }
891
+ missingMandatoryOptionValue(t) {
892
+ const e = `error: required option '${t.flags}' not specified`;
893
+ this.error(e, {
894
+ code: "commander.missingMandatoryOptionValue"
895
+ });
896
+ }
897
+ _conflictingOption(t, e) {
898
+ const findBestOptionFromValue = (t)=>{
899
+ const e = t.attributeName();
900
+ const i = this.getOptionValue(e);
901
+ const n = this.options.find((t)=>t.negate && e === t.attributeName());
902
+ const s = this.options.find((t)=>!t.negate && e === t.attributeName());
903
+ if (n && (void 0 === n.presetArg && false === i || void 0 !== n.presetArg && i === n.presetArg)) return n;
904
+ return s || t;
905
+ };
906
+ const getErrorMessage = (t)=>{
907
+ const e = findBestOptionFromValue(t);
908
+ const i = e.attributeName();
909
+ const n = this.getOptionValueSource(i);
910
+ if ("env" === n) return `environment variable '${e.envVar}'`;
911
+ return `option '${e.flags}'`;
912
+ };
913
+ const i = `error: ${getErrorMessage(t)} cannot be used with ${getErrorMessage(e)}`;
914
+ this.error(i, {
915
+ code: "commander.conflictingOption"
916
+ });
917
+ }
918
+ unknownOption(t) {
919
+ if (this._allowUnknownOption) return;
920
+ let e = "";
921
+ if (t.startsWith("--") && this._showSuggestionAfterError) {
922
+ let i = [];
923
+ let n = this;
924
+ do {
925
+ const t = n.createHelp().visibleOptions(n).filter((t)=>t.long).map((t)=>t.long);
926
+ i = i.concat(t);
927
+ n = n.parent;
928
+ }while (n && !n._enablePositionalOptions);
929
+ e = f(t, i);
930
+ }
931
+ const i = `error: unknown option '${t}'${e}`;
932
+ this.error(i, {
933
+ code: "commander.unknownOption"
934
+ });
935
+ }
936
+ _excessArguments(t) {
937
+ if (this._allowExcessArguments) return;
938
+ const e = this._args.length;
939
+ const i = 1 === e ? "" : "s";
940
+ const n = this.parent ? ` for '${this.name()}'` : "";
941
+ const s = `error: too many arguments${n}. Expected ${e} argument${i} but got ${t.length}.`;
942
+ this.error(s, {
943
+ code: "commander.excessArguments"
944
+ });
945
+ }
946
+ unknownCommand() {
947
+ const t = this.args[0];
948
+ let e = "";
949
+ if (this._showSuggestionAfterError) {
950
+ const i = [];
951
+ this.createHelp().visibleCommands(this).forEach((t)=>{
952
+ i.push(t.name());
953
+ if (t.alias()) i.push(t.alias());
954
+ });
955
+ e = f(t, i);
956
+ }
957
+ const i = `error: unknown command '${t}'${e}`;
958
+ this.error(i, {
959
+ code: "commander.unknownCommand"
960
+ });
961
+ }
962
+ version(t, e, i) {
963
+ if (void 0 === t) return this._version;
964
+ this._version = t;
965
+ e = e || "-V, --version";
966
+ i = i || "output the version number";
967
+ const n = this.createOption(e, i);
968
+ this._versionOptionName = n.attributeName();
969
+ this.options.push(n);
970
+ this.on("option:" + n.name(), ()=>{
971
+ this._outputConfiguration.writeOut(`${t}\n`);
972
+ this._exit(0, "commander.version", t);
973
+ });
974
+ return this;
975
+ }
976
+ description(t, e) {
977
+ if (void 0 === t && void 0 === e) return this._description;
978
+ this._description = t;
979
+ if (e) this._argsDescription = e;
980
+ return this;
981
+ }
982
+ summary(t) {
983
+ if (void 0 === t) return this._summary;
984
+ this._summary = t;
985
+ return this;
986
+ }
987
+ alias(t) {
988
+ if (void 0 === t) return this._aliases[0];
989
+ let e = this;
990
+ if (0 !== this.commands.length && this.commands[this.commands.length - 1]._executableHandler) e = this.commands[this.commands.length - 1];
991
+ if (t === e._name) throw new Error("Command alias can't be the same as its name");
992
+ e._aliases.push(t);
993
+ return this;
994
+ }
995
+ aliases(t) {
996
+ if (void 0 === t) return this._aliases;
997
+ t.forEach((t)=>this.alias(t));
998
+ return this;
999
+ }
1000
+ usage(t) {
1001
+ if (void 0 === t) {
1002
+ if (this._usage) return this._usage;
1003
+ const t = this._args.map((t)=>h(t));
1004
+ return [].concat(this.options.length || this._hasHelpOption ? "[options]" : [], this.commands.length ? "[command]" : [], this._args.length ? t : []).join(" ");
1005
+ }
1006
+ this._usage = t;
1007
+ return this;
1008
+ }
1009
+ name(t) {
1010
+ if (void 0 === t) return this._name;
1011
+ this._name = t;
1012
+ return this;
1013
+ }
1014
+ nameFromFilename(t) {
1015
+ this._name = r.basename(t, r.extname(t));
1016
+ return this;
1017
+ }
1018
+ executableDir(t) {
1019
+ if (void 0 === t) return this._executableDir;
1020
+ this._executableDir = t;
1021
+ return this;
1022
+ }
1023
+ helpInformation(t) {
1024
+ const e = this.createHelp();
1025
+ if (void 0 === e.helpWidth) e.helpWidth = t && t.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
1026
+ return e.formatHelp(this, e);
1027
+ }
1028
+ _getHelpContext(t) {
1029
+ t = t || {};
1030
+ const e = {
1031
+ error: !!t.error
1032
+ };
1033
+ let i;
1034
+ i = e.error ? (t)=>this._outputConfiguration.writeErr(t) : (t)=>this._outputConfiguration.writeOut(t);
1035
+ e.write = t.write || i;
1036
+ e.command = this;
1037
+ return e;
1038
+ }
1039
+ outputHelp(t) {
1040
+ let e;
1041
+ if ("function" == typeof t) {
1042
+ e = t;
1043
+ t = void 0;
1044
+ }
1045
+ const i = this._getHelpContext(t);
1046
+ getCommandAndParents(this).reverse().forEach((t)=>t.emit("beforeAllHelp", i));
1047
+ this.emit("beforeHelp", i);
1048
+ let n = this.helpInformation(i);
1049
+ if (e) {
1050
+ n = e(n);
1051
+ if ("string" != typeof n && !Buffer.isBuffer(n)) throw new Error("outputHelp callback must return a string or a Buffer");
1052
+ }
1053
+ i.write(n);
1054
+ this.emit(this._helpLongFlag);
1055
+ this.emit("afterHelp", i);
1056
+ getCommandAndParents(this).forEach((t)=>t.emit("afterAllHelp", i));
1057
+ }
1058
+ helpOption(t, e) {
1059
+ if ("boolean" == typeof t) {
1060
+ this._hasHelpOption = t;
1061
+ return this;
1062
+ }
1063
+ this._helpFlags = t || this._helpFlags;
1064
+ this._helpDescription = e || this._helpDescription;
1065
+ const i = m(this._helpFlags);
1066
+ this._helpShortFlag = i.shortFlag;
1067
+ this._helpLongFlag = i.longFlag;
1068
+ return this;
1069
+ }
1070
+ help(t) {
1071
+ this.outputHelp(t);
1072
+ let e = a.exitCode || 0;
1073
+ if (0 === e && t && "function" != typeof t && t.error) e = 1;
1074
+ this._exit(e, "commander.help", "(outputHelp)");
1075
+ }
1076
+ addHelpText(t, e) {
1077
+ const i = [
1078
+ "beforeAll",
1079
+ "before",
1080
+ "after",
1081
+ "afterAll"
1082
+ ];
1083
+ if (!i.includes(t)) throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);
1084
+ const n = `${t}Help`;
1085
+ this.on(n, (t)=>{
1086
+ let i;
1087
+ i = "function" == typeof e ? e({
1088
+ error: t.error,
1089
+ command: t.command
1090
+ }) : e;
1091
+ if (i) t.write(`${i}\n`);
1092
+ });
1093
+ return this;
1094
+ }
1095
+ }
1096
+ function outputHelpIfRequested(t, e) {
1097
+ const i = t._hasHelpOption && e.find((e)=>e === t._helpLongFlag || e === t._helpShortFlag);
1098
+ if (i) {
1099
+ t.outputHelp();
1100
+ t._exit(0, "commander.helpDisplayed", "(outputHelp)");
1101
+ }
1102
+ }
1103
+ function incrementNodeInspectorPort(t) {
1104
+ return t.map((t)=>{
1105
+ if (!t.startsWith("--inspect")) return t;
1106
+ let e;
1107
+ let i = "127.0.0.1";
1108
+ let n = "9229";
1109
+ let s;
1110
+ if (null !== (s = t.match(/^(--inspect(-brk)?)$/))) e = s[1];
1111
+ else if (null !== (s = t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))) {
1112
+ e = s[1];
1113
+ if (/^\d+$/.test(s[3])) n = s[3];
1114
+ else i = s[3];
1115
+ } else if (null !== (s = t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))) {
1116
+ e = s[1];
1117
+ i = s[3];
1118
+ n = s[4];
1119
+ }
1120
+ if (e && "0" !== n) return `${e}=${i}:${parseInt(n) + 1}`;
1121
+ return t;
1122
+ });
1123
+ }
1124
+ function getCommandAndParents(t) {
1125
+ const e = [];
1126
+ for(let i = t; i; i = i.parent)e.push(i);
1127
+ return e;
1128
+ }
1129
+ e.Command = Command;
1130
+ },
1131
+ 796: (t, e)=>{
1132
+ class CommanderError extends Error {
1133
+ constructor(t, e, i){
1134
+ super(i);
1135
+ Error.captureStackTrace(this, this.constructor);
1136
+ this.name = this.constructor.name;
1137
+ this.code = e;
1138
+ this.exitCode = t;
1139
+ this.nestedError = void 0;
1140
+ }
1141
+ }
1142
+ class InvalidArgumentError extends CommanderError {
1143
+ constructor(t){
1144
+ super(1, "commander.invalidArgument", t);
1145
+ Error.captureStackTrace(this, this.constructor);
1146
+ this.name = this.constructor.name;
1147
+ }
1148
+ }
1149
+ e.CommanderError = CommanderError;
1150
+ e.InvalidArgumentError = InvalidArgumentError;
1151
+ },
1152
+ 519: (t, e, i)=>{
1153
+ const { humanReadableArgName: n } = i(535);
1154
+ class Help {
1155
+ constructor(){
1156
+ this.helpWidth = void 0;
1157
+ this.sortSubcommands = false;
1158
+ this.sortOptions = false;
1159
+ this.showGlobalOptions = false;
1160
+ }
1161
+ visibleCommands(t) {
1162
+ const e = t.commands.filter((t)=>!t._hidden);
1163
+ if (t._hasImplicitHelpCommand()) {
1164
+ const [, i, n] = t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
1165
+ const s = t.createCommand(i).helpOption(false);
1166
+ s.description(t._helpCommandDescription);
1167
+ if (n) s.arguments(n);
1168
+ e.push(s);
1169
+ }
1170
+ if (this.sortSubcommands) e.sort((t, e)=>t.name().localeCompare(e.name()));
1171
+ return e;
1172
+ }
1173
+ compareOptions(t, e) {
1174
+ const getSortKey = (t)=>t.short ? t.short.replace(/^-/, "") : t.long.replace(/^--/, "");
1175
+ return getSortKey(t).localeCompare(getSortKey(e));
1176
+ }
1177
+ visibleOptions(t) {
1178
+ const e = t.options.filter((t)=>!t.hidden);
1179
+ const i = t._hasHelpOption && t._helpShortFlag && !t._findOption(t._helpShortFlag);
1180
+ const n = t._hasHelpOption && !t._findOption(t._helpLongFlag);
1181
+ if (i || n) {
1182
+ let s;
1183
+ s = i ? n ? t.createOption(t._helpFlags, t._helpDescription) : t.createOption(t._helpShortFlag, t._helpDescription) : t.createOption(t._helpLongFlag, t._helpDescription);
1184
+ e.push(s);
1185
+ }
1186
+ if (this.sortOptions) e.sort(this.compareOptions);
1187
+ return e;
1188
+ }
1189
+ visibleGlobalOptions(t) {
1190
+ if (!this.showGlobalOptions) return [];
1191
+ const e = [];
1192
+ for(let i = t.parent; i; i = i.parent){
1193
+ const t = i.options.filter((t)=>!t.hidden);
1194
+ e.push(...t);
1195
+ }
1196
+ if (this.sortOptions) e.sort(this.compareOptions);
1197
+ return e;
1198
+ }
1199
+ visibleArguments(t) {
1200
+ if (t._argsDescription) t._args.forEach((e)=>{
1201
+ e.description = e.description || t._argsDescription[e.name()] || "";
1202
+ });
1203
+ if (t._args.find((t)=>t.description)) return t._args;
1204
+ return [];
1205
+ }
1206
+ subcommandTerm(t) {
1207
+ const e = t._args.map((t)=>n(t)).join(" ");
1208
+ return t._name + (t._aliases[0] ? "|" + t._aliases[0] : "") + (t.options.length ? " [options]" : "") + (e ? " " + e : "");
1209
+ }
1210
+ optionTerm(t) {
1211
+ return t.flags;
1212
+ }
1213
+ argumentTerm(t) {
1214
+ return t.name();
1215
+ }
1216
+ longestSubcommandTermLength(t, e) {
1217
+ return e.visibleCommands(t).reduce((t, i)=>Math.max(t, e.subcommandTerm(i).length), 0);
1218
+ }
1219
+ longestOptionTermLength(t, e) {
1220
+ return e.visibleOptions(t).reduce((t, i)=>Math.max(t, e.optionTerm(i).length), 0);
1221
+ }
1222
+ longestGlobalOptionTermLength(t, e) {
1223
+ return e.visibleGlobalOptions(t).reduce((t, i)=>Math.max(t, e.optionTerm(i).length), 0);
1224
+ }
1225
+ longestArgumentTermLength(t, e) {
1226
+ return e.visibleArguments(t).reduce((t, i)=>Math.max(t, e.argumentTerm(i).length), 0);
1227
+ }
1228
+ commandUsage(t) {
1229
+ let e = t._name;
1230
+ if (t._aliases[0]) e = e + "|" + t._aliases[0];
1231
+ let i = "";
1232
+ for(let e = t.parent; e; e = e.parent)i = e.name() + " " + i;
1233
+ return i + e + " " + t.usage();
1234
+ }
1235
+ commandDescription(t) {
1236
+ return t.description();
1237
+ }
1238
+ subcommandDescription(t) {
1239
+ return t.summary() || t.description();
1240
+ }
1241
+ optionDescription(t) {
1242
+ const e = [];
1243
+ if (t.argChoices) e.push(`choices: ${t.argChoices.map((t)=>JSON.stringify(t)).join(", ")}`);
1244
+ if (void 0 !== t.defaultValue) {
1245
+ const i = t.required || t.optional || t.isBoolean() && "boolean" == typeof t.defaultValue;
1246
+ if (i) e.push(`default: ${t.defaultValueDescription || JSON.stringify(t.defaultValue)}`);
1247
+ }
1248
+ if (void 0 !== t.presetArg && t.optional) e.push(`preset: ${JSON.stringify(t.presetArg)}`);
1249
+ if (void 0 !== t.envVar) e.push(`env: ${t.envVar}`);
1250
+ if (e.length > 0) return `${t.description} (${e.join(", ")})`;
1251
+ return t.description;
1252
+ }
1253
+ argumentDescription(t) {
1254
+ const e = [];
1255
+ if (t.argChoices) e.push(`choices: ${t.argChoices.map((t)=>JSON.stringify(t)).join(", ")}`);
1256
+ if (void 0 !== t.defaultValue) e.push(`default: ${t.defaultValueDescription || JSON.stringify(t.defaultValue)}`);
1257
+ if (e.length > 0) {
1258
+ const i = `(${e.join(", ")})`;
1259
+ if (t.description) return `${t.description} ${i}`;
1260
+ return i;
1261
+ }
1262
+ return t.description;
1263
+ }
1264
+ formatHelp(t, e) {
1265
+ const i = e.padWidth(t, e);
1266
+ const n = e.helpWidth || 80;
1267
+ const s = 2;
1268
+ const r = 2;
1269
+ function formatItem(t, o) {
1270
+ if (o) {
1271
+ const a = `${t.padEnd(i + r)}${o}`;
1272
+ return e.wrap(a, n - s, i + r);
1273
+ }
1274
+ return t;
1275
+ }
1276
+ function formatList(t) {
1277
+ return t.join("\n").replace(/^/gm, " ".repeat(s));
1278
+ }
1279
+ let o = [
1280
+ `Usage: ${e.commandUsage(t)}`,
1281
+ ""
1282
+ ];
1283
+ const a = e.commandDescription(t);
1284
+ if (a.length > 0) o = o.concat([
1285
+ e.wrap(a, n, 0),
1286
+ ""
1287
+ ]);
1288
+ const l = e.visibleArguments(t).map((t)=>formatItem(e.argumentTerm(t), e.argumentDescription(t)));
1289
+ if (l.length > 0) o = o.concat([
1290
+ "Arguments:",
1291
+ formatList(l),
1292
+ ""
1293
+ ]);
1294
+ const h = e.visibleOptions(t).map((t)=>formatItem(e.optionTerm(t), e.optionDescription(t)));
1295
+ if (h.length > 0) o = o.concat([
1296
+ "Options:",
1297
+ formatList(h),
1298
+ ""
1299
+ ]);
1300
+ if (this.showGlobalOptions) {
1301
+ const i = e.visibleGlobalOptions(t).map((t)=>formatItem(e.optionTerm(t), e.optionDescription(t)));
1302
+ if (i.length > 0) o = o.concat([
1303
+ "Global Options:",
1304
+ formatList(i),
1305
+ ""
1306
+ ]);
1307
+ }
1308
+ const u = e.visibleCommands(t).map((t)=>formatItem(e.subcommandTerm(t), e.subcommandDescription(t)));
1309
+ if (u.length > 0) o = o.concat([
1310
+ "Commands:",
1311
+ formatList(u),
1312
+ ""
1313
+ ]);
1314
+ return o.join("\n");
1315
+ }
1316
+ padWidth(t, e) {
1317
+ return Math.max(e.longestOptionTermLength(t, e), e.longestGlobalOptionTermLength(t, e), e.longestSubcommandTermLength(t, e), e.longestArgumentTermLength(t, e));
1318
+ }
1319
+ wrap(t, e, i, n = 40) {
1320
+ const s = " \\f\\t\\v   -    \ufeff";
1321
+ const r = new RegExp(`[\\n][${s}]+`);
1322
+ if (t.match(r)) return t;
1323
+ const o = e - i;
1324
+ if (o < n) return t;
1325
+ const a = t.slice(0, i);
1326
+ const l = t.slice(i).replace("\r\n", "\n");
1327
+ const h = " ".repeat(i);
1328
+ const u = "​";
1329
+ const c = `\\s${u}`;
1330
+ const p = new RegExp(`\n|.{1,${o - 1}}([${c}]|$)|[^${c}]+?([${c}]|$)`, "g");
1331
+ const m = l.match(p) || [];
1332
+ return a + m.map((t, e)=>{
1333
+ if ("\n" === t) return "";
1334
+ return (e > 0 ? h : "") + t.trimEnd();
1335
+ }).join("\n");
1336
+ }
1337
+ }
1338
+ e.Help = Help;
1339
+ },
1340
+ 437: (t, e, i)=>{
1341
+ const { InvalidArgumentError: n } = i(796);
1342
+ class Option {
1343
+ constructor(t, e){
1344
+ this.flags = t;
1345
+ this.description = e || "";
1346
+ this.required = t.includes("<");
1347
+ this.optional = t.includes("[");
1348
+ this.variadic = /\w\.\.\.[>\]]$/.test(t);
1349
+ this.mandatory = false;
1350
+ const i = splitOptionFlags(t);
1351
+ this.short = i.shortFlag;
1352
+ this.long = i.longFlag;
1353
+ this.negate = false;
1354
+ if (this.long) this.negate = this.long.startsWith("--no-");
1355
+ this.defaultValue = void 0;
1356
+ this.defaultValueDescription = void 0;
1357
+ this.presetArg = void 0;
1358
+ this.envVar = void 0;
1359
+ this.parseArg = void 0;
1360
+ this.hidden = false;
1361
+ this.argChoices = void 0;
1362
+ this.conflictsWith = [];
1363
+ this.implied = void 0;
1364
+ }
1365
+ default(t, e) {
1366
+ this.defaultValue = t;
1367
+ this.defaultValueDescription = e;
1368
+ return this;
1369
+ }
1370
+ preset(t) {
1371
+ this.presetArg = t;
1372
+ return this;
1373
+ }
1374
+ conflicts(t) {
1375
+ this.conflictsWith = this.conflictsWith.concat(t);
1376
+ return this;
1377
+ }
1378
+ implies(t) {
1379
+ this.implied = Object.assign(this.implied || {}, t);
1380
+ return this;
1381
+ }
1382
+ env(t) {
1383
+ this.envVar = t;
1384
+ return this;
1385
+ }
1386
+ argParser(t) {
1387
+ this.parseArg = t;
1388
+ return this;
1389
+ }
1390
+ makeOptionMandatory(t = true) {
1391
+ this.mandatory = !!t;
1392
+ return this;
1393
+ }
1394
+ hideHelp(t = true) {
1395
+ this.hidden = !!t;
1396
+ return this;
1397
+ }
1398
+ _concatValue(t, e) {
1399
+ if (e === this.defaultValue || !Array.isArray(e)) return [
1400
+ t
1401
+ ];
1402
+ return e.concat(t);
1403
+ }
1404
+ choices(t) {
1405
+ this.argChoices = t.slice();
1406
+ this.parseArg = (t, e)=>{
1407
+ if (!this.argChoices.includes(t)) throw new n(`Allowed choices are ${this.argChoices.join(", ")}.`);
1408
+ if (this.variadic) return this._concatValue(t, e);
1409
+ return t;
1410
+ };
1411
+ return this;
1412
+ }
1413
+ name() {
1414
+ if (this.long) return this.long.replace(/^--/, "");
1415
+ return this.short.replace(/^-/, "");
1416
+ }
1417
+ attributeName() {
1418
+ return camelcase(this.name().replace(/^no-/, ""));
1419
+ }
1420
+ is(t) {
1421
+ return this.short === t || this.long === t;
1422
+ }
1423
+ isBoolean() {
1424
+ return !this.required && !this.optional && !this.negate;
1425
+ }
1426
+ }
1427
+ class DualOptions {
1428
+ constructor(t){
1429
+ this.positiveOptions = new Map;
1430
+ this.negativeOptions = new Map;
1431
+ this.dualOptions = new Set;
1432
+ t.forEach((t)=>{
1433
+ if (t.negate) this.negativeOptions.set(t.attributeName(), t);
1434
+ else this.positiveOptions.set(t.attributeName(), t);
1435
+ });
1436
+ this.negativeOptions.forEach((t, e)=>{
1437
+ if (this.positiveOptions.has(e)) this.dualOptions.add(e);
1438
+ });
1439
+ }
1440
+ valueFromOption(t, e) {
1441
+ const i = e.attributeName();
1442
+ if (!this.dualOptions.has(i)) return true;
1443
+ const n = this.negativeOptions.get(i).presetArg;
1444
+ const s = void 0 !== n ? n : false;
1445
+ return e.negate === (s === t);
1446
+ }
1447
+ }
1448
+ function camelcase(t) {
1449
+ return t.split("-").reduce((t, e)=>t + e[0].toUpperCase() + e.slice(1));
1450
+ }
1451
+ function splitOptionFlags(t) {
1452
+ let e;
1453
+ let i;
1454
+ const n = t.split(/[ |,]+/);
1455
+ if (n.length > 1 && !/^[[<]/.test(n[1])) e = n.shift();
1456
+ i = n.shift();
1457
+ if (!e && /^-[^-]$/.test(i)) {
1458
+ e = i;
1459
+ i = void 0;
1460
+ }
1461
+ return {
1462
+ shortFlag: e,
1463
+ longFlag: i
1464
+ };
1465
+ }
1466
+ e.Option = Option;
1467
+ e.splitOptionFlags = splitOptionFlags;
1468
+ e.DualOptions = DualOptions;
1469
+ },
1470
+ 860: (t, e)=>{
1471
+ const i = 3;
1472
+ function editDistance(t, e) {
1473
+ if (Math.abs(t.length - e.length) > i) return Math.max(t.length, e.length);
1474
+ const n = [];
1475
+ for(let e = 0; e <= t.length; e++)n[e] = [
1476
+ e
1477
+ ];
1478
+ for(let t = 0; t <= e.length; t++)n[0][t] = t;
1479
+ for(let i = 1; i <= e.length; i++)for(let s = 1; s <= t.length; s++){
1480
+ let r = 1;
1481
+ r = t[s - 1] === e[i - 1] ? 0 : 1;
1482
+ n[s][i] = Math.min(n[s - 1][i] + 1, n[s][i - 1] + 1, n[s - 1][i - 1] + r);
1483
+ 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);
1484
+ }
1485
+ return n[t.length][e.length];
1486
+ }
1487
+ function suggestSimilar(t, e) {
1488
+ if (!e || 0 === e.length) return "";
1489
+ e = Array.from(new Set(e));
1490
+ const n = t.startsWith("--");
1491
+ if (n) {
1492
+ t = t.slice(2);
1493
+ e = e.map((t)=>t.slice(2));
1494
+ }
1495
+ let s = [];
1496
+ let r = i;
1497
+ const o = .4;
1498
+ e.forEach((e)=>{
1499
+ if (e.length <= 1) return;
1500
+ const i = editDistance(t, e);
1501
+ const n = Math.max(t.length, e.length);
1502
+ const a = (n - i) / n;
1503
+ if (a > o) {
1504
+ if (i < r) {
1505
+ r = i;
1506
+ s = [
1507
+ e
1508
+ ];
1509
+ } else if (i === r) s.push(e);
1510
+ }
1511
+ });
1512
+ s.sort((t, e)=>t.localeCompare(e));
1513
+ if (n) s = s.map((t)=>`--${t}`);
1514
+ if (s.length > 1) return `\n(Did you mean one of ${s.join(", ")}?)`;
1515
+ if (1 === s.length) return `\n(Did you mean ${s[0]}?)`;
1516
+ return "";
1517
+ }
1518
+ e.suggestSimilar = suggestSimilar;
1519
+ }
1520
+ };
1521
+ var e = {};
1522
+ function __nccwpck_require__(i) {
1523
+ var n = e[i];
1524
+ if (void 0 !== n) return n.exports;
1525
+ var s = e[i] = {
1526
+ exports: {}
1527
+ };
1528
+ var r = true;
1529
+ try {
1530
+ t[i](s, s.exports, __nccwpck_require__);
1531
+ r = false;
1532
+ } finally{
1533
+ if (r) delete e[i];
1534
+ }
1535
+ return s.exports;
1536
+ }
1537
+ if (void 0 !== __nccwpck_require__) __nccwpck_require__.ab = __dirname + "/";
1538
+ var i = __nccwpck_require__(632);
1539
+ module.exports = i;
1540
+ })();