gant-core 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{C as t}from"./config/index.mjs";import{W as e}from"./webpack/Webpack.mjs";import i from"chokidar";import n,{resolve as s}from"path";import{g as r,j as o,w as a,s as h,d as l,t as p,a as c}from"./utils/index.mjs";import{g as m}from"./routes/index.mjs";import{g as u}from"./tsconfig/index.mjs";import{c as d,a as g}from"./copyfiles/index.mjs";import{r as f}from"./webpack/config/framework/index.mjs";import _ from"fs";import{fileURLToPath as v}from"node:url";import{e as b}from"./create/config/index.mjs";import{c as O}from"./create/module/index.mjs";import{g as A,a as C}from"./utils/detectPort.mjs";import w from"events";import y from"child_process";import x from"process";import{i as E}from"./i18n/index.mjs";import"./utils/getJavascriptfile.mjs";import"jiti";import"@rspack/core";import"@rspack/dev-server";import"./webpack/config/index.mjs";import"./webpack/config/production.config.mjs";import"./webpack/plugins/copy.mjs";import"compression-webpack-plugin";import"./webpack/config/default.config.mjs";import"module";import"./webpack/config/cssRules.mjs";import"./webpack/config/browsers.mjs";import"./webpack/config/development.config.mjs";import"./webpack/config/analyzer.config.mjs";import"prettier";import"net";import"./webpack/config/framework/react.mjs";import"@rspack/plugin-react-refresh";import"./webpack/config/framework/vue.mjs";import"node:tty";import"tty";import"readline";import"os";import"assert";import"stream";import"buffer";import"util";import"string_decoder";import"node:process";import"node:assert";import"node:path";import"node:os";import"node:crypto";import"node:stream";import"node:readline";import"http";import"https";import"url";import"crypto";import"./i18n/utils.mjs";import"http2";import"zlib";var k;async function $(l="development"){process.env.SRC="true",process.env.NODE_ENV=l;const p=process.cwd(),c=new t({cwd:p});let _=c.getUserConfig();function v(t){const i=r(),n=s(p,i,".gant");o(n),a(s(n,"setting.ts"),`export default ${JSON.stringify(t.setting||{})}`),a(s(n,"microServiceMap.ts"),`export default ${JSON.stringify(t.microServiceMap||{})}`);const c={[t?.name||"@@"]:p,...t?.resolve?.alias},_=[p];h(t.packages).map(e=>{const i=t.packages[e];c[e]=i,_.push(i)}),u(n,{paths:c,includes:_,cwd:p,framework:f(t)});const v=[...Object.keys(t.packages).map(e=>t.packages[e]),p];d(n,v),g(n,v.map(t=>s(t,"public"))),m(s(n,"./routes"),t.routes);return new e(t,p,l)}c.configFiles;let b=v(_);if("development"===l){await b.runServer();let O=null;function A(t){const e=[...Object.keys(_.packages).map(t=>_.packages[t]),p].map(t=>s(t,"public")),r=c.configFiles?.map(t=>n.dirname(t))||[],o=[...new Set([...r,...e])];O=i.watch(o,{}),O.on("change",async t=>{O?.close(),await(b.devServer?.stop()),_=c.getUserConfig(),b=v(_),await b.runServer({open:!1}),A()})}return void A()}b.runBuild()}!function(t){t.development="development",t.production="production",t.test="test"}(k||(k={}));const S=n.dirname(v(import.meta.url));function H(){const e=process.cwd(),i=new t({cwd:e});let n=i.getMsUserConfig();const o=r(),h=s(e,o,".gant");_.existsSync(h)||_.mkdirSync(h,{recursive:!0}),a(s(h,"setting.ts"),`export default ${JSON.stringify(n.setting||{})}`),a(s(h,"microServiceMap.ts"),`export default ${JSON.stringify(n.microServiceMap||{})}`);const l=n?.name||"main",p={},c={...n?.resolve?.alias},m=[e];return n.mfa?.entry&&(p[l]={entry:n.mfa?.entry,publicPath:"string"==typeof n.mfa?.publicPath?[n.mfa?.publicPath]:n.mfa?.publicPath,port:n.mfa?.port,htmlTemplatePath:n.mfa.htmlTemplatePath,apps:[e],base:n.mfa.base,isMaster:!0}),n.mfa.pages?.map?.(t=>{const e="string"==typeof t.path?[t.path]:t.path,i="string"==typeof t.publicPath?[t.publicPath]:t.publicPath;m.push(...e),p[t.name]={entry:t.entry||n.mfa.subEntry,publicPath:i,port:t.port,htmlTemplatePath:t.htmlTemplatePath,apps:e,base:t.base,url:t.url}}),a(s(h,"appMaps.ts"),`export default ${JSON.stringify(p)}`),u(h,{includes:m,paths:c,cwd:e,framework:f(n),createIncludes:!1}),{userConfig:n,msName:l,msConfig:p,configManager:i}}async function V(t="development",e){process.env.SRC="false",process.env.NODE_ENV=t;const{userConfig:i,msName:n,msConfig:s,configManager:r}=H();if(l(i.mfa))return;const o=e||n,a=s[o];a&&await F(r,t,i,o,a)}async function F(a,h,l,u,f,v=!0){const O=process.cwd(),A=r(),C=p(l);const w=f.apps?.map?.(e=>t.getMainConfigFile({cwd:e}))?.filter?.(t=>!!t);let y=function(){const t=s(O,A,`.gant/${u}`);o(t),d(t,f.apps),g(t,f.publicPath);const i=_.readFileSync(s(S,"./template/msentry.txt"),"utf-8"),r=b.compile(i);_.writeFileSync(s(t,"index.ts"),r({entry:n.join("../../",f.entry)}));const l=a.getMsPagesUserConfig(f.apps);return m(s(t,"./routes"),l.routes),C.entry={index:s(t,"index.ts")},C.base=c(f,"base","/"),C.define={...C.define,APP_NAME:u},C.devServer={...C.devServer,port:f.port,static:{directory:s(t,"public")}},C.output={...C.output,chunkLoadingGlobal:`webpackJsonp_${u}`,chunkFilename:`${u}.[name].[id].[contenthash].js`,path:s(O,`dist/${u}`)},C.outputPathDir=s(O,`dist/${u}`),C.publicPathDir=s(O,`.gant/${u}/public`),new e(C,O,h)}();if("development"===h){await y.runServer({open:v});let x=null;function E(t){const e=(f.publicPath||[]).filter(Boolean),n=[...new Set([...t,...e])];x=i.watch(n),x.on("change",async t=>{await(y.devServer?.stop());const{userConfig:e,msConfig:i}=H();x.close(),await F(a,h,e,u,i[u],!1)})}return void E(w)}y.runBuild()}var P={exports:{}},N={},j={};let D=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}};j.CommanderError=D,j.InvalidArgumentError=class extends D{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:T}=j;N.Argument=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new T(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},N.humanReadableArgName=function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"};var M={},I={};const{humanReadableArgName:W}=N;I.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(t){const e=t.commands.filter(t=>!t._hidden);if(t._hasImplicitHelpCommand()){const[,i,n]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),s=t.createCommand(i).helpOption(!1);s.description(t._helpCommandDescription),n&&s.arguments(n),e.push(s)}return this.sortSubcommands&&e.sort((t,e)=>t.name().localeCompare(e.name())),e}compareOptions(t,e){const i=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){const e=t.options.filter(t=>!t.hidden),i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag),n=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||n){let s;s=i?n?t.createOption(t._helpFlags,t._helpDescription):t.createOption(t._helpShortFlag,t._helpDescription):t.createOption(t._helpLongFlag,t._helpDescription),e.push(s)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let i=t.parent;i;i=i.parent){const t=i.options.filter(t=>!t.hidden);e.push(...t)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(t=>t.description)?t.registeredArguments:[]}subcommandTerm(t){const e=t.registeredArguments.map(t=>W(t)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((t,i)=>Math.max(t,e.subcommandTerm(i).length),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((t,i)=>Math.max(t,e.optionTerm(i).length),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((t,i)=>Math.max(t,e.optionTerm(i).length),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((t,i)=>Math.max(t,e.argumentTerm(i).length),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let e=t.parent;e;e=e.parent)i=e.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue){(t.required||t.optional||t.isBoolean()&&"boolean"==typeof t.defaultValue)&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}return void 0!==t.presetArg&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),void 0!==t.envVar&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){const i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){const i=e.padWidth(t,e),n=e.helpWidth||80;function s(t,s){if(s){const r=`${t.padEnd(i+2)}${s}`;return e.wrap(r,n-2,i+2)}return t}function r(t){return t.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${e.commandUsage(t)}`,""];const a=e.commandDescription(t);a.length>0&&(o=o.concat([e.wrap(a,n,0),""]));const h=e.visibleArguments(t).map(t=>s(e.argumentTerm(t),e.argumentDescription(t)));h.length>0&&(o=o.concat(["Arguments:",r(h),""]));const l=e.visibleOptions(t).map(t=>s(e.optionTerm(t),e.optionDescription(t)));if(l.length>0&&(o=o.concat(["Options:",r(l),""])),this.showGlobalOptions){const i=e.visibleGlobalOptions(t).map(t=>s(e.optionTerm(t),e.optionDescription(t)));i.length>0&&(o=o.concat(["Global Options:",r(i),""]))}const p=e.visibleCommands(t).map(t=>s(e.subcommandTerm(t),e.subcommandDescription(t)));return p.length>0&&(o=o.concat(["Commands:",r(p),""])),o.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,n=40){const s=new RegExp("[\\n][ \\f\\t\\v   -    \ufeff]+");if(t.match(s))return t;const r=e-i;if(r<n)return t;const o=t.slice(0,i),a=t.slice(i).replace("\r\n","\n"),h=" ".repeat(i),l="\\s​",p=new RegExp(`\n|.{1,${r-1}}([${l}]|$)|[^${l}]+?([${l}]|$)`,"g");return o+(a.match(p)||[]).map((t,e)=>"\n"===t?"":(e>0?h:"")+t.trimEnd()).join("\n")}};var L={};const{InvalidArgumentError:q}=j;function U(t){let e,i;const n=t.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(e=n.shift()),i=n.shift(),!e&&/^-[^-]$/.test(i)&&(e=i,i=void 0),{shortFlag:e,longFlag:i}}L.Option=class{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;const i=U(t);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(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return"string"==typeof t&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new q(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},L.splitOptionFlags=U,L.DualOptions=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,e)=>{this.positiveOptions.has(e)&&this.dualOptions.add(e)})}valueFromOption(t,e){const i=e.attributeName();if(!this.dualOptions.has(i))return!0;const n=this.negativeOptions.get(i).presetArg,s=void 0!==n&&n;return e.negate===(s===t)}};var G={};G.suggestSimilar=function(t,e){if(!e||0===e.length)return"";e=Array.from(new Set(e));const i=t.startsWith("--");i&&(t=t.slice(2),e=e.map(t=>t.slice(2)));let n=[],s=3;return e.forEach(e=>{if(e.length<=1)return;const i=function(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);const i=[];for(let e=0;e<=t.length;e++)i[e]=[e];for(let t=0;t<=e.length;t++)i[0][t]=t;for(let n=1;n<=e.length;n++)for(let s=1;s<=t.length;s++){let r=1;r=t[s-1]===e[n-1]?0:1,i[s][n]=Math.min(i[s-1][n]+1,i[s][n-1]+1,i[s-1][n-1]+r),s>1&&n>1&&t[s-1]===e[n-2]&&t[s-2]===e[n-1]&&(i[s][n]=Math.min(i[s][n],i[s-2][n-2]+1))}return i[t.length][e.length]}(t,e),r=Math.max(t.length,e.length);(r-i)/r>.4&&(i<s?(s=i,n=[e]):i===s&&n.push(e))}),n.sort((t,e)=>t.localeCompare(e)),i&&(n=n.map(t=>`--${t}`)),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""};const R=w.EventEmitter,J=y,B=n,z=_,Y=x,{Argument:K,humanReadableArgName:Q}=N,{CommanderError:X}=j,{Help:Z}=I,{Option:tt,splitOptionFlags:et,DualOptions:it}=L,{suggestSimilar:nt}=G;function st(t,e){t._hasHelpOption&&e.find(e=>e===t._helpLongFlag||e===t._helpShortFlag)&&(t.outputHelp(),t._exit(0,"commander.helpDisplayed","(outputHelp)"))}function rt(t){return t.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i,n="127.0.0.1",s="9229";return null!==(i=t.match(/^(--inspect(-brk)?)$/))?e=i[1]:null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(e=i[1],/^\d+$/.test(i[3])?s=i[3]:n=i[3]):null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=i[1],n=i[3],s=i[4]),e&&"0"!==s?`${e}=${n}:${parseInt(s)+1}`:t})}M.Command=class t extends R{constructor(t){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=t||"",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=>Y.stdout.write(t),writeErr:t=>Y.stderr.write(t),getOutHelpWidth:()=>Y.stdout.isTTY?Y.stdout.columns:void 0,getErrHelpWidth:()=>Y.stderr.isTTY?Y.stderr.columns:void 0,outputError:(t,e)=>e(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(t){return this._outputConfiguration=t._outputConfiguration,this._hasHelpOption=t._hasHelpOption,this._helpFlags=t._helpFlags,this._helpDescription=t._helpDescription,this._helpShortFlag=t._helpShortFlag,this._helpLongFlag=t._helpLongFlag,this._helpCommandName=t._helpCommandName,this._helpCommandnameAndArgs=t._helpCommandnameAndArgs,this._helpCommandDescription=t._helpCommandDescription,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){const t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let n=e,s=i;"object"==typeof n&&null!==n&&(s=n,n=null),s=s||{};const[,r,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(r);return n&&(a.description(n),a._executableHandler=!0),s.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!s.noHelp&&!s.hidden),a._executableFile=s.executableFile||null,o&&a.arguments(o),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(e){return new t(e)}createHelp(){return Object.assign(new Z,this.configureHelp())}configureHelp(t){return void 0===t?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return void 0===t?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return"string"!=typeof t&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this.commands.push(t),t.parent=this,this}createArgument(t,e){return new K(t,e)}argument(t,e,i,n){const s=this.createArgument(t,e);return"function"==typeof i?s.default(n).argParser(i):s.default(i),this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){const e=this.registeredArguments.slice(-1)[0];if(e&&e.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&void 0!==t.defaultValue&&void 0===t.parseArg)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}addHelpCommand(t,e){return!1===t?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,"string"==typeof t&&(this._helpCommandName=t.split(" ")[0],this._helpCommandnameAndArgs=t),this._helpCommandDescription=e||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return void 0===this._addImplicitHelpCommand?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(t,e){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return this._exitCallback=t||(t=>{if("commander.executeSubCommandAsync"!==t.code)throw t}),this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new X(t,e,i)),Y.exit(t)}action(t){return this._actionHandler=e=>{const i=this.registeredArguments.length,n=e.slice(0,i);return this._storeOptionsAsProperties?n[i]=this:n[i]=this.opts(),n.push(this),t.apply(this,n)},this}createOption(t,e){return new tt(t,e)}_callParseArg(t,e,i,n){try{return t.parseArg(e,i)}catch(t){if("commander.invalidArgument"===t.code){const e=`${n} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}addOption(t){const e=t.name(),i=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");this._findOption(e)||this.setOptionValueWithSource(i,void 0===t.defaultValue||t.defaultValue,"default")}else void 0!==t.defaultValue&&this.setOptionValueWithSource(i,t.defaultValue,"default");this.options.push(t);const n=(e,n,s)=>{null==e&&void 0!==t.presetArg&&(e=t.presetArg);const r=this.getOptionValue(i);null!==e&&t.parseArg?e=this._callParseArg(t,e,r,n):null!==e&&t.variadic&&(e=t._concatValue(e,r)),null==e&&(e=!t.negate&&(!(!t.isBoolean()&&!t.optional)||"")),this.setOptionValueWithSource(i,e,s)};return this.on("option:"+e,e=>{const i=`error: option '${t.flags}' argument '${e}' is invalid.`;n(e,i,"cli")}),t.envVar&&this.on("optionEnv:"+e,e=>{const i=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;n(e,i,"env")}),this}_optionEx(t,e,i,n,s){if("object"==typeof e&&e instanceof tt)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const r=this.createOption(e,i);if(r.makeOptionMandatory(!!t.mandatory),"function"==typeof n)r.default(s).argParser(n);else if(n instanceof RegExp){const t=n;n=(e,i)=>{const n=t.exec(e);return n?n[0]:i},r.default(s).argParser(n)}else r.default(n);return this.addOption(r)}option(t,e,i,n){return this._optionEx({},t,e,i,n)}requiredOption(t,e,i,n){return this._optionEx({mandatory:!0},t,e,i,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){if(this._passThroughOptions=!!t,this.parent&&t&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,i){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(i=>{void 0!==i.getOptionValueSource(t)&&(e=i.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");let i;switch(e=e||{},void 0===t&&(t=Y.argv,Y.versions&&Y.versions.electron&&(e.from="electron")),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":Y.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,e){const i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){const i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),this}_executeSubCommand(t,e){e=e.slice();let i=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function s(t,e){const i=B.resolve(t,e);if(z.existsSync(i))return i;if(n.includes(B.extname(e)))return;const s=n.find(t=>z.existsSync(`${i}${t}`));return s?`${i}${s}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r,o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let t;try{t=z.realpathSync(this._scriptPath)}catch(e){t=this._scriptPath}a=B.resolve(B.dirname(t),a)}if(a){let e=s(a,o);if(!e&&!t._executableFile&&this._scriptPath){const i=B.basename(this._scriptPath,B.extname(this._scriptPath));i!==this._name&&(e=s(a,`${i}-${t._name}`))}o=e||o}if(i=n.includes(B.extname(o)),"win32"!==Y.platform?i?(e.unshift(o),e=rt(Y.execArgv).concat(e),r=J.spawn(Y.argv[0],e,{stdio:"inherit"})):r=J.spawn(o,e,{stdio:"inherit"}):(e.unshift(o),e=rt(Y.execArgv).concat(e),r=J.spawn(Y.execPath,e,{stdio:"inherit"})),!r.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{Y.on(t,()=>{!1===r.killed&&null===r.exitCode&&r.kill(t)})})}const h=this._exitCallback;h?r.on("close",()=>{h(new X(Y.exitCode||0,"commander.executeSubCommandAsync","(close)"))}):r.on("close",Y.exit.bind(Y)),r.on("error",e=>{if("ENOENT"===e.code){const e=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 '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${e}`;throw new Error(i)}if("EACCES"===e.code)throw new Error(`'${o}' not executable`);if(h){const t=new X(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,h(t)}else Y.exit(1)}),this.runningCommand=r}_dispatchSubcommand(t,e,i){const n=this._findCommand(t);let s;return n||this.help({error:!0}),s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(!n._executableHandler)return n._parseCommand(e,i);this._executeSubCommand(n,e.concat(i))}),s}_dispatchHelpCommand(t){t||this.help();const e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._helpLongFlag||this._helpShortFlag])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const t=(t,e,i)=>{let n=e;if(null!==e&&t.parseArg){const s=`error: command-argument value '${e}' is invalid for argument '${t.name()}'.`;n=this._callParseArg(t,e,i,s)}return n};this._checkNumberOfArguments();const e=[];this.registeredArguments.forEach((i,n)=>{let s=i.defaultValue;i.variadic?n<this.args.length?(s=this.args.slice(n),i.parseArg&&(s=s.reduce((e,n)=>t(i,n,e),i.defaultValue))):void 0===s&&(s=[]):n<this.args.length&&(s=this.args[n],i.parseArg&&(s=t(i,s,i.defaultValue))),e[n]=s}),this.processedArgs=e}_chainOrCall(t,e){return t&&t.then&&"function"==typeof t.then?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let i=t;const n=[];return this._getCommandAndAncestors().reverse().filter(t=>void 0!==t._lifeCycleHooks[e]).forEach(t=>{t._lifeCycleHooks[e].forEach(e=>{n.push({hookedCommand:t,callback:e})})}),"postAction"===e&&n.reverse(),n.forEach(t=>{i=this._chainOrCall(i,()=>t.callback(t.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,e,i){let n=t;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach(t=>{n=this._chainOrCall(n,()=>t(this,e))}),n}_parseCommand(t,e){const i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName)return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return st(this,e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),st(this,i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},s=`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(s,t,e)})),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&void 0===t.getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){const t=this.options.filter(t=>{const e=t.attributeName();return void 0!==this.getOptionValue(e)&&"default"!==this.getOptionValueSource(e)}),e=t.filter(t=>t.conflictsWith.length>0);e.forEach(e=>{const i=t.find(t=>e.conflictsWith.includes(t.attributeName()));i&&this._conflictingOption(e,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){const e=[],i=[];let n=e;const s=t.slice();function r(t){return t.length>1&&"-"===t[0]}let o=null;for(;s.length;){const t=s.shift();if("--"===t){n===i&&n.push(t),n.push(...s);break}if(!o||r(t)){if(o=null,r(t)){const e=this._findOption(t);if(e){if(e.required){const t=s.shift();void 0===t&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;s.length>0&&!r(s[0])&&(t=s.shift()),this.emit(`option:${e.name()}`,t)}else this.emit(`option:${e.name()}`);o=e.variadic?e:null;continue}}if(t.length>2&&"-"===t[0]&&"-"!==t[1]){const e=this._findOption(`-${t[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,t.slice(2)):(this.emit(`option:${e.name()}`),s.unshift(`-${t.slice(2)}`));continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("="),i=this._findOption(t.slice(0,e));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(e+1));continue}}if(r(t)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===i.length){if(this._findCommand(t)){e.push(t),s.length>0&&i.push(...s);break}if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){e.push(t),s.length>0&&e.push(...s);break}if(this._defaultCommandName){i.push(t),s.length>0&&i.push(...s);break}}if(this._passThroughOptions){n.push(t),s.length>0&&n.push(...s);break}n.push(t)}else this.emit(`option:${o.name()}`,t)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let i=0;i<e;i++){const e=this.options[i].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}\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=e||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in Y.env){const e=t.attributeName();(void 0===this.getOptionValue(e)||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,Y.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){const t=new it(this.options),e=t=>void 0!==this.getOptionValue(t)&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter(i=>void 0!==i.implied&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(t=>{Object.keys(t.implied).filter(t=>!e(t)).forEach(e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")})})}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const i=t=>{const e=t.attributeName(),i=this.getOptionValue(e),n=this.options.find(t=>t.negate&&e===t.attributeName()),s=this.options.find(t=>!t.negate&&e===t.attributeName());return n&&(void 0===n.presetArg&&!1===i||void 0!==n.presetArg&&i===n.presetArg)?n:s||t},n=t=>{const e=i(t),n=e.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${e.envVar}'`:`option '${e.flags}'`},s=`error: ${n(t)} cannot be used with ${n(e)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[],n=this;do{const t=n.createHelp().visibleOptions(n).filter(t=>t.long).map(t=>t.long);i=i.concat(t),n=n.parent}while(n&&!n._enablePositionalOptions);e=nt(t,i)}const i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this.registeredArguments.length,i=1===e?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach(t=>{i.push(t.name()),t.alias()&&i.push(t.alias())}),e=nt(t,i)}const i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(void 0===t)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";const n=this.createOption(e,i);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}\n`),this._exit(0,"commander.version",t)}),this}description(t,e){return void 0===t&&void 0===e?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return void 0===t?this._summary:(this._summary=t,this)}alias(t){if(void 0===t)return this._aliases[0];let e=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");return e._aliases.push(t),this}aliases(t){return void 0===t?this._aliases:(t.forEach(t=>this.alias(t)),this)}usage(t){if(void 0===t){if(this._usage)return this._usage;const t=this.registeredArguments.map(t=>Q(t));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=B.basename(t,B.extname(t)),this}executableDir(t){return void 0===t?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const e=this.createHelp();return void 0===e.helpWidth&&(e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),e.formatHelp(this,e)}_getHelpContext(t){const e={error:!!(t=t||{}).error};let i;return i=e.error?t=>this._outputConfiguration.writeErr(t):t=>this._outputConfiguration.writeOut(t),e.write=t.write||i,e.command=this,e}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const i=this._getHelpContext(t);this._getCommandAndAncestors().reverse().forEach(t=>t.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(e&&(n=e(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(t=>t.emit("afterAllHelp",i))}helpOption(t,e){if("boolean"==typeof t)return this._hasHelpOption=t,this;this._helpFlags=t||this._helpFlags,this._helpDescription=e||this._helpDescription;const i=et(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(t){this.outputHelp(t);let e=Y.exitCode||0;0===e&&t&&"function"!=typeof t&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const n=`${t}Help`;return this.on(n,t=>{let i;i="function"==typeof e?e({error:t.error,command:t.command}):e,i&&t.write(`${i}\n`)}),this}},function(t,e){const{Argument:i}=N,{Command:n}=M,{CommanderError:s,InvalidArgumentError:r}=j,{Help:o}=I,{Option:a}=L;(e=t.exports=new n).program=e,e.Command=n,e.Option=a,e.Argument=i,e.Help=o,e.CommanderError=s,e.InvalidArgumentError=r,e.InvalidOptionArgumentError=r}(P,P.exports);var ot=A(P.exports);const{program:at,createCommand:ht,createArgument:lt,createOption:pt,CommanderError:ct,InvalidArgumentError:mt,InvalidOptionArgumentError:ut,Command:dt,Argument:gt,Option:ft,Help:_t}=ot,vt=new dt;vt.version("1.0.0","-v, --version","gant-core version"),vt.command("default",{isDefault:!0,noHelp:!0,hidden:!0}).action(()=>$()),vt.command("build").description("build cli").action(()=>$("build")),vt.command("analyzer").description("bundle-analyzer").action(()=>$("analyzer")),vt.command("i18n").arguments("[currentLanguage] [targetLanguage]").description("i18n translation").action(E),vt.command("create").description("创建项目").action(()=>O()),vt.command("mfa").arguments("[name]").action(t=>{V("development",t)}),vt.command("mfa-build").arguments("[name]").action(t=>{V("build",t)}),vt.command("mfa-analyzer").arguments("[name]").action(t=>{V("analyzer",t)});(async()=>{try{vt.parse(process.argv)}catch(t){console.log("Start Error",C.red(t?.message))}})();export{k as Env};
2
+ import{C as t}from"./config/index.mjs";import{W as e}from"./webpack/Webpack.mjs";import i from"chokidar";import n,{resolve as s}from"path";import{g as r,j as o,w as a,s as h,d as l,t as p,a as c}from"./utils/index.mjs";import{g as m}from"./routes/index.mjs";import{g as u}from"./tsconfig/index.mjs";import{c as d,a as g}from"./copyfiles/index.mjs";import{r as f}from"./webpack/config/framework/index.mjs";import _ from"fs";import{fileURLToPath as v}from"node:url";import{e as b}from"./create/config/index.mjs";import{c as O}from"./create/module/index.mjs";import{g as A,a as C}from"./utils/detectPort.mjs";import w from"events";import y from"child_process";import x from"process";import{i as E}from"./i18n/index.mjs";import"./utils/getJavascriptfile.mjs";import"jiti";import"@rspack/core";import"@rspack/dev-server";import"./webpack/config/index.mjs";import"./webpack/config/production.config.mjs";import"./webpack/plugins/copy.mjs";import"compression-webpack-plugin";import"./webpack/config/default.config.mjs";import"module";import"./webpack/config/cssRules.mjs";import"./webpack/config/browsers.mjs";import"./webpack/config/development.config.mjs";import"./webpack/config/analyzer.config.mjs";import"prettier";import"net";import"./webpack/config/framework/react.mjs";import"@rspack/plugin-react-refresh";import"./webpack/config/framework/vue.mjs";import"node:tty";import"tty";import"readline";import"os";import"assert";import"stream";import"buffer";import"util";import"string_decoder";import"node:process";import"node:assert";import"node:path";import"node:os";import"node:crypto";import"node:stream";import"node:readline";import"http";import"https";import"url";import"crypto";import"./i18n/utils.mjs";import"http2";import"zlib";var k;async function $(l="development"){process.env.SRC="true",process.env.NODE_ENV=l;const p=process.cwd(),c=new t({cwd:p});let _=c.getUserConfig();function v(t){const i=r(),n=s(p,i,".gant");o(n),a(s(n,"setting.ts"),`export default ${JSON.stringify(t.setting||{})}`),a(s(n,"microServiceMap.ts"),`export default ${JSON.stringify(t.microServiceMap||{})}`);const c={[t?.name||"@@"]:p,...t?.resolve?.alias},_=[p];h(t.packages).map(e=>{const i=t.packages[e];c[e]=i,_.push(i)}),u(n,{paths:c,includes:_,cwd:p,framework:f(t)});const v=[...Object.keys(t.packages).map(e=>t.packages[e]),p];d(n,v),g(n,v.map(t=>s(t,"public"))),m(s(n,"./routes"),t.routes);return new e(t,p,l)}c.configFiles;let b=v(_);if("development"===l){await b.runServer();let O=null;function A(t){const e=[...Object.keys(_.packages).map(t=>_.packages[t]),p].map(t=>s(t,"public")),r=c.configFiles?.map(t=>n.dirname(t))||[],o=[...new Set([...r,...e])];O=i.watch(o,{}),O.on("change",async t=>{O?.close(),await(b.devServer?.stop()),_=c.getUserConfig(),b=v(_),await b.runServer({open:!1}),A()})}return void A()}b.runBuild()}!function(t){t.development="development",t.production="production",t.test="test"}(k||(k={}));const S=n.dirname(v(import.meta.url));function H(){const e=process.cwd(),i=new t({cwd:e});let n=i.getMsUserConfig();const o=r(),h=s(e,o,".gant");_.existsSync(h)||_.mkdirSync(h,{recursive:!0}),a(s(h,"setting.ts"),`export default ${JSON.stringify(n.setting||{})}`),a(s(h,"microServiceMap.ts"),`export default ${JSON.stringify(n.microServiceMap||{})}`);const l=n?.name||"main",p={},c={...n?.resolve?.alias},m=[e];return n.mfa?.entry&&(p[l]={entry:n.mfa?.entry,publicPath:"string"==typeof n.mfa?.publicPath?[n.mfa?.publicPath]:n.mfa?.publicPath,port:n.mfa?.port,htmlTemplatePath:n.mfa.htmlTemplatePath,apps:[e],base:n.mfa.base,isMaster:!0}),n.mfa.pages?.map?.(t=>{const e="string"==typeof t.path?[t.path]:t.path,i="string"==typeof t.publicPath?[t.publicPath]:t.publicPath;m.push(...e),p[t.name]={entry:t.entry||n.mfa.subEntry,publicPath:i,port:t.port,htmlTemplatePath:t.htmlTemplatePath,apps:e,base:t.base,url:t.url}}),a(s(h,"appMaps.ts"),`export default ${JSON.stringify(p)}`),u(h,{includes:m,paths:c,cwd:e,framework:f(n),createIncludes:!1}),{userConfig:n,msName:l,msConfig:p,configManager:i}}async function V(t="development",e){process.env.SRC="false",process.env.NODE_ENV=t;const{userConfig:i,msName:n,msConfig:s,configManager:r}=H();if(l(i.mfa))return;const o=e||n,a=s[o];a&&await F(r,t,i,o,a)}async function F(a,h,l,u,f,v=!0){const O=process.cwd(),A=r(),C=p(l);const w=f.apps?.map?.(e=>t.getMainConfigFile({cwd:e}))?.filter?.(t=>!!t);let y=function(){const t=s(O,A,`.gant/${u}`);o(t),d(t,f.apps),g(t,f.publicPath);const i=_.readFileSync(s(S,"./template/msentry.txt"),"utf-8"),r=b.compile(i);_.writeFileSync(s(t,"index.ts"),r({entry:n.posix.join("../../",f.entry)}));const l=a.getMsPagesUserConfig(f.apps);return m(s(t,"./routes"),l.routes),C.entry={index:s(t,"index.ts")},C.base=c(f,"base","/"),C.define={...C.define,APP_NAME:u},C.devServer={...C.devServer,port:f.port,static:{directory:s(t,"public")}},C.output={...C.output,chunkLoadingGlobal:`webpackJsonp_${u}`,chunkFilename:`${u}.[name].[id].[contenthash].js`,path:s(O,`dist/${u}`)},C.outputPathDir=s(O,`dist/${u}`),C.publicPathDir=s(O,`.gant/${u}/public`),new e(C,O,h)}();if("development"===h){await y.runServer({open:v});let x=null;function E(t){const e=(f.publicPath||[]).filter(Boolean),n=[...new Set([...t,...e])];x=i.watch(n),x.on("change",async t=>{await(y.devServer?.stop());const{userConfig:e,msConfig:i}=H();x.close(),await F(a,h,e,u,i[u],!1)})}return void E(w)}y.runBuild()}var P={exports:{}},N={},j={};let D=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}};j.CommanderError=D,j.InvalidArgumentError=class extends D{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:T}=j;N.Argument=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new T(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},N.humanReadableArgName=function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"};var M={},I={};const{humanReadableArgName:W}=N;I.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(t){const e=t.commands.filter(t=>!t._hidden);if(t._hasImplicitHelpCommand()){const[,i,n]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),s=t.createCommand(i).helpOption(!1);s.description(t._helpCommandDescription),n&&s.arguments(n),e.push(s)}return this.sortSubcommands&&e.sort((t,e)=>t.name().localeCompare(e.name())),e}compareOptions(t,e){const i=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){const e=t.options.filter(t=>!t.hidden),i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag),n=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||n){let s;s=i?n?t.createOption(t._helpFlags,t._helpDescription):t.createOption(t._helpShortFlag,t._helpDescription):t.createOption(t._helpLongFlag,t._helpDescription),e.push(s)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let i=t.parent;i;i=i.parent){const t=i.options.filter(t=>!t.hidden);e.push(...t)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(t=>t.description)?t.registeredArguments:[]}subcommandTerm(t){const e=t.registeredArguments.map(t=>W(t)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((t,i)=>Math.max(t,e.subcommandTerm(i).length),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((t,i)=>Math.max(t,e.optionTerm(i).length),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((t,i)=>Math.max(t,e.optionTerm(i).length),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((t,i)=>Math.max(t,e.argumentTerm(i).length),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let e=t.parent;e;e=e.parent)i=e.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue){(t.required||t.optional||t.isBoolean()&&"boolean"==typeof t.defaultValue)&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}return void 0!==t.presetArg&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),void 0!==t.envVar&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){const i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){const i=e.padWidth(t,e),n=e.helpWidth||80;function s(t,s){if(s){const r=`${t.padEnd(i+2)}${s}`;return e.wrap(r,n-2,i+2)}return t}function r(t){return t.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${e.commandUsage(t)}`,""];const a=e.commandDescription(t);a.length>0&&(o=o.concat([e.wrap(a,n,0),""]));const h=e.visibleArguments(t).map(t=>s(e.argumentTerm(t),e.argumentDescription(t)));h.length>0&&(o=o.concat(["Arguments:",r(h),""]));const l=e.visibleOptions(t).map(t=>s(e.optionTerm(t),e.optionDescription(t)));if(l.length>0&&(o=o.concat(["Options:",r(l),""])),this.showGlobalOptions){const i=e.visibleGlobalOptions(t).map(t=>s(e.optionTerm(t),e.optionDescription(t)));i.length>0&&(o=o.concat(["Global Options:",r(i),""]))}const p=e.visibleCommands(t).map(t=>s(e.subcommandTerm(t),e.subcommandDescription(t)));return p.length>0&&(o=o.concat(["Commands:",r(p),""])),o.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,n=40){const s=new RegExp("[\\n][ \\f\\t\\v   -    \ufeff]+");if(t.match(s))return t;const r=e-i;if(r<n)return t;const o=t.slice(0,i),a=t.slice(i).replace("\r\n","\n"),h=" ".repeat(i),l="\\s​",p=new RegExp(`\n|.{1,${r-1}}([${l}]|$)|[^${l}]+?([${l}]|$)`,"g");return o+(a.match(p)||[]).map((t,e)=>"\n"===t?"":(e>0?h:"")+t.trimEnd()).join("\n")}};var L={};const{InvalidArgumentError:q}=j;function U(t){let e,i;const n=t.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(e=n.shift()),i=n.shift(),!e&&/^-[^-]$/.test(i)&&(e=i,i=void 0),{shortFlag:e,longFlag:i}}L.Option=class{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;const i=U(t);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(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return"string"==typeof t&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new q(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},L.splitOptionFlags=U,L.DualOptions=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,e)=>{this.positiveOptions.has(e)&&this.dualOptions.add(e)})}valueFromOption(t,e){const i=e.attributeName();if(!this.dualOptions.has(i))return!0;const n=this.negativeOptions.get(i).presetArg,s=void 0!==n&&n;return e.negate===(s===t)}};var G={};G.suggestSimilar=function(t,e){if(!e||0===e.length)return"";e=Array.from(new Set(e));const i=t.startsWith("--");i&&(t=t.slice(2),e=e.map(t=>t.slice(2)));let n=[],s=3;return e.forEach(e=>{if(e.length<=1)return;const i=function(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);const i=[];for(let e=0;e<=t.length;e++)i[e]=[e];for(let t=0;t<=e.length;t++)i[0][t]=t;for(let n=1;n<=e.length;n++)for(let s=1;s<=t.length;s++){let r=1;r=t[s-1]===e[n-1]?0:1,i[s][n]=Math.min(i[s-1][n]+1,i[s][n-1]+1,i[s-1][n-1]+r),s>1&&n>1&&t[s-1]===e[n-2]&&t[s-2]===e[n-1]&&(i[s][n]=Math.min(i[s][n],i[s-2][n-2]+1))}return i[t.length][e.length]}(t,e),r=Math.max(t.length,e.length);(r-i)/r>.4&&(i<s?(s=i,n=[e]):i===s&&n.push(e))}),n.sort((t,e)=>t.localeCompare(e)),i&&(n=n.map(t=>`--${t}`)),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""};const R=w.EventEmitter,J=y,B=n,z=_,Y=x,{Argument:K,humanReadableArgName:Q}=N,{CommanderError:X}=j,{Help:Z}=I,{Option:tt,splitOptionFlags:et,DualOptions:it}=L,{suggestSimilar:nt}=G;function st(t,e){t._hasHelpOption&&e.find(e=>e===t._helpLongFlag||e===t._helpShortFlag)&&(t.outputHelp(),t._exit(0,"commander.helpDisplayed","(outputHelp)"))}function rt(t){return t.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i,n="127.0.0.1",s="9229";return null!==(i=t.match(/^(--inspect(-brk)?)$/))?e=i[1]:null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(e=i[1],/^\d+$/.test(i[3])?s=i[3]:n=i[3]):null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=i[1],n=i[3],s=i[4]),e&&"0"!==s?`${e}=${n}:${parseInt(s)+1}`:t})}M.Command=class t extends R{constructor(t){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=t||"",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=>Y.stdout.write(t),writeErr:t=>Y.stderr.write(t),getOutHelpWidth:()=>Y.stdout.isTTY?Y.stdout.columns:void 0,getErrHelpWidth:()=>Y.stderr.isTTY?Y.stderr.columns:void 0,outputError:(t,e)=>e(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(t){return this._outputConfiguration=t._outputConfiguration,this._hasHelpOption=t._hasHelpOption,this._helpFlags=t._helpFlags,this._helpDescription=t._helpDescription,this._helpShortFlag=t._helpShortFlag,this._helpLongFlag=t._helpLongFlag,this._helpCommandName=t._helpCommandName,this._helpCommandnameAndArgs=t._helpCommandnameAndArgs,this._helpCommandDescription=t._helpCommandDescription,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){const t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let n=e,s=i;"object"==typeof n&&null!==n&&(s=n,n=null),s=s||{};const[,r,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(r);return n&&(a.description(n),a._executableHandler=!0),s.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!s.noHelp&&!s.hidden),a._executableFile=s.executableFile||null,o&&a.arguments(o),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(e){return new t(e)}createHelp(){return Object.assign(new Z,this.configureHelp())}configureHelp(t){return void 0===t?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return void 0===t?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return"string"!=typeof t&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this.commands.push(t),t.parent=this,this}createArgument(t,e){return new K(t,e)}argument(t,e,i,n){const s=this.createArgument(t,e);return"function"==typeof i?s.default(n).argParser(i):s.default(i),this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){const e=this.registeredArguments.slice(-1)[0];if(e&&e.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&void 0!==t.defaultValue&&void 0===t.parseArg)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}addHelpCommand(t,e){return!1===t?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,"string"==typeof t&&(this._helpCommandName=t.split(" ")[0],this._helpCommandnameAndArgs=t),this._helpCommandDescription=e||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return void 0===this._addImplicitHelpCommand?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(t,e){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return this._exitCallback=t||(t=>{if("commander.executeSubCommandAsync"!==t.code)throw t}),this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new X(t,e,i)),Y.exit(t)}action(t){return this._actionHandler=e=>{const i=this.registeredArguments.length,n=e.slice(0,i);return this._storeOptionsAsProperties?n[i]=this:n[i]=this.opts(),n.push(this),t.apply(this,n)},this}createOption(t,e){return new tt(t,e)}_callParseArg(t,e,i,n){try{return t.parseArg(e,i)}catch(t){if("commander.invalidArgument"===t.code){const e=`${n} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}addOption(t){const e=t.name(),i=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");this._findOption(e)||this.setOptionValueWithSource(i,void 0===t.defaultValue||t.defaultValue,"default")}else void 0!==t.defaultValue&&this.setOptionValueWithSource(i,t.defaultValue,"default");this.options.push(t);const n=(e,n,s)=>{null==e&&void 0!==t.presetArg&&(e=t.presetArg);const r=this.getOptionValue(i);null!==e&&t.parseArg?e=this._callParseArg(t,e,r,n):null!==e&&t.variadic&&(e=t._concatValue(e,r)),null==e&&(e=!t.negate&&(!(!t.isBoolean()&&!t.optional)||"")),this.setOptionValueWithSource(i,e,s)};return this.on("option:"+e,e=>{const i=`error: option '${t.flags}' argument '${e}' is invalid.`;n(e,i,"cli")}),t.envVar&&this.on("optionEnv:"+e,e=>{const i=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;n(e,i,"env")}),this}_optionEx(t,e,i,n,s){if("object"==typeof e&&e instanceof tt)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const r=this.createOption(e,i);if(r.makeOptionMandatory(!!t.mandatory),"function"==typeof n)r.default(s).argParser(n);else if(n instanceof RegExp){const t=n;n=(e,i)=>{const n=t.exec(e);return n?n[0]:i},r.default(s).argParser(n)}else r.default(n);return this.addOption(r)}option(t,e,i,n){return this._optionEx({},t,e,i,n)}requiredOption(t,e,i,n){return this._optionEx({mandatory:!0},t,e,i,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){if(this._passThroughOptions=!!t,this.parent&&t&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,i){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(i=>{void 0!==i.getOptionValueSource(t)&&(e=i.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");let i;switch(e=e||{},void 0===t&&(t=Y.argv,Y.versions&&Y.versions.electron&&(e.from="electron")),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":Y.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,e){const i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){const i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),this}_executeSubCommand(t,e){e=e.slice();let i=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function s(t,e){const i=B.resolve(t,e);if(z.existsSync(i))return i;if(n.includes(B.extname(e)))return;const s=n.find(t=>z.existsSync(`${i}${t}`));return s?`${i}${s}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r,o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let t;try{t=z.realpathSync(this._scriptPath)}catch(e){t=this._scriptPath}a=B.resolve(B.dirname(t),a)}if(a){let e=s(a,o);if(!e&&!t._executableFile&&this._scriptPath){const i=B.basename(this._scriptPath,B.extname(this._scriptPath));i!==this._name&&(e=s(a,`${i}-${t._name}`))}o=e||o}if(i=n.includes(B.extname(o)),"win32"!==Y.platform?i?(e.unshift(o),e=rt(Y.execArgv).concat(e),r=J.spawn(Y.argv[0],e,{stdio:"inherit"})):r=J.spawn(o,e,{stdio:"inherit"}):(e.unshift(o),e=rt(Y.execArgv).concat(e),r=J.spawn(Y.execPath,e,{stdio:"inherit"})),!r.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{Y.on(t,()=>{!1===r.killed&&null===r.exitCode&&r.kill(t)})})}const h=this._exitCallback;h?r.on("close",()=>{h(new X(Y.exitCode||0,"commander.executeSubCommandAsync","(close)"))}):r.on("close",Y.exit.bind(Y)),r.on("error",e=>{if("ENOENT"===e.code){const e=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 '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${e}`;throw new Error(i)}if("EACCES"===e.code)throw new Error(`'${o}' not executable`);if(h){const t=new X(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,h(t)}else Y.exit(1)}),this.runningCommand=r}_dispatchSubcommand(t,e,i){const n=this._findCommand(t);let s;return n||this.help({error:!0}),s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(!n._executableHandler)return n._parseCommand(e,i);this._executeSubCommand(n,e.concat(i))}),s}_dispatchHelpCommand(t){t||this.help();const e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._helpLongFlag||this._helpShortFlag])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const t=(t,e,i)=>{let n=e;if(null!==e&&t.parseArg){const s=`error: command-argument value '${e}' is invalid for argument '${t.name()}'.`;n=this._callParseArg(t,e,i,s)}return n};this._checkNumberOfArguments();const e=[];this.registeredArguments.forEach((i,n)=>{let s=i.defaultValue;i.variadic?n<this.args.length?(s=this.args.slice(n),i.parseArg&&(s=s.reduce((e,n)=>t(i,n,e),i.defaultValue))):void 0===s&&(s=[]):n<this.args.length&&(s=this.args[n],i.parseArg&&(s=t(i,s,i.defaultValue))),e[n]=s}),this.processedArgs=e}_chainOrCall(t,e){return t&&t.then&&"function"==typeof t.then?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let i=t;const n=[];return this._getCommandAndAncestors().reverse().filter(t=>void 0!==t._lifeCycleHooks[e]).forEach(t=>{t._lifeCycleHooks[e].forEach(e=>{n.push({hookedCommand:t,callback:e})})}),"postAction"===e&&n.reverse(),n.forEach(t=>{i=this._chainOrCall(i,()=>t.callback(t.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,e,i){let n=t;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach(t=>{n=this._chainOrCall(n,()=>t(this,e))}),n}_parseCommand(t,e){const i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName)return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return st(this,e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),st(this,i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},s=`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(s,t,e)})),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&void 0===t.getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){const t=this.options.filter(t=>{const e=t.attributeName();return void 0!==this.getOptionValue(e)&&"default"!==this.getOptionValueSource(e)}),e=t.filter(t=>t.conflictsWith.length>0);e.forEach(e=>{const i=t.find(t=>e.conflictsWith.includes(t.attributeName()));i&&this._conflictingOption(e,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){const e=[],i=[];let n=e;const s=t.slice();function r(t){return t.length>1&&"-"===t[0]}let o=null;for(;s.length;){const t=s.shift();if("--"===t){n===i&&n.push(t),n.push(...s);break}if(!o||r(t)){if(o=null,r(t)){const e=this._findOption(t);if(e){if(e.required){const t=s.shift();void 0===t&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;s.length>0&&!r(s[0])&&(t=s.shift()),this.emit(`option:${e.name()}`,t)}else this.emit(`option:${e.name()}`);o=e.variadic?e:null;continue}}if(t.length>2&&"-"===t[0]&&"-"!==t[1]){const e=this._findOption(`-${t[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,t.slice(2)):(this.emit(`option:${e.name()}`),s.unshift(`-${t.slice(2)}`));continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("="),i=this._findOption(t.slice(0,e));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(e+1));continue}}if(r(t)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===i.length){if(this._findCommand(t)){e.push(t),s.length>0&&i.push(...s);break}if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){e.push(t),s.length>0&&e.push(...s);break}if(this._defaultCommandName){i.push(t),s.length>0&&i.push(...s);break}}if(this._passThroughOptions){n.push(t),s.length>0&&n.push(...s);break}n.push(t)}else this.emit(`option:${o.name()}`,t)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let i=0;i<e;i++){const e=this.options[i].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}\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=e||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in Y.env){const e=t.attributeName();(void 0===this.getOptionValue(e)||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,Y.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){const t=new it(this.options),e=t=>void 0!==this.getOptionValue(t)&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter(i=>void 0!==i.implied&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(t=>{Object.keys(t.implied).filter(t=>!e(t)).forEach(e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")})})}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const i=t=>{const e=t.attributeName(),i=this.getOptionValue(e),n=this.options.find(t=>t.negate&&e===t.attributeName()),s=this.options.find(t=>!t.negate&&e===t.attributeName());return n&&(void 0===n.presetArg&&!1===i||void 0!==n.presetArg&&i===n.presetArg)?n:s||t},n=t=>{const e=i(t),n=e.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${e.envVar}'`:`option '${e.flags}'`},s=`error: ${n(t)} cannot be used with ${n(e)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[],n=this;do{const t=n.createHelp().visibleOptions(n).filter(t=>t.long).map(t=>t.long);i=i.concat(t),n=n.parent}while(n&&!n._enablePositionalOptions);e=nt(t,i)}const i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this.registeredArguments.length,i=1===e?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach(t=>{i.push(t.name()),t.alias()&&i.push(t.alias())}),e=nt(t,i)}const i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(void 0===t)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";const n=this.createOption(e,i);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}\n`),this._exit(0,"commander.version",t)}),this}description(t,e){return void 0===t&&void 0===e?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return void 0===t?this._summary:(this._summary=t,this)}alias(t){if(void 0===t)return this._aliases[0];let e=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");return e._aliases.push(t),this}aliases(t){return void 0===t?this._aliases:(t.forEach(t=>this.alias(t)),this)}usage(t){if(void 0===t){if(this._usage)return this._usage;const t=this.registeredArguments.map(t=>Q(t));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=B.basename(t,B.extname(t)),this}executableDir(t){return void 0===t?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const e=this.createHelp();return void 0===e.helpWidth&&(e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),e.formatHelp(this,e)}_getHelpContext(t){const e={error:!!(t=t||{}).error};let i;return i=e.error?t=>this._outputConfiguration.writeErr(t):t=>this._outputConfiguration.writeOut(t),e.write=t.write||i,e.command=this,e}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const i=this._getHelpContext(t);this._getCommandAndAncestors().reverse().forEach(t=>t.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(e&&(n=e(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(t=>t.emit("afterAllHelp",i))}helpOption(t,e){if("boolean"==typeof t)return this._hasHelpOption=t,this;this._helpFlags=t||this._helpFlags,this._helpDescription=e||this._helpDescription;const i=et(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(t){this.outputHelp(t);let e=Y.exitCode||0;0===e&&t&&"function"!=typeof t&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const n=`${t}Help`;return this.on(n,t=>{let i;i="function"==typeof e?e({error:t.error,command:t.command}):e,i&&t.write(`${i}\n`)}),this}},function(t,e){const{Argument:i}=N,{Command:n}=M,{CommanderError:s,InvalidArgumentError:r}=j,{Help:o}=I,{Option:a}=L;(e=t.exports=new n).program=e,e.Command=n,e.Option=a,e.Argument=i,e.Help=o,e.CommanderError=s,e.InvalidArgumentError=r,e.InvalidOptionArgumentError=r}(P,P.exports);var ot=A(P.exports);const{program:at,createCommand:ht,createArgument:lt,createOption:pt,CommanderError:ct,InvalidArgumentError:mt,InvalidOptionArgumentError:ut,Command:dt,Argument:gt,Option:ft,Help:_t}=ot,vt=new dt;vt.version("1.0.0","-v, --version","gant-core version"),vt.command("default",{isDefault:!0,noHelp:!0,hidden:!0}).action(()=>$()),vt.command("build").description("build cli").action(()=>$("build")),vt.command("analyzer").description("bundle-analyzer").action(()=>$("analyzer")),vt.command("i18n").arguments("[currentLanguage] [targetLanguage]").description("i18n translation").action(E),vt.command("create").description("创建项目").action(()=>O()),vt.command("mfa").arguments("[name]").action(t=>{V("development",t)}),vt.command("mfa-build").arguments("[name]").action(t=>{V("build",t)}),vt.command("mfa-analyzer").arguments("[name]").action(t=>{V("analyzer",t)});(async()=>{try{vt.parse(process.argv)}catch(t){console.log("Start Error",C.red(t?.message))}})();export{k as Env};
3
3
  //# sourceMappingURL=index.mjs.map
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"module";import{o as t,p as s,d as r,e as a,m as i,f as o,g as n,h as l}from"../../utils/index.mjs";import{g as m}from"./cssRules.mjs";import{resolve as p}from"path";import{rspack as c}from"@rspack/core";import{b as u}from"./browsers.mjs";import{g}from"./framework/index.mjs";const d=e(import.meta.url),f=["name","routes","mpas","packages","microServiceMap","base","customHistoryApiFallback","outputPathDir","define","setting","framework","library","compression","terserOptions","htmlTemplatePath","locales","mfa","publicPathDir","provide","copy"],h=(e,h)=>{const b=t(h,f);let{base:x="/",routes:y,htmlTemplatePath:P,outputPathDir:w="dist",define:v,provide:j}=s(h,f);x=/^\/.*\/$/.test(x)?x:"/";const k=g(h,h.mode);let S=h.entry||{};const N=[];if(r(S)&&(S.index=p(e,"src/main")),"string"==typeof S.index){const e=a("string"==typeof P?P:P?.index);N.push(new c.HtmlRspackPlugin({template:e,filename:"index.html",chunks:["index"],publicPath:x,base:x,templateParameters:{base:x}})),h.entry=S}r(S)||Object.entries(S).forEach(([e,t])=>{if("index"!==e){const t=a("string"==typeof P?P:P?.[e]);N.push(new c.HtmlRspackPlugin({template:t,filename:`${e}.html`,chunks:[e],publicPath:x,base:x,templateParameters:{base:x}}))}});const _=m(h.mode);return i({entry:S,stats:"minimal",devServer:{static:{directory:p(e,"src/.gant/public"),publicPath:x},compress:!0,historyApiFallback:l(h,"customHistoryApiFallback")?h?.customHistoryApiFallback:{index:p(x,"index.html"),rewrites:[{from:/^\/public\/(.*)$/,to:e=>p(x,e.match[1])}]}},module:{rules:[...k.loaders,{test:/\.(ts|tsx)$/,exclude:/node_modules/,use:{loader:d.resolve("swc-loader"),options:{jsc:{target:"es2020",parser:{syntax:"typescript",tsx:!0,dynamicImport:!0},transform:k.swcTransform}}}},..._,{test:/\.ejs$/,use:{loader:d.resolve("ejs-loader"),options:{esModule:!1}}},{test:/\.(png|jpg|gif|woff|woff2|eot|ttf|svg)$/i,use:[{loader:d.resolve("url-loader"),options:{limit:8192,name:"[name][hash].[ext]",outputPath:"assets/"}}]}]},resolve:{extensions:[".tsx",".ts",".js",".jsx",".json",...k.extensions],alias:{"@gant/setting":p(e,n(),".gant/setting.ts"),"@gant/microServiceMap":p(e,n(),".gant/microServiceMap.ts")}},output:{path:p(e,w),publicPath:x,charset:!0,clean:!0},plugins:[...k.plugins,...N,new c.ProvidePlugin({...j}),new c.ProgressPlugin,new c.DefinePlugin({GANT_START_TIME:JSON.stringify(global.__gant_start_time),BASE:JSON.stringify(x),"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV),...o(v,e=>JSON.stringify(e))}),new c.BannerPlugin({banner:`/*! @browserslist ${u.join(", ")} */`,raw:!0})]},b)};export{h as g};
2
+ import{createRequire as e}from"module";import{o as t,p as s,d as r,e as a,m as i,f as o,g as n,h as l}from"../../utils/index.mjs";import{g as m}from"./cssRules.mjs";import{resolve as p,posix as c}from"path";import{rspack as u}from"@rspack/core";import{b as g}from"./browsers.mjs";import{g as d}from"./framework/index.mjs";const f=e(import.meta.url),h=["name","routes","mpas","packages","microServiceMap","base","customHistoryApiFallback","outputPathDir","define","setting","framework","library","compression","terserOptions","htmlTemplatePath","locales","mfa","publicPathDir","provide","copy"],b=(e,b)=>{const x=t(b,h);let{base:y="/",routes:P,htmlTemplatePath:w,outputPathDir:j="dist",define:v,provide:k}=s(b,h);y=/^\/.*\/$/.test(y)?y:"/";const S=d(b,b.mode);let N=b.entry||{};const _=[];if(r(N)&&(N.index=p(e,"src/main")),"string"==typeof N.index){const e=a("string"==typeof w?w:w?.index);_.push(new u.HtmlRspackPlugin({template:e,filename:"index.html",chunks:["index"],publicPath:y,base:y,templateParameters:{base:y}})),b.entry=N}r(N)||Object.entries(N).forEach(([e,t])=>{if("index"!==e){const t=a("string"==typeof w?w:w?.[e]);_.push(new u.HtmlRspackPlugin({template:t,filename:`${e}.html`,chunks:[e],publicPath:y,base:y,templateParameters:{base:y}}))}});const O=m(b.mode);return i({entry:N,stats:"minimal",devServer:{static:{directory:p(e,"src/.gant/public"),publicPath:y},compress:!0,historyApiFallback:l(b,"customHistoryApiFallback")?b?.customHistoryApiFallback:{index:c.join(y,"index.html"),rewrites:[{from:/^\/public\/(.*)$/,to:e=>c.join(y,e.match[1])}]}},module:{rules:[...S.loaders,{test:/\.(ts|tsx)$/,exclude:/node_modules/,use:{loader:f.resolve("swc-loader"),options:{jsc:{target:"es2020",parser:{syntax:"typescript",tsx:!0,dynamicImport:!0},transform:S.swcTransform}}}},...O,{test:/\.ejs$/,use:{loader:f.resolve("ejs-loader"),options:{esModule:!1}}},{test:/\.(png|jpg|gif|woff|woff2|eot|ttf|svg)$/i,use:[{loader:f.resolve("url-loader"),options:{limit:8192,name:"[name][hash].[ext]",outputPath:"assets/"}}]}]},resolve:{extensions:[".tsx",".ts",".js",".jsx",".json",...S.extensions],alias:{"@gant/setting":p(e,n(),".gant/setting.ts"),"@gant/microServiceMap":p(e,n(),".gant/microServiceMap.ts")}},output:{path:p(e,j),publicPath:y,charset:!0,clean:!0},plugins:[...S.plugins,..._,new u.ProvidePlugin({...k}),new u.ProgressPlugin,new u.DefinePlugin({GANT_START_TIME:JSON.stringify(global.__gant_start_time),BASE:JSON.stringify(y),"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV),...o(v,e=>JSON.stringify(e))}),new u.BannerPlugin({banner:`/*! @browserslist ${g.join(", ")} */`,raw:!0})]},x)};export{b as g};
3
3
  //# sourceMappingURL=default.config.mjs.map
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{m as e,h as t}from"../../utils/index.mjs";import{resolve as o}from"path";import{g as r}from"./framework/index.mjs";var a=(a,i)=>{const{base:s="/"}=a,m=r(a,"development");return e({mode:"development",devtool:"eval-source-map",devServer:{port:8080,hot:!0,open:!0,client:{overlay:!1},static:{directory:o(i,"src/.gant/public"),publicPath:s},compress:!0,historyApiFallback:t(a,"customHistoryApiFallback")?a?.customHistoryApiFallback:{index:o(s,"index.html"),rewrites:[{from:new RegExp(`${s}public/(.*)`),to:e=>e.match&&e.match[1]?o(s,e.match[1]):s}]}},resolve:{},plugins:[...m.devPlugins]},a)};export{a as _};
2
+ import{m as e,h as o}from"../../utils/index.mjs";import{posix as t,resolve as r}from"path";import{g as i}from"./framework/index.mjs";var a=(a,s)=>{const{base:m="/"}=a,l=i(a,"development");return e({mode:"development",devtool:"eval-source-map",devServer:{port:8080,hot:!0,open:!0,client:{overlay:!1},static:{directory:r(s,"src/.gant/public"),publicPath:m},compress:!0,historyApiFallback:o(a,"customHistoryApiFallback")?a?.customHistoryApiFallback:{index:`${m}index.html`,rewrites:[{from:new RegExp(`${m}public/(.*)`),to:e=>e.match&&e.match[1]?t.join(m,e.match[1]):m}]}},resolve:{},plugins:[...l.devPlugins]},a)};export{a as _};
3
3
  //# sourceMappingURL=development.config.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gant-core",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "",
5
5
  "main": "lib/core/index.js",
6
6
  "types": "lib/types/index.d.ts",