create-vitnode-app 0.0.7-canary.39 → 0.0.7-canary.40
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/README.md +1 -0
- package/dist/index.cjs +19 -19
- package/package.json +2 -2
- package/templates/create-packages-json.ts +9 -1
- package/templates/docker/docker-compose-dev.yml +35 -0
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@ yarn create vitnode-app@latest
|
|
|
41
41
|
| -------------------------- | ------------------------------------------------------------------ |
|
|
42
42
|
| `--package-manager`, `-pm` | Specify the package manager to use. Support `npm`, `pnpm`, `yarn`. |
|
|
43
43
|
| `--eslint` | Initialize with eslint config. |
|
|
44
|
+
| `--docker` | Initialize with Dockerfile & Docker Compose. |
|
|
44
45
|
| `--no-eslint` | Skip initializing with eslint config. |
|
|
45
46
|
| `--i18n-routing` | Initialize with i18n routing. |
|
|
46
47
|
| `--skip-install` | Skip installing packages after initializing the project. |
|
package/dist/index.cjs
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Pe=Object.create;var ne=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var
|
|
3
|
-
`).replace(/^/gm," ".repeat(s))}let c=[`Usage: ${t.commandUsage(e)}`,""],u=t.commandDescription(e);u.length>0&&(c=c.concat([t.wrap(u,n,0),""]));let h=t.visibleArguments(e).map(
|
|
4
|
-
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){let s=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",
|
|
2
|
+
"use strict";var Pe=Object.create;var ne=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var x=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var Te=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of De(e))!Ie.call(o,n)&&n!==t&&ne(o,n,{get:()=>e[n],enumerable:!(i=je(e,n))||i.enumerable});return o};var v=(o,e,t)=>(t=o!=null?Pe(Fe(o)):{},Te(e||!o||!o.__esModule?ne(t,"default",{value:o,enumerable:!0}):t,o));var V=x(W=>{"use strict";var P=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}},T=class extends P{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};W.CommanderError=P;W.InvalidArgumentError=T});var j=x(q=>{"use strict";var{InvalidArgumentError:We}=V(),M=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new We(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Me(o){let e=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+e+">":"["+e+"]"}q.Argument=M;q.humanReadableArgName=Me});var J=x(se=>{"use strict";var{humanReadableArgName:qe}=j(),R=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(n=>!n._hidden),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort((n,s)=>n.name().localeCompare(s.name())),t}compareOptions(e,t){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){let t=e.options.filter(n=>!n.hidden),i=e._getHelpOption();if(i&&!i.hidden){let n=i.short&&e._findOption(i.short),s=i.long&&e._findOption(i.long);!n&&!s?t.push(i):i.long&&!s?t.push(e.createOption(i.long,i.description)):i.short&&!n&&t.push(e.createOption(i.short,i.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let i=e.parent;i;i=i.parent){let n=i.options.filter(s=>!s.hidden);t.push(...n)}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(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(i=>qe(i)).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((i,n)=>Math.max(i,t.subcommandTerm(n).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,n)=>Math.max(i,t.argumentTerm(n).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let n=e.parent;n;n=n.parent)i=n.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){let i=t.padWidth(e,t),n=t.helpWidth||80,s=2,r=2;function l(d,w){if(w){let I=`${d.padEnd(i+r)}${w}`;return t.wrap(I,n-s,i+r)}return d}function a(d){return d.join(`
|
|
3
|
+
`).replace(/^/gm," ".repeat(s))}let c=[`Usage: ${t.commandUsage(e)}`,""],u=t.commandDescription(e);u.length>0&&(c=c.concat([t.wrap(u,n,0),""]));let h=t.visibleArguments(e).map(d=>l(t.argumentTerm(d),t.argumentDescription(d)));h.length>0&&(c=c.concat(["Arguments:",a(h),""]));let f=t.visibleOptions(e).map(d=>l(t.optionTerm(d),t.optionDescription(d)));if(f.length>0&&(c=c.concat(["Options:",a(f),""])),this.showGlobalOptions){let d=t.visibleGlobalOptions(e).map(w=>l(t.optionTerm(w),t.optionDescription(w)));d.length>0&&(c=c.concat(["Global Options:",a(d),""]))}let A=t.visibleCommands(e).map(d=>l(t.subcommandTerm(d),t.subcommandDescription(d)));return A.length>0&&(c=c.concat(["Commands:",a(A),""])),c.join(`
|
|
4
|
+
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){let s=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",r=new RegExp(`[\\n][${s}]+`);if(e.match(r))return e;let l=t-i;if(l<n)return e;let a=e.slice(0,i),c=e.slice(i).replace(`\r
|
|
5
5
|
`,`
|
|
6
6
|
`),u=" ".repeat(i),f="\\s\u200B",A=new RegExp(`
|
|
7
|
-
|.{1,${l-1}}([${f}]|$)|[^${f}]+?([${f}]|$)`,"g"),
|
|
7
|
+
|.{1,${l-1}}([${f}]|$)|[^${f}]+?([${f}]|$)`,"g"),d=c.match(A)||[];return a+d.map((w,I)=>w===`
|
|
8
8
|
`?"":(I>0?u:"")+w.trimEnd()).join(`
|
|
9
|
-
`)}};se.Help=R});var
|
|
9
|
+
`)}};se.Help=R});var z=x(B=>{"use strict";var{InvalidArgumentError:Re}=V(),L=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=Le(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 typeof e=="string"&&(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)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new Re(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Je(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},U=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(e,t){let i=t.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,s=n!==void 0?n:!1;return t.negate===(s===e)}};function Je(o){return o.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Le(o){let e,t,i=o.split(/[ |,]+/);return i.length>1&&!/^[[<]/.test(i[1])&&(e=i.shift()),t=i.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}B.Option=L;B.DualOptions=U});var oe=x(re=>{"use strict";function Ue(o,e){if(Math.abs(o.length-e.length)>3)return Math.max(o.length,e.length);let t=[];for(let i=0;i<=o.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let n=1;n<=o.length;n++){let s=1;o[n-1]===e[i-1]?s=0:s=1,t[n][i]=Math.min(t[n-1][i]+1,t[n][i-1]+1,t[n-1][i-1]+s),n>1&&i>1&&o[n-1]===e[i-2]&&o[n-2]===e[i-1]&&(t[n][i]=Math.min(t[n][i],t[n-2][i-2]+1))}return t[o.length][e.length]}function Be(o,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=o.startsWith("--");t&&(o=o.slice(2),e=e.map(r=>r.slice(2)));let i=[],n=3,s=.4;return e.forEach(r=>{if(r.length<=1)return;let l=Ue(o,r),a=Math.max(o.length,r.length);(a-l)/a>s&&(l<n?(n=l,i=[r]):l===n&&i.push(r))}),i.sort((r,l)=>r.localeCompare(l)),t&&(i=i.map(r=>`--${r}`)),i.length>1?`
|
|
10
10
|
(Did you mean one of ${i.join(", ")}?)`:i.length===1?`
|
|
11
|
-
(Did you mean ${i[0]}?)`:""}re.suggestSimilar=Be});var he=x(ue=>{"use strict";var
|
|
12
|
-
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new
|
|
13
|
-
Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new K(e,t,i)),p.exit(e)}action(e){let t=i=>{let n=this.registeredArguments.length,s=i.slice(0,n);return this._storeOptionsAsProperties?s[n]=this:s[n]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new ae(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(s){if(s.code==="commander.invalidArgument"){let
|
|
14
|
-
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=n=>[n.name()].concat(n.aliases()),i=t(e).find(n=>this._findCommand(n));if(i){let n=t(this._findCommand(i)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${n}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let n=(s,
|
|
11
|
+
(Did you mean ${i[0]}?)`:""}re.suggestSimilar=Be});var he=x(ue=>{"use strict";var ze=require("events").EventEmitter,G=require("child_process"),y=require("path"),Y=require("fs"),p=require("process"),{Argument:Ge,humanReadableArgName:Ye}=j(),{CommanderError:K}=V(),{Help:Ke}=J(),{Option:ae,DualOptions:Xe}=z(),{suggestSimilar:le}=oe(),X=class o extends ze{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:t=>p.stdout.write(t),writeErr:t=>p.stderr.write(t),getOutHelpWidth:()=>p.stdout.isTTY?p.stdout.columns:void 0,getErrHelpWidth:()=>p.stderr.isTTY?p.stderr.columns:void 0,outputError:(t,i)=>i(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,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(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let n=t,s=i;typeof n=="object"&&n!==null&&(s=n,n=null),s=s||{};let[,r,l]=e.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,l&&a.arguments(l),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(e){return new o(e)}createHelp(){return Object.assign(new Ke,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
12
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Ge(e,t)}argument(e,t,i,n){let s=this.createArgument(e,t);return typeof i=="function"?s.default(n).argParser(i):s.default(i),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let 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&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,i,n]=e.match(/([^ ]+) *(.*)/),s=t??"display help for command",r=this.createCommand(i);return r.helpOption(!1),n&&r.arguments(n),s&&r.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=r,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
13
|
+
Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new K(e,t,i)),p.exit(e)}action(e){let t=i=>{let n=this.registeredArguments.length,s=i.slice(0,n);return this._storeOptionsAsProperties?s[n]=this:s[n]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new ae(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(s){if(s.code==="commander.invalidArgument"){let r=`${n} ${s.message}`;this.error(r,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let i=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
|
|
14
|
+
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=n=>[n.name()].concat(n.aliases()),i=t(e).find(n=>this._findCommand(n));if(i){let n=t(this._findCommand(i)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${n}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let n=(s,r,l)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let a=this.getOptionValue(i);s!==null&&e.parseArg?s=this._callParseArg(e,s,a,r):s!==null&&e.variadic&&(s=e._concatValue(s,a)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(i,s,l)};return this.on("option:"+t,s=>{let r=`error: option '${e.flags}' argument '${s}' is invalid.`;n(s,r,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let r=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;n(s,r,"env")}),this}_optionEx(e,t,i,n,s){if(typeof t=="object"&&t instanceof ae)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let r=this.createOption(t,i);if(r.makeOptionMandatory(!!e.mandatory),typeof n=="function")r.default(s).argParser(n);else if(n instanceof RegExp){let l=n;n=(a,c)=>{let u=l.exec(a);return u?u[0]:c},r.default(s).argParser(n)}else r.default(n);return this.addOption(r)}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){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");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=>{i.getOptionValueSource(e)!==void 0&&(t=i.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){p.versions?.electron&&(t.from="electron");let n=p.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(t.from="eval")}e===void 0&&(e=p.argv),this.rawArgs=e.slice();let i;switch(t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":p.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);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){let i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){let i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_executeSubCommand(e,t){t=t.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function s(u,h){let f=y.resolve(u,h);if(Y.existsSync(f))return f;if(n.includes(y.extname(h)))return;let A=n.find(d=>Y.existsSync(`${f}${d}`));if(A)return`${f}${A}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let u;try{u=Y.realpathSync(this._scriptPath)}catch{u=this._scriptPath}l=y.resolve(y.dirname(u),l)}if(l){let u=s(l,r);if(!u&&!e._executableFile&&this._scriptPath){let h=y.basename(this._scriptPath,y.extname(this._scriptPath));h!==this._name&&(u=s(l,`${h}-${e._name}`))}r=u||r}i=n.includes(y.extname(r));let a;p.platform!=="win32"?i?(t.unshift(r),t=ce(p.execArgv).concat(t),a=G.spawn(p.argv[0],t,{stdio:"inherit"})):a=G.spawn(r,t,{stdio:"inherit"}):(t.unshift(r),t=ce(p.execArgv).concat(t),a=G.spawn(p.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{p.on(h,()=>{a.killed===!1&&a.exitCode===null&&a.kill(h)})});let c=this._exitCallback;a.on("close",u=>{u=u??1,c?c(new K(u,"commander.executeSubCommandAsync","(close)")):p.exit(u)}),a.on("error",u=>{if(u.code==="ENOENT"){let h=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",f=`'${r}' does not exist
|
|
15
15
|
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
16
16
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
17
|
-
- ${h}`;throw new Error(f)}else if(u.code==="EACCES")throw new Error(`'${
|
|
17
|
+
- ${h}`;throw new Error(f)}else if(u.code==="EACCES")throw new Error(`'${r}' not executable`);if(!c)p.exit(1);else{let h=new K(1,"commander.executeSubCommandAsync","(error)");h.nestedError=u,c(h)}}),this.runningCommand=a}_dispatchSubcommand(e,t,i){let n=this._findCommand(e);n||this.help({error:!0});let s;return s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(n._executableHandler)this._executeSubCommand(n,t.concat(i));else return n._parseCommand(t,i)}),s}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&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(){let e=(i,n,s)=>{let r=n;if(n!==null&&i.parseArg){let l=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;r=this._callParseArg(i,n,s,l)}return r};this._checkNumberOfArguments();let t=[];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((r,l)=>e(i,l,r),i.defaultValue))):s===void 0&&(s=[]):n<this.args.length&&(s=this.args[n],i.parseArg&&(s=e(i,s,i.defaultValue))),t[n]=s}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let i=e,n=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[t]!==void 0).forEach(s=>{s._lifeCycleHooks[t].forEach(r=>{n.push({hookedCommand:s,callback:r})})}),t==="postAction"&&n.reverse(),n.forEach(s=>{i=this._chainOrCall(i,()=>s.callback(s.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(s=>{n=this._chainOrCall(n,()=>s(this,t))}),n}_parseCommand(e,t){let 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._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let r;return r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(s,e,t)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent&&this.parent.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,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&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});e.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=e.find(s=>i.conflictsWith.includes(s.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],n=t,s=e.slice();function r(a){return a.length>1&&a[0]==="-"}let l=null;for(;s.length;){let a=s.shift();if(a==="--"){n===i&&n.push(a),n.push(...s);break}if(l&&!r(a)){this.emit(`option:${l.name()}`,a);continue}if(l=null,r(a)){let c=this._findOption(a);if(c){if(c.required){let u=s.shift();u===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,u)}else if(c.optional){let u=null;s.length>0&&!r(s[0])&&(u=s.shift()),this.emit(`option:${c.name()}`,u)}else this.emit(`option:${c.name()}`);l=c.variadic?c:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let c=this._findOption(`-${a[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,a.slice(2)):(this.emit(`option:${c.name()}`),s.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let c=a.indexOf("="),u=this._findOption(a.slice(0,c));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,a.slice(c+1));continue}}if(r(a)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(a)){t.push(a),s.length>0&&i.push(...s);break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a),s.length>0&&t.push(...s);break}else if(this._defaultCommandName){i.push(a),s.length>0&&i.push(...s);break}}if(this._passThroughOptions){n.push(a),s.length>0&&n.push(...s);break}n.push(a)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let i=0;i<t;i++){let n=this.options[i].attributeName();e[n]=n===this._versionOptionName?this._version:this[n]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
18
18
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
19
19
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
20
|
-
`),this.outputHelp({error:!0}));let i=t||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in p.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,p.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Xe(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!t(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=
|
|
21
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${n}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>Ye(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=
|
|
22
|
-
Expecting one of '${i.join("', '")}'`);let n=`${e}Help`;return this.on(n,s=>{let
|
|
23
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ce(
|
|
24
|
-
`);for(let n of i)try{(0,
|
|
20
|
+
`),this.outputHelp({error:!0}));let i=t||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in p.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,p.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Xe(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!t(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=r=>{let l=r.attributeName(),a=this.getOptionValue(l),c=this.options.find(h=>h.negate&&l===h.attributeName()),u=this.options.find(h=>!h.negate&&l===h.attributeName());return c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg)?c:u||r},n=r=>{let l=i(r),a=l.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},s=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let r=s.createHelp().visibleOptions(s).filter(l=>l.long).map(l=>l.long);n=n.concat(r),s=s.parent}while(s&&!s._enablePositionalOptions);t=le(e,n)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(s=>{n.push(s.name()),s.alias()&&n.push(s.alias())}),t=le(e,n)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
21
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${n}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>Ye(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=y.basename(e,y.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},i;return t.error?i=n=>this._outputConfiguration.writeErr(n):i=n=>this._outputConfiguration.writeOut(n),t.write=e.write||i,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=p.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
22
|
+
Expecting one of '${i.join("', '")}'`);let n=`${e}Help`;return this.on(n,s=>{let r;typeof t=="function"?r=t({error:s.error,command:s.command}):r=t,r&&s.write(`${r}
|
|
23
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ce(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?n=s[3]:i=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],i=s[3],n=s[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}ue.Command=X});var fe=x(g=>{"use strict";var{Argument:pe}=j(),{Command:Q}=he(),{CommanderError:Qe,InvalidArgumentError:de}=V(),{Help:Ze}=J(),{Option:me}=z();g.program=new Q;g.createCommand=o=>new Q(o);g.createOption=(o,e)=>new me(o,e);g.createArgument=(o,e)=>new pe(o,e);g.Command=Q;g.Option=me;g.Argument=pe;g.Help=Ze;g.CommanderError=Qe;g.InvalidArgumentError=de;g.InvalidOptionArgumentError=de});var C=require("path"),Ve=require("fs");var ge=v(fe(),1),{program:ct,createCommand:ut,createArgument:ht,createOption:pt,CommanderError:dt,InvalidArgumentError:mt,InvalidOptionArgumentError:ft,Command:_e,Argument:gt,Option:be,Help:_t}=ge.default;var b=v(require("picocolors"),1),He=v(require("figlet"),1),Ne=v(require("prompts"),1);var Oe={name:"create-vitnode-app",version:"0.0.7-canary.39",description:"Create a new VitNode app in seconds.",author:"VitNode Team",license:"MIT",homepage:"https://VitNode.com",repository:{type:"git",url:"git+https://github.com/aXenDeveloper/VitNode.git",directory:"packages/create-vitnode-app"},type:"module",bin:{"create-vitnode-app":"dist/index.cjs"},scripts:{lint:"eslint .","lint:fix":"eslint . --fix","build:scripts":"tsup index.ts","dev:script":"tsup index.ts --watch","start:script":"node dist/index.cjs"},dependencies:{figlet:"^1.7.0",picocolors:"^1.0.1",prompts:"^2.4.2","validate-npm-package-name":"^5.0.1"},devDependencies:{"@types/figlet":"^1.5.8","@types/node":"^20.14.11","@types/prompts":"^2.4.9","@types/validate-npm-package-name":"^4.0.2",commander:"^12.1.0",tsup:"^8.1.0",typescript:"^5.5.3","eslint-config-typescript-vitnode":"workspace:*"}};var Ce=v(require("validate-npm-package-name"),1),Z=({name:o})=>{let e=(0,Ce.default)(o);return e.validForNewPackages?{valid:!0}:{valid:!1,problems:[...e.errors||[],...e.warnings||[]]}};var D=require("fs"),ve=require("path"),ee=v(require("picocolors"),1);function F(o,e){let t=[".DS_Store",".git",".gitattributes",".gitignore",".gitlab-ci.yml",".hg",".hgcheck",".hgignore",".idea",".npmignore",".travis.yml","LICENSE","Thumbs.db","docs","mkdocs.yml","npm-debug.log","yarn-debug.log","yarn-error.log","yarnrc.yml",".yarn"],i=(0,D.readdirSync)(o).filter(n=>!t.includes(n)&&!n.endsWith(".iml"));if(i.length>0){console.log(`The directory ${ee.default.green(e)} contains files that could conflict:
|
|
24
|
+
`);for(let n of i)try{(0,D.lstatSync)((0,ve.join)(o,n)).isDirectory()?console.log(`${ee.default.blue(n)}/`):console.log(`${n}`)}catch{console.log(`${n}`)}return console.log(`
|
|
25
25
|
Either try using a new directory name, or remove the files listed above.
|
|
26
|
-
`),!1}return!0}var
|
|
27
|
-
`),(0,
|
|
28
|
-
`),process.exit(1))},Se=async
|
|
26
|
+
`),!1}return!0}var ye=require("constants"),we=require("fs/promises");async function Ae(o){try{return await(0,we.access)(o,ye.W_OK),!0}catch{return!1}}var m=require("fs"),_=require("path"),te=v(require("picocolors"),1);var $=require("fs"),H=require("path"),xe=({appName:o,root:e,packageManager:t,docker:i})=>{let n=JSON.parse((0,$.readFileSync)((0,H.join)(__dirname,"..","package.json"),"utf-8")),s={name:o,version:"1.0.0",private:!0,scripts:{"config:init":"turbo config:init",dev:"turbo dev",build:"turbo build",lint:"turbo lint","lint:fix":"turbo lint:fix",...i?{"docker:dev":"docker compose -f ./docker-compose-dev.yml -p vitnode-development up -d"}:{}},overrides:t.startsWith("npm")?{react:"^19.0.0-rc.0","react-dom":"^19.0.0-rc.0"}:{},dependencies:{"drizzle-kit":"^0.22.8","drizzle-orm":"^0.31.4"},devDependencies:{"eslint-config-typescript-vitnode":`^${n.version}`,prettier:"^3.3.3","prettier-plugin-tailwindcss":"^0.6.5",turbo:"^2.0.7",typescript:"^5.4.5"},packageManager:t,workspaces:["apps/*"]};(0,$.writeFileSync)((0,H.join)(e,"package.json"),JSON.stringify(s,null,2));let r={name:"frontend",version:"1.0.0",private:!0,scripts:{"config:init":"vitnode-frontend init",dev:"vitnode-frontend init && next dev --turbo",build:"next build",start:"next start",lint:"eslint .","lint:fix":"eslint . --fix"},dependencies:{geist:"^1.3.1",next:"15.0.0-canary.72",react:"^19.0.0-rc.0","react-dom":"^19.0.0-rc.0","next-intl":"^3.17.1","vitnode-frontend":`^${n.version}`},devDependencies:{"@types/node":"^20.14.11","@types/react":"^18.3.3","@types/react-dom":"^18.3.0",autoprefixer:"^10.4.19",eslint:"^8.57.0","eslint-config-typescript-vitnode":`^${n.version}`,postcss:"^8.4.39",tailwindcss:"^3.4.4",typescript:"^5.5.3"}};(0,$.writeFileSync)((0,H.join)(e,"apps","frontend","package.json"),JSON.stringify(r,null,2));let l={name:"backend",version:"1.0.0",private:!0,scripts:{"config:init":"vitnode-backend init",dev:"vitnode-backend init && cross-env NODE_ENV=development nest start -w",build:"nest build",start:"node dist/main",lint:"eslint .","lint:fix":"eslint . --fix"},dependencies:{"@nestjs/common":"^10.3.10","@nestjs/core":"^10.3.10","@nestjs/graphql":"^12.2.0","@react-email/components":"^0.0.21",react:"^19.0.0-rc.0","react-dom":"^19.0.0-rc.0","reflect-metadata":"^0.2.2","vitnode-backend":`^${n.version}`},devDependencies:{"@nestjs/cli":"^10.4.2","@nestjs/platform-express":"^10.3.10","@nestjs/schematics":"^10.1.2","@types/express":"^4.17.21","@types/node":"^20.14.11","@types/pg":"^8.11.6","@types/react":"^18.3.3","cross-env":"^7.0.3","drizzle-kit":"^0.22.8","drizzle-orm":"^0.31.4",eslint:"^8.57.0","eslint-config-typescript-vitnode":`^${n.version}`,pg:"^8.12.0","source-map-support":"^0.5.21","ts-loader":"^9.5.1","ts-node":"^10.9.2","tsconfig-paths":"^4.2.0",typescript:"^5.5.3"}};(0,$.writeFileSync)((0,H.join)(e,"apps","backend","package.json"),JSON.stringify(l,null,2))};var ke=async({root:o,appName:e,packageManager:t,eslint:i,i18nRouting:n,docker:s})=>{let r=(0,_.join)(__dirname,"..","templates");if(console.log(`Creating a new VitNode app in ${te.default.green(o)}. Using ${te.default.green(t)}...
|
|
27
|
+
`),(0,m.mkdirSync)(o,{recursive:!0}),F(o,e)||process.exit(1),process.chdir(o),(0,m.cpSync)((0,_.join)(r,"basic"),o,{recursive:!0}),xe({appName:e,root:o,packageManager:t,docker:s}),(0,m.renameSync)((0,_.join)(o,".gitignore_template"),(0,_.join)(o,".gitignore")),(0,m.renameSync)((0,_.join)(o,".npmrc_template"),(0,_.join)(o,".npmrc")),t.startsWith("pnpm")){let l=(0,_.join)(o,"apps","frontend","tailwind.config.ts"),c=(0,m.readFileSync)(l,"utf-8").replace("../../node_modules/vitnode-frontend/src/components/**/*.tsx","./node_modules/vitnode-frontend/src/components/**/*.tsx").replace("../../node_modules/vitnode-frontend/src/views/**/*.tsx","./node_modules/vitnode-frontend/src/views/**/*.tsx");(0,m.writeFileSync)(l,c)}t.startsWith("pnpm")&&(0,m.cpSync)((0,_.join)(r,"pnpm"),o,{recursive:!0}),i&&(0,m.cpSync)((0,_.join)(r,"eslint"),o,{recursive:!0}),(0,m.cpSync)(n?(0,_.join)(r,"i18n","with"):(0,_.join)(r,"i18n","without"),o,{recursive:!0})};var E=v(require("picocolors"),1),S=v(require("prompts"),1);var $e=require("child_process"),ie=async o=>new Promise(e=>{(0,$e.exec)(o,(t,i,n)=>{t&&e(void 0),e((i||n).replace(/\s+/g,""))})}),Ee=async()=>{let[o,e,t]=await Promise.all([ie("yarnpkg --version"),ie("npm --version"),ie("pnpm --version")]);return{yarn:o,pnpm:t,npm:e}};var k=o=>{o.aborted&&(process.stdout.write("\x1B[?25h"),process.stdout.write(`
|
|
28
|
+
`),process.exit(1))},Se=async o=>{let e=o.opts(),t={packageManager:e.packageManager,eslint:e.eslint,i18nRouting:e.i18nRouting,install:!e.skipInstall,docker:e.docker};if(!e.packageManager){let i=await Ee(),n=E.default.blue("package manager"),{packageManager:s}=await(0,S.default)({onState:k,name:"packageManager",type:"select",message:`Which ${n} do you want to use?`,initial:e.packageManager,choices:[{title:`npm${i.npm?`@${i.npm}`:""}`,value:"npm",disabled:!i.npm},{title:`pnpm${i.pnpm?`@${i.pnpm}`:""}`,value:"pnpm",disabled:!i.pnpm},{title:`yarn${i.yarn?`@${i.yarn}`:""}`,value:"yarn",disabled:!i.yarn}]});t={...t,packageManager:`${s}@${i[s]}`}}if(e.eslint===void 0){let i=E.default.blue("ESLint"),{eslint:n}=await(0,S.default)({onState:k,type:"toggle",name:"eslint",message:`Would you like to use ${i}?`,initial:e.eslint?"Yes":"No",active:"Yes",inactive:"No"});t={...t,eslint:!!n}}if(e.i18nRouting===void 0){let i=E.default.blue("i18n routing"),{i18nRouting:n}=await(0,S.default)({onState:k,type:"toggle",name:"i18nRouting",message:`Would you like to use ${i}?`,initial:e.i18nRouting?"Yes":"No",active:"Yes",inactive:"No"});t={...t,i18nRouting:!!n}}if(e.docker===void 0){let i=E.default.blue("Dockerfile & Docker Compose"),{docker:n}=await(0,S.default)({onState:k,type:"toggle",name:"docker",message:`Would you like to create ${i}?`,initial:e.i18nRouting?"Yes":"No",active:"Yes",inactive:"No"});t={...t,docker:!!n}}if(e.skipInstall===void 0){let i=E.default.blue("Install dependencies"),{install:n}=await(0,S.default)({onState:k,type:"toggle",name:"install",message:`Would you like to ${i}?`,initial:e.eslint?"Yes":"No",active:"Yes",inactive:"No"});t={...t,install:!!n}}return console.log("program",t),t};var N="",O=new _e().version(Oe.version).argument("[project-directory]").usage(`${b.default.green("[project-directory]")} [options]`).action(o=>{N=o});O.addOption(new be("-pm, --package-manager <package-manager>","Specify the package manager to use").choices(["npm","pnpm","yarn"]));O.option("--eslint","Initialize with eslint config.");O.option("--docker","Initialize with Dockerfile & Docker Compose.");O.option("--no-eslint","Initialize without eslint config.");O.option("--i18n-routing","Initialize with i18n routing.");O.option("--skip-install","Skip installing packages after initializing the project.");O.parse(process.argv);(async()=>{if(console.log(b.default.blue(He.default.textSync("VitNode",{horizontalLayout:"full"}))),!N){let l=await(0,Ne.default)({onState:k,type:"text",name:"path",message:"What is your project named?",initial:"my-vitnode",validate:a=>{let c=Z({name:(0,C.basename)((0,C.resolve)(a))});return c.valid?!0:`Invalid project name: ${c.problems[0]}`}});typeof l.path=="string"&&(N=l.path.trim())}N||(console.log(`
|
|
29
29
|
Please specify the project directory:
|
|
30
30
|
${b.default.cyan(O.name())} ${b.default.green("<project-directory>")}
|
|
31
31
|
For example:
|
|
32
32
|
${b.default.cyan(O.name())} ${b.default.green("my-vitnode-app")}
|
|
33
33
|
|
|
34
|
-
Run ${b.default.cyan(`${O.name()} --help`)} to see all options.`),process.exit(1));let
|
|
34
|
+
Run ${b.default.cyan(`${O.name()} --help`)} to see all options.`),process.exit(1));let o=(0,C.resolve)(N),e=(0,C.basename)(o),t=Z({name:e});t.valid||(console.error(`Could not create a project called ${b.default.red(`"${e}"`)} because of npm naming restrictions:`),t.problems.forEach(l=>console.error(`${b.default.red(b.default.bold("*"))} ${l}`)),process.exit(1));let i=(0,C.resolve)(o),n=(0,C.basename)(i);(0,Ve.existsSync)(i)&&!F(i,n)&&(console.error("The specified directory is not empty."),process.exit(1)),await Ae((0,C.dirname)(i))||(console.error("The application path is not writable, please check folder permissions and try again."),console.error("It is likely you do not have write permissions for this folder."),process.exit(1));let r=await Se(O);await ke({root:i,appName:n,...r})})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-vitnode-app",
|
|
3
|
-
"version": "0.0.7-canary.
|
|
3
|
+
"version": "0.0.7-canary.40",
|
|
4
4
|
"description": "Create a new VitNode app in seconds.",
|
|
5
5
|
"author": "VitNode Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"commander": "^12.1.0",
|
|
29
29
|
"tsup": "^8.1.0",
|
|
30
30
|
"typescript": "^5.5.3",
|
|
31
|
-
"eslint-config-typescript-vitnode": "0.0.7-canary.
|
|
31
|
+
"eslint-config-typescript-vitnode": "0.0.7-canary.40"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"lint": "eslint .",
|
|
@@ -17,8 +17,10 @@ export const createPackagesJSON = ({
|
|
|
17
17
|
appName,
|
|
18
18
|
root,
|
|
19
19
|
packageManager,
|
|
20
|
+
docker,
|
|
20
21
|
}: {
|
|
21
22
|
appName: string;
|
|
23
|
+
docker: boolean;
|
|
22
24
|
packageManager: string;
|
|
23
25
|
root: string;
|
|
24
26
|
}) => {
|
|
@@ -36,6 +38,12 @@ export const createPackagesJSON = ({
|
|
|
36
38
|
build: 'turbo build',
|
|
37
39
|
lint: 'turbo lint',
|
|
38
40
|
'lint:fix': 'turbo lint:fix',
|
|
41
|
+
...(docker
|
|
42
|
+
? {
|
|
43
|
+
'docker:dev':
|
|
44
|
+
'docker compose -f ./docker-compose-dev.yml -p vitnode-development up -d',
|
|
45
|
+
}
|
|
46
|
+
: {}),
|
|
39
47
|
},
|
|
40
48
|
overrides: packageManager.startsWith('npm')
|
|
41
49
|
? {
|
|
@@ -77,7 +85,7 @@ export const createPackagesJSON = ({
|
|
|
77
85
|
},
|
|
78
86
|
dependencies: {
|
|
79
87
|
geist: '^1.3.1',
|
|
80
|
-
next: '15.0.0-canary.
|
|
88
|
+
next: '15.0.0-canary.72',
|
|
81
89
|
react: '^19.0.0-rc.0',
|
|
82
90
|
'react-dom': '^19.0.0-rc.0',
|
|
83
91
|
'next-intl': '^3.17.1',
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
version: '3.8'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
database:
|
|
5
|
+
container_name: vitnode_postgres_development
|
|
6
|
+
image: postgres:16.3-alpine
|
|
7
|
+
restart: unless-stopped
|
|
8
|
+
environment:
|
|
9
|
+
POSTGRES_USER: ${DB_USER-root}
|
|
10
|
+
POSTGRES_PASSWORD: ${DB_PASSWORD-root}
|
|
11
|
+
POSTGRES_DB: vitnode
|
|
12
|
+
command: ['postgres', '-c', 'log_statement=all'] # log all sql queries
|
|
13
|
+
volumes:
|
|
14
|
+
- ./docker/dev/database:/var/lib/postgresql/data
|
|
15
|
+
ports:
|
|
16
|
+
- '5432:5432'
|
|
17
|
+
networks:
|
|
18
|
+
- vitnode_dev
|
|
19
|
+
|
|
20
|
+
pgadmin:
|
|
21
|
+
container_name: vitnode_pgadmin_development
|
|
22
|
+
image: dpage/pgadmin4:latest
|
|
23
|
+
restart: unless-stopped
|
|
24
|
+
environment:
|
|
25
|
+
PGADMIN_DEFAULT_EMAIL: admin@admin.com
|
|
26
|
+
PGADMIN_DEFAULT_PASSWORD: admin
|
|
27
|
+
ports:
|
|
28
|
+
- '5050:80'
|
|
29
|
+
depends_on:
|
|
30
|
+
- database
|
|
31
|
+
networks:
|
|
32
|
+
- vitnode_dev
|
|
33
|
+
|
|
34
|
+
networks:
|
|
35
|
+
vitnode_dev:
|