gant-core 2.0.2 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/bin/index.js +21 -1
  3. package/bin/styletext-loader.mjs +30 -0
  4. package/lib/cli/config/index.js +155 -2
  5. package/lib/cli/config/index.mjs +3 -0
  6. package/lib/cli/copyfiles/index.js +33 -2
  7. package/lib/cli/copyfiles/index.mjs +3 -0
  8. package/lib/cli/create/config/index.js +1226 -4
  9. package/lib/cli/create/config/index.mjs +11 -0
  10. package/lib/cli/create/index.js +4 -2
  11. package/lib/cli/create/index.mjs +3 -0
  12. package/lib/cli/create/module/index.js +33214 -2
  13. package/lib/cli/create/module/index.mjs +3 -0
  14. package/lib/cli/i18n/index.js +22179 -3
  15. package/lib/cli/i18n/index.mjs +10 -0
  16. package/lib/cli/i18n/utils.js +180 -2
  17. package/lib/cli/i18n/utils.mjs +3 -0
  18. package/lib/cli/index.js +3655 -2
  19. package/lib/cli/index.mjs +3 -0
  20. package/lib/cli/routes/index.js +75 -2
  21. package/lib/cli/routes/index.mjs +3 -0
  22. package/lib/cli/tsconfig/index.js +70 -2
  23. package/lib/cli/tsconfig/index.mjs +3 -0
  24. package/lib/cli/utils/detectPort.js +120 -2
  25. package/lib/cli/utils/detectPort.mjs +3 -0
  26. package/lib/cli/utils/getJavascriptfile.js +14 -2
  27. package/lib/cli/utils/getJavascriptfile.mjs +3 -0
  28. package/lib/cli/utils/index.js +4948 -2
  29. package/lib/cli/utils/index.mjs +3 -0
  30. package/lib/cli/webpack/Webpack.js +60 -2
  31. package/lib/cli/webpack/Webpack.mjs +3 -0
  32. package/lib/cli/webpack/config/analyzer.config.js +17 -2
  33. package/lib/cli/webpack/config/analyzer.config.mjs +3 -0
  34. package/lib/cli/webpack/config/browsers.js +13 -2
  35. package/lib/cli/webpack/config/browsers.mjs +3 -0
  36. package/lib/cli/webpack/config/cssRules.js +80 -2
  37. package/lib/cli/webpack/config/cssRules.mjs +3 -0
  38. package/lib/cli/webpack/config/default.config.js +179 -2
  39. package/lib/cli/webpack/config/default.config.mjs +3 -0
  40. package/lib/cli/webpack/config/development.config.js +45 -2
  41. package/lib/cli/webpack/config/development.config.mjs +3 -0
  42. package/lib/cli/webpack/config/framework/index.js +25 -2
  43. package/lib/cli/webpack/config/framework/index.mjs +3 -0
  44. package/lib/cli/webpack/config/framework/react.js +23 -2
  45. package/lib/cli/webpack/config/framework/react.mjs +3 -0
  46. package/lib/cli/webpack/config/framework/vue.js +33 -2
  47. package/lib/cli/webpack/config/framework/vue.mjs +3 -0
  48. package/lib/cli/webpack/config/index.js +23 -2
  49. package/lib/cli/webpack/config/index.mjs +3 -0
  50. package/lib/cli/webpack/config/production.config.js +74 -2
  51. package/lib/cli/webpack/config/production.config.mjs +3 -0
  52. package/lib/cli/webpack/plugins/copy.js +20 -2
  53. package/lib/cli/webpack/plugins/copy.mjs +3 -0
  54. package/lib/cli/webpack/plugins/index.js +4 -2
  55. package/lib/cli/webpack/plugins/index.mjs +3 -0
  56. package/package.json +2 -2
  57. package/rollup.config.js +5 -4
  58. package/.changeset/README.md +0 -8
  59. package/.changeset/config.json +0 -11
  60. package/lib/cli/acorn.js +0 -3
  61. package/lib/cli/angular.js +0 -3
  62. package/lib/cli/babel.js +0 -3
  63. package/lib/cli/estree.js +0 -3
  64. package/lib/cli/flow.js +0 -3
  65. package/lib/cli/glimmer.js +0 -3
  66. package/lib/cli/graphql.js +0 -3
  67. package/lib/cli/html.js +0 -3
  68. package/lib/cli/markdown.js +0 -3
  69. package/lib/cli/meriyah.js +0 -3
  70. package/lib/cli/msmain.js +0 -65
  71. package/lib/cli/postcss.js +0 -3
  72. package/lib/cli/typescript.js +0 -3
  73. package/lib/cli/yaml.js +0 -3
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{C as t}from"./config/index.mjs";import{W as e}from"./webpack/Webpack.mjs";import i from"chokidar";import n,{resolve as s}from"path";import{g as r,j as o,w as a,s as h,d as l,t as p,a as c}from"./utils/index.mjs";import{g as m}from"./routes/index.mjs";import{g as u}from"./tsconfig/index.mjs";import{c as d,a as g}from"./copyfiles/index.mjs";import{r as f}from"./webpack/config/framework/index.mjs";import _ from"fs";import{fileURLToPath as v}from"node:url";import{e as b}from"./create/config/index.mjs";import{c as O}from"./create/module/index.mjs";import{g as A,a as C}from"./utils/detectPort.mjs";import w from"events";import y from"child_process";import x from"process";import{i as E}from"./i18n/index.mjs";import"./utils/getJavascriptfile.mjs";import"jiti";import"@rspack/core";import"@rspack/dev-server";import"./webpack/config/index.mjs";import"./webpack/config/production.config.mjs";import"./webpack/plugins/copy.mjs";import"compression-webpack-plugin";import"./webpack/config/default.config.mjs";import"module";import"./webpack/config/cssRules.mjs";import"./webpack/config/browsers.mjs";import"./webpack/config/development.config.mjs";import"./webpack/config/analyzer.config.mjs";import"prettier";import"net";import"./webpack/config/framework/react.mjs";import"@rspack/plugin-react-refresh";import"./webpack/config/framework/vue.mjs";import"node:tty";import"tty";import"readline";import"os";import"assert";import"stream";import"buffer";import"util";import"string_decoder";import"node:process";import"node:assert";import"node:path";import"node:os";import"node:crypto";import"node:stream";import"node:readline";import"http";import"https";import"url";import"crypto";import"./i18n/utils.mjs";import"http2";import"zlib";var k;async function $(l="development"){process.env.SRC="true",process.env.NODE_ENV=l;const p=process.cwd(),c=new t({cwd:p});let _=c.getUserConfig();function v(t){const i=r(),n=s(p,i,".gant");o(n),a(s(n,"setting.ts"),`export default ${JSON.stringify(t.setting||{})}`),a(s(n,"microServiceMap.ts"),`export default ${JSON.stringify(t.microServiceMap||{})}`);const c={[t?.name||"@@"]:p,...t?.resolve?.alias},_=[p];h(t.packages).map(e=>{const i=t.packages[e];c[e]=i,_.push(i)}),u(n,{paths:c,includes:_,cwd:p,framework:f(t)});const v=[...Object.keys(t.packages).map(e=>t.packages[e]),p];d(n,v),g(n,v.map(t=>s(t,"public"))),m(s(n,"./routes"),t.routes);return new e(t,p,l)}c.configFiles;let b=v(_);if("development"===l){await b.runServer();let O=null;function A(t){const e=[...Object.keys(_.packages).map(t=>_.packages[t]),p].map(t=>s(t,"public")),r=c.configFiles?.map(t=>n.dirname(t))||[],o=[...new Set([...r,...e])];O=i.watch(o,{}),O.on("change",async t=>{O?.close(),await(b.devServer?.stop()),_=c.getUserConfig(),b=v(_),await b.runServer({open:!1}),A()})}return void A()}b.runBuild()}!function(t){t.development="development",t.production="production",t.test="test"}(k||(k={}));const S=n.dirname(v(import.meta.url));function H(){const e=process.cwd(),i=new t({cwd:e});let n=i.getMsUserConfig();const o=r(),h=s(e,o,".gant");_.existsSync(h)||_.mkdirSync(h,{recursive:!0}),a(s(h,"setting.ts"),`export default ${JSON.stringify(n.setting||{})}`),a(s(h,"microServiceMap.ts"),`export default ${JSON.stringify(n.microServiceMap||{})}`);const l=n?.name||"main",p={},c={...n?.resolve?.alias},m=[e];return n.mfa?.entry&&(p[l]={entry:n.mfa?.entry,publicPath:"string"==typeof n.mfa?.publicPath?[n.mfa?.publicPath]:n.mfa?.publicPath,port:n.mfa?.port,htmlTemplatePath:n.mfa.htmlTemplatePath,apps:[e],base:n.mfa.base,isMaster:!0}),n.mfa.pages?.map?.(t=>{const e="string"==typeof t.path?[t.path]:t.path,i="string"==typeof t.publicPath?[t.publicPath]:t.publicPath;m.push(...e),p[t.name]={entry:t.entry||n.mfa.subEntry,publicPath:i,port:t.port,htmlTemplatePath:t.htmlTemplatePath,apps:e,base:t.base,url:t.url}}),a(s(h,"appMaps.ts"),`export default ${JSON.stringify(p)}`),u(h,{includes:m,paths:c,cwd:e,framework:f(n),createIncludes:!1}),{userConfig:n,msName:l,msConfig:p,configManager:i}}async function V(t="development",e){process.env.SRC="false",process.env.NODE_ENV=t;const{userConfig:i,msName:n,msConfig:s,configManager:r}=H();if(l(i.mfa))return;const o=e||n,a=s[o];a&&await F(r,t,i,o,a)}async function F(a,h,l,u,f,v=!0){const O=process.cwd(),A=r(),C=p(l);const w=f.apps?.map?.(e=>t.getMainConfigFile({cwd:e}))?.filter?.(t=>!!t);let y=function(){const t=s(O,A,`.gant/${u}`);o(t),d(t,f.apps),g(t,f.publicPath);const i=_.readFileSync(s(S,"./template/msentry.txt"),"utf-8"),r=b.compile(i);_.writeFileSync(s(t,"index.ts"),r({entry:n.posix.join("../../",f.entry)}));const l=a.getMsPagesUserConfig(f.apps);return m(s(t,"./routes"),l.routes),C.entry={index:s(t,"index.ts")},C.base=c(f,"base","/"),C.define={...C.define,APP_NAME:u},C.devServer={...C.devServer,port:f.port,static:{directory:s(t,"public")}},C.output={...C.output,chunkLoadingGlobal:`webpackJsonp_${u}`,chunkFilename:`${u}.[name].[id].[contenthash].js`,path:s(O,`dist/${u}`)},C.outputPathDir=s(O,`dist/${u}`),C.publicPathDir=s(O,`.gant/${u}/public`),new e(C,O,h)}();if("development"===h){await y.runServer({open:v});let x=null;function E(t){const e=(f.publicPath||[]).filter(Boolean),n=[...new Set([...t,...e])];x=i.watch(n),x.on("change",async t=>{await(y.devServer?.stop());const{userConfig:e,msConfig:i}=H();x.close(),await F(a,h,e,u,i[u],!1)})}return void E(w)}y.runBuild()}var P={exports:{}},N={},j={};let D=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}};j.CommanderError=D,j.InvalidArgumentError=class extends D{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:T}=j;N.Argument=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new T(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},N.humanReadableArgName=function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"};var M={},I={};const{humanReadableArgName:W}=N;I.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(t){const e=t.commands.filter(t=>!t._hidden);if(t._hasImplicitHelpCommand()){const[,i,n]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),s=t.createCommand(i).helpOption(!1);s.description(t._helpCommandDescription),n&&s.arguments(n),e.push(s)}return this.sortSubcommands&&e.sort((t,e)=>t.name().localeCompare(e.name())),e}compareOptions(t,e){const i=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){const e=t.options.filter(t=>!t.hidden),i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag),n=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||n){let s;s=i?n?t.createOption(t._helpFlags,t._helpDescription):t.createOption(t._helpShortFlag,t._helpDescription):t.createOption(t._helpLongFlag,t._helpDescription),e.push(s)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let i=t.parent;i;i=i.parent){const t=i.options.filter(t=>!t.hidden);e.push(...t)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(t=>t.description)?t.registeredArguments:[]}subcommandTerm(t){const e=t.registeredArguments.map(t=>W(t)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((t,i)=>Math.max(t,e.subcommandTerm(i).length),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((t,i)=>Math.max(t,e.optionTerm(i).length),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((t,i)=>Math.max(t,e.optionTerm(i).length),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((t,i)=>Math.max(t,e.argumentTerm(i).length),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let e=t.parent;e;e=e.parent)i=e.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue){(t.required||t.optional||t.isBoolean()&&"boolean"==typeof t.defaultValue)&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}return void 0!==t.presetArg&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),void 0!==t.envVar&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){const i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){const i=e.padWidth(t,e),n=e.helpWidth||80;function s(t,s){if(s){const r=`${t.padEnd(i+2)}${s}`;return e.wrap(r,n-2,i+2)}return t}function r(t){return t.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${e.commandUsage(t)}`,""];const a=e.commandDescription(t);a.length>0&&(o=o.concat([e.wrap(a,n,0),""]));const h=e.visibleArguments(t).map(t=>s(e.argumentTerm(t),e.argumentDescription(t)));h.length>0&&(o=o.concat(["Arguments:",r(h),""]));const l=e.visibleOptions(t).map(t=>s(e.optionTerm(t),e.optionDescription(t)));if(l.length>0&&(o=o.concat(["Options:",r(l),""])),this.showGlobalOptions){const i=e.visibleGlobalOptions(t).map(t=>s(e.optionTerm(t),e.optionDescription(t)));i.length>0&&(o=o.concat(["Global Options:",r(i),""]))}const p=e.visibleCommands(t).map(t=>s(e.subcommandTerm(t),e.subcommandDescription(t)));return p.length>0&&(o=o.concat(["Commands:",r(p),""])),o.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,n=40){const s=new RegExp("[\\n][ \\f\\t\\v   -    \ufeff]+");if(t.match(s))return t;const r=e-i;if(r<n)return t;const o=t.slice(0,i),a=t.slice(i).replace("\r\n","\n"),h=" ".repeat(i),l="\\s​",p=new RegExp(`\n|.{1,${r-1}}([${l}]|$)|[^${l}]+?([${l}]|$)`,"g");return o+(a.match(p)||[]).map((t,e)=>"\n"===t?"":(e>0?h:"")+t.trimEnd()).join("\n")}};var L={};const{InvalidArgumentError:q}=j;function U(t){let e,i;const n=t.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(e=n.shift()),i=n.shift(),!e&&/^-[^-]$/.test(i)&&(e=i,i=void 0),{shortFlag:e,longFlag:i}}L.Option=class{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;const i=U(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return"string"==typeof t&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new q(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},L.splitOptionFlags=U,L.DualOptions=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,e)=>{this.positiveOptions.has(e)&&this.dualOptions.add(e)})}valueFromOption(t,e){const i=e.attributeName();if(!this.dualOptions.has(i))return!0;const n=this.negativeOptions.get(i).presetArg,s=void 0!==n&&n;return e.negate===(s===t)}};var G={};G.suggestSimilar=function(t,e){if(!e||0===e.length)return"";e=Array.from(new Set(e));const i=t.startsWith("--");i&&(t=t.slice(2),e=e.map(t=>t.slice(2)));let n=[],s=3;return e.forEach(e=>{if(e.length<=1)return;const i=function(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);const i=[];for(let e=0;e<=t.length;e++)i[e]=[e];for(let t=0;t<=e.length;t++)i[0][t]=t;for(let n=1;n<=e.length;n++)for(let s=1;s<=t.length;s++){let r=1;r=t[s-1]===e[n-1]?0:1,i[s][n]=Math.min(i[s-1][n]+1,i[s][n-1]+1,i[s-1][n-1]+r),s>1&&n>1&&t[s-1]===e[n-2]&&t[s-2]===e[n-1]&&(i[s][n]=Math.min(i[s][n],i[s-2][n-2]+1))}return i[t.length][e.length]}(t,e),r=Math.max(t.length,e.length);(r-i)/r>.4&&(i<s?(s=i,n=[e]):i===s&&n.push(e))}),n.sort((t,e)=>t.localeCompare(e)),i&&(n=n.map(t=>`--${t}`)),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""};const R=w.EventEmitter,J=y,B=n,z=_,Y=x,{Argument:K,humanReadableArgName:Q}=N,{CommanderError:X}=j,{Help:Z}=I,{Option:tt,splitOptionFlags:et,DualOptions:it}=L,{suggestSimilar:nt}=G;function st(t,e){t._hasHelpOption&&e.find(e=>e===t._helpLongFlag||e===t._helpShortFlag)&&(t.outputHelp(),t._exit(0,"commander.helpDisplayed","(outputHelp)"))}function rt(t){return t.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i,n="127.0.0.1",s="9229";return null!==(i=t.match(/^(--inspect(-brk)?)$/))?e=i[1]:null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(e=i[1],/^\d+$/.test(i[3])?s=i[3]:n=i[3]):null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=i[1],n=i[3],s=i[4]),e&&"0"!==s?`${e}=${n}:${parseInt(s)+1}`:t})}M.Command=class t extends R{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>Y.stdout.write(t),writeErr:t=>Y.stderr.write(t),getOutHelpWidth:()=>Y.stdout.isTTY?Y.stdout.columns:void 0,getErrHelpWidth:()=>Y.stderr.isTTY?Y.stderr.columns:void 0,outputError:(t,e)=>e(t)},this._hidden=!1,this._hasHelpOption=!0,this._helpFlags="-h, --help",this._helpDescription="display help for command",this._helpShortFlag="-h",this._helpLongFlag="--help",this._addImplicitHelpCommand=void 0,this._helpCommandName="help",this._helpCommandnameAndArgs="help [command]",this._helpCommandDescription="display help for command",this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._hasHelpOption=t._hasHelpOption,this._helpFlags=t._helpFlags,this._helpDescription=t._helpDescription,this._helpShortFlag=t._helpShortFlag,this._helpLongFlag=t._helpLongFlag,this._helpCommandName=t._helpCommandName,this._helpCommandnameAndArgs=t._helpCommandnameAndArgs,this._helpCommandDescription=t._helpCommandDescription,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){const t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let n=e,s=i;"object"==typeof n&&null!==n&&(s=n,n=null),s=s||{};const[,r,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(r);return n&&(a.description(n),a._executableHandler=!0),s.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!s.noHelp&&!s.hidden),a._executableFile=s.executableFile||null,o&&a.arguments(o),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(e){return new t(e)}createHelp(){return Object.assign(new Z,this.configureHelp())}configureHelp(t){return void 0===t?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return void 0===t?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return"string"!=typeof t&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this.commands.push(t),t.parent=this,this}createArgument(t,e){return new K(t,e)}argument(t,e,i,n){const s=this.createArgument(t,e);return"function"==typeof i?s.default(n).argParser(i):s.default(i),this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){const e=this.registeredArguments.slice(-1)[0];if(e&&e.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&void 0!==t.defaultValue&&void 0===t.parseArg)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}addHelpCommand(t,e){return!1===t?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,"string"==typeof t&&(this._helpCommandName=t.split(" ")[0],this._helpCommandnameAndArgs=t),this._helpCommandDescription=e||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return void 0===this._addImplicitHelpCommand?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(t,e){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return this._exitCallback=t||(t=>{if("commander.executeSubCommandAsync"!==t.code)throw t}),this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new X(t,e,i)),Y.exit(t)}action(t){return this._actionHandler=e=>{const i=this.registeredArguments.length,n=e.slice(0,i);return this._storeOptionsAsProperties?n[i]=this:n[i]=this.opts(),n.push(this),t.apply(this,n)},this}createOption(t,e){return new tt(t,e)}_callParseArg(t,e,i,n){try{return t.parseArg(e,i)}catch(t){if("commander.invalidArgument"===t.code){const e=`${n} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}addOption(t){const e=t.name(),i=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");this._findOption(e)||this.setOptionValueWithSource(i,void 0===t.defaultValue||t.defaultValue,"default")}else void 0!==t.defaultValue&&this.setOptionValueWithSource(i,t.defaultValue,"default");this.options.push(t);const n=(e,n,s)=>{null==e&&void 0!==t.presetArg&&(e=t.presetArg);const r=this.getOptionValue(i);null!==e&&t.parseArg?e=this._callParseArg(t,e,r,n):null!==e&&t.variadic&&(e=t._concatValue(e,r)),null==e&&(e=!t.negate&&(!(!t.isBoolean()&&!t.optional)||"")),this.setOptionValueWithSource(i,e,s)};return this.on("option:"+e,e=>{const i=`error: option '${t.flags}' argument '${e}' is invalid.`;n(e,i,"cli")}),t.envVar&&this.on("optionEnv:"+e,e=>{const i=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;n(e,i,"env")}),this}_optionEx(t,e,i,n,s){if("object"==typeof e&&e instanceof tt)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const r=this.createOption(e,i);if(r.makeOptionMandatory(!!t.mandatory),"function"==typeof n)r.default(s).argParser(n);else if(n instanceof RegExp){const t=n;n=(e,i)=>{const n=t.exec(e);return n?n[0]:i},r.default(s).argParser(n)}else r.default(n);return this.addOption(r)}option(t,e,i,n){return this._optionEx({},t,e,i,n)}requiredOption(t,e,i,n){return this._optionEx({mandatory:!0},t,e,i,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){if(this._passThroughOptions=!!t,this.parent&&t&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,i){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(i=>{void 0!==i.getOptionValueSource(t)&&(e=i.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");let i;switch(e=e||{},void 0===t&&(t=Y.argv,Y.versions&&Y.versions.electron&&(e.from="electron")),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":Y.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,e){const i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){const i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),this}_executeSubCommand(t,e){e=e.slice();let i=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function s(t,e){const i=B.resolve(t,e);if(z.existsSync(i))return i;if(n.includes(B.extname(e)))return;const s=n.find(t=>z.existsSync(`${i}${t}`));return s?`${i}${s}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r,o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let t;try{t=z.realpathSync(this._scriptPath)}catch(e){t=this._scriptPath}a=B.resolve(B.dirname(t),a)}if(a){let e=s(a,o);if(!e&&!t._executableFile&&this._scriptPath){const i=B.basename(this._scriptPath,B.extname(this._scriptPath));i!==this._name&&(e=s(a,`${i}-${t._name}`))}o=e||o}if(i=n.includes(B.extname(o)),"win32"!==Y.platform?i?(e.unshift(o),e=rt(Y.execArgv).concat(e),r=J.spawn(Y.argv[0],e,{stdio:"inherit"})):r=J.spawn(o,e,{stdio:"inherit"}):(e.unshift(o),e=rt(Y.execArgv).concat(e),r=J.spawn(Y.execPath,e,{stdio:"inherit"})),!r.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{Y.on(t,()=>{!1===r.killed&&null===r.exitCode&&r.kill(t)})})}const h=this._exitCallback;h?r.on("close",()=>{h(new X(Y.exitCode||0,"commander.executeSubCommandAsync","(close)"))}):r.on("close",Y.exit.bind(Y)),r.on("error",e=>{if("ENOENT"===e.code){const e=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${o}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${e}`;throw new Error(i)}if("EACCES"===e.code)throw new Error(`'${o}' not executable`);if(h){const t=new X(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,h(t)}else Y.exit(1)}),this.runningCommand=r}_dispatchSubcommand(t,e,i){const n=this._findCommand(t);let s;return n||this.help({error:!0}),s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(!n._executableHandler)return n._parseCommand(e,i);this._executeSubCommand(n,e.concat(i))}),s}_dispatchHelpCommand(t){t||this.help();const e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._helpLongFlag||this._helpShortFlag])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const t=(t,e,i)=>{let n=e;if(null!==e&&t.parseArg){const s=`error: command-argument value '${e}' is invalid for argument '${t.name()}'.`;n=this._callParseArg(t,e,i,s)}return n};this._checkNumberOfArguments();const e=[];this.registeredArguments.forEach((i,n)=>{let s=i.defaultValue;i.variadic?n<this.args.length?(s=this.args.slice(n),i.parseArg&&(s=s.reduce((e,n)=>t(i,n,e),i.defaultValue))):void 0===s&&(s=[]):n<this.args.length&&(s=this.args[n],i.parseArg&&(s=t(i,s,i.defaultValue))),e[n]=s}),this.processedArgs=e}_chainOrCall(t,e){return t&&t.then&&"function"==typeof t.then?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let i=t;const n=[];return this._getCommandAndAncestors().reverse().filter(t=>void 0!==t._lifeCycleHooks[e]).forEach(t=>{t._lifeCycleHooks[e].forEach(e=>{n.push({hookedCommand:t,callback:e})})}),"postAction"===e&&n.reverse(),n.forEach(t=>{i=this._chainOrCall(i,()=>t.callback(t.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,e,i){let n=t;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach(t=>{n=this._chainOrCall(n,()=>t(this,e))}),n}_parseCommand(t,e){const i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName)return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return st(this,e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),st(this,i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){let i;return n(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,()=>this._actionHandler(this.processedArgs)),this.parent&&(i=this._chainOrCall(i,()=>{this.parent.emit(s,t,e)})),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&void 0===t.getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){const t=this.options.filter(t=>{const e=t.attributeName();return void 0!==this.getOptionValue(e)&&"default"!==this.getOptionValueSource(e)}),e=t.filter(t=>t.conflictsWith.length>0);e.forEach(e=>{const i=t.find(t=>e.conflictsWith.includes(t.attributeName()));i&&this._conflictingOption(e,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){const e=[],i=[];let n=e;const s=t.slice();function r(t){return t.length>1&&"-"===t[0]}let o=null;for(;s.length;){const t=s.shift();if("--"===t){n===i&&n.push(t),n.push(...s);break}if(!o||r(t)){if(o=null,r(t)){const e=this._findOption(t);if(e){if(e.required){const t=s.shift();void 0===t&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;s.length>0&&!r(s[0])&&(t=s.shift()),this.emit(`option:${e.name()}`,t)}else this.emit(`option:${e.name()}`);o=e.variadic?e:null;continue}}if(t.length>2&&"-"===t[0]&&"-"!==t[1]){const e=this._findOption(`-${t[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,t.slice(2)):(this.emit(`option:${e.name()}`),s.unshift(`-${t.slice(2)}`));continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("="),i=this._findOption(t.slice(0,e));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(e+1));continue}}if(r(t)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===i.length){if(this._findCommand(t)){e.push(t),s.length>0&&i.push(...s);break}if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){e.push(t),s.length>0&&e.push(...s);break}if(this._defaultCommandName){i.push(t),s.length>0&&i.push(...s);break}}if(this._passThroughOptions){n.push(t),s.length>0&&n.push(...s);break}n.push(t)}else this.emit(`option:${o.name()}`,t)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let i=0;i<e;i++){const e=this.options[i].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const i=e||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in Y.env){const e=t.attributeName();(void 0===this.getOptionValue(e)||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,Y.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){const t=new it(this.options),e=t=>void 0!==this.getOptionValue(t)&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter(i=>void 0!==i.implied&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(t=>{Object.keys(t.implied).filter(t=>!e(t)).forEach(e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")})})}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const i=t=>{const e=t.attributeName(),i=this.getOptionValue(e),n=this.options.find(t=>t.negate&&e===t.attributeName()),s=this.options.find(t=>!t.negate&&e===t.attributeName());return n&&(void 0===n.presetArg&&!1===i||void 0!==n.presetArg&&i===n.presetArg)?n:s||t},n=t=>{const e=i(t),n=e.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${e.envVar}'`:`option '${e.flags}'`},s=`error: ${n(t)} cannot be used with ${n(e)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[],n=this;do{const t=n.createHelp().visibleOptions(n).filter(t=>t.long).map(t=>t.long);i=i.concat(t),n=n.parent}while(n&&!n._enablePositionalOptions);e=nt(t,i)}const i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this.registeredArguments.length,i=1===e?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach(t=>{i.push(t.name()),t.alias()&&i.push(t.alias())}),e=nt(t,i)}const i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(void 0===t)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";const n=this.createOption(e,i);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}\n`),this._exit(0,"commander.version",t)}),this}description(t,e){return void 0===t&&void 0===e?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return void 0===t?this._summary:(this._summary=t,this)}alias(t){if(void 0===t)return this._aliases[0];let e=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");return e._aliases.push(t),this}aliases(t){return void 0===t?this._aliases:(t.forEach(t=>this.alias(t)),this)}usage(t){if(void 0===t){if(this._usage)return this._usage;const t=this.registeredArguments.map(t=>Q(t));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=B.basename(t,B.extname(t)),this}executableDir(t){return void 0===t?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const e=this.createHelp();return void 0===e.helpWidth&&(e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),e.formatHelp(this,e)}_getHelpContext(t){const e={error:!!(t=t||{}).error};let i;return i=e.error?t=>this._outputConfiguration.writeErr(t):t=>this._outputConfiguration.writeOut(t),e.write=t.write||i,e.command=this,e}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const i=this._getHelpContext(t);this._getCommandAndAncestors().reverse().forEach(t=>t.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(e&&(n=e(n),"string"!=typeof n&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._helpLongFlag&&this.emit(this._helpLongFlag),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(t=>t.emit("afterAllHelp",i))}helpOption(t,e){if("boolean"==typeof t)return this._hasHelpOption=t,this;this._helpFlags=t||this._helpFlags,this._helpDescription=e||this._helpDescription;const i=et(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(t){this.outputHelp(t);let e=Y.exitCode||0;0===e&&t&&"function"!=typeof t&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const n=`${t}Help`;return this.on(n,t=>{let i;i="function"==typeof e?e({error:t.error,command:t.command}):e,i&&t.write(`${i}\n`)}),this}},function(t,e){const{Argument:i}=N,{Command:n}=M,{CommanderError:s,InvalidArgumentError:r}=j,{Help:o}=I,{Option:a}=L;(e=t.exports=new n).program=e,e.Command=n,e.Option=a,e.Argument=i,e.Help=o,e.CommanderError=s,e.InvalidArgumentError=r,e.InvalidOptionArgumentError=r}(P,P.exports);var ot=A(P.exports);const{program:at,createCommand:ht,createArgument:lt,createOption:pt,CommanderError:ct,InvalidArgumentError:mt,InvalidOptionArgumentError:ut,Command:dt,Argument:gt,Option:ft,Help:_t}=ot,vt=new dt;vt.version("1.0.0","-v, --version","gant-core version"),vt.command("default",{isDefault:!0,noHelp:!0,hidden:!0}).action(()=>$()),vt.command("build").description("build cli").action(()=>$("build")),vt.command("analyzer").description("bundle-analyzer").action(()=>$("analyzer")),vt.command("i18n").arguments("[currentLanguage] [targetLanguage]").description("i18n translation").action(E),vt.command("create").description("创建项目").action(()=>O()),vt.command("mfa").arguments("[name]").action(t=>{V("development",t)}),vt.command("mfa-build").arguments("[name]").action(t=>{V("build",t)}),vt.command("mfa-analyzer").arguments("[name]").action(t=>{V("analyzer",t)});(async()=>{try{vt.parse(process.argv)}catch(t){console.log("Start Error",C.red(t?.message))}})();export{k as Env};
3
+ //# sourceMappingURL=index.mjs.map
@@ -1,3 +1,76 @@
1
- #!/usr/bin/env node
2
- "use strict";var e=require("../utils/index.js"),t=require("path");exports.generateRoutes=(n,r)=>{const i=t.resolve(n);e.generateDir(i);let o=e.isEmpty(r)?[]:r;o=Array.isArray(r)?r:[r];const s=e.keyBy(o,"path");o=e.values(s);const a={};let l=0;!function t(n,r="root",i){n.map(n=>{const o=`${l}`;a[o]={...e.omit(n,"children"),id:o,mpaKey:i||n.mpaKey,parentId:r};const s=e.get(n,"children",[]);l++,e.isEmpty(s)||t(s,o,n.mpaKey)})}(o),o=e.values(a);const c=`export default {\n ${Object.keys(a).map(t=>function(t,n){const r=Object.entries(n).map(([t,n])=>e.isNull(n)||e.isUndefined(n)?"":`${t}: '${n}'`).filter(e=>!!e).join(", ");return`'${t}': {${r}}`}(t,a[t])).join(",\n")}\n }`;return e.writeFileToJS(t.resolve(i,"./maps.ts"),c),function(n,r="index"){const o=`\n export default {\n ${n.map(t=>function(t){const{component:n="",routes:r,...i}=t,o=Object.entries(i).map(([t,n])=>e.isNull(n)||e.isUndefined(n)?"":`${t}: '${n}'`).filter(e=>!!e).join(", ");return`'${t.id}': { ${n?(e=>`lazy: async () =>import('${e}'), loader:async()=> { const Page:any = await import('${e}');return Page.loader||null},`)(n):""} ${o} }`}(t)).join(",\n")}\n }\n `;e.writeFileToJS(t.resolve(i,`${r}.ts`),o)}(o,"index"),!0};
1
+ 'use strict';
2
+
3
+ var utils_index = require('../utils/index.js');
4
+ var path = require('path');
5
+
6
+ const getComponentTempalte = component => {
7
+ return `lazy: async () =>import('${component}'), loader:async()=> { const Page:any = await import('${component}');return Page.loader||null},`;
8
+ };
9
+ // 生成路由对象的方法
10
+ function generateRouteObject(route) {
11
+ const { component = '', routes, ...rest } = route; // 解构出路由对象的 name、path、component 属性,其余属性保存在 rest 变量中
12
+ const additionalProps = Object.entries(rest)
13
+ .map(([key, value]) => (utils_index.isNull(value) || utils_index.isUndefined(value) ? '' : `${key}: '${value}'`))
14
+ .filter(item => !!item)
15
+ .join(', '); // 处理额外属性
16
+ return `'${route.id}': { ${component ? getComponentTempalte(component) : ''} ${additionalProps} }`;
17
+ }
18
+ function generateRouteMaps(key, route) {
19
+ const additionalProps = Object.entries(route)
20
+ .map(([key, value]) => (utils_index.isNull(value) || utils_index.isUndefined(value) ? '' : `${key}: '${value}'`))
21
+ .filter(item => !!item)
22
+ .join(', '); // 处理额外属性
23
+ return `'${key}': {${additionalProps}}`;
24
+ }
25
+ const generateRoutes = (rootPath, _routes) => {
26
+ const routesPath = path.resolve(rootPath);
27
+ utils_index.generateDir(routesPath);
28
+ let routes = utils_index.isEmpty(_routes) ? [] : _routes;
29
+ routes = Array.isArray(_routes) ? _routes : [_routes];
30
+ // 使用 _.keyBy 先按 path 创建一个映射
31
+ const keyedRoutes = utils_index.keyBy(routes, 'path');
32
+ // 从映射中提取值,这将保留最后出现的每个 path 的对象
33
+ routes = utils_index.values(keyedRoutes);
34
+ const routesMaps = {};
35
+ let index = 0;
36
+ function mapRoutes(routes, parentId = 'root', mpaKey) {
37
+ routes.map(itemRoute => {
38
+ const id = `${index}`;
39
+ routesMaps[id] = {
40
+ ...utils_index.omit(itemRoute, 'children'),
41
+ id: id,
42
+ mpaKey: mpaKey ? mpaKey : itemRoute.mpaKey,
43
+ parentId: parentId,
44
+ };
45
+ const children = utils_index.get(itemRoute, 'children', []);
46
+ index++;
47
+ if (utils_index.isEmpty(children))
48
+ return;
49
+ mapRoutes(children, id, itemRoute.mpaKey);
50
+ });
51
+ }
52
+ mapRoutes(routes);
53
+ routes = utils_index.values(routesMaps);
54
+ const routeMapsConent = `export default {
55
+ ${Object.keys(routesMaps)
56
+ .map(key => {
57
+ const itemRoute = routesMaps[key];
58
+ return generateRouteMaps(key, itemRoute);
59
+ })
60
+ .join(',\n')}
61
+ }`;
62
+ utils_index.writeFileToJS(path.resolve(routesPath, './maps.ts'), routeMapsConent);
63
+ function generateRouteFile(routes, name = 'index') {
64
+ const content = `
65
+ export default {
66
+ ${routes.map(route => generateRouteObject(route)).join(',\n')}
67
+ }
68
+ `;
69
+ utils_index.writeFileToJS(path.resolve(routesPath, `${name}.ts`), content);
70
+ }
71
+ generateRouteFile(routes, 'index');
72
+ return true;
73
+ };
74
+
75
+ exports.generateRoutes = generateRoutes;
3
76
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{j as n,d as t,k as a,v as e,w as o,o as s,a as r,l as i,n as c}from"../utils/index.mjs";import{resolve as p}from"path";const m=(m,l)=>{const $=p(m);n($);let d=t(l)?[]:l;d=Array.isArray(l)?l:[l];const u=a(d,"path");d=e(u);const f={};let y=0;!function n(a,e="root",o){a.map(a=>{const i=`${y}`;f[i]={...s(a,"children"),id:i,mpaKey:o||a.mpaKey,parentId:e};const c=r(a,"children",[]);y++,t(c)||n(c,i,a.mpaKey)})}(d),d=e(f);const j=`export default {\n ${Object.keys(f).map(n=>function(n,t){const a=Object.entries(t).map(([n,t])=>i(t)||c(t)?"":`${n}: '${t}'`).filter(n=>!!n).join(", ");return`'${n}': {${a}}`}(n,f[n])).join(",\n")}\n }`;return o(p($,"./maps.ts"),j),function(n,t="index"){const a=`\n export default {\n ${n.map(n=>function(n){const{component:t="",routes:a,...e}=n,o=Object.entries(e).map(([n,t])=>i(t)||c(t)?"":`${n}: '${t}'`).filter(n=>!!n).join(", ");return`'${n.id}': { ${t?(n=>`lazy: async () =>import('${n}'), loader:async()=> { const Page:any = await import('${n}');return Page.loader||null},`)(t):""} ${o} }`}(n)).join(",\n")}\n }\n `;o(p($,`${t}.ts`),a)}(d,"index"),!0};export{m as g};
3
+ //# sourceMappingURL=index.mjs.map
@@ -1,3 +1,71 @@
1
- #!/usr/bin/env node
2
- "use strict";var e=require("path"),s=require("fs"),t=require("../utils/index.js");exports.generateTsConfig=(r,i)=>{const{cwd:o,framework:n,createIncludes:a=!0}=i,l=e.resolve(o),c=t.getSrcPath(),p={"@gant/*":[e.resolve(l,c,".gant/*")],...i.paths};Object.keys(i.paths)?.map?.(e=>{p[e]=[i.paths[e]],p[e+"/*"]=[i.paths[e]+"/*"]});const v=[e.resolve(l,c,".gant/*.ts"),e.resolve(l,c,".gant/*.d.ts"),e.resolve(l,c,".gant/**/*.ts")],u=["*.ts","*.tsx","*.d.ts","**/*.ts","**/*.d.ts","**/*.tsx","**/**/*.ts","**/**/*d.ts","**/**/*.tsx"];"vue"===n&&u.push("*.vue","**/*.vue","**/**/*.vue"),i?.includes?.map?.(s=>{u.map(t=>v.push(e.resolve(s,t)))});const d="vue"===n?"vue":"react",g=s.readFileSync(e.resolve(__dirname,`../template/tsconfig.${d}.template.json`),"utf-8"),m=s.readFileSync(e.resolve(__dirname,"../template/types.d.txt"),"utf-8"),S=JSON.parse(g);if(S.compilerOptions.paths=p,S.include=v,t.writeFileToJSON(e.resolve(r,"tsconfig.json"),JSON.stringify(S)),t.writeFileToJS(e.resolve(r,"types.d.ts"),m),a)try{i?.includes.map(r=>{const i=e.resolve(r,c,".gant");s.existsSync(i)&&s.rmdirSync(i,{recursive:!0}),s.mkdirSync(i,{recursive:!0}),t.writeFileToJSON(e.resolve(i,"tsconfig.json"),JSON.stringify(S)),t.writeFileToJS(e.resolve(i,"types.d.ts"),m)})}catch(e){console.error("创建配置文件错误:",e)}};
1
+ 'use strict';
2
+
3
+ var node_url = require('node:url');
4
+ var path = require('path');
5
+ var fs = require('fs');
6
+ var utils_index = require('../utils/index.js');
7
+
8
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
9
+ const __dirname$1 = path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('tsconfig/index.js', document.baseURI).href))));
10
+ const generateTsConfig = (rootPath, options) => {
11
+ const { cwd, framework, createIncludes = true } = options;
12
+ const currentPath = path.resolve(cwd);
13
+ const srcpath = utils_index.getSrcPath();
14
+ const paths = {
15
+ '@gant/*': [path.resolve(currentPath, srcpath, '.gant/*')],
16
+ ...options.paths,
17
+ };
18
+ Object.keys(options.paths)?.map?.(name => {
19
+ paths[name] = [options.paths[name]];
20
+ paths[name + '/*'] = [options.paths[name] + '/*'];
21
+ });
22
+ const includes = [
23
+ path.resolve(currentPath, srcpath, '.gant/*.ts'),
24
+ path.resolve(currentPath, srcpath, '.gant/*.d.ts'),
25
+ path.resolve(currentPath, srcpath, '.gant/**/*.ts'),
26
+ ];
27
+ const types = [
28
+ '*.ts',
29
+ '*.tsx',
30
+ '*.d.ts',
31
+ '**/*.ts',
32
+ '**/*.d.ts',
33
+ '**/*.tsx',
34
+ '**/**/*.ts',
35
+ '**/**/*d.ts',
36
+ '**/**/*.tsx',
37
+ ];
38
+ if (framework === 'vue') {
39
+ types.push(...['*.vue', '**/*.vue', '**/**/*.vue']);
40
+ }
41
+ options?.includes?.map?.(itemPath => {
42
+ types.map(pathName => includes.push(path.resolve(itemPath, pathName)));
43
+ });
44
+ const suffix = framework === 'vue' ? 'vue' : 'react';
45
+ const jsonString = fs.readFileSync(path.resolve(__dirname$1, `../template/tsconfig.${suffix}.template.json`), 'utf-8');
46
+ const typesString = fs.readFileSync(path.resolve(__dirname$1, '../template/types.d.txt'), 'utf-8');
47
+ const jsonObj = JSON.parse(jsonString);
48
+ jsonObj.compilerOptions.paths = paths;
49
+ jsonObj.include = includes;
50
+ utils_index.writeFileToJSON(path.resolve(rootPath, 'tsconfig.json'), JSON.stringify(jsonObj));
51
+ utils_index.writeFileToJS(path.resolve(rootPath, 'types.d.ts'), typesString);
52
+ if (!createIncludes)
53
+ return;
54
+ try {
55
+ options?.includes.map(itemPath => {
56
+ const itemDirPath = path.resolve(itemPath, srcpath, '.gant');
57
+ if (fs.existsSync(itemDirPath)) {
58
+ fs.rmdirSync(itemDirPath, { recursive: true });
59
+ }
60
+ fs.mkdirSync(itemDirPath, { recursive: true });
61
+ utils_index.writeFileToJSON(path.resolve(itemDirPath, 'tsconfig.json'), JSON.stringify(jsonObj));
62
+ utils_index.writeFileToJS(path.resolve(itemDirPath, 'types.d.ts'), typesString);
63
+ });
64
+ }
65
+ catch (error) {
66
+ console.error('创建配置文件错误:', error);
67
+ }
68
+ };
69
+
70
+ exports.generateTsConfig = generateTsConfig;
3
71
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{fileURLToPath as t}from"node:url";import s,{resolve as e}from"path";import r from"fs";import{g as n,q as a,w as o}from"../utils/index.mjs";const i=s.dirname(t(import.meta.url)),c=(t,c)=>{const{cwd:p,framework:m,createIncludes:d=!0}=c,u=e(p),l=n(),f={"@gant/*":[e(u,l,".gant/*")],...c.paths};Object.keys(c.paths)?.map?.(t=>{f[t]=[c.paths[t]],f[t+"/*"]=[c.paths[t]+"/*"]});const g=[e(u,l,".gant/*.ts"),e(u,l,".gant/*.d.ts"),e(u,l,".gant/**/*.ts")],y=["*.ts","*.tsx","*.d.ts","**/*.ts","**/*.d.ts","**/*.tsx","**/**/*.ts","**/**/*d.ts","**/**/*.tsx"];"vue"===m&&y.push("*.vue","**/*.vue","**/**/*.vue"),c?.includes?.map?.(t=>{y.map(s=>g.push(e(t,s)))});const h="vue"===m?"vue":"react",v=r.readFileSync(e(i,`../template/tsconfig.${h}.template.json`),"utf-8"),S=r.readFileSync(e(i,"../template/types.d.txt"),"utf-8"),x=JSON.parse(v);if(x.compilerOptions.paths=f,x.include=g,a(e(t,"tsconfig.json"),JSON.stringify(x)),o(e(t,"types.d.ts"),S),d)try{c?.includes.map(t=>{const n=s.resolve(t,l,".gant");r.existsSync(n)&&r.rmdirSync(n,{recursive:!0}),r.mkdirSync(n,{recursive:!0}),a(e(n,"tsconfig.json"),JSON.stringify(x)),o(e(n,"types.d.ts"),S)})}catch(t){console.error("创建配置文件错误:",t)}};export{c as g};
3
+ //# sourceMappingURL=index.mjs.map
@@ -1,3 +1,121 @@
1
- #!/usr/bin/env node
2
- "use strict";var e=require("net"),m="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r={exports:{}};let o=process||{},n=o.argv||[],l=o.env||{},i=!(l.NO_COLOR||n.includes("--no-color"))&&(!!l.FORCE_COLOR||n.includes("--color")||"win32"===o.platform||(o.stdout||{}).isTTY&&"dumb"!==l.TERM||!!l.CI),g=(e,m,t=e)=>r=>{let o=""+r,n=o.indexOf(m,e.length);return~n?e+a(o,m,t,n)+m:e+o+m},a=(e,m,t,r)=>{let o="",n=0;do{o+=e.substring(n,r)+t,n=r+m.length,r=e.indexOf(m,n)}while(~r);return o+e.substring(n)},s=(e=i)=>{let m=e?g:()=>String;return{isColorSupported:e,reset:m("",""),bold:m("","",""),dim:m("","",""),italic:m("",""),underline:m("",""),inverse:m("",""),hidden:m("",""),strikethrough:m("",""),black:m("",""),red:m("",""),green:m("",""),yellow:m("",""),blue:m("",""),magenta:m("",""),cyan:m("",""),white:m("",""),gray:m("",""),bgBlack:m("",""),bgRed:m("",""),bgGreen:m("",""),bgYellow:m("",""),bgBlue:m("",""),bgMagenta:m("",""),bgCyan:m("",""),bgWhite:m("",""),blackBright:m("",""),redBright:m("",""),greenBright:m("",""),yellowBright:m("",""),blueBright:m("",""),magentaBright:m("",""),cyanBright:m("",""),whiteBright:m("",""),bgBlackBright:m("",""),bgRedBright:m("",""),bgGreenBright:m("",""),bgYellowBright:m("",""),bgBlueBright:m("",""),bgMagentaBright:m("",""),bgCyanBright:m("",""),bgWhiteBright:m("","")}};r.exports=s(),r.exports.createColors=s;var u=t(r.exports);function d(m){return new Promise(t=>{const r=e.createServer();r.on("error",()=>{r.close(),t(!1)}),r.listen(m,"0.0.0.0",()=>{r.close(),t(!0)})})}exports.color=u,exports.commonjsGlobal=m,exports.detectPort=async function(e,m=20){const t=e;for(let t=0;t<m;t++){if(await d(e))return e;console.log(u.yellow(`Port ${e} is in use, trying ${e+1}...`)),e++}throw new Error(`Could not find an available port after ${m} attempts starting from ${t}`)},exports.getDefaultExportFromCjs=t;
1
+ 'use strict';
2
+
3
+ var net = require('net');
4
+
5
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
+
7
+ function getDefaultExportFromCjs (x) {
8
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
9
+ }
10
+
11
+ var picocolors = {exports: {}};
12
+
13
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
14
+ let isColorSupported =
15
+ !(!!env.NO_COLOR || argv.includes("--no-color")) &&
16
+ (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
17
+
18
+ let formatter = (open, close, replace = open) =>
19
+ input => {
20
+ let string = "" + input, index = string.indexOf(close, open.length);
21
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
22
+ };
23
+
24
+ let replaceClose = (string, close, replace, index) => {
25
+ let result = "", cursor = 0;
26
+ do {
27
+ result += string.substring(cursor, index) + replace;
28
+ cursor = index + close.length;
29
+ index = string.indexOf(close, cursor);
30
+ } while (~index)
31
+ return result + string.substring(cursor)
32
+ };
33
+
34
+ let createColors = (enabled = isColorSupported) => {
35
+ let f = enabled ? formatter : () => String;
36
+ return {
37
+ isColorSupported: enabled,
38
+ reset: f("\x1b[0m", "\x1b[0m"),
39
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
40
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
41
+ italic: f("\x1b[3m", "\x1b[23m"),
42
+ underline: f("\x1b[4m", "\x1b[24m"),
43
+ inverse: f("\x1b[7m", "\x1b[27m"),
44
+ hidden: f("\x1b[8m", "\x1b[28m"),
45
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
46
+
47
+ black: f("\x1b[30m", "\x1b[39m"),
48
+ red: f("\x1b[31m", "\x1b[39m"),
49
+ green: f("\x1b[32m", "\x1b[39m"),
50
+ yellow: f("\x1b[33m", "\x1b[39m"),
51
+ blue: f("\x1b[34m", "\x1b[39m"),
52
+ magenta: f("\x1b[35m", "\x1b[39m"),
53
+ cyan: f("\x1b[36m", "\x1b[39m"),
54
+ white: f("\x1b[37m", "\x1b[39m"),
55
+ gray: f("\x1b[90m", "\x1b[39m"),
56
+
57
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
58
+ bgRed: f("\x1b[41m", "\x1b[49m"),
59
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
60
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
61
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
62
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
63
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
64
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
65
+
66
+ blackBright: f("\x1b[90m", "\x1b[39m"),
67
+ redBright: f("\x1b[91m", "\x1b[39m"),
68
+ greenBright: f("\x1b[92m", "\x1b[39m"),
69
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
70
+ blueBright: f("\x1b[94m", "\x1b[39m"),
71
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
72
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
73
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
74
+
75
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
76
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
77
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
78
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
79
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
80
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
81
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
82
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
83
+ }
84
+ };
85
+
86
+ picocolors.exports = createColors();
87
+ picocolors.exports.createColors = createColors;
88
+
89
+ var picocolorsExports = picocolors.exports;
90
+ var color = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
91
+
92
+ function checkPort(port) {
93
+ return new Promise(resolve => {
94
+ const server = net.createServer();
95
+ server.on('error', () => {
96
+ server.close();
97
+ resolve(false);
98
+ });
99
+ server.listen(port, '0.0.0.0', () => {
100
+ server.close();
101
+ resolve(true);
102
+ });
103
+ });
104
+ }
105
+ async function detectPort(port, maxAttempts = 20) {
106
+ const originalPort = port;
107
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
108
+ const available = await checkPort(port);
109
+ if (available)
110
+ return port;
111
+ console.log(color.yellow(`Port ${port} is in use, trying ${port + 1}...`));
112
+ port++;
113
+ }
114
+ throw new Error(`Could not find an available port after ${maxAttempts} attempts starting from ${originalPort}`);
115
+ }
116
+
117
+ exports.color = color;
118
+ exports.commonjsGlobal = commonjsGlobal;
119
+ exports.detectPort = detectPort;
120
+ exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
3
121
  //# sourceMappingURL=detectPort.js.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import e from"net";var m="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r={exports:{}};let n=process||{},o=n.argv||[],i=n.env||{},l=!(i.NO_COLOR||o.includes("--no-color"))&&(!!i.FORCE_COLOR||o.includes("--color")||"win32"===n.platform||(n.stdout||{}).isTTY&&"dumb"!==i.TERM||!!i.CI),g=(e,m,t=e)=>r=>{let n=""+r,o=n.indexOf(m,e.length);return~o?e+a(n,m,t,o)+m:e+n+m},a=(e,m,t,r)=>{let n="",o=0;do{n+=e.substring(o,r)+t,o=r+m.length,r=e.indexOf(m,o)}while(~r);return n+e.substring(o)},s=(e=l)=>{let m=e?g:()=>String;return{isColorSupported:e,reset:m("",""),bold:m("","",""),dim:m("","",""),italic:m("",""),underline:m("",""),inverse:m("",""),hidden:m("",""),strikethrough:m("",""),black:m("",""),red:m("",""),green:m("",""),yellow:m("",""),blue:m("",""),magenta:m("",""),cyan:m("",""),white:m("",""),gray:m("",""),bgBlack:m("",""),bgRed:m("",""),bgGreen:m("",""),bgYellow:m("",""),bgBlue:m("",""),bgMagenta:m("",""),bgCyan:m("",""),bgWhite:m("",""),blackBright:m("",""),redBright:m("",""),greenBright:m("",""),yellowBright:m("",""),blueBright:m("",""),magentaBright:m("",""),cyanBright:m("",""),whiteBright:m("",""),bgBlackBright:m("",""),bgRedBright:m("",""),bgGreenBright:m("",""),bgYellowBright:m("",""),bgBlueBright:m("",""),bgMagentaBright:m("",""),bgCyanBright:m("",""),bgWhiteBright:m("","")}};r.exports=s(),r.exports.createColors=s;var d=t(r.exports);function u(m){return new Promise(t=>{const r=e.createServer();r.on("error",()=>{r.close(),t(!1)}),r.listen(m,"0.0.0.0",()=>{r.close(),t(!0)})})}async function b(e,m=20){const t=e;for(let t=0;t<m;t++){if(await u(e))return e;console.log(d.yellow(`Port ${e} is in use, trying ${e+1}...`)),e++}throw new Error(`Could not find an available port after ${m} attempts starting from ${t}`)}export{d as a,m as c,b as d,t as g};
3
+ //# sourceMappingURL=detectPort.mjs.map
@@ -1,3 +1,15 @@
1
- #!/usr/bin/env node
2
- "use strict";var e=require("path"),t=require("jiti"),r="undefined"!=typeof document?document.currentScript:null;const i=t.createJiti("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("utils/getJavascriptfile.js",document.baseURI).href);exports.getJavascriptfile=function(t){const r=e.resolve(t),n=i(r);return n.default||n};
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+ var jiti$1 = require('jiti');
5
+
6
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
7
+ const jiti = jiti$1.createJiti((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils/getJavascriptfile.js', document.baseURI).href)));
8
+ function getJavascriptfile(filePath) {
9
+ const resolvedPath = path.resolve(filePath);
10
+ const config = jiti(resolvedPath);
11
+ return config.default || config;
12
+ }
13
+
14
+ exports.getJavascriptfile = getJavascriptfile;
3
15
  //# sourceMappingURL=getJavascriptfile.js.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{resolve as t}from"path";import{createJiti as o}from"jiti";const r=o(import.meta.url);function i(o){const i=t(o),m=r(i);return m.default||m}export{i as g};
3
+ //# sourceMappingURL=getJavascriptfile.mjs.map