comp-hub 0.47.1 → 0.47.2
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/dist/cli.js +35 -35
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`).replace(/^/gm," ".repeat(
|
|
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
|
|
2
|
+
"use strict";var cr=Object.create;var Me=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var pr=Object.getOwnPropertyNames;var hr=Object.getPrototypeOf,_r=Object.prototype.hasOwnProperty;var S=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var mr=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of pr(e))!_r.call(i,o)&&o!==t&&Me(i,o,{get:()=>e[o],enumerable:!(r=ur(e,o))||r.enumerable});return i};var d=(i,e,t)=>(t=i!=null?cr(hr(i)):{},mr(e||!i||!i.__esModule?Me(t,"default",{value:i,enumerable:!0}):t,i));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(ne=>{var{InvalidArgumentError:gn}=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 gn(`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 On(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}ne.Argument=oe;ne.humanReadableArgName=On});var se=S(gt=>{var{humanReadableArgName:An}=B(),ie=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=>An(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 lr=`${_.padEnd(r+s)}${x}`;return t.wrap(lr,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)===`
|
|
5
5
|
`&&(p=p.slice(0,p.length-1)),(m>0?a:"")+p.trimRight())).join(`
|
|
6
|
-
`)}};
|
|
6
|
+
`)}};gt.Help=ie});var ce=S(W=>{var{InvalidArgumentError:Cn}=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=Ot(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 Cn(`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 Tn(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,n=o!==void 0?o:!1;return t.negate===(n===e)}};function Tn(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Ot(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}}W.Option=ae;W.splitOptionFlags=Ot;W.DualOptions=le});var Ct=S(At=>{function Pn(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 Sn(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=Pn(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?`
|
|
7
7
|
(Did you mean one of ${r.join(", ")}?)`:r.length===1?`
|
|
8
|
-
(Did you mean ${r[0]}?)`:""}
|
|
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
|
|
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,
|
|
8
|
+
(Did you mean ${r[0]}?)`:""}At.suggestSimilar=Sn});var It=S(Rt=>{var Mn=require("events").EventEmitter,ue=require("child_process"),P=require("path"),pe=require("fs"),h=require("process"),{Argument:Rn,humanReadableArgName:In}=B(),{CommanderError:he}=H(),{Help:bn}=se(),{Option:Tt,splitOptionFlags:Ln,DualOptions:Dn}=ce(),{suggestSimilar:Pt}=Ct(),_e=class i extends Mn{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 bn,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 Rn(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 he(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 Tt(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 Tt)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 $(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(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=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=Mt(h.execArgv).concat(t),a=ue.spawn(h.argv[0],t,{stdio:"inherit"})):a=ue.spawn(s,t,{stdio:"inherit"}):(t.unshift(s),t=Mt(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 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
|
|
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 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 $(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 St(this,t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),St(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 $(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,
|
|
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=>
|
|
18
|
-
Expecting one of '${r.join("', '")}'`);let o=`${e}Help`;return this.on(o,
|
|
19
|
-
`)}),this}};function Pt(n,e){n._hasHelpOption&&e.find(r=>r===n._helpLongFlag||r===n._helpShortFlag)&&(n.outputHelp(),n._exit(0,"commander.helpDisplayed","(outputHelp)"))}function St(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}Mt.Command=_e});var Dt=S((A,Lt)=>{var{Argument:bi}=B(),{Command:It}=Rt(),{CommanderError:Li,InvalidArgumentError:bt}=H(),{Help:Di}=se(),{Option:Ni}=ce();A=Lt.exports=new It;A.program=A;A.Argument=bi;A.Command=It;A.CommanderError=Li;A.Help=Di;A.InvalidArgumentError=bt;A.InvalidOptionArgumentError=bt;A.Option=Ni});var $t=S((Rn,me)=>{"use strict";var $i=require("net"),q=class extends Error{constructor(e){super(`${e} is locked`)}},y={old:new Set,young:new Set},vi=1e3*15,K,Ht=n=>new Promise((e,t)=>{let r=$i.createServer();r.unref(),r.on("error",t),r.listen(n,()=>{let{port:o}=r.address();r.close(()=>{e(o)})})}),Fi=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},vi),K.unref&&K.unref());for(let t of Fi(e))try{let r=await Ht({...n,port:t});for(;y.old.has(r)||y.young.has(r);){if(t!==0)throw new q(t);r=await Ht({...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")),mt=d(require("http")),w=d(require("path"));var nt=d(require("path")),st=d(require("os"));var _r="Comp Hub",mr="main",dr="container",Er="item",fr="/__global_config__",gr="local://",Or="comphubConfig",Ar="https://intranet.comphub.cn",Cr="https://iframe.comphub.cn",Tr="https://cdn.comphub.cn/vendor",Pr="https://github.com/ggbond-github/comp-hub-community",Sr="https://www.npmjs.com/package/comp-hub",Mr="ca-pub-3825910057508741",Rr="__remote__",Ir="__local__",br="__admin__",Lr="https://api.comphub.cn",Dr="http://localhost:7002",Nr="http://127.0.0.1:5000",wr="http://localhost:5001",yr="http://localhost:3580",Ur="https://apiadmin.comphub.cn",xr="https://admin.comphub.cn",Hr="/_module_load_prefix_",$r="/_node_modules_load_prefix_",vr="/_comp_preview_prefix_local_",Fr="/__proxy__",Vr="/__master__",kr="authorization",jr="x-refresh-token",Yr="accept-language",Gr="X-Token-Refreshed",Br="team-id",Wr="comp-hub-db",Kr="file-compiled",qr="https://oss.comphub.cn",Xr="oss:sts:token",Jr="oss:sts:expire",Zr="https://prebuild.comphub.cn",zr="/dev",Qr="/prod",eo="/node_modules/.prebuild_module",to="_metadata.json",ro="vue/dist/vue.esm-bundler.js",oo="react-jsx-loader",io="vue3-sfc-loader",no="vue2-sfc-loader",so="sass-compiler",ao="less-compiler",lo="webcomp-loader",Me="react",Re="webcomponent",co={COMP_FRAMEWORK_VUE:"vue",COMP_FRAMEWORK_REACT:Me,COMP_FRAMEWORK_WEB_COMPONENT:Re},uo="comp.json",po="README.md",ho="main.js",_o="index.vue",mo=["index.jsx","index.js","index.tsx"],Eo="index.js",fo="/.comp_hub_temp",go="screenshot_mini.png",Oo=1024*1024*10,Ao=1024*1024*3,Co=30,To=1024*150,Ie="list_local",be="list_remote",Po={COMP_LIST_TYPE_LOCAL:Ie,COMP_LIST_TYPE_REMOTE:be},Le="config",De="error",Ne="dir",we="preview",ye="extra",Ue="deps",xe="readme",He="upgradeLog",So={TAB_TYPE_CONFIG:Le,TAB_TYPE_ERROR:De,TAB_TYPE_DIR:Ne,TAB_TYPE_PREVIEW:we,TAB_TYPE_EXTRA:ye,TAB_TYPE_DEPS:Ue,TAB_TYPE_README:xe,TAB_TYPE_UPGRADE_LOG:He},$e="mini",ve="full",Mo={COMP_EDIT_TAB_TYPE_MINI:$e,COMP_EDIT_TAB_TYPE_FULL:ve},Fe="EDIT",Ve="ADD",Ro={DIALOG_TYPE_EDIT:Fe,DIALOG_TYPE_ADD:Ve},ke="ONLY_INSTALL",je="AUTO",Ye="MAJOR_VERSION",Ge="MINOR_VERSION",Be="EXACT_VERSION",Io={COMP_MATCH_TYPE_ONLY_INSTALL:ke,COMP_MATCH_TYPE_AUTO:je,COMP_MATCH_TYPE_MAJOR_VERSION:Ye,COMP_MATCH_TYPE_MINOR_VERSION:Ge,COMP_MATCH_TYPE_EXACT_VERSION:Be},We="online",Ke="offline",bo={COMP_UPDATE_TYPE_ONLINE:We,COMP_UPDATE_TYPE_OFFLINE:Ke},qe="NOT_EXIST",Xe="EXIST",Lo={COMP_CHECK_STATUS_NOT_EXIST:qe,COMP_CHECK_STATUS_EXIST:Xe},Do="__id__",No=0,wo=1,yo=-1,Je="checkPreviewListForm",Ze="checkExtraInfoForm",ze="checkCompConfig",Qe="checkUpgradeLogForm",et="getCompError",tt="afterCompDel",rt="afterCompCancelCollect",ot="afterCompRenderRetry",it="openCompTerminal",Uo={COMP_METHOD_KEY_CHECK_PREVIEW_LIST_FORM:Je,COMP_METHOD_KEY_CHECK_EXTRA_INFO_FORM:Ze,COMP_METHOD_KEY_CHECK_COMP_CONFIG:ze,COMP_METHOD_KEY_CHECK_UPGRADE_LOG_FORM:Qe,COMP_METHOD_KEY_GET_COMP_ERROR:et,COMP_METHOD_KEY_AFTER_COMP_DEL:tt,COMP_METHOD_KEY_AFTER_COMP_CANCEL_COLLECT:rt,COMP_METHOD_KEY_AFTER_COMP_RENDER_RETRY:ot,COMP_METHOD_KEY_OPEN_COMP_TERMINAL:it},xo="compListStore",Ho="compEditStore",$o="callbacks",vo={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"}},Fo="http://127.0.0.1",Vo="http://localhost:8095",ko="http://localhost:8096",jo="http://localhost:5198",Yo="http://localhost:3056",Go="https://www.comphub.cn",Bo="https://comphub.cn",Wo="CREATE",Ko="JOIN",qo="EXIT",Xo="teamAddMyComp",Jo="teamCompList",Zo="teamCompGroupList",zo="teamMyCompList",Qo="teamMyCompUpdate",ei="__v__",ti="local",ri="prod",oi="local",ii="prod",ni="http://localhost:5173",si="https://docs.comphub.cn",ai="1.5em",li="1.5em",ci="SUPER_ADMIN",ui="ADMIN",F={MAIN:"main",IFRAME_CONTAINER:"iframeContainer",IFRAME_ITEM:"iframeItem"},pi={[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"]}},hi={"vue3-sfc-loader":"vue3-sfc-loader-f42c4ee3.js","vue2-sfc-loader":"vue2-sfc-loader-63905622.js","react-jsx-loader":"react-jsx-loader-39babd0c.js","sass-compiler":"sass-compiler-482885df.js","less-compiler":"less-compiler-0cc8346f.js","webcomp-loader":"webcomp-loader-e24fcd01.js"},D=Object.freeze(Object.defineProperty({__proto__:null,ACCEPT_LANGUAGE_HEADER_NAME:Yr,ADMIN_SERVICE_PREFIX:br,ADMIN_SERVICE_URL_DEV:yr,ADMIN_SERVICE_URL_PROD:Ur,ADMIN_WEB_URL_PROD:xr,ADSENSE_CLIENT_ID:Mr,AUTHORIZATION_HEADER_NAME:kr,CACHE_KEY_STS_EXPIRE_TIME:Jr,CACHE_KEY_STS_TOKEN:Xr,COMPHUB_CONFIG_KEY:Or,COMP_ACTION_ICON_HEIGHT:li,COMP_ACTION_ICON_WIDTH:ai,COMP_CHECK_STATUSES:Lo,COMP_CHECK_STATUS_EXIST:Xe,COMP_CHECK_STATUS_NOT_EXIST:qe,COMP_CONFIG_FILENAME:uo,COMP_DOWNLOAD_ZIP_INLINE_MAX_TOTAL_SIZE:To,COMP_EDIT_TAB_TYPES:Mo,COMP_EDIT_TAB_TYPE_FULL:ve,COMP_EDIT_TAB_TYPE_MINI:$e,COMP_ENTRY_FILE:ho,COMP_FIELD_COMP_ID:Do,COMP_FRAMEWORK_REACT:Me,COMP_FRAMEWORK_TYPES:co,COMP_FRAMEWORK_VUE:"vue",COMP_FRAMEWORK_WEB_COMPONENT:Re,COMP_HUB_DEV_DOCS_URL:ni,COMP_HUB_PROD_DOCS_URL:si,COMP_LIST_TYPES:Po,COMP_LIST_TYPE_LOCAL:Ie,COMP_LIST_TYPE_REMOTE:be,COMP_MATCH_TYPES:Io,COMP_MATCH_TYPE_AUTO:je,COMP_MATCH_TYPE_EXACT_VERSION:Be,COMP_MATCH_TYPE_MAJOR_VERSION:Ye,COMP_MATCH_TYPE_MINOR_VERSION:Ge,COMP_MATCH_TYPE_ONLY_INSTALL:ke,COMP_METHOD_KEY_AFTER_COMP_CANCEL_COLLECT:rt,COMP_METHOD_KEY_AFTER_COMP_DEL:tt,COMP_METHOD_KEY_AFTER_COMP_RENDER_RETRY:ot,COMP_METHOD_KEY_CHECK_COMP_CONFIG:ze,COMP_METHOD_KEY_CHECK_EXTRA_INFO_FORM:Ze,COMP_METHOD_KEY_CHECK_PREVIEW_LIST_FORM:Je,COMP_METHOD_KEY_CHECK_UPGRADE_LOG_FORM:Qe,COMP_METHOD_KEY_GET_COMP_ERROR:et,COMP_METHOD_KEY_OPEN_COMP_TERMINAL:it,COMP_PREVIEW_PREFIX_LOCAL:vr,COMP_README_FILENAME:po,COMP_SCREENSHOT_MINI_FILENAME:go,COMP_SUBMIT_MAX_FILE_COUNT:Co,COMP_SUBMIT_MAX_SINGLE_FILE_SIZE:Ao,COMP_SUBMIT_MAX_TOTAL_SIZE:Oo,COMP_TEMP_DIR:fo,COMP_UPDATE_TYPES:bo,COMP_UPDATE_TYPE_OFFLINE:Ke,COMP_UPDATE_TYPE_ONLINE:We,COMP_USE_ENTRY_FILE:_o,COMP_USE_ENTRY_FILE_REACT:mo,COMP_USE_ENTRY_FILE_WEB_COMPONENT:Eo,DIALOG_TYPES:Ro,DIALOG_TYPE_ADD:Ve,DIALOG_TYPE_EDIT:Fe,FILE_MANAGER_DIRNAME:gr,GITHUB_REPO_URL:Pr,GLOBAL_CONFIG_PATH:fr,IFRAME_HOST:Fo,IFRAME_ROUTES:vo,INDEX_DB_NAME:Wr,INDEX_DB_TABLE_NAME:Kr,LESS_COMPILER_KEY:ao,LOCAL_CHILD_IFRAME_URL:Vo,LOCAL_LEAF_IFRAME_URL:ko,LOCAL_MAIN_EXTRANET_URL:Yo,LOCAL_MIDWAY_ENV_LOCAL:ti,LOCAL_MIDWAY_ENV_PROD:ri,LOCAL_SERVICE_PREFIX:Ir,LOCAL_SERVICE_URL_DEV:Nr,LOCAL_SERVICE_URL_DEV_SUB:wr,LOCAL_TOP_IFRAME_URL:jo,MASTER_API_PREFIX:Vr,META_FILE_NAME:to,MODULE_LOAD_PREFIX:Hr,NODE_MODULES_LOAD_PREFIX:$r,NPM_PACKAGE_URL:Sr,OSS_CUSTOM_DOMAIN:qr,PREBUILD_HOST:Zr,PREBUILD_MAX_SINGLE_FILE_SIZE:52428800,PREBUILD_MODULE_DIR:eo,PREBUILD_MODULE_DIR_DEV:zr,PREBUILD_MODULE_DIR_PROD:Qr,PROVIDE_KEYS:Uo,PROVIDE_KEY_CALLBACKS:$o,PROVIDE_KEY_COMP_EDIT_STORE:Ho,PROVIDE_KEY_COMP_LIST_STORE:xo,PROXY_PATH_PREFIX:Fr,REACT_JSX_LOADER_KEY:oo,REFRESH_TOKEN_HEADER_NAME:jr,REMOTE_MAIN_EXTRANET_APEX_URL:Bo,REMOTE_MAIN_EXTRANET_URL:Go,REMOTE_MIDWAY_ENV_LOCAL:oi,REMOTE_MIDWAY_ENV_PROD:ii,REMOTE_SERVICE_PREFIX:Rr,REMOTE_SERVICE_URL_DEV:Dr,REMOTE_SERVICE_URL_PROD:Lr,ROLE_CODE_ADMIN:ui,ROLE_CODE_SUPER_ADMIN:ci,ROUTE_STATE_KEY_VERSION:ei,SASS_COMPILER_KEY:so,SCOPE_ID_TEAM_ADD_MY_COMP:Xo,SCOPE_ID_TEAM_COMP_GROUP_LIST:Zo,SCOPE_ID_TEAM_COMP_LIST:Jo,SCOPE_ID_TEAM_MY_COMP_LIST:zo,SCOPE_ID_TEAM_MY_COMP_UPDATE:Qo,SENTRY_PROJECTS:pi,SENTRY_PROJECT_NAMES:F,SITE_TITLE:_r,TAB_TYPES:So,TAB_TYPE_CONFIG:Le,TAB_TYPE_DEPS:Ue,TAB_TYPE_DIR:Ne,TAB_TYPE_ERROR:De,TAB_TYPE_EXTRA:ye,TAB_TYPE_PREVIEW:we,TAB_TYPE_README:xe,TAB_TYPE_UPGRADE_LOG:He,TEAM_ID_HEADER_NAME:Br,TEAM_OPERATE_TYPE_CREATE:Wo,TEAM_OPERATE_TYPE_EXIT:qo,TEAM_OPERATE_TYPE_JOIN:Ko,VENDOR_CDN_BASE:Tr,VENDOR_LOADER_FILES:hi,VERSION_COMPARE_GREATER:wo,VERSION_COMPARE_LESS:yo,VERSION_COMPARE_SAME:No,VUE2_SFC_LOADER_KEY:no,VUE3_SFC_LOADER_KEY:io,VUE_ESM_BUNDLER:ro,WEBCOMP_LOADER_KEY:lo,WEBSITE_OSS_URL_IFRAME:Cr,WEBSITE_OSS_URL_MAIN:Ar,WEBSITE_PATH_CONTAINER:dr,WEBSITE_PATH_ITEM:Er,WEBSITE_PATH_MAIN:mr,X_TOKEN_REFRESHED_HEADER_NAME:Gr},Symbol.toStringTag,{value:"Module"}));var V=5478,at=D.REMOTE_SERVICE_URL_PROD,I=nt.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,k=5e3;var ee=d(require("fs")),Q=d(require("path")),pt=d(require("crypto"));function j(n){return JSON.parse(ee.default.readFileSync(n,"utf8"))}function ht(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 _t(n){return pt.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=ht(__dirname)||w.default.resolve(__dirname,"..");function dt(){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 _i(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 Et(n,e){let t=_i(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 mi(n.managementPort))return n}catch{}try{N.default.unlinkSync(I)}catch{}}}catch{}return null}function mi(n){return new Promise(e=>{let t=mt.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 Nt=d(Dt(),1),{program:mn,createCommand:dn,createArgument:En,createOption:fn,CommanderError:gn,InvalidArgumentError:On,InvalidOptionArgumentError:An,Command:wt,Argument:Cn,Option:b,Help:Tn}=Nt.default;var Zt=d(require("fs")),zt=d(require("path"));var yt=d(require("http")),Ut=d(require("https"));var wi="/api/v2/upgrade/check";function yi(n){return(n||at).replace(/\/+$/,"")}function Ui(n,e,t){return new Promise((r,o)=>{let i=n.startsWith("https:")?Ut.default:yt.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 xi(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 Hi(n){return n.hasUpgrade&&n.isForce?"block":n.hasUpgrade?"notice":"none"}async function xt(n){let{base:e,compHubVersion:t,timeout:r,request:o=Ui}=n,i=`${yi(e)}${wi}`;try{let s=await o(i,{compHubVersion:t},r),l=xi(s);return{ok:!0,...l,verdict:Hi(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 X=d(require("http"));function Vi(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:Vi(o)}))});t.on("error",r=>e({ok:!1,error:r.message})),t.setTimeout(ut,()=>{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 vt(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(`
|
|
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 Dn(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=Pt(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=Pt(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=>In(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(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),$(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=Ln(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 St(i,e){i._hasHelpOption&&e.find(r=>r===i._helpLongFlag||r===i._helpShortFlag)&&(i.outputHelp(),i._exit(0,"commander.helpDisplayed","(outputHelp)"))}function Mt(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 $(i){let e=[];for(let t=i;t;t=t.parent)e.push(t);return e}Rt.Command=_e});var Nt=S((A,Dt)=>{var{Argument:Nn}=B(),{Command:bt}=It(),{CommanderError:wn,InvalidArgumentError:Lt}=H(),{Help:yn}=se(),{Option:Un}=ce();A=Dt.exports=new bt;A.program=A;A.Argument=Nn;A.Command=bt;A.CommanderError=wn;A.Help=yn;A.InvalidArgumentError=Lt;A.InvalidOptionArgumentError=Lt;A.Option=Un});var vt=S((bi,me)=>{"use strict";var Vn=require("net"),q=class extends Error{constructor(e){super(`${e} is locked`)}},y={old:new Set,young:new Set},kn=1e3*15,K,$t=i=>new Promise((e,t)=>{let r=Vn.createServer();r.unref(),r.on("error",t),r.listen(i,()=>{let{port:o}=r.address();r.close(()=>{e(o)})})}),jn=function*(i){i&&(yield*i),yield 0};me.exports=async i=>{let e;i&&(e=typeof i.port=="number"?[i.port]:i.port),K===void 0&&(K=setInterval(()=>{y.old=y.young,y.young=new Set},kn),K.unref&&K.unref());for(let t of jn(e))try{let r=await $t({...i,port:t});for(;y.old.has(r)||y.young.has(r);){if(t!==0)throw new q(t);r=await $t({...i,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=(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")),dt=d(require("http")),w=d(require("path"));var st=d(require("path")),at=d(require("os"));var dr="Comp Hub",Er="main",fr="container",gr="item",Or="/__global_config__",Ar="local://",Cr="comphubConfig",Tr="https://intranet.comphub.cn",Pr="https://iframe.comphub.cn",Sr="https://cdn.comphub.cn/vendor",Mr="https://github.com/ggbond-github/comp-hub-community",Rr="https://www.npmjs.com/package/comp-hub",Ir="ca-pub-3825910057508741",br="__remote__",Lr="__local__",Dr="__admin__",Nr="https://api.comphub.cn",wr="http://localhost:7002",yr="http://127.0.0.1:5000",Ur="http://localhost:5001",xr="http://localhost:3580",Hr="https://apiadmin.comphub.cn",$r="https://admin.comphub.cn",vr="/_module_load_prefix_",Fr="/_node_modules_load_prefix_",Vr="/_comp_preview_prefix_local_",kr="/__proxy__",jr="/__master__",Yr="authorization",Gr="x-refresh-token",Br="accept-language",Wr="X-Token-Refreshed",Kr="team-id",qr="comp-hub-db",Xr="file-compiled",Jr="https://oss.comphub.cn",Zr="oss:sts:token",zr="oss:sts:expire",Qr="https://prebuild.comphub.cn",eo="/dev",to="/prod",ro="/node_modules/.prebuild_module",oo="_metadata.json",no="vue/dist/vue.esm-bundler.js",io="react-jsx-loader",so="vue3-sfc-loader",ao="vue2-sfc-loader",lo="sass-compiler",co="less-compiler",uo="webcomp-loader",Re="react",Ie="webcomponent",po={COMP_FRAMEWORK_VUE:"vue",COMP_FRAMEWORK_REACT:Re,COMP_FRAMEWORK_WEB_COMPONENT:Ie},ho="comp.json",_o="README.md",mo="main.js",Eo="index.vue",fo=["index.jsx","index.js","index.tsx"],go="index.js",Oo="/.comp_hub_temp",Ao="screenshot_mini.png",Co=1024*1024*10,To=1024*1024*3,Po=30,So=1024*150,be="list_local",Le="list_remote",Mo={COMP_LIST_TYPE_LOCAL:be,COMP_LIST_TYPE_REMOTE:Le},De="config",Ne="error",we="dir",ye="preview",Ue="extra",xe="deps",He="readme",$e="upgradeLog",Ro={TAB_TYPE_CONFIG:De,TAB_TYPE_ERROR:Ne,TAB_TYPE_DIR:we,TAB_TYPE_PREVIEW:ye,TAB_TYPE_EXTRA:Ue,TAB_TYPE_DEPS:xe,TAB_TYPE_README:He,TAB_TYPE_UPGRADE_LOG:$e},ve="mini",Fe="full",Io={COMP_EDIT_TAB_TYPE_MINI:ve,COMP_EDIT_TAB_TYPE_FULL:Fe},Ve="EDIT",ke="ADD",bo={DIALOG_TYPE_EDIT:Ve,DIALOG_TYPE_ADD:ke},je="ONLY_INSTALL",Ye="AUTO",Ge="MAJOR_VERSION",Be="MINOR_VERSION",We="EXACT_VERSION",Lo={COMP_MATCH_TYPE_ONLY_INSTALL:je,COMP_MATCH_TYPE_AUTO:Ye,COMP_MATCH_TYPE_MAJOR_VERSION:Ge,COMP_MATCH_TYPE_MINOR_VERSION:Be,COMP_MATCH_TYPE_EXACT_VERSION:We},Ke="online",qe="offline",Do={COMP_UPDATE_TYPE_ONLINE:Ke,COMP_UPDATE_TYPE_OFFLINE:qe},Xe="NOT_EXIST",Je="EXIST",No={COMP_CHECK_STATUS_NOT_EXIST:Xe,COMP_CHECK_STATUS_EXIST:Je},wo="__id__",yo=0,Uo=1,xo=-1,Ze="checkPreviewListForm",ze="checkExtraInfoForm",Qe="checkCompConfig",et="checkUpgradeLogForm",tt="getCompError",rt="afterCompDel",ot="afterCompCancelCollect",nt="afterCompRenderRetry",it="openCompTerminal",Ho={COMP_METHOD_KEY_CHECK_PREVIEW_LIST_FORM:Ze,COMP_METHOD_KEY_CHECK_EXTRA_INFO_FORM:ze,COMP_METHOD_KEY_CHECK_COMP_CONFIG:Qe,COMP_METHOD_KEY_CHECK_UPGRADE_LOG_FORM:et,COMP_METHOD_KEY_GET_COMP_ERROR:tt,COMP_METHOD_KEY_AFTER_COMP_DEL:rt,COMP_METHOD_KEY_AFTER_COMP_CANCEL_COLLECT:ot,COMP_METHOD_KEY_AFTER_COMP_RENDER_RETRY:nt,COMP_METHOD_KEY_OPEN_COMP_TERMINAL:it},$o="compListStore",vo="compEditStore",Fo="callbacks",Vo={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"}},ko="http://127.0.0.1",jo="http://localhost:8095",Yo="http://localhost:8096",Go="http://localhost:5198",Bo="http://localhost:3056",Wo="https://www.comphub.cn",Ko="https://comphub.cn",qo="CREATE",Xo="JOIN",Jo="EXIT",Zo="teamAddMyComp",zo="teamCompList",Qo="teamCompGroupList",en="teamMyCompList",tn="teamMyCompUpdate",rn="__v__",on="local",nn="prod",sn="local",an="prod",ln="http://localhost:5173",cn="https://docs.comphub.cn",un="1.5em",pn="1.5em",hn="SUPER_ADMIN",_n="ADMIN",F={MAIN:"main",IFRAME_CONTAINER:"iframeContainer",IFRAME_ITEM:"iframeItem"},mn={[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"]}},dn={"vue3-sfc-loader":"vue3-sfc-loader-f42c4ee3.js","vue2-sfc-loader":"vue2-sfc-loader-63905622.js","react-jsx-loader":"react-jsx-loader-39babd0c.js","sass-compiler":"sass-compiler-482885df.js","less-compiler":"less-compiler-0cc8346f.js","webcomp-loader":"webcomp-loader-e24fcd01.js"},D=Object.freeze(Object.defineProperty({__proto__:null,ACCEPT_LANGUAGE_HEADER_NAME:Br,ADMIN_SERVICE_PREFIX:Dr,ADMIN_SERVICE_URL_DEV:xr,ADMIN_SERVICE_URL_PROD:Hr,ADMIN_WEB_URL_PROD:$r,ADSENSE_CLIENT_ID:Ir,AUTHORIZATION_HEADER_NAME:Yr,CACHE_KEY_STS_EXPIRE_TIME:zr,CACHE_KEY_STS_TOKEN:Zr,COMPHUB_CONFIG_KEY:Cr,COMP_ACTION_ICON_HEIGHT:pn,COMP_ACTION_ICON_WIDTH:un,COMP_CHECK_STATUSES:No,COMP_CHECK_STATUS_EXIST:Je,COMP_CHECK_STATUS_NOT_EXIST:Xe,COMP_CONFIG_FILENAME:ho,COMP_DOWNLOAD_ZIP_INLINE_MAX_TOTAL_SIZE:So,COMP_EDIT_TAB_TYPES:Io,COMP_EDIT_TAB_TYPE_FULL:Fe,COMP_EDIT_TAB_TYPE_MINI:ve,COMP_ENTRY_FILE:mo,COMP_FIELD_COMP_ID:wo,COMP_FRAMEWORK_REACT:Re,COMP_FRAMEWORK_TYPES:po,COMP_FRAMEWORK_VUE:"vue",COMP_FRAMEWORK_WEB_COMPONENT:Ie,COMP_HUB_DEV_DOCS_URL:ln,COMP_HUB_PROD_DOCS_URL:cn,COMP_LIST_TYPES:Mo,COMP_LIST_TYPE_LOCAL:be,COMP_LIST_TYPE_REMOTE:Le,COMP_MATCH_TYPES:Lo,COMP_MATCH_TYPE_AUTO:Ye,COMP_MATCH_TYPE_EXACT_VERSION:We,COMP_MATCH_TYPE_MAJOR_VERSION:Ge,COMP_MATCH_TYPE_MINOR_VERSION:Be,COMP_MATCH_TYPE_ONLY_INSTALL:je,COMP_METHOD_KEY_AFTER_COMP_CANCEL_COLLECT:ot,COMP_METHOD_KEY_AFTER_COMP_DEL:rt,COMP_METHOD_KEY_AFTER_COMP_RENDER_RETRY:nt,COMP_METHOD_KEY_CHECK_COMP_CONFIG:Qe,COMP_METHOD_KEY_CHECK_EXTRA_INFO_FORM:ze,COMP_METHOD_KEY_CHECK_PREVIEW_LIST_FORM:Ze,COMP_METHOD_KEY_CHECK_UPGRADE_LOG_FORM:et,COMP_METHOD_KEY_GET_COMP_ERROR:tt,COMP_METHOD_KEY_OPEN_COMP_TERMINAL:it,COMP_PREVIEW_PREFIX_LOCAL:Vr,COMP_README_FILENAME:_o,COMP_SCREENSHOT_MINI_FILENAME:Ao,COMP_SUBMIT_MAX_FILE_COUNT:Po,COMP_SUBMIT_MAX_SINGLE_FILE_SIZE:To,COMP_SUBMIT_MAX_TOTAL_SIZE:Co,COMP_TEMP_DIR:Oo,COMP_UPDATE_TYPES:Do,COMP_UPDATE_TYPE_OFFLINE:qe,COMP_UPDATE_TYPE_ONLINE:Ke,COMP_USE_ENTRY_FILE:Eo,COMP_USE_ENTRY_FILE_REACT:fo,COMP_USE_ENTRY_FILE_WEB_COMPONENT:go,DIALOG_TYPES:bo,DIALOG_TYPE_ADD:ke,DIALOG_TYPE_EDIT:Ve,FILE_MANAGER_DIRNAME:Ar,GITHUB_REPO_URL:Mr,GLOBAL_CONFIG_PATH:Or,IFRAME_HOST:ko,IFRAME_ROUTES:Vo,INDEX_DB_NAME:qr,INDEX_DB_TABLE_NAME:Xr,LESS_COMPILER_KEY:co,LOCAL_CHILD_IFRAME_URL:jo,LOCAL_LEAF_IFRAME_URL:Yo,LOCAL_MAIN_EXTRANET_URL:Bo,LOCAL_MIDWAY_ENV_LOCAL:on,LOCAL_MIDWAY_ENV_PROD:nn,LOCAL_SERVICE_PREFIX:Lr,LOCAL_SERVICE_URL_DEV:yr,LOCAL_SERVICE_URL_DEV_SUB:Ur,LOCAL_TOP_IFRAME_URL:Go,MASTER_API_PREFIX:jr,META_FILE_NAME:oo,MODULE_LOAD_PREFIX:vr,NODE_MODULES_LOAD_PREFIX:Fr,NPM_PACKAGE_URL:Rr,OSS_CUSTOM_DOMAIN:Jr,PREBUILD_HOST:Qr,PREBUILD_MAX_SINGLE_FILE_SIZE:52428800,PREBUILD_MODULE_DIR:ro,PREBUILD_MODULE_DIR_DEV:eo,PREBUILD_MODULE_DIR_PROD:to,PROVIDE_KEYS:Ho,PROVIDE_KEY_CALLBACKS:Fo,PROVIDE_KEY_COMP_EDIT_STORE:vo,PROVIDE_KEY_COMP_LIST_STORE:$o,PROXY_PATH_PREFIX:kr,REACT_JSX_LOADER_KEY:io,REFRESH_TOKEN_HEADER_NAME:Gr,REMOTE_MAIN_EXTRANET_APEX_URL:Ko,REMOTE_MAIN_EXTRANET_URL:Wo,REMOTE_MIDWAY_ENV_LOCAL:sn,REMOTE_MIDWAY_ENV_PROD:an,REMOTE_SERVICE_PREFIX:br,REMOTE_SERVICE_URL_DEV:wr,REMOTE_SERVICE_URL_PROD:Nr,ROLE_CODE_ADMIN:_n,ROLE_CODE_SUPER_ADMIN:hn,ROUTE_STATE_KEY_VERSION:rn,SASS_COMPILER_KEY:lo,SCOPE_ID_TEAM_ADD_MY_COMP:Zo,SCOPE_ID_TEAM_COMP_GROUP_LIST:Qo,SCOPE_ID_TEAM_COMP_LIST:zo,SCOPE_ID_TEAM_MY_COMP_LIST:en,SCOPE_ID_TEAM_MY_COMP_UPDATE:tn,SENTRY_PROJECTS:mn,SENTRY_PROJECT_NAMES:F,SITE_TITLE:dr,TAB_TYPES:Ro,TAB_TYPE_CONFIG:De,TAB_TYPE_DEPS:xe,TAB_TYPE_DIR:we,TAB_TYPE_ERROR:Ne,TAB_TYPE_EXTRA:Ue,TAB_TYPE_PREVIEW:ye,TAB_TYPE_README:He,TAB_TYPE_UPGRADE_LOG:$e,TEAM_ID_HEADER_NAME:Kr,TEAM_OPERATE_TYPE_CREATE:qo,TEAM_OPERATE_TYPE_EXIT:Jo,TEAM_OPERATE_TYPE_JOIN:Xo,VENDOR_CDN_BASE:Sr,VENDOR_LOADER_FILES:dn,VERSION_COMPARE_GREATER:Uo,VERSION_COMPARE_LESS:xo,VERSION_COMPARE_SAME:yo,VUE2_SFC_LOADER_KEY:ao,VUE3_SFC_LOADER_KEY:so,VUE_ESM_BUNDLER:no,WEBCOMP_LOADER_KEY:uo,WEBSITE_OSS_URL_IFRAME:Pr,WEBSITE_OSS_URL_MAIN:Tr,WEBSITE_PATH_CONTAINER:fr,WEBSITE_PATH_ITEM:gr,WEBSITE_PATH_MAIN:Er,X_TOKEN_REFRESHED_HEADER_NAME:Wr},Symbol.toStringTag,{value:"Module"}));var V=5478,lt=D.REMOTE_SERVICE_URL_PROD,I=st.default.join(at.default.tmpdir(),".comphub","master.json"),f={PREFIX:"/__master__",HEALTH:"/__master__/health",REGISTER:"/__master__/register",DEREGISTER:"/__master__/deregister",PROJECTS:"/__master__/projects",SHUTDOWN:"/__master__/shutdown"},ct=500,ut=40,pt=2e3,k=5e3;var ee=d(require("fs")),Q=d(require("path")),ht=d(require("crypto"));function j(i){return JSON.parse(ee.default.readFileSync(i,"utf8"))}function _t(i){let e=i;for(let t=0;t<12;t++){try{let o=Q.default.join(e,"package.json");if(ee.default.existsSync(o)){let n=j(o);if(n&&n.name==="comp-hub")return e}}catch{}let r=Q.default.dirname(e);if(r===e)break;e=r}return null}function mt(i){return ht.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 Y=_t(__dirname)||w.default.resolve(__dirname,"..");function Et(){let i=w.default.join(Y,"package.json"),e=j(i),t=w.default.join(Y,e.main||"dist/index.js");return{pkg:e,entry:t}}function En(i){let e=w.default.join(i,".comphub.json"),t=w.default.join(i,".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 ft(i,e){let t=En(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 fn(i.managementPort))return i}catch{}try{N.default.unlinkSync(I)}catch{}}}catch{}return null}function fn(i){return new Promise(e=>{let t=dt.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 wt=d(Nt(),1),{program:Ei,createCommand:fi,createArgument:gi,createOption:Oi,CommanderError:Ai,InvalidArgumentError:Ci,InvalidOptionArgumentError:Ti,Command:yt,Argument:Pi,Option:b,Help:Si}=wt.default;var Qt=d(require("fs")),er=d(require("path"));var Ut=d(require("http")),xt=d(require("https"));var xn="/api/v2/upgrade/check";function Hn(i){return(i||lt).replace(/\/+$/,"")}function $n(i,e,t){return new Promise((r,o)=>{let n=i.startsWith("https:")?xt.default:Ut.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||k,()=>{c.destroy(new Error("Request timeout"))}),c.write(s),c.end()})}function vn(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 Fn(i){return i.hasUpgrade&&i.isForce?"block":i.hasUpgrade?"notice":"none"}async function Ht(i){let{base:e,compHubVersion:t,timeout:r,request:o=$n}=i,n=`${Hn(e)}${xn}`;try{let s=await o(n,{compHubVersion:t},r),l=vn(s);return{ok:!0,...l,verdict:Fn(l)}}catch(s){return{ok:!1,error:s?.message||String(s)}}}var jt=d(require("fs")),Yt=d(require("path")),Gt=require("child_process"),de=d(vt());var X=d(require("http"));function Yn(i){try{return JSON.parse(i)}catch{return i}}function v(i){return new Promise(e=>{let t=X.default.get(i,r=>{let o="";r.on("data",n=>o+=n),r.on("end",()=>e({ok:!0,status:r.statusCode,body:Yn(o)}))});t.on("error",r=>e({ok:!1,error:r.message})),t.setTimeout(pt,()=>{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=X.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(k,()=>{s.destroy(),t({ok:!1,error:"Request timeout"})}),s.write(r),s.end()})}function Ft(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=X.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(`
|
|
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
|
|
22
|
-
`);
|
|
23
|
-
`)}),["SIGINT","SIGTERM"].forEach(
|
|
24
|
-
`))}var{cyan:
|
|
25
|
-
${
|
|
26
|
-
`);let m=`http://localhost:${a}/__master__/projects/${r}/logs`;try{await
|
|
27
|
-
${
|
|
28
|
-
${
|
|
29
|
-
`);let o=await v(g(e,f.HEALTH));(!o.ok||!o.body||typeof o.body.status!="string")&&(console.error(`${
|
|
30
|
-
${
|
|
31
|
-
`);for(let s of
|
|
32
|
-
${
|
|
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(i,e){return M(g(i,"/__master__/deregister"),{hash:e})}var{green:Gn}=E,Ee=/^\[[0-9a-f]{8}\]/;function kt(i,e,t){e.pending+=i.toString();let r=e.pending.split(`
|
|
22
|
+
`);e.pending=r.pop()||"";for(let o of r)Ee.test(o)||t.write(o+`
|
|
23
|
+
`)}async function Bn(){for(let i=0;i<ut;i++){let e=await T();if(e)return e;await new Promise(t=>setTimeout(t,ct))}return null}async function Wn(i,e,t){let r=Yt.default.join(Y,"dist/master.js");if(!jt.default.existsSync(r))throw new Error("Master entry file not found, startup failed");let o=["--port",String(i),"--public-port",String(i)],n=(0,Gt.spawn)(process.execPath,["--no-deprecation",r,...o],{stdio:["inherit","pipe","pipe"],cwd:t,env:{...process.env,COMP_HUB_VERSION:e.version}}),s={pending:""},l={pending:""};n.stderr&&n.stderr.on("data",c=>kt(c,l,process.stderr)),n.stdout&&n.stdout.on("data",c=>kt(c,s,process.stdout)),["SIGINT","SIGTERM"].forEach(c=>{process.on(c,()=>{n.kill(c)})}),n.on("exit",c=>{s.pending&&!Ee.test(s.pending)&&process.stdout.write(s.pending),l.pending&&!Ee.test(l.pending)&&process.stderr.write(l.pending),process.exit(c||0)});let a=await Bn();if(!a)throw n.kill(),new Error("Master startup timeout");return{runtime:a}}async function Bt(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:V,s=await(0,de.default)({port:de.default.makeRange(n,n+100)}),{runtime:l}=await Wn(s,e,process.cwd());return{runtime:l,portMismatch:t,runningPublicPort:r}}async function Wt(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(`${Gn("\u2713")} Project registered (hash: ${e})`)}var{cyan:L,green:J,white:Kt,yellow:Kn,red:qt}=E;function Xt(i,e,t,r,o,n){let{portMismatch:s,runningPublicPort:l}=n,a=`http://localhost:${r}/${t}/${D.WEBSITE_PATH_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 "),"","",` ${J("Version")} ${i.version}`,` ${J("Project")} ${e}`,` ${J("Hash")} ${t}`,` ${J("Port")} ${r}`,"",` ${Kn("URL")} ${L(a)}`,"",Kt(" \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(Kt(" \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"),"",qt(` \u26A0 Master is already running on port ${l}, ignoring -p ${o.port}`),qt(" To change port, please run comphub kill first"),""),console.log(c.join(`
|
|
24
|
+
`))}var{cyan:Jt,green:qn,white:Zt,yellow:zt,red:fe}=E;async function ge(i,e){Qt.default.existsSync(er.default.join(process.cwd(),"package.json"))||(console.error(`${fe("\u2717")} Current directory is not a Node.js project`),process.exit(1));let t=process.cwd(),r=mt(t);e=ft(e,t);let o=await Ht({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(`${fe("\u2717")} comp-hub must be upgraded before it can start (current v${i.version}${_})`),console.error(` Please run the upgrade command: ${Jt("npm install comp-hub@latest -g")}`),console.error(" Then run comphub again after upgrading"),console.error(""),process.exit(1)}console.log(`${qn("\u2713")} ${i.name} v${i.version}`);let{runtime:n,portMismatch:s,runningPublicPort:l}=await Bt(e,i),a=n.managementPort,c=n.publicPort;if(await Wt(a,r,t,e),Xt(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(`${zt("\u2139")} comp-hub has a new version available${_}; run the upgrade command to update:`),console.log(` ${Jt("npm install comp-hub@latest -g")}`),console.log("")}else o.ok||(console.log(""),console.log(`${zt("\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
|
+
${Zt("\u2500")} Streaming logs from MidwayJS (${r}) ${Zt("\u2500")}
|
|
26
|
+
`);let m=`http://localhost:${a}/__master__/projects/${r}/logs`;try{await Ft(m,r)}catch(O){console.error(`
|
|
27
|
+
${fe("\u2717")} Log stream error: ${O.message}`)}}function tr(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 U(i){if(i.port!=null)return i.port;let e=await T();return e?e.managementPort:V}var{green:R,yellow:rr,cyan:or,white:C,red:Xn}=E;async function Oe(i){let e=await U(i),t=await T(),r=t?t.publicPort:e;console.log(`
|
|
28
|
+
${rr("\u25CF")} Master Status
|
|
29
|
+
`);let o=await v(g(e,f.HEALTH));(!o.ok||!o.body||typeof o.body.status!="string")&&(console.error(`${Xn("\u2717")} Master service is not running`),process.exit(1));let n=o.body,s=n.status==="running"?R("\u25CF"):or("\u25CF");console.log(` ${R("Status")} ${s} ${n.status}`),console.log(` ${R("Version")} ${C(n.version||"")}`),console.log(` ${R("Uptime")} ${C(tr(n.uptime??0))}`),console.log(` ${R("Projects")} ${C(String(n.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(` ${rr("\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")} ${or(`http://localhost:${r}/${c.hash}/${D.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:nr,yellow:Ae,red:Z}=E;async function Ce(i,e){let t=await U(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 n=o.body.projects;(!Array.isArray(n)||n.length===0)&&(console.log(`${Ae("\u2139")} No running projects`),process.exit(0)),console.log(`
|
|
30
|
+
${Ae("\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(` ${nr("\u2713")} Stopped: ${s.hash} (${s.cwd||""})`):console.error(` ${Z("\u2717")} Failed to stop: ${s.hash} - ${l.error}`)}console.log(""),process.exit(0)}i||(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
|
+
${Ae("\u25B8")} Stopping project ${i}...`);let r=await M(g(t,f.DEREGISTER),{hash:i});r.ok?console.log(` ${nr("\u2713")} Stopped: ${i}
|
|
33
33
|
`):(console.error(` ${Z("\u2717")} Failed to stop: ${r.error}
|
|
34
|
-
`),process.exit(1)),process.exit(0)}var{green:
|
|
35
|
-
${
|
|
36
|
-
`);let t=await M(g(e,f.SHUTDOWN),{});t.ok?console.log(`${
|
|
37
|
-
`):(console.error(`${
|
|
38
|
-
`),process.exit(1)),process.exit(0)}var
|
|
39
|
-
${
|
|
40
|
-
`);let
|
|
41
|
-
`),process.exit(0)),
|
|
42
|
-
`)}catch{console.error(` ${
|
|
43
|
-
`),process.exit(1)}else console.log(` ${
|
|
44
|
-
`);process.exit(0)}function z(
|
|
34
|
+
`),process.exit(1)),process.exit(0)}var{green:Jn,yellow:Zn,red:zn}=E;async function Te(i){let e=await U(i);console.log(`
|
|
35
|
+
${Zn("\u25B8")} Shutting down master process...
|
|
36
|
+
`);let t=await M(g(e,f.SHUTDOWN),{});t.ok?console.log(`${Jn("\u2713")} Master process has been shut down
|
|
37
|
+
`):(console.error(`${zn("\u2717")} Shutdown failed: ${t.error}
|
|
38
|
+
`),process.exit(1)),process.exit(0)}var Pe=d(require("fs"));var{green:ir,yellow:sr,red:Qn}=E;async function Se(){console.log(`
|
|
39
|
+
${sr("\u25B8")} Checking master runtime...
|
|
40
|
+
`);let i=await T();if(i&&(console.log(` ${ir("\u2713")} Master is running normally on port ${i.publicPort}
|
|
41
|
+
`),process.exit(0)),Pe.default.existsSync(I))try{Pe.default.unlinkSync(I),console.log(` ${ir("\u2713")} Removed stale runtime file
|
|
42
|
+
`)}catch{console.error(` ${Qn("\u2717")} Failed to remove runtime file
|
|
43
|
+
`),process.exit(1)}else console.log(` ${sr("\u2139")} No stale runtime file found
|
|
44
|
+
`);process.exit(0)}function z(i){return parseInt(i,10)}function ar(i){let e=new yt;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=>Oe(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)=>Ce(t,r)),e.command("kill").description("Shutdown master process").addOption(new b("-p, --port <number>","Master port").argParser(z).hideHelp()).action(t=>Te(t)),e.command("fix").description("Fix common issues (stale runtime file, etc.)").action(()=>Se()),e.action(async()=>{try{await ge(i,e.opts())}catch(t){console.error(`\u2717 Startup failed: ${t.message}`),process.exit(1)}}),e}var{pkg:ei}=Et(),ti=ar(ei);ti.parseAsync(process.argv).catch(i=>{console.error(`\u2717 CLI error: ${i.message}`),process.exit(1)});
|