monocart-coverage-reports 2.8.3 → 2.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -5
- package/README.zh-Hans.md +20 -4
- package/lib/converter/ast-visitor.js +25 -5
- package/lib/converter/ast.js +10 -7
- package/lib/converter/collect-source-maps.js +11 -4
- package/lib/converter/converter.js +88 -34
- package/lib/index.d.ts +12 -7
- package/lib/index.js +1 -0
- package/lib/index.mjs +1 -0
- package/lib/packages/monocart-coverage-app.js +1 -1
- package/lib/packages/monocart-coverage-cli.js +14 -14
- package/lib/packages/monocart-coverage-vendor.js +23 -23
- package/lib/platform/share.js +47 -26
- package/lib/register/register.js +4 -4
- package/lib/register/register.mjs +3 -3
- package/lib/utils/snapshot.js +388 -385
- package/lib/utils/util.js +10 -0
- package/package.json +14 -12
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var Ct=Object.create;var y=Object.defineProperty;var
|
|
2
|
-
`).replace(/^/gm," ".repeat(r))}let
|
|
3
|
-
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){let r=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",o=new RegExp(`[\\n][${r}]+`);if(e.match(o))return e;let
|
|
1
|
+
var Ct=Object.create;var y=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var d=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),yt=(s,e)=>{for(var t in e)y(s,t,{get:e[t],enumerable:!0})},le=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of wt(e))!At.call(s,n)&&n!==t&&y(s,n,{get:()=>e[n],enumerable:!(i=bt(e,n))||i.enumerable});return s};var V=(s,e,t)=>(t=s!=null?Ct(Et(s)):{},le(e||!s||!s.__esModule?y(t,"default",{value:s,enumerable:!0}):t,s)),St=s=>le(y({},"__esModule",{value:!0}),s);var A=d(I=>{var S=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},P=class extends S{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};I.CommanderError=S;I.InvalidArgumentError=P});var v=d(N=>{var{InvalidArgumentError:vt}=A(),T=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new vt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function $t(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}N.Argument=T;N.humanReadableArgName=$t});var F=d(ue=>{var{humanReadableArgName:Ht}=v(),q=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(n=>!n._hidden),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort((n,r)=>n.name().localeCompare(r.name())),t}compareOptions(e,t){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){let t=e.options.filter(n=>!n.hidden),i=e._getHelpOption();if(i&&!i.hidden){let n=i.short&&e._findOption(i.short),r=i.long&&e._findOption(i.long);!n&&!r?t.push(i):i.long&&!r?t.push(e.createOption(i.long,i.description)):i.short&&!n&&t.push(e.createOption(i.short,i.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let i=e.parent;i;i=i.parent){let n=i.options.filter(r=>!r.hidden);t.push(...n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(i=>Ht(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,n)=>Math.max(i,t.subcommandTerm(n).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,n)=>Math.max(i,t.argumentTerm(n).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let n=e.parent;n;n=n.parent)i=n.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){let i=t.padWidth(e,t),n=t.helpWidth||80,r=2,o=2;function u(m,_){if(_){let E=`${m.padEnd(i+o)}${_}`;return t.wrap(E,n-r,i+o)}return m}function a(m){return m.join(`
|
|
2
|
+
`).replace(/^/gm," ".repeat(r))}let l=[`Usage: ${t.commandUsage(e)}`,""],c=t.commandDescription(e);c.length>0&&(l=l.concat([t.wrap(c,n,0),""]));let h=t.visibleArguments(e).map(m=>u(t.argumentTerm(m),t.argumentDescription(m)));h.length>0&&(l=l.concat(["Arguments:",a(h),""]));let f=t.visibleOptions(e).map(m=>u(t.optionTerm(m),t.optionDescription(m)));if(f.length>0&&(l=l.concat(["Options:",a(f),""])),this.showGlobalOptions){let m=t.visibleGlobalOptions(e).map(_=>u(t.optionTerm(_),t.optionDescription(_)));m.length>0&&(l=l.concat(["Global Options:",a(m),""]))}let g=t.visibleCommands(e).map(m=>u(t.subcommandTerm(m),t.subcommandDescription(m)));return g.length>0&&(l=l.concat(["Commands:",a(g),""])),l.join(`
|
|
3
|
+
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){let r=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",o=new RegExp(`[\\n][${r}]+`);if(e.match(o))return e;let u=t-i;if(u<n)return e;let a=e.slice(0,i),l=e.slice(i).replace(`\r
|
|
4
4
|
`,`
|
|
5
|
-
`),c=" ".repeat(i),f="\\s\u200B",
|
|
6
|
-
|.{1,${
|
|
5
|
+
`),c=" ".repeat(i),f="\\s\u200B",g=new RegExp(`
|
|
6
|
+
|.{1,${u-1}}([${f}]|$)|[^${f}]+?([${f}]|$)`,"g"),m=l.match(g)||[];return a+m.map((_,E)=>_===`
|
|
7
7
|
`?"":(E>0?c:"")+_.trimEnd()).join(`
|
|
8
|
-
`)}};ue.Help=q});var
|
|
8
|
+
`)}};ue.Help=q});var W=d(D=>{var{InvalidArgumentError:kt}=A(),j=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=Pt(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new kt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Vt(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},G=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(e,t){let i=t.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,r=n!==void 0?n:!1;return t.negate===(r===e)}};function Vt(s){return s.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Pt(s){let e,t,i=s.split(/[ |,]+/);return i.length>1&&!/^[[<]/.test(i[1])&&(e=i.shift()),t=i.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}D.Option=j;D.DualOptions=G});var he=d(ce=>{function It(s,e){if(Math.abs(s.length-e.length)>3)return Math.max(s.length,e.length);let t=[];for(let i=0;i<=s.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let n=1;n<=s.length;n++){let r=1;s[n-1]===e[i-1]?r=0:r=1,t[n][i]=Math.min(t[n-1][i]+1,t[n][i-1]+1,t[n-1][i-1]+r),n>1&&i>1&&s[n-1]===e[i-2]&&s[n-2]===e[i-1]&&(t[n][i]=Math.min(t[n][i],t[n-2][i-2]+1))}return t[s.length][e.length]}function Tt(s,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=s.startsWith("--");t&&(s=s.slice(2),e=e.map(o=>o.slice(2)));let i=[],n=3,r=.4;return e.forEach(o=>{if(o.length<=1)return;let u=It(s,o),a=Math.max(s.length,o.length);(a-u)/a>r&&(u<n?(n=u,i=[o]):u===n&&i.push(o))}),i.sort((o,u)=>o.localeCompare(u)),t&&(i=i.map(o=>`--${o}`)),i.length>1?`
|
|
9
9
|
(Did you mean one of ${i.join(", ")}?)`:i.length===1?`
|
|
10
|
-
(Did you mean ${i[0]}?)`:""}ce.suggestSimilar=
|
|
11
|
-
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new
|
|
10
|
+
(Did you mean ${i[0]}?)`:""}ce.suggestSimilar=Tt});var ge=d(de=>{var Nt=require("node:events").EventEmitter,M=require("node:child_process"),x=require("node:path"),L=require("node:fs"),p=require("node:process"),{Argument:qt,humanReadableArgName:Ft}=v(),{CommanderError:R}=A(),{Help:jt}=F(),{Option:fe,DualOptions:Gt}=W(),{suggestSimilar:me}=he(),U=class s extends Nt{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>p.stdout.write(t),writeErr:t=>p.stderr.write(t),getOutHelpWidth:()=>p.stdout.isTTY?p.stdout.columns:void 0,getErrHelpWidth:()=>p.stderr.isTTY?p.stderr.columns:void 0,outputError:(t,i)=>i(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let n=t,r=i;typeof n=="object"&&n!==null&&(r=n,n=null),r=r||{};let[,o,u]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(o);return n&&(a.description(n),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(r.noHelp||r.hidden),a._executableFile=r.executableFile||null,u&&a.arguments(u),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(e){return new s(e)}createHelp(){return Object.assign(new jt,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
11
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new qt(e,t)}argument(e,t,i,n){let r=this.createArgument(e,t);return typeof i=="function"?r.default(n).argParser(i):r.default(i),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,i,n]=e.match(/([^ ]+) *(.*)/),r=t??"display help for command",o=this.createCommand(i);return o.helpOption(!1),n&&o.arguments(n),r&&o.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
12
12
|
Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new R(e,t,i)),p.exit(e)}action(e){let t=i=>{let n=this.registeredArguments.length,r=i.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new fe(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(r){if(r.code==="commander.invalidArgument"){let o=`${n} ${r.message}`;this.error(o,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let i=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
|
|
13
|
-
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=n=>[n.name()].concat(n.aliases()),i=t(e).find(n=>this._findCommand(n));if(i){let n=t(this._findCommand(i)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${n}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let r=e.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let n=(r,o,
|
|
13
|
+
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=n=>[n.name()].concat(n.aliases()),i=t(e).find(n=>this._findCommand(n));if(i){let n=t(this._findCommand(i)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${n}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let r=e.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let n=(r,o,u)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let a=this.getOptionValue(i);r!==null&&e.parseArg?r=this._callParseArg(e,r,a,o):r!==null&&e.variadic&&(r=e._concatValue(r,a)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(i,r,u)};return this.on("option:"+t,r=>{let o=`error: option '${e.flags}' argument '${r}' is invalid.`;n(r,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let o=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;n(r,o,"env")}),this}_optionEx(e,t,i,n,r){if(typeof t=="object"&&t instanceof fe)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,i);if(o.makeOptionMandatory(!!e.mandatory),typeof n=="function")o.default(r).argParser(n);else if(n instanceof RegExp){let u=n;n=(a,l)=>{let c=u.exec(a);return c?c[0]:l},o.default(r).argParser(n)}else o.default(n);return this.addOption(o)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:!0},e,t,i,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(e)!==void 0&&(t=i.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){var n;if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){(n=p.versions)!=null&&n.electron&&(t.from="electron");let r=p.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(t.from="eval")}e===void 0&&(e=p.argv),this.rawArgs=e.slice();let i;switch(t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":p.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(e,t){let i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){let i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_executeSubCommand(e,t){t=t.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function r(c,h){let f=x.resolve(c,h);if(L.existsSync(f))return f;if(n.includes(x.extname(h)))return;let g=n.find(m=>L.existsSync(`${f}${m}`));if(g)return`${f}${g}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,u=this._executableDir||"";if(this._scriptPath){let c;try{c=L.realpathSync(this._scriptPath)}catch{c=this._scriptPath}u=x.resolve(x.dirname(c),u)}if(u){let c=r(u,o);if(!c&&!e._executableFile&&this._scriptPath){let h=x.basename(this._scriptPath,x.extname(this._scriptPath));h!==this._name&&(c=r(u,`${h}-${e._name}`))}o=c||o}i=n.includes(x.extname(o));let a;p.platform!=="win32"?i?(t.unshift(o),t=pe(p.execArgv).concat(t),a=M.spawn(p.argv[0],t,{stdio:"inherit"})):a=M.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=pe(p.execArgv).concat(t),a=M.spawn(p.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{p.on(h,()=>{a.killed===!1&&a.exitCode===null&&a.kill(h)})});let l=this._exitCallback;a.on("close",c=>{c=c??1,l?l(new R(c,"commander.executeSubCommandAsync","(close)")):p.exit(c)}),a.on("error",c=>{if(c.code==="ENOENT"){let h=u?`searched for local subcommand relative to directory '${u}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",f=`'${o}' does not exist
|
|
14
14
|
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
15
15
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
16
|
-
- ${h}`;throw new Error(f)}else if(c.code==="EACCES")throw new Error(`'${o}' not executable`);if(!
|
|
16
|
+
- ${h}`;throw new Error(f)}else if(c.code==="EACCES")throw new Error(`'${o}' not executable`);if(!l)p.exit(1);else{let h=new R(1,"commander.executeSubCommandAsync","(error)");h.nestedError=c,l(h)}}),this.runningCommand=a}_dispatchSubcommand(e,t,i){let n=this._findCommand(e);n||this.help({error:!0});let r;return r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,()=>{if(n._executableHandler)this._executeSubCommand(n,t.concat(i));else return n._parseCommand(t,i)}),r}_dispatchHelpCommand(e){var i,n;e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[((i=this._getHelpOption())==null?void 0:i.long)??((n=this._getHelpOption())==null?void 0:n.short)??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(i,n,r)=>{let o=n;if(n!==null&&i.parseArg){let u=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;o=this._callParseArg(i,n,r,u)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((i,n)=>{let r=i.defaultValue;i.variadic?n<this.args.length?(r=this.args.slice(n),i.parseArg&&(r=r.reduce((o,u)=>e(i,u,o),i.defaultValue))):r===void 0&&(r=[]):n<this.args.length&&(r=this.args[n],i.parseArg&&(r=e(i,r,i.defaultValue))),t[n]=r}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let i=e,n=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(o=>{n.push({hookedCommand:r,callback:o})})}),t==="postAction"&&n.reverse(),n.forEach(r=>{i=this._chainOrCall(i,()=>r.callback(r.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(r=>{n=this._chainOrCall(n,()=>r(this,t))}),n}_parseCommand(e,t){let i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(r))n(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});e.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=e.find(r=>i.conflictsWith.includes(r.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],n=t,r=e.slice();function o(a){return a.length>1&&a[0]==="-"}let u=null;for(;r.length;){let a=r.shift();if(a==="--"){n===i&&n.push(a),n.push(...r);break}if(u&&!o(a)){this.emit(`option:${u.name()}`,a);continue}if(u=null,o(a)){let l=this._findOption(a);if(l){if(l.required){let c=r.shift();c===void 0&&this.optionMissingArgument(l),this.emit(`option:${l.name()}`,c)}else if(l.optional){let c=null;r.length>0&&!o(r[0])&&(c=r.shift()),this.emit(`option:${l.name()}`,c)}else this.emit(`option:${l.name()}`);u=l.variadic?l:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let l=this._findOption(`-${a[1]}`);if(l){l.required||l.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${l.name()}`,a.slice(2)):(this.emit(`option:${l.name()}`),r.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let l=a.indexOf("="),c=this._findOption(a.slice(0,l));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,a.slice(l+1));continue}}if(o(a)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(a)){t.push(a),r.length>0&&i.push(...r);break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a),r.length>0&&t.push(...r);break}else if(this._defaultCommandName){i.push(a),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){n.push(a),r.length>0&&n.push(...r);break}n.push(a)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let i=0;i<t;i++){let n=this.options[i].attributeName();e[n]=n===this._versionOptionName?this._version:this[n]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
17
17
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
18
18
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
19
|
-
`),this.outputHelp({error:!0}));let i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in p.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,p.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new
|
|
20
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){var n;if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=(n=this.parent)==null?void 0:n._findCommand(e);if(i){let r=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>
|
|
19
|
+
`),this.outputHelp({error:!0}));let i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in p.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,p.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Gt(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!t(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=o=>{let u=o.attributeName(),a=this.getOptionValue(u),l=this.options.find(h=>h.negate&&u===h.attributeName()),c=this.options.find(h=>!h.negate&&u===h.attributeName());return l&&(l.presetArg===void 0&&a===!1||l.presetArg!==void 0&&a===l.presetArg)?l:c||o},n=o=>{let u=i(o),a=u.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},r=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(u=>u.long).map(u=>u.long);n=n.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);t=me(e,n)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(r=>{n.push(r.name()),r.alias()&&n.push(r.alias())}),t=me(e,n)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
20
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){var n;if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=(n=this.parent)==null?void 0:n._findCommand(e);if(i){let r=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>Ft(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=x.basename(e,x.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},i;return t.error?i=n=>this._outputConfiguration.writeErr(n):i=n=>this._outputConfiguration.writeOut(n),t.write=e.write||i,t.command=this,t}outputHelp(e){var r;let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),(r=this._getHelpOption())!=null&&r.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=p.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
21
21
|
Expecting one of '${i.join("', '")}'`);let n=`${e}Help`;return this.on(n,r=>{let o;typeof t=="function"?o=t({error:r.error,command:r.command}):o=t,o&&r.write(`${o}
|
|
22
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function pe(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?n=r[3]:i=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],i=r[3],n=r[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}de.Command=U});var xe=g(O=>{var{Argument:_e}=v(),{Command:B}=ge(),{CommanderError:Gt,InvalidArgumentError:Oe}=A(),{Help:Dt}=F(),{Option:Ce}=M();O.program=new B;O.createCommand=s=>new B(s);O.createOption=(s,e)=>new Ce(s,e);O.createArgument=(s,e)=>new _e(s,e);O.Command=B;O.Option=Ce;O.Argument=_e;O.Help=Dt;O.CommanderError=Gt;O.InvalidArgumentError=Oe;O.InvalidOptionArgumentError=Oe});var ve=g((Di,Se)=>{Se.exports=ye;ye.sync=Wt;var Ee=require("fs");function Mt(s,e){var t=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!t||(t=t.split(";"),t.indexOf("")!==-1))return!0;for(var i=0;i<t.length;i++){var n=t[i].toLowerCase();if(n&&s.substr(-n.length).toLowerCase()===n)return!0}return!1}function Ae(s,e,t){return!s.isSymbolicLink()&&!s.isFile()?!1:Mt(e,t)}function ye(s,e,t){Ee.stat(s,function(i,n){t(i,i?!1:Ae(n,s,e))})}function Wt(s,e){return Ae(Ee.statSync(s),s,e)}});var Ie=g((Mi,Ve)=>{Ve.exports=He;He.sync=Lt;var $e=require("fs");function He(s,e,t){$e.stat(s,function(i,n){t(i,i?!1:ke(n,e))})}function Lt(s,e){return ke($e.statSync(s),e)}function ke(s,e){return s.isFile()&&Rt(s,e)}function Rt(s,e){var t=s.mode,i=s.uid,n=s.gid,r=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),o=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),l=parseInt("100",8),a=parseInt("010",8),u=parseInt("001",8),c=l|a,h=t&u||t&a&&n===o||t&l&&i===r||t&c&&r===0;return h}});var Te=g((Li,Pe)=>{var Wi=require("fs"),$;process.platform==="win32"||global.TESTING_WINDOWS?$=ve():$=Ie();Pe.exports=K;K.sync=Ut;function K(s,e,t){if(typeof e=="function"&&(t=e,e={}),!t){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(i,n){K(s,e||{},function(r,o){r?n(r):i(o)})})}$(s,e||{},function(i,n){i&&(i.code==="EACCES"||e&&e.ignoreErrors)&&(i=null,n=!1),t(i,n)})}function Ut(s,e){try{return $.sync(s,e||{})}catch(t){if(e&&e.ignoreErrors||t.code==="EACCES")return!1;throw t}}});var Me=g((Ri,De)=>{var b=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Ne=require("path"),Bt=b?";":":",qe=Te(),Fe=s=>Object.assign(new Error(`not found: ${s}`),{code:"ENOENT"}),je=(s,e)=>{let t=e.colon||Bt,i=s.match(/\//)||b&&s.match(/\\/)?[""]:[...b?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(t)],n=b?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",r=b?n.split(t):[""];return b&&s.indexOf(".")!==-1&&r[0]!==""&&r.unshift(""),{pathEnv:i,pathExt:r,pathExtExe:n}},Ge=(s,e,t)=>{typeof e=="function"&&(t=e,e={}),e||(e={});let{pathEnv:i,pathExt:n,pathExtExe:r}=je(s,e),o=[],l=u=>new Promise((c,h)=>{if(u===i.length)return e.all&&o.length?c(o):h(Fe(s));let f=i[u],d=/^".*"$/.test(f)?f.slice(1,-1):f,m=Ne.join(d,s),_=!d&&/^\.[\\\/]/.test(s)?s.slice(0,2)+m:m;c(a(_,u,0))}),a=(u,c,h)=>new Promise((f,d)=>{if(h===n.length)return f(l(c+1));let m=n[h];qe(u+m,{pathExt:r},(_,E)=>{if(!_&&E)if(e.all)o.push(u+m);else return f(u+m);return f(a(u,c,h+1))})});return t?l(0).then(u=>t(null,u),t):l(0)},Kt=(s,e)=>{e=e||{};let{pathEnv:t,pathExt:i,pathExtExe:n}=je(s,e),r=[];for(let o=0;o<t.length;o++){let l=t[o],a=/^".*"$/.test(l)?l.slice(1,-1):l,u=Ne.join(a,s),c=!a&&/^\.[\\\/]/.test(s)?s.slice(0,2)+u:u;for(let h=0;h<i.length;h++){let f=c+i[h];try{if(qe.sync(f,{pathExt:n}))if(e.all)r.push(f);else return f}catch{}}}if(e.all&&r.length)return r;if(e.nothrow)return null;throw Fe(s)};De.exports=Ge;Ge.sync=Kt});var Le=g((Ui,z)=>{"use strict";var We=(s={})=>{let e=s.env||process.env;return(s.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};z.exports=We;z.exports.default=We});var Ke=g((Bi,Be)=>{"use strict";var Re=require("path"),zt=Me(),Jt=Le();function Ue(s,e){let t=s.options.env||process.env,i=process.cwd(),n=s.options.cwd!=null,r=n&&process.chdir!==void 0&&!process.chdir.disabled;if(r)try{process.chdir(s.options.cwd)}catch{}let o;try{o=zt.sync(s.command,{path:t[Jt({env:t})],pathExt:e?Re.delimiter:void 0})}catch{}finally{r&&process.chdir(i)}return o&&(o=Re.resolve(n?s.options.cwd:"",o)),o}function Xt(s){return Ue(s)||Ue(s,!0)}Be.exports=Xt});var ze=g((Ki,X)=>{"use strict";var J=/([()\][%!^"`<>&|;, *?])/g;function Yt(s){return s=s.replace(J,"^$1"),s}function Qt(s,e){return s=`${s}`,s=s.replace(/(\\*)"/g,'$1$1\\"'),s=s.replace(/(\\*)$/,"$1$1"),s=`"${s}"`,s=s.replace(J,"^$1"),e&&(s=s.replace(J,"^$1")),s}X.exports.command=Yt;X.exports.argument=Qt});var Xe=g((zi,Je)=>{"use strict";Je.exports=/^#!(.*)/});var Qe=g((Ji,Ye)=>{"use strict";var Zt=Xe();Ye.exports=(s="")=>{let e=s.match(Zt);if(!e)return null;let[t,i]=e[0].replace(/#! ?/,"").split(" "),n=t.split("/").pop();return n==="env"?i:i?`${n} ${i}`:n}});var et=g((Xi,Ze)=>{"use strict";var Y=require("fs"),ei=Qe();function ti(s){let t=Buffer.alloc(150),i;try{i=Y.openSync(s,"r"),Y.readSync(i,t,0,150,0),Y.closeSync(i)}catch{}return ei(t.toString())}Ze.exports=ti});var st=g((Yi,nt)=>{"use strict";var ii=require("path"),tt=Ke(),it=ze(),ni=et(),si=process.platform==="win32",ri=/\.(?:com|exe)$/i,oi=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function ai(s){s.file=tt(s);let e=s.file&&ni(s.file);return e?(s.args.unshift(s.file),s.command=e,tt(s)):s.file}function li(s){if(!si)return s;let e=ai(s),t=!ri.test(e);if(s.options.forceShell||t){let i=oi.test(e);s.command=ii.normalize(s.command),s.command=it.command(s.command),s.args=s.args.map(r=>it.argument(r,i));let n=[s.command].concat(s.args).join(" ");s.args=["/d","/s","/c",`"${n}"`],s.command=process.env.comspec||"cmd.exe",s.options.windowsVerbatimArguments=!0}return s}function ui(s,e,t){e&&!Array.isArray(e)&&(t=e,e=null),e=e?e.slice(0):[],t=Object.assign({},t);let i={command:s,args:e,options:t,file:void 0,original:{command:s,args:e}};return t.shell?i:li(i)}nt.exports=ui});var at=g((Qi,ot)=>{"use strict";var Q=process.platform==="win32";function Z(s,e){return Object.assign(new Error(`${e} ${s.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${s.command}`,path:s.command,spawnargs:s.args})}function ci(s,e){if(!Q)return;let t=s.emit;s.emit=function(i,n){if(i==="exit"){let r=rt(n,e,"spawn");if(r)return t.call(s,"error",r)}return t.apply(s,arguments)}}function rt(s,e){return Q&&s===1&&!e.file?Z(e.original,"spawn"):null}function hi(s,e){return Q&&s===1&&!e.file?Z(e.original,"spawnSync"):null}ot.exports={hookChildProcess:ci,verifyENOENT:rt,verifyENOENTSync:hi,notFoundError:Z}});var ct=g((Zi,w)=>{"use strict";var lt=require("child_process"),ee=st(),te=at();function ut(s,e,t){let i=ee(s,e,t),n=lt.spawn(i.command,i.args,i.options);return te.hookChildProcess(n,i),n}function fi(s,e,t){let i=ee(s,e,t),n=lt.spawnSync(i.command,i.args,i.options);return n.error=n.error||te.verifyENOENTSync(n.status,i),n}w.exports=ut;w.exports.spawn=ut;w.exports.sync=fi;w.exports._parse=ee;w.exports._enoent=te});var xi={};At(xi,{foregroundChild:()=>Ot,program:()=>we});module.exports=yt(xi);var be=V(xe(),1),{program:we,createCommand:Hi,createArgument:ki,createOption:Vi,CommanderError:Ii,InvalidArgumentError:Pi,InvalidOptionArgumentError:Ti,Command:Ni,Argument:qi,Option:Fi,Help:ji}=be.default;var gt=require("child_process"),_t=V(ct(),1);var x=[];x.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&x.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&x.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var H=s=>!!s&&typeof s=="object"&&typeof s.removeListener=="function"&&typeof s.emit=="function"&&typeof s.reallyExit=="function"&&typeof s.listeners=="function"&&typeof s.kill=="function"&&typeof s.pid=="number"&&typeof s.on=="function",ie=Symbol.for("signal-exit emitter"),ne=globalThis,mi=Object.defineProperty.bind(Object),se=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ne[ie])return ne[ie];mi(ne,ie,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let i=this.listeners[e],n=i.indexOf(t);n!==-1&&(n===0&&i.length===1?i.length=0:i.splice(n,1))}emit(e,t,i){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(let r of this.listeners[e])n=r(t,i)===!0||n;return e==="exit"&&(n=this.emit("afterExit",t,i)||n),n}},k=class{},pi=s=>({onExit(e,t){return s.onExit(e,t)},load(){return s.load()},unload(){return s.unload()}}),re=class extends k{onExit(){return()=>{}}load(){}unload(){}},oe=class extends k{#o=ae.platform==="win32"?"SIGINT":"SIGHUP";#t=new se;#e;#s;#r;#n={};#i=!1;constructor(e){super(),this.#e=e,this.#n={};for(let t of x)this.#n[t]=()=>{let i=this.#e.listeners(t),{count:n}=this.#t,r=e;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(n+=r.__signal_exit_emitter__.count),i.length===n){this.unload();let o=this.#t.emit("exit",null,t),l=t==="SIGHUP"?this.#o:t;o||e.kill(e.pid,l)}};this.#r=e.reallyExit,this.#s=e.emit}onExit(e,t){if(!H(this.#e))return()=>{};this.#i===!1&&this.load();let i=t!=null&&t.alwaysLast?"afterExit":"exit";return this.#t.on(i,e),()=>{this.#t.removeListener(i,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#i){this.#i=!0,this.#t.count+=1;for(let e of x)try{let t=this.#n[e];t&&this.#e.on(e,t)}catch{}this.#e.emit=(e,...t)=>this.#l(e,...t),this.#e.reallyExit=e=>this.#a(e)}}unload(){this.#i&&(this.#i=!1,x.forEach(e=>{let t=this.#n[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,t)}catch{}}),this.#e.emit=this.#s,this.#e.reallyExit=this.#r,this.#t.count-=1)}#a(e){return H(this.#e)?(this.#e.exitCode=e||0,this.#t.emit("exit",this.#e.exitCode,null),this.#r.call(this.#e,this.#e.exitCode)):0}#l(e,...t){let i=this.#s;if(e==="exit"&&H(this.#e)){typeof t[0]=="number"&&(this.#e.exitCode=t[0]);let n=i.call(this.#e,e,...t);return this.#t.emit("exit",this.#e.exitCode,null),n}else return i.call(this.#e,e,...t)}},ae=globalThis.process,{onExit:ht,load:nn,unload:sn}=pi(H(ae)?new oe(ae):new re);var ft=V(require("node:constants"),1),mt=Object.keys(ft.default).filter(s=>s.startsWith("SIG")&&s!=="SIGPROF"&&s!=="SIGKILL");var pt=require("child_process"),di=String.raw`
|
|
22
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function pe(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?n=r[3]:i=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],i=r[3],n=r[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}de.Command=U});var Ce=d(O=>{var{Argument:_e}=v(),{Command:B}=ge(),{CommanderError:Dt,InvalidArgumentError:Oe}=A(),{Help:Wt}=F(),{Option:xe}=W();O.program=new B;O.createCommand=s=>new B(s);O.createOption=(s,e)=>new xe(s,e);O.createArgument=(s,e)=>new _e(s,e);O.Command=B;O.Option=xe;O.Argument=_e;O.Help=Wt;O.CommanderError=Dt;O.InvalidArgumentError=Oe;O.InvalidOptionArgumentError=Oe});var ve=d((Di,Se)=>{Se.exports=ye;ye.sync=Lt;var Ee=require("fs");function Mt(s,e){var t=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!t||(t=t.split(";"),t.indexOf("")!==-1))return!0;for(var i=0;i<t.length;i++){var n=t[i].toLowerCase();if(n&&s.substr(-n.length).toLowerCase()===n)return!0}return!1}function Ae(s,e,t){return!s.isSymbolicLink()&&!s.isFile()?!1:Mt(e,t)}function ye(s,e,t){Ee.stat(s,function(i,n){t(i,i?!1:Ae(n,s,e))})}function Lt(s,e){return Ae(Ee.statSync(s),s,e)}});var Pe=d((Wi,Ve)=>{Ve.exports=He;He.sync=Rt;var $e=require("fs");function He(s,e,t){$e.stat(s,function(i,n){t(i,i?!1:ke(n,e))})}function Rt(s,e){return ke($e.statSync(s),e)}function ke(s,e){return s.isFile()&&Ut(s,e)}function Ut(s,e){var t=s.mode,i=s.uid,n=s.gid,r=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),o=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),u=parseInt("100",8),a=parseInt("010",8),l=parseInt("001",8),c=u|a,h=t&l||t&a&&n===o||t&u&&i===r||t&c&&r===0;return h}});var Te=d((Li,Ie)=>{var Mi=require("fs"),$;process.platform==="win32"||global.TESTING_WINDOWS?$=ve():$=Pe();Ie.exports=K;K.sync=Bt;function K(s,e,t){if(typeof e=="function"&&(t=e,e={}),!t){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(i,n){K(s,e||{},function(r,o){r?n(r):i(o)})})}$(s,e||{},function(i,n){i&&(i.code==="EACCES"||e&&e.ignoreErrors)&&(i=null,n=!1),t(i,n)})}function Bt(s,e){try{return $.sync(s,e||{})}catch(t){if(e&&e.ignoreErrors||t.code==="EACCES")return!1;throw t}}});var We=d((Ri,De)=>{var b=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Ne=require("path"),Kt=b?";":":",qe=Te(),Fe=s=>Object.assign(new Error(`not found: ${s}`),{code:"ENOENT"}),je=(s,e)=>{let t=e.colon||Kt,i=s.match(/\//)||b&&s.match(/\\/)?[""]:[...b?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(t)],n=b?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",r=b?n.split(t):[""];return b&&s.indexOf(".")!==-1&&r[0]!==""&&r.unshift(""),{pathEnv:i,pathExt:r,pathExtExe:n}},Ge=(s,e,t)=>{typeof e=="function"&&(t=e,e={}),e||(e={});let{pathEnv:i,pathExt:n,pathExtExe:r}=je(s,e),o=[],u=l=>new Promise((c,h)=>{if(l===i.length)return e.all&&o.length?c(o):h(Fe(s));let f=i[l],g=/^".*"$/.test(f)?f.slice(1,-1):f,m=Ne.join(g,s),_=!g&&/^\.[\\\/]/.test(s)?s.slice(0,2)+m:m;c(a(_,l,0))}),a=(l,c,h)=>new Promise((f,g)=>{if(h===n.length)return f(u(c+1));let m=n[h];qe(l+m,{pathExt:r},(_,E)=>{if(!_&&E)if(e.all)o.push(l+m);else return f(l+m);return f(a(l,c,h+1))})});return t?u(0).then(l=>t(null,l),t):u(0)},zt=(s,e)=>{e=e||{};let{pathEnv:t,pathExt:i,pathExtExe:n}=je(s,e),r=[];for(let o=0;o<t.length;o++){let u=t[o],a=/^".*"$/.test(u)?u.slice(1,-1):u,l=Ne.join(a,s),c=!a&&/^\.[\\\/]/.test(s)?s.slice(0,2)+l:l;for(let h=0;h<i.length;h++){let f=c+i[h];try{if(qe.sync(f,{pathExt:n}))if(e.all)r.push(f);else return f}catch{}}}if(e.all&&r.length)return r;if(e.nothrow)return null;throw Fe(s)};De.exports=Ge;Ge.sync=zt});var Le=d((Ui,z)=>{"use strict";var Me=(s={})=>{let e=s.env||process.env;return(s.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};z.exports=Me;z.exports.default=Me});var Ke=d((Bi,Be)=>{"use strict";var Re=require("path"),Jt=We(),Xt=Le();function Ue(s,e){let t=s.options.env||process.env,i=process.cwd(),n=s.options.cwd!=null,r=n&&process.chdir!==void 0&&!process.chdir.disabled;if(r)try{process.chdir(s.options.cwd)}catch{}let o;try{o=Jt.sync(s.command,{path:t[Xt({env:t})],pathExt:e?Re.delimiter:void 0})}catch{}finally{r&&process.chdir(i)}return o&&(o=Re.resolve(n?s.options.cwd:"",o)),o}function Yt(s){return Ue(s)||Ue(s,!0)}Be.exports=Yt});var ze=d((Ki,X)=>{"use strict";var J=/([()\][%!^"`<>&|;, *?])/g;function Qt(s){return s=s.replace(J,"^$1"),s}function Zt(s,e){return s=`${s}`,s=s.replace(/(\\*)"/g,'$1$1\\"'),s=s.replace(/(\\*)$/,"$1$1"),s=`"${s}"`,s=s.replace(J,"^$1"),e&&(s=s.replace(J,"^$1")),s}X.exports.command=Qt;X.exports.argument=Zt});var Xe=d((zi,Je)=>{"use strict";Je.exports=/^#!(.*)/});var Qe=d((Ji,Ye)=>{"use strict";var ei=Xe();Ye.exports=(s="")=>{let e=s.match(ei);if(!e)return null;let[t,i]=e[0].replace(/#! ?/,"").split(" "),n=t.split("/").pop();return n==="env"?i:i?`${n} ${i}`:n}});var et=d((Xi,Ze)=>{"use strict";var Y=require("fs"),ti=Qe();function ii(s){let t=Buffer.alloc(150),i;try{i=Y.openSync(s,"r"),Y.readSync(i,t,0,150,0),Y.closeSync(i)}catch{}return ti(t.toString())}Ze.exports=ii});var st=d((Yi,nt)=>{"use strict";var ni=require("path"),tt=Ke(),it=ze(),si=et(),ri=process.platform==="win32",oi=/\.(?:com|exe)$/i,ai=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function li(s){s.file=tt(s);let e=s.file&&si(s.file);return e?(s.args.unshift(s.file),s.command=e,tt(s)):s.file}function ui(s){if(!ri)return s;let e=li(s),t=!oi.test(e);if(s.options.forceShell||t){let i=ai.test(e);s.command=ni.normalize(s.command),s.command=it.command(s.command),s.args=s.args.map(r=>it.argument(r,i));let n=[s.command].concat(s.args).join(" ");s.args=["/d","/s","/c",`"${n}"`],s.command=process.env.comspec||"cmd.exe",s.options.windowsVerbatimArguments=!0}return s}function ci(s,e,t){e&&!Array.isArray(e)&&(t=e,e=null),e=e?e.slice(0):[],t=Object.assign({},t);let i={command:s,args:e,options:t,file:void 0,original:{command:s,args:e}};return t.shell?i:ui(i)}nt.exports=ci});var at=d((Qi,ot)=>{"use strict";var Q=process.platform==="win32";function Z(s,e){return Object.assign(new Error(`${e} ${s.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${s.command}`,path:s.command,spawnargs:s.args})}function hi(s,e){if(!Q)return;let t=s.emit;s.emit=function(i,n){if(i==="exit"){let r=rt(n,e,"spawn");if(r)return t.call(s,"error",r)}return t.apply(s,arguments)}}function rt(s,e){return Q&&s===1&&!e.file?Z(e.original,"spawn"):null}function fi(s,e){return Q&&s===1&&!e.file?Z(e.original,"spawnSync"):null}ot.exports={hookChildProcess:hi,verifyENOENT:rt,verifyENOENTSync:fi,notFoundError:Z}});var ct=d((Zi,w)=>{"use strict";var lt=require("child_process"),ee=st(),te=at();function ut(s,e,t){let i=ee(s,e,t),n=lt.spawn(i.command,i.args,i.options);return te.hookChildProcess(n,i),n}function mi(s,e,t){let i=ee(s,e,t),n=lt.spawnSync(i.command,i.args,i.options);return n.error=n.error||te.verifyENOENTSync(n.status,i),n}w.exports=ut;w.exports.spawn=ut;w.exports.sync=mi;w.exports._parse=ee;w.exports._enoent=te});var Ci={};yt(Ci,{foregroundChild:()=>xt,program:()=>we});module.exports=St(Ci);var be=V(Ce(),1),{program:we,createCommand:Hi,createArgument:ki,createOption:Vi,CommanderError:Pi,InvalidArgumentError:Ii,InvalidOptionArgumentError:Ti,Command:Ni,Argument:qi,Option:Fi,Help:ji}=be.default;var _t=require("child_process"),Ot=V(ct(),1);var C=[];C.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&C.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&C.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var H=s=>!!s&&typeof s=="object"&&typeof s.removeListener=="function"&&typeof s.emit=="function"&&typeof s.reallyExit=="function"&&typeof s.listeners=="function"&&typeof s.kill=="function"&&typeof s.pid=="number"&&typeof s.on=="function",ie=Symbol.for("signal-exit emitter"),ne=globalThis,pi=Object.defineProperty.bind(Object),se=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ne[ie])return ne[ie];pi(ne,ie,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let i=this.listeners[e],n=i.indexOf(t);n!==-1&&(n===0&&i.length===1?i.length=0:i.splice(n,1))}emit(e,t,i){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(let r of this.listeners[e])n=r(t,i)===!0||n;return e==="exit"&&(n=this.emit("afterExit",t,i)||n),n}},k=class{},di=s=>({onExit(e,t){return s.onExit(e,t)},load(){return s.load()},unload(){return s.unload()}}),re=class extends k{onExit(){return()=>{}}load(){}unload(){}},oe=class extends k{#o=ae.platform==="win32"?"SIGINT":"SIGHUP";#t=new se;#e;#s;#r;#n={};#i=!1;constructor(e){super(),this.#e=e,this.#n={};for(let t of C)this.#n[t]=()=>{let i=this.#e.listeners(t),{count:n}=this.#t,r=e;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(n+=r.__signal_exit_emitter__.count),i.length===n){this.unload();let o=this.#t.emit("exit",null,t),u=t==="SIGHUP"?this.#o:t;o||e.kill(e.pid,u)}};this.#r=e.reallyExit,this.#s=e.emit}onExit(e,t){if(!H(this.#e))return()=>{};this.#i===!1&&this.load();let i=t!=null&&t.alwaysLast?"afterExit":"exit";return this.#t.on(i,e),()=>{this.#t.removeListener(i,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#i){this.#i=!0,this.#t.count+=1;for(let e of C)try{let t=this.#n[e];t&&this.#e.on(e,t)}catch{}this.#e.emit=(e,...t)=>this.#l(e,...t),this.#e.reallyExit=e=>this.#a(e)}}unload(){this.#i&&(this.#i=!1,C.forEach(e=>{let t=this.#n[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,t)}catch{}}),this.#e.emit=this.#s,this.#e.reallyExit=this.#r,this.#t.count-=1)}#a(e){return H(this.#e)?(this.#e.exitCode=e||0,this.#t.emit("exit",this.#e.exitCode,null),this.#r.call(this.#e,this.#e.exitCode)):0}#l(e,...t){let i=this.#s;if(e==="exit"&&H(this.#e)){typeof t[0]=="number"&&(this.#e.exitCode=t[0]);let n=i.call(this.#e,e,...t);return this.#t.emit("exit",this.#e.exitCode,null),n}else return i.call(this.#e,e,...t)}},ae=globalThis.process,{onExit:ht,load:nn,unload:sn}=di(H(ae)?new oe(ae):new re);var ft=V(require("node:constants"),1),mt=Object.keys(ft.default).filter(s=>s.startsWith("SIG")&&s!=="SIGPROF"&&s!=="SIGKILL");var pt=s=>{let e=new Map;for(let i of mt){let n=()=>{try{s.kill(i)}catch{}};try{process.on(i,n),e.set(i,n)}catch{}}let t=()=>{for(let[i,n]of e)process.removeListener(i,n)};return s.on("exit",t),t};var dt=require("child_process"),gi=String.raw`
|
|
23
23
|
const pid = parseInt(process.argv[1], 10)
|
|
24
24
|
process.title = 'node (foreground-child watchdog pid=' + pid + ')'
|
|
25
25
|
if (!isNaN(pid)) {
|
|
@@ -40,4 +40,4 @@ if (!isNaN(pid)) {
|
|
|
40
40
|
})
|
|
41
41
|
process.on('SIGHUP', bark)
|
|
42
42
|
}
|
|
43
|
-
`,
|
|
43
|
+
`,gt=s=>{let e=!1,t=(0,dt.spawn)(process.execPath,["-e",gi,String(s.pid)],{stdio:"ignore"});return t.on("exit",()=>e=!0),s.on("exit",()=>{e||t.kill("SIGKILL")}),t};var _i=(process==null?void 0:process.platform)==="win32"?Ot.default:_t.spawn,Oi=s=>{let[e,t=[],i={},n=()=>{}]=s;if(typeof t=="function"?(n=t,i={},t=[]):t&&typeof t=="object"&&!Array.isArray(t)?(typeof i=="function"&&(n=i),i=t,t=[]):typeof i=="function"&&(n=i,i={}),Array.isArray(e)){let[r,...o]=e;e=r,t=o}return[e,t,{...i},n]};function xt(...s){let[e,t,i,n]=Oi(s);i.stdio=[0,1,2],process.send&&i.stdio.push("ipc");let r=_i(e,t,i),u=ht(()=>{try{r.kill("SIGHUP")}catch{r.kill("SIGTERM")}});pt(r),gt(r);let a=!1;return r.on("close",async(l,c)=>{if(a)return;a=!0;let h=n(l,c),f=xi(h)?await h:h;if(u(),f!==!1)if(typeof f=="string"?(c=f,l=null):typeof f=="number"&&(l=f,c=null),c){setTimeout(()=>{},2e3);try{process.kill(process.pid,c)}catch{process.kill(process.pid,"SIGTERM")}}else process.exit(l||0)}),process.send&&(process.removeAllListeners("message"),r.on("message",(l,c)=>{var h;(h=process.send)==null||h.call(process,l,c)}),process.on("message",(l,c)=>{r.send(l,c)})),r}var xi=s=>!!s&&typeof s=="object"&&typeof s.then=="function";0&&(module.exports={foregroundChild,program});
|