create-vitnode-app 0.0.7-canary.26 → 0.0.7-canary.28
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/dist/index.cjs +21 -21
- package/package.json +4 -7
- package/templates/basic/.gitignore_template +55 -0
- package/templates/basic/.npmrc_template +1 -0
- package/templates/basic/apps/backend/nest-cli.json +15 -0
- package/templates/basic/apps/backend/src/app.module.ts +23 -0
- package/templates/basic/apps/backend/src/database.ts +19 -0
- package/templates/basic/apps/backend/src/main.ts +27 -0
- package/templates/basic/apps/backend/src/plugins/plugins.module.ts +14 -0
- package/templates/basic/apps/backend/src/plugins/welcome/admin/admin.module.ts +4 -0
- package/templates/basic/apps/backend/src/plugins/welcome/admin/database/drizzle.config.ts +11 -0
- package/templates/basic/apps/backend/src/plugins/welcome/admin/database/functions.ts +6 -0
- package/templates/basic/apps/backend/src/plugins/welcome/admin/database/index.ts +1 -0
- package/templates/basic/apps/backend/src/plugins/welcome/config.json +10 -0
- package/templates/basic/apps/backend/src/plugins/welcome/versions.json +3 -0
- package/templates/basic/apps/backend/src/plugins/welcome/welcome.module.ts +8 -0
- package/templates/basic/apps/backend/tsconfig.build.json +4 -0
- package/templates/basic/apps/backend/tsconfig.json +14 -0
- package/templates/basic/apps/backend/uploads/index.html +0 -0
- package/templates/basic/apps/backend/uploads/private/index.html +0 -0
- package/templates/basic/apps/backend/uploads/public/index.html +0 -0
- package/templates/basic/apps/backend/uploads/temp/index.html +0 -0
- package/templates/basic/apps/frontend/i18n.ts +13 -0
- package/templates/basic/apps/frontend/middleware.ts +7 -0
- package/templates/basic/apps/frontend/next.config.mjs +6 -0
- package/templates/basic/apps/frontend/postcss.config.mjs +9 -0
- package/templates/basic/apps/frontend/tailwind.config.ts +15 -0
- package/templates/basic/apps/frontend/tsconfig.json +19 -0
- package/templates/basic/tsconfig.json +4 -0
- package/templates/create-packages-json.ts +134 -0
- package/templates/eslint/.prettierrc.mjs +11 -0
- package/templates/eslint/apps/backend/.eslintrc.json +5 -0
- package/templates/eslint/apps/frontend/.eslintrc.json +5 -0
- package/templates/pnpm/pnpm-workspace.yaml +2 -0
package/dist/index.cjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`).replace(/^/gm," ".repeat(s))}let
|
|
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),
|
|
2
|
+
"use strict";var Ve=Object.create;var ie=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Pe=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var x=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var Fe=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ne(e))!je.call(o,n)&&n!==t&&ie(o,n,{get:()=>e[n],enumerable:!(i=He(e,n))||i.enumerable});return o};var C=(o,e,t)=>(t=o!=null?Ve(Pe(o)):{},Fe(e||!o||!o.__esModule?ie(t,"default",{value:o,enumerable:!0}):t,o));var E=x(q=>{"use strict";var H=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}},I=class extends H{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};q.CommanderError=H;q.InvalidArgumentError=I});var N=x(M=>{"use strict";var{InvalidArgumentError:De}=E(),W=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 De(`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 Te(o){let e=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+e+">":"["+e+"]"}M.Argument=W;M.humanReadableArgName=Te});var J=x(ne=>{"use strict";var{humanReadableArgName:Ie}=N(),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=>Ie(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,A){if(A){let T=`${d.padEnd(i+r)}${A}`;return t.wrap(T,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 m=t.visibleOptions(e).map(d=>l(t.optionTerm(d),t.optionDescription(d)));if(m.length>0&&(c=c.concat(["Options:",a(m),""])),this.showGlobalOptions){let d=t.visibleGlobalOptions(e).map(A=>l(t.optionTerm(A),t.optionDescription(A)));d.length>0&&(c=c.concat(["Global Options:",a(d),""]))}let w=t.visibleCommands(e).map(d=>l(t.subcommandTerm(d),t.subcommandDescription(d)));return w.length>0&&(c=c.concat(["Commands:",a(w),""])),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
|
-
`),
|
|
7
|
-
|.{1,${l-1}}([${
|
|
8
|
-
`?"":(
|
|
9
|
-
`)}};
|
|
6
|
+
`),u=" ".repeat(i),m="\\s\u200B",w=new RegExp(`
|
|
7
|
+
|.{1,${l-1}}([${m}]|$)|[^${m}]+?([${m}]|$)`,"g"),d=c.match(w)||[];return a+d.map((A,T)=>A===`
|
|
8
|
+
`?"":(T>0?u:"")+A.trimEnd()).join(`
|
|
9
|
+
`)}};ne.Help=R});var G=x(B=>{"use strict";var{InvalidArgumentError:qe}=E(),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=Me(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 qe(`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 We(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 We(o){return o.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Me(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 re=x(se=>{"use strict";function Re(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 Je(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=Re(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]}?)`:""}
|
|
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
|
|
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
|
|
11
|
+
(Did you mean ${i[0]}?)`:""}se.suggestSimilar=Je});var ue=x(ce=>{"use strict";var Le=require("events").EventEmitter,z=require("child_process"),v=require("path"),Y=require("fs"),p=require("process"),{Argument:Ue,humanReadableArgName:Be}=N(),{CommanderError:K}=E(),{Help:Ge}=J(),{Option:oe,DualOptions:ze}=G(),{suggestSimilar:ae}=re(),X=class o extends Le{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 Ge,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 Ue(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 oe(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 oe)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 m=v.resolve(u,h);if(Y.existsSync(m))return m;if(n.includes(v.extname(h)))return;let w=n.find(d=>Y.existsSync(`${m}${d}`));if(w)return`${m}${w}`}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=v.resolve(v.dirname(u),l)}if(l){let u=s(l,r);if(!u&&!e._executableFile&&this._scriptPath){let h=v.basename(this._scriptPath,v.extname(this._scriptPath));h!==this._name&&(u=s(l,`${h}-${e._name}`))}r=u||r}i=n.includes(v.extname(r));let a;p.platform!=="win32"?i?(t.unshift(r),t=le(p.execArgv).concat(t),a=z.spawn(p.argv[0],t,{stdio:"inherit"})):a=z.spawn(r,t,{stdio:"inherit"}):(t.unshift(r),t=le(p.execArgv).concat(t),a=z.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",m=`'${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
|
-
- ${
|
|
17
|
+
- ${h}`;throw new Error(m)}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
|
|
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=>
|
|
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 ze(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=ae(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=ae(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=>Be(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=v.basename(e,v.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
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
|
|
23
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function le(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})}ce.Command=X});var me=x(g=>{"use strict";var{Argument:he}=N(),{Command:Q}=ue(),{CommanderError:Ye,InvalidArgumentError:pe}=E(),{Help:Ke}=J(),{Option:de}=G();g.program=new Q;g.createCommand=o=>new Q(o);g.createOption=(o,e)=>new de(o,e);g.createArgument=(o,e)=>new he(o,e);g.Command=Q;g.Option=de;g.Argument=he;g.Help=Ke;g.CommanderError=Ye;g.InvalidArgumentError=pe;g.InvalidOptionArgumentError=pe});var b=require("path"),Ee=require("fs");var fe=C(me(),1),{program:ot,createCommand:at,createArgument:lt,createOption:ct,CommanderError:ut,InvalidArgumentError:ht,InvalidOptionArgumentError:pt,Command:ge,Argument:dt,Option:_e,Help:mt}=fe.default;var _=C(require("picocolors"),1),ke=C(require("figlet"),1),Se=C(require("prompts"),1);var Oe={name:"create-vitnode-app",version:"0.0.7-canary.27",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 be=C(require("validate-npm-package-name"),1),Z=({name:o})=>{let e=(0,be.default)(o);return e.validForNewPackages?{valid:!0}:{valid:!1,problems:[...e.errors||[],...e.warnings||[]]}};var P=require("fs"),Ce=require("path"),ee=C(require("picocolors"),1);function j(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,P.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:`),console.log();for(let n of i)try{(0,P.lstatSync)((0,Ce.join)(o,n)).isDirectory()?console.log(`${ee.default.blue(n)}/`):console.log(`${n}`)}catch{console.log(`${n}`)}return console.log(`
|
|
24
24
|
Either try using a new directory name, or remove the files listed above.
|
|
25
|
-
`),!1}return!0}var
|
|
26
|
-
`),(0,
|
|
27
|
-
`),process.exit(1))}
|
|
25
|
+
`),!1}return!0}var ve=require("constants"),ye=require("fs/promises");async function Ae(o){try{return await(0,ye.access)(o,ve.W_OK),!0}catch{return!1}}var f=require("fs"),O=require("path"),te=C(require("picocolors"),1);var $=require("fs"),k=require("path"),we=({appName:o,root:e})=>{let t=JSON.parse((0,$.readFileSync)((0,k.join)(__dirname,"..","package.json"),"utf-8")),i={name:o,version:"1.0.0",private:!0,scripts:{"config:init":"vitnode-frontend init",dev:"vitnode-frontend init && turbo dev",build:"turbo build",lint:"turbo lint","lint:fix":"turbo lint:fix"},dependencies:{"drizzle-kit":"^0.22.8","drizzle-orm":"^0.31.4"},devDependencies:{"eslint-config-typescript-vitnode":`^${t.version}`,prettier:"^3.3.3","prettier-plugin-tailwindcss":"^0.6.5",turbo:"^2.0.7",typescript:"^5.4.5"},workspaces:["apps/*"]};(0,$.writeFileSync)((0,k.join)(e,"package.json"),JSON.stringify(i,null,2));let n={name:"frontend",version:"1.0.0",private:!0,scripts:{dev:"next dev --turbo",build:"next build",start:"next start",lint:"eslint .","lint:fix":"eslint . --fix"},dependencies:{next:"15.0.0-rc.0",react:"19.0.0-rc.0","react-dom":"19.0.0-rc.0","next-intl":"^3.17.1","vitnode-frontend":`^${t.version}`},devDependencies:{"@types/node":"^20.14.11","@types/react":"^18.3.3","@types/react-dom":"^18.3.0",eslint:"^8.57.0","eslint-config-typescript-vitnode":`^${t.version}`,typescript:"^5.5.3"}};(0,$.writeFileSync)((0,k.join)(e,"apps","frontend","package.json"),JSON.stringify(n,null,2));let s={name:"backend",version:"1.0.0",private:!0,scripts:{"config:init":"vitnode-backend init",build:"nest build",dev:"vitnode-backend init && cross-env NODE_ENV=development nest start -w",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","reflect-metadata":"^0.2.2","vitnode-backend":`^${t.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":`^${t.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,k.join)(e,"apps","backend","package.json"),JSON.stringify(s,null,2))};var xe=({root:o,appName:e,packageManager:t,eslint:i})=>{let n=(0,O.join)(__dirname,"..","templates");if(console.log(n),console.log(`Creating a new VitNode app in ${te.default.green(o)}. Using ${te.default.green(t)}...
|
|
26
|
+
`),(0,f.mkdirSync)(o,{recursive:!0}),j(o,e)||process.exit(1),process.chdir(o),(0,f.cpSync)((0,O.join)(n,"basic"),o,{recursive:!0}),we({appName:e,root:o}),(0,f.renameSync)((0,O.join)(o,".gitignore_template"),(0,O.join)(o,".gitignore")),(0,f.renameSync)((0,O.join)(o,".npmrc_template"),(0,O.join)(o,".npmrc")),t==="pnpm"){let s=(0,O.join)(o,"frontend","tailwind.config.ts"),l=(0,f.readFileSync)(s,"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,f.writeFileSync)(s,l)}t==="pnpm"&&(0,f.cpSync)((0,O.join)(n,"pnpm"),o,{recursive:!0}),i&&(0,f.cpSync)((0,O.join)(n,"eslint"),o,{recursive:!0})};var F=C(require("picocolors"),1),D=C(require("prompts"),1),S=o=>{o.aborted&&(process.stdout.write("\x1B[?25h"),process.stdout.write(`
|
|
27
|
+
`),process.exit(1))},$e=async o=>{let e=o.opts(),t={packageManager:e.packageManager,eslint:e.eslint,install:!e.skipInstall};if(!e.packageManager){let i=F.default.blue("package manager"),{packageManager:n}=await(0,D.default)({onState:S,name:"packageManager",type:"select",message:`Which ${i} do you want to use?`,initial:e.packageManager,choices:[{title:"npm",value:"npm"},{title:"pnpm",value:"pnpm"},{title:"yarn",value:"yarn",disabled:!0}]});t={...t,packageManager:n}}if(e.eslint===void 0){let i=F.default.blue("ESLint"),{eslint:n}=await(0,D.default)({onState:S,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.skipInstall===void 0){let i=F.default.blue("Install dependencies"),{install:n}=await(0,D.default)({onState:S,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 V="",y=new ge().version(Oe.version).argument("[project-directory]").usage(`${_.default.green("[project-directory]")} [options]`).action(o=>{V=o});y.addOption(new _e("-pm, --package-manager <package-manager>","Specify the package manager to use").choices(["npm","pnpm"]));y.option("--eslint","Initialize with eslint config.");y.option("--no-eslint","Initialize without eslint config.");y.option("--skip-install","Skip installing packages after initializing the project.");y.parse(process.argv);(async()=>{if(console.log(_.default.blue(ke.default.textSync("VitNode",{horizontalLayout:"full"}))),!V){let l=await(0,Se.default)({onState:S,type:"text",name:"path",message:"What is your project named?",initial:"my-app",validate:a=>{let c=Z({name:(0,b.basename)((0,b.resolve)(a))});return c.valid?!0:`Invalid project name: ${c.problems[0]}`}});typeof l.path=="string"&&(V=l.path.trim())}V||(console.log(`
|
|
28
28
|
Please specify the project directory:
|
|
29
|
-
${
|
|
29
|
+
${_.default.cyan(y.name())} ${_.default.green("<project-directory>")}
|
|
30
30
|
For example:
|
|
31
|
-
${
|
|
31
|
+
${_.default.cyan(y.name())} ${_.default.green("my-vitnode-app")}
|
|
32
32
|
|
|
33
|
-
Run ${
|
|
33
|
+
Run ${_.default.cyan(`${y.name()} --help`)} to see all options.`),process.exit(1));let o=(0,b.resolve)(V),e=(0,b.basename)(o),t=Z({name:e});t.valid||(console.error(`Could not create a project called ${_.default.red(`"${e}"`)} because of npm naming restrictions:`),t.problems.forEach(l=>console.error(`${_.default.red(_.default.bold("*"))} ${l}`)),process.exit(1));let i=(0,b.resolve)(o),n=(0,b.basename)(i);(0,Ee.existsSync)(i)&&!j(i,n)&&(console.error("The specified directory is not empty."),process.exit(1)),await Ae((0,b.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 $e(y);xe({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.28",
|
|
4
4
|
"description": "Create a new VitNode app in seconds.",
|
|
5
5
|
"author": "VitNode Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,9 +10,6 @@
|
|
|
10
10
|
"url": "git+https://github.com/aXenDeveloper/VitNode.git",
|
|
11
11
|
"directory": "packages/create-vitnode-app"
|
|
12
12
|
},
|
|
13
|
-
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
],
|
|
16
13
|
"type": "module",
|
|
17
14
|
"bin": {
|
|
18
15
|
"create-vitnode-app": "dist/index.cjs"
|
|
@@ -25,13 +22,13 @@
|
|
|
25
22
|
},
|
|
26
23
|
"devDependencies": {
|
|
27
24
|
"@types/figlet": "^1.5.8",
|
|
28
|
-
"@types/node": "^20",
|
|
25
|
+
"@types/node": "^20.14.11",
|
|
29
26
|
"@types/prompts": "^2.4.9",
|
|
30
27
|
"@types/validate-npm-package-name": "^4.0.2",
|
|
31
28
|
"commander": "^12.1.0",
|
|
32
29
|
"tsup": "^8.1.0",
|
|
33
|
-
"typescript": "^5",
|
|
34
|
-
"eslint-config-typescript-vitnode": "0.0.7-canary.
|
|
30
|
+
"typescript": "^5.5.3",
|
|
31
|
+
"eslint-config-typescript-vitnode": "0.0.7-canary.28"
|
|
35
32
|
},
|
|
36
33
|
"scripts": {
|
|
37
34
|
"lint": "eslint .",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# Dependencies
|
|
4
|
+
node_modules
|
|
5
|
+
.pnp
|
|
6
|
+
.pnp.js
|
|
7
|
+
|
|
8
|
+
# Local env files
|
|
9
|
+
.env
|
|
10
|
+
.env.local
|
|
11
|
+
.env.development.local
|
|
12
|
+
.env.test.local
|
|
13
|
+
.env.production.local
|
|
14
|
+
|
|
15
|
+
# Testing
|
|
16
|
+
coverage
|
|
17
|
+
|
|
18
|
+
# Turbo
|
|
19
|
+
.turbo
|
|
20
|
+
|
|
21
|
+
# Vercel
|
|
22
|
+
.vercel
|
|
23
|
+
|
|
24
|
+
# Build Outputs
|
|
25
|
+
.next/
|
|
26
|
+
out/
|
|
27
|
+
build
|
|
28
|
+
dist
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# Debug
|
|
32
|
+
npm-debug.log*
|
|
33
|
+
yarn-debug.log*
|
|
34
|
+
yarn-error.log*
|
|
35
|
+
|
|
36
|
+
# Misc
|
|
37
|
+
.DS_Store
|
|
38
|
+
*.pem
|
|
39
|
+
|
|
40
|
+
# Docker
|
|
41
|
+
/docker
|
|
42
|
+
|
|
43
|
+
# Others
|
|
44
|
+
/backend/uploads/public/*
|
|
45
|
+
/backend/uploads/private/*
|
|
46
|
+
/backend/uploads/temp/*
|
|
47
|
+
!/backend/uploads/index.html
|
|
48
|
+
!/backend/uploads/public/index.html
|
|
49
|
+
!/backend/uploads/private/index.html
|
|
50
|
+
!/backend/uploads/temp/index.html
|
|
51
|
+
/backend/schema.gql
|
|
52
|
+
|
|
53
|
+
# Configuration
|
|
54
|
+
/backend/src/plugins/*/admin/database/migrations
|
|
55
|
+
/backend/src/plugins/core/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
package-manager-strict=false
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/nest-cli",
|
|
3
|
+
"collection": "@nestjs/schematics",
|
|
4
|
+
"sourceRoot": "src",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"deleteOutDir": true,
|
|
7
|
+
"builder": {
|
|
8
|
+
"type": "swc",
|
|
9
|
+
"options": {
|
|
10
|
+
"extensions": [".ts", ".tsx"]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"typeCheck": true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
|
|
3
|
+
import { Module } from '@nestjs/common';
|
|
4
|
+
import { VitNodeCoreModule } from 'vitnode-backend';
|
|
5
|
+
|
|
6
|
+
import { PluginsModule } from './plugins/plugins.module';
|
|
7
|
+
import { DATABASE_ENVS, schemaDatabase } from './database';
|
|
8
|
+
|
|
9
|
+
@Module({
|
|
10
|
+
imports: [
|
|
11
|
+
VitNodeCoreModule.register({
|
|
12
|
+
paths: {
|
|
13
|
+
envFile: join(process.cwd(), '..', '..', '.env'),
|
|
14
|
+
},
|
|
15
|
+
database: {
|
|
16
|
+
config: DATABASE_ENVS,
|
|
17
|
+
schemaDatabase,
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
PluginsModule,
|
|
21
|
+
],
|
|
22
|
+
})
|
|
23
|
+
export class AppModule {}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// ! DO NOT REMOVE, MODIFY OR MOVE THIS FILE!!!
|
|
2
|
+
|
|
3
|
+
import tableCore from '@/plugins/core/admin/database/index';
|
|
4
|
+
import tableWelcome from '@/plugins/welcome/admin/database/index';
|
|
5
|
+
// ! === IMPORT ===
|
|
6
|
+
|
|
7
|
+
export const schemaDatabase = {
|
|
8
|
+
...tableWelcome,
|
|
9
|
+
// ! === MODULE ===
|
|
10
|
+
...tableCore,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const DATABASE_ENVS = {
|
|
14
|
+
host: process.env.DB_HOST || 'localhost',
|
|
15
|
+
port: process.env.DB_PORT ? +process.env.DB_PORT : 5432,
|
|
16
|
+
user: process.env.DB_USER || 'root',
|
|
17
|
+
password: process.env.DB_PASSWORD || 'root',
|
|
18
|
+
database: process.env.DB_DATABASE || 'vitnode',
|
|
19
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { NestFactory } from '@nestjs/core';
|
|
3
|
+
import { INestApplication } from '@nestjs/common';
|
|
4
|
+
import { nestjsMainApp } from 'vitnode-backend';
|
|
5
|
+
|
|
6
|
+
import { AppModule } from './app.module';
|
|
7
|
+
|
|
8
|
+
async function bootstrap() {
|
|
9
|
+
const app: INestApplication = await NestFactory.create(AppModule);
|
|
10
|
+
|
|
11
|
+
nestjsMainApp(app, {
|
|
12
|
+
cors: {
|
|
13
|
+
origin: [
|
|
14
|
+
process.env.NEXT_PUBLIC_FRONTEND_URL
|
|
15
|
+
? process.env.NEXT_PUBLIC_FRONTEND_URL
|
|
16
|
+
: 'http://localhost:3000',
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await app.listen(process.env.PORT ?? '8080', null, () => {
|
|
22
|
+
console.log(
|
|
23
|
+
`Application is running on: http://localhost:${process.env.PORT ?? 8080}/graphql`,
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
bootstrap();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// ! DO NOT REMOVE, MODIFY OR MOVE THIS FILE!!!
|
|
2
|
+
|
|
3
|
+
import { Module } from '@nestjs/common';
|
|
4
|
+
|
|
5
|
+
import { WelcomeModule } from './welcome/welcome.module';
|
|
6
|
+
// ! === IMPORT ===
|
|
7
|
+
|
|
8
|
+
@Module({
|
|
9
|
+
imports: [
|
|
10
|
+
WelcomeModule,
|
|
11
|
+
// ! === MODULE ===
|
|
12
|
+
],
|
|
13
|
+
})
|
|
14
|
+
export class PluginsModule {}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ! DO NOT REMOVE, MODIFY OR MOVE THIS FILE!!!
|
|
2
|
+
import { defineConfig } from 'drizzle-kit';
|
|
3
|
+
|
|
4
|
+
import { DATABASE_ENVS } from '@/database';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
dialect: 'postgresql',
|
|
8
|
+
dbCredentials: DATABASE_ENVS,
|
|
9
|
+
schema: './plugins/welcome/admin/database/schema/*.ts',
|
|
10
|
+
out: './plugins/welcome/admin/database/migrations/',
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Welcome",
|
|
3
|
+
"description": "Basic plugin with default page.",
|
|
4
|
+
"code": "welcome",
|
|
5
|
+
"author": "VitNode",
|
|
6
|
+
"author_url": "https://vitnode.com/",
|
|
7
|
+
"support_url": "https://github.com/aXenDeveloper/vitnode/issues",
|
|
8
|
+
"allow_default": true,
|
|
9
|
+
"nav": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "eslint-config-typescript-vitnode/tsconfig.nest.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"baseUrl": "./",
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"paths": {
|
|
10
|
+
"@/*": ["./src/*", "./node_modules/vitnode-backend/dist/*"]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"exclude": ["uploads"]
|
|
14
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getRequestConfig } from 'next-intl/server';
|
|
2
|
+
import { i18nConfig } from 'vitnode-frontend/i18n';
|
|
3
|
+
|
|
4
|
+
export default getRequestConfig(async args => {
|
|
5
|
+
const config = await i18nConfig({
|
|
6
|
+
...args,
|
|
7
|
+
pathsToMessagesFromPlugins: async ({ plugin, locale }) => {
|
|
8
|
+
return import(`./plugins/${plugin}/langs/${locale}.json`);
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
return config;
|
|
13
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Config } from 'tailwindcss';
|
|
2
|
+
import vitnodeConfig from 'vitnode-frontend/tailwind.config';
|
|
3
|
+
|
|
4
|
+
const config = {
|
|
5
|
+
presets: [vitnodeConfig],
|
|
6
|
+
content: [
|
|
7
|
+
'../../node_modules/vitnode-frontend/src/components/**/*.tsx',
|
|
8
|
+
'../../node_modules/vitnode-frontend/src/views/**/*.tsx',
|
|
9
|
+
'./components/**/*.{ts,tsx}',
|
|
10
|
+
'./app/**/*.{ts,tsx}',
|
|
11
|
+
'./plugins/templates/**/*.{ts,tsx}',
|
|
12
|
+
],
|
|
13
|
+
} satisfies Config;
|
|
14
|
+
|
|
15
|
+
export default config;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "eslint-config-typescript-vitnode/tsconfig.next.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ES2022",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"baseUrl": "./",
|
|
8
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
9
|
+
"plugins": [
|
|
10
|
+
{
|
|
11
|
+
"name": "next"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"paths": {
|
|
15
|
+
"@/*": ["./*"]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
interface PackageJSON {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
private: boolean;
|
|
8
|
+
devDependencies?: Record<string, string>;
|
|
9
|
+
dependencies?: Record<string, string>;
|
|
10
|
+
scripts?: Record<string, string>;
|
|
11
|
+
workspaces?: string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const createPackagesJSON = ({
|
|
15
|
+
appName,
|
|
16
|
+
root,
|
|
17
|
+
}: {
|
|
18
|
+
appName: string;
|
|
19
|
+
root: string;
|
|
20
|
+
}) => {
|
|
21
|
+
const pkg: PackageJSON = JSON.parse(
|
|
22
|
+
readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const basePackageJSON: PackageJSON = {
|
|
26
|
+
name: appName,
|
|
27
|
+
version: '1.0.0',
|
|
28
|
+
private: true,
|
|
29
|
+
scripts: {
|
|
30
|
+
'config:init': 'vitnode-frontend init',
|
|
31
|
+
dev: 'vitnode-frontend init && turbo dev',
|
|
32
|
+
build: 'turbo build',
|
|
33
|
+
lint: 'turbo lint',
|
|
34
|
+
'lint:fix': 'turbo lint:fix',
|
|
35
|
+
},
|
|
36
|
+
dependencies: {
|
|
37
|
+
'drizzle-kit': '^0.22.8',
|
|
38
|
+
'drizzle-orm': '^0.31.4',
|
|
39
|
+
},
|
|
40
|
+
devDependencies: {
|
|
41
|
+
'eslint-config-typescript-vitnode': `^${pkg.version}`,
|
|
42
|
+
prettier: '^3.3.3',
|
|
43
|
+
'prettier-plugin-tailwindcss': '^0.6.5',
|
|
44
|
+
turbo: '^2.0.7',
|
|
45
|
+
typescript: '^5.4.5',
|
|
46
|
+
},
|
|
47
|
+
workspaces: ['apps/*'],
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
writeFileSync(
|
|
51
|
+
join(root, 'package.json'),
|
|
52
|
+
JSON.stringify(basePackageJSON, null, 2),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const frontendPackagesJSON: PackageJSON = {
|
|
56
|
+
name: 'frontend',
|
|
57
|
+
version: '1.0.0',
|
|
58
|
+
private: true,
|
|
59
|
+
scripts: {
|
|
60
|
+
dev: 'next dev --turbo',
|
|
61
|
+
build: 'next build',
|
|
62
|
+
start: 'next start',
|
|
63
|
+
lint: 'eslint .',
|
|
64
|
+
'lint:fix': 'eslint . --fix',
|
|
65
|
+
},
|
|
66
|
+
dependencies: {
|
|
67
|
+
next: '15.0.0-rc.0',
|
|
68
|
+
react: '19.0.0-rc.0',
|
|
69
|
+
'react-dom': '19.0.0-rc.0',
|
|
70
|
+
'next-intl': '^3.17.1',
|
|
71
|
+
'vitnode-frontend': `^${pkg.version}`,
|
|
72
|
+
},
|
|
73
|
+
devDependencies: {
|
|
74
|
+
'@types/node': '^20.14.11',
|
|
75
|
+
'@types/react': '^18.3.3',
|
|
76
|
+
'@types/react-dom': '^18.3.0',
|
|
77
|
+
eslint: '^8.57.0',
|
|
78
|
+
'eslint-config-typescript-vitnode': `^${pkg.version}`,
|
|
79
|
+
typescript: '^5.5.3',
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
writeFileSync(
|
|
84
|
+
join(root, 'apps', 'frontend', 'package.json'),
|
|
85
|
+
JSON.stringify(frontendPackagesJSON, null, 2),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const backendPackagesJSON: PackageJSON = {
|
|
89
|
+
name: 'backend',
|
|
90
|
+
version: '1.0.0',
|
|
91
|
+
private: true,
|
|
92
|
+
scripts: {
|
|
93
|
+
'config:init': 'vitnode-backend init',
|
|
94
|
+
build: 'nest build',
|
|
95
|
+
dev: 'vitnode-backend init && cross-env NODE_ENV=development nest start -w',
|
|
96
|
+
start: 'node dist/main',
|
|
97
|
+
lint: 'eslint .',
|
|
98
|
+
'lint:fix': 'eslint . --fix',
|
|
99
|
+
},
|
|
100
|
+
dependencies: {
|
|
101
|
+
'@nestjs/common': '^10.3.10',
|
|
102
|
+
'@nestjs/core': '^10.3.10',
|
|
103
|
+
'@nestjs/graphql': '^12.2.0',
|
|
104
|
+
'@react-email/components': '^0.0.21',
|
|
105
|
+
'reflect-metadata': '^0.2.2',
|
|
106
|
+
'vitnode-backend': `^${pkg.version}`,
|
|
107
|
+
},
|
|
108
|
+
devDependencies: {
|
|
109
|
+
'@nestjs/cli': '^10.4.2',
|
|
110
|
+
'@nestjs/platform-express': '^10.3.10',
|
|
111
|
+
'@nestjs/schematics': '^10.1.2',
|
|
112
|
+
'@types/express': '^4.17.21',
|
|
113
|
+
'@types/node': '^20.14.11',
|
|
114
|
+
'@types/pg': '^8.11.6',
|
|
115
|
+
'@types/react': '^18.3.3',
|
|
116
|
+
'cross-env': '^7.0.3',
|
|
117
|
+
'drizzle-kit': '^0.22.8',
|
|
118
|
+
'drizzle-orm': '^0.31.4',
|
|
119
|
+
eslint: '^8.57.0',
|
|
120
|
+
'eslint-config-typescript-vitnode': `^${pkg.version}`,
|
|
121
|
+
pg: '^8.12.0',
|
|
122
|
+
'source-map-support': '^0.5.21',
|
|
123
|
+
'ts-loader': '^9.5.1',
|
|
124
|
+
'ts-node': '^10.9.2',
|
|
125
|
+
'tsconfig-paths': '^4.2.0',
|
|
126
|
+
typescript: '^5.5.3',
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
writeFileSync(
|
|
131
|
+
join(root, 'apps', 'backend', 'package.json'),
|
|
132
|
+
JSON.stringify(backendPackagesJSON, null, 2),
|
|
133
|
+
);
|
|
134
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import vitnodePrettier from "eslint-config-typescript-vitnode/prettierrc.mjs";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @see https://prettier.io/docs/en/configuration.html
|
|
5
|
+
* @type {import("prettier").Config}
|
|
6
|
+
*/
|
|
7
|
+
const config = {
|
|
8
|
+
...vitnodePrettier,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default config;
|