comp-hub 0.44.11 → 0.44.22

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 CHANGED
@@ -38,7 +38,13 @@ comphub
38
38
 
39
39
  Once started, open the URL shown in the terminal (default `http://localhost:5478`).
40
40
 
41
- > `ch` is a shorthand alias for `comphub` — all commands below work interchangeably, e.g. `ch`, `ch status`, `ch -p 8080`.
41
+ **Without installing** — npx fetches the CLI on demand:
42
+
43
+ ```bash
44
+ npx comp-hub
45
+ ```
46
+
47
+ > The CLI is published with three binary names — `comphub`, `ch` and `comp-hub` — all identical. Every command below works with any of them, e.g. `ch status`, `comp-hub -p 8080`.
42
48
 
43
49
  ### CLI Options
44
50
 
@@ -127,7 +133,7 @@ module.exports = {
127
133
  - Upload components as **folders** — folder name is the component name
128
134
  - Entry point: `index.vue` (Vue) or `index.jsx`/`index.tsx` (React)
129
135
  - Include a `README.md` describing usage
130
- - Optional `comp.json` for component metadata (name, version, dependencies, etc.)
136
+ - `comp.json` is generated by the platform and holds only `__id__`, `name` and `version` — dependencies are detected from your source `import` statements, not declared here
131
137
  - Optional `demo/` directory for preview configs
132
138
 
133
139
  ## Links
package/dist/cli.js CHANGED
@@ -1,44 +1,44 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var sr=Object.create;var Se=Object.defineProperty;var ar=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var cr=Object.getPrototypeOf,ur=Object.prototype.hasOwnProperty;var S=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var pr=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of lr(e))!ur.call(i,o)&&o!==t&&Se(i,o,{get:()=>e[o],enumerable:!(r=ar(e,o))||r.enumerable});return i};var d=(i,e,t)=>(t=i!=null?sr(cr(i)):{},pr(e||!i||!i.__esModule?Se(t,"default",{value:i,enumerable:!0}):t,i));var U=S(te=>{var Y=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},ee=class extends Y{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};te.CommanderError=Y;te.InvalidArgumentError=ee});var G=S(oe=>{var{InvalidArgumentError:hn}=U(),re=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,r)=>{if(!this.argChoices.includes(t))throw new hn(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function _n(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}oe.Argument=re;oe.humanReadableArgName=_n});var ie=S(ft=>{var{humanReadableArgName:mn}=G(),ne=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(r=>!r._hidden);if(e._hasImplicitHelpCommand()){let[,r,o]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),n=e.createCommand(r).helpOption(!1);n.description(e._helpCommandDescription),o&&n.arguments(o),t.push(n)}return this.sortSubcommands&&t.sort((r,o)=>r.name().localeCompare(o.name())),t}compareOptions(e,t){let r=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(n=>!n.hidden),r=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),o=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(r||o){let n;r?o?n=e.createOption(e._helpFlags,e._helpDescription):n=e.createOption(e._helpShortFlag,e._helpDescription):n=e.createOption(e._helpLongFlag,e._helpDescription),t.push(n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let o=r.options.filter(n=>!n.hidden);t.push(...o)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e._args.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e._args.find(t=>t.description)?e._args:[]}subcommandTerm(e){let t=e._args.map(r=>mn(r)).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((r,o)=>Math.max(r,t.subcommandTerm(o).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,o)=>Math.max(r,t.argumentTerm(o).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let o=e.parent;o;o=o.parent)r=o.name()+" "+r;return r+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(r=>JSON.stringify(r)).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(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),o=t.helpWidth||80,n=2,s=2;function l(_,x){if(x){let ir=`${_.padEnd(r+s)}${x}`;return t.wrap(ir,o-n,r+s)}return _}function a(_){return _.join(`
3
- `).replace(/^/gm," ".repeat(n))}let c=[`Usage: ${t.commandUsage(e)}`,""],u=t.commandDescription(e);u.length>0&&(c=c.concat([u,""]));let p=t.visibleArguments(e).map(_=>l(t.argumentTerm(_),t.argumentDescription(_)));p.length>0&&(c=c.concat(["Arguments:",a(p),""]));let m=t.visibleOptions(e).map(_=>l(t.optionTerm(_),t.optionDescription(_)));if(m.length>0&&(c=c.concat(["Options:",a(m),""])),this.showGlobalOptions){let _=t.visibleGlobalOptions(e).map(x=>l(t.optionTerm(x),t.optionDescription(x)));_.length>0&&(c=c.concat(["Global Options:",a(_),""]))}let O=t.visibleCommands(e).map(_=>l(t.subcommandTerm(_),t.subcommandDescription(_)));return O.length>0&&(c=c.concat(["Commands:",a(O),""])),c.join(`
4
- `)}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,r,o=40){if(e.match(/[\n]\s+/))return e;let n=t-r;if(n<o)return e;let s=e.slice(0,r),l=e.slice(r),a=" ".repeat(r),c=new RegExp(".{1,"+(n-1)+"}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)","g"),u=l.match(c)||[];return s+u.map((p,m)=>(p.slice(-1)===`
2
+ "use strict";var sr=Object.create;var Se=Object.defineProperty;var ar=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var cr=Object.getPrototypeOf,ur=Object.prototype.hasOwnProperty;var S=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var pr=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of lr(e))!ur.call(n,o)&&o!==t&&Se(n,o,{get:()=>e[o],enumerable:!(r=ar(e,o))||r.enumerable});return n};var d=(n,e,t)=>(t=n!=null?sr(cr(n)):{},pr(e||!n||!n.__esModule?Se(t,"default",{value:n,enumerable:!0}):t,n));var H=S(re=>{var G=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},te=class extends G{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};re.CommanderError=G;re.InvalidArgumentError=te});var B=S(ie=>{var{InvalidArgumentError:ui}=H(),oe=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,r)=>{if(!this.argChoices.includes(t))throw new ui(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function pi(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}ie.Argument=oe;ie.humanReadableArgName=pi});var se=S(Et=>{var{humanReadableArgName:hi}=B(),ne=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(r=>!r._hidden);if(e._hasImplicitHelpCommand()){let[,r,o]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),i=e.createCommand(r).helpOption(!1);i.description(e._helpCommandDescription),o&&i.arguments(o),t.push(i)}return this.sortSubcommands&&t.sort((r,o)=>r.name().localeCompare(o.name())),t}compareOptions(e,t){let r=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),r=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),o=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(r||o){let i;r?o?i=e.createOption(e._helpFlags,e._helpDescription):i=e.createOption(e._helpShortFlag,e._helpDescription):i=e.createOption(e._helpLongFlag,e._helpDescription),t.push(i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let o=r.options.filter(i=>!i.hidden);t.push(...o)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e._args.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e._args.find(t=>t.description)?e._args:[]}subcommandTerm(e){let t=e._args.map(r=>hi(r)).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((r,o)=>Math.max(r,t.subcommandTerm(o).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,o)=>Math.max(r,t.argumentTerm(o).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let o=e.parent;o;o=o.parent)r=o.name()+" "+r;return r+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(r=>JSON.stringify(r)).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(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),o=t.helpWidth||80,i=2,s=2;function l(_,U){if(U){let nr=`${_.padEnd(r+s)}${U}`;return t.wrap(nr,o-i,r+s)}return _}function a(_){return _.join(`
3
+ `).replace(/^/gm," ".repeat(i))}let c=[`Usage: ${t.commandUsage(e)}`,""],u=t.commandDescription(e);u.length>0&&(c=c.concat([u,""]));let p=t.visibleArguments(e).map(_=>l(t.argumentTerm(_),t.argumentDescription(_)));p.length>0&&(c=c.concat(["Arguments:",a(p),""]));let m=t.visibleOptions(e).map(_=>l(t.optionTerm(_),t.optionDescription(_)));if(m.length>0&&(c=c.concat(["Options:",a(m),""])),this.showGlobalOptions){let _=t.visibleGlobalOptions(e).map(U=>l(t.optionTerm(U),t.optionDescription(U)));_.length>0&&(c=c.concat(["Global Options:",a(_),""]))}let O=t.visibleCommands(e).map(_=>l(t.subcommandTerm(_),t.subcommandDescription(_)));return O.length>0&&(c=c.concat(["Commands:",a(O),""])),c.join(`
4
+ `)}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,r,o=40){if(e.match(/[\n]\s+/))return e;let i=t-r;if(i<o)return e;let s=e.slice(0,r),l=e.slice(r),a=" ".repeat(r),c=new RegExp(".{1,"+(i-1)+"}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)","g"),u=l.match(c)||[];return s+u.map((p,m)=>(p.slice(-1)===`
5
5
  `&&(p=p.slice(0,p.length-1)),(m>0?a:"")+p.trimRight())).join(`
6
- `)}};ft.Help=ne});var le=S(B=>{var{InvalidArgumentError:dn}=U(),se=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 r=gt(e);this.short=r.shortFlag,this.long=r.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){return this.implied=Object.assign(this.implied||{},e),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,r)=>{if(!this.argChoices.includes(t))throw new dn(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return En(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},ae=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,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let o=this.negativeOptions.get(r).presetArg,n=o!==void 0?o:!1;return t.negate===(n===e)}};function En(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function gt(i){let e,t,r=i.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),t=r.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}B.Option=se;B.splitOptionFlags=gt;B.DualOptions=ae});var At=S(Ot=>{function fn(i,e){if(Math.abs(i.length-e.length)>3)return Math.max(i.length,e.length);let t=[];for(let r=0;r<=i.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=i.length;o++){let n=1;i[o-1]===e[r-1]?n=0:n=1,t[o][r]=Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+n),o>1&&r>1&&i[o-1]===e[r-2]&&i[o-2]===e[r-1]&&(t[o][r]=Math.min(t[o][r],t[o-2][r-2]+1))}return t[i.length][e.length]}function gn(i,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=i.startsWith("--");t&&(i=i.slice(2),e=e.map(s=>s.slice(2)));let r=[],o=3,n=.4;return e.forEach(s=>{if(s.length<=1)return;let l=fn(i,s),a=Math.max(i.length,s.length);(a-l)/a>n&&(l<o?(o=l,r=[s]):l===o&&r.push(s))}),r.sort((s,l)=>s.localeCompare(l)),t&&(r=r.map(s=>`--${s}`)),r.length>1?`
6
+ `)}};Et.Help=ne});var ce=S(W=>{var{InvalidArgumentError:_i}=H(),ae=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 r=ft(e);this.short=r.shortFlag,this.long=r.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){return this.implied=Object.assign(this.implied||{},e),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,r)=>{if(!this.argChoices.includes(t))throw new _i(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return mi(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},le=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,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let o=this.negativeOptions.get(r).presetArg,i=o!==void 0?o:!1;return t.negate===(i===e)}};function mi(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ft(n){let e,t,r=n.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),t=r.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}W.Option=ae;W.splitOptionFlags=ft;W.DualOptions=le});var Ot=S(gt=>{function di(n,e){if(Math.abs(n.length-e.length)>3)return Math.max(n.length,e.length);let t=[];for(let r=0;r<=n.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=n.length;o++){let i=1;n[o-1]===e[r-1]?i=0:i=1,t[o][r]=Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+i),o>1&&r>1&&n[o-1]===e[r-2]&&n[o-2]===e[r-1]&&(t[o][r]=Math.min(t[o][r],t[o-2][r-2]+1))}return t[n.length][e.length]}function Ei(n,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=n.startsWith("--");t&&(n=n.slice(2),e=e.map(s=>s.slice(2)));let r=[],o=3,i=.4;return e.forEach(s=>{if(s.length<=1)return;let l=di(n,s),a=Math.max(n.length,s.length);(a-l)/a>i&&(l<o?(o=l,r=[s]):l===o&&r.push(s))}),r.sort((s,l)=>s.localeCompare(l)),t&&(r=r.map(s=>`--${s}`)),r.length>1?`
7
7
  (Did you mean one of ${r.join(", ")}?)`:r.length===1?`
8
- (Did you mean ${r[0]}?)`:""}Ot.suggestSimilar=gn});var Rt=S(Mt=>{var On=require("events").EventEmitter,ce=require("child_process"),P=require("path"),ue=require("fs"),h=require("process"),{Argument:An,humanReadableArgName:Cn}=G(),{CommanderError:pe}=U(),{Help:Tn}=ie(),{Option:Ct,splitOptionFlags:Pn,DualOptions:Sn}=le(),{suggestSimilar:Tt}=At(),he=class i extends On{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this._args=[],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=>h.stdout.write(t),writeErr:t=>h.stderr.write(t),getOutHelpWidth:()=>h.stdout.isTTY?h.stdout.columns:void 0,getErrHelpWidth:()=>h.stderr.isTTY?h.stderr.columns:void 0,outputError:(t,r)=>r(t)},this._hidden=!1,this._hasHelpOption=!0,this._helpFlags="-h, --help",this._helpDescription="display help for command",this._helpShortFlag="-h",this._helpLongFlag="--help",this._addImplicitHelpCommand=void 0,this._helpCommandName="help",this._helpCommandnameAndArgs="help [command]",this._helpCommandDescription="display help for command",this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._hasHelpOption=e._hasHelpOption,this._helpFlags=e._helpFlags,this._helpDescription=e._helpDescription,this._helpShortFlag=e._helpShortFlag,this._helpLongFlag=e._helpLongFlag,this._helpCommandName=e._helpCommandName,this._helpCommandnameAndArgs=e._helpCommandnameAndArgs,this._helpCommandDescription=e._helpCommandDescription,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}command(e,t,r){let o=t,n=r;typeof o=="object"&&o!==null&&(n=o,o=null),n=n||{};let[,s,l]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return o&&(a.description(o),a._executableHandler=!0),n.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(n.noHelp||n.hidden),a._executableFile=n.executableFile||null,l&&a.arguments(l),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),o?this:a}createCommand(e){return new i(e)}createHelp(){return Object.assign(new Tn,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
9
- - 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.commands.push(e),e.parent=this,this}createArgument(e,t){return new An(e,t)}argument(e,t,r,o){let n=this.createArgument(e,t);return typeof r=="function"?n.default(o).argParser(r):n.default(r),this.addArgument(n),this}arguments(e){return e.split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this._args.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this._args.push(e),this}addHelpCommand(e,t){return e===!1?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,typeof e=="string"&&(this._helpCommandName=e.split(" ")[0],this._helpCommandnameAndArgs=e),this._helpCommandDescription=t||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return this._addImplicitHelpCommand===void 0?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
10
- Expecting one of '${r.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,r){this._exitCallback&&this._exitCallback(new pe(e,t,r)),h.exit(e)}action(e){let t=r=>{let o=this._args.length,n=r.slice(0,o);return this._storeOptionsAsProperties?n[o]=this:n[o]=this.opts(),n.push(this),e.apply(this,n)};return this._actionHandler=t,this}createOption(e,t){return new Ct(e,t)}addOption(e){let t=e.name(),r=e.attributeName();if(e.negate){let n=e.long.replace(/^--no-/,"--");this._findOption(n)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");this.options.push(e);let o=(n,s,l)=>{n==null&&e.presetArg!==void 0&&(n=e.presetArg);let a=this.getOptionValue(r);if(n!==null&&e.parseArg)try{n=e.parseArg(n,a)}catch(c){if(c.code==="commander.invalidArgument"){let u=`${s} ${c.message}`;this.error(u,{exitCode:c.exitCode,code:c.code})}throw c}else n!==null&&e.variadic&&(n=e._concatValue(n,a));n==null&&(e.negate?n=!1:e.isBoolean()||e.optional?n=!0:n=""),this.setOptionValueWithSource(r,n,l)};return this.on("option:"+t,n=>{let s=`error: option '${e.flags}' argument '${n}' is invalid.`;o(n,s,"cli")}),e.envVar&&this.on("optionEnv:"+t,n=>{let s=`error: option '${e.flags}' value '${n}' from env '${e.envVar}' is invalid.`;o(n,s,"env")}),this}_optionEx(e,t,r,o,n){if(typeof t=="object"&&t instanceof Ct)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(t,r);if(s.makeOptionMandatory(!!e.mandatory),typeof o=="function")s.default(n).argParser(o);else if(o instanceof RegExp){let l=o;o=(a,c)=>{let u=l.exec(a);return u?u[0]:c},s.default(n).argParser(o)}else s.default(o);return this.addOption(s)}option(e,t,r,o){return this._optionEx({},e,t,r,o)}requiredOption(e,t,r,o){return this._optionEx({mandatory:!0},e,t,r,o)}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){if(this._passThroughOptions=!!e,this.parent&&e&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(e=!0){if(this._storeOptionsAsProperties=!!e,this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return H(this).forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");t=t||{},e===void 0&&(e=h.argv,h.versions&&h.versions.electron&&(t.from="electron")),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":h.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);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",r}parse(e,t){let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_executeSubCommand(e,t){t=t.slice();let r=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function n(u,p){let m=P.resolve(u,p);if(ue.existsSync(m))return m;if(o.includes(P.extname(p)))return;let O=o.find(_=>ue.existsSync(`${m}${_}`));if(O)return`${m}${O}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let u;try{u=ue.realpathSync(this._scriptPath)}catch{u=this._scriptPath}l=P.resolve(P.dirname(u),l)}if(l){let u=n(l,s);if(!u&&!e._executableFile&&this._scriptPath){let p=P.basename(this._scriptPath,P.extname(this._scriptPath));p!==this._name&&(u=n(l,`${p}-${e._name}`))}s=u||s}r=o.includes(P.extname(s));let a;h.platform!=="win32"?r?(t.unshift(s),t=St(h.execArgv).concat(t),a=ce.spawn(h.argv[0],t,{stdio:"inherit"})):a=ce.spawn(s,t,{stdio:"inherit"}):(t.unshift(s),t=St(h.execArgv).concat(t),a=ce.spawn(h.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(p=>{h.on(p,()=>{a.killed===!1&&a.exitCode===null&&a.kill(p)})});let c=this._exitCallback;c?a.on("close",()=>{c(new pe(h.exitCode||0,"commander.executeSubCommandAsync","(close)"))}):a.on("close",h.exit.bind(h)),a.on("error",u=>{if(u.code==="ENOENT"){let p=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",m=`'${s}' does not exist
8
+ (Did you mean ${r[0]}?)`:""}gt.suggestSimilar=Ei});var Mt=S(St=>{var fi=require("events").EventEmitter,ue=require("child_process"),P=require("path"),pe=require("fs"),h=require("process"),{Argument:gi,humanReadableArgName:Oi}=B(),{CommanderError:he}=H(),{Help:Ai}=se(),{Option:At,splitOptionFlags:Ci,DualOptions:Ti}=ce(),{suggestSimilar:Ct}=Ot(),_e=class n extends fi{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this._args=[],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=>h.stdout.write(t),writeErr:t=>h.stderr.write(t),getOutHelpWidth:()=>h.stdout.isTTY?h.stdout.columns:void 0,getErrHelpWidth:()=>h.stderr.isTTY?h.stderr.columns:void 0,outputError:(t,r)=>r(t)},this._hidden=!1,this._hasHelpOption=!0,this._helpFlags="-h, --help",this._helpDescription="display help for command",this._helpShortFlag="-h",this._helpLongFlag="--help",this._addImplicitHelpCommand=void 0,this._helpCommandName="help",this._helpCommandnameAndArgs="help [command]",this._helpCommandDescription="display help for command",this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._hasHelpOption=e._hasHelpOption,this._helpFlags=e._helpFlags,this._helpDescription=e._helpDescription,this._helpShortFlag=e._helpShortFlag,this._helpLongFlag=e._helpLongFlag,this._helpCommandName=e._helpCommandName,this._helpCommandnameAndArgs=e._helpCommandnameAndArgs,this._helpCommandDescription=e._helpCommandDescription,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}command(e,t,r){let o=t,i=r;typeof o=="object"&&o!==null&&(i=o,o=null),i=i||{};let[,s,l]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return o&&(a.description(o),a._executableHandler=!0),i.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(i.noHelp||i.hidden),a._executableFile=i.executableFile||null,l&&a.arguments(l),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),o?this:a}createCommand(e){return new n(e)}createHelp(){return Object.assign(new Ai,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
9
+ - 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.commands.push(e),e.parent=this,this}createArgument(e,t){return new gi(e,t)}argument(e,t,r,o){let i=this.createArgument(e,t);return typeof r=="function"?i.default(o).argParser(r):i.default(r),this.addArgument(i),this}arguments(e){return e.split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this._args.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this._args.push(e),this}addHelpCommand(e,t){return e===!1?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,typeof e=="string"&&(this._helpCommandName=e.split(" ")[0],this._helpCommandnameAndArgs=e),this._helpCommandDescription=t||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return this._addImplicitHelpCommand===void 0?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
10
+ Expecting one of '${r.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,r){this._exitCallback&&this._exitCallback(new he(e,t,r)),h.exit(e)}action(e){let t=r=>{let o=this._args.length,i=r.slice(0,o);return this._storeOptionsAsProperties?i[o]=this:i[o]=this.opts(),i.push(this),e.apply(this,i)};return this._actionHandler=t,this}createOption(e,t){return new At(e,t)}addOption(e){let t=e.name(),r=e.attributeName();if(e.negate){let i=e.long.replace(/^--no-/,"--");this._findOption(i)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");this.options.push(e);let o=(i,s,l)=>{i==null&&e.presetArg!==void 0&&(i=e.presetArg);let a=this.getOptionValue(r);if(i!==null&&e.parseArg)try{i=e.parseArg(i,a)}catch(c){if(c.code==="commander.invalidArgument"){let u=`${s} ${c.message}`;this.error(u,{exitCode:c.exitCode,code:c.code})}throw c}else i!==null&&e.variadic&&(i=e._concatValue(i,a));i==null&&(e.negate?i=!1:e.isBoolean()||e.optional?i=!0:i=""),this.setOptionValueWithSource(r,i,l)};return this.on("option:"+t,i=>{let s=`error: option '${e.flags}' argument '${i}' is invalid.`;o(i,s,"cli")}),e.envVar&&this.on("optionEnv:"+t,i=>{let s=`error: option '${e.flags}' value '${i}' from env '${e.envVar}' is invalid.`;o(i,s,"env")}),this}_optionEx(e,t,r,o,i){if(typeof t=="object"&&t instanceof At)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(t,r);if(s.makeOptionMandatory(!!e.mandatory),typeof o=="function")s.default(i).argParser(o);else if(o instanceof RegExp){let l=o;o=(a,c)=>{let u=l.exec(a);return u?u[0]:c},s.default(i).argParser(o)}else s.default(o);return this.addOption(s)}option(e,t,r,o){return this._optionEx({},e,t,r,o)}requiredOption(e,t,r,o){return this._optionEx({mandatory:!0},e,t,r,o)}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){if(this._passThroughOptions=!!e,this.parent&&e&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(e=!0){if(this._storeOptionsAsProperties=!!e,this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return $(this).forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");t=t||{},e===void 0&&(e=h.argv,h.versions&&h.versions.electron&&(t.from="electron")),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":h.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);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",r}parse(e,t){let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_executeSubCommand(e,t){t=t.slice();let r=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function i(u,p){let m=P.resolve(u,p);if(pe.existsSync(m))return m;if(o.includes(P.extname(p)))return;let O=o.find(_=>pe.existsSync(`${m}${_}`));if(O)return`${m}${O}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let u;try{u=pe.realpathSync(this._scriptPath)}catch{u=this._scriptPath}l=P.resolve(P.dirname(u),l)}if(l){let u=i(l,s);if(!u&&!e._executableFile&&this._scriptPath){let p=P.basename(this._scriptPath,P.extname(this._scriptPath));p!==this._name&&(u=i(l,`${p}-${e._name}`))}s=u||s}r=o.includes(P.extname(s));let a;h.platform!=="win32"?r?(t.unshift(s),t=Pt(h.execArgv).concat(t),a=ue.spawn(h.argv[0],t,{stdio:"inherit"})):a=ue.spawn(s,t,{stdio:"inherit"}):(t.unshift(s),t=Pt(h.execArgv).concat(t),a=ue.spawn(h.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(p=>{h.on(p,()=>{a.killed===!1&&a.exitCode===null&&a.kill(p)})});let c=this._exitCallback;c?a.on("close",()=>{c(new he(h.exitCode||0,"commander.executeSubCommandAsync","(close)"))}):a.on("close",h.exit.bind(h)),a.on("error",u=>{if(u.code==="ENOENT"){let p=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",m=`'${s}' does not exist
11
11
  - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
12
12
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
13
- - ${p}`;throw new Error(m)}else if(u.code==="EACCES")throw new Error(`'${s}' not executable`);if(!c)h.exit(1);else{let p=new pe(1,"commander.executeSubCommandAsync","(error)");p.nestedError=u,c(p)}}),this.runningCommand=a}_dispatchSubcommand(e,t,r){let o=this._findCommand(e);o||this.help({error:!0});let n;return n=this._chainOrCallSubCommandHook(n,o,"preSubcommand"),n=this._chainOrCall(n,()=>{if(o._executableHandler)this._executeSubCommand(o,t.concat(r));else return o._parseCommand(t,r)}),n}_checkNumberOfArguments(){this._args.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this._args.length>0&&this._args[this._args.length-1].variadic)&&this.args.length>this._args.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,o,n)=>{let s=o;if(o!==null&&r.parseArg)try{s=r.parseArg(o,n)}catch(l){if(l.code==="commander.invalidArgument"){let a=`error: command-argument value '${o}' is invalid for argument '${r.name()}'. ${l.message}`;this.error(a,{exitCode:l.exitCode,code:l.code})}throw l}return s};this._checkNumberOfArguments();let t=[];this._args.forEach((r,o)=>{let n=r.defaultValue;r.variadic?o<this.args.length?(n=this.args.slice(o),r.parseArg&&(n=n.reduce((s,l)=>e(r,l,s),r.defaultValue))):n===void 0&&(n=[]):o<this.args.length&&(n=this.args[o],r.parseArg&&(n=e(r,n,r.defaultValue))),t[o]=n}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,o=[];return H(this).reverse().filter(n=>n._lifeCycleHooks[t]!==void 0).forEach(n=>{n._lifeCycleHooks[t].forEach(s=>{o.push({hookedCommand:n,callback:s})})}),t==="postAction"&&o.reverse(),o.forEach(n=>{r=this._chainOrCall(r,()=>n.callback(n.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let o=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(n=>{o=this._chainOrCall(o,()=>n(this,t))}),o}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._hasImplicitHelpCommand()&&e[0]===this._helpCommandName)return e.length===1&&this.help(),this._dispatchSubcommand(e[1],[],[this._helpLongFlag]);if(this._defaultCommandName)return Pt(this,t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),Pt(this,r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(n,e,t)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent&&this.parent.listenerCount(n))o(),this._processArguments(),this.parent.emit(n,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():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),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(){for(let e=this;e;e=e.parent)e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let o=r.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let o=e.find(n=>r.conflictsWith.includes(n.attributeName()));o&&this._conflictingOption(r,o)})}_checkForConflictingOptions(){for(let e=this;e;e=e.parent)e._checkForConflictingLocalOptions()}parseOptions(e){let t=[],r=[],o=t,n=e.slice();function s(a){return a.length>1&&a[0]==="-"}let l=null;for(;n.length;){let a=n.shift();if(a==="--"){o===r&&o.push(a),o.push(...n);break}if(l&&!s(a)){this.emit(`option:${l.name()}`,a);continue}if(l=null,s(a)){let c=this._findOption(a);if(c){if(c.required){let u=n.shift();u===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,u)}else if(c.optional){let u=null;n.length>0&&!s(n[0])&&(u=n.shift()),this.emit(`option:${c.name()}`,u)}else this.emit(`option:${c.name()}`);l=c.variadic?c:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let c=this._findOption(`-${a[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,a.slice(2)):(this.emit(`option:${c.name()}`),n.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let c=a.indexOf("="),u=this._findOption(a.slice(0,c));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,a.slice(c+1));continue}}if(s(a)&&(o=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(a)){t.push(a),n.length>0&&r.push(...n);break}else if(a===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(a),n.length>0&&t.push(...n);break}else if(this._defaultCommandName){r.push(a),n.length>0&&r.push(...n);break}}if(this._passThroughOptions){o.push(a),n.length>0&&o.push(...n);break}o.push(a)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let o=this.options[r].attributeName();e[o]=o===this._versionOptionName?this._version:this[o]}return e}return this._optionValues}optsWithGlobals(){return H(this).reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
13
+ - ${p}`;throw new Error(m)}else if(u.code==="EACCES")throw new Error(`'${s}' not executable`);if(!c)h.exit(1);else{let p=new he(1,"commander.executeSubCommandAsync","(error)");p.nestedError=u,c(p)}}),this.runningCommand=a}_dispatchSubcommand(e,t,r){let o=this._findCommand(e);o||this.help({error:!0});let i;return i=this._chainOrCallSubCommandHook(i,o,"preSubcommand"),i=this._chainOrCall(i,()=>{if(o._executableHandler)this._executeSubCommand(o,t.concat(r));else return o._parseCommand(t,r)}),i}_checkNumberOfArguments(){this._args.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this._args.length>0&&this._args[this._args.length-1].variadic)&&this.args.length>this._args.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,o,i)=>{let s=o;if(o!==null&&r.parseArg)try{s=r.parseArg(o,i)}catch(l){if(l.code==="commander.invalidArgument"){let a=`error: command-argument value '${o}' is invalid for argument '${r.name()}'. ${l.message}`;this.error(a,{exitCode:l.exitCode,code:l.code})}throw l}return s};this._checkNumberOfArguments();let t=[];this._args.forEach((r,o)=>{let i=r.defaultValue;r.variadic?o<this.args.length?(i=this.args.slice(o),r.parseArg&&(i=i.reduce((s,l)=>e(r,l,s),r.defaultValue))):i===void 0&&(i=[]):o<this.args.length&&(i=this.args[o],r.parseArg&&(i=e(r,i,r.defaultValue))),t[o]=i}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,o=[];return $(this).reverse().filter(i=>i._lifeCycleHooks[t]!==void 0).forEach(i=>{i._lifeCycleHooks[t].forEach(s=>{o.push({hookedCommand:i,callback:s})})}),t==="postAction"&&o.reverse(),o.forEach(i=>{r=this._chainOrCall(r,()=>i.callback(i.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let o=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(i=>{o=this._chainOrCall(o,()=>i(this,t))}),o}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._hasImplicitHelpCommand()&&e[0]===this._helpCommandName)return e.length===1&&this.help(),this._dispatchSubcommand(e[1],[],[this._helpLongFlag]);if(this._defaultCommandName)return Tt(this,t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),Tt(this,r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(i,e,t)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent&&this.parent.listenerCount(i))o(),this._processArguments(),this.parent.emit(i,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():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),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(){for(let e=this;e;e=e.parent)e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let o=r.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let o=e.find(i=>r.conflictsWith.includes(i.attributeName()));o&&this._conflictingOption(r,o)})}_checkForConflictingOptions(){for(let e=this;e;e=e.parent)e._checkForConflictingLocalOptions()}parseOptions(e){let t=[],r=[],o=t,i=e.slice();function s(a){return a.length>1&&a[0]==="-"}let l=null;for(;i.length;){let a=i.shift();if(a==="--"){o===r&&o.push(a),o.push(...i);break}if(l&&!s(a)){this.emit(`option:${l.name()}`,a);continue}if(l=null,s(a)){let c=this._findOption(a);if(c){if(c.required){let u=i.shift();u===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,u)}else if(c.optional){let u=null;i.length>0&&!s(i[0])&&(u=i.shift()),this.emit(`option:${c.name()}`,u)}else this.emit(`option:${c.name()}`);l=c.variadic?c:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let c=this._findOption(`-${a[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,a.slice(2)):(this.emit(`option:${c.name()}`),i.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let c=a.indexOf("="),u=this._findOption(a.slice(0,c));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,a.slice(c+1));continue}}if(s(a)&&(o=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(a)){t.push(a),i.length>0&&r.push(...i);break}else if(a===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(a),i.length>0&&t.push(...i);break}else if(this._defaultCommandName){r.push(a),i.length>0&&r.push(...i);break}}if(this._passThroughOptions){o.push(a),i.length>0&&o.push(...i);break}o.push(a)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let o=this.options[r].attributeName();e[o]=o===this._versionOptionName?this._version:this[o]}return e}return this._optionValues}optsWithGlobals(){return $(this).reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
14
14
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
15
15
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
16
- `),this.outputHelp({error:!0}));let r=t||{},o=r.exitCode||1,n=r.code||"commander.error";this._exit(o,n,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in h.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()}`,h.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Sn(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(o=>!t(o)).forEach(o=>{this.setOptionValueWithSource(o,r.implied[o],"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 r=s=>{let l=s.attributeName(),a=this.getOptionValue(l),c=this.options.find(p=>p.negate&&l===p.attributeName()),u=this.options.find(p=>!p.negate&&l===p.attributeName());return c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg)?c:u||s},o=s=>{let l=r(s),a=l.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},n=`error: ${o(e)} cannot be used with ${o(t)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],n=this;do{let s=n.createHelp().visibleOptions(n).filter(l=>l.long).map(l=>l.long);o=o.concat(s),n=n.parent}while(n&&!n._enablePositionalOptions);t=Tt(e,o)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this._args.length,r=t===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(n=>{o.push(n.name()),n.alias()&&o.push(n.alias())}),t=Tt(e,o)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let o=this.createOption(t,r);return this._versionOptionName=o.attributeName(),this.options.push(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${e}
17
- `),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){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");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._args.map(r=>Cn(r));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.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=P.basename(e,P.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},r;return t.error?r=o=>this._outputConfiguration.writeErr(o):r=o=>this._outputConfiguration.writeOut(o),t.write=e.write||r,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getHelpContext(e);H(this).reverse().forEach(n=>n.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let o=this.helpInformation(r);if(t&&(o=t(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(o),this.emit(this._helpLongFlag),this.emit("afterHelp",r),H(this).forEach(n=>n.emit("afterAllHelp",r))}helpOption(e,t){if(typeof e=="boolean")return this._hasHelpOption=e,this;this._helpFlags=e||this._helpFlags,this._helpDescription=t||this._helpDescription;let r=Pn(this._helpFlags);return this._helpShortFlag=r.shortFlag,this._helpLongFlag=r.longFlag,this}help(e){this.outputHelp(e);let t=h.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
18
- Expecting one of '${r.join("', '")}'`);let o=`${e}Help`;return this.on(o,n=>{let s;typeof t=="function"?s=t({error:n.error,command:n.command}):s=t,s&&n.write(`${s}
19
- `)}),this}};function Pt(i,e){i._hasHelpOption&&e.find(r=>r===i._helpLongFlag||r===i._helpShortFlag)&&(i.outputHelp(),i._exit(0,"commander.helpDisplayed","(outputHelp)"))}function St(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",o="9229",n;return(n=e.match(/^(--inspect(-brk)?)$/))!==null?t=n[1]:(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=n[1],/^\d+$/.test(n[3])?o=n[3]:r=n[3]):(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=n[1],r=n[3],o=n[4]),t&&o!=="0"?`${t}=${r}:${parseInt(o)+1}`:e})}function H(i){let e=[];for(let t=i;t;t=t.parent)e.push(t);return e}Mt.Command=he});var Lt=S((A,Dt)=>{var{Argument:Mn}=G(),{Command:It}=Rt(),{CommanderError:Rn,InvalidArgumentError:bt}=U(),{Help:In}=ie(),{Option:bn}=le();A=Dt.exports=new It;A.program=A;A.Argument=Mn;A.Command=It;A.CommanderError=Rn;A.Help=In;A.InvalidArgumentError=bt;A.InvalidOptionArgumentError=bt;A.Option=bn});var $t=S((Mi,me)=>{"use strict";var xn=require("net"),K=class extends Error{constructor(e){super(`${e} is locked`)}},y={old:new Set,young:new Set},Un=1e3*15,W,Ht=i=>new Promise((e,t)=>{let r=xn.createServer();r.unref(),r.on("error",t),r.listen(i,()=>{let{port:o}=r.address();r.close(()=>{e(o)})})}),Hn=function*(i){i&&(yield*i),yield 0};me.exports=async i=>{let e;i&&(e=typeof i.port=="number"?[i.port]:i.port),W===void 0&&(W=setInterval(()=>{y.old=y.young,y.young=new Set},Un),W.unref&&W.unref());for(let t of Hn(e))try{let r=await Ht({...i,port:t});for(;y.old.has(r)||y.young.has(r);){if(t!==0)throw new K(t);r=await Ht({...i,port:t})}return y.young.add(r),r}catch(r){if(!["EADDRINUSE","EACCES"].includes(r.code)&&!(r instanceof K))throw r}throw new Error("No available ports found")};me.exports.makeRange=(i,e)=>{if(!Number.isInteger(i)||!Number.isInteger(e))throw new TypeError("`from` and `to` must be integer numbers");if(i<1024||i>65535)throw new RangeError("`from` must be between 1024 and 65535");if(e<1024||e>65536)throw new RangeError("`to` must be between 1024 and 65536");if(e<i)throw new RangeError("`to` must be greater than or equal to `from`");return function*(r,o){for(let n=r;n<=o;n++)yield n}(i,e)}});var N=d(require("fs")),mt=d(require("http")),w=d(require("path"));var it=d(require("path")),st=d(require("os"));var hr="Comp Hub",_r="main",mr="container",dr="item",Er="/__global_config__",fr="local://",gr="comphubConfig",Or="https://intranet.comphub.cn",Ar="https://iframe.comphub.cn",Cr="https://cdn.comphub.cn/vendor",Tr="__remote__",Pr="__local__",Sr="__admin__",Mr="https://api.comphub.cn",Rr="http://localhost:7002",Ir="http://127.0.0.1:5000",br="http://localhost:5001",Dr="http://localhost:3580",Lr="https://apiadmin.comphub.cn",Nr="https://admin.comphub.cn",wr="/_module_load_prefix_",yr="/_node_modules_load_prefix_",xr="/_comp_preview_prefix_local_",Ur="/__proxy__",Hr="/__master__",$r="authorization",vr="x-refresh-token",Fr="accept-language",Vr="X-Token-Refreshed",kr="team-id",jr="comp-hub-db",Yr="file-compiled",Gr="https://oss.comphub.cn",Br="oss:sts:token",Wr="oss:sts:expire",Kr="https://prebuild.comphub.cn",qr="/dev",Xr="/prod",Jr="/node_modules/.prebuild_module",zr="_metadata.json",Zr="vue/dist/vue.esm-bundler.js",Qr="react-jsx-loader",eo="vue3-sfc-loader",to="vue2-sfc-loader",ro="sass-compiler",oo="less-compiler",Me="react",no={COMP_FRAMEWORK_VUE:"vue",COMP_FRAMEWORK_REACT:Me},io="comp.json",so="README.md",ao="main.js",lo="index.vue",co=["index.jsx","index.js","index.tsx"],uo="/.comp_hub_temp",po="screenshot_mini.png",ho=1024*1024*10,_o=1024*1024*3,mo=30,Re="list_local",Ie="list_remote",Eo={COMP_LIST_TYPE_LOCAL:Re,COMP_LIST_TYPE_REMOTE:Ie},be="config",De="error",Le="dir",Ne="preview",we="extra",ye="deps",xe="readme",Ue="upgradeLog",fo={TAB_TYPE_CONFIG:be,TAB_TYPE_ERROR:De,TAB_TYPE_DIR:Le,TAB_TYPE_PREVIEW:Ne,TAB_TYPE_EXTRA:we,TAB_TYPE_DEPS:ye,TAB_TYPE_README:xe,TAB_TYPE_UPGRADE_LOG:Ue},He="mini",$e="full",go={COMP_EDIT_TAB_TYPE_MINI:He,COMP_EDIT_TAB_TYPE_FULL:$e},ve="EDIT",Fe="ADD",Oo={DIALOG_TYPE_EDIT:ve,DIALOG_TYPE_ADD:Fe},Ve="ONLY_INSTALL",ke="AUTO",je="MAJOR_VERSION",Ye="MINOR_VERSION",Ge="EXACT_VERSION",Ao={COMP_MATCH_TYPE_ONLY_INSTALL:Ve,COMP_MATCH_TYPE_AUTO:ke,COMP_MATCH_TYPE_MAJOR_VERSION:je,COMP_MATCH_TYPE_MINOR_VERSION:Ye,COMP_MATCH_TYPE_EXACT_VERSION:Ge},Be="online",We="offline",Co={COMP_UPDATE_TYPE_ONLINE:Be,COMP_UPDATE_TYPE_OFFLINE:We},Ke="NOT_EXIST",qe="EXIST",To={COMP_CHECK_STATUS_NOT_EXIST:Ke,COMP_CHECK_STATUS_EXIST:qe},Po="__id__",So=0,Mo=1,Ro=-1,Xe="checkPreviewListForm",Je="checkExtraInfoForm",ze="checkCompConfig",Ze="checkUpgradeLogForm",Qe="getCompError",et="afterCompDel",tt="afterCompCancelCollect",rt="afterCompRenderRetry",ot="openCompTerminal",Io={COMP_METHOD_KEY_CHECK_PREVIEW_LIST_FORM:Xe,COMP_METHOD_KEY_CHECK_EXTRA_INFO_FORM:Je,COMP_METHOD_KEY_CHECK_COMP_CONFIG:ze,COMP_METHOD_KEY_CHECK_UPGRADE_LOG_FORM:Ze,COMP_METHOD_KEY_GET_COMP_ERROR:Qe,COMP_METHOD_KEY_AFTER_COMP_DEL:et,COMP_METHOD_KEY_AFTER_COMP_CANCEL_COLLECT:tt,COMP_METHOD_KEY_AFTER_COMP_RENDER_RETRY:rt,COMP_METHOD_KEY_OPEN_COMP_TERMINAL:ot},bo="compListStore",Do="compEditStore",Lo="callbacks",No={CONTAINER:{SHARE:"share",COLLECT:"collect",LOCAL:"local",MINE:"mine",SIMILAR:"similar",TEAM_ALL:"teamAll",TEAM_MINE:"teamMine",TEAM_GROUP:"teamGroup",TEAM_ADD:"teamAdd"},ITEM:{PREVIEW_REMOTE:"previewRemote",PREVIEW_LOCAL:"previewLocal",CAROUSEL_REMOTE:"carouselRemote",CAROUSEL_LOCAL:"carouselLocal",EDIT_PANEL:"editPanel",STORAGE_WORKER:"storageWorker"}},wo="http://127.0.0.1",yo="http://localhost:8095",xo="http://localhost:8096",Uo="http://localhost:5198",Ho="http://localhost:3056",$o="https://www.comphub.cn",vo="http://localhost:8101",Fo="https://render.comphub.cn",Vo="/item",ko="/container",jo="CREATE",Yo="JOIN",Go="EXIT",Bo="teamAddMyComp",Wo="teamCompList",Ko="teamCompGroupList",qo="teamMyCompList",Xo="teamMyCompUpdate",Jo="__v__",zo="local",Zo="prod",Qo="local",en="prod",tn="http://localhost:5173",rn="https://docs.comphub.cn",on="1.5em",nn="1.5em",sn="SUPER_ADMIN",an="ADMIN",v={MAIN:"main",IFRAME_CONTAINER:"iframeContainer",IFRAME_ITEM:"iframeItem"},ln={[v.MAIN]:{ENABLED:!0,DSN:"https://eb372d9ca4c4b35497e99966cae2c1b2@o4512055411146752.ingest.us.sentry.io/4512055626891264",TRACES_SAMPLE_RATE:1,TRACE_PROPAGATION_TARGETS:["localhost"]},[v.IFRAME_CONTAINER]:{ENABLED:!0,DSN:"https://09eacfc954a80beb1aed90bbdb09b3f6@o4512055411146752.ingest.us.sentry.io/4512055609720832",TRACES_SAMPLE_RATE:1,TRACE_PROPAGATION_TARGETS:["localhost"]},[v.IFRAME_ITEM]:{ENABLED:!0,DSN:"https://0a564c86371356eccceff7854690e489@o4512055411146752.ingest.us.sentry.io/4512055615029249",TRACES_SAMPLE_RATE:1,TRACE_PROPAGATION_TARGETS:["localhost"]}},cn={"vue3-sfc-loader":"vue3-sfc-loader-f3c985c9.js","vue2-sfc-loader":"vue2-sfc-loader-445fb53a.js","react-jsx-loader":"react-jsx-loader-b8a3bbcb.js","sass-compiler":"sass-compiler-482885df.js","less-compiler":"less-compiler-0cc8346f.js"},nt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPT_LANGUAGE_HEADER_NAME:Fr,ADMIN_SERVICE_PREFIX:Sr,ADMIN_SERVICE_URL_DEV:Dr,ADMIN_SERVICE_URL_PROD:Lr,ADMIN_WEB_URL_PROD:Nr,AUTHORIZATION_HEADER_NAME:$r,CACHE_KEY_STS_EXPIRE_TIME:Wr,CACHE_KEY_STS_TOKEN:Br,COMPHUB_CONFIG_KEY:gr,COMP_ACTION_ICON_HEIGHT:nn,COMP_ACTION_ICON_WIDTH:on,COMP_CHECK_STATUSES:To,COMP_CHECK_STATUS_EXIST:qe,COMP_CHECK_STATUS_NOT_EXIST:Ke,COMP_CONFIG_FILENAME:io,COMP_EDIT_TAB_TYPES:go,COMP_EDIT_TAB_TYPE_FULL:$e,COMP_EDIT_TAB_TYPE_MINI:He,COMP_ENTRY_FILE:ao,COMP_FIELD_COMP_ID:Po,COMP_FRAMEWORK_REACT:Me,COMP_FRAMEWORK_TYPES:no,COMP_FRAMEWORK_VUE:"vue",COMP_HUB_DEV_DOCS_URL:tn,COMP_HUB_PROD_DOCS_URL:rn,COMP_LIST_TYPES:Eo,COMP_LIST_TYPE_LOCAL:Re,COMP_LIST_TYPE_REMOTE:Ie,COMP_MATCH_TYPES:Ao,COMP_MATCH_TYPE_AUTO:ke,COMP_MATCH_TYPE_EXACT_VERSION:Ge,COMP_MATCH_TYPE_MAJOR_VERSION:je,COMP_MATCH_TYPE_MINOR_VERSION:Ye,COMP_MATCH_TYPE_ONLY_INSTALL:Ve,COMP_METHOD_KEY_AFTER_COMP_CANCEL_COLLECT:tt,COMP_METHOD_KEY_AFTER_COMP_DEL:et,COMP_METHOD_KEY_AFTER_COMP_RENDER_RETRY:rt,COMP_METHOD_KEY_CHECK_COMP_CONFIG:ze,COMP_METHOD_KEY_CHECK_EXTRA_INFO_FORM:Je,COMP_METHOD_KEY_CHECK_PREVIEW_LIST_FORM:Xe,COMP_METHOD_KEY_CHECK_UPGRADE_LOG_FORM:Ze,COMP_METHOD_KEY_GET_COMP_ERROR:Qe,COMP_METHOD_KEY_OPEN_COMP_TERMINAL:ot,COMP_PREVIEW_PREFIX_LOCAL:xr,COMP_README_FILENAME:so,COMP_SCREENSHOT_MINI_FILENAME:po,COMP_SUBMIT_MAX_FILE_COUNT:mo,COMP_SUBMIT_MAX_SINGLE_FILE_SIZE:_o,COMP_SUBMIT_MAX_TOTAL_SIZE:ho,COMP_TEMP_DIR:uo,COMP_UPDATE_TYPES:Co,COMP_UPDATE_TYPE_OFFLINE:We,COMP_UPDATE_TYPE_ONLINE:Be,COMP_USE_ENTRY_FILE:lo,COMP_USE_ENTRY_FILE_REACT:co,DIALOG_TYPES:Oo,DIALOG_TYPE_ADD:Fe,DIALOG_TYPE_EDIT:ve,FILE_MANAGER_DIRNAME:fr,GLOBAL_CONFIG_PATH:Er,IFRAME_CONTAINER_WEBSITE_PATH:ko,IFRAME_HOST:wo,IFRAME_ITEM_WEBSITE_PATH:Vo,IFRAME_ROUTES:No,INDEX_DB_NAME:jr,INDEX_DB_TABLE_NAME:Yr,LESS_COMPILER_KEY:oo,LOCAL_CHILD_IFRAME_URL:yo,LOCAL_ITEM_EXTRANET_URL:vo,LOCAL_LEAF_IFRAME_URL:xo,LOCAL_MAIN_EXTRANET_URL:Ho,LOCAL_MIDWAY_ENV_LOCAL:zo,LOCAL_MIDWAY_ENV_PROD:Zo,LOCAL_SERVICE_PREFIX:Pr,LOCAL_SERVICE_URL_DEV:Ir,LOCAL_SERVICE_URL_DEV_SUB:br,LOCAL_TOP_IFRAME_URL:Uo,MASTER_API_PREFIX:Hr,META_FILE_NAME:zr,MODULE_LOAD_PREFIX:wr,NODE_MODULES_LOAD_PREFIX:yr,OSS_CUSTOM_DOMAIN:Gr,PREBUILD_HOST:Kr,PREBUILD_MAX_SINGLE_FILE_SIZE:52428800,PREBUILD_MODULE_DIR:Jr,PREBUILD_MODULE_DIR_DEV:qr,PREBUILD_MODULE_DIR_PROD:Xr,PROVIDE_KEYS:Io,PROVIDE_KEY_CALLBACKS:Lo,PROVIDE_KEY_COMP_EDIT_STORE:Do,PROVIDE_KEY_COMP_LIST_STORE:bo,PROXY_PATH_PREFIX:Ur,REACT_JSX_LOADER_KEY:Qr,REFRESH_TOKEN_HEADER_NAME:vr,REMOTE_ITEM_EXTRANET_URL:Fo,REMOTE_MAIN_EXTRANET_URL:$o,REMOTE_MIDWAY_ENV_LOCAL:Qo,REMOTE_MIDWAY_ENV_PROD:en,REMOTE_SERVICE_PREFIX:Tr,REMOTE_SERVICE_URL_DEV:Rr,REMOTE_SERVICE_URL_PROD:Mr,ROLE_CODE_ADMIN:an,ROLE_CODE_SUPER_ADMIN:sn,ROUTE_STATE_KEY_VERSION:Jo,SASS_COMPILER_KEY:ro,SCOPE_ID_TEAM_ADD_MY_COMP:Bo,SCOPE_ID_TEAM_COMP_GROUP_LIST:Ko,SCOPE_ID_TEAM_COMP_LIST:Wo,SCOPE_ID_TEAM_MY_COMP_LIST:qo,SCOPE_ID_TEAM_MY_COMP_UPDATE:Xo,SENTRY_PROJECTS:ln,SENTRY_PROJECT_NAMES:v,SITE_TITLE:hr,TAB_TYPES:fo,TAB_TYPE_CONFIG:be,TAB_TYPE_DEPS:ye,TAB_TYPE_DIR:Le,TAB_TYPE_ERROR:De,TAB_TYPE_EXTRA:we,TAB_TYPE_PREVIEW:Ne,TAB_TYPE_README:xe,TAB_TYPE_UPGRADE_LOG:Ue,TEAM_ID_HEADER_NAME:kr,TEAM_OPERATE_TYPE_CREATE:jo,TEAM_OPERATE_TYPE_EXIT:Go,TEAM_OPERATE_TYPE_JOIN:Yo,VENDOR_CDN_BASE:Cr,VENDOR_LOADER_FILES:cn,VERSION_COMPARE_GREATER:Mo,VERSION_COMPARE_LESS:Ro,VERSION_COMPARE_SAME:So,VUE2_SFC_LOADER_KEY:to,VUE3_SFC_LOADER_KEY:eo,VUE_ESM_BUNDLER:Zr,WEBSITE_OSS_URL_IFRAME:Ar,WEBSITE_OSS_URL_MAIN:Or,WEBSITE_PATH_CONTAINER:mr,WEBSITE_PATH_ITEM:dr,WEBSITE_PATH_MAIN:_r,X_TOKEN_REFRESHED_HEADER_NAME:Vr},Symbol.toStringTag,{value:"Module"}));var F=5478,at=nt.REMOTE_SERVICE_URL_PROD,I=it.default.join(st.default.tmpdir(),".comphub","master.json"),f={PREFIX:"/__master__",HEALTH:"/__master__/health",REGISTER:"/__master__/register",DEREGISTER:"/__master__/deregister",PROJECTS:"/__master__/projects",SHUTDOWN:"/__master__/shutdown"},lt=500,ct=40,ut=2e3,V=5e3;var Q=d(require("fs")),Z=d(require("path")),pt=d(require("crypto"));function k(i){return JSON.parse(Q.default.readFileSync(i,"utf8"))}function ht(i){let e=i;for(let t=0;t<12;t++){try{let o=Z.default.join(e,"package.json");if(Q.default.existsSync(o)){let n=k(o);if(n&&n.name==="comp-hub")return e}}catch{}let r=Z.default.dirname(e);if(r===e)break;e=r}return null}function _t(i){return pt.default.createHash("sha256").update(i).digest("hex").slice(0,8)}function g(i,e){return`http://localhost:${i}${e}`}var E={cyan:i=>`\x1B[36m${i}\x1B[0m`,green:i=>`\x1B[32m${i}\x1B[0m`,white:i=>`\x1B[37m${i}\x1B[0m`,yellow:i=>`\x1B[33m${i}\x1B[0m`,red:i=>`\x1B[31m${i}\x1B[0m`};var j=ht(__dirname)||w.default.resolve(__dirname,"..");function dt(){let i=w.default.join(j,"package.json"),e=k(i),t=w.default.join(j,e.main||"dist/index.js");return{pkg:e,entry:t}}function un(i){let e=w.default.join(i,".comphub.json"),t=w.default.join(i,".comphub.js");try{if(N.default.existsSync(e))return k(e)}catch{}try{if(N.default.existsSync(t)){let r=require(t);return r.default||r}}catch{}return{}}function Et(i,e){let t=un(e);return{dir:i.dir||t.dir||"./",api:i.api||t.api,allowDebug:i.allowDebug!=null?i.allowDebug:t.allowDebug!=null?t.allowDebug:!1,proxy:i.proxy||t.proxy,port:i.port,logLevel:i.logLevel||t.logLevel||"info"}}async function T(){try{if(N.default.existsSync(I)){let i=JSON.parse(N.default.readFileSync(I,"utf8"));try{if(process.kill(i.pid,0),await pn(i.managementPort))return i}catch{}try{N.default.unlinkSync(I)}catch{}}}catch{}return null}function pn(i){return new Promise(e=>{let t=mt.default.get(`http://localhost:${i}${f.HEALTH}`,r=>{let o="";r.on("data",n=>o+=n),r.on("end",()=>{try{let n=JSON.parse(o);e(typeof n.status=="string")}catch{e(!1)}})});t.on("error",()=>e(!1)),t.setTimeout(2e3,()=>{t.destroy(),e(!1)})})}var Nt=d(Lt(),1),{program:ui,createCommand:pi,createArgument:hi,createOption:_i,CommanderError:mi,InvalidArgumentError:di,InvalidOptionArgumentError:Ei,Command:wt,Argument:fi,Option:b,Help:gi}=Nt.default;function _e(i){let e=[{label:"d",divisor:86400},{label:"h",divisor:3600},{label:"m",divisor:60},{label:"s",divisor:1}],t=Math.floor(i),r=[];for(let{label:o,divisor:n}of e)if(t>=n){let s=Math.floor(t/n);t=t%n,r.push(`${s}${o}`)}return r.length>0?r.join(" "):"0s"}async function D(i){if(i.port!=null)return i.port;let e=await T();return e?e.managementPort:F}var zt=d(require("fs")),Zt=d(require("path"));var yt=d(require("http")),xt=d(require("https"));var Dn="/api/v2/upgrade/check";function Ln(i){return(i||at).replace(/\/+$/,"")}function Nn(i,e,t){return new Promise((r,o)=>{let n=i.startsWith("https:")?xt.default:yt.default,s=JSON.stringify(e),l=new URL(i),a={hostname:l.hostname,port:l.port||(l.protocol==="https:"?443:80),path:l.pathname+l.search,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},c=n.request(a,u=>{let p="";u.setEncoding("utf8"),u.on("data",m=>p+=m),u.on("end",()=>{let m=p;try{m=JSON.parse(p)}catch{}r({status:u.statusCode||0,body:m})})});c.on("error",o),c.setTimeout(t||V,()=>{c.destroy(new Error("Request timeout"))}),c.write(s),c.end()})}function wn(i){if(!i||i.status!==200)throw new Error(i.status?`HTTP ${i.status}`:"No response");let e=i.body?.data;if(!e||typeof e.hasUpgrade!="boolean")throw new Error("Invalid response format");return{hasUpgrade:e.hasUpgrade,isForce:!!e.isForce,latestVersion:typeof e.latestVersion=="string"?e.latestVersion:""}}function yn(i){return i.hasUpgrade&&i.isForce?"block":i.hasUpgrade?"notice":"none"}async function Ut(i){let{base:e,compHubVersion:t,timeout:r,request:o=Nn}=i,n=`${Ln(e)}${Dn}`;try{let s=await o(n,{compHubVersion:t},r),l=wn(s);return{ok:!0,...l,verdict:yn(l)}}catch(s){return{ok:!1,error:s?.message||String(s)}}}var Vt=d(require("fs")),kt=d(require("path")),jt=require("child_process"),de=d($t());var q=d(require("http"));function $n(i){try{return JSON.parse(i)}catch{return i}}function $(i){return new Promise(e=>{let t=q.default.get(i,r=>{let o="";r.on("data",n=>o+=n),r.on("end",()=>e({ok:!0,status:r.statusCode,body:$n(o)}))});t.on("error",r=>e({ok:!1,error:r.message})),t.setTimeout(ut,()=>{t.destroy(),e({ok:!1,error:"Request timeout"})})})}function M(i,e){return new Promise(t=>{let r=JSON.stringify(e),o=new URL(i),n={hostname:o.hostname,port:o.port,path:o.pathname,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},s=q.default.request(n,l=>{let a="";l.on("data",c=>a+=c),l.on("end",()=>{try{t({ok:!0,body:JSON.parse(a)})}catch{t({ok:!1,error:"Invalid JSON response"})}})});s.on("error",l=>t({ok:!1,error:l.message})),s.setTimeout(V,()=>{s.destroy(),t({ok:!1,error:"Request timeout"})}),s.write(r),s.end()})}function vt(i,e){return new Promise((t,r)=>{let o=new URL(i),n={hostname:o.hostname,port:o.port,path:o.pathname,method:"GET",headers:{Accept:"text/event-stream"}},s=q.default.request(n,l=>{if(l.statusCode!==200){r(new Error(`SSE connection failed (HTTP ${l.statusCode})`));return}let a="";l.on("data",c=>{a+=c.toString();let u=a.split(`
16
+ `),this.outputHelp({error:!0}));let r=t||{},o=r.exitCode||1,i=r.code||"commander.error";this._exit(o,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in h.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()}`,h.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Ti(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(o=>!t(o)).forEach(o=>{this.setOptionValueWithSource(o,r.implied[o],"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 r=s=>{let l=s.attributeName(),a=this.getOptionValue(l),c=this.options.find(p=>p.negate&&l===p.attributeName()),u=this.options.find(p=>!p.negate&&l===p.attributeName());return c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg)?c:u||s},o=s=>{let l=r(s),a=l.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},i=`error: ${o(e)} cannot be used with ${o(t)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],i=this;do{let s=i.createHelp().visibleOptions(i).filter(l=>l.long).map(l=>l.long);o=o.concat(s),i=i.parent}while(i&&!i._enablePositionalOptions);t=Ct(e,o)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this._args.length,r=t===1?"":"s",i=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(i,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(i=>{o.push(i.name()),i.alias()&&o.push(i.alias())}),t=Ct(e,o)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let o=this.createOption(t,r);return this._versionOptionName=o.attributeName(),this.options.push(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${e}
17
+ `),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){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");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._args.map(r=>Oi(r));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.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=P.basename(e,P.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},r;return t.error?r=o=>this._outputConfiguration.writeErr(o):r=o=>this._outputConfiguration.writeOut(o),t.write=e.write||r,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getHelpContext(e);$(this).reverse().forEach(i=>i.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let o=this.helpInformation(r);if(t&&(o=t(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(o),this.emit(this._helpLongFlag),this.emit("afterHelp",r),$(this).forEach(i=>i.emit("afterAllHelp",r))}helpOption(e,t){if(typeof e=="boolean")return this._hasHelpOption=e,this;this._helpFlags=e||this._helpFlags,this._helpDescription=t||this._helpDescription;let r=Ci(this._helpFlags);return this._helpShortFlag=r.shortFlag,this._helpLongFlag=r.longFlag,this}help(e){this.outputHelp(e);let t=h.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
18
+ Expecting one of '${r.join("', '")}'`);let o=`${e}Help`;return this.on(o,i=>{let s;typeof t=="function"?s=t({error:i.error,command:i.command}):s=t,s&&i.write(`${s}
19
+ `)}),this}};function Tt(n,e){n._hasHelpOption&&e.find(r=>r===n._helpLongFlag||r===n._helpShortFlag)&&(n.outputHelp(),n._exit(0,"commander.helpDisplayed","(outputHelp)"))}function Pt(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",o="9229",i;return(i=e.match(/^(--inspect(-brk)?)$/))!==null?t=i[1]:(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=i[1],/^\d+$/.test(i[3])?o=i[3]:r=i[3]):(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],r=i[3],o=i[4]),t&&o!=="0"?`${t}=${r}:${parseInt(o)+1}`:e})}function $(n){let e=[];for(let t=n;t;t=t.parent)e.push(t);return e}St.Command=_e});var Dt=S((A,bt)=>{var{Argument:Pi}=B(),{Command:Rt}=Mt(),{CommanderError:Si,InvalidArgumentError:It}=H(),{Help:Mi}=se(),{Option:Ri}=ce();A=bt.exports=new Rt;A.program=A;A.Argument=Pi;A.Command=Rt;A.CommanderError=Si;A.Help=Mi;A.InvalidArgumentError=It;A.InvalidOptionArgumentError=It;A.Option=Ri});var Ht=S((Cn,me)=>{"use strict";var wi=require("net"),q=class extends Error{constructor(e){super(`${e} is locked`)}},y={old:new Set,young:new Set},yi=1e3*15,K,Ut=n=>new Promise((e,t)=>{let r=wi.createServer();r.unref(),r.on("error",t),r.listen(n,()=>{let{port:o}=r.address();r.close(()=>{e(o)})})}),xi=function*(n){n&&(yield*n),yield 0};me.exports=async n=>{let e;n&&(e=typeof n.port=="number"?[n.port]:n.port),K===void 0&&(K=setInterval(()=>{y.old=y.young,y.young=new Set},yi),K.unref&&K.unref());for(let t of xi(e))try{let r=await Ut({...n,port:t});for(;y.old.has(r)||y.young.has(r);){if(t!==0)throw new q(t);r=await Ut({...n,port:t})}return y.young.add(r),r}catch(r){if(!["EADDRINUSE","EACCES"].includes(r.code)&&!(r instanceof q))throw r}throw new Error("No available ports found")};me.exports.makeRange=(n,e)=>{if(!Number.isInteger(n)||!Number.isInteger(e))throw new TypeError("`from` and `to` must be integer numbers");if(n<1024||n>65535)throw new RangeError("`from` must be between 1024 and 65535");if(e<1024||e>65536)throw new RangeError("`to` must be between 1024 and 65536");if(e<n)throw new RangeError("`to` must be greater than or equal to `from`");return function*(r,o){for(let i=r;i<=o;i++)yield i}(n,e)}});var N=d(require("fs")),_t=d(require("http")),w=d(require("path"));var it=d(require("path")),nt=d(require("os"));var hr="Comp Hub",_r="main",mr="container",dr="item",Er="/__global_config__",fr="local://",gr="comphubConfig",Or="https://intranet.comphub.cn",Ar="https://iframe.comphub.cn",Cr="https://cdn.comphub.cn/vendor",Tr="ca-pub-3825910057508741",Pr="__remote__",Sr="__local__",Mr="__admin__",Rr="https://api.comphub.cn",Ir="http://localhost:7002",br="http://127.0.0.1:5000",Dr="http://localhost:5001",Lr="http://localhost:3580",Nr="https://apiadmin.comphub.cn",wr="https://admin.comphub.cn",yr="/_module_load_prefix_",xr="/_node_modules_load_prefix_",Ur="/_comp_preview_prefix_local_",Hr="/__proxy__",$r="/__master__",vr="authorization",Fr="x-refresh-token",Vr="accept-language",kr="X-Token-Refreshed",jr="team-id",Yr="comp-hub-db",Gr="file-compiled",Br="https://oss.comphub.cn",Wr="oss:sts:token",Kr="oss:sts:expire",qr="https://prebuild.comphub.cn",Xr="/dev",Jr="/prod",Zr="/node_modules/.prebuild_module",zr="_metadata.json",Qr="vue/dist/vue.esm-bundler.js",eo="react-jsx-loader",to="vue3-sfc-loader",ro="vue2-sfc-loader",oo="sass-compiler",io="less-compiler",Me="react",no={COMP_FRAMEWORK_VUE:"vue",COMP_FRAMEWORK_REACT:Me},so="comp.json",ao="README.md",lo="main.js",co="index.vue",uo=["index.jsx","index.js","index.tsx"],po="/.comp_hub_temp",ho="screenshot_mini.png",_o=1024*1024*10,mo=1024*1024*3,Eo=30,fo=1024*150,Re="list_local",Ie="list_remote",go={COMP_LIST_TYPE_LOCAL:Re,COMP_LIST_TYPE_REMOTE:Ie},be="config",De="error",Le="dir",Ne="preview",we="extra",ye="deps",xe="readme",Ue="upgradeLog",Oo={TAB_TYPE_CONFIG:be,TAB_TYPE_ERROR:De,TAB_TYPE_DIR:Le,TAB_TYPE_PREVIEW:Ne,TAB_TYPE_EXTRA:we,TAB_TYPE_DEPS:ye,TAB_TYPE_README:xe,TAB_TYPE_UPGRADE_LOG:Ue},He="mini",$e="full",Ao={COMP_EDIT_TAB_TYPE_MINI:He,COMP_EDIT_TAB_TYPE_FULL:$e},ve="EDIT",Fe="ADD",Co={DIALOG_TYPE_EDIT:ve,DIALOG_TYPE_ADD:Fe},Ve="ONLY_INSTALL",ke="AUTO",je="MAJOR_VERSION",Ye="MINOR_VERSION",Ge="EXACT_VERSION",To={COMP_MATCH_TYPE_ONLY_INSTALL:Ve,COMP_MATCH_TYPE_AUTO:ke,COMP_MATCH_TYPE_MAJOR_VERSION:je,COMP_MATCH_TYPE_MINOR_VERSION:Ye,COMP_MATCH_TYPE_EXACT_VERSION:Ge},Be="online",We="offline",Po={COMP_UPDATE_TYPE_ONLINE:Be,COMP_UPDATE_TYPE_OFFLINE:We},Ke="NOT_EXIST",qe="EXIST",So={COMP_CHECK_STATUS_NOT_EXIST:Ke,COMP_CHECK_STATUS_EXIST:qe},Mo="__id__",Ro=0,Io=1,bo=-1,Xe="checkPreviewListForm",Je="checkExtraInfoForm",Ze="checkCompConfig",ze="checkUpgradeLogForm",Qe="getCompError",et="afterCompDel",tt="afterCompCancelCollect",rt="afterCompRenderRetry",ot="openCompTerminal",Do={COMP_METHOD_KEY_CHECK_PREVIEW_LIST_FORM:Xe,COMP_METHOD_KEY_CHECK_EXTRA_INFO_FORM:Je,COMP_METHOD_KEY_CHECK_COMP_CONFIG:Ze,COMP_METHOD_KEY_CHECK_UPGRADE_LOG_FORM:ze,COMP_METHOD_KEY_GET_COMP_ERROR:Qe,COMP_METHOD_KEY_AFTER_COMP_DEL:et,COMP_METHOD_KEY_AFTER_COMP_CANCEL_COLLECT:tt,COMP_METHOD_KEY_AFTER_COMP_RENDER_RETRY:rt,COMP_METHOD_KEY_OPEN_COMP_TERMINAL:ot},Lo="compListStore",No="compEditStore",wo="callbacks",yo={CONTAINER:{SHARE:"share",COLLECT:"collect",LOCAL:"local",MINE:"mine",SIMILAR:"similar",TEAM_ALL:"teamAll",TEAM_MINE:"teamMine",TEAM_GROUP:"teamGroup",TEAM_ADD:"teamAdd"},ITEM:{PREVIEW_REMOTE:"previewRemote",PREVIEW_LOCAL:"previewLocal",PREVIEW_EXTRANET:"previewExtranet",CAROUSEL_REMOTE:"carouselRemote",CAROUSEL_LOCAL:"carouselLocal",EDIT_PANEL:"editPanel",STORAGE_WORKER:"storageWorker"}},xo="http://127.0.0.1",Uo="http://localhost:8095",Ho="http://localhost:8096",$o="http://localhost:5198",vo="http://localhost:3056",Fo="https://www.comphub.cn",Vo="https://comphub.cn",ko="CREATE",jo="JOIN",Yo="EXIT",Go="teamAddMyComp",Bo="teamCompList",Wo="teamCompGroupList",Ko="teamMyCompList",qo="teamMyCompUpdate",Xo="__v__",Jo="local",Zo="prod",zo="local",Qo="prod",ei="http://localhost:5173",ti="https://docs.comphub.cn",ri="1.5em",oi="1.5em",ii="SUPER_ADMIN",ni="ADMIN",F={MAIN:"main",IFRAME_CONTAINER:"iframeContainer",IFRAME_ITEM:"iframeItem"},si={[F.MAIN]:{ENABLED:!0,DSN:"https://eb372d9ca4c4b35497e99966cae2c1b2@o4512055411146752.ingest.us.sentry.io/4512055626891264",TRACES_SAMPLE_RATE:1,TRACE_PROPAGATION_TARGETS:["localhost"]},[F.IFRAME_CONTAINER]:{ENABLED:!0,DSN:"https://09eacfc954a80beb1aed90bbdb09b3f6@o4512055411146752.ingest.us.sentry.io/4512055609720832",TRACES_SAMPLE_RATE:1,TRACE_PROPAGATION_TARGETS:["localhost"]},[F.IFRAME_ITEM]:{ENABLED:!0,DSN:"https://0a564c86371356eccceff7854690e489@o4512055411146752.ingest.us.sentry.io/4512055615029249",TRACES_SAMPLE_RATE:1,TRACE_PROPAGATION_TARGETS:["localhost"]}},ai={"vue3-sfc-loader":"vue3-sfc-loader-f3c985c9.js","vue2-sfc-loader":"vue2-sfc-loader-445fb53a.js","react-jsx-loader":"react-jsx-loader-b8a3bbcb.js","sass-compiler":"sass-compiler-482885df.js","less-compiler":"less-compiler-0cc8346f.js"},L=Object.freeze(Object.defineProperty({__proto__:null,ACCEPT_LANGUAGE_HEADER_NAME:Vr,ADMIN_SERVICE_PREFIX:Mr,ADMIN_SERVICE_URL_DEV:Lr,ADMIN_SERVICE_URL_PROD:Nr,ADMIN_WEB_URL_PROD:wr,ADSENSE_CLIENT_ID:Tr,AUTHORIZATION_HEADER_NAME:vr,CACHE_KEY_STS_EXPIRE_TIME:Kr,CACHE_KEY_STS_TOKEN:Wr,COMPHUB_CONFIG_KEY:gr,COMP_ACTION_ICON_HEIGHT:oi,COMP_ACTION_ICON_WIDTH:ri,COMP_CHECK_STATUSES:So,COMP_CHECK_STATUS_EXIST:qe,COMP_CHECK_STATUS_NOT_EXIST:Ke,COMP_CONFIG_FILENAME:so,COMP_DOWNLOAD_ZIP_INLINE_MAX_TOTAL_SIZE:fo,COMP_EDIT_TAB_TYPES:Ao,COMP_EDIT_TAB_TYPE_FULL:$e,COMP_EDIT_TAB_TYPE_MINI:He,COMP_ENTRY_FILE:lo,COMP_FIELD_COMP_ID:Mo,COMP_FRAMEWORK_REACT:Me,COMP_FRAMEWORK_TYPES:no,COMP_FRAMEWORK_VUE:"vue",COMP_HUB_DEV_DOCS_URL:ei,COMP_HUB_PROD_DOCS_URL:ti,COMP_LIST_TYPES:go,COMP_LIST_TYPE_LOCAL:Re,COMP_LIST_TYPE_REMOTE:Ie,COMP_MATCH_TYPES:To,COMP_MATCH_TYPE_AUTO:ke,COMP_MATCH_TYPE_EXACT_VERSION:Ge,COMP_MATCH_TYPE_MAJOR_VERSION:je,COMP_MATCH_TYPE_MINOR_VERSION:Ye,COMP_MATCH_TYPE_ONLY_INSTALL:Ve,COMP_METHOD_KEY_AFTER_COMP_CANCEL_COLLECT:tt,COMP_METHOD_KEY_AFTER_COMP_DEL:et,COMP_METHOD_KEY_AFTER_COMP_RENDER_RETRY:rt,COMP_METHOD_KEY_CHECK_COMP_CONFIG:Ze,COMP_METHOD_KEY_CHECK_EXTRA_INFO_FORM:Je,COMP_METHOD_KEY_CHECK_PREVIEW_LIST_FORM:Xe,COMP_METHOD_KEY_CHECK_UPGRADE_LOG_FORM:ze,COMP_METHOD_KEY_GET_COMP_ERROR:Qe,COMP_METHOD_KEY_OPEN_COMP_TERMINAL:ot,COMP_PREVIEW_PREFIX_LOCAL:Ur,COMP_README_FILENAME:ao,COMP_SCREENSHOT_MINI_FILENAME:ho,COMP_SUBMIT_MAX_FILE_COUNT:Eo,COMP_SUBMIT_MAX_SINGLE_FILE_SIZE:mo,COMP_SUBMIT_MAX_TOTAL_SIZE:_o,COMP_TEMP_DIR:po,COMP_UPDATE_TYPES:Po,COMP_UPDATE_TYPE_OFFLINE:We,COMP_UPDATE_TYPE_ONLINE:Be,COMP_USE_ENTRY_FILE:co,COMP_USE_ENTRY_FILE_REACT:uo,DIALOG_TYPES:Co,DIALOG_TYPE_ADD:Fe,DIALOG_TYPE_EDIT:ve,FILE_MANAGER_DIRNAME:fr,GLOBAL_CONFIG_PATH:Er,IFRAME_HOST:xo,IFRAME_ROUTES:yo,INDEX_DB_NAME:Yr,INDEX_DB_TABLE_NAME:Gr,LESS_COMPILER_KEY:io,LOCAL_CHILD_IFRAME_URL:Uo,LOCAL_LEAF_IFRAME_URL:Ho,LOCAL_MAIN_EXTRANET_URL:vo,LOCAL_MIDWAY_ENV_LOCAL:Jo,LOCAL_MIDWAY_ENV_PROD:Zo,LOCAL_SERVICE_PREFIX:Sr,LOCAL_SERVICE_URL_DEV:br,LOCAL_SERVICE_URL_DEV_SUB:Dr,LOCAL_TOP_IFRAME_URL:$o,MASTER_API_PREFIX:$r,META_FILE_NAME:zr,MODULE_LOAD_PREFIX:yr,NODE_MODULES_LOAD_PREFIX:xr,OSS_CUSTOM_DOMAIN:Br,PREBUILD_HOST:qr,PREBUILD_MAX_SINGLE_FILE_SIZE:52428800,PREBUILD_MODULE_DIR:Zr,PREBUILD_MODULE_DIR_DEV:Xr,PREBUILD_MODULE_DIR_PROD:Jr,PROVIDE_KEYS:Do,PROVIDE_KEY_CALLBACKS:wo,PROVIDE_KEY_COMP_EDIT_STORE:No,PROVIDE_KEY_COMP_LIST_STORE:Lo,PROXY_PATH_PREFIX:Hr,REACT_JSX_LOADER_KEY:eo,REFRESH_TOKEN_HEADER_NAME:Fr,REMOTE_MAIN_EXTRANET_APEX_URL:Vo,REMOTE_MAIN_EXTRANET_URL:Fo,REMOTE_MIDWAY_ENV_LOCAL:zo,REMOTE_MIDWAY_ENV_PROD:Qo,REMOTE_SERVICE_PREFIX:Pr,REMOTE_SERVICE_URL_DEV:Ir,REMOTE_SERVICE_URL_PROD:Rr,ROLE_CODE_ADMIN:ni,ROLE_CODE_SUPER_ADMIN:ii,ROUTE_STATE_KEY_VERSION:Xo,SASS_COMPILER_KEY:oo,SCOPE_ID_TEAM_ADD_MY_COMP:Go,SCOPE_ID_TEAM_COMP_GROUP_LIST:Wo,SCOPE_ID_TEAM_COMP_LIST:Bo,SCOPE_ID_TEAM_MY_COMP_LIST:Ko,SCOPE_ID_TEAM_MY_COMP_UPDATE:qo,SENTRY_PROJECTS:si,SENTRY_PROJECT_NAMES:F,SITE_TITLE:hr,TAB_TYPES:Oo,TAB_TYPE_CONFIG:be,TAB_TYPE_DEPS:ye,TAB_TYPE_DIR:Le,TAB_TYPE_ERROR:De,TAB_TYPE_EXTRA:we,TAB_TYPE_PREVIEW:Ne,TAB_TYPE_README:xe,TAB_TYPE_UPGRADE_LOG:Ue,TEAM_ID_HEADER_NAME:jr,TEAM_OPERATE_TYPE_CREATE:ko,TEAM_OPERATE_TYPE_EXIT:Yo,TEAM_OPERATE_TYPE_JOIN:jo,VENDOR_CDN_BASE:Cr,VENDOR_LOADER_FILES:ai,VERSION_COMPARE_GREATER:Io,VERSION_COMPARE_LESS:bo,VERSION_COMPARE_SAME:Ro,VUE2_SFC_LOADER_KEY:ro,VUE3_SFC_LOADER_KEY:to,VUE_ESM_BUNDLER:Qr,WEBSITE_OSS_URL_IFRAME:Ar,WEBSITE_OSS_URL_MAIN:Or,WEBSITE_PATH_CONTAINER:mr,WEBSITE_PATH_ITEM:dr,WEBSITE_PATH_MAIN:_r,X_TOKEN_REFRESHED_HEADER_NAME:kr},Symbol.toStringTag,{value:"Module"}));var V=5478,st=L.REMOTE_SERVICE_URL_PROD,I=it.default.join(nt.default.tmpdir(),".comphub","master.json"),f={PREFIX:"/__master__",HEALTH:"/__master__/health",REGISTER:"/__master__/register",DEREGISTER:"/__master__/deregister",PROJECTS:"/__master__/projects",SHUTDOWN:"/__master__/shutdown"},at=500,lt=40,ct=2e3,k=5e3;var ee=d(require("fs")),Q=d(require("path")),ut=d(require("crypto"));function j(n){return JSON.parse(ee.default.readFileSync(n,"utf8"))}function pt(n){let e=n;for(let t=0;t<12;t++){try{let o=Q.default.join(e,"package.json");if(ee.default.existsSync(o)){let i=j(o);if(i&&i.name==="comp-hub")return e}}catch{}let r=Q.default.dirname(e);if(r===e)break;e=r}return null}function ht(n){return ut.default.createHash("sha256").update(n).digest("hex").slice(0,8)}function g(n,e){return`http://localhost:${n}${e}`}var E={cyan:n=>`\x1B[36m${n}\x1B[0m`,green:n=>`\x1B[32m${n}\x1B[0m`,white:n=>`\x1B[37m${n}\x1B[0m`,yellow:n=>`\x1B[33m${n}\x1B[0m`,red:n=>`\x1B[31m${n}\x1B[0m`};var Y=pt(__dirname)||w.default.resolve(__dirname,"..");function mt(){let n=w.default.join(Y,"package.json"),e=j(n),t=w.default.join(Y,e.main||"dist/index.js");return{pkg:e,entry:t}}function li(n){let e=w.default.join(n,".comphub.json"),t=w.default.join(n,".comphub.js");try{if(N.default.existsSync(e))return j(e)}catch{}try{if(N.default.existsSync(t)){let r=require(t);return r.default||r}}catch{}return{}}function dt(n,e){let t=li(e);return{dir:n.dir||t.dir||"./",api:n.api||t.api,allowDebug:n.allowDebug!=null?n.allowDebug:t.allowDebug!=null?t.allowDebug:!1,proxy:n.proxy||t.proxy,port:n.port,logLevel:n.logLevel||t.logLevel||"info"}}async function T(){try{if(N.default.existsSync(I)){let n=JSON.parse(N.default.readFileSync(I,"utf8"));try{if(process.kill(n.pid,0),await ci(n.managementPort))return n}catch{}try{N.default.unlinkSync(I)}catch{}}}catch{}return null}function ci(n){return new Promise(e=>{let t=_t.default.get(`http://localhost:${n}${f.HEALTH}`,r=>{let o="";r.on("data",i=>o+=i),r.on("end",()=>{try{let i=JSON.parse(o);e(typeof i.status=="string")}catch{e(!1)}})});t.on("error",()=>e(!1)),t.setTimeout(2e3,()=>{t.destroy(),e(!1)})})}var Lt=d(Dt(),1),{program:cn,createCommand:un,createArgument:pn,createOption:hn,CommanderError:_n,InvalidArgumentError:mn,InvalidOptionArgumentError:dn,Command:Nt,Argument:En,Option:b,Help:fn}=Lt.default;var Jt=d(require("fs")),Zt=d(require("path"));var wt=d(require("http")),yt=d(require("https"));var Ii="/api/v2/upgrade/check";function bi(n){return(n||st).replace(/\/+$/,"")}function Di(n,e,t){return new Promise((r,o)=>{let i=n.startsWith("https:")?yt.default:wt.default,s=JSON.stringify(e),l=new URL(n),a={hostname:l.hostname,port:l.port||(l.protocol==="https:"?443:80),path:l.pathname+l.search,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},c=i.request(a,u=>{let p="";u.setEncoding("utf8"),u.on("data",m=>p+=m),u.on("end",()=>{let m=p;try{m=JSON.parse(p)}catch{}r({status:u.statusCode||0,body:m})})});c.on("error",o),c.setTimeout(t||k,()=>{c.destroy(new Error("Request timeout"))}),c.write(s),c.end()})}function Li(n){if(!n||n.status!==200)throw new Error(n.status?`HTTP ${n.status}`:"No response");let e=n.body?.data;if(!e||typeof e.hasUpgrade!="boolean")throw new Error("Invalid response format");return{hasUpgrade:e.hasUpgrade,isForce:!!e.isForce,latestVersion:typeof e.latestVersion=="string"?e.latestVersion:""}}function Ni(n){return n.hasUpgrade&&n.isForce?"block":n.hasUpgrade?"notice":"none"}async function xt(n){let{base:e,compHubVersion:t,timeout:r,request:o=Di}=n,i=`${bi(e)}${Ii}`;try{let s=await o(i,{compHubVersion:t},r),l=Li(s);return{ok:!0,...l,verdict:Ni(l)}}catch(s){return{ok:!1,error:s?.message||String(s)}}}var Ft=d(require("fs")),Vt=d(require("path")),kt=require("child_process"),de=d(Ht());var X=d(require("http"));function Ui(n){try{return JSON.parse(n)}catch{return n}}function v(n){return new Promise(e=>{let t=X.default.get(n,r=>{let o="";r.on("data",i=>o+=i),r.on("end",()=>e({ok:!0,status:r.statusCode,body:Ui(o)}))});t.on("error",r=>e({ok:!1,error:r.message})),t.setTimeout(ct,()=>{t.destroy(),e({ok:!1,error:"Request timeout"})})})}function M(n,e){return new Promise(t=>{let r=JSON.stringify(e),o=new URL(n),i={hostname:o.hostname,port:o.port,path:o.pathname,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},s=X.default.request(i,l=>{let a="";l.on("data",c=>a+=c),l.on("end",()=>{try{t({ok:!0,body:JSON.parse(a)})}catch{t({ok:!1,error:"Invalid JSON response"})}})});s.on("error",l=>t({ok:!1,error:l.message})),s.setTimeout(k,()=>{s.destroy(),t({ok:!1,error:"Request timeout"})}),s.write(r),s.end()})}function $t(n,e){return new Promise((t,r)=>{let o=new URL(n),i={hostname:o.hostname,port:o.port,path:o.pathname,method:"GET",headers:{Accept:"text/event-stream"}},s=X.default.request(i,l=>{if(l.statusCode!==200){r(new Error(`SSE connection failed (HTTP ${l.statusCode})`));return}let a="";l.on("data",c=>{a+=c.toString();let u=a.split(`
20
20
 
21
- `);a=u.pop()||"";for(let p of u){let m=p.startsWith("data: ")?p.slice(6):p;try{let O=JSON.parse(m);process.stdout.write(O)}catch{}}}),l.on("end",()=>t()),l.on("error",c=>r(c))});s.on("error",l=>r(l)),s.setTimeout(0),s.end()})}function Ft(i,e){return M(g(i,"/__master__/deregister"),{hash:e})}var{green:vn}=E;async function Fn(){for(let i=0;i<ct;i++){let e=await T();if(e)return e;await new Promise(t=>setTimeout(t,lt))}return null}async function Vn(i,e,t){let r=kt.default.join(j,"dist/master.js");if(!Vt.default.existsSync(r))throw new Error("Master entry file not found, startup failed");let o=["--port",String(i),"--public-port",String(i)],n=(0,jt.spawn)(process.execPath,["--no-deprecation",r,...o],{stdio:["inherit","pipe","pipe"],cwd:t,env:{...process.env,COMP_HUB_VERSION:e.version}}),s="";n.stderr&&n.stderr.on("data",a=>{process.stderr.write(a)}),n.stdout&&n.stdout.on("data",a=>{s+=a.toString();let c=s.split(`
21
+ `);a=u.pop()||"";for(let p of u){let m=p.startsWith("data: ")?p.slice(6):p;try{let O=JSON.parse(m);process.stdout.write(O)}catch{}}}),l.on("end",()=>t()),l.on("error",c=>r(c))});s.on("error",l=>r(l)),s.setTimeout(0),s.end()})}function vt(n,e){return M(g(n,"/__master__/deregister"),{hash:e})}var{green:Hi}=E;async function $i(){for(let n=0;n<lt;n++){let e=await T();if(e)return e;await new Promise(t=>setTimeout(t,at))}return null}async function vi(n,e,t){let r=Vt.default.join(Y,"dist/master.js");if(!Ft.default.existsSync(r))throw new Error("Master entry file not found, startup failed");let o=["--port",String(n),"--public-port",String(n)],i=(0,kt.spawn)(process.execPath,["--no-deprecation",r,...o],{stdio:["inherit","pipe","pipe"],cwd:t,env:{...process.env,COMP_HUB_VERSION:e.version}}),s="";i.stderr&&i.stderr.on("data",a=>{process.stderr.write(a)}),i.stdout&&i.stdout.on("data",a=>{s+=a.toString();let c=s.split(`
22
22
  `);s=c.pop()||"";for(let u of c)/^\[[0-9a-f]{8}\]/.test(u)||process.stdout.write(u+`
23
- `)}),["SIGINT","SIGTERM"].forEach(a=>{process.on(a,()=>{n.kill(a)})}),n.on("exit",a=>{s&&!/^\[[0-9a-f]{8}\]/.test(s)&&process.stdout.write(s),process.exit(a||0)});let l=await Fn();if(!l)throw n.kill(),new Error("Master startup timeout");return{runtime:l}}async function Yt(i,e){let t=!1,r=0,o=await T();if(o){let a=i.port!=null?i.port:o.publicPort;return i.port!=null&&o.publicPort!==a&&(t=!0,r=o.publicPort),{runtime:o,portMismatch:t,runningPublicPort:r}}let n=i.port!=null?i.port:F,s=await(0,de.default)({port:de.default.makeRange(n,n+100)}),{runtime:l}=await Vn(s,e,process.cwd());return{runtime:l,portMismatch:t,runningPublicPort:r}}async function Gt(i,e,t,r){let o={hash:e,cwd:t,dir:r.dir||"./"};r.api&&(o.api=r.api),r.allowDebug&&(o.allowDebug=!0),r.proxy&&(o.proxy=r.proxy),r.logLevel&&(o.logLevel=r.logLevel);let n=await M(g(i,f.REGISTER),o);if(!n.ok)throw new Error(n.error||"Registration failed");console.log(`${vn("\u2713")} Project registered (hash: ${e})`)}var{cyan:L,green:X,white:Bt,yellow:kn,red:Wt}=E;function Kt(i,e,t,r,o,n){let{portMismatch:s,runningPublicPort:l}=n,a=`http://localhost:${r}/${t}/main/`,c=["",L(" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 "),L(" \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557"),L(" \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D"),L(" \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557"),L(" \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D"),L(" \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D "),"","",` ${X("Version")} ${i.version}`,` ${X("Project")} ${e}`,` ${X("Hash")} ${t}`,` ${X("Port")} ${r}`,"",` ${kn("URL")} ${L(a)}`,"",Bt(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),"",` ${"comphub status".padEnd(30)}View all projects`,` ${`comphub stop ${t}`.padEnd(30)}Stop current project`,` ${"comphub stop --all".padEnd(30)}Stop all projects`,` ${"comphub kill".padEnd(30)}Shutdown master`,""];s&&c.push(Bt(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),"",Wt(` \u26A0 Master is already running on port ${l}, ignoring -p ${o.port}`),Wt(" To change port, please run comphub kill first"),""),console.log(c.join(`
24
- `))}var{cyan:qt,green:jn,white:Xt,yellow:Jt,red:Ee}=E;async function fe(i,e){zt.default.existsSync(Zt.default.join(process.cwd(),"package.json"))||(console.error(`${Ee("\u2717")} Current directory is not a Node.js project`),process.exit(1));let t=process.cwd(),r=_t(t);e=Et(e,t);let o=await Ut({base:e.api,compHubVersion:i.version});if(o.ok&&o.verdict==="block"){let _=o.latestVersion&&o.latestVersion!==i.version?`, latest version v${o.latestVersion}`:"";console.error(""),console.error(`${Ee("\u2717")} comp-hub must be upgraded before it can start (current v${i.version}${_})`),console.error(` Please run the upgrade command: ${qt("npm install comp-hub@latest -g")}`),console.error(" Then run comphub again after upgrading"),console.error(""),process.exit(1)}console.log(`${jn("\u2713")} ${i.name} v${i.version}`);let{runtime:n,portMismatch:s,runningPublicPort:l}=await Yt(e,i),a=n.managementPort,c=n.publicPort;if(await Gt(a,r,t,e),Kt(i,t,r,c,e,{portMismatch:s,runningPublicPort:l}),o.ok&&o.verdict==="notice"){let _=o.latestVersion&&o.latestVersion!==i.version?` (latest version v${o.latestVersion})`:"";console.log(""),console.log(`${Jt("\u2139")} comp-hub has a new version available${_}; run the upgrade command to update:`),console.log(` ${qt("npm install comp-hub@latest -g")}`),console.log("")}else o.ok||(console.log(""),console.log(`${Jt("\u26A0")} comp-hub version check failed (${o.error}); skipping the version check for this run`),console.log(""));let u=!1,p=async()=>{if(!u){u=!0;try{await Ft(a,r)}catch{}process.exit(0)}};process.on("SIGINT",p),process.on("SIGTERM",p),console.log(`
25
- ${Xt("\u2500")} Streaming logs from MidwayJS (${r}) ${Xt("\u2500")}
26
- `);let m=`http://localhost:${a}/__master__/projects/${r}/logs`;try{await vt(m,r)}catch(O){console.error(`
27
- ${Ee("\u2717")} Log stream error: ${O.message}`)}}var{green:R,yellow:Qt,cyan:er,white:C,red:Yn}=E;async function ge(i){let e=await D(i),t=await T(),r=t?t.publicPort:e;console.log(`
23
+ `)}),["SIGINT","SIGTERM"].forEach(a=>{process.on(a,()=>{i.kill(a)})}),i.on("exit",a=>{s&&!/^\[[0-9a-f]{8}\]/.test(s)&&process.stdout.write(s),process.exit(a||0)});let l=await $i();if(!l)throw i.kill(),new Error("Master startup timeout");return{runtime:l}}async function jt(n,e){let t=!1,r=0,o=await T();if(o){let a=n.port!=null?n.port:o.publicPort;return n.port!=null&&o.publicPort!==a&&(t=!0,r=o.publicPort),{runtime:o,portMismatch:t,runningPublicPort:r}}let i=n.port!=null?n.port:V,s=await(0,de.default)({port:de.default.makeRange(i,i+100)}),{runtime:l}=await vi(s,e,process.cwd());return{runtime:l,portMismatch:t,runningPublicPort:r}}async function Yt(n,e,t,r){let o={hash:e,cwd:t,dir:r.dir||"./"};r.api&&(o.api=r.api),r.allowDebug&&(o.allowDebug=!0),r.proxy&&(o.proxy=r.proxy),r.logLevel&&(o.logLevel=r.logLevel);let i=await M(g(n,f.REGISTER),o);if(!i.ok)throw new Error(i.error||"Registration failed");console.log(`${Hi("\u2713")} Project registered (hash: ${e})`)}var{cyan:D,green:J,white:Gt,yellow:Fi,red:Bt}=E;function Wt(n,e,t,r,o,i){let{portMismatch:s,runningPublicPort:l}=i,a=`http://localhost:${r}/${t}/${L.WEBSITE_PATH_MAIN}/`,c=["",D(" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 "),D(" \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557"),D(" \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D"),D(" \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557"),D(" \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D"),D(" \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D "),"","",` ${J("Version")} ${n.version}`,` ${J("Project")} ${e}`,` ${J("Hash")} ${t}`,` ${J("Port")} ${r}`,"",` ${Fi("URL")} ${D(a)}`,"",Gt(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),"",` ${"comphub status".padEnd(30)}View all projects`,` ${`comphub stop ${t}`.padEnd(30)}Stop current project`,` ${"comphub stop --all".padEnd(30)}Stop all projects`,` ${"comphub kill".padEnd(30)}Shutdown master`,""];s&&c.push(Gt(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),"",Bt(` \u26A0 Master is already running on port ${l}, ignoring -p ${o.port}`),Bt(" To change port, please run comphub kill first"),""),console.log(c.join(`
24
+ `))}var{cyan:Kt,green:Vi,white:qt,yellow:Xt,red:Ee}=E;async function fe(n,e){Jt.default.existsSync(Zt.default.join(process.cwd(),"package.json"))||(console.error(`${Ee("\u2717")} Current directory is not a Node.js project`),process.exit(1));let t=process.cwd(),r=ht(t);e=dt(e,t);let o=await xt({base:e.api,compHubVersion:n.version});if(o.ok&&o.verdict==="block"){let _=o.latestVersion&&o.latestVersion!==n.version?`, latest version v${o.latestVersion}`:"";console.error(""),console.error(`${Ee("\u2717")} comp-hub must be upgraded before it can start (current v${n.version}${_})`),console.error(` Please run the upgrade command: ${Kt("npm install comp-hub@latest -g")}`),console.error(" Then run comphub again after upgrading"),console.error(""),process.exit(1)}console.log(`${Vi("\u2713")} ${n.name} v${n.version}`);let{runtime:i,portMismatch:s,runningPublicPort:l}=await jt(e,n),a=i.managementPort,c=i.publicPort;if(await Yt(a,r,t,e),Wt(n,t,r,c,e,{portMismatch:s,runningPublicPort:l}),o.ok&&o.verdict==="notice"){let _=o.latestVersion&&o.latestVersion!==n.version?` (latest version v${o.latestVersion})`:"";console.log(""),console.log(`${Xt("\u2139")} comp-hub has a new version available${_}; run the upgrade command to update:`),console.log(` ${Kt("npm install comp-hub@latest -g")}`),console.log("")}else o.ok||(console.log(""),console.log(`${Xt("\u26A0")} comp-hub version check failed (${o.error}); skipping the version check for this run`),console.log(""));let u=!1,p=async()=>{if(!u){u=!0;try{await vt(a,r)}catch{}process.exit(0)}};process.on("SIGINT",p),process.on("SIGTERM",p),console.log(`
25
+ ${qt("\u2500")} Streaming logs from MidwayJS (${r}) ${qt("\u2500")}
26
+ `);let m=`http://localhost:${a}/__master__/projects/${r}/logs`;try{await $t(m,r)}catch(O){console.error(`
27
+ ${Ee("\u2717")} Log stream error: ${O.message}`)}}function zt(n){let e=[{label:"d",divisor:86400},{label:"h",divisor:3600},{label:"m",divisor:60},{label:"s",divisor:1}],t=Math.floor(n),r=[];for(let{label:o,divisor:i}of e)if(t>=i){let s=Math.floor(t/i);t=t%i,r.push(`${s}${o}`)}return r.length>0?r.join(" "):"0s"}async function x(n){if(n.port!=null)return n.port;let e=await T();return e?e.managementPort:V}var{green:R,yellow:Qt,cyan:er,white:C,red:ki}=E;async function ge(n){let e=await x(n),t=await T(),r=t?t.publicPort:e;console.log(`
28
28
  ${Qt("\u25CF")} Master Status
29
- `);let o=await $(g(e,f.HEALTH));(!o.ok||!o.body||typeof o.body.status!="string")&&(console.error(`${Yn("\u2717")} Master service is not running`),process.exit(1));let n=o.body,s=n.status==="running"?R("\u25CF"):er("\u25CF");console.log(` ${R("Status")} ${s} ${n.status}`),console.log(` ${R("Version")} ${C(n.version||"")}`),console.log(` ${R("Uptime")} ${C(_e(n.uptime??0))}`),console.log(` ${R("Projects")} ${C(String(n.projects??0))}`),console.log("");let l=await $(g(e,f.PROJECTS));if(l.ok&&l.body){let a=l.body.projects;if(Array.isArray(a)&&a.length>0){console.log(` ${Qt("\u25B8")} Registered Projects (${a.length}):`),console.log(" "+C("\u2500".repeat(56)));for(let c of a)console.log(` ${R("hash")} ${C(c.hash)}`),console.log(` ${R("path")} ${C(c.cwd||"")}`),console.log(` ${R("url")} ${er(`http://localhost:${r}/${c.hash}/main/`)}`),console.log(" "+C("\u2500".repeat(56)))}else console.log(` ${C("\u2500".repeat(58))}`),console.log(` ${C("(No registered projects)")}`),console.log(` ${C("\u2500".repeat(58))}`)}console.log(""),process.exit(0)}var{green:tr,yellow:Oe,red:J}=E;async function Ae(i,e){let t=await D(e);if(e.all){let o=await $(g(t,f.PROJECTS));(!o.ok||!o.body)&&(console.error(`${J("\u2717")} Cannot connect to master service`),process.exit(1));let n=o.body.projects;(!Array.isArray(n)||n.length===0)&&(console.log(`${Oe("\u2139")} No running projects`),process.exit(0)),console.log(`
30
- ${Oe("\u25B8")} Stopping all ${n.length} projects...
31
- `);for(let s of n){let l=await M(g(t,f.DEREGISTER),{hash:s.hash});l.ok?console.log(` ${tr("\u2713")} Stopped: ${s.hash} (${s.cwd||""})`):console.error(` ${J("\u2717")} Failed to stop: ${s.hash} - ${l.error}`)}console.log(""),process.exit(0)}i||(console.error(`${J("\u2717")} Please specify project hash or use --all to stop all projects`),console.error(" Usage: comphub stop <hash>"),console.error(" Usage: comphub stop --all"),process.exit(1)),console.log(`
32
- ${Oe("\u25B8")} Stopping project ${i}...`);let r=await M(g(t,f.DEREGISTER),{hash:i});r.ok?console.log(` ${tr("\u2713")} Stopped: ${i}
33
- `):(console.error(` ${J("\u2717")} Failed to stop: ${r.error}
34
- `),process.exit(1)),process.exit(0)}var{green:Gn,yellow:Bn,red:Wn}=E;async function Ce(i){let e=await D(i);console.log(`
35
- ${Bn("\u25B8")} Shutting down master process...
36
- `);let t=await M(g(e,f.SHUTDOWN),{});t.ok?console.log(`${Gn("\u2713")} Master process has been shut down
37
- `):(console.error(`${Wn("\u2717")} Shutdown failed: ${t.error}
38
- `),process.exit(1)),process.exit(0)}var Te=d(require("fs"));var{green:rr,yellow:or,red:Kn}=E;async function Pe(){console.log(`
29
+ `);let o=await v(g(e,f.HEALTH));(!o.ok||!o.body||typeof o.body.status!="string")&&(console.error(`${ki("\u2717")} Master service is not running`),process.exit(1));let i=o.body,s=i.status==="running"?R("\u25CF"):er("\u25CF");console.log(` ${R("Status")} ${s} ${i.status}`),console.log(` ${R("Version")} ${C(i.version||"")}`),console.log(` ${R("Uptime")} ${C(zt(i.uptime??0))}`),console.log(` ${R("Projects")} ${C(String(i.projects??0))}`),console.log("");let l=await v(g(e,f.PROJECTS));if(l.ok&&l.body){let a=l.body.projects;if(Array.isArray(a)&&a.length>0){console.log(` ${Qt("\u25B8")} Registered Projects (${a.length}):`),console.log(" "+C("\u2500".repeat(56)));for(let c of a)console.log(` ${R("hash")} ${C(c.hash)}`),console.log(` ${R("path")} ${C(c.cwd||"")}`),console.log(` ${R("url")} ${er(`http://localhost:${r}/${c.hash}/${L.WEBSITE_PATH_MAIN}/`)}`),console.log(" "+C("\u2500".repeat(56)))}else console.log(` ${C("\u2500".repeat(58))}`),console.log(` ${C("(No registered projects)")}`),console.log(` ${C("\u2500".repeat(58))}`)}console.log(""),process.exit(0)}var{green:tr,yellow:Oe,red:Z}=E;async function Ae(n,e){let t=await x(e);if(e.all){let o=await v(g(t,f.PROJECTS));(!o.ok||!o.body)&&(console.error(`${Z("\u2717")} Cannot connect to master service`),process.exit(1));let i=o.body.projects;(!Array.isArray(i)||i.length===0)&&(console.log(`${Oe("\u2139")} No running projects`),process.exit(0)),console.log(`
30
+ ${Oe("\u25B8")} Stopping all ${i.length} projects...
31
+ `);for(let s of i){let l=await M(g(t,f.DEREGISTER),{hash:s.hash});l.ok?console.log(` ${tr("\u2713")} Stopped: ${s.hash} (${s.cwd||""})`):console.error(` ${Z("\u2717")} Failed to stop: ${s.hash} - ${l.error}`)}console.log(""),process.exit(0)}n||(console.error(`${Z("\u2717")} Please specify project hash or use --all to stop all projects`),console.error(" Usage: comphub stop <hash>"),console.error(" Usage: comphub stop --all"),process.exit(1)),console.log(`
32
+ ${Oe("\u25B8")} Stopping project ${n}...`);let r=await M(g(t,f.DEREGISTER),{hash:n});r.ok?console.log(` ${tr("\u2713")} Stopped: ${n}
33
+ `):(console.error(` ${Z("\u2717")} Failed to stop: ${r.error}
34
+ `),process.exit(1)),process.exit(0)}var{green:ji,yellow:Yi,red:Gi}=E;async function Ce(n){let e=await x(n);console.log(`
35
+ ${Yi("\u25B8")} Shutting down master process...
36
+ `);let t=await M(g(e,f.SHUTDOWN),{});t.ok?console.log(`${ji("\u2713")} Master process has been shut down
37
+ `):(console.error(`${Gi("\u2717")} Shutdown failed: ${t.error}
38
+ `),process.exit(1)),process.exit(0)}var Te=d(require("fs"));var{green:rr,yellow:or,red:Bi}=E;async function Pe(){console.log(`
39
39
  ${or("\u25B8")} Checking master runtime...
40
- `);let i=await T();if(i&&(console.log(` ${rr("\u2713")} Master is running normally on port ${i.publicPort}
40
+ `);let n=await T();if(n&&(console.log(` ${rr("\u2713")} Master is running normally on port ${n.publicPort}
41
41
  `),process.exit(0)),Te.default.existsSync(I))try{Te.default.unlinkSync(I),console.log(` ${rr("\u2713")} Removed stale runtime file
42
- `)}catch{console.error(` ${Kn("\u2717")} Failed to remove runtime file
42
+ `)}catch{console.error(` ${Bi("\u2717")} Failed to remove runtime file
43
43
  `),process.exit(1)}else console.log(` ${or("\u2139")} No stale runtime file found
44
- `);process.exit(0)}function z(i){return parseInt(i,10)}function nr(i){let e=new wt;return e.name("comphub").addOption(new b("-p, --port <number>","Startup port").argParser(z)).option("-d, --dir <path>","Resource directory relative path").option("-l, --log-level <level>","Log level: debug, info, warn, error (default: info)","error").version(i.version,"-v, --version","Show version").addOption(new b("--allow-debug","Enable debug mode").hideHelp()).addOption(new b("--api <url>","API URL").hideHelp()).helpOption("-h, --help","Show help"),e.command("status").description("View master service status and all running projects").addOption(new b("-p, --port <number>","Master port").argParser(z).hideHelp()).action(t=>ge(t)),e.command("stop [hash]").description("Stop a specific project (by hash) or stop all projects (--all)").addOption(new b("-p, --port <number>","Master port").argParser(z).hideHelp()).option("-a, --all","Stop all projects").action((t,r)=>Ae(t,r)),e.command("kill").description("Shutdown master process").addOption(new b("-p, --port <number>","Master port").argParser(z).hideHelp()).action(t=>Ce(t)),e.command("fix").description("Fix common issues (stale runtime file, etc.)").action(()=>Pe()),e.action(async()=>{try{await fe(i,e.opts())}catch(t){console.error(`\u2717 Startup failed: ${t.message}`),process.exit(1)}}),e}var{pkg:qn}=dt(),Xn=nr(qn);Xn.parseAsync(process.argv).catch(i=>{console.error(`\u2717 CLI error: ${i.message}`),process.exit(1)});
44
+ `);process.exit(0)}function z(n){return parseInt(n,10)}function ir(n){let e=new Nt;return e.name("comphub").addOption(new b("-p, --port <number>","Startup port").argParser(z)).option("-d, --dir <path>","Resource directory relative path").option("-l, --log-level <level>","Log level: debug, info, warn, error (default: info)","error").version(n.version,"-v, --version","Show version").addOption(new b("--allow-debug","Enable debug mode").hideHelp()).addOption(new b("--api <url>","API URL").hideHelp()).helpOption("-h, --help","Show help"),e.command("status").description("View master service status and all running projects").addOption(new b("-p, --port <number>","Master port").argParser(z).hideHelp()).action(t=>ge(t)),e.command("stop [hash]").description("Stop a specific project (by hash) or stop all projects (--all)").addOption(new b("-p, --port <number>","Master port").argParser(z).hideHelp()).option("-a, --all","Stop all projects").action((t,r)=>Ae(t,r)),e.command("kill").description("Shutdown master process").addOption(new b("-p, --port <number>","Master port").argParser(z).hideHelp()).action(t=>Ce(t)),e.command("fix").description("Fix common issues (stale runtime file, etc.)").action(()=>Pe()),e.action(async()=>{try{await fe(n,e.opts())}catch(t){console.error(`\u2717 Startup failed: ${t.message}`),process.exit(1)}}),e}var{pkg:Wi}=mt(),Ki=ir(Wi);Ki.parseAsync(process.argv).catch(n=>{console.error(`\u2717 CLI error: ${n.message}`),process.exit(1)});