gant-core 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/lib/cli/create/module/index.js +1 -1
- package/lib/cli/index.js +1 -1
- package/lib/cli/webpack/Webpack.js +1 -1
- package/lib/cli/webpack/config/analyzer.config.js +1 -1
- package/lib/cli/webpack/config/cssRules.js +1 -1
- package/lib/cli/webpack/config/production.config.js +1 -1
- package/lib/core/store/index.js +1 -1
- package/package.json +2 -2
- package/rollup.config.js +1 -1
package/lib/cli/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e,t=require("./config/index.js"),i=require("./webpack/Webpack.js"),n=require("chokidar"),r=require("path"),s=require("./utils/index.js"),o=require("./routes/index.js"),a=require("./tsconfig/index.js"),l=require("./copyfiles/index.js"),h=require("./webpack/config/framework/index.js"),c=require("fs"),u=require("./create/config/index.js"),p=require("./create/module/index.js"),m=require("./utils/detectPort.js"),d=require("events"),g=require("child_process"),f=require("process"),_=require("./i18n/index.js");async function v(e="development"){process.env.SRC="true",process.env.NODE_ENV=e;const c=process.cwd(),u=new t.Config({cwd:c});let p=u.getUserConfig();function m(t){const n=s.getSrcPath(),u=r.resolve(c,n,".gant");s.generateDir(u),s.writeFileToJS(r.resolve(u,"setting.ts"),`export default ${JSON.stringify(t.setting||{})}`),s.writeFileToJS(r.resolve(u,"microServiceMap.ts"),`export default ${JSON.stringify(t.microServiceMap||{})}`);const p={[t?.name||"@@"]:c,...t?.resolve?.alias},m=[c];s.keys(t.packages).map(e=>{const i=t.packages[e];p[e]=i,m.push(i)}),a.generateTsConfig(u,{paths:p,includes:m,cwd:c,framework:h.resolveFramework(t)});const d=[...Object.keys(t.packages).map(e=>t.packages[e]),c];l.copyAppsFiles(u,d),l.copyPublicFiles(u,d.map(e=>r.resolve(e,"public"))),o.generateRoutes(r.resolve(u,"./routes"),t.routes);return new i.Webpack(t,c,e)}u.configFiles;let d=m(p);if("development"===e){await d.runServer();let g=null;function f(e){const t=[...Object.keys(p.packages).map(e=>p.packages[e]),c].map(e=>r.resolve(e,"public")),i=u.configFiles?.map(e=>r.dirname(e))||[],s=[...new Set([...i,...t])];g=n.watch(s,{}),g.on("change",async e=>{g?.close(),await(d.devServer?.stop()),p=u.getUserConfig(),d=m(p),await d.runServer({open:!1}),f()})}return void f()}d.runBuild()}function b(){const e=process.cwd(),i=new t.Config({cwd:e});let n=i.getMsUserConfig();const o=s.getSrcPath(),l=r.resolve(e,o,".gant");c.existsSync(l)||c.mkdirSync(l,{recursive:!0}),s.writeFileToJS(r.resolve(l,"setting.ts"),`export default ${JSON.stringify(n.setting||{})}`),s.writeFileToJS(r.resolve(l,"microServiceMap.ts"),`export default ${JSON.stringify(n.microServiceMap||{})}`);const u=n?.name||"main",p={},m={...n?.resolve?.alias},d=[e];return n.mfa?.entry&&(p[u]={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?.(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||n.mfa.subEntry,publicPath:i,port:e.port,htmlTemplatePath:e.htmlTemplatePath,apps:t,base:e.base,url:e.url}}),s.writeFileToJS(r.resolve(l,"appMaps.ts"),`export default ${JSON.stringify(p)}`),a.generateTsConfig(l,{includes:d,paths:m,cwd:e,framework:h.resolveFramework(n),createIncludes:!1}),{userConfig:n,msName:u,msConfig:p,configManager:i}}async function O(e="development",t){process.env.SRC="false",process.env.NODE_ENV=e;const{userConfig:i,msName:n,msConfig:r,configManager:o}=b();if(s.isEmpty(i.mfa))return;const a=t||n,l=r[a];l&&await A(o,e,i,a,l)}async function A(e,a,h,p,m,d=!0){const g=process.cwd(),f=s.getSrcPath(),_=s.cloneDeep(h);const v=m.apps?.map?.(e=>t.Config.getMainConfigFile({cwd:e}))?.filter?.(e=>!!e);let O=function(){const t=r.resolve(g,f,`.gant/${p}`);s.generateDir(t),l.copyAppsFiles(t,m.apps),l.copyPublicFiles(t,m.publicPath);const n=c.readFileSync(r.resolve(__dirname,"./template/msentry.txt"),"utf-8"),h=u.ejs.compile(n);c.writeFileSync(r.resolve(t,"index.ts"),h({entry:r.join("../../",m.entry)}));const d=e.getMsPagesUserConfig(m.apps);return o.generateRoutes(r.resolve(t,"./routes"),d.routes),_.entry={index:r.resolve(t,"index.ts")},_.base=s.get(m,"base","/"),_.define={..._.define,APP_NAME:p},_.devServer={..._.devServer,port:m.port,static:{directory:r.resolve(t,"public")}},_.output={..._.output,chunkLoadingGlobal:`webpackJsonp_${p}`,chunkFilename:`${p}.[name].[id].[contenthash].js`,path:r.resolve(g,`dist/${p}`)},_.outputPathDir=r.resolve(g,`dist/${p}`),_.publicPathDir=r.resolve(g,`.gant/${p}/public`),new i.Webpack(_,g,a)}();if("development"===a){await O.runServer({open:d});let C=null;function w(t){const i=(m.publicPath||[]).filter(Boolean),r=[...new Set([...t,...i])];C=n.watch(r),C.on("change",async t=>{await(O.devServer?.stop());const{userConfig:i,msConfig:n}=b();C.close(),await A(e,a,i,p,n[p],!1)})}return void w(v)}O.runBuild()}require("./utils/getJavascriptfile.js"),require("jiti"),require("@rspack/core"),require("@rspack/dev-server"),require("./webpack/config/index.js"),require("./webpack/config/production.config.js"),require("./webpack/plugins/copy.js"),require("mini-css-extract-plugin"),require("compression-webpack-plugin"),require("./webpack/config/default.config.js"),require("./webpack/config/cssRules.js"),require("./webpack/config/browsers.js"),require("./webpack/config/development.config.js"),require("./webpack/config/analyzer.config.js"),require("module"),require("url"),require("fs/promises"),require("assert"),require("v8"),require("util"),require("net"),require("./webpack/config/framework/react.js"),require("./webpack/config/framework/vue.js"),require("node:tty"),require("tty"),require("readline"),require("os"),require("stream"),require("buffer"),require("string_decoder"),require("node:process"),require("node:assert"),require("node:path"),require("node:os"),require("node:crypto"),require("node:stream"),require("node:readline"),require("http"),require("https"),require("crypto"),require("./i18n/utils.js"),require("http2"),require("zlib"),exports.Env=void 0,(e=exports.Env||(exports.Env={})).development="development",e.production="production",e.test="test";var C={exports:{}},w={},y={};let x=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}};y.CommanderError=x,y.InvalidArgumentError=class extends x{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:E}=y;w.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 E(`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}},w.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"};var k={},S={};const{humanReadableArgName:$}=w;S.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=>$(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 H={};const{InvalidArgumentError:V}=y;function q(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}}H.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=q(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 V(`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}},H.splitOptionFlags=q,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 F={};F.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=3;return t.forEach(t=>{if(t.length<=1)return;const i=function(e,t){if(Math.abs(e.length-t.length)>3)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 P=d.EventEmitter,N=g,j=r,D=c,T=f,{Argument:M,humanReadableArgName:I}=w,{CommanderError:W}=y,{Help:L}=S,{Option:U,splitOptionFlags:G,DualOptions:J}=H,{suggestSimilar:R}=F;function B(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})}k.Command=class e extends P{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=>T.stdout.write(e),writeErr:e=>T.stderr.write(e),getOutHelpWidth:()=>T.stdout.isTTY?T.stdout.columns:void 0,getErrHelpWidth:()=>T.stderr.isTTY?T.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 L,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 M(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 W(e,t,i)),T.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 U(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 U)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=T.argv,T.versions&&T.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":T.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=j.resolve(e,t);if(D.existsSync(i))return i;if(n.includes(j.extname(t)))return;const r=n.find(e=>D.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=D.realpathSync(this._scriptPath)}catch(t){e=this._scriptPath}a=j.resolve(j.dirname(e),a)}if(a){let t=r(a,o);if(!t&&!e._executableFile&&this._scriptPath){const i=j.basename(this._scriptPath,j.extname(this._scriptPath));i!==this._name&&(t=r(a,`${i}-${e._name}`))}o=t||o}if(i=n.includes(j.extname(o)),"win32"!==T.platform?i?(t.unshift(o),t=z(T.execArgv).concat(t),s=N.spawn(T.argv[0],t,{stdio:"inherit"})):s=N.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=z(T.execArgv).concat(t),s=N.spawn(T.execPath,t,{stdio:"inherit"})),!s.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(e=>{T.on(e,()=>{!1===s.killed&&null===s.exitCode&&s.kill(e)})})}const l=this._exitCallback;l?s.on("close",()=>{l(new W(T.exitCode||0,"commander.executeSubCommandAsync","(close)"))}):s.on("close",T.exit.bind(T)),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 W(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,l(e)}else T.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 B(this,t),this._dispatchSubcommand(this._defaultCommandName,e,t);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),B(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 T.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()}`,T.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){const e=new J(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=>I(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=j.basename(e,j.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=G(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(e){this.outputHelp(e);let t=T.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}=w,{Command:n}=k,{CommanderError:r,InvalidArgumentError:s}=y,{Help:o}=S,{Option:a}=H;(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}(C,C.exports);var Y=C.exports,K=m.getDefaultExportFromCjs(Y);const{program:Q,createCommand:X,createArgument:Z,createOption:ee,CommanderError:te,InvalidArgumentError:ie,InvalidOptionArgumentError:ne,Command:re,Argument:se,Option:oe,Help:ae}=K,le=new re;le.version("1.0.0","-v, --version","gant-core version"),le.command("default",{isDefault:!0,noHelp:!0,hidden:!0}).action(()=>v()),le.command("build").description("build cli").action(()=>v("build")),le.command("analyzer").description("bundle-analyzer").action(()=>v("analyzer")),le.command("i18n").arguments("[currentLanguage] [targetLanguage]").description("i18n translation").action(_.i18n),le.command("create").description("创建项目").action(()=>p.createModule()),le.command("mfa").arguments("[name]").action(e=>{O("development",e)}),le.command("mfa-build").arguments("[name]").action(e=>{O("build",e)}),le.command("mfa-analyzer").arguments("[name]").action(e=>{O("analyzer",e)});(async()=>{try{le.parse(process.argv)}catch(e){console.log("Start Error",m.color.red(e?.message))}})();
|
|
2
|
+
"use strict";var e,t=require("./config/index.js"),i=require("./webpack/Webpack.js"),n=require("chokidar"),r=require("path"),s=require("./utils/index.js"),o=require("./routes/index.js"),a=require("./tsconfig/index.js"),l=require("./copyfiles/index.js"),h=require("./webpack/config/framework/index.js"),c=require("fs"),u=require("./create/config/index.js"),p=require("./create/module/index.js"),m=require("./utils/detectPort.js"),d=require("events"),g=require("child_process"),f=require("process"),_=require("./i18n/index.js");async function v(e="development"){process.env.SRC="true",process.env.NODE_ENV=e;const c=process.cwd(),u=new t.Config({cwd:c});let p=u.getUserConfig();function m(t){const n=s.getSrcPath(),u=r.resolve(c,n,".gant");s.generateDir(u),s.writeFileToJS(r.resolve(u,"setting.ts"),`export default ${JSON.stringify(t.setting||{})}`),s.writeFileToJS(r.resolve(u,"microServiceMap.ts"),`export default ${JSON.stringify(t.microServiceMap||{})}`);const p={[t?.name||"@@"]:c,...t?.resolve?.alias},m=[c];s.keys(t.packages).map(e=>{const i=t.packages[e];p[e]=i,m.push(i)}),a.generateTsConfig(u,{paths:p,includes:m,cwd:c,framework:h.resolveFramework(t)});const d=[...Object.keys(t.packages).map(e=>t.packages[e]),c];l.copyAppsFiles(u,d),l.copyPublicFiles(u,d.map(e=>r.resolve(e,"public"))),o.generateRoutes(r.resolve(u,"./routes"),t.routes);return new i.Webpack(t,c,e)}u.configFiles;let d=m(p);if("development"===e){await d.runServer();let g=null;function f(e){const t=[...Object.keys(p.packages).map(e=>p.packages[e]),c].map(e=>r.resolve(e,"public")),i=u.configFiles?.map(e=>r.dirname(e))||[],s=[...new Set([...i,...t])];g=n.watch(s,{}),g.on("change",async e=>{g?.close(),await(d.devServer?.stop()),p=u.getUserConfig(),d=m(p),await d.runServer({open:!1}),f()})}return void f()}d.runBuild()}function b(){const e=process.cwd(),i=new t.Config({cwd:e});let n=i.getMsUserConfig();const o=s.getSrcPath(),l=r.resolve(e,o,".gant");c.existsSync(l)||c.mkdirSync(l,{recursive:!0}),s.writeFileToJS(r.resolve(l,"setting.ts"),`export default ${JSON.stringify(n.setting||{})}`),s.writeFileToJS(r.resolve(l,"microServiceMap.ts"),`export default ${JSON.stringify(n.microServiceMap||{})}`);const u=n?.name||"main",p={},m={...n?.resolve?.alias},d=[e];return n.mfa?.entry&&(p[u]={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?.(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||n.mfa.subEntry,publicPath:i,port:e.port,htmlTemplatePath:e.htmlTemplatePath,apps:t,base:e.base,url:e.url}}),s.writeFileToJS(r.resolve(l,"appMaps.ts"),`export default ${JSON.stringify(p)}`),a.generateTsConfig(l,{includes:d,paths:m,cwd:e,framework:h.resolveFramework(n),createIncludes:!1}),{userConfig:n,msName:u,msConfig:p,configManager:i}}async function O(e="development",t){process.env.SRC="false",process.env.NODE_ENV=e;const{userConfig:i,msName:n,msConfig:r,configManager:o}=b();if(s.isEmpty(i.mfa))return;const a=t||n,l=r[a];l&&await A(o,e,i,a,l)}async function A(e,a,h,p,m,d=!0){const g=process.cwd(),f=s.getSrcPath(),_=s.cloneDeep(h);const v=m.apps?.map?.(e=>t.Config.getMainConfigFile({cwd:e}))?.filter?.(e=>!!e);let O=function(){const t=r.resolve(g,f,`.gant/${p}`);s.generateDir(t),l.copyAppsFiles(t,m.apps),l.copyPublicFiles(t,m.publicPath);const n=c.readFileSync(r.resolve(__dirname,"./template/msentry.txt"),"utf-8"),h=u.ejs.compile(n);c.writeFileSync(r.resolve(t,"index.ts"),h({entry:r.join("../../",m.entry)}));const d=e.getMsPagesUserConfig(m.apps);return o.generateRoutes(r.resolve(t,"./routes"),d.routes),_.entry={index:r.resolve(t,"index.ts")},_.base=s.get(m,"base","/"),_.define={..._.define,APP_NAME:p},_.devServer={..._.devServer,port:m.port,static:{directory:r.resolve(t,"public")}},_.output={..._.output,chunkLoadingGlobal:`webpackJsonp_${p}`,chunkFilename:`${p}.[name].[id].[contenthash].js`,path:r.resolve(g,`dist/${p}`)},_.outputPathDir=r.resolve(g,`dist/${p}`),_.publicPathDir=r.resolve(g,`.gant/${p}/public`),new i.Webpack(_,g,a)}();if("development"===a){await O.runServer({open:d});let C=null;function w(t){const i=(m.publicPath||[]).filter(Boolean),r=[...new Set([...t,...i])];C=n.watch(r),C.on("change",async t=>{await(O.devServer?.stop());const{userConfig:i,msConfig:n}=b();C.close(),await A(e,a,i,p,n[p],!1)})}return void w(v)}O.runBuild()}require("./utils/getJavascriptfile.js"),require("jiti"),require("@rspack/core"),require("@rspack/dev-server"),require("./webpack/config/index.js"),require("./webpack/config/production.config.js"),require("./webpack/plugins/copy.js"),require("compression-webpack-plugin"),require("./webpack/config/default.config.js"),require("./webpack/config/cssRules.js"),require("./webpack/config/browsers.js"),require("./webpack/config/development.config.js"),require("./webpack/config/analyzer.config.js"),require("module"),require("url"),require("fs/promises"),require("assert"),require("v8"),require("util"),require("net"),require("./webpack/config/framework/react.js"),require("./webpack/config/framework/vue.js"),require("node:tty"),require("tty"),require("readline"),require("os"),require("stream"),require("buffer"),require("string_decoder"),require("node:process"),require("node:assert"),require("node:path"),require("node:os"),require("node:crypto"),require("node:stream"),require("node:readline"),require("http"),require("https"),require("crypto"),require("./i18n/utils.js"),require("http2"),require("zlib"),exports.Env=void 0,(e=exports.Env||(exports.Env={})).development="development",e.production="production",e.test="test";var C={exports:{}},w={},y={};let x=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}};y.CommanderError=x,y.InvalidArgumentError=class extends x{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:E}=y;w.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 E(`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}},w.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"};var k={},S={};const{humanReadableArgName:$}=w;S.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=>$(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 H={};const{InvalidArgumentError:V}=y;function q(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}}H.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=q(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 V(`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}},H.splitOptionFlags=q,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 F={};F.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=3;return t.forEach(t=>{if(t.length<=1)return;const i=function(e,t){if(Math.abs(e.length-t.length)>3)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 P=d.EventEmitter,N=g,j=r,D=c,T=f,{Argument:M,humanReadableArgName:I}=w,{CommanderError:W}=y,{Help:L}=S,{Option:U,splitOptionFlags:G,DualOptions:J}=H,{suggestSimilar:R}=F;function B(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})}k.Command=class e extends P{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=>T.stdout.write(e),writeErr:e=>T.stderr.write(e),getOutHelpWidth:()=>T.stdout.isTTY?T.stdout.columns:void 0,getErrHelpWidth:()=>T.stderr.isTTY?T.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 L,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 M(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 W(e,t,i)),T.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 U(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 U)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=T.argv,T.versions&&T.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":T.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=j.resolve(e,t);if(D.existsSync(i))return i;if(n.includes(j.extname(t)))return;const r=n.find(e=>D.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=D.realpathSync(this._scriptPath)}catch(t){e=this._scriptPath}a=j.resolve(j.dirname(e),a)}if(a){let t=r(a,o);if(!t&&!e._executableFile&&this._scriptPath){const i=j.basename(this._scriptPath,j.extname(this._scriptPath));i!==this._name&&(t=r(a,`${i}-${e._name}`))}o=t||o}if(i=n.includes(j.extname(o)),"win32"!==T.platform?i?(t.unshift(o),t=z(T.execArgv).concat(t),s=N.spawn(T.argv[0],t,{stdio:"inherit"})):s=N.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=z(T.execArgv).concat(t),s=N.spawn(T.execPath,t,{stdio:"inherit"})),!s.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(e=>{T.on(e,()=>{!1===s.killed&&null===s.exitCode&&s.kill(e)})})}const l=this._exitCallback;l?s.on("close",()=>{l(new W(T.exitCode||0,"commander.executeSubCommandAsync","(close)"))}):s.on("close",T.exit.bind(T)),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 W(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,l(e)}else T.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 B(this,t),this._dispatchSubcommand(this._defaultCommandName,e,t);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),B(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 T.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()}`,T.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){const e=new J(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=>I(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=j.basename(e,j.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=G(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(e){this.outputHelp(e);let t=T.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}=w,{Command:n}=k,{CommanderError:r,InvalidArgumentError:s}=y,{Help:o}=S,{Option:a}=H;(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}(C,C.exports);var Y=C.exports,K=m.getDefaultExportFromCjs(Y);const{program:Q,createCommand:X,createArgument:Z,createOption:ee,CommanderError:te,InvalidArgumentError:ie,InvalidOptionArgumentError:ne,Command:re,Argument:se,Option:oe,Help:ae}=K,le=new re;le.version("1.0.0","-v, --version","gant-core version"),le.command("default",{isDefault:!0,noHelp:!0,hidden:!0}).action(()=>v()),le.command("build").description("build cli").action(()=>v("build")),le.command("analyzer").description("bundle-analyzer").action(()=>v("analyzer")),le.command("i18n").arguments("[currentLanguage] [targetLanguage]").description("i18n translation").action(_.i18n),le.command("create").description("创建项目").action(()=>p.createModule()),le.command("mfa").arguments("[name]").action(e=>{O("development",e)}),le.command("mfa-build").arguments("[name]").action(e=>{O("build",e)}),le.command("mfa-analyzer").arguments("[name]").action(e=>{O("analyzer",e)});(async()=>{try{le.parse(process.argv)}catch(e){console.log("Start Error",m.color.red(e?.message))}})();
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("@rspack/core"),r=require("@rspack/dev-server"),t=require("./config/index.js");require("fs"),require("path"),require("../utils/getJavascriptfile.js");var o=require("../utils/detectPort.js");exports.Webpack=class{Compiler;Config;devServer=null;constructor(r,o,s){try{let i={};i="development"===s?t.getDevConfig(r,o):"analyzer"===s?t.getAnalyzerConfig(r,o):t.getProductionConfig(r,o),this.Config=i,this.Compiler=e.rspack(i)}catch(e){console.log(e)}}runBuild=()=>{this.Compiler.run((e,r)=>{if(e)console.log(e.message);else{console.log(r?.toString({colors:!0}));for(const e of Object.keys(r?.compilation?.assets||{}))console.log(`Generated asset: ${e}`)}})};runServer=async e=>{const t=Number(e?.port??this.Config?.devServer?.port??8080),s=await o.detectPort(t);this.devServer=new r.RspackDevServer({...this.Config?.devServer,...e,port:s},this.Compiler),await(this.devServer?.start())}};
|
|
2
|
+
"use strict";var e=require("@rspack/core"),r=require("@rspack/dev-server"),t=require("./config/index.js");require("fs"),require("path"),require("../utils/getJavascriptfile.js");var o=require("../utils/detectPort.js");exports.Webpack=class{Compiler;Config;devServer=null;type;constructor(r,o,s){this.type=s;try{let i={};i="development"===s?t.getDevConfig(r,o):"analyzer"===s?t.getAnalyzerConfig(r,o):t.getProductionConfig(r,o),this.Config=i,this.Compiler=e.rspack(i)}catch(e){console.log(e)}}runBuild=()=>{this.Compiler.run((e,r)=>{if(e)console.log(e.message);else{console.log(r?.toString({colors:!0}));for(const e of Object.keys(r?.compilation?.assets||{}))console.log(`Generated asset: ${e}`)}})};runServer=async e=>{const t=Number(e?.port??this.Config?.devServer?.port??8080),s=await o.detectPort(t);this.devServer=new r.RspackDevServer({...this.Config?.devServer,...e,port:s},this.Compiler),await(this.devServer?.start())}};
|
|
3
3
|
//# sourceMappingURL=Webpack.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var r=require("./production.config.js");exports._getAnalyzerConfig=(n,o)=>{const{RsdoctorRspackPlugin:e}=require("@rsdoctor/rspack-plugin"),i=r.getProConfig(n,o);return{...i,plugins:[...i.plugins||[],new e({})]}};
|
|
3
3
|
//# sourceMappingURL=analyzer.config.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("./browsers.js");const
|
|
2
|
+
"use strict";var e=require("./browsers.js");const{CssExtractRspackPlugin:s}=require("@rspack/core");exports.getCssRules=r=>[{test:/\.(less)$/,exclude:/node_modules|public/,use:["development"===r?require.resolve("style-loader"):s.loader,{loader:require.resolve("css-loader"),options:{modules:{localIdentName:"[name]__[local]--[hash:base64:5]"}}},{loader:require.resolve("postcss-loader"),options:{postcssOptions:{plugins:[require.resolve("postcss-short"),require("postcss-preset-env")({browsers:e.browserslist,autoprefixer:{flexbox:"no-2009"},stage:3})]}}},{loader:require.resolve("less-loader"),options:{implementation:require.resolve("less"),lessOptions:{javascriptEnabled:!0}}}]},{test:/\.(css)$/,use:["development"===r?require.resolve("style-loader"):s.loader,require.resolve("css-loader"),{loader:require.resolve("postcss-loader"),options:{postcssOptions:{plugins:[require.resolve("postcss-short"),require("postcss-preset-env")({browsers:e.browserslist,autoprefixer:{flexbox:"no-2009"},stage:3})]}}}]}];
|
|
3
3
|
//# sourceMappingURL=cssRules.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var i=require("../plugins/copy.js"),e=require("path"),s=require("../../utils/index.js"),t=require("
|
|
2
|
+
"use strict";var i=require("../plugins/copy.js"),e=require("path"),s=require("../../utils/index.js"),t=require("@rspack/core"),n=require("compression-webpack-plugin");exports.getProConfig=(r,o)=>{const{outputPathDir:u="dist",publicPathDir:p=e.resolve(o,s.getSrcPath(),".gant/public"),optimization:a,library:l,compression:c=!0,copy:m=[]}=r,g=[];return l?s.mergeConfig({mode:"production",optimization:{minimize:!0,...a},plugins:[new t.CssExtractRspackPlugin]},r):(!0===c&&g.push(new n({algorithm:"gzip",test:/\.js(\?.*)?$/i,threshold:10240,minRatio:.7,deleteOriginalAssets:!1})),s.mergeConfig({mode:"production",devtool:"source-map",optimization:{minimize:!0,runtimeChunk:"single",moduleIds:"deterministic",...a,splitChunks:{chunks:"all",minSize:10240,maxAsyncRequests:30,maxInitialRequests:30,minChunks:1,maxSize:5242880,...a?.splitChunks,cacheGroups:{vendors:{chunks:"initial",name:"vendors",test:/[\\/]node_modules[\\/]/,priority:-10,reuseExistingChunk:!0},...s.get(a?.splitChunks,"cacheGroups",{})}}},plugins:[new t.CssExtractRspackPlugin,new i.CopyFolderPlugin({patterns:[{from:p,to:e.resolve(o,u,"public")},...m]}),...g]},r))};
|
|
3
3
|
//# sourceMappingURL=production.config.js.map
|
package/lib/core/store/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t}from"../request/index.js";import{groupBy as e,get as s,reduce as a,find as i,keyBy as n,pick as r,isEmpty as o,findIndex as c,isPlainObject as h,cloneDeep as u,mapValues as d,uniqBy as g}from"lodash-es";import m from"mitt";const l=new class{codeLists=[];codeMaps={};async findAllCodeList(){const s=await t("/codeList/findAll",{data:{},serviceId:"fwPlatform"})||[],a=e(s,"type");this.codeLists=s,this.codeMaps=a}getCodeLocaleList=t=>s(this.codeMaps,t,[]);getCodeLocaleName=(t,e)=>{const s=this.getCodeLocaleList(t);function n(t){const e=i(s,e=>e.value===String(t));return e?.name||""}if(Array.isArray(e)){const t=a(e,(t="",e="")=>t+","+n(e),"");return t.slice(1,t.length)}if(String(e).indexOf(",")>=0){const t=e.replace("[","").replace("]","").split(","),s=a(t,(t="",e="")=>t+","+n(e),"");return s.slice(1,s.length)}return n(e)}};l.getCodeLocaleList,l.getCodeLocaleName;const p=new class{parameterList=[];parameterMap={};findAllParameters=async()=>{const e=await t("/parameter/findAll",{serviceId:"fwPlatform",data:{}},{showError:!1})||[],s=n(e,"name");this.parameterList=e,this.parameterMap=s};getSystemParameterByName=t=>"string"==typeof t?this.parameterMap[t]:r(this.parameterMap,t)};const y=(({prefixKey:t="",storage:e=localStorage}={})=>new class{storage=e;prefixKey=t;getKey(t){return`${this.prefixKey}${t}`.toUpperCase()}set(t,e,s=604800){const a=JSON.stringify({value:e,expire:null!==s?(new Date).getTime()+1e3*s:null});this.storage.setItem(this.getKey(t),a)}get(t,e=null){const s=this.storage.getItem(this.getKey(t));if(s)try{const e=JSON.parse(s),{value:a,expire:i}=e;if(null===i||i>=Date.now())return a;this.remove(t)}catch(t){return console.error(t),e}return e}remove(t){this.storage.removeItem(this.getKey(t))}clear(){this.storage.clear()}setCookie(t,e,s=604800){document.cookie=`${this.getKey(t)}=${e}; Max-Age=${s}`}getCookie(t){const e=document.cookie.split("; ");for(let s=0,a=e.length;s<a;s++){const a=e[s].split("=");if(a[0]===this.getKey(t))return a[1]}return""}removeCookie(t){this.setCookie(t,1,-1)}clearCookie(){const t=document.cookie.match(/[^ =;]+(?==)/g);if(t)for(let e=t.length;e--;)document.cookie=t[e]+"=0;expire="+new Date(0).toUTCString()}})();class f{userIdentity={};currentUser={};isSuperAdmin=!1;roles=[];functions=[];delegations=[];userSetting={};users=[];getUserIdentity(){if(!o(this.userIdentity))return this.userIdentity;const t=y?.get("userIdentity");return t||{}}setUserIdentity(t){return this.userIdentity={...this.userIdentity,...t},y.set("userIdentity",this.userIdentity),this.userIdentity}clearUserIdentity(){y.remove("userIdentity"),this.userIdentity={}}setUserAggregateInfo=({delegations:t,roles:e,functions:s,isSuperAdmin:a,currentUser:i})=>{this.delegations=t,this.roles=e,this.functions=s,this.isSuperAdmin=a,this.currentUser=i};getUserSettingType=t=>`${this.currentUser.id}-${t}`;getUserSetting=async e=>{const s=this.getUserSettingType(e),a=this.currentUser.id;if(this.userSetting[s])return this.userSetting[s];const i=await async function(e){return t("/accountUserSelf/getUserData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:a+e}),n=i?.bigData?JSON.parse(i.bigData):void 0;return this.userSetting[s]=n,n};updateUserSetting=async(e,s)=>{const a=this.getUserSettingType(e),i=this.currentUser.id;return await async function(e,s){return t("/accountUserSelf/setUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:i+e,bigData:JSON.stringify(s)}),this.userSetting[a]=s,s};removeUserSetting=async e=>{const s=this.getUserSettingType(e),a=this.currentUser.id;await async function(e,s){return t("/accountUserSelf/delUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:a}),delete this.userSetting[s]};getUserInfo=async(e,a)=>{const i=c(this.users,t=>a?t.userLoginName===e:t.id===e);if(i>-1)return s(this.users,`[${i}]`);const n=a?await async function(e){return t("/security/getUserByUserLoginName",{method:"POST",data:{userLoginName:e},serviceId:"fwSecurity"})}(e):await async function(e){return t("/security/getUserById",{method:"POST",data:{id:e},serviceId:"fwSecurity"})}(e);return h(n)&&this.users.push(n),n}}const w=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,S=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,L=t=>w.test(t)||S.test(t)||0===t?.indexOf("/")?t:"/"+t,I="MENU_HISTORY_UPDATE",P="MENU_BREADCRUMBS_UPDATE";m();class U{menuDataMaps={};menuData=[];menuPathMaps={};breadcrumbs=[];menuHistorys=[];userId;emitter;constructor(){this.emitter=m()}addListenerMenuHistorys=t=>{this.emitter.on(I,t)};removeListenerMenuHistorys=t=>this.emitter.off(I,t);addListenerBreadcrumbs=t=>this.emitter.on(P,t);removeListenerBreadcrumbs=t=>this.emitter.off(P,t);getTreeMenuData=(t,e,s)=>t.map(t=>{const{id:a,path:i,leaf:n}=t,r=e[a],o={...t,key:a,path:s?s+L(i):L(i)};if(r&&!n){const t=this.getTreeMenuData(r,e,o.path);o.children=t}return this.menuDataMaps[o.path]=o,o}).sort((t,e)=>t.seqNum-e.seqNum);init=(t,s)=>{const a=u(t);if(o(a))return;const i=e(a,"parentResourceId"),{ROOT:n,...r}=i;this.menuData=this.getTreeMenuData(n,r),this.menuData=[...this.menuData];const c=d(this.menuDataMaps,"name");this.updateMenuMaps(c),this.initMenuHistorys(s)};updateMenuMaps=t=>{this.menuPathMaps={...this.menuPathMaps,...t};const e=this.menuHistorys.map(t=>{const e=this.menuPathMaps[t.pathname];return{pathname:t.pathname,name:e||t.name}}),s=this.breadcrumbs.map(t=>{const e=this.menuPathMaps[t.pathname];return{...t,name:e||t.name}});this.updatehistorys(e),this.updateBreadcrumbs(s)};liseterHistorys=t=>{let e=this.menuHistorys;this.menuDataMaps[t]?.leaf&&!e.some(e=>e.pathname===t)&&(e=[{pathname:t,name:this.menuPathMaps[t]},...e],this.updatehistorys(e))};updatehistorys=t=>{if(!this.userId)return;const e=t.map(t=>({...t,name:t.name?t.name:this.menuPathMaps[t.pathname]}));this.menuHistorys=e,this.menuHistorys=g(this.menuHistorys,"pathname"),this.emitter.emit(I,this.menuHistorys),y.set(`${this.userId}-menu-history`,this.menuHistorys)};initMenuHistorys=t=>{this.userId=t;const e=y.get(`${t}-menu-history`,this.menuHistorys);this.updatehistorys(e)};liseterBreadcrumbs=t=>{const e=t.split("/");let s=1;const a=[],i={pathname:t,name:this.menuPathMaps[t]};for(;s<e.length;){const t=e.slice(0,s).join("/");this.menuPathMaps[t]&&a.push({name:this.menuPathMaps[t],pathname:t}),s++}a.push(i),this.updateBreadcrumbs(a)};updateBreadcrumbs=t=>{this.breadcrumbs=t,this.breadcrumbs=g(this.breadcrumbs,"pathname"),this.emitter.emit(P,t)}}class C{loginPathname;BASE="/";get baseLoginPathname(){return`${this.BASE}${this.loginPathname?.replace("/","")}`}tokenValue="";get isLoginPathname(){const t=window.location.pathname;return this.baseLoginPathname==t}getRealPath=t=>`${this.BASE}${t.replace("/","")}`;chekToken=async()=>{const e=await t("/authentication/checkToken",{serviceId:"fwSecurity"},{showError:!1});return e&&this.isLoginPathname&&window.location.replace(this.BASE),e};getLoginMethod=async()=>t("/authentication/getLoginMethod",{serviceId:"fwSecurity"});redirectBaseLogin=async()=>{const t=window.location.pathname,e=window.location.href;if(this.isLoginPathname)return!0;const s=new URLSearchParams(window.location.search),a=new URLSearchParams;"true"===s.get("forceLocal")&&a.append("forceLocal","true"),t!==this.BASE&&"/"!==t&&a.append("redirectUrl",e);const i=decodeURIComponent(a.toString());return window.location.replace(`${this.baseLoginPathname}${i?"?"+decodeURIComponent(a.toString()):""}`),!1};checkPassword=async()=>"noPass"!==await t("/security/checkPasswordUpdateTime",{data:{}},{showError:!1})||(this.tokenValue=await t("/authentication/extractToken",{data:{}}),!1);refactorToken=async()=>{var e;await(e=this.tokenValue,t("/authentication/refactorToken",{data:{value:e}}))};login=async t=>{const e=await this.baseLogin(t);return e.error,e};baseLogin=async e=>{const s={error:void 0,data:void 0};try{const a=await function(e){return t("/authentication/login",{data:e,serviceId:"fwSecurity"})}(e),{userToken:i,traceId:n}=a;if(i){s.data=a;return await this.checkPassword()||(s.error="passwordExpiration"),s}return n?(s.data=a,s.error="SLIDER_VERIFICATION_LOGIN",s):(s.error="passwordError",s)}catch(t){return s.error="validateError",s}};loginSuccess=()=>{let t=new URLSearchParams(window.location.search).get("redirectUrl");t?window.location.href=t:window.location.replace(this.BASE)};baseLoginOut=async e=>{const s=new URLSearchParams,a=window.location.href;window.location.pathname!==this.BASE&&s.append("redirectUrl",a),await t("/authentication/logout",{data:{},serviceId:"fwSecurity"}),e?window.location.replace(`${this.baseLoginPathname}?${s.toString()}`):window.location.replace(this.baseLoginPathname)}}const k={sso:!1,ssoUrlSearchParams:["ticket"],ssoCheckTokenUrl:"",ssoSuccessUrlkey:"successUrl",ssoLoginUrl:window.location.origin+"/fwSecurity/ssoAuth/login.api",ssologinOutUrl:window.location.origin+"/fwSecurity/ssoAuth/logout.api"};class v{init(t){this.ssoConfig={...this.ssoConfig,...t}}ssoConfig=k;isSso=async e=>{if(!this.ssoConfig.sso)return!1;let s=!1;try{s=await t("/ssoAuthConfig/checkOnlyRedirect",{},{showError:!1})}catch(t){console.error("sso",t)}return e&&(s=await e()),!!s};ssoLogin=()=>{const{ssoSuccessUrlkey:t,ssoUrlSearchParams:e,ssoLoginUrl:s}=this.ssoConfig,a=new URLSearchParams(window.location.search.slice(1)),i=new URLSearchParams,n=window.location.href;return i.append(t,encodeURIComponent(n)),e.map(t=>{const e=a.get(t);e&&i.append(t,e)}),window.location.href=`${s}?${i.toString()}`,!1};ssoLoginOut=()=>{window.location.href=this.ssoConfig.ssologinOutUrl}}class D{getValidateCodeImage=e=>function(e={}){return t("/authentication/getValidateCode",{data:e,serviceId:"fwSecurity"})}(e);sliderVerificationCodeImage=()=>t("/authentication/sliderVerificationCode",{method:"POST",serviceId:"fwSecurity"});checkCaptcha=e=>{return s=e,t("/authentication/checkCaptcha",{method:"POST",data:{...s},serviceId:"fwSecurity"});var s}}class A extends C{ssoLogin;validate;noCheckPermissionsPath=[];ssoCallback;constructor(){super(),this.ssoLogin=new v,this.validate=new D}init=(t,e="/",s)=>{this.BASE=e,this.ssoCallback=s,this.noCheckPermissionsPath=t?.noCheckPermissionsPath,this.ssoLogin.init(t),this.loginPathname=t?.loginPathname||"/login"};isNoLoginRequiredPage=()=>{const t=window.location.pathname,e=this.noCheckPermissionsPath?.some(e=>this.getRealPath(e)==t);return e};loginOut=async()=>{await this.ssoLogin.isSso(this.ssoCallback)&&this.ssoLogin.ssoLoginOut(),await this.baseLoginOut()};loginAuthentication=async e=>{var s;await(s=e,t("/authentication/beforeLoginCheckCode",{method:"POST",data:{...s},serviceId:"fwSecurity"})),this.loginSuccess()};redirectLogin=async()=>{if(this.ssoLogin.ssoConfig.sso){if(await this.ssoLogin.isSso())return this.ssoCallback()?(this.ssoLogin.ssoLogin(),!1):!!this.isNoLoginRequiredPage()||this.redirectBaseLogin()}return!!this.isNoLoginRequiredPage()||(!!this.isLoginPathname||await this.redirectBaseLogin())}}const M=new class{userStore;menuStore;loginStore;isSuperAdmin=!1;loginCallback;constructor(){this.userStore=new f,this.menuStore=new U,this.loginStore=new A}platformLanguages=[];productInfo={isProdEnv:!1,productName:""};get isPrd(){return this.productInfo?.isProdEnv}get userInfo(){return this.userStore.currentUser}get menuData(){return this.menuStore.menuData}findPlantform=async()=>{const e=await t("/platformManage/getPlatformAggregateInfo",{method:"POST"},{showError:!1});this.platformLanguages=e.platformLanguages,this.productInfo=e.productInfo};getAggregateInfo=async e=>{const s=await async function(){return t("/security/findUserAggregateInfo",{method:"POST"})}(),{user:a,startMenus:i,isSuperAdmin:n,...r}=s;this.userStore.setUserAggregateInfo({...r,currentUser:a}),this.isSuperAdmin=n;const c="function"==typeof e?await e(s):e;this.menuStore.init(o(c)?i:c,a.id)};init=async t=>{const{base:e="/",menuData:s,loginSuccessCallback:a,ssoCallback:i}=t;this.loginStore.init(t?.loginConfig,e,i);try{const t=await this.loginStore.chekToken();return t?(this.userStore.setUserIdentity(t),await this.getAggregateInfo(s),await l.findAllCodeList(),await p.findAllParameters(),await(a?.()),!0):await this.loginStore.redirectLogin()}catch(t){console.error(t)}return!1}};const b="company-v1";var T=new class{data={};getCompanyDataType=t=>`${b}-${t}`;getCompanyData=async e=>{const s=this.getCompanyDataType(e);if(this.data[s])return this.data[s];const a=await async function(e){return t("/companyData/getCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:b}),i=a?.bigData?JSON.parse(a.bigData):void 0;return this.data[s]=i,i};updateCompanyData=async(e,s)=>{const a=this.getCompanyDataType(e);return await async function(e){return t("/companyData/setCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:b,bigData:JSON.stringify(s)}),this.data[a]=s,s};removeCompanyData=async e=>{const s=this.getCompanyDataType(e);await async function(e){return t("/companyData/delCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:b}),delete this.data[s]}};const O=l,E=p,$=M.userStore,B=M.loginStore,N=M.menuStore;export{P as M,I as a,O as c,M as g,T as i,B as l,N as m,E as p,y as s,$ as u};
|
|
1
|
+
import{r as t}from"../request/index.js";import{groupBy as e,get as s,reduce as a,find as i,keyBy as n,pick as r,isEmpty as o,findIndex as c,isPlainObject as h,cloneDeep as u,mapValues as d,uniqBy as g}from"lodash-es";import m from"mitt";const l=new class{codeLists=[];codeMaps={};async findAllCodeList(){const s=await t("/codeList/findAll",{data:{},serviceId:"fwPlatform"})||[],a=e(s,"type");this.codeLists=s,this.codeMaps=a}getCodeLocaleList=t=>s(this.codeMaps,t,[]);getCodeLocaleName=(t,e)=>{const s=this.getCodeLocaleList(t);function n(t){const e=i(s,e=>e.value===String(t));return e?.name||""}if(Array.isArray(e)){const t=a(e,(t="",e="")=>t+","+n(e),"");return t.slice(1,t.length)}if(String(e).indexOf(",")>=0){const t=e.replace("[","").replace("]","").split(","),s=a(t,(t="",e="")=>t+","+n(e),"");return s.slice(1,s.length)}return n(e)}};l.getCodeLocaleList,l.getCodeLocaleName;const p=new class{parameterList=[];parameterMap={};findAllParameters=async()=>{const e=await t("/parameter/findAll",{serviceId:"fwPlatform",data:{}},{showError:!1})||[],s=n(e,"name");this.parameterList=e,this.parameterMap=s};getSystemParameterByName=t=>"string"==typeof t?this.parameterMap[t]:r(this.parameterMap,t)};const y=(({prefixKey:t="",storage:e=localStorage}={})=>new class{storage=e;prefixKey=t;getKey(t){return`${this.prefixKey}${t}`.toUpperCase()}set(t,e,s=604800){const a=JSON.stringify({value:e,expire:null!==s?(new Date).getTime()+1e3*s:null});this.storage.setItem(this.getKey(t),a)}get(t,e=null){const s=this.storage.getItem(this.getKey(t));if(s)try{const e=JSON.parse(s),{value:a,expire:i}=e;if(null===i||i>=Date.now())return a;this.remove(t)}catch(t){return console.error(t),e}return e}remove(t){this.storage.removeItem(this.getKey(t))}clear(){this.storage.clear()}setCookie(t,e,s=604800){document.cookie=`${this.getKey(t)}=${e}; Max-Age=${s}`}getCookie(t){const e=document.cookie.split("; ");for(let s=0,a=e.length;s<a;s++){const a=e[s].split("=");if(a[0]===this.getKey(t))return a[1]}return""}removeCookie(t){this.setCookie(t,1,-1)}clearCookie(){const t=document.cookie.match(/[^ =;]+(?==)/g);if(t)for(let e=t.length;e--;)document.cookie=t[e]+"=0;expire="+new Date(0).toUTCString()}})();class f{userIdentity={};currentUser={};isSuperAdmin=!1;roles=[];functions=[];delegations=[];userSetting={};users=[];getUserIdentity(){if(!o(this.userIdentity))return this.userIdentity;const t=y?.get("userIdentity");return t||{}}setUserIdentity(t){return this.userIdentity={...this.userIdentity,...t},y.set("userIdentity",this.userIdentity),this.userIdentity}clearUserIdentity(){y.remove("userIdentity"),this.userIdentity={}}setUserAggregateInfo=({delegations:t,roles:e,functions:s,isSuperAdmin:a,currentUser:i})=>{this.delegations=t,this.roles=e,this.functions=s,this.isSuperAdmin=a,this.currentUser=i};getUserSettingType=t=>`${this.currentUser.id}-${t}`;getUserSetting=async e=>{const s=this.getUserSettingType(e),a=this.currentUser.id;if(this.userSetting[s])return this.userSetting[s];const i=await async function(e){return t("/accountUserSelf/getUserData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:a+e}),n=i?.bigData?JSON.parse(i.bigData):void 0;return this.userSetting[s]=n,n};updateUserSetting=async(e,s)=>{const a=this.getUserSettingType(e),i=this.currentUser.id;return await async function(e,s){return t("/accountUserSelf/setUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:i+e,bigData:JSON.stringify(s)}),this.userSetting[a]=s,s};removeUserSetting=async e=>{const s=this.getUserSettingType(e),a=this.currentUser.id;await async function(e,s){return t("/accountUserSelf/delUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:a}),delete this.userSetting[s]};getUserInfo=async(e,a)=>{const i=c(this.users,t=>a?t.userLoginName===e:t.id===e);if(i>-1)return s(this.users,`[${i}]`);const n=a?await async function(e){return t("/security/getUserByUserLoginName",{method:"POST",data:{userLoginName:e},serviceId:"fwSecurity"})}(e):await async function(e){return t("/security/getUserById",{method:"POST",data:{id:e},serviceId:"fwSecurity"})}(e);return h(n)&&this.users.push(n),n}}const w=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,S=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,L=t=>w.test(t)||S.test(t)||0===t?.indexOf("/")?t:"/"+t,I="MENU_HISTORY_UPDATE",P="MENU_BREADCRUMBS_UPDATE";m();class U{menuDataMaps={};menuData=[];menuPathMaps={};breadcrumbs=[];menuHistorys=[];userId;emitter;constructor(){this.emitter=m()}addListenerMenuHistorys=t=>{this.emitter.on(I,t)};removeListenerMenuHistorys=t=>this.emitter.off(I,t);addListenerBreadcrumbs=t=>this.emitter.on(P,t);removeListenerBreadcrumbs=t=>this.emitter.off(P,t);getTreeMenuData=(t,e,s)=>t.map(t=>{const{id:a,path:i,leaf:n}=t,r=e[a],o={...t,key:a,path:s?s+L(i):L(i)};if(r&&!n){const t=this.getTreeMenuData(r,e,o.path);o.children=t}return this.menuDataMaps[o.path]=o,o}).sort((t,e)=>t.seqNum-e.seqNum);init=(t,s)=>{const a=u(t);if(o(a))return;const i=e(a,"parentResourceId"),{ROOT:n,...r}=i;this.menuData=this.getTreeMenuData(n,r),this.menuData=[...this.menuData];const c=d(this.menuDataMaps,"name");this.updateMenuMaps(c),this.initMenuHistorys(s)};updateMenuMaps=t=>{this.menuPathMaps={...this.menuPathMaps,...t};const e=this.menuHistorys.map(t=>{const e=this.menuPathMaps[t.pathname];return{pathname:t.pathname,name:e||t.name}}),s=this.breadcrumbs.map(t=>{const e=this.menuPathMaps[t.pathname];return{...t,name:e||t.name}});this.updatehistorys(e),this.updateBreadcrumbs(s)};liseterHistorys=t=>{let e=this.menuHistorys;this.menuDataMaps[t]?.leaf&&!e.some(e=>e.pathname===t)&&(e=[{pathname:t,name:this.menuPathMaps[t]},...e],this.updatehistorys(e))};updatehistorys=t=>{if(!this.userId)return;const e=t.map(t=>({...t,name:t.name?t.name:this.menuPathMaps[t.pathname]}));this.menuHistorys=e,this.menuHistorys=g(this.menuHistorys,"pathname"),this.emitter.emit(I,this.menuHistorys),y.set(`${this.userId}-menu-history`,this.menuHistorys)};initMenuHistorys=t=>{this.userId=t;const e=y.get(`${t}-menu-history`,this.menuHistorys);this.updatehistorys(e)};liseterBreadcrumbs=t=>{const e=t.split("/");let s=1;const a=[],i={pathname:t,name:this.menuPathMaps[t]};for(;s<e.length;){const t=e.slice(0,s).join("/");this.menuPathMaps[t]&&a.push({name:this.menuPathMaps[t],pathname:t}),s++}a.push(i),this.updateBreadcrumbs(a)};updateBreadcrumbs=t=>{this.breadcrumbs=t,this.breadcrumbs=g(this.breadcrumbs,"pathname"),this.emitter.emit(P,t)}}class C{loginPathname;BASE="/";get baseLoginPathname(){return`${this.BASE}${this.loginPathname?.replace("/","")}`}tokenValue="";get isLoginPathname(){const t=window.location.pathname;return this.baseLoginPathname==t}getRealPath=t=>`${this.BASE}${t.replace("/","")}`;chekToken=async()=>{const e=await t("/authentication/checkToken",{serviceId:"fwSecurity"},{showError:!1});return e&&this.isLoginPathname&&window.location.replace(this.BASE),e};getLoginMethod=async()=>t("/authentication/getLoginMethod",{serviceId:"fwSecurity"});redirectBaseLogin=async()=>{const t=window.location.pathname,e=window.location.href;if(this.isLoginPathname)return!0;const s=new URLSearchParams(window.location.search),a=new URLSearchParams;"true"===s.get("forceLocal")&&a.append("forceLocal","true"),t!==this.BASE&&"/"!==t&&a.append("redirectUrl",e);const i=decodeURIComponent(a.toString());return window.location.replace(`${this.baseLoginPathname}${i?"?"+decodeURIComponent(a.toString()):""}`),!1};checkPassword=async()=>"noPass"!==await t("/security/checkPasswordUpdateTime",{data:{}},{showError:!1})||(this.tokenValue=await t("/authentication/extractToken",{data:{}}),!1);refactorToken=async()=>{var e;await(e=this.tokenValue,t("/authentication/refactorToken",{data:{value:e}}))};login=async t=>{const e=await this.baseLogin(t);return e.error,e};baseLogin=async e=>{const s={error:void 0,data:void 0};try{const a=await function(e){return t("/authentication/login",{data:e,serviceId:"fwSecurity"})}(e),{userToken:i,traceId:n}=a;if(i){s.data=a;return await this.checkPassword()||(s.error="passwordExpiration"),s}return n?(s.data=a,s.error="SLIDER_VERIFICATION_LOGIN",s):(s.error="passwordError",s)}catch(t){return s.error="validateError",s}};loginSuccess=()=>{let t=new URLSearchParams(window.location.search).get("redirectUrl");t?window.location.href=t:window.location.replace(this.BASE)};baseLoginOut=async e=>{const s=new URLSearchParams,a=window.location.href;window.location.pathname!==this.BASE&&s.append("redirectUrl",a),await t("/authentication/logout",{data:{},serviceId:"fwSecurity"}),e?window.location.replace(`${this.baseLoginPathname}?${s.toString()}`):window.location.replace(this.baseLoginPathname)}}const k={sso:!1,ssoUrlSearchParams:["ticket"],ssoSuccessUrlkey:"successUrl",ssoLoginUrl:window.location.origin+"/fwSecurity/ssoAuth/login.api",ssologinOutUrl:window.location.origin+"/fwSecurity/ssoAuth/logout.api",ssoCheckTokenUrl:window.location.origin+"/fwSecurity/ssoAuth/checkToken.api"};class v{init(t){this.ssoConfig={...this.ssoConfig,...t}}ssoConfig=k;isSso=async e=>{if(!this.ssoConfig.sso)return!1;let s=!1;try{s=await(a=this.ssoConfig.ssoCheckTokenUrl,t(a,{},{showError:!1}))}catch(t){console.error("sso",t)}var a;return e&&(s=await e()),!!s};ssoLogin=()=>{const{ssoSuccessUrlkey:t,ssoUrlSearchParams:e,ssoLoginUrl:s}=this.ssoConfig,a=new URLSearchParams(window.location.search.slice(1)),i=new URLSearchParams,n=window.location.href;return i.append(t,encodeURIComponent(n)),e.map(t=>{const e=a.get(t);e&&i.append(t,e)}),window.location.href=`${s}?${i.toString()}`,!1};ssoLoginOut=()=>{window.location.href=this.ssoConfig.ssologinOutUrl}}class D{getValidateCodeImage=e=>function(e={}){return t("/authentication/getValidateCode",{data:e,serviceId:"fwSecurity"})}(e);sliderVerificationCodeImage=()=>t("/authentication/sliderVerificationCode",{method:"POST",serviceId:"fwSecurity"});checkCaptcha=e=>{return s=e,t("/authentication/checkCaptcha",{method:"POST",data:{...s},serviceId:"fwSecurity"});var s}}class T extends C{ssoLogin;validate;noCheckPermissionsPath=[];ssoCallback;constructor(){super(),this.ssoLogin=new v,this.validate=new D}init=(t,e="/",s)=>{this.BASE=e,this.ssoCallback=s,this.noCheckPermissionsPath=t?.noCheckPermissionsPath,this.ssoLogin.init(t),this.loginPathname=t?.loginPathname||"/login"};isNoLoginRequiredPage=()=>{const t=window.location.pathname,e=this.noCheckPermissionsPath?.some(e=>this.getRealPath(e)==t);return e};loginOut=async()=>{await this.ssoLogin.isSso(this.ssoCallback)&&this.ssoLogin.ssoLoginOut(),await this.baseLoginOut()};loginAuthentication=async e=>{var s;await(s=e,t("/authentication/beforeLoginCheckCode",{method:"POST",data:{...s},serviceId:"fwSecurity"})),this.loginSuccess()};redirectLogin=async()=>{if(this.ssoLogin.ssoConfig.sso){if(await this.ssoLogin.isSso())return this.ssoCallback()?(this.ssoLogin.ssoLogin(),!1):!!this.isNoLoginRequiredPage()||this.redirectBaseLogin()}return!!this.isNoLoginRequiredPage()||(!!this.isLoginPathname||await this.redirectBaseLogin())}}const A=new class{userStore;menuStore;loginStore;isSuperAdmin=!1;loginCallback;constructor(){this.userStore=new f,this.menuStore=new U,this.loginStore=new T}platformLanguages=[];productInfo={isProdEnv:!1,productName:""};get isPrd(){return this.productInfo?.isProdEnv}get userInfo(){return this.userStore.currentUser}get menuData(){return this.menuStore.menuData}findPlantform=async()=>{const e=await t("/platformManage/getPlatformAggregateInfo",{method:"POST"},{showError:!1});this.platformLanguages=e.platformLanguages,this.productInfo=e.productInfo};getAggregateInfo=async e=>{const s=await async function(){return t("/security/findUserAggregateInfo",{method:"POST"})}(),{user:a,startMenus:i,isSuperAdmin:n,...r}=s;this.userStore.setUserAggregateInfo({...r,currentUser:a}),this.isSuperAdmin=n;const c="function"==typeof e?await e(s):e;this.menuStore.init(o(c)?i:c,a.id)};init=async t=>{const{base:e="/",menuData:s,loginSuccessCallback:a,ssoCallback:i}=t;this.loginStore.init(t?.loginConfig,e,i);try{const t=await this.loginStore.chekToken();return t?(this.userStore.setUserIdentity(t),await this.getAggregateInfo(s),await l.findAllCodeList(),await p.findAllParameters(),await(a?.()),!0):await this.loginStore.redirectLogin()}catch(t){console.error(t)}return!1}};const M="company-v1";var b=new class{data={};getCompanyDataType=t=>`${M}-${t}`;getCompanyData=async e=>{const s=this.getCompanyDataType(e);if(this.data[s])return this.data[s];const a=await async function(e){return t("/companyData/getCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:M}),i=a?.bigData?JSON.parse(a.bigData):void 0;return this.data[s]=i,i};updateCompanyData=async(e,s)=>{const a=this.getCompanyDataType(e);return await async function(e){return t("/companyData/setCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:M,bigData:JSON.stringify(s)}),this.data[a]=s,s};removeCompanyData=async e=>{const s=this.getCompanyDataType(e);await async function(e){return t("/companyData/delCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:M}),delete this.data[s]}};const O=l,E=p,$=A.userStore,B=A.loginStore,N=A.menuStore;export{P as M,I as a,O as c,A as g,b as i,B as l,N as m,E as p,y as s,$ as u};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gant-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/core/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@ant-design/colors": "^7.0.2",
|
|
25
25
|
"@ctrl/tinycolor": "^4.2.0",
|
|
26
26
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
|
|
27
|
+
"@rsdoctor/rspack-plugin": "^1.5.10",
|
|
27
28
|
"@root/walk": "^1.1.0",
|
|
28
29
|
"@rspack/core": "^2.0.1",
|
|
29
30
|
"@rspack/dev-server": "^2.0.1",
|
|
@@ -63,7 +64,6 @@
|
|
|
63
64
|
"url-loader": "^4.1.1",
|
|
64
65
|
"vue-loader": "^17.4.2",
|
|
65
66
|
"webpack": "^5.90.3",
|
|
66
|
-
"webpack-bundle-analyzer": "^4.10.1",
|
|
67
67
|
"webpack-dev-server": "^4.7.4"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
package/rollup.config.js
CHANGED