@h3ravel/console 11.2.1 → 11.3.1

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/bin/fire.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));require(`tsx/esm`);let c=require(`@h3ravel/core`);c=s(c);let l=require(`@h3ravel/shared`);l=s(l);let u=require(`fs/promises`);u=s(u);let d=require(`path`);d=s(d);let f=require(`fs`);f=s(f);let p=require(`node:fs/promises`);p=s(p);let m=require(`@h3ravel/support`);m=s(m);let h=require(`dayjs`);h=s(h);let g=require(`node:fs`);g=s(g);let _=require(`node:path`);_=s(_);let v=require(`@h3ravel/http`);v=s(v);let y=require(`@h3ravel/router`);y=s(y);let b=require(`@h3ravel/database`);b=s(b);let x=require(`@h3ravel/cache`);x=s(x);let S=require(`@h3ravel/queue`);S=s(S);let C=require(`@h3ravel/mail`);C=s(C);let w=require(`@h3ravel/config`);w=s(w);let T=require(`commander`);T=s(T);let E=require(`child_process`);E=s(E);let D=require(`tsdown`);D=s(D);var O=class extends c.ConsoleCommand{};const k=String.raw`
2
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));require(`tsx/esm`);let c=require(`@h3ravel/core`);c=s(c);let l=require(`@h3ravel/shared`);l=s(l);let u=require(`node:fs/promises`);u=s(u);let d=require(`@h3ravel/support`);d=s(d);let f=require(`dayjs`);f=s(f);let p=require(`node:fs`);p=s(p);let m=require(`node:path`);m=s(m);let h=require(`@h3ravel/http`);h=s(h);let g=require(`@h3ravel/router`);g=s(g);let _=require(`@h3ravel/database`);_=s(_);let v=require(`@h3ravel/cache`);v=s(v);let y=require(`@h3ravel/queue`);y=s(y);let b=require(`@h3ravel/mail`);b=s(b);let x=require(`@h3ravel/config`);x=s(x);let S=require(`commander`);S=s(S);let C=require(`path`);C=s(C);let w=require(`child_process`);w=s(w);let T=require(`tsdown`);T=s(T);var E=class extends c.ConsoleCommand{};const D=String.raw`
3
3
  111
4
4
  111111111
5
5
  1111111111 111111
@@ -21,19 +21,19 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
21
21
  111111 111 111111
22
22
  111111111
23
23
  110
24
- `,A=String.raw`
24
+ `,O=String.raw`
25
25
  _ _ _____ _
26
26
  | | | |___ / _ __ __ ___ _____| |
27
27
  | |_| | |_ \| '__/ _ \ \ / / _ \ |
28
28
  | _ |___) | | | (_| |\ V / __/ |
29
29
  |_| |_|____/|_| \__,_| \_/ \___|_|
30
30
 
31
- `;var j=class extends O{signature=`list`;description=`List all available commands`;async handle(){let e=[{short:`-h`,long:`--help`,description:`Display help for the given command. When no command is given display help for the list command`}].concat(this.program.options).map(e=>l.Logger.describe(l.Logger.log(` `+[e.short,e.long].filter(e=>!!e).join(`, `),`green`,!1),e.description,25,!1).join(``)),t=this.program.commands.map(e=>l.Logger.describe(l.Logger.log(` `+e.name(),`green`,!1),e.description(),25,!1).join(``)).reduce((e,t)=>{let n=t.replace(/\x1b\[\d+m/g,``),r=n.includes(`:`)?n.split(`:`)[0].trim():`__root__`;return e[r]??=[],e[r].push(t),e},{}),n=Object.entries(t).map(([e,t])=>{let n=e===`__root__`?``:e;return[l.Logger.log(n,`yellow`,!1),t.join(`
31
+ `;var k=class extends E{signature=`list`;description=`List all available commands`;async handle(){let e=[{short:`-h`,long:`--help`,description:`Display help for the given command. When no command is given display help for the list command`}].concat(this.program.options).map(e=>l.Logger.describe(l.Logger.log(` `+[e.short,e.long].filter(e=>!!e).join(`, `),`green`,!1),e.description,25,!1).join(``)),t=this.program.commands.map(e=>l.Logger.describe(l.Logger.log(` `+e.name(),`green`,!1),e.description(),25,!1).join(``)).reduce((e,t)=>{let n=t.replace(/\x1b\[\d+m/g,``),r=n.includes(`:`)?n.split(`:`)[0].trim():`__root__`;return e[r]??=[],e[r].push(t),e},{}),n=Object.entries(t).map(([e,t])=>{let n=e===`__root__`?``:e;return[l.Logger.log(n,`yellow`,!1),t.join(`
32
32
  `)].join(`
33
- `)});l.Logger.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(A),console.log(``),l.Logger.log(`Usage:`,`yellow`),l.Logger.log(` command [options] [arguments]`,`white`),console.log(``),l.Logger.log(`Options:`,`yellow`),console.log(e.join(`
33
+ `)});l.Logger.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(O),console.log(``),l.Logger.log(`Usage:`,`yellow`),l.Logger.log(` command [options] [arguments]`,`white`),console.log(``),l.Logger.log(`Options:`,`yellow`),console.log(e.join(`
34
34
  `).trim()),console.log(``),l.Logger.log(`Available Commands:`,`yellow`),console.log(n.join(`
35
35
 
36
- `).trim())}};function M(e,t){let n=(0,d.resolve)(`.`,e),r;for((0,f.statSync)(n).isDirectory()||(n=(0,d.dirname)(n));;){if(r=t(n,(0,f.readdirSync)(n)),r)return(0,d.resolve)(n,r);if(n=(0,d.dirname)(r=n),r===n)break}}var N=class{static findModulePkg(e,t){let n=e.replace(/\\/g,`/`).split(`/`),r=``;n.length>0&&n[0][0]===`@`&&(r+=n.shift()+`/`),r+=n.shift();let i=d.default.join(t??process.cwd(),`node_modules`,r),a=this.findUpConfig(i,`package`,[`json`]);if(a)return d.default.join(d.default.dirname(a),n.join(`/`))}static async fileExists(e){try{return await(0,u.access)(e),!0}catch{return!1}}static findUpConfig(e,t,n){return M(e,(e,r)=>{for(let e of n){let n=`${t}.${e}`;if(r.includes(n))return n}return!1})}},P=class e{static CREATE_PATTERNS=[/^create_(\w+)_table$/,/^create_(\w+)$/];static CHANGE_PATTERNS=[/.+_(to|from|in)_(\w+)_table$/,/.+_(to|from|in)_(\w+)$/];static guess(t){for(let n of e.CREATE_PATTERNS){let e=t.match(n);if(e)return[e[1],!0]}for(let n of e.CHANGE_PATTERNS){let e=t.match(n);if(e)return[e[2],!1]}return[]}},F=class{static findModulePkg(e,t){let n=e.replace(/\\/g,`/`).split(`/`),r=``;n.length>0&&n[0][0]===`@`&&(r+=n.shift()+`/`),r+=n.shift();let i=d.default.join(t??process.cwd(),`node_modules`,r),a=this.findUpConfig(i,`package`,[`json`]);if(a)return d.default.join(d.default.dirname(a),n.join(`/`))}static async fileExists(e){try{return await(0,u.access)(e),!0}catch{return!1}}static findUpConfig(e,t,n){return M(e,(e,r)=>{for(let e of n){let n=`${t}.${e}`;if(r.includes(n))return n}return!1})}},I=class extends O{signature=`#make:
36
+ `).trim())}},A=class e{static CREATE_PATTERNS=[/^create_(\w+)_table$/,/^create_(\w+)$/];static CHANGE_PATTERNS=[/.+_(to|from|in)_(\w+)_table$/,/.+_(to|from|in)_(\w+)$/];static guess(t){for(let n of e.CREATE_PATTERNS){let e=t.match(n);if(e)return[e[1],!0]}for(let n of e.CHANGE_PATTERNS){let e=t.match(n);if(e)return[e[2],!1]}return[]}},j=class extends E{signature=`#make:
37
37
  {controller : Create a new controller class.
38
38
  | {--a|api : Exclude the create and edit methods from the controller}
39
39
  | {--m|model= : Generate a resource controller for the given model}
@@ -66,5 +66,5 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
66
66
  | {--force : Create the model even if it already exists}
67
67
  }
68
68
  {^name : The name of the [name] to generate}
69
- `;description=`Generate component classes`;async handle(){let e=this.dictionary.baseCommand??this.dictionary.name,t={controller:`makeController`,resource:`makeResource`,migration:`makeMigration`,factory:`makeFactory`,seeder:`makeSeeder`,model:`makeModel`,view:`makeView`};try{await this?.[t[e]]()}catch(e){l.Logger.error(e)}}async makeController(){let e=this.option(`api`)?`-resource`:``,t=this.argument(`name`),n=this.option(`force`),r=_.default.join(app_path(`Http/Controllers`),t+`.ts`),i=F.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,a=_.default.join(i,`dist/stubs/controller${e}.stub`);!n&&(0,g.existsSync)(r)&&l.Logger.error(`ERORR: ${t} controller already exists`);let o=await(0,p.readFile)(a,`utf-8`);o=o.replace(/{{ name }}/g,t),await(0,p.writeFile)(r,o),l.Logger.split(`INFO: Controller Created`,l.Logger.log(_.default.basename(r),`gray`,!1))}makeResource(){l.Logger.success(`Resource support is not yet available`)}async makeMigration(){let e=this.argument(`name`),t=(0,h.default)().format(`YYYY_MM_DD_HHmmss`),n=_.default.join(database_path(`migrations`),`${t}_${e}.ts`),r=N.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,i=this.option(`create`,!1),a=this.option(`table`);if(!a&&typeof i==`string`&&(a=i,i=!0),!a){let t=P.guess(e);a=t[0],i=!!t[1]}let o=_.default.join(r,this.getMigrationStubName(a,i)),s=await(0,p.readFile)(o,`utf-8`);a!==null&&(s=s.replace(/DummyTable|{{\s*table\s*}}/g,a)),l.Logger.info(`INFO: Creating Migration`),await this.kernel.ensureDirectoryExists(_.default.dirname(n)),await(0,p.writeFile)(n,s),l.Logger.split(`INFO: Migration Created`,l.Logger.log(_.default.basename(n),`gray`,!1))}makeFactory(){l.Logger.success(`Factory support is not yet available`)}makeSeeder(){l.Logger.success(`Seeder support is not yet available`)}async makeModel(){let e=this.option(`type`,`ts`),t=this.argument(`name`),n=this.argument(`force`),r=_.default.join(app_path(`Models`),t.toLowerCase(),`.`+e);!n&&(0,g.existsSync)(r)&&l.Logger.error(`ERORR: ${t} view already exists`);let i=N.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,a=_.default.join(i,`dist/stubs/model-${e}.stub`),o=await(0,p.readFile)(a,`utf-8`);o=o.replace(/{{ name }}/g,t),await(0,p.writeFile)(r,o),l.Logger.split(`INFO: Model Created`,l.Logger.log(_.default.basename(r),`gray`,!1))}async makeView(){let e=this.argument(`name`),t=this.option(`force`),n=_.default.join(base_path(`src/resources/views`),e+`.edge`);e.includes(`/`)&&await(0,p.mkdir)((0,m.beforeLast)(n,`/`),{recursive:!0}),!t&&(0,g.existsSync)(n)&&l.Logger.error(`ERORR: ${e} view already exists`),await(0,p.writeFile)(n,`{{-- src/resources/views/${e}.edge --}}`),l.Logger.split(`INFO: View Created`,l.Logger.log(`src/resources/views/${e}.edge`,`gray`,!1))}getMigrationStubName(e,t=!1,n=`ts`){let r;return r=e?t?`migration.create-${n}.stub`:`migration.update-${n}.stub`:`migration-${n}.stub`,`dist/stubs/`+r}},L=[v.HttpServiceProvider,w.ConfigServiceProvider,y.RouteServiceProvider,y.AssetsServiceProvider,b.DatabaseServiceProvider,x.CacheServiceProvider,S.QueueServiceProvider,C.MailServiceProvider],R=class e{static parseOptions(t){let n=[],r=/\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g,i;for(;(i=r.exec(t))!==null;){let t=i[1][0]===`^`||/:[#^]/.test(i[1]),r=([`#`,`^`].includes(i[1][0])||/:[#^]/.test(i[1]))&&!t,a=i[1].trim().replace(/[#^]/,``),o=a.indexOf(`:`);if(o===-1){n.push({name:a});continue}let s=a.substring(0,o).trim(),c=a.substring(o+1).trim(),l=c,u,d=c.indexOf(`|`);if(d!==-1){l=c.substring(0,d).trim();let t=c.substring(d+1).trim().replace(/^\{/,``).trim();u=e.parseOptions(`{`+t+`}`)}else l=l.trim();let f=s,p=/[^a-zA-Z0-9_|-]/.test(f),m=!1;f.endsWith(`?*`)?(p=!1,m=!0,f=f.slice(0,-2)):f.endsWith(`*`)?(m=!0,f=f.slice(0,-1)):f.endsWith(`?`)&&(p=!1,f=f.slice(0,-1));let h=f.startsWith(`--`),g,_;if(h){let e=f.split(`|`).map(e=>e.trim());g=[];for(let t of e){t.startsWith(`--`)&&t.slice(2).length===1?t=`-`+t.slice(2):t.startsWith(`-`)&&!t.startsWith(`--`)&&t.slice(1).length>1?t=`--`+t.slice(1):!t.startsWith(`-`)&&t.slice(1).length>1&&(t=`--`+t);let e=t.indexOf(`=`);if(e!==-1){g.push(t.substring(0,e));let n=t.substring(e+1);_=n===`*`?[]:n===`true`||n===`false`||!n&&!p?n===`true`:isNaN(Number(n))?n:Number(n)}else g.push(t)}}n.push({name:h?g[g.length-1]:f,required:p,multiple:m,description:l,flags:g,shared:t,isFlag:h,isHidden:r,defaultValue:_,nestedOptions:u})}return n}static parseSignature(t,n){let r=t.split(`
70
- `).map(e=>e.trim()).filter(e=>e.length>0),i=[`#`,`^`].includes(r[0][0])||/:[#^]/.test(r[0]),a=r[0].replace(/[^\w=:-]/g,``),o=n.getDescription(),s=a.endsWith(`:`),c=r.slice(1).join(` `),l=e.parseOptions(c);return s?{baseCommand:a.slice(0,-1),isNamespaceCommand:s,subCommands:l.filter(e=>!e.flags&&!e.isHidden),description:o,commandClass:n,options:l.filter(e=>!!e.flags),isHidden:i}:{baseCommand:a,isNamespaceCommand:s,options:l,description:o,commandClass:n,isHidden:i}}};function z(e={}){let t,n,r=e.args||[],i=e.allowRestarts||!1,a=e.input,o=e.options||e;return delete o.args,delete o.allowRestarts,{name:`run`,buildStart(e){let n=a??e.input;if(typeof n==`string`&&(n=[n]),typeof n==`object`&&(n=Object.values(n)),n.length>1)throw Error("@rollup/plugin-run must have a single entry point; consider setting the `input` option");t=(0,d.resolve)(n[0])},generateBundle(e,t,n){n||this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`)},writeBundle(e,a){let s=(e,t)=>{n&&n.kill(),n=(0,E.fork)((0,d.join)(e,t),r,o)},c=e.dir||(0,d.dirname)(e.file),l=Object.keys(a).find(e=>{let n=a[e];return n.isEntry&&n.facadeModuleId===t});l?(s(c,l),i&&(process.stdin.resume(),process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{let t=e.toString().trim().toLowerCase();t===`rs`||t===`restart`||e.toString().charCodeAt(0)===11?s(c,l):(t===`cls`||t===`clear`||e.toString().charCodeAt(0)===12)&&console.clear()}))):this.error(`@rollup/plugin-run could not find output chunk`)}}}const B=process.env.NODE_ENV||`development`,V=B===`development`?`.h3ravel/serve`:`dist`,H={outDir:V,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:B===`development`,clean:!0,shims:!0,copy:[{from:`public`,to:V},`src/resources`,`src/database`],env:B===`development`?{NODE_ENV:B,SRC_PATH:V}:{},watch:B===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,plugins:B===`development`&&process.env.CLI_BUILD!==`true`?[z({env:Object.assign({},process.env,{NODE_ENV:B,SRC_PATH:V}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]};var U=H,W=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new I(this.app,this.kernel),new j(this.app,this.kernel)].forEach(e=>this.addCommand(e))}async loadDiscoveredCommands(){let e=[...this.app.registeredCommands.map(e=>new e(this.app,this.kernel))],t=app_path(`Console/Commands/*.js`).replace(`/src/`,`/.h3ravel/serve/`);for await(let n of(0,p.glob)(t)){let t=_.default.basename(n).replace(`.js`,``);try{let r=(await import(n))[t];e.push(new r(this.app,this.kernel))}catch{}}e.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(R.parseSignature(e.getSignature(),e))}initialize(){let e=l.Logger.parse([[`Musket CLI:`,`white`],[this.kernel.consolePackage.version,`green`]],` `,!1),t=l.Logger.parse([[`H3ravel Framework:`,`white`],[this.kernel.modulePackage.version,`green`]],` `,!1),n={quiet:[`-q, --quiet`,`Do not output any message`],silent:[`--silent`,`Do not output any message`],verbose:[`-v, --verbose <number>`,`Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug`],lock:[`--lock`,`Locked and loaded, do not ask any interactive question`]};T.program.name(`musket`).version(`${e}\n${t}`).description(A).addOption(new T.Option(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new T.Option(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new T.Option(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new T.Option(n.lock[0],n.lock[1])).action(async()=>{let e=new j(this.app,this.kernel);e.setInput(T.program.opts(),T.program.args,T.program.registeredArguments,{},T.program),e.handle()}),T.program.command(`init`).description(`Initialize H3ravel.`).action(async()=>{l.Logger.success(`Initialized: H3ravel has been initialized!`)});for(let e=0;e<this.commands.length;e++){let t=this.commands[e],r=t.commandClass;if(t.isNamespaceCommand&&t.subCommands){let e=t.isHidden?T.program:T.program.command(t.baseCommand).description(t.description??``).addOption(new T.Option(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new T.Option(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new T.Option(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new T.Option(n.lock[0],n.lock[1])).action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,T.program),await r.handle()});(t.options?.length??0)>0&&t.options?.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(t=>{this.makeOption(t,e)}),t.subCommands.filter((e,t,n)=>!e.shared&&n.findIndex(t=>t.name===e.name)===t).forEach(e=>{let i=T.program.command(`${t.baseCommand}:${e.name}`).description(e.description||``).addOption(new T.Option(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new T.Option(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new T.Option(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new T.Option(n.lock[0],n.lock[1])).action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,e,T.program),await r.handle()});t.subCommands?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,i,!1,e)}),t.options?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,i,!1,e)}),e.nestedOptions&&e.nestedOptions.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(e=>{this.makeOption(e,i)})})}else{let e=T.program.command(t.baseCommand).description(t.description??``);t?.options?.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(t=>{this.makeOption(t,e,!0)}),e.action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,T.program),await r.handle()})}}return T.program.hook(`preAction`,async(e,t)=>{t.name()!==`fire`&&await(0,D.build)({...U,watch:!1,plugins:[]})}),T.program}makeOption(e,t,n,r){let i=e.description?.replace(/\[(\w+)\]/g,(e,t)=>r?.[t]??`[${t}]`)??``,a=e.name.replaceAll(`-`,``);if(e.isFlag)if(n){let n=e.flags?.map(e=>e.length===1?`-${e}`:`--${e}`).join(`, `).replaceAll(`----`,`--`).replaceAll(`---`,`-`);t.option(n||``,i,String(e.defaultValue)||void 0)}else t.option(e.flags?.join(`, `)+(e.required?` <${a}>`:``),i,e.defaultValue);else t.argument(e.required?`<${e.name}>`:`[${e.name}]`,i,e.defaultValue)}static async parse(t){return(await new e(t.app,t).build()).parseAsync()}},G=class e extends c.ConsoleKernel{constructor(e){super(e),this.app=e}static init(t){let n=new e(t);Promise.all([n.loadRequirements()]).then(([e])=>e.run())}async run(){await W.parse(this),process.exit(0)}async loadRequirements(){this.cwd=_.default.join(process.cwd(),this.basePath),this.modulePath=F.findModulePkg(`@h3ravel/core`,this.cwd)??``,this.consolePath=F.findModulePkg(`@h3ravel/console`,this.cwd)??``;try{this.modulePackage=await import(_.default.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(_.default.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},K=class extends c.ServiceProvider{static priority=992;static console=!0;register(){}boot(){G.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}},q=class{async fire(){let e=new c.Application(process.cwd()),t=app_path(`Providers/*.js`).replace(`/src/`,`/.h3ravel/serve/`);for await(let e of(0,p.glob)(t)){let t=_.default.basename(e).replace(`.js`,``);try{L.push((await import(e))[t])}catch{}}L.push(K),e.registerProviders(L),await e.registerConfiguredProviders(),await e.boot()}};new q().fire();
69
+ `;description=`Generate component classes`;async handle(){let e=this.dictionary.baseCommand??this.dictionary.name,t={controller:`makeController`,resource:`makeResource`,migration:`makeMigration`,factory:`makeFactory`,seeder:`makeSeeder`,model:`makeModel`,view:`makeView`};try{await this?.[t[e]]()}catch(e){l.Logger.error(e)}}async makeController(){let e=this.option(`api`)?`-resource`:``,t=this.argument(`name`),n=this.option(`force`),r=m.default.join(app_path(`Http/Controllers`),t+`.ts`),i=l.FileSystem.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,a=m.default.join(i,`dist/stubs/controller${e}.stub`);!n&&(0,p.existsSync)(r)&&l.Logger.error(`ERORR: ${t} controller already exists`);let o=await(0,u.readFile)(a,`utf-8`);o=o.replace(/{{ name }}/g,t),await(0,u.writeFile)(r,o),l.Logger.split(`INFO: Controller Created`,l.Logger.log(m.default.basename(r),`gray`,!1))}makeResource(){l.Logger.success(`Resource support is not yet available`)}async makeMigration(){let e=this.argument(`name`),t=(0,f.default)().format(`YYYY_MM_DD_HHmmss`),n=m.default.join(database_path(`migrations`),`${t}_${e}.ts`),r=l.FileSystem.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,i=this.option(`create`,!1),a=this.option(`table`);if(!a&&typeof i==`string`&&(a=i,i=!0),!a){let t=A.guess(e);a=t[0],i=!!t[1]}let o=m.default.join(r,this.getMigrationStubName(a,i)),s=await(0,u.readFile)(o,`utf-8`);a!==null&&(s=s.replace(/DummyTable|{{\s*table\s*}}/g,a)),l.Logger.info(`INFO: Creating Migration`),await this.kernel.ensureDirectoryExists(m.default.dirname(n)),await(0,u.writeFile)(n,s),l.Logger.split(`INFO: Migration Created`,l.Logger.log(m.default.basename(n),`gray`,!1))}makeFactory(){l.Logger.success(`Factory support is not yet available`)}makeSeeder(){l.Logger.success(`Seeder support is not yet available`)}async makeModel(){let e=this.option(`type`,`ts`),t=this.argument(`name`),n=this.argument(`force`),r=m.default.join(app_path(`Models`),t.toLowerCase(),`.`+e);!n&&(0,p.existsSync)(r)&&l.Logger.error(`ERORR: ${t} view already exists`);let i=l.FileSystem.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,a=m.default.join(i,`dist/stubs/model-${e}.stub`),o=await(0,u.readFile)(a,`utf-8`);o=o.replace(/{{ name }}/g,t),await(0,u.writeFile)(r,o),l.Logger.split(`INFO: Model Created`,l.Logger.log(m.default.basename(r),`gray`,!1))}async makeView(){let e=this.argument(`name`),t=this.option(`force`),n=m.default.join(base_path(`src/resources/views`),e+`.edge`);e.includes(`/`)&&await(0,u.mkdir)((0,d.beforeLast)(n,`/`),{recursive:!0}),!t&&(0,p.existsSync)(n)&&l.Logger.error(`ERORR: ${e} view already exists`),await(0,u.writeFile)(n,`{{-- src/resources/views/${e}.edge --}}`),l.Logger.split(`INFO: View Created`,l.Logger.log(`src/resources/views/${e}.edge`,`gray`,!1))}getMigrationStubName(e,t=!1,n=`ts`){let r;return r=e?t?`migration.create-${n}.stub`:`migration.update-${n}.stub`:`migration-${n}.stub`,`dist/stubs/`+r}},M=class extends E{signature=`postinstall`;description=`Default post installation command`;async handle(){this.createSqliteDB()}async createSqliteDB(){await l.FileSystem.fileExists(database_path())||await(0,u.mkdir)(database_path(),{recursive:!0}),await l.FileSystem.fileExists(database_path(`db.sqlite`))||await(0,u.writeFile)(database_path(`db.sqlite`),``)}},N=[h.HttpServiceProvider,x.ConfigServiceProvider,g.RouteServiceProvider,g.AssetsServiceProvider,_.DatabaseServiceProvider,v.CacheServiceProvider,y.QueueServiceProvider,b.MailServiceProvider],P=class e{static parseOptions(t){let n=[],r=/\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g,i;for(;(i=r.exec(t))!==null;){let t=i[1][0]===`^`||/:[#^]/.test(i[1]),r=([`#`,`^`].includes(i[1][0])||/:[#^]/.test(i[1]))&&!t,a=i[1].trim().replace(/[#^]/,``),o=a.indexOf(`:`);if(o===-1){n.push({name:a});continue}let s=a.substring(0,o).trim(),c=a.substring(o+1).trim(),l=c,u,d=c.indexOf(`|`);if(d!==-1){l=c.substring(0,d).trim();let t=c.substring(d+1).trim().replace(/^\{/,``).trim();u=e.parseOptions(`{`+t+`}`)}else l=l.trim();let f=s,p=/[^a-zA-Z0-9_|-]/.test(f),m=!1;f.endsWith(`?*`)?(p=!1,m=!0,f=f.slice(0,-2)):f.endsWith(`*`)?(m=!0,f=f.slice(0,-1)):f.endsWith(`?`)&&(p=!1,f=f.slice(0,-1));let h=f.startsWith(`--`),g,_;if(h){let e=f.split(`|`).map(e=>e.trim());g=[];for(let t of e){t.startsWith(`--`)&&t.slice(2).length===1?t=`-`+t.slice(2):t.startsWith(`-`)&&!t.startsWith(`--`)&&t.slice(1).length>1?t=`--`+t.slice(1):!t.startsWith(`-`)&&t.slice(1).length>1&&(t=`--`+t);let e=t.indexOf(`=`);if(e!==-1){g.push(t.substring(0,e));let n=t.substring(e+1);_=n===`*`?[]:n===`true`||n===`false`||!n&&!p?n===`true`:isNaN(Number(n))?n:Number(n)}else g.push(t)}}n.push({name:h?g[g.length-1]:f,required:p,multiple:m,description:l,flags:g,shared:t,isFlag:h,isHidden:r,defaultValue:_,nestedOptions:u})}return n}static parseSignature(t,n){let r=t.split(`
70
+ `).map(e=>e.trim()).filter(e=>e.length>0),i=[`#`,`^`].includes(r[0][0])||/:[#^]/.test(r[0]),a=r[0].replace(/[^\w=:-]/g,``),o=n.getDescription(),s=a.endsWith(`:`),c=r.slice(1).join(` `),l=e.parseOptions(c);return s?{baseCommand:a.slice(0,-1),isNamespaceCommand:s,subCommands:l.filter(e=>!e.flags&&!e.isHidden),description:o,commandClass:n,options:l.filter(e=>!!e.flags),isHidden:i}:{baseCommand:a,isNamespaceCommand:s,options:l,description:o,commandClass:n,isHidden:i}}};function F(e={}){let t,n,r=e.args||[],i=e.allowRestarts||!1,a=e.input,o=e.options||e;return delete o.args,delete o.allowRestarts,{name:`run`,buildStart(e){let n=a??e.input;if(typeof n==`string`&&(n=[n]),typeof n==`object`&&(n=Object.values(n)),n.length>1)throw Error("@rollup/plugin-run must have a single entry point; consider setting the `input` option");t=(0,C.resolve)(n[0])},generateBundle(e,t,n){n||this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`)},writeBundle(e,a){let s=(e,t)=>{n&&n.kill(),n=(0,w.fork)((0,C.join)(e,t),r,o)},c=e.dir||(0,C.dirname)(e.file),l=Object.keys(a).find(e=>{let n=a[e];return n.isEntry&&n.facadeModuleId===t});l?(s(c,l),i&&(process.stdin.resume(),process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{let t=e.toString().trim().toLowerCase();t===`rs`||t===`restart`||e.toString().charCodeAt(0)===11?s(c,l):(t===`cls`||t===`clear`||e.toString().charCodeAt(0)===12)&&console.clear()}))):this.error(`@rollup/plugin-run could not find output chunk`)}}}const I=process.env.NODE_ENV||`development`,L=I===`development`?`.h3ravel/serve`:`dist`,R={outDir:L,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:I===`development`,clean:!0,shims:!0,copy:[{from:`public`,to:L},`src/resources`,`src/database`],env:I===`development`?{NODE_ENV:I,SRC_PATH:L}:{},watch:I===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,plugins:I===`development`&&process.env.CLI_BUILD!==`true`?[F({env:Object.assign({},process.env,{NODE_ENV:I,SRC_PATH:L}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]};var z=R,B=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new j(this.app,this.kernel),new k(this.app,this.kernel),new M(this.app,this.kernel)].forEach(e=>this.addCommand(e))}async loadDiscoveredCommands(){let e=[...this.app.registeredCommands.map(e=>new e(this.app,this.kernel))],t=app_path(`Console/Commands/*.js`).replace(`/src/`,`/.h3ravel/serve/`);for await(let n of(0,u.glob)(t)){let t=m.default.basename(n).replace(`.js`,``);try{let r=(await import(n))[t];e.push(new r(this.app,this.kernel))}catch{}}e.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(P.parseSignature(e.getSignature(),e))}initialize(){let e=l.Logger.parse([[`Musket CLI:`,`white`],[this.kernel.consolePackage.version,`green`]],` `,!1),t=l.Logger.parse([[`H3ravel Framework:`,`white`],[this.kernel.modulePackage.version,`green`]],` `,!1),n={quiet:[`-q, --quiet`,`Do not output any message`],silent:[`--silent`,`Do not output any message`],verbose:[`-v, --verbose <number>`,`Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug`],lock:[`--lock`,`Locked and loaded, do not ask any interactive question`]};S.program.name(`musket`).version(`${e}\n${t}`).description(O).addOption(new S.Option(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S.Option(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S.Option(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S.Option(n.lock[0],n.lock[1])).action(async()=>{let e=new k(this.app,this.kernel);e.setInput(S.program.opts(),S.program.args,S.program.registeredArguments,{},S.program),e.handle()}),S.program.command(`init`).description(`Initialize H3ravel.`).action(async()=>{l.Logger.success(`Initialized: H3ravel has been initialized!`)});for(let e=0;e<this.commands.length;e++){let t=this.commands[e],r=t.commandClass;if(t.isNamespaceCommand&&t.subCommands){let e=t.isHidden?S.program:S.program.command(t.baseCommand).description(t.description??``).addOption(new S.Option(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S.Option(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S.Option(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S.Option(n.lock[0],n.lock[1])).action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,S.program),await r.handle()});(t.options?.length??0)>0&&t.options?.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(t=>{this.makeOption(t,e)}),t.subCommands.filter((e,t,n)=>!e.shared&&n.findIndex(t=>t.name===e.name)===t).forEach(e=>{let i=S.program.command(`${t.baseCommand}:${e.name}`).description(e.description||``).addOption(new S.Option(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S.Option(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S.Option(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S.Option(n.lock[0],n.lock[1])).action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,e,S.program),await r.handle()});t.subCommands?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,i,!1,e)}),t.options?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,i,!1,e)}),e.nestedOptions&&e.nestedOptions.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(e=>{this.makeOption(e,i)})})}else{let e=S.program.command(t.baseCommand).description(t.description??``);t?.options?.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(t=>{this.makeOption(t,e,!0)}),e.action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,S.program),await r.handle()})}}return S.program.hook(`preAction`,async(e,t)=>{t.name()!==`fire`&&await(0,T.build)({...z,watch:!1,plugins:[]})}),S.program}makeOption(e,t,n,r){let i=e.description?.replace(/\[(\w+)\]/g,(e,t)=>r?.[t]??`[${t}]`)??``,a=e.name.replaceAll(`-`,``);if(e.isFlag)if(n){let n=e.flags?.map(e=>e.length===1?`-${e}`:`--${e}`).join(`, `).replaceAll(`----`,`--`).replaceAll(`---`,`-`);t.option(n||``,i,String(e.defaultValue)||void 0)}else t.option(e.flags?.join(`, `)+(e.required?` <${a}>`:``),i,e.defaultValue);else t.argument(e.required?`<${e.name}>`:`[${e.name}]`,i,e.defaultValue)}static async parse(t){return(await new e(t.app,t).build()).parseAsync()}},V=class e extends c.ConsoleKernel{constructor(e){super(e),this.app=e}static init(t){let n=new e(t);Promise.all([n.loadRequirements()]).then(([e])=>e.run())}async run(){await B.parse(this),process.exit(0)}async loadRequirements(){this.cwd=m.default.join(process.cwd(),this.basePath),this.modulePath=l.FileSystem.findModulePkg(`@h3ravel/core`,this.cwd)??``,this.consolePath=l.FileSystem.findModulePkg(`@h3ravel/console`,this.cwd)??``;try{this.modulePackage=await import(m.default.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(m.default.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},H=class extends c.ServiceProvider{static priority=992;static console=!0;register(){}boot(){V.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}},U=class{async fire(){let e=new c.Application(process.cwd()),t=app_path(`Providers/*.js`).replace(`/src/`,`/.h3ravel/serve/`);for await(let e of(0,u.glob)(t)){let t=m.default.basename(e).replace(`.js`,``);try{N.push((await import(e))[t])}catch{}}N.push(H),e.registerProviders(N),await e.registerConfiguredProviders(),await e.boot()}};new U().fire();
package/bin/fire.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import"tsx/esm";import{Application as e,ConsoleCommand as t,ConsoleKernel as n,ServiceProvider as r}from"@h3ravel/core";import{Logger as i}from"@h3ravel/shared";import{access as a}from"fs/promises";import o,{dirname as s,join as c,resolve as l}from"path";import{readdirSync as u,statSync as d}from"fs";import{glob as f,mkdir as p,readFile as m,writeFile as h}from"node:fs/promises";import{beforeLast as g}from"@h3ravel/support";import _ from"dayjs";import{existsSync as v}from"node:fs";import y from"node:path";import{HttpServiceProvider as b}from"@h3ravel/http";import{AssetsServiceProvider as x,RouteServiceProvider as S}from"@h3ravel/router";import{DatabaseServiceProvider as C}from"@h3ravel/database";import{CacheServiceProvider as w}from"@h3ravel/cache";import{QueueServiceProvider as T}from"@h3ravel/queue";import{MailServiceProvider as E}from"@h3ravel/mail";import{ConfigServiceProvider as D}from"@h3ravel/config";import{Option as O,program as k}from"commander";import{fork as A}from"child_process";import{build as j}from"tsdown";var M=class extends t{};String.raw`
2
+ import"tsx/esm";import{Application as e,ConsoleCommand as t,ConsoleKernel as n,ServiceProvider as r}from"@h3ravel/core";import{FileSystem as i,Logger as a}from"@h3ravel/shared";import{glob as o,mkdir as s,readFile as c,writeFile as l}from"node:fs/promises";import{beforeLast as u}from"@h3ravel/support";import d from"dayjs";import{existsSync as f}from"node:fs";import p from"node:path";import{HttpServiceProvider as m}from"@h3ravel/http";import{AssetsServiceProvider as h,RouteServiceProvider as g}from"@h3ravel/router";import{DatabaseServiceProvider as _}from"@h3ravel/database";import{CacheServiceProvider as v}from"@h3ravel/cache";import{QueueServiceProvider as y}from"@h3ravel/queue";import{MailServiceProvider as b}from"@h3ravel/mail";import{ConfigServiceProvider as x}from"@h3ravel/config";import{Option as S,program as C}from"commander";import{dirname as w,join as T,resolve as E}from"path";import{fork as D}from"child_process";import{build as O}from"tsdown";var k=class extends t{};String.raw`
3
3
  111
4
4
  111111111
5
5
  1111111111 111111
@@ -21,19 +21,19 @@ import"tsx/esm";import{Application as e,ConsoleCommand as t,ConsoleKernel as n,S
21
21
  111111 111 111111
22
22
  111111111
23
23
  110
24
- `;const N=String.raw`
24
+ `;const A=String.raw`
25
25
  _ _ _____ _
26
26
  | | | |___ / _ __ __ ___ _____| |
27
27
  | |_| | |_ \| '__/ _ \ \ / / _ \ |
28
28
  | _ |___) | | | (_| |\ V / __/ |
29
29
  |_| |_|____/|_| \__,_| \_/ \___|_|
30
30
 
31
- `;var P=class extends M{signature=`list`;description=`List all available commands`;async handle(){let e=[{short:`-h`,long:`--help`,description:`Display help for the given command. When no command is given display help for the list command`}].concat(this.program.options).map(e=>i.describe(i.log(` `+[e.short,e.long].filter(e=>!!e).join(`, `),`green`,!1),e.description,25,!1).join(``)),t=this.program.commands.map(e=>i.describe(i.log(` `+e.name(),`green`,!1),e.description(),25,!1).join(``)).reduce((e,t)=>{let n=t.replace(/\x1b\[\d+m/g,``),r=n.includes(`:`)?n.split(`:`)[0].trim():`__root__`;return e[r]??=[],e[r].push(t),e},{}),n=Object.entries(t).map(([e,t])=>{let n=e===`__root__`?``:e;return[i.log(n,`yellow`,!1),t.join(`
31
+ `;var j=class extends k{signature=`list`;description=`List all available commands`;async handle(){let e=[{short:`-h`,long:`--help`,description:`Display help for the given command. When no command is given display help for the list command`}].concat(this.program.options).map(e=>a.describe(a.log(` `+[e.short,e.long].filter(e=>!!e).join(`, `),`green`,!1),e.description,25,!1).join(``)),t=this.program.commands.map(e=>a.describe(a.log(` `+e.name(),`green`,!1),e.description(),25,!1).join(``)).reduce((e,t)=>{let n=t.replace(/\x1b\[\d+m/g,``),r=n.includes(`:`)?n.split(`:`)[0].trim():`__root__`;return e[r]??=[],e[r].push(t),e},{}),n=Object.entries(t).map(([e,t])=>{let n=e===`__root__`?``:e;return[a.log(n,`yellow`,!1),t.join(`
32
32
  `)].join(`
33
- `)});i.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(N),console.log(``),i.log(`Usage:`,`yellow`),i.log(` command [options] [arguments]`,`white`),console.log(``),i.log(`Options:`,`yellow`),console.log(e.join(`
34
- `).trim()),console.log(``),i.log(`Available Commands:`,`yellow`),console.log(n.join(`
33
+ `)});a.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(A),console.log(``),a.log(`Usage:`,`yellow`),a.log(` command [options] [arguments]`,`white`),console.log(``),a.log(`Options:`,`yellow`),console.log(e.join(`
34
+ `).trim()),console.log(``),a.log(`Available Commands:`,`yellow`),console.log(n.join(`
35
35
 
36
- `).trim())}};function F(e,t){let n=l(`.`,e),r;for(d(n).isDirectory()||(n=s(n));;){if(r=t(n,u(n)),r)return l(n,r);if(n=s(r=n),r===n)break}}var I=class{static findModulePkg(e,t){let n=e.replace(/\\/g,`/`).split(`/`),r=``;n.length>0&&n[0][0]===`@`&&(r+=n.shift()+`/`),r+=n.shift();let i=o.join(t??process.cwd(),`node_modules`,r),a=this.findUpConfig(i,`package`,[`json`]);if(a)return o.join(o.dirname(a),n.join(`/`))}static async fileExists(e){try{return await a(e),!0}catch{return!1}}static findUpConfig(e,t,n){return F(e,(e,r)=>{for(let e of n){let n=`${t}.${e}`;if(r.includes(n))return n}return!1})}},L=class e{static CREATE_PATTERNS=[/^create_(\w+)_table$/,/^create_(\w+)$/];static CHANGE_PATTERNS=[/.+_(to|from|in)_(\w+)_table$/,/.+_(to|from|in)_(\w+)$/];static guess(t){for(let n of e.CREATE_PATTERNS){let e=t.match(n);if(e)return[e[1],!0]}for(let n of e.CHANGE_PATTERNS){let e=t.match(n);if(e)return[e[2],!1]}return[]}},R=class{static findModulePkg(e,t){let n=e.replace(/\\/g,`/`).split(`/`),r=``;n.length>0&&n[0][0]===`@`&&(r+=n.shift()+`/`),r+=n.shift();let i=o.join(t??process.cwd(),`node_modules`,r),a=this.findUpConfig(i,`package`,[`json`]);if(a)return o.join(o.dirname(a),n.join(`/`))}static async fileExists(e){try{return await a(e),!0}catch{return!1}}static findUpConfig(e,t,n){return F(e,(e,r)=>{for(let e of n){let n=`${t}.${e}`;if(r.includes(n))return n}return!1})}},z=class extends M{signature=`#make:
36
+ `).trim())}},M=class e{static CREATE_PATTERNS=[/^create_(\w+)_table$/,/^create_(\w+)$/];static CHANGE_PATTERNS=[/.+_(to|from|in)_(\w+)_table$/,/.+_(to|from|in)_(\w+)$/];static guess(t){for(let n of e.CREATE_PATTERNS){let e=t.match(n);if(e)return[e[1],!0]}for(let n of e.CHANGE_PATTERNS){let e=t.match(n);if(e)return[e[2],!1]}return[]}},N=class extends k{signature=`#make:
37
37
  {controller : Create a new controller class.
38
38
  | {--a|api : Exclude the create and edit methods from the controller}
39
39
  | {--m|model= : Generate a resource controller for the given model}
@@ -66,5 +66,5 @@ import"tsx/esm";import{Application as e,ConsoleCommand as t,ConsoleKernel as n,S
66
66
  | {--force : Create the model even if it already exists}
67
67
  }
68
68
  {^name : The name of the [name] to generate}
69
- `;description=`Generate component classes`;async handle(){let e=this.dictionary.baseCommand??this.dictionary.name,t={controller:`makeController`,resource:`makeResource`,migration:`makeMigration`,factory:`makeFactory`,seeder:`makeSeeder`,model:`makeModel`,view:`makeView`};try{await this?.[t[e]]()}catch(e){i.error(e)}}async makeController(){let e=this.option(`api`)?`-resource`:``,t=this.argument(`name`),n=this.option(`force`),r=y.join(app_path(`Http/Controllers`),t+`.ts`),a=R.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,o=y.join(a,`dist/stubs/controller${e}.stub`);!n&&v(r)&&i.error(`ERORR: ${t} controller already exists`);let s=await m(o,`utf-8`);s=s.replace(/{{ name }}/g,t),await h(r,s),i.split(`INFO: Controller Created`,i.log(y.basename(r),`gray`,!1))}makeResource(){i.success(`Resource support is not yet available`)}async makeMigration(){let e=this.argument(`name`),t=_().format(`YYYY_MM_DD_HHmmss`),n=y.join(database_path(`migrations`),`${t}_${e}.ts`),r=I.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,a=this.option(`create`,!1),o=this.option(`table`);if(!o&&typeof a==`string`&&(o=a,a=!0),!o){let t=L.guess(e);o=t[0],a=!!t[1]}let s=y.join(r,this.getMigrationStubName(o,a)),c=await m(s,`utf-8`);o!==null&&(c=c.replace(/DummyTable|{{\s*table\s*}}/g,o)),i.info(`INFO: Creating Migration`),await this.kernel.ensureDirectoryExists(y.dirname(n)),await h(n,c),i.split(`INFO: Migration Created`,i.log(y.basename(n),`gray`,!1))}makeFactory(){i.success(`Factory support is not yet available`)}makeSeeder(){i.success(`Seeder support is not yet available`)}async makeModel(){let e=this.option(`type`,`ts`),t=this.argument(`name`),n=this.argument(`force`),r=y.join(app_path(`Models`),t.toLowerCase(),`.`+e);!n&&v(r)&&i.error(`ERORR: ${t} view already exists`);let a=I.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,o=y.join(a,`dist/stubs/model-${e}.stub`),s=await m(o,`utf-8`);s=s.replace(/{{ name }}/g,t),await h(r,s),i.split(`INFO: Model Created`,i.log(y.basename(r),`gray`,!1))}async makeView(){let e=this.argument(`name`),t=this.option(`force`),n=y.join(base_path(`src/resources/views`),e+`.edge`);e.includes(`/`)&&await p(g(n,`/`),{recursive:!0}),!t&&v(n)&&i.error(`ERORR: ${e} view already exists`),await h(n,`{{-- src/resources/views/${e}.edge --}}`),i.split(`INFO: View Created`,i.log(`src/resources/views/${e}.edge`,`gray`,!1))}getMigrationStubName(e,t=!1,n=`ts`){let r;return r=e?t?`migration.create-${n}.stub`:`migration.update-${n}.stub`:`migration-${n}.stub`,`dist/stubs/`+r}},B=[b,D,S,x,C,w,T,E],V=class e{static parseOptions(t){let n=[],r=/\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g,i;for(;(i=r.exec(t))!==null;){let t=i[1][0]===`^`||/:[#^]/.test(i[1]),r=([`#`,`^`].includes(i[1][0])||/:[#^]/.test(i[1]))&&!t,a=i[1].trim().replace(/[#^]/,``),o=a.indexOf(`:`);if(o===-1){n.push({name:a});continue}let s=a.substring(0,o).trim(),c=a.substring(o+1).trim(),l=c,u,d=c.indexOf(`|`);if(d!==-1){l=c.substring(0,d).trim();let t=c.substring(d+1).trim().replace(/^\{/,``).trim();u=e.parseOptions(`{`+t+`}`)}else l=l.trim();let f=s,p=/[^a-zA-Z0-9_|-]/.test(f),m=!1;f.endsWith(`?*`)?(p=!1,m=!0,f=f.slice(0,-2)):f.endsWith(`*`)?(m=!0,f=f.slice(0,-1)):f.endsWith(`?`)&&(p=!1,f=f.slice(0,-1));let h=f.startsWith(`--`),g,_;if(h){let e=f.split(`|`).map(e=>e.trim());g=[];for(let t of e){t.startsWith(`--`)&&t.slice(2).length===1?t=`-`+t.slice(2):t.startsWith(`-`)&&!t.startsWith(`--`)&&t.slice(1).length>1?t=`--`+t.slice(1):!t.startsWith(`-`)&&t.slice(1).length>1&&(t=`--`+t);let e=t.indexOf(`=`);if(e!==-1){g.push(t.substring(0,e));let n=t.substring(e+1);_=n===`*`?[]:n===`true`||n===`false`||!n&&!p?n===`true`:isNaN(Number(n))?n:Number(n)}else g.push(t)}}n.push({name:h?g[g.length-1]:f,required:p,multiple:m,description:l,flags:g,shared:t,isFlag:h,isHidden:r,defaultValue:_,nestedOptions:u})}return n}static parseSignature(t,n){let r=t.split(`
70
- `).map(e=>e.trim()).filter(e=>e.length>0),i=[`#`,`^`].includes(r[0][0])||/:[#^]/.test(r[0]),a=r[0].replace(/[^\w=:-]/g,``),o=n.getDescription(),s=a.endsWith(`:`),c=r.slice(1).join(` `),l=e.parseOptions(c);return s?{baseCommand:a.slice(0,-1),isNamespaceCommand:s,subCommands:l.filter(e=>!e.flags&&!e.isHidden),description:o,commandClass:n,options:l.filter(e=>!!e.flags),isHidden:i}:{baseCommand:a,isNamespaceCommand:s,options:l,description:o,commandClass:n,isHidden:i}}};function H(e={}){let t,n,r=e.args||[],i=e.allowRestarts||!1,a=e.input,o=e.options||e;return delete o.args,delete o.allowRestarts,{name:`run`,buildStart(e){let n=a??e.input;if(typeof n==`string`&&(n=[n]),typeof n==`object`&&(n=Object.values(n)),n.length>1)throw Error("@rollup/plugin-run must have a single entry point; consider setting the `input` option");t=l(n[0])},generateBundle(e,t,n){n||this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`)},writeBundle(e,a){let l=(e,t)=>{n&&n.kill(),n=A(c(e,t),r,o)},u=e.dir||s(e.file),d=Object.keys(a).find(e=>{let n=a[e];return n.isEntry&&n.facadeModuleId===t});d?(l(u,d),i&&(process.stdin.resume(),process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{let t=e.toString().trim().toLowerCase();t===`rs`||t===`restart`||e.toString().charCodeAt(0)===11?l(u,d):(t===`cls`||t===`clear`||e.toString().charCodeAt(0)===12)&&console.clear()}))):this.error(`@rollup/plugin-run could not find output chunk`)}}}const U=process.env.NODE_ENV||`development`,W=U===`development`?`.h3ravel/serve`:`dist`;var G={outDir:W,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:U===`development`,clean:!0,shims:!0,copy:[{from:`public`,to:W},`src/resources`,`src/database`],env:U===`development`?{NODE_ENV:U,SRC_PATH:W}:{},watch:U===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,plugins:U===`development`&&process.env.CLI_BUILD!==`true`?[H({env:Object.assign({},process.env,{NODE_ENV:U,SRC_PATH:W}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]},K=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new z(this.app,this.kernel),new P(this.app,this.kernel)].forEach(e=>this.addCommand(e))}async loadDiscoveredCommands(){let e=[...this.app.registeredCommands.map(e=>new e(this.app,this.kernel))],t=app_path(`Console/Commands/*.js`).replace(`/src/`,`/.h3ravel/serve/`);for await(let n of f(t)){let t=y.basename(n).replace(`.js`,``);try{let r=(await import(n))[t];e.push(new r(this.app,this.kernel))}catch{}}e.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(V.parseSignature(e.getSignature(),e))}initialize(){let e=i.parse([[`Musket CLI:`,`white`],[this.kernel.consolePackage.version,`green`]],` `,!1),t=i.parse([[`H3ravel Framework:`,`white`],[this.kernel.modulePackage.version,`green`]],` `,!1),n={quiet:[`-q, --quiet`,`Do not output any message`],silent:[`--silent`,`Do not output any message`],verbose:[`-v, --verbose <number>`,`Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug`],lock:[`--lock`,`Locked and loaded, do not ask any interactive question`]};k.name(`musket`).version(`${e}\n${t}`).description(N).addOption(new O(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new O(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new O(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new O(n.lock[0],n.lock[1])).action(async()=>{let e=new P(this.app,this.kernel);e.setInput(k.opts(),k.args,k.registeredArguments,{},k),e.handle()}),k.command(`init`).description(`Initialize H3ravel.`).action(async()=>{i.success(`Initialized: H3ravel has been initialized!`)});for(let e=0;e<this.commands.length;e++){let t=this.commands[e],r=t.commandClass;if(t.isNamespaceCommand&&t.subCommands){let e=t.isHidden?k:k.command(t.baseCommand).description(t.description??``).addOption(new O(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new O(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new O(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new O(n.lock[0],n.lock[1])).action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,k),await r.handle()});(t.options?.length??0)>0&&t.options?.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(t=>{this.makeOption(t,e)}),t.subCommands.filter((e,t,n)=>!e.shared&&n.findIndex(t=>t.name===e.name)===t).forEach(e=>{let i=k.command(`${t.baseCommand}:${e.name}`).description(e.description||``).addOption(new O(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new O(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new O(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new O(n.lock[0],n.lock[1])).action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,e,k),await r.handle()});t.subCommands?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,i,!1,e)}),t.options?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,i,!1,e)}),e.nestedOptions&&e.nestedOptions.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(e=>{this.makeOption(e,i)})})}else{let e=k.command(t.baseCommand).description(t.description??``);t?.options?.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(t=>{this.makeOption(t,e,!0)}),e.action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,k),await r.handle()})}}return k.hook(`preAction`,async(e,t)=>{t.name()!==`fire`&&await j({...G,watch:!1,plugins:[]})}),k}makeOption(e,t,n,r){let i=e.description?.replace(/\[(\w+)\]/g,(e,t)=>r?.[t]??`[${t}]`)??``,a=e.name.replaceAll(`-`,``);if(e.isFlag)if(n){let n=e.flags?.map(e=>e.length===1?`-${e}`:`--${e}`).join(`, `).replaceAll(`----`,`--`).replaceAll(`---`,`-`);t.option(n||``,i,String(e.defaultValue)||void 0)}else t.option(e.flags?.join(`, `)+(e.required?` <${a}>`:``),i,e.defaultValue);else t.argument(e.required?`<${e.name}>`:`[${e.name}]`,i,e.defaultValue)}static async parse(t){return(await new e(t.app,t).build()).parseAsync()}},q=class e extends n{constructor(e){super(e),this.app=e}static init(t){let n=new e(t);Promise.all([n.loadRequirements()]).then(([e])=>e.run())}async run(){await K.parse(this),process.exit(0)}async loadRequirements(){this.cwd=y.join(process.cwd(),this.basePath),this.modulePath=R.findModulePkg(`@h3ravel/core`,this.cwd)??``,this.consolePath=R.findModulePkg(`@h3ravel/console`,this.cwd)??``;try{this.modulePackage=await import(y.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(y.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},J=class extends r{static priority=992;static console=!0;register(){}boot(){q.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}};new class{async fire(){let t=new e(process.cwd()),n=(app_path(`Providers/*.js`).replace(`/src/`,`/.h3ravel/serve/`));for await(let e of f(n)){let t=(y.basename(e).replace(`.js`,``));try{B.push((await import(e))[t])}catch{}}B.push(J),t.registerProviders(B),await t.registerConfiguredProviders(),await t.boot()}}().fire();export{};
69
+ `;description=`Generate component classes`;async handle(){let e=this.dictionary.baseCommand??this.dictionary.name,t={controller:`makeController`,resource:`makeResource`,migration:`makeMigration`,factory:`makeFactory`,seeder:`makeSeeder`,model:`makeModel`,view:`makeView`};try{await this?.[t[e]]()}catch(e){a.error(e)}}async makeController(){let e=this.option(`api`)?`-resource`:``,t=this.argument(`name`),n=this.option(`force`),r=p.join(app_path(`Http/Controllers`),t+`.ts`),o=i.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,s=p.join(o,`dist/stubs/controller${e}.stub`);!n&&f(r)&&a.error(`ERORR: ${t} controller already exists`);let u=await c(s,`utf-8`);u=u.replace(/{{ name }}/g,t),await l(r,u),a.split(`INFO: Controller Created`,a.log(p.basename(r),`gray`,!1))}makeResource(){a.success(`Resource support is not yet available`)}async makeMigration(){let e=this.argument(`name`),t=d().format(`YYYY_MM_DD_HHmmss`),n=p.join(database_path(`migrations`),`${t}_${e}.ts`),r=i.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,o=this.option(`create`,!1),s=this.option(`table`);if(!s&&typeof o==`string`&&(s=o,o=!0),!s){let t=M.guess(e);s=t[0],o=!!t[1]}let u=p.join(r,this.getMigrationStubName(s,o)),f=await c(u,`utf-8`);s!==null&&(f=f.replace(/DummyTable|{{\s*table\s*}}/g,s)),a.info(`INFO: Creating Migration`),await this.kernel.ensureDirectoryExists(p.dirname(n)),await l(n,f),a.split(`INFO: Migration Created`,a.log(p.basename(n),`gray`,!1))}makeFactory(){a.success(`Factory support is not yet available`)}makeSeeder(){a.success(`Seeder support is not yet available`)}async makeModel(){let e=this.option(`type`,`ts`),t=this.argument(`name`),n=this.argument(`force`),r=p.join(app_path(`Models`),t.toLowerCase(),`.`+e);!n&&f(r)&&a.error(`ERORR: ${t} view already exists`);let o=i.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,s=p.join(o,`dist/stubs/model-${e}.stub`),u=await c(s,`utf-8`);u=u.replace(/{{ name }}/g,t),await l(r,u),a.split(`INFO: Model Created`,a.log(p.basename(r),`gray`,!1))}async makeView(){let e=this.argument(`name`),t=this.option(`force`),n=p.join(base_path(`src/resources/views`),e+`.edge`);e.includes(`/`)&&await s(u(n,`/`),{recursive:!0}),!t&&f(n)&&a.error(`ERORR: ${e} view already exists`),await l(n,`{{-- src/resources/views/${e}.edge --}}`),a.split(`INFO: View Created`,a.log(`src/resources/views/${e}.edge`,`gray`,!1))}getMigrationStubName(e,t=!1,n=`ts`){let r;return r=e?t?`migration.create-${n}.stub`:`migration.update-${n}.stub`:`migration-${n}.stub`,`dist/stubs/`+r}},P=class extends k{signature=`postinstall`;description=`Default post installation command`;async handle(){this.createSqliteDB()}async createSqliteDB(){await i.fileExists(database_path())||await s(database_path(),{recursive:!0}),await i.fileExists(database_path(`db.sqlite`))||await l(database_path(`db.sqlite`),``)}},F=[m,x,g,h,_,v,y,b],I=class e{static parseOptions(t){let n=[],r=/\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g,i;for(;(i=r.exec(t))!==null;){let t=i[1][0]===`^`||/:[#^]/.test(i[1]),r=([`#`,`^`].includes(i[1][0])||/:[#^]/.test(i[1]))&&!t,a=i[1].trim().replace(/[#^]/,``),o=a.indexOf(`:`);if(o===-1){n.push({name:a});continue}let s=a.substring(0,o).trim(),c=a.substring(o+1).trim(),l=c,u,d=c.indexOf(`|`);if(d!==-1){l=c.substring(0,d).trim();let t=c.substring(d+1).trim().replace(/^\{/,``).trim();u=e.parseOptions(`{`+t+`}`)}else l=l.trim();let f=s,p=/[^a-zA-Z0-9_|-]/.test(f),m=!1;f.endsWith(`?*`)?(p=!1,m=!0,f=f.slice(0,-2)):f.endsWith(`*`)?(m=!0,f=f.slice(0,-1)):f.endsWith(`?`)&&(p=!1,f=f.slice(0,-1));let h=f.startsWith(`--`),g,_;if(h){let e=f.split(`|`).map(e=>e.trim());g=[];for(let t of e){t.startsWith(`--`)&&t.slice(2).length===1?t=`-`+t.slice(2):t.startsWith(`-`)&&!t.startsWith(`--`)&&t.slice(1).length>1?t=`--`+t.slice(1):!t.startsWith(`-`)&&t.slice(1).length>1&&(t=`--`+t);let e=t.indexOf(`=`);if(e!==-1){g.push(t.substring(0,e));let n=t.substring(e+1);_=n===`*`?[]:n===`true`||n===`false`||!n&&!p?n===`true`:isNaN(Number(n))?n:Number(n)}else g.push(t)}}n.push({name:h?g[g.length-1]:f,required:p,multiple:m,description:l,flags:g,shared:t,isFlag:h,isHidden:r,defaultValue:_,nestedOptions:u})}return n}static parseSignature(t,n){let r=t.split(`
70
+ `).map(e=>e.trim()).filter(e=>e.length>0),i=[`#`,`^`].includes(r[0][0])||/:[#^]/.test(r[0]),a=r[0].replace(/[^\w=:-]/g,``),o=n.getDescription(),s=a.endsWith(`:`),c=r.slice(1).join(` `),l=e.parseOptions(c);return s?{baseCommand:a.slice(0,-1),isNamespaceCommand:s,subCommands:l.filter(e=>!e.flags&&!e.isHidden),description:o,commandClass:n,options:l.filter(e=>!!e.flags),isHidden:i}:{baseCommand:a,isNamespaceCommand:s,options:l,description:o,commandClass:n,isHidden:i}}};function L(e={}){let t,n,r=e.args||[],i=e.allowRestarts||!1,a=e.input,o=e.options||e;return delete o.args,delete o.allowRestarts,{name:`run`,buildStart(e){let n=a??e.input;if(typeof n==`string`&&(n=[n]),typeof n==`object`&&(n=Object.values(n)),n.length>1)throw Error("@rollup/plugin-run must have a single entry point; consider setting the `input` option");t=E(n[0])},generateBundle(e,t,n){n||this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`)},writeBundle(e,a){let s=(e,t)=>{n&&n.kill(),n=D(T(e,t),r,o)},c=e.dir||w(e.file),l=Object.keys(a).find(e=>{let n=a[e];return n.isEntry&&n.facadeModuleId===t});l?(s(c,l),i&&(process.stdin.resume(),process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{let t=e.toString().trim().toLowerCase();t===`rs`||t===`restart`||e.toString().charCodeAt(0)===11?s(c,l):(t===`cls`||t===`clear`||e.toString().charCodeAt(0)===12)&&console.clear()}))):this.error(`@rollup/plugin-run could not find output chunk`)}}}const R=process.env.NODE_ENV||`development`,z=R===`development`?`.h3ravel/serve`:`dist`;var B={outDir:z,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:R===`development`,clean:!0,shims:!0,copy:[{from:`public`,to:z},`src/resources`,`src/database`],env:R===`development`?{NODE_ENV:R,SRC_PATH:z}:{},watch:R===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,plugins:R===`development`&&process.env.CLI_BUILD!==`true`?[L({env:Object.assign({},process.env,{NODE_ENV:R,SRC_PATH:z}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]},V=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new N(this.app,this.kernel),new j(this.app,this.kernel),new P(this.app,this.kernel)].forEach(e=>this.addCommand(e))}async loadDiscoveredCommands(){let e=[...this.app.registeredCommands.map(e=>new e(this.app,this.kernel))],t=app_path(`Console/Commands/*.js`).replace(`/src/`,`/.h3ravel/serve/`);for await(let n of o(t)){let t=p.basename(n).replace(`.js`,``);try{let r=(await import(n))[t];e.push(new r(this.app,this.kernel))}catch{}}e.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(I.parseSignature(e.getSignature(),e))}initialize(){let e=a.parse([[`Musket CLI:`,`white`],[this.kernel.consolePackage.version,`green`]],` `,!1),t=a.parse([[`H3ravel Framework:`,`white`],[this.kernel.modulePackage.version,`green`]],` `,!1),n={quiet:[`-q, --quiet`,`Do not output any message`],silent:[`--silent`,`Do not output any message`],verbose:[`-v, --verbose <number>`,`Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug`],lock:[`--lock`,`Locked and loaded, do not ask any interactive question`]};C.name(`musket`).version(`${e}\n${t}`).description(A).addOption(new S(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S(n.lock[0],n.lock[1])).action(async()=>{let e=new j(this.app,this.kernel);e.setInput(C.opts(),C.args,C.registeredArguments,{},C),e.handle()}),C.command(`init`).description(`Initialize H3ravel.`).action(async()=>{a.success(`Initialized: H3ravel has been initialized!`)});for(let e=0;e<this.commands.length;e++){let t=this.commands[e],r=t.commandClass;if(t.isNamespaceCommand&&t.subCommands){let e=t.isHidden?C:C.command(t.baseCommand).description(t.description??``).addOption(new S(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S(n.lock[0],n.lock[1])).action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,C),await r.handle()});(t.options?.length??0)>0&&t.options?.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(t=>{this.makeOption(t,e)}),t.subCommands.filter((e,t,n)=>!e.shared&&n.findIndex(t=>t.name===e.name)===t).forEach(e=>{let i=C.command(`${t.baseCommand}:${e.name}`).description(e.description||``).addOption(new S(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S(n.lock[0],n.lock[1])).action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,e,C),await r.handle()});t.subCommands?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,i,!1,e)}),t.options?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,i,!1,e)}),e.nestedOptions&&e.nestedOptions.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(e=>{this.makeOption(e,i)})})}else{let e=C.command(t.baseCommand).description(t.description??``);t?.options?.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(t=>{this.makeOption(t,e,!0)}),e.action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,C),await r.handle()})}}return C.hook(`preAction`,async(e,t)=>{t.name()!==`fire`&&await O({...B,watch:!1,plugins:[]})}),C}makeOption(e,t,n,r){let i=e.description?.replace(/\[(\w+)\]/g,(e,t)=>r?.[t]??`[${t}]`)??``,a=e.name.replaceAll(`-`,``);if(e.isFlag)if(n){let n=e.flags?.map(e=>e.length===1?`-${e}`:`--${e}`).join(`, `).replaceAll(`----`,`--`).replaceAll(`---`,`-`);t.option(n||``,i,String(e.defaultValue)||void 0)}else t.option(e.flags?.join(`, `)+(e.required?` <${a}>`:``),i,e.defaultValue);else t.argument(e.required?`<${e.name}>`:`[${e.name}]`,i,e.defaultValue)}static async parse(t){return(await new e(t.app,t).build()).parseAsync()}},H=class e extends n{constructor(e){super(e),this.app=e}static init(t){let n=new e(t);Promise.all([n.loadRequirements()]).then(([e])=>e.run())}async run(){await V.parse(this),process.exit(0)}async loadRequirements(){this.cwd=p.join(process.cwd(),this.basePath),this.modulePath=i.findModulePkg(`@h3ravel/core`,this.cwd)??``,this.consolePath=i.findModulePkg(`@h3ravel/console`,this.cwd)??``;try{this.modulePackage=await import(p.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(p.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},U=class extends r{static priority=992;static console=!0;register(){}boot(){H.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}};new class{async fire(){let t=new e(process.cwd()),n=(app_path(`Providers/*.js`).replace(`/src/`,`/.h3ravel/serve/`));for await(let e of o(n)){let t=(p.basename(e).replace(`.js`,``));try{F.push((await import(e))[t])}catch{}}F.push(U),t.registerProviders(F),await t.registerConfiguredProviders(),await t.boot()}}().fire();export{};
@@ -0,0 +1,10 @@
1
+ //#region src/Utils.d.ts
2
+ declare class Utils {}
3
+ declare class TableGuesser {
4
+ static CREATE_PATTERNS: RegExp[];
5
+ static CHANGE_PATTERNS: RegExp[];
6
+ static guess(migration: string): (string | boolean)[];
7
+ }
8
+ //#endregion
9
+ export { TableGuesser, Utils };
10
+ //# sourceMappingURL=Utils-CbqNJtIj.d.ts.map
@@ -0,0 +1,10 @@
1
+ //#region src/Utils.d.ts
2
+ declare class Utils {}
3
+ declare class TableGuesser {
4
+ static CREATE_PATTERNS: RegExp[];
5
+ static CHANGE_PATTERNS: RegExp[];
6
+ static guess(migration: string): (string | boolean)[];
7
+ }
8
+ //#endregion
9
+ export { TableGuesser, Utils };
10
+ //# sourceMappingURL=Utils-CxAcuqeI.d.cts.map
@@ -0,0 +1,33 @@
1
+
2
+ //#region src/Utils.ts
3
+ var Utils = class {};
4
+ var TableGuesser = class TableGuesser {
5
+ static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
6
+ static CHANGE_PATTERNS = [/.+_(to|from|in)_(\w+)_table$/, /.+_(to|from|in)_(\w+)$/];
7
+ static guess(migration) {
8
+ for (const pattern of TableGuesser.CREATE_PATTERNS) {
9
+ const matches = migration.match(pattern);
10
+ if (matches) return [matches[1], true];
11
+ }
12
+ for (const pattern of TableGuesser.CHANGE_PATTERNS) {
13
+ const matches = migration.match(pattern);
14
+ if (matches) return [matches[2], false];
15
+ }
16
+ return [];
17
+ }
18
+ };
19
+
20
+ //#endregion
21
+ Object.defineProperty(exports, 'TableGuesser', {
22
+ enumerable: true,
23
+ get: function () {
24
+ return TableGuesser;
25
+ }
26
+ });
27
+ Object.defineProperty(exports, 'Utils', {
28
+ enumerable: true,
29
+ get: function () {
30
+ return Utils;
31
+ }
32
+ });
33
+ //# sourceMappingURL=Utils-D6ZDNdVG.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils-D6ZDNdVG.cjs","names":[],"sources":["../src/Utils.ts"],"sourcesContent":["export class Utils {\n}\n\nclass TableGuesser {\n static CREATE_PATTERNS = [\n /^create_(\\w+)_table$/,\n /^create_(\\w+)$/\n ]\n static CHANGE_PATTERNS = [\n /.+_(to|from|in)_(\\w+)_table$/,\n /.+_(to|from|in)_(\\w+)$/\n ]\n static guess (migration: string) {\n for (const pattern of TableGuesser.CREATE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[1], true]\n }\n }\n for (const pattern of TableGuesser.CHANGE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[2], false]\n }\n }\n return []\n }\n}\n\nexport { TableGuesser }\n"],"mappings":";;AAAA,IAAa,QAAb,MAAmB;AAGnB,IAAM,eAAN,MAAM,aAAa;CACjB,OAAO,kBAAkB,CACvB,wBACA,iBACD;CACD,OAAO,kBAAkB,CACvB,gCACA,yBACD;CACD,OAAO,MAAO,WAAmB;AAC/B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,KAAK;;AAG7B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,MAAM;;AAG9B,SAAO,EAAE"}
@@ -0,0 +1,21 @@
1
+ //#region src/Utils.ts
2
+ var Utils = class {};
3
+ var TableGuesser = class TableGuesser {
4
+ static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
5
+ static CHANGE_PATTERNS = [/.+_(to|from|in)_(\w+)_table$/, /.+_(to|from|in)_(\w+)$/];
6
+ static guess(migration) {
7
+ for (const pattern of TableGuesser.CREATE_PATTERNS) {
8
+ const matches = migration.match(pattern);
9
+ if (matches) return [matches[1], true];
10
+ }
11
+ for (const pattern of TableGuesser.CHANGE_PATTERNS) {
12
+ const matches = migration.match(pattern);
13
+ if (matches) return [matches[2], false];
14
+ }
15
+ return [];
16
+ }
17
+ };
18
+
19
+ //#endregion
20
+ export { TableGuesser, Utils };
21
+ //# sourceMappingURL=Utils-Dn22CO9s.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils-Dn22CO9s.js","names":[],"sources":["../src/Utils.ts"],"sourcesContent":["export class Utils {\n}\n\nclass TableGuesser {\n static CREATE_PATTERNS = [\n /^create_(\\w+)_table$/,\n /^create_(\\w+)$/\n ]\n static CHANGE_PATTERNS = [\n /.+_(to|from|in)_(\\w+)_table$/,\n /.+_(to|from|in)_(\\w+)$/\n ]\n static guess (migration: string) {\n for (const pattern of TableGuesser.CREATE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[1], true]\n }\n }\n for (const pattern of TableGuesser.CHANGE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[2], false]\n }\n }\n return []\n }\n}\n\nexport { TableGuesser }\n"],"mappings":";AAAA,IAAa,QAAb,MAAmB;AAGnB,IAAM,eAAN,MAAM,aAAa;CACjB,OAAO,kBAAkB,CACvB,wBACA,iBACD;CACD,OAAO,kBAAkB,CACvB,gCACA,yBACD;CACD,OAAO,MAAO,WAAmB;AAC/B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,KAAK;;AAG7B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,MAAM;;AAG9B,SAAO,EAAE"}
package/dist/Utils.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_Utils = require('./Utils-CpiQZ3n9.cjs');
1
+ const require_Utils = require('./Utils-D6ZDNdVG.cjs');
2
2
 
3
3
  exports.TableGuesser = require_Utils.TableGuesser;
4
4
  exports.Utils = require_Utils.Utils;
package/dist/Utils.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { TableGuesser, Utils } from "./Utils-rIdzILgO.cjs";
1
+ import { TableGuesser, Utils } from "./Utils-CxAcuqeI.cjs";
2
2
  export { TableGuesser, Utils };
package/dist/Utils.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { TableGuesser, Utils } from "./Utils-cBgwEyTl.js";
1
+ import { TableGuesser, Utils } from "./Utils-CbqNJtIj.js";
2
2
  export { TableGuesser, Utils };
package/dist/Utils.js CHANGED
@@ -1,3 +1,3 @@
1
- import { TableGuesser, Utils } from "./Utils-Dvclc4Pc.js";
1
+ import { TableGuesser, Utils } from "./Utils-Dn22CO9s.js";
2
2
 
3
3
  export { TableGuesser, Utils };
package/dist/index.cjs CHANGED
@@ -1,22 +1,41 @@
1
- const require_Utils = require('./Utils-CpiQZ3n9.cjs');
2
- let fs_promises = require("fs/promises");
3
- fs_promises = require_Utils.__toESM(fs_promises);
4
- let path = require("path");
5
- path = require_Utils.__toESM(path);
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const require_Utils = require('./Utils-D6ZDNdVG.cjs');
6
25
  let __h3ravel_core = require("@h3ravel/core");
7
- __h3ravel_core = require_Utils.__toESM(__h3ravel_core);
26
+ __h3ravel_core = __toESM(__h3ravel_core);
8
27
  let __h3ravel_shared = require("@h3ravel/shared");
9
- __h3ravel_shared = require_Utils.__toESM(__h3ravel_shared);
28
+ __h3ravel_shared = __toESM(__h3ravel_shared);
10
29
  let node_fs_promises = require("node:fs/promises");
11
- node_fs_promises = require_Utils.__toESM(node_fs_promises);
30
+ node_fs_promises = __toESM(node_fs_promises);
12
31
  let __h3ravel_support = require("@h3ravel/support");
13
- __h3ravel_support = require_Utils.__toESM(__h3ravel_support);
32
+ __h3ravel_support = __toESM(__h3ravel_support);
14
33
  let dayjs = require("dayjs");
15
- dayjs = require_Utils.__toESM(dayjs);
34
+ dayjs = __toESM(dayjs);
16
35
  let node_fs = require("node:fs");
17
- node_fs = require_Utils.__toESM(node_fs);
36
+ node_fs = __toESM(node_fs);
18
37
  let node_path = require("node:path");
19
- node_path = require_Utils.__toESM(node_path);
38
+ node_path = __toESM(node_path);
20
39
  require("@h3ravel/http");
21
40
  require("@h3ravel/router");
22
41
  require("@h3ravel/database");
@@ -25,11 +44,13 @@ require("@h3ravel/queue");
25
44
  require("@h3ravel/mail");
26
45
  require("@h3ravel/config");
27
46
  let commander = require("commander");
28
- commander = require_Utils.__toESM(commander);
47
+ commander = __toESM(commander);
48
+ let path = require("path");
49
+ path = __toESM(path);
29
50
  let child_process = require("child_process");
30
- child_process = require_Utils.__toESM(child_process);
51
+ child_process = __toESM(child_process);
31
52
  let tsdown = require("tsdown");
32
- tsdown = require_Utils.__toESM(tsdown);
53
+ tsdown = __toESM(tsdown);
33
54
 
34
55
  //#region src/Commands/Command.ts
35
56
  var Command = class extends __h3ravel_core.ConsoleCommand {};
@@ -124,44 +145,6 @@ var ListCommand = class extends Command {
124
145
  }
125
146
  };
126
147
 
127
- //#endregion
128
- //#region ../filesystem/dist/index.js
129
- var Helpers = class {
130
- static findModulePkg(moduleId, cwd) {
131
- const parts = moduleId.replace(/\\/g, "/").split("/");
132
- let packageName = "";
133
- if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
134
- packageName += parts.shift();
135
- const packageJson = path.default.join(cwd ?? process.cwd(), "node_modules", packageName);
136
- const resolved = this.findUpConfig(packageJson, "package", ["json"]);
137
- if (!resolved) return;
138
- return path.default.join(path.default.dirname(resolved), parts.join("/"));
139
- }
140
- /**
141
- * Check if file exists
142
- *
143
- * @param path
144
- * @returns
145
- */
146
- static async fileExists(path$1$1) {
147
- try {
148
- await (0, fs_promises.access)(path$1$1);
149
- return true;
150
- } catch {
151
- return false;
152
- }
153
- }
154
- static findUpConfig(cwd, name, extensions) {
155
- return require_Utils.sync_default(cwd, (_dir, names) => {
156
- for (const ext of extensions) {
157
- const filename = `${name}.${ext}`;
158
- if (names.includes(filename)) return filename;
159
- }
160
- return false;
161
- });
162
- }
163
- };
164
-
165
148
  //#endregion
166
149
  //#region src/Commands/MakeCommand.ts
167
150
  var MakeCommand = class extends Command {
@@ -234,15 +217,15 @@ var MakeCommand = class extends Command {
234
217
  const type = this.option("api") ? "-resource" : "";
235
218
  const name = this.argument("name");
236
219
  const force = this.option("force");
237
- const path$5 = node_path.default.join(app_path("Http/Controllers"), name + ".ts");
238
- const crtlrPath = Helpers.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
220
+ const path$4 = node_path.default.join(app_path("Http/Controllers"), name + ".ts");
221
+ const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
239
222
  const stubPath = node_path.default.join(crtlrPath, `dist/stubs/controller${type}.stub`);
240
223
  /** Check if the controller already exists */
241
- if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
224
+ if (!force && (0, node_fs.existsSync)(path$4)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
242
225
  let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
243
226
  stub = stub.replace(/{{ name }}/g, name);
244
- await (0, node_fs_promises.writeFile)(path$5, stub);
245
- __h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
227
+ await (0, node_fs_promises.writeFile)(path$4, stub);
228
+ __h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$4), "gray", false));
246
229
  }
247
230
  makeResource() {
248
231
  __h3ravel_shared.Logger.success("Resource support is not yet available");
@@ -253,8 +236,8 @@ var MakeCommand = class extends Command {
253
236
  async makeMigration() {
254
237
  const name = this.argument("name");
255
238
  const datePrefix = (0, dayjs.default)().format("YYYY_MM_DD_HHmmss");
256
- const path$5 = node_path.default.join(database_path("migrations"), `${datePrefix}_${name}.ts`);
257
- const crtlrPath = require_Utils.Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
239
+ const path$4 = node_path.default.join(database_path("migrations"), `${datePrefix}_${name}.ts`);
240
+ const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
258
241
  let create = this.option("create", false);
259
242
  let table = this.option("table");
260
243
  if (!table && typeof create === "string") {
@@ -270,9 +253,9 @@ var MakeCommand = class extends Command {
270
253
  let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
271
254
  if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
272
255
  __h3ravel_shared.Logger.info("INFO: Creating Migration");
273
- await this.kernel.ensureDirectoryExists(node_path.default.dirname(path$5));
274
- await (0, node_fs_promises.writeFile)(path$5, stub);
275
- __h3ravel_shared.Logger.split("INFO: Migration Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
256
+ await this.kernel.ensureDirectoryExists(node_path.default.dirname(path$4));
257
+ await (0, node_fs_promises.writeFile)(path$4, stub);
258
+ __h3ravel_shared.Logger.split("INFO: Migration Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$4), "gray", false));
276
259
  }
277
260
  /**
278
261
  * Create a new model factory
@@ -293,15 +276,15 @@ var MakeCommand = class extends Command {
293
276
  const type = this.option("type", "ts");
294
277
  const name = this.argument("name");
295
278
  const force = this.argument("force");
296
- const path$5 = node_path.default.join(app_path("Models"), name.toLowerCase(), "." + type);
279
+ const path$4 = node_path.default.join(app_path("Models"), name.toLowerCase(), "." + type);
297
280
  /** Check if the model already exists */
298
- if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
299
- const crtlrPath = require_Utils.Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
281
+ if (!force && (0, node_fs.existsSync)(path$4)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
282
+ const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
300
283
  const stubPath = node_path.default.join(crtlrPath, `dist/stubs/model-${type}.stub`);
301
284
  let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
302
285
  stub = stub.replace(/{{ name }}/g, name);
303
- await (0, node_fs_promises.writeFile)(path$5, stub);
304
- __h3ravel_shared.Logger.split("INFO: Model Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
286
+ await (0, node_fs_promises.writeFile)(path$4, stub);
287
+ __h3ravel_shared.Logger.split("INFO: Model Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$4), "gray", false));
305
288
  }
306
289
  /**
307
290
  * Create a new view.
@@ -309,11 +292,11 @@ var MakeCommand = class extends Command {
309
292
  async makeView() {
310
293
  const name = this.argument("name");
311
294
  const force = this.option("force");
312
- const path$5 = node_path.default.join(base_path("src/resources/views"), name + ".edge");
313
- if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$5, "/"), { recursive: true });
295
+ const path$4 = node_path.default.join(base_path("src/resources/views"), name + ".edge");
296
+ if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$4, "/"), { recursive: true });
314
297
  /** Check if the view already exists */
315
- if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
316
- await (0, node_fs_promises.writeFile)(path$5, `{{-- src/resources/views/${name}.edge --}}`);
298
+ if (!force && (0, node_fs.existsSync)(path$4)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
299
+ await (0, node_fs_promises.writeFile)(path$4, `{{-- src/resources/views/${name}.edge --}}`);
317
300
  __h3ravel_shared.Logger.split("INFO: View Created", __h3ravel_shared.Logger.log(`src/resources/views/${name}.edge`, "gray", false));
318
301
  }
319
302
  /**
@@ -333,6 +316,30 @@ var MakeCommand = class extends Command {
333
316
  }
334
317
  };
335
318
 
319
+ //#endregion
320
+ //#region src/Commands/PostinstallCommand.ts
321
+ var PostinstallCommand = class extends Command {
322
+ /**
323
+ * The name and signature of the console command.
324
+ *
325
+ * @var string
326
+ */
327
+ signature = "postinstall";
328
+ /**
329
+ * The console command description.
330
+ *
331
+ * @var string
332
+ */
333
+ description = "Default post installation command";
334
+ async handle() {
335
+ this.createSqliteDB();
336
+ }
337
+ async createSqliteDB() {
338
+ if (!await __h3ravel_shared.FileSystem.fileExists(database_path())) await (0, node_fs_promises.mkdir)(database_path(), { recursive: true });
339
+ if (!await __h3ravel_shared.FileSystem.fileExists(database_path("db.sqlite"))) await (0, node_fs_promises.writeFile)(database_path("db.sqlite"), "");
340
+ }
341
+ };
342
+
336
343
  //#endregion
337
344
  //#region src/Signature.ts
338
345
  var Signature = class Signature {
@@ -609,7 +616,11 @@ var Musket = class Musket {
609
616
  return this.initialize();
610
617
  }
611
618
  loadBaseCommands() {
612
- [new MakeCommand(this.app, this.kernel), new ListCommand(this.app, this.kernel)].forEach((e) => this.addCommand(e));
619
+ [
620
+ new MakeCommand(this.app, this.kernel),
621
+ new ListCommand(this.app, this.kernel),
622
+ new PostinstallCommand(this.app, this.kernel)
623
+ ].forEach((e) => this.addCommand(e));
613
624
  }
614
625
  async loadDiscoveredCommands() {
615
626
  const commands = [...this.app.registeredCommands.map((cmd) => new cmd(this.app, this.kernel))];
@@ -763,8 +774,8 @@ var Kernel = class Kernel extends __h3ravel_core.ConsoleKernel {
763
774
  }
764
775
  async loadRequirements() {
765
776
  this.cwd = node_path.default.join(process.cwd(), this.basePath);
766
- this.modulePath = Helpers.findModulePkg("@h3ravel/core", this.cwd) ?? "";
767
- this.consolePath = Helpers.findModulePkg("@h3ravel/console", this.cwd) ?? "";
777
+ this.modulePath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/core", this.cwd) ?? "";
778
+ this.consolePath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/console", this.cwd) ?? "";
768
779
  try {
769
780
  this.modulePackage = await import(node_path.default.join(this.modulePath, "package.json"));
770
781
  } catch {
@@ -815,6 +826,7 @@ exports.Kernel = Kernel;
815
826
  exports.ListCommand = ListCommand;
816
827
  exports.MakeCommand = MakeCommand;
817
828
  exports.Musket = Musket;
829
+ exports.PostinstallCommand = PostinstallCommand;
818
830
  exports.Signature = Signature;
819
831
  exports.TableGuesser = require_Utils.TableGuesser;
820
832
  exports.TsDownConfig = TsDownConfig;