gant-core 0.2.5 → 0.2.6
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/lib/cli/acorn.js +2 -0
- package/lib/cli/angular.js +2 -0
- package/lib/cli/babel.js +2 -0
- package/lib/cli/config/index.js +1 -1
- package/lib/cli/create/module/index.js +2 -2
- package/lib/cli/estree.js +2 -0
- package/lib/cli/flow.js +2 -0
- package/lib/cli/glimmer.js +2 -0
- package/lib/cli/graphql.js +2 -0
- package/lib/cli/html.js +2 -0
- package/lib/cli/i18n/index.js +2 -2
- package/lib/cli/index.js +1 -1
- package/lib/cli/markdown.js +2 -0
- package/lib/cli/meriyah.js +2 -0
- package/lib/cli/postcss.js +2 -0
- package/lib/cli/typescript.js +2 -0
- package/lib/cli/utils/getJavascriptfile.js +1 -9
- package/lib/cli/utils/index.js +1 -1
- package/lib/cli/webpack/config/default.config.js +1 -1
- package/lib/cli/webpack/config/production.config.js +1 -13
- package/lib/cli/webpack/plugins/index.js +1 -1
- package/lib/cli/yaml.js +2 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +35 -39
- package/rollup.config.js +2 -3
package/lib/cli/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e,t=require("fs"),i=require("./config/index.js"),n=require("./webpack/Webpack.js"),r=require("chokidar"),s=require("path"),o=require("./utils/index.js"),a=require("./routes/index.js"),l=require("./tsconfig/index.js"),h=require("./copyfiles/index.js"),c=require("./create/config/index.js"),u=require("./create/module/index.js"),p=require("events"),m=require("child_process"),d=require("process"),g=require("./i18n/index.js");function f(e="development"){process.env.SRC="true",process.env.NODE_ENV=e;const c=process.cwd(),u=new i.Config({cwd:c});let p=u.getUserConfig();function m(r){const u=o.getSrcPath(),p=s.resolve(c,u,".gant");o.generateDir(p);const m=t.readFileSync(s.resolve(__dirname,"./template/core.txt"),"utf-8");o.writeFileToJS(s.resolve(p,"index.ts"),m);const d={[r?.name||"@@"]:c,...r?.resolve?.alias},g=[c];i.keys(r.packages).map((e=>{const t=r.packages[e];d[e]=t,g.push(t)})),l.generateTsConfig(p,{paths:d,includes:g,cwd:c,vue:r.vue});const f=[...i.keys(r.packages),c];h.copyAppsFiles(p,[...i.keys(r.packages),c]),h.copyPublicFiles(p,f.map((e=>s.resolve(e,"public")))),a.generateRoutes(s.resolve(p,"./routes"),r.routes);return new n.Webpack(r,c,e)}u.configFiles;let d=m(p);if("development"!==e)d.runBuild();else{d.runServer();let g=null;function f(e){g=r.watch(u.configFiles?.map((e=>s.dirname(e))),{}),g.on("change",(e=>{d.devServer.stop(),p=u.getUserConfig(),d=m(p),d.runServer({open:!1})}))}f()}}function _(){const e=process.cwd(),n=new i.Config({cwd:e});let r=n.getMsUserConfig();const a=o.getSrcPath(),h=s.resolve(e,a,".gant");t.existsSync(h)||t.mkdirSync(h,{recursive:!0});const c=t.readFileSync(s.resolve(__dirname,"./template/core.txt"),"utf-8");o.writeFileToJS(s.resolve(h,"index.ts"),c);const u=r?.name||"main",p={},m={...r?.resolve?.alias},d=[e];return r.mfa?.entry&&(p[u]={entry:r.mfa?.entry,publicPath:"string"==typeof r.mfa?.publicPath?[r.mfa?.publicPath]:r.mfa?.publicPath,port:r.mfa?.port,htmlTemplatePath:r.mfa.htmlTemplatePath,apps:[e],base:r.mfa.base,isMaster:!0}),r.mfa.pages?.map?.((e=>{const t="string"==typeof e.path?[e.path]:e.path,i="string"==typeof e.publicPath?[e.publicPath]:e.publicPath;d.push(...t),p[e.name]={entry:e.entry||r.mfa.subEntry,publicPath:i,port:e.port,htmlTemplatePath:e.htmlTemplatePath,apps:t,base:e.base,url:e.url}})),o.writeFileToJS(s.resolve(h,"appMaps.ts"),`export default ${JSON.stringify(p)}`),l.generateTsConfig(h,{includes:d,paths:m,cwd:e,vue:r.vue,createIncludes:!1}),{userConfig:r,msName:u,msConfig:p,configManager:n}}function v(e="development",t){process.env.SRC="false",process.env.NODE_ENV=e;const{userConfig:n,msName:r,msConfig:s,configManager:o}=_();if(i.isEmpty(n.mfa))return;const a=t||r,l=s[a];l&&b(o,e,n,a,l)}function b(e,l,u,p,m,d=!0){const g=process.cwd(),f=o.getSrcPath(),v=i.cloneDeep(u);const O=m.apps?.map?.((e=>i.Config.getMainConfigFile({cwd:e})))?.filter?.((e=>!!e));let C=function(){const r=s.resolve(g,f,`.gant/${p}`);o.generateDir(r),h.copyAppsFiles(r,m.apps),h.copyPublicFiles(r,m.publicPath);const u=t.readFileSync(s.resolve(__dirname,"./template/msentry.txt"),"utf-8"),d=c.ejs.compile(u);t.writeFileSync(s.resolve(r,"index.ts"),d({entry:s.join("../../",m.entry)}));const _=e.getMsPagesUserConfig(m.apps);return a.generateRoutes(s.resolve(r,"./routes"),_.routes),v.entry={index:s.resolve(r,"index.ts")},v.base=i.get(m,"base","/"),v.define={...v.define,APP_NAME:p},v.devServer={...v.devServer,port:m.port,static:{directory:s.resolve(r,"public")}},v.output={...v.output,chunkLoadingGlobal:`webpackJsonp_${p}`,chunkFilename:`${p}.[name].[id].[contenthash].js`,path:s.resolve(g,`dist/${p}`)},v.outputPathDir=s.resolve(g,`dist/${p}`),v.publicPathDir=s.resolve(g,`.gant/${p}/public`),new n.Webpack(v,g,l)}();if("development"!==l)C.runBuild();else{C.runServer({open:d});let A=null;function w(t){A=r.watch(t),A.on("change",(t=>{C.devServer.stop();const{userConfig:i,msConfig:n}=_();A.close(),b(e,l,i,p,n[p],!1)}))}w(O)}}require("./config/defineConfig.js"),require("./utils/getJavascriptfile.js"),require("esbuild"),require("os"),require("crypto"),require("webpack"),require("webpack-dev-server"),require("./webpack/config/index.js"),require("./webpack/config/production.config.js"),require("zlib"),require("./webpack/plugins/copy.js"),require("mini-css-extract-plugin"),require("css-minimizer-webpack-plugin"),require("terser-webpack-plugin"),require("./webpack/config/default.config.js"),require("html-webpack-plugin"),require("./webpack/config/cssRules.js"),require("./webpack/config/development.config.js"),require("./webpack/config/analyzer.config.js"),require("prettier"),require("assert"),require("tty"),require("readline"),require("stream"),require("buffer"),require("util"),require("string_decoder"),require("node:process"),require("node:os"),require("node:tty"),require("node:assert"),require("node:readline"),require("http"),require("https"),require("url"),require("net"),require("./i18n/utils.js"),exports.Env=void 0,(e=exports.Env||(exports.Env={})).development="development",e.production="production",e.test="test";var O={exports:{}},C={},A={};let w=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}};A.CommanderError=w,A.InvalidArgumentError=class extends w{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:x}=A;C.Argument=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}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)?t.concat(e):[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=(e,t)=>{if(!this.argChoices.includes(e))throw new x(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},C.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"};var y={},E={};const{humanReadableArgName:k}=C;E.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){const t=e.commands.filter((e=>!e._hidden));if(e._hasImplicitHelpCommand()){const[,i,n]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),r=e.createCommand(i).helpOption(!1);r.description(e._helpCommandDescription),n&&r.arguments(n),t.push(r)}return this.sortSubcommands&&t.sort(((e,t)=>e.name().localeCompare(t.name()))),t}compareOptions(e,t){const i=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){const t=e.options.filter((e=>!e.hidden)),i=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),n=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(i||n){let r;r=i?n?e.createOption(e._helpFlags,e._helpDescription):e.createOption(e._helpShortFlag,e._helpDescription):e.createOption(e._helpLongFlag,e._helpDescription),t.push(r)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let i=e.parent;i;i=i.parent){const e=i.options.filter((e=>!e.hidden));t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach((t=>{t.description=t.description||e._argsDescription[t.name()]||""})),e.registeredArguments.find((e=>e.description))?e.registeredArguments:[]}subcommandTerm(e){const t=e.registeredArguments.map((e=>k(e))).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce(((e,i)=>Math.max(e,t.subcommandTerm(i).length)),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce(((e,i)=>Math.max(e,t.optionTerm(i).length)),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce(((e,i)=>Math.max(e,t.optionTerm(i).length)),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce(((e,i)=>Math.max(e,t.argumentTerm(i).length)),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let t=e.parent;t;t=t.parent)i=t.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`),void 0!==e.defaultValue){(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}return void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){const i=t.padWidth(e,t),n=t.helpWidth||80;function r(e,r){if(r){const s=`${e.padEnd(i+2)}${r}`;return t.wrap(s,n-2,i+2)}return e}function s(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${t.commandUsage(e)}`,""];const a=t.commandDescription(e);a.length>0&&(o=o.concat([t.wrap(a,n,0),""]));const l=t.visibleArguments(e).map((e=>r(t.argumentTerm(e),t.argumentDescription(e))));l.length>0&&(o=o.concat(["Arguments:",s(l),""]));const h=t.visibleOptions(e).map((e=>r(t.optionTerm(e),t.optionDescription(e))));if(h.length>0&&(o=o.concat(["Options:",s(h),""])),this.showGlobalOptions){const i=t.visibleGlobalOptions(e).map((e=>r(t.optionTerm(e),t.optionDescription(e))));i.length>0&&(o=o.concat(["Global Options:",s(i),""]))}const c=t.visibleCommands(e).map((e=>r(t.subcommandTerm(e),t.subcommandDescription(e))));return c.length>0&&(o=o.concat(["Commands:",s(c),""])),o.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){const r=new RegExp("[\\n][ \\f\\t\\v - \ufeff]+");if(e.match(r))return e;const s=t-i;if(s<n)return e;const o=e.slice(0,i),a=e.slice(i).replace("\r\n","\n"),l=" ".repeat(i),h="\\s",c=new RegExp(`\n|.{1,${s-1}}([${h}]|$)|[^${h}]+?([${h}]|$)`,"g");return o+(a.match(c)||[]).map(((e,t)=>"\n"===e?"":(t>0?l:"")+e.trimEnd())).join("\n")}};var $={};const{InvalidArgumentError:S}=A;function H(e){let t,i;const n=e.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(t=n.shift()),i=n.shift(),!t&&/^-[^-]$/.test(i)&&(t=i,i=void 0),{shortFlag:t,longFlag:i}}$.Option=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;const i=H(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return"string"==typeof e&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new S(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,t):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce(((e,t)=>e+t[0].toUpperCase()+t.slice(1)))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},$.splitOptionFlags=H,$.DualOptions=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach((e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)})),this.negativeOptions.forEach(((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)}))}valueFromOption(e,t){const i=t.attributeName();if(!this.dualOptions.has(i))return!0;const n=this.negativeOptions.get(i).presetArg,r=void 0!==n&&n;return t.negate===(r===e)}};var V={};const F=3;V.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const i=e.startsWith("--");i&&(e=e.slice(2),t=t.map((e=>e.slice(2))));let n=[],r=F;return t.forEach((t=>{if(t.length<=1)return;const i=function(e,t){if(Math.abs(e.length-t.length)>F)return Math.max(e.length,t.length);const i=[];for(let t=0;t<=e.length;t++)i[t]=[t];for(let e=0;e<=t.length;e++)i[0][e]=e;for(let n=1;n<=t.length;n++)for(let r=1;r<=e.length;r++){let s=1;s=e[r-1]===t[n-1]?0:1,i[r][n]=Math.min(i[r-1][n]+1,i[r][n-1]+1,i[r-1][n-1]+s),r>1&&n>1&&e[r-1]===t[n-2]&&e[r-2]===t[n-1]&&(i[r][n]=Math.min(i[r][n],i[r-2][n-2]+1))}return i[e.length][t.length]}(e,t),s=Math.max(e.length,t.length);(s-i)/s>.4&&(i<r?(r=i,n=[t]):i===r&&n.push(t))})),n.sort(((e,t)=>e.localeCompare(t))),i&&(n=n.map((e=>`--${e}`))),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""};const q=p.EventEmitter,P=m,D=s,N=t,j=d,{Argument:T,humanReadableArgName:M}=C,{CommanderError:I}=A,{Help:W}=E,{Option:L,splitOptionFlags:U,DualOptions:G}=$,{suggestSimilar:R}=V;function J(e,t){e._hasHelpOption&&t.find((t=>t===e._helpLongFlag||t===e._helpShortFlag))&&(e.outputHelp(),e._exit(0,"commander.helpDisplayed","(outputHelp)"))}function z(e){return e.map((e=>{if(!e.startsWith("--inspect"))return e;let t,i,n="127.0.0.1",r="9229";return null!==(i=e.match(/^(--inspect(-brk)?)$/))?t=i[1]:null!==(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):null!==(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=i[1],n=i[3],r=i[4]),t&&"0"!==r?`${t}=${n}:${parseInt(r)+1}`:e}))}y.Command=class e extends q{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:e=>j.stdout.write(e),writeErr:e=>j.stderr.write(e),getOutHelpWidth:()=>j.stdout.isTTY?j.stdout.columns:void 0,getErrHelpWidth:()=>j.stderr.isTTY?j.stderr.columns:void 0,outputError:(e,t)=>t(e)},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}_getCommandAndAncestors(){const e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let n=t,r=i;"object"==typeof n&&null!==n&&(r=n,n=null),r=r||{};const[,s,o]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return n&&(a.description(n),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!r.noHelp&&!r.hidden),a._executableFile=r.executableFile||null,o&&a.arguments(o),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(t){return new e(t)}createHelp(){return Object.assign(new W,this.configureHelp())}configureHelp(e){return void 0===e?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return void 0===e?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return"string"!=typeof e&&(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\n- specify the name in Command constructor or using .name()");return(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 T(e,t)}argument(e,t,i,n){const r=this.createArgument(e,t);return"function"==typeof i?r.default(n).argParser(i):r.default(i),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach((e=>{this.argument(e)})),this}addArgument(e){const t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&void 0!==e.defaultValue&&void 0===e.parseArg)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}addHelpCommand(e,t){return!1===e?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,"string"==typeof e&&(this._helpCommandName=e.split(" ")[0],this._helpCommandnameAndArgs=e),this._helpCommandDescription=t||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return void 0===this._addImplicitHelpCommand?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(e,t){const i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if("commander.executeSubCommandAsync"!==e.code)throw e}),this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new I(e,t,i)),j.exit(e)}action(e){return this._actionHandler=t=>{const i=this.registeredArguments.length,n=t.slice(0,i);return this._storeOptionsAsProperties?n[i]=this:n[i]=this.opts(),n.push(this),e.apply(this,n)},this}createOption(e,t){return new L(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(e){if("commander.invalidArgument"===e.code){const t=`${n} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}addOption(e){const t=e.name(),i=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(i,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(i,e.defaultValue,"default");this.options.push(e);const n=(t,n,r)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const s=this.getOptionValue(i);null!==t&&e.parseArg?t=this._callParseArg(e,t,s,n):null!==t&&e.variadic&&(t=e._concatValue(t,s)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(i,t,r)};return this.on("option:"+t,(t=>{const i=`error: option '${e.flags}' argument '${t}' is invalid.`;n(t,i,"cli")})),e.envVar&&this.on("optionEnv:"+t,(t=>{const i=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;n(t,i,"env")})),this}_optionEx(e,t,i,n,r){if("object"==typeof t&&t instanceof L)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const s=this.createOption(t,i);if(s.makeOptionMandatory(!!e.mandatory),"function"==typeof n)s.default(r).argParser(n);else if(n instanceof RegExp){const e=n;n=(t,i)=>{const n=e.exec(t);return n?n[0]:i},s.default(r).argParser(n)}else s.default(n);return this.addOption(s)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:!0},e,t,i,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){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.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach((i=>{void 0!==i.getOptionValueSource(e)&&(t=i.getOptionValueSource(e))})),t}_prepareUserArgs(e,t){if(void 0!==e&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");let i;switch(t=t||{},void 0===e&&(e=j.argv,j.versions&&j.versions.electron&&(t.from="electron")),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":j.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=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",i}parse(e,t){const i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){const i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_executeSubCommand(e,t){t=t.slice();let i=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function r(e,t){const i=D.resolve(e,t);if(N.existsSync(i))return i;if(n.includes(D.extname(t)))return;const r=n.find((e=>N.existsSync(`${i}${e}`)));return r?`${i}${r}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s,o=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let e;try{e=N.realpathSync(this._scriptPath)}catch(t){e=this._scriptPath}a=D.resolve(D.dirname(e),a)}if(a){let t=r(a,o);if(!t&&!e._executableFile&&this._scriptPath){const i=D.basename(this._scriptPath,D.extname(this._scriptPath));i!==this._name&&(t=r(a,`${i}-${e._name}`))}o=t||o}if(i=n.includes(D.extname(o)),"win32"!==j.platform?i?(t.unshift(o),t=z(j.execArgv).concat(t),s=P.spawn(j.argv[0],t,{stdio:"inherit"})):s=P.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=z(j.execArgv).concat(t),s=P.spawn(j.execPath,t,{stdio:"inherit"})),!s.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((e=>{j.on(e,(()=>{!1===s.killed&&null===s.exitCode&&s.kill(e)}))}))}const l=this._exitCallback;l?s.on("close",(()=>{l(new I(j.exitCode||0,"commander.executeSubCommandAsync","(close)"))})):s.on("close",j.exit.bind(j)),s.on("error",(t=>{if("ENOENT"===t.code){const t=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${o}' does not exist\n - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${t}`;throw new Error(i)}if("EACCES"===t.code)throw new Error(`'${o}' not executable`);if(l){const e=new I(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,l(e)}else j.exit(1)})),this.runningCommand=s}_dispatchSubcommand(e,t,i){const n=this._findCommand(e);let r;return n||this.help({error:!0}),r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,(()=>{if(!n._executableHandler)return n._parseCommand(t,i);this._executeSubCommand(n,t.concat(i))})),r}_dispatchHelpCommand(e){e||this.help();const t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._helpLongFlag||this._helpShortFlag])}_checkNumberOfArguments(){this.registeredArguments.forEach(((e,t)=>{e.required&&null==this.args[t]&&this.missingArgument(e.name())})),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const e=(e,t,i)=>{let n=t;if(null!==t&&e.parseArg){const r=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;n=this._callParseArg(e,t,i,r)}return n};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((i,n)=>{let r=i.defaultValue;i.variadic?n<this.args.length?(r=this.args.slice(n),i.parseArg&&(r=r.reduce(((t,n)=>e(i,n,t)),i.defaultValue))):void 0===r&&(r=[]):n<this.args.length&&(r=this.args[n],i.parseArg&&(r=e(i,r,i.defaultValue))),t[n]=r})),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&"function"==typeof e.then?e.then((()=>t())):t()}_chainOrCallHooks(e,t){let i=e;const n=[];return this._getCommandAndAncestors().reverse().filter((e=>void 0!==e._lifeCycleHooks[t])).forEach((e=>{e._lifeCycleHooks[t].forEach((t=>{n.push({hookedCommand:e,callback:t})}))})),"postAction"===t&&n.reverse(),n.forEach((e=>{i=this._chainOrCall(i,(()=>e.callback(e.hookedCommand,this)))})),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach((e=>{n=this._chainOrCall(n,(()=>e(this,t)))})),n}_parseCommand(e,t){const i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._hasImplicitHelpCommand()&&e[0]===this._helpCommandName)return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return J(this,t),this._dispatchSubcommand(this._defaultCommandName,e,t);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),J(this,i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){let i;return n(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs))),this.parent&&(i=this._chainOrCall(i,(()=>{this.parent.emit(r,e,t)}))),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(r))n(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find((t=>t._name===e||t._aliases.includes(e)))}_findOption(e){return this.options.find((t=>t.is(e)))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e=>{e.options.forEach((t=>{t.mandatory&&void 0===e.getOptionValue(t.attributeName())&&e.missingMandatoryOptionValue(t)}))}))}_checkForConflictingLocalOptions(){const e=this.options.filter((e=>{const t=e.attributeName();return void 0!==this.getOptionValue(t)&&"default"!==this.getOptionValueSource(t)})),t=e.filter((e=>e.conflictsWith.length>0));t.forEach((t=>{const i=e.find((e=>t.conflictsWith.includes(e.attributeName())));i&&this._conflictingOption(t,i)}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e=>{e._checkForConflictingLocalOptions()}))}parseOptions(e){const t=[],i=[];let n=t;const r=e.slice();function s(e){return e.length>1&&"-"===e[0]}let o=null;for(;r.length;){const e=r.shift();if("--"===e){n===i&&n.push(e),n.push(...r);break}if(!o||s(e)){if(o=null,s(e)){const t=this._findOption(e);if(t){if(t.required){const e=r.shift();void 0===e&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;r.length>0&&!s(r[0])&&(e=r.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(e.length>2&&"-"===e[0]&&"-"!==e[1]){const t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),r.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("="),i=this._findOption(e.slice(0,t));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,e.slice(t+1));continue}}if(s(e)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===i.length){if(this._findCommand(e)){t.push(e),r.length>0&&i.push(...r);break}if(e===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(e),r.length>0&&t.push(...r);break}if(this._defaultCommandName){i.push(e),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){n.push(e),r.length>0&&n.push(...r);break}n.push(e)}else this.emit(`option:${o.name()}`,e)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let i=0;i<t;i++){const t=this.options[i].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(((e,t)=>Object.assign(e,t.opts())),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach((e=>{if(e.envVar&&e.envVar in j.env){const t=e.attributeName();(void 0===this.getOptionValue(t)||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,j.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}}))}_parseOptionsImplied(){const e=new G(this.options),t=e=>void 0!==this.getOptionValue(e)&&!["default","implied"].includes(this.getOptionValueSource(e));this.options.filter((i=>void 0!==i.implied&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i))).forEach((e=>{Object.keys(e.implied).filter((e=>!t(e))).forEach((t=>{this.setOptionValueWithSource(t,e.implied[t],"implied")}))}))}missingArgument(e){const t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){const t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){const t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){const i=e=>{const t=e.attributeName(),i=this.getOptionValue(t),n=this.options.find((e=>e.negate&&t===e.attributeName())),r=this.options.find((e=>!e.negate&&t===e.attributeName()));return n&&(void 0===n.presetArg&&!1===i||void 0!==n.presetArg&&i===n.presetArg)?n:r||e},n=e=>{const t=i(e),n=t.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},r=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],n=this;do{const e=n.createHelp().visibleOptions(n).filter((e=>e.long)).map((e=>e.long));i=i.concat(e),n=n.parent}while(n&&!n._enablePositionalOptions);t=R(e,i)}const i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,i=1===t?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((e=>{i.push(e.name()),e.alias()&&i.push(e.alias())})),t=R(e,i)}const i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";const n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,"commander.version",e)})),this}description(e,t){return void 0===e&&void 0===t?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return void 0===e?this._summary:(this._summary=e,this)}alias(e){if(void 0===e)return this._aliases[0];let t=this;if(0!==this.commands.length&&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 void 0===e?this._aliases:(e.forEach((e=>this.alias(e))),this)}usage(e){if(void 0===e){if(this._usage)return this._usage;const e=this.registeredArguments.map((e=>M(e)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=e,this}name(e){return void 0===e?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=D.basename(e,D.extname(e)),this}executableDir(e){return void 0===e?this._executableDir:(this._executableDir=e,this)}helpInformation(e){const t=this.createHelp();return void 0===t.helpWidth&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){const t={error:!!(e=e||{}).error};let i;return i=t.error?e=>this._outputConfiguration.writeErr(e):e=>this._outputConfiguration.writeOut(e),t.write=e.write||i,t.command=this,t}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach((e=>e.emit("beforeAllHelp",i))),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),"string"!=typeof n&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._helpLongFlag&&this.emit(this._helpLongFlag),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach((e=>e.emit("afterAllHelp",i)))}helpOption(e,t){if("boolean"==typeof e)return this._hasHelpOption=e,this;this._helpFlags=e||this._helpFlags,this._helpDescription=t||this._helpDescription;const i=U(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(e){this.outputHelp(e);let t=j.exitCode||0;0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const n=`${e}Help`;return this.on(n,(e=>{let i;i="function"==typeof t?t({error:e.error,command:e.command}):t,i&&e.write(`${i}\n`)})),this}},function(e,t){const{Argument:i}=C,{Command:n}=y,{CommanderError:r,InvalidArgumentError:s}=A,{Help:o}=E,{Option:a}=$;(t=e.exports=new n).program=t,t.Command=n,t.Option=a,t.Argument=i,t.Help=o,t.CommanderError=r,t.InvalidArgumentError=s,t.InvalidOptionArgumentError=s}(O,O.exports);var B=O.exports,Y=c.getDefaultExportFromCjs(B);const{program:K,createCommand:Q,createArgument:X,createOption:Z,CommanderError:ee,InvalidArgumentError:te,InvalidOptionArgumentError:ie,Command:ne,Argument:re,Option:se,Help:oe}=Y,ae=new ne;ae.version("1.0.0","-v, --version","gant-core version"),ae.command("default",{isDefault:!0,noHelp:!0,hidden:!0}).action((()=>f())),ae.command("build").description("build cli").action((()=>f("build"))),ae.command("analyzer").description("bundle-analyzer").action((()=>f("analyzer"))),ae.command("i18n").arguments("[currentLanguage] [targetLanguage]").description("i18n translation").action(g.i18n),ae.command("create").description("创建项目").action((()=>u.createModule())),ae.command("mfa").arguments("[name]").action((e=>{v("development",e)})),ae.command("mfa-build").arguments("[name]").action((e=>{v("build",e)})),ae.command("mfa-analyzer").arguments("[name]").action((e=>{v("analyzer",e)}));(async()=>{try{ae.parse(process.argv)}catch(e){console.log("Start Error",g.color.red(e?.message))}})();
|
|
2
|
+
"use strict";var e,t=require("fs"),i=require("./config/index.js"),n=require("./webpack/Webpack.js"),r=require("chokidar"),s=require("path"),o=require("./utils/index.js"),a=require("./routes/index.js"),l=require("./tsconfig/index.js"),h=require("./copyfiles/index.js"),c=require("./create/config/index.js"),u=require("./create/module/index.js"),p=require("events"),m=require("child_process"),d=require("process"),g=require("./i18n/index.js");function f(e="development"){process.env.SRC="true",process.env.NODE_ENV=e;const c=process.cwd(),u=new i.Config({cwd:c});let p=u.getUserConfig();function m(r){const u=o.getSrcPath(),p=s.resolve(c,u,".gant");o.generateDir(p);const m=t.readFileSync(s.resolve(__dirname,"./template/core.txt"),"utf-8");o.writeFileToJS(s.resolve(p,"index.ts"),m);const d={[r?.name||"@@"]:c,...r?.resolve?.alias},g=[c];i.keys(r.packages).map((e=>{const t=r.packages[e];d[e]=t,g.push(t)})),l.generateTsConfig(p,{paths:d,includes:g,cwd:c,vue:r.vue});const f=[...i.keys(r.packages),c];h.copyAppsFiles(p,[...i.keys(r.packages),c]),h.copyPublicFiles(p,f.map((e=>s.resolve(e,"public")))),a.generateRoutes(s.resolve(p,"./routes"),r.routes);return new n.Webpack(r,c,e)}u.configFiles;let d=m(p);if("development"!==e)d.runBuild();else{d.runServer();let g=null;function f(e){g=r.watch(u.configFiles?.map((e=>s.dirname(e))),{}),g.on("change",(e=>{d.devServer.stop(),p=u.getUserConfig(),d=m(p),d.runServer({open:!1})}))}f()}}function _(){const e=process.cwd(),n=new i.Config({cwd:e});let r=n.getMsUserConfig();const a=o.getSrcPath(),h=s.resolve(e,a,".gant");t.existsSync(h)||t.mkdirSync(h,{recursive:!0});const c=t.readFileSync(s.resolve(__dirname,"./template/core.txt"),"utf-8");o.writeFileToJS(s.resolve(h,"index.ts"),c);const u=r?.name||"main",p={},m={...r?.resolve?.alias},d=[e];return r.mfa?.entry&&(p[u]={entry:r.mfa?.entry,publicPath:"string"==typeof r.mfa?.publicPath?[r.mfa?.publicPath]:r.mfa?.publicPath,port:r.mfa?.port,htmlTemplatePath:r.mfa.htmlTemplatePath,apps:[e],base:r.mfa.base,isMaster:!0}),r.mfa.pages?.map?.((e=>{const t="string"==typeof e.path?[e.path]:e.path,i="string"==typeof e.publicPath?[e.publicPath]:e.publicPath;d.push(...t),p[e.name]={entry:e.entry||r.mfa.subEntry,publicPath:i,port:e.port,htmlTemplatePath:e.htmlTemplatePath,apps:t,base:e.base,url:e.url}})),o.writeFileToJS(s.resolve(h,"appMaps.ts"),`export default ${JSON.stringify(p)}`),l.generateTsConfig(h,{includes:d,paths:m,cwd:e,vue:r.vue,createIncludes:!1}),{userConfig:r,msName:u,msConfig:p,configManager:n}}function v(e="development",t){process.env.SRC="false",process.env.NODE_ENV=e;const{userConfig:n,msName:r,msConfig:s,configManager:o}=_();if(i.isEmpty(n.mfa))return;const a=t||r,l=s[a];l&&b(o,e,n,a,l)}function b(e,l,u,p,m,d=!0){const g=process.cwd(),f=o.getSrcPath(),v=i.cloneDeep(u);const O=m.apps?.map?.((e=>i.Config.getMainConfigFile({cwd:e})))?.filter?.((e=>!!e));let C=function(){const r=s.resolve(g,f,`.gant/${p}`);o.generateDir(r),h.copyAppsFiles(r,m.apps),h.copyPublicFiles(r,m.publicPath);const u=t.readFileSync(s.resolve(__dirname,"./template/msentry.txt"),"utf-8"),d=c.ejs.compile(u);t.writeFileSync(s.resolve(r,"index.ts"),d({entry:s.join("../../",m.entry)}));const _=e.getMsPagesUserConfig(m.apps);return a.generateRoutes(s.resolve(r,"./routes"),_.routes),v.entry={index:s.resolve(r,"index.ts")},v.base=i.get(m,"base","/"),v.define={...v.define,APP_NAME:p},v.devServer={...v.devServer,port:m.port,static:{directory:s.resolve(r,"public")}},v.output={...v.output,chunkLoadingGlobal:`webpackJsonp_${p}`,chunkFilename:`${p}.[name].[id].[contenthash].js`,path:s.resolve(g,`dist/${p}`)},v.outputPathDir=s.resolve(g,`dist/${p}`),v.publicPathDir=s.resolve(g,`.gant/${p}/public`),new n.Webpack(v,g,l)}();if("development"!==l)C.runBuild();else{C.runServer({open:d});let A=null;function w(t){A=r.watch(t),A.on("change",(t=>{C.devServer.stop();const{userConfig:i,msConfig:n}=_();A.close(),b(e,l,i,p,n[p],!1)}))}w(O)}}require("./config/defineConfig.js"),require("./utils/getJavascriptfile.js"),require("module"),require("webpack"),require("webpack-dev-server"),require("./webpack/config/index.js"),require("./webpack/config/production.config.js"),require("./webpack/plugins/copy.js"),require("mini-css-extract-plugin"),require("css-minimizer-webpack-plugin"),require("terser-webpack-plugin"),require("compression-webpack-plugin"),require("./webpack/config/default.config.js"),require("html-webpack-plugin"),require("./webpack/config/cssRules.js"),require("./webpack/config/development.config.js"),require("./webpack/config/analyzer.config.js"),require("url"),require("os"),require("tty"),require("fs/promises"),require("assert"),require("v8"),require("util"),require("readline"),require("stream"),require("buffer"),require("string_decoder"),require("crypto"),require("node:process"),require("node:os"),require("node:tty"),require("node:assert"),require("node:readline"),require("http"),require("https"),require("net"),require("./i18n/utils.js"),require("zlib"),exports.Env=void 0,(e=exports.Env||(exports.Env={})).development="development",e.production="production",e.test="test";var O={exports:{}},C={},A={};let w=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}};A.CommanderError=w,A.InvalidArgumentError=class extends w{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:x}=A;C.Argument=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}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)?t.concat(e):[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=(e,t)=>{if(!this.argChoices.includes(e))throw new x(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},C.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"};var y={},E={};const{humanReadableArgName:k}=C;E.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){const t=e.commands.filter((e=>!e._hidden));if(e._hasImplicitHelpCommand()){const[,i,n]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),r=e.createCommand(i).helpOption(!1);r.description(e._helpCommandDescription),n&&r.arguments(n),t.push(r)}return this.sortSubcommands&&t.sort(((e,t)=>e.name().localeCompare(t.name()))),t}compareOptions(e,t){const i=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){const t=e.options.filter((e=>!e.hidden)),i=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),n=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(i||n){let r;r=i?n?e.createOption(e._helpFlags,e._helpDescription):e.createOption(e._helpShortFlag,e._helpDescription):e.createOption(e._helpLongFlag,e._helpDescription),t.push(r)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let i=e.parent;i;i=i.parent){const e=i.options.filter((e=>!e.hidden));t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach((t=>{t.description=t.description||e._argsDescription[t.name()]||""})),e.registeredArguments.find((e=>e.description))?e.registeredArguments:[]}subcommandTerm(e){const t=e.registeredArguments.map((e=>k(e))).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce(((e,i)=>Math.max(e,t.subcommandTerm(i).length)),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce(((e,i)=>Math.max(e,t.optionTerm(i).length)),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce(((e,i)=>Math.max(e,t.optionTerm(i).length)),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce(((e,i)=>Math.max(e,t.argumentTerm(i).length)),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let t=e.parent;t;t=t.parent)i=t.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`),void 0!==e.defaultValue){(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}return void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){const i=t.padWidth(e,t),n=t.helpWidth||80;function r(e,r){if(r){const s=`${e.padEnd(i+2)}${r}`;return t.wrap(s,n-2,i+2)}return e}function s(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${t.commandUsage(e)}`,""];const a=t.commandDescription(e);a.length>0&&(o=o.concat([t.wrap(a,n,0),""]));const l=t.visibleArguments(e).map((e=>r(t.argumentTerm(e),t.argumentDescription(e))));l.length>0&&(o=o.concat(["Arguments:",s(l),""]));const h=t.visibleOptions(e).map((e=>r(t.optionTerm(e),t.optionDescription(e))));if(h.length>0&&(o=o.concat(["Options:",s(h),""])),this.showGlobalOptions){const i=t.visibleGlobalOptions(e).map((e=>r(t.optionTerm(e),t.optionDescription(e))));i.length>0&&(o=o.concat(["Global Options:",s(i),""]))}const c=t.visibleCommands(e).map((e=>r(t.subcommandTerm(e),t.subcommandDescription(e))));return c.length>0&&(o=o.concat(["Commands:",s(c),""])),o.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){const r=new RegExp("[\\n][ \\f\\t\\v - \ufeff]+");if(e.match(r))return e;const s=t-i;if(s<n)return e;const o=e.slice(0,i),a=e.slice(i).replace("\r\n","\n"),l=" ".repeat(i),h="\\s",c=new RegExp(`\n|.{1,${s-1}}([${h}]|$)|[^${h}]+?([${h}]|$)`,"g");return o+(a.match(c)||[]).map(((e,t)=>"\n"===e?"":(t>0?l:"")+e.trimEnd())).join("\n")}};var $={};const{InvalidArgumentError:S}=A;function H(e){let t,i;const n=e.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(t=n.shift()),i=n.shift(),!t&&/^-[^-]$/.test(i)&&(t=i,i=void 0),{shortFlag:t,longFlag:i}}$.Option=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;const i=H(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return"string"==typeof e&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new S(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,t):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce(((e,t)=>e+t[0].toUpperCase()+t.slice(1)))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},$.splitOptionFlags=H,$.DualOptions=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach((e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)})),this.negativeOptions.forEach(((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)}))}valueFromOption(e,t){const i=t.attributeName();if(!this.dualOptions.has(i))return!0;const n=this.negativeOptions.get(i).presetArg,r=void 0!==n&&n;return t.negate===(r===e)}};var V={};const F=3;V.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const i=e.startsWith("--");i&&(e=e.slice(2),t=t.map((e=>e.slice(2))));let n=[],r=F;return t.forEach((t=>{if(t.length<=1)return;const i=function(e,t){if(Math.abs(e.length-t.length)>F)return Math.max(e.length,t.length);const i=[];for(let t=0;t<=e.length;t++)i[t]=[t];for(let e=0;e<=t.length;e++)i[0][e]=e;for(let n=1;n<=t.length;n++)for(let r=1;r<=e.length;r++){let s=1;s=e[r-1]===t[n-1]?0:1,i[r][n]=Math.min(i[r-1][n]+1,i[r][n-1]+1,i[r-1][n-1]+s),r>1&&n>1&&e[r-1]===t[n-2]&&e[r-2]===t[n-1]&&(i[r][n]=Math.min(i[r][n],i[r-2][n-2]+1))}return i[e.length][t.length]}(e,t),s=Math.max(e.length,t.length);(s-i)/s>.4&&(i<r?(r=i,n=[t]):i===r&&n.push(t))})),n.sort(((e,t)=>e.localeCompare(t))),i&&(n=n.map((e=>`--${e}`))),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""};const q=p.EventEmitter,P=m,D=s,N=t,j=d,{Argument:T,humanReadableArgName:M}=C,{CommanderError:I}=A,{Help:W}=E,{Option:L,splitOptionFlags:U,DualOptions:G}=$,{suggestSimilar:R}=V;function J(e,t){e._hasHelpOption&&t.find((t=>t===e._helpLongFlag||t===e._helpShortFlag))&&(e.outputHelp(),e._exit(0,"commander.helpDisplayed","(outputHelp)"))}function z(e){return e.map((e=>{if(!e.startsWith("--inspect"))return e;let t,i,n="127.0.0.1",r="9229";return null!==(i=e.match(/^(--inspect(-brk)?)$/))?t=i[1]:null!==(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):null!==(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=i[1],n=i[3],r=i[4]),t&&"0"!==r?`${t}=${n}:${parseInt(r)+1}`:e}))}y.Command=class e extends q{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:e=>j.stdout.write(e),writeErr:e=>j.stderr.write(e),getOutHelpWidth:()=>j.stdout.isTTY?j.stdout.columns:void 0,getErrHelpWidth:()=>j.stderr.isTTY?j.stderr.columns:void 0,outputError:(e,t)=>t(e)},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}_getCommandAndAncestors(){const e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let n=t,r=i;"object"==typeof n&&null!==n&&(r=n,n=null),r=r||{};const[,s,o]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return n&&(a.description(n),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!r.noHelp&&!r.hidden),a._executableFile=r.executableFile||null,o&&a.arguments(o),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(t){return new e(t)}createHelp(){return Object.assign(new W,this.configureHelp())}configureHelp(e){return void 0===e?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return void 0===e?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return"string"!=typeof e&&(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\n- specify the name in Command constructor or using .name()");return(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 T(e,t)}argument(e,t,i,n){const r=this.createArgument(e,t);return"function"==typeof i?r.default(n).argParser(i):r.default(i),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach((e=>{this.argument(e)})),this}addArgument(e){const t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&void 0!==e.defaultValue&&void 0===e.parseArg)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}addHelpCommand(e,t){return!1===e?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,"string"==typeof e&&(this._helpCommandName=e.split(" ")[0],this._helpCommandnameAndArgs=e),this._helpCommandDescription=t||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return void 0===this._addImplicitHelpCommand?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(e,t){const i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if("commander.executeSubCommandAsync"!==e.code)throw e}),this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new I(e,t,i)),j.exit(e)}action(e){return this._actionHandler=t=>{const i=this.registeredArguments.length,n=t.slice(0,i);return this._storeOptionsAsProperties?n[i]=this:n[i]=this.opts(),n.push(this),e.apply(this,n)},this}createOption(e,t){return new L(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(e){if("commander.invalidArgument"===e.code){const t=`${n} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}addOption(e){const t=e.name(),i=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(i,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(i,e.defaultValue,"default");this.options.push(e);const n=(t,n,r)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const s=this.getOptionValue(i);null!==t&&e.parseArg?t=this._callParseArg(e,t,s,n):null!==t&&e.variadic&&(t=e._concatValue(t,s)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(i,t,r)};return this.on("option:"+t,(t=>{const i=`error: option '${e.flags}' argument '${t}' is invalid.`;n(t,i,"cli")})),e.envVar&&this.on("optionEnv:"+t,(t=>{const i=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;n(t,i,"env")})),this}_optionEx(e,t,i,n,r){if("object"==typeof t&&t instanceof L)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const s=this.createOption(t,i);if(s.makeOptionMandatory(!!e.mandatory),"function"==typeof n)s.default(r).argParser(n);else if(n instanceof RegExp){const e=n;n=(t,i)=>{const n=e.exec(t);return n?n[0]:i},s.default(r).argParser(n)}else s.default(n);return this.addOption(s)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:!0},e,t,i,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){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.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach((i=>{void 0!==i.getOptionValueSource(e)&&(t=i.getOptionValueSource(e))})),t}_prepareUserArgs(e,t){if(void 0!==e&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");let i;switch(t=t||{},void 0===e&&(e=j.argv,j.versions&&j.versions.electron&&(t.from="electron")),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":j.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=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",i}parse(e,t){const i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){const i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_executeSubCommand(e,t){t=t.slice();let i=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function r(e,t){const i=D.resolve(e,t);if(N.existsSync(i))return i;if(n.includes(D.extname(t)))return;const r=n.find((e=>N.existsSync(`${i}${e}`)));return r?`${i}${r}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s,o=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let e;try{e=N.realpathSync(this._scriptPath)}catch(t){e=this._scriptPath}a=D.resolve(D.dirname(e),a)}if(a){let t=r(a,o);if(!t&&!e._executableFile&&this._scriptPath){const i=D.basename(this._scriptPath,D.extname(this._scriptPath));i!==this._name&&(t=r(a,`${i}-${e._name}`))}o=t||o}if(i=n.includes(D.extname(o)),"win32"!==j.platform?i?(t.unshift(o),t=z(j.execArgv).concat(t),s=P.spawn(j.argv[0],t,{stdio:"inherit"})):s=P.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=z(j.execArgv).concat(t),s=P.spawn(j.execPath,t,{stdio:"inherit"})),!s.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((e=>{j.on(e,(()=>{!1===s.killed&&null===s.exitCode&&s.kill(e)}))}))}const l=this._exitCallback;l?s.on("close",(()=>{l(new I(j.exitCode||0,"commander.executeSubCommandAsync","(close)"))})):s.on("close",j.exit.bind(j)),s.on("error",(t=>{if("ENOENT"===t.code){const t=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${o}' does not exist\n - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${t}`;throw new Error(i)}if("EACCES"===t.code)throw new Error(`'${o}' not executable`);if(l){const e=new I(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,l(e)}else j.exit(1)})),this.runningCommand=s}_dispatchSubcommand(e,t,i){const n=this._findCommand(e);let r;return n||this.help({error:!0}),r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,(()=>{if(!n._executableHandler)return n._parseCommand(t,i);this._executeSubCommand(n,t.concat(i))})),r}_dispatchHelpCommand(e){e||this.help();const t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._helpLongFlag||this._helpShortFlag])}_checkNumberOfArguments(){this.registeredArguments.forEach(((e,t)=>{e.required&&null==this.args[t]&&this.missingArgument(e.name())})),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const e=(e,t,i)=>{let n=t;if(null!==t&&e.parseArg){const r=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;n=this._callParseArg(e,t,i,r)}return n};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((i,n)=>{let r=i.defaultValue;i.variadic?n<this.args.length?(r=this.args.slice(n),i.parseArg&&(r=r.reduce(((t,n)=>e(i,n,t)),i.defaultValue))):void 0===r&&(r=[]):n<this.args.length&&(r=this.args[n],i.parseArg&&(r=e(i,r,i.defaultValue))),t[n]=r})),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&"function"==typeof e.then?e.then((()=>t())):t()}_chainOrCallHooks(e,t){let i=e;const n=[];return this._getCommandAndAncestors().reverse().filter((e=>void 0!==e._lifeCycleHooks[t])).forEach((e=>{e._lifeCycleHooks[t].forEach((t=>{n.push({hookedCommand:e,callback:t})}))})),"postAction"===t&&n.reverse(),n.forEach((e=>{i=this._chainOrCall(i,(()=>e.callback(e.hookedCommand,this)))})),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach((e=>{n=this._chainOrCall(n,(()=>e(this,t)))})),n}_parseCommand(e,t){const i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._hasImplicitHelpCommand()&&e[0]===this._helpCommandName)return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return J(this,t),this._dispatchSubcommand(this._defaultCommandName,e,t);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),J(this,i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){let i;return n(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs))),this.parent&&(i=this._chainOrCall(i,(()=>{this.parent.emit(r,e,t)}))),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(r))n(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find((t=>t._name===e||t._aliases.includes(e)))}_findOption(e){return this.options.find((t=>t.is(e)))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e=>{e.options.forEach((t=>{t.mandatory&&void 0===e.getOptionValue(t.attributeName())&&e.missingMandatoryOptionValue(t)}))}))}_checkForConflictingLocalOptions(){const e=this.options.filter((e=>{const t=e.attributeName();return void 0!==this.getOptionValue(t)&&"default"!==this.getOptionValueSource(t)})),t=e.filter((e=>e.conflictsWith.length>0));t.forEach((t=>{const i=e.find((e=>t.conflictsWith.includes(e.attributeName())));i&&this._conflictingOption(t,i)}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e=>{e._checkForConflictingLocalOptions()}))}parseOptions(e){const t=[],i=[];let n=t;const r=e.slice();function s(e){return e.length>1&&"-"===e[0]}let o=null;for(;r.length;){const e=r.shift();if("--"===e){n===i&&n.push(e),n.push(...r);break}if(!o||s(e)){if(o=null,s(e)){const t=this._findOption(e);if(t){if(t.required){const e=r.shift();void 0===e&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;r.length>0&&!s(r[0])&&(e=r.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(e.length>2&&"-"===e[0]&&"-"!==e[1]){const t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),r.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("="),i=this._findOption(e.slice(0,t));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,e.slice(t+1));continue}}if(s(e)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===i.length){if(this._findCommand(e)){t.push(e),r.length>0&&i.push(...r);break}if(e===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(e),r.length>0&&t.push(...r);break}if(this._defaultCommandName){i.push(e),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){n.push(e),r.length>0&&n.push(...r);break}n.push(e)}else this.emit(`option:${o.name()}`,e)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let i=0;i<t;i++){const t=this.options[i].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(((e,t)=>Object.assign(e,t.opts())),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach((e=>{if(e.envVar&&e.envVar in j.env){const t=e.attributeName();(void 0===this.getOptionValue(t)||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,j.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}}))}_parseOptionsImplied(){const e=new G(this.options),t=e=>void 0!==this.getOptionValue(e)&&!["default","implied"].includes(this.getOptionValueSource(e));this.options.filter((i=>void 0!==i.implied&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i))).forEach((e=>{Object.keys(e.implied).filter((e=>!t(e))).forEach((t=>{this.setOptionValueWithSource(t,e.implied[t],"implied")}))}))}missingArgument(e){const t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){const t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){const t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){const i=e=>{const t=e.attributeName(),i=this.getOptionValue(t),n=this.options.find((e=>e.negate&&t===e.attributeName())),r=this.options.find((e=>!e.negate&&t===e.attributeName()));return n&&(void 0===n.presetArg&&!1===i||void 0!==n.presetArg&&i===n.presetArg)?n:r||e},n=e=>{const t=i(e),n=t.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},r=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],n=this;do{const e=n.createHelp().visibleOptions(n).filter((e=>e.long)).map((e=>e.long));i=i.concat(e),n=n.parent}while(n&&!n._enablePositionalOptions);t=R(e,i)}const i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,i=1===t?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((e=>{i.push(e.name()),e.alias()&&i.push(e.alias())})),t=R(e,i)}const i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";const n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,"commander.version",e)})),this}description(e,t){return void 0===e&&void 0===t?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return void 0===e?this._summary:(this._summary=e,this)}alias(e){if(void 0===e)return this._aliases[0];let t=this;if(0!==this.commands.length&&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 void 0===e?this._aliases:(e.forEach((e=>this.alias(e))),this)}usage(e){if(void 0===e){if(this._usage)return this._usage;const e=this.registeredArguments.map((e=>M(e)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=e,this}name(e){return void 0===e?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=D.basename(e,D.extname(e)),this}executableDir(e){return void 0===e?this._executableDir:(this._executableDir=e,this)}helpInformation(e){const t=this.createHelp();return void 0===t.helpWidth&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){const t={error:!!(e=e||{}).error};let i;return i=t.error?e=>this._outputConfiguration.writeErr(e):e=>this._outputConfiguration.writeOut(e),t.write=e.write||i,t.command=this,t}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach((e=>e.emit("beforeAllHelp",i))),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),"string"!=typeof n&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._helpLongFlag&&this.emit(this._helpLongFlag),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach((e=>e.emit("afterAllHelp",i)))}helpOption(e,t){if("boolean"==typeof e)return this._hasHelpOption=e,this;this._helpFlags=e||this._helpFlags,this._helpDescription=t||this._helpDescription;const i=U(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(e){this.outputHelp(e);let t=j.exitCode||0;0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const n=`${e}Help`;return this.on(n,(e=>{let i;i="function"==typeof t?t({error:e.error,command:e.command}):t,i&&e.write(`${i}\n`)})),this}},function(e,t){const{Argument:i}=C,{Command:n}=y,{CommanderError:r,InvalidArgumentError:s}=A,{Help:o}=E,{Option:a}=$;(t=e.exports=new n).program=t,t.Command=n,t.Option=a,t.Argument=i,t.Help=o,t.CommanderError=r,t.InvalidArgumentError=s,t.InvalidOptionArgumentError=s}(O,O.exports);var B=O.exports,Y=c.getDefaultExportFromCjs(B);const{program:K,createCommand:Q,createArgument:X,createOption:Z,CommanderError:ee,InvalidArgumentError:te,InvalidOptionArgumentError:ie,Command:ne,Argument:re,Option:se,Help:oe}=Y,ae=new ne;ae.version("1.0.0","-v, --version","gant-core version"),ae.command("default",{isDefault:!0,noHelp:!0,hidden:!0}).action((()=>f())),ae.command("build").description("build cli").action((()=>f("build"))),ae.command("analyzer").description("bundle-analyzer").action((()=>f("analyzer"))),ae.command("i18n").arguments("[currentLanguage] [targetLanguage]").description("i18n translation").action(g.i18n),ae.command("create").description("创建项目").action((()=>u.createModule())),ae.command("mfa").arguments("[name]").action((e=>{v("development",e)})),ae.command("mfa-build").arguments("[name]").action((e=>{v("build",e)})),ae.command("mfa-analyzer").arguments("[name]").action((e=>{v("analyzer",e)}));(async()=>{try{ae.parse(process.argv)}catch(e){console.log("Start Error",g.color.red(e?.message))}})();
|