@h3ravel/console 11.8.0 → 11.9.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,8 +1,11 @@
1
1
  #!/usr/bin/env node
2
- const e=require(`./zero-BT86xjc9.cjs`);require(`tsx/esm`);let t=require(`@h3ravel/core`);t=e.__toESM(t);let n=require(`@h3ravel/shared`);n=e.__toESM(n);let r=require(`execa`);r=e.__toESM(r);let i=require(`preferred-pm`);i=e.__toESM(i);let a=require(`node:fs/promises`);a=e.__toESM(a);let o=require(`@h3ravel/support`);o=e.__toESM(o);let s=require(`node:path`);s=e.__toESM(s);let c=require(`commander`);c=e.__toESM(c);let l=require(`node:fs`);l=e.__toESM(l);let u=require(`child_process`);u=e.__toESM(u);let d=require(`path`);d=e.__toESM(d);let f=require(`tsdown`);f=e.__toESM(f);var p=class e extends t.ConsoleCommand{signature=`build:
2
+ const e=require(`./zero-Ce9OzYZl.cjs`);require(`tsx/esm`);let t=require(`@h3ravel/core`);t=e.__toESM(t);let n=require(`@h3ravel/shared`);n=e.__toESM(n);let r=require(`execa`);r=e.__toESM(r);let i=require(`preferred-pm`);i=e.__toESM(i);let a=require(`node:fs/promises`);a=e.__toESM(a);let o=require(`@h3ravel/support`);o=e.__toESM(o);let s=require(`node:path`);s=e.__toESM(s);let c=require(`commander`);c=e.__toESM(c);let l=require(`node:fs`);l=e.__toESM(l);let u=require(`child_process`);u=e.__toESM(u);let d=require(`path`);d=e.__toESM(d);let f=require(`tsdown`);f=e.__toESM(f);var p=class e extends t.ConsoleCommand{signature=`build
3
3
  {--m|minify : Minify your bundle output}
4
4
  {--d|dev : Build for dev but don't watch for changes}
5
- `;description=`Build the app for production`;async handle(){try{await this.fire()}catch(e){n.Logger.error(e)}}async fire(){let t=this.option(`dev`)?`.h3ravel/serve`:env(`DIST_DIR`,`dist`),n=this.option(`minify`),r=this.getVerbosity(),i=r>0;this.newLine(),await e.build({outDir:t,minify:n,verbosity:r,debug:i,mute:!1}),this.newLine()}static async build({debug:e,minify:t,mute:a,verbosity:o,outDir:s}={mute:!1,debug:!1,minify:!1,verbosity:0,outDir:`dist`}){let c=(await(0,i.default)(base_path()))?.name??`pnpm`,l={EXTENDED_DEBUG:e?`true`:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:s,DIST_MINIFY:t,LOG_LEVEL:[`silent`,`info`,`warn`,`error`][o]},u=l.LOG_LEVEL===`silent`?`--silent`:null;if(a)return await(0,r.execa)(c,[`tsdown`,u,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:base_path(),env:Object.assign({},process.env,l)});let d=s===`dist`?`Production`:`Development`;return await n.TaskManager.advancedTaskRunner([[`Creating ${d} Bundle`,`STARTED`],[`${d} Bundle Created`,`COMPLETED`]],async()=>{await(0,r.execa)(c,[`tsdown`,u,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:base_path(),env:Object.assign({},process.env,l)})})}},m=class extends t.ConsoleCommand{};const h=String.raw`
5
+ `;description=`Build the app for production`;async handle(){try{await this.fire()}catch(e){n.Logger.error(e)}}async fire(){let t=this.option(`dev`)?`.h3ravel/serve`:env(`DIST_DIR`,`dist`),n=this.option(`minify`),r=this.getVerbosity(),i=r>0;this.newLine(),await e.build({outDir:t,minify:n,verbosity:r,debug:i,mute:!1}),this.newLine()}static async build({debug:e,minify:t,mute:a,verbosity:o,outDir:s}={mute:!1,debug:!1,minify:!1,verbosity:0,outDir:`dist`}){let c=(await(0,i.default)(base_path()))?.name??`pnpm`,l={EXTENDED_DEBUG:e?`true`:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:s,DIST_MINIFY:t,LOG_LEVEL:[`silent`,`info`,`warn`,`error`][o]},u=l.LOG_LEVEL===`silent`?`--silent`:null;if(a)return await(0,r.execa)(c,[`tsdown`,u,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:base_path(),env:Object.assign({},process.env,l)});let d=s===`dist`?`Production`:`Development`;return await n.TaskManager.advancedTaskRunner([[`Creating ${d} Bundle`,`STARTED`],[`${d} Bundle Created`,`COMPLETED`]],async()=>{await(0,r.execa)(c,[`tsdown`,u,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:base_path(),env:Object.assign({},process.env,l)})})}},m=class extends t.ConsoleCommand{},h=class extends m{signature=`help
6
+ {command_name=help : The command name}
7
+ {--format=txt : The output format}
8
+ `;description=`Display help for a command`;async handle(){let e=this.argument(`command_name`);if(!e){this.program.outputHelp();return}let t=this.program.commands.find(t=>t.name()===e);t||(this.error(`ERROR: Unknown command: ${n.Logger.log(e,[`italic`,`grey`],!1)}.`),process.exit(1)),t.outputHelp()}};const g=String.raw`
6
9
  111
7
10
  111111111
8
11
  1111111111 111111
@@ -24,20 +27,20 @@ const e=require(`./zero-BT86xjc9.cjs`);require(`tsx/esm`);let t=require(`@h3rave
24
27
  111111 111 111111
25
28
  111111111
26
29
  110
27
- `,g=String.raw`
30
+ `,_=String.raw`
28
31
  _ _ _____ _
29
32
  | | | |___ / _ __ __ ___ _____| |
30
33
  | |_| | |_ \| '__/ _ \ \ / / _ \ |
31
34
  | _ |___) | | | (_| |\ V / __/ |
32
35
  |_| |_|____/|_| \__,_| \_/ \___|_|
33
36
 
34
- `;var _=class e extends m{signature=`list`;description=`List all available commands`;async handle(){let t=[{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=>n.Logger.describe(n.Logger.log(` `+[e.short,e.long].filter(e=>!!e).join(`, `),`green`,!1),e.description,25,!1).join(``)),r=this.program.commands.map(e=>n.Logger.describe(n.Logger.log(` `+e.name(),`green`,!1),e.description(),25,!1).join(``)),i=e.groupItems(r);n.Logger.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(g),console.log(``),n.Logger.log(`Usage:`,`yellow`),n.Logger.log(` command [options] [arguments]`,`white`),console.log(``),n.Logger.log(`Options:`,`yellow`),console.log(t.join(`
37
+ `;var v=class e extends m{signature=`list`;description=`List all available commands`;async handle(){let t=[{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=>n.Logger.describe(n.Logger.log(` `+[e.short,e.long].filter(e=>!!e).join(`, `),`green`,!1),e.description,25,!1).join(``)),r=this.program.commands.map(e=>n.Logger.describe(n.Logger.log(` `+e.name(),`green`,!1),e.description(),25,!1).join(``)),i=e.groupItems(r);n.Logger.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(_),console.log(``),n.Logger.log(`Usage:`,`yellow`),n.Logger.log(` command [options] [arguments]`,`white`),console.log(``),n.Logger.log(`Options:`,`yellow`),console.log(t.join(`
35
38
  `).trim()),console.log(``),n.Logger.log(`Available Commands:`,`yellow`),console.log(i.join(`
36
39
 
37
40
  `).trim())}static groupItems(e,t=!1){let r=e.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},{});return Object.entries(r).map(([e,r])=>{let i=e===`__root__`?``:e,a=[n.Logger.log(i,`yellow`,!1),r.join(`
38
41
  `)].join(`
39
42
  `);return t&&(a+=`
40
- `),a})}},v=class extends m{signature=`#make:
43
+ `),a})}},y=class extends m{signature=`#make:
41
44
  {controller : Create a new controller class.
42
45
  | {--a|api : Exclude the create and edit methods from the controller}
43
46
  | {--m|model= : Generate a resource controller for the given model}
@@ -56,8 +59,7 @@ const e=require(`./zero-BT86xjc9.cjs`);require(`tsx/esm`);let t=require(`@h3rave
56
59
  | {--force : Create the view even if it already exists}
57
60
  }
58
61
  {^name : The name of the [name] to generate}
59
- `;description=`Generate component classes`;async handle(){let e=this.dictionary.baseCommand??this.dictionary.name;this.argument(`name`)||this.program.error(`Please provide a valid name for the `+e),await this[{controller:`makeController`,resource:`makeResource`,view:`makeView`,command:`makeCommand`}[e]]()}async makeController(){let e=this.option(`api`)?`-resource`:``,t=this.argument(`name`),r=this.option(`force`),i=n.FileSystem.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,c=s.default.join(i,`dist/stubs/controller${e}.stub`),l=app_path(`Http/Controllers/${t}.ts`);t.includes(`/`)&&await(0,a.mkdir)(o.Str.beforeLast(l,`/`),{recursive:!0}),!r&&await n.FileSystem.fileExists(l)&&n.Logger.error(`ERORR: ${t} controller already exists`);let u=await(0,a.readFile)(c,`utf-8`);u=u.replace(/{{ name }}/g,t),await(0,a.writeFile)(l,u),n.Logger.split(`INFO: Controller Created`,n.Logger.log(s.default.basename(l),`gray`,!1))}makeResource(){n.Logger.success(`Resource support is not yet available`)}makeCommand(){n.Logger.success(`Musket command creation is not yet available`)}async makeView(){let e=this.argument(`name`),t=this.option(`force`),r=base_path(`src/resources/views/${e}.edge`);e.includes(`/`)&&await(0,a.mkdir)(o.Str.beforeLast(r,`/`),{recursive:!0}),!t&&await n.FileSystem.fileExists(r)&&n.Logger.error(`ERORR: ${e} view already exists`),await(0,a.writeFile)(r,`{{-- src/resources/views/${e}.edge --}}`),n.Logger.split(`INFO: View Created`,n.Logger.log(`src/resources/views/${e}.edge`,`gray`,!1))}},y=class extends m{signature=`postinstall`;description=`Default post installation command`;async handle(){this.createSqliteDB()}async createSqliteDB(){config(`database.default`)===`sqlite`&&(await n.FileSystem.fileExists(database_path())||await(0,a.mkdir)(database_path(),{recursive:!0}),await n.FileSystem.fileExists(database_path(`db.sqlite`))||await(0,a.writeFile)(database_path(`db.sqlite`),``))}},b=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,h;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),h=`[${f.split(`--`).at(1)?.split(`|`).at(1)??f}]`);let g=f.startsWith(`--`),_,v;if(g){let e=f.split(`|`).map(e=>e.trim());_=[];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){_.push(t.substring(0,e));let n=t.substring(e+1);v=n===`*`?[]:n===`true`||n===`false`||!n&&!p?n===`true`:isNaN(Number(n))?n:Number(n)}else _.push(t)}}n.push({name:g?_[_.length-1]:f,required:p,multiple:m,description:l,flags:_,shared:t,isFlag:g,isHidden:r,placeholder:h,defaultValue:v,nestedOptions:u})}return n}static parseSignature(t,n){let r=t.split(`
60
- `).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 x(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,u.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 S=process.env.NODE_ENV||`development`;let C=S===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(C=process.env.DIST_DIR);const w={outDir:C,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:S===`development`,minify:!!process.env.DIST_MINIFY,external:[/^@h3ravel\/.*/gi],clean:!0,shims:!0,copy:[{from:`public`,to:C},`src/resources`,`src/database`],env:S===`development`?{NODE_ENV:S,DIST_DIR:C}:{},watch:S===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,hooks(e){e.hook(`build:done`,async()=>{let e=[`database/migrations`,`database/factories`,`database/seeders`];for(let t=0;t<e.length;t++){let n=e[t];(0,l.existsSync)(s.default.join(C,n))&&await(0,a.rm)(s.default.join(C,n),{recursive:!0})}})},plugins:S===`development`&&process.env.CLI_BUILD!==`true`?[x({env:Object.assign({},process.env,{NODE_ENV:S,DIST_DIR:C}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]};var T=w,E=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),await this.initialize()}loadBaseCommands(){[new v(this.app,this.kernel),new _(this.app,this.kernel),new y(this.app,this.kernel),new p(this.app,this.kernel)].forEach(e=>this.addCommand(e))}async loadDiscoveredCommands(){let e=`/${env(`DIST_DIR`,`.h3ravel/serve`)}/`.replaceAll(`//`,``),t=[...this.app.registeredCommands.map(e=>new e(this.app,this.kernel))],n=app_path(`Console/Commands/*.js`).replace(`/src/`,e);for await(let e of(0,a.glob)(n)){let n=s.default.basename(e).replace(`.js`,``);try{let r=(await import(e))[n];t.push(new r(this.app,this.kernel))}catch{}}t.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(b.parseSignature(e.getSignature(),e))}async initialize(){(process.argv.includes(`--help`)||process.argv.includes(`-h`))&&(await this.rebuild(`help`),Object.keys(require.cache).forEach(e=>delete require.cache[e]));let e=n.Logger.parse([[`Musket CLI:`,`white`],[this.kernel.consolePackage.version,`green`]],` `,!1),t=n.Logger.parse([[`H3ravel Framework:`,`white`],[this.kernel.modulePackage.version,`green`]],` `,!1),r={quiet:[`-q, --quiet`,`Do not output any message except errors and warnings`],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`],noInteraction:[`-n, --no-interaction`,`Do not ask any interactive question`]};c.program.name(`musket`).version(`${e}\n${t}`).description(g).configureHelp({showGlobalOptions:!0}).addOption(new c.Option(r.quiet[0],r.quiet[1])).addOption(new c.Option(r.silent[0],r.silent[1]).implies({quiet:!0})).addOption(new c.Option(r.verbose[0],r.verbose[1]).choices([`1`,`2`,`3`])).addOption(new c.Option(r.noInteraction[0],r.noInteraction[1])).action(async()=>{let e=new _(this.app,this.kernel);e.setInput(c.program.opts(),c.program.args,c.program.registeredArguments,{},c.program),e.handle()}),c.program.configureHelp({styleTitle:e=>n.Logger.log(e,`yellow`,!1),styleOptionTerm:e=>n.Logger.log(e,`green`,!1),styleArgumentTerm:e=>n.Logger.log(e,`green`,!1),styleSubcommandTerm:e=>n.Logger.log(e,`green`,!1),formatItemList(e,t){if(t.length<1)return[];let r=e=>e.replace(/[^A-Za-z0-9-,]/g,``).replace(`32m`,``),i=t.filter(e=>r(e).startsWith(`--`)||r(e).includes(`,--`));i.length>0&&(i=[n.Logger.log(`
62
+ `;description=`Generate component classes`;async handle(){let e=this.dictionary.baseCommand??this.dictionary.name;this.argument(`name`)||this.program.error(`Please provide a valid name for the `+e),await this[{controller:`makeController`,resource:`makeResource`,view:`makeView`,command:`makeCommand`}[e]]()}async makeController(){let e=this.option(`api`)?`-resource`:``,t=this.argument(`name`),r=this.option(`force`),i=n.FileSystem.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,c=s.default.join(i,`dist/stubs/controller${e}.stub`),l=app_path(`Http/Controllers/${t}.ts`);t.includes(`/`)&&await(0,a.mkdir)(o.Str.beforeLast(l,`/`),{recursive:!0}),!r&&await n.FileSystem.fileExists(l)&&n.Logger.error(`ERORR: ${t} controller already exists`);let u=await(0,a.readFile)(c,`utf-8`);u=u.replace(/{{ name }}/g,t),await(0,a.writeFile)(l,u),n.Logger.split(`INFO: Controller Created`,n.Logger.log(s.default.basename(l),`gray`,!1))}makeResource(){n.Logger.success(`Resource support is not yet available`)}makeCommand(){n.Logger.success(`Musket command creation is not yet available`)}async makeView(){let e=this.argument(`name`),t=this.option(`force`),r=base_path(`src/resources/views/${e}.edge`);e.includes(`/`)&&await(0,a.mkdir)(o.Str.beforeLast(r,`/`),{recursive:!0}),!t&&await n.FileSystem.fileExists(r)&&n.Logger.error(`ERORR: ${e} view already exists`),await(0,a.writeFile)(r,`{{-- src/resources/views/${e}.edge --}}`),n.Logger.split(`INFO: View Created`,n.Logger.log(`src/resources/views/${e}.edge`,`gray`,!1))}},b=class extends m{signature=`postinstall`;description=`Default post installation command`;async handle(){this.createSqliteDB()}async createSqliteDB(){config(`database.default`)===`sqlite`&&(await n.FileSystem.fileExists(database_path())||await(0,a.mkdir)(database_path(),{recursive:!0}),await n.FileSystem.fileExists(database_path(`db.sqlite`))||await(0,a.writeFile)(database_path(`db.sqlite`),``))}},x=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,m=[],h=/[^a-zA-Z0-9_|-]/.test(f),g=!1,_,v;if(f.includes(`=`)){let[e,t]=f.split(`=`);f=e.trim();let n=e.trim().split(`|`),r=(n.at(1)??n.at(0)).replace(`--`,``);v=t.trim(),_=v?`[${r}]`:`<${r}>`,h=!1}f.endsWith(`?*`)?(h=!1,g=!0,f=f.slice(0,-2)):f.endsWith(`*`)?(g=!0,f=f.slice(0,-1)):f.endsWith(`?`)&&(h=!1,f=f.slice(0,-1),_=`[${f.split(`--`).at(1)?.split(`|`).at(1)??f}]`);let y=f.startsWith(`--`);if(y){let e=f.split(`|`).map(e=>e.trim());p=[];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){p.push(t.substring(0,e));let n=t.substring(e+1);v=n===`*`?[]:n===`true`||n===`false`||!n&&!h?n===`true`:isNaN(Number(n))?n:Number(n)}else p.push(t)}}let b=l.match(/^([^:]+?)\s*:\s*\[?([\w\s,]+)\]?$/);i&&(l=b?.[1].trim()??l,m=b?.[2].split(`,`).map(e=>e.trim()).filter(Boolean)??m),n.push({name:y?p[p.length-1]:f,choices:m,required:h,multiple:g,description:l,flags:p,shared:t,isFlag:y,isHidden:r,placeholder:_,defaultValue:v,nestedOptions:u})}return n}static parseSignature(t,n){let r=t.split(`
63
+ `).map(e=>e.trim()).filter(e=>e.length>0),i=[`#`,`^`].includes(r[0][0])||/:[#^]/.test(r[0]),a=r[0].split(`{`)[0].trim().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 S(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,u.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 C=process.env.NODE_ENV||`development`;let w=C===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(w=process.env.DIST_DIR);const T={outDir:w,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:C===`development`,minify:!!process.env.DIST_MINIFY,external:[/^@h3ravel\/.*/gi],clean:!0,shims:!0,copy:[{from:`public`,to:w},`src/resources`,`src/database`],env:C===`development`?{NODE_ENV:C,DIST_DIR:w}:{},watch:C===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,hooks(e){e.hook(`build:done`,async()=>{let e=[`database/migrations`,`database/factories`,`database/seeders`];for(let t=0;t<e.length;t++){let n=e[t];(0,l.existsSync)(s.default.join(w,n))&&await(0,a.rm)(s.default.join(w,n),{recursive:!0})}})},plugins:C===`development`&&process.env.CLI_BUILD!==`true`?[S({env:Object.assign({},process.env,{NODE_ENV:C,DIST_DIR:w}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]};var E=T,D=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),await this.initialize()}loadBaseCommands(){[new h(this.app,this.kernel),new y(this.app,this.kernel),new v(this.app,this.kernel),new b(this.app,this.kernel),new p(this.app,this.kernel)].forEach(e=>this.addCommand(e))}async loadDiscoveredCommands(){let e=`/${env(`DIST_DIR`,`.h3ravel/serve`)}/`.replaceAll(`//`,``),t=[...this.app.registeredCommands.map(e=>new e(this.app,this.kernel))],n=app_path(`Console/Commands/*.js`).replace(`/src/`,e);for await(let e of(0,a.glob)(n)){let n=s.default.basename(e).replace(`.js`,``);try{let r=(await import(e))[n];t.push(new r(this.app,this.kernel))}catch{}}t.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(x.parseSignature(e.getSignature(),e))}async initialize(){(process.argv.includes(`--help`)||process.argv.includes(`-h`))&&(await this.rebuild(`help`),Object.keys(require.cache).forEach(e=>delete require.cache[e]));let e=n.Logger.parse([[`Musket CLI:`,`white`],[this.kernel.consolePackage.version,`green`]],` `,!1),t=n.Logger.parse([[`H3ravel Framework:`,`white`],[this.kernel.modulePackage.version,`green`]],` `,!1),r={quiet:[`-q, --quiet`,`Do not output any message except errors and warnings`],silent:[`--silent`,`Do not output any message`],verbose:[`-v, --verbose [level]`,`Increase the verbosity of messages: 1 for normal output, 2 and v for more verbose output and 3 and vv for debug`],noInteraction:[`-n, --no-interaction`,`Do not ask any interactive question`]};c.program.name(`musket`).version(`${e}\n${t}`).description(_).configureHelp({showGlobalOptions:!0}).addOption(new c.Option(r.quiet[0],r.quiet[1])).addOption(new c.Option(r.silent[0],r.silent[1]).implies({quiet:!0})).addOption(new c.Option(r.verbose[0],r.verbose[1]).choices([`1`,`2`,`3`,`v`,`vv`]).default(`1`)).addOption(new c.Option(r.noInteraction[0],r.noInteraction[1])).action(async()=>{let e=new v(this.app,this.kernel);e.setInput(c.program.opts(),c.program.args,c.program.registeredArguments,{},c.program),await this.handle(e)}),c.program.configureHelp({styleTitle:e=>n.Logger.log(e,`yellow`,!1),styleOptionTerm:e=>n.Logger.log(e,`green`,!1),styleArgumentTerm:e=>n.Logger.log(e,`green`,!1),styleSubcommandTerm:e=>n.Logger.log(e,`green`,!1),formatItemList(e,t){if(t.length<1)return[];if(!e.includes(`Commands:`))return t;let r=e=>e.replace(/[^A-Za-z0-9-,]/g,``).replace(`32m`,``),i=t.filter(e=>r(e).startsWith(`--`)||r(e).includes(`,--`));i.length>0&&(i=[n.Logger.log(`
61
64
  `+e+`
62
- `,`yellow`,!1)].concat(i));let a=t.filter(e=>!r(e).startsWith(`--`)&&!r(e).includes(`,--`));return a.length<1?i:i.concat(n.Logger.log(`
63
- Available Commands:`,`yellow`,!1),_.groupItems(a,!0))},showGlobalOptions:!0}),c.program.command(`init`).description(`Initialize H3ravel.`).action(async()=>{n.Logger.success(`Initialized: H3ravel has been initialized!`)});for(let e=0;e<this.commands.length;e++){let t=this.commands[e],n=t.commandClass;if(t.isNamespaceCommand&&t.subCommands){let e=t.isHidden?c.program:c.program.command(t.baseCommand).description(t.description??``).action(async()=>{n.setInput(e.opts(),e.args,e.registeredArguments,t,c.program),await n.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 r=c.program.command(`${t.baseCommand}:${e.name}`).description(e.description||``).action(async()=>{n.setInput(r.opts(),r.args,r.registeredArguments,e,c.program),await n.handle()});t.subCommands?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,r,!1,e)}),t.options?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,r,!1,e)}),e.nestedOptions&&e.nestedOptions.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(e=>{this.makeOption(e,r)})})}else{let e=c.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()=>{n.setInput(e.opts(),e.args,e.registeredArguments,t,c.program),await n.handle()})}}return c.program.hook(`preAction`,async(e,t)=>{this.rebuild(t.name())}),c.program}async rebuild(e){e!==`fire`&&e!==`build`&&await(0,f.build)({...T,watch:!1,plugins:[]})}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.replace(/^-+/,``)}`).join(`, `)??void 0;e.required&&!e.placeholder?n+=` <${a}>`:e.placeholder&&(n+=` `+e.placeholder),t.option(n||``,i,e.defaultValue)}else{let n=e.flags?.join(`, `)??``;e.required&&!e.placeholder?n+=` <${a}>`:e.placeholder&&(n+=` `+e.placeholder),t.option(n,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()}},D=class e extends t.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 E.parse(this),process.exit(0)}async loadRequirements(){this.cwd=s.default.join(process.cwd(),this.basePath),this.modulePath=n.FileSystem.findModulePkg(`@h3ravel/core`,this.cwd)??``,this.consolePath=n.FileSystem.findModulePkg(`@h3ravel/console`,this.cwd)??``;try{this.modulePackage=await import(s.default.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(s.default.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},O=class extends t.ServiceProvider{static priority=992;static runsInConsole=!0;runsInConsole=!0;register(){}boot(){D.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}},k=class{async fire(){let e=process.env.DIST_DIR??`/.h3ravel/serve/`,n=[],r=new t.Application(process.cwd()),i=base_path(s.default.join(e,`bootstrap/providers.js`));n.push(...(await import(i)).default),n.push(O),await r.quickStartup(n,[`CoreServiceProvider`])}};new k().fire();
65
+ `,`yellow`,!1)].concat(i));let a=t.filter(e=>!r(e).startsWith(`--`)&&!r(e).includes(`,--`));if(a.length<1)return i;let o=r(e).includes(`Arguments`)?e:`Available Commands:`;return i.concat(n.Logger.log(`\n${o}`,`yellow`,!1),v.groupItems(a,!0))},showGlobalOptions:!0}),c.program.command(`init`).description(`Initialize H3ravel.`).action(async()=>{n.Logger.success(`Initialized: H3ravel has been initialized!`)});for(let e=0;e<this.commands.length;e++){let t=this.commands[e],n=t.commandClass;if(t.isNamespaceCommand&&t.subCommands){let e=t.isHidden?c.program:c.program.command(t.baseCommand).description(t.description??``).action(async()=>{n.setInput(e.opts(),e.args,e.registeredArguments,t,c.program),await this.handle(n)});(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 r=c.program.command(`${t.baseCommand}:${e.name}`).description(e.description||``).action(async()=>{n.setInput(r.opts(),r.args,r.registeredArguments,e,c.program),await this.handle(n)});t.subCommands?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,r,!1,e)}),t.options?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,r,!1,e)}),e.nestedOptions&&e.nestedOptions.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(e=>{this.makeOption(e,r)})})}else{let e=c.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()=>{n.setInput(e.opts(),e.args,e.registeredArguments,t,c.program),await this.handle(n)})}}return c.program.hook(`preAction`,async(e,t)=>{this.rebuild(t.name())}),c.program}async rebuild(e){e!==`fire`&&e!==`build`&&await(0,f.build)({...E,watch:!1,plugins:[]})}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.replace(/^-+/,``)}`).join(`, `)??void 0;e.required&&!e.placeholder?n+=` <${a}>`:e.placeholder&&(n+=` `+e.placeholder);let r=new c.Option(n||``,i).default(e.defaultValue);e.choices&&e.choices.length&&(r=r.choices(e.choices??[])),t.addOption(r)}else{let n=e.flags?.join(`, `)??``;e.required&&!e.placeholder?n+=` <${a}>`:e.placeholder&&(n+=` `+e.placeholder);let r=new c.Option(n,i).default(e.defaultValue);e.choices&&e.choices.length&&(r=r.choices(e.choices??[])),t.addOption(r)}else{let n=e.placeholder;n||=e.required?`<${e.name}>`:`[${e.name}]`;let r=new c.Argument(n,i);e.choices&&e.choices.length&&(r=r.choices(e.choices??[])),e.defaultValue&&r.default(e.defaultValue),t.addArgument(r)}}async handle(e){await new t.ContainerResolver(this.app).resolveMethodParams(e,`handle`)}static async parse(t){return(await new e(t.app,t).build()).exitOverride(()=>{n.Logger.log(`Unknown command or argument.`,`white`),n.Logger.log([[`Run`,`white`],["`musket --help`",[`grey`,`italic`]],[`to see available commands.`,`white`]],` `)}).parseAsync(process.argv).catch(e=>e)}},O=class e extends t.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 D.parse(this),process.exit(0)}async loadRequirements(){this.cwd=s.default.join(process.cwd(),this.basePath),this.modulePath=n.FileSystem.findModulePkg(`@h3ravel/core`,this.cwd)??``,this.consolePath=n.FileSystem.findModulePkg(`@h3ravel/console`,this.cwd)??``;try{this.modulePackage=await import(s.default.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(s.default.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},k=class extends t.ServiceProvider{static priority=992;static runsInConsole=!0;runsInConsole=!0;register(){}boot(){O.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}},A=class{async fire(){let e=process.env.DIST_DIR??`/.h3ravel/serve/`,n=[],r=new t.Application(process.cwd()),i=base_path(s.default.join(e,`bootstrap/providers.js`));n.push(...(await import(i)).default),n.push(k),await r.quickStartup(n,[`CoreServiceProvider`])}};new A().fire();
package/bin/fire.js CHANGED
@@ -1,8 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import"./zero-Ddh7ucIS.js";import{createRequire as e}from"node:module";import"tsx/esm";import{Application as t,ConsoleCommand as n,ConsoleKernel as r,ServiceProvider as i}from"@h3ravel/core";import{FileSystem as a,Logger as o,TaskManager as s}from"@h3ravel/shared";import{execa as c}from"execa";import l from"preferred-pm";import{glob as u,mkdir as d,readFile as f,rm as p,writeFile as m}from"node:fs/promises";import{Str as h}from"@h3ravel/support";import g from"node:path";import{Option as _,program as v}from"commander";import{existsSync as y}from"node:fs";import{fork as b}from"child_process";import{dirname as x,join as S,resolve as C}from"path";import{build as w}from"tsdown";var T=e(import.meta.url),E=class e extends n{signature=`build:
2
+ import"./zero-BGMatB6V.js";import{createRequire as e}from"node:module";import"tsx/esm";import{Application as t,ConsoleCommand as n,ConsoleKernel as r,ContainerResolver as i,ServiceProvider as a}from"@h3ravel/core";import{FileSystem as o,Logger as s,TaskManager as c}from"@h3ravel/shared";import{execa as l}from"execa";import u from"preferred-pm";import{glob as d,mkdir as f,readFile as p,rm as m,writeFile as h}from"node:fs/promises";import{Str as g}from"@h3ravel/support";import _ from"node:path";import{Argument as v,Option as y,program as b}from"commander";import{existsSync as x}from"node:fs";import{fork as S}from"child_process";import{dirname as C,join as w,resolve as T}from"path";import{build as E}from"tsdown";var D=e(import.meta.url),O=class e extends n{signature=`build
3
3
  {--m|minify : Minify your bundle output}
4
4
  {--d|dev : Build for dev but don't watch for changes}
5
- `;description=`Build the app for production`;async handle(){try{await this.fire()}catch(e){o.error(e)}}async fire(){let t=this.option(`dev`)?`.h3ravel/serve`:env(`DIST_DIR`,`dist`),n=this.option(`minify`),r=this.getVerbosity(),i=r>0;this.newLine(),await e.build({outDir:t,minify:n,verbosity:r,debug:i,mute:!1}),this.newLine()}static async build({debug:e,minify:t,mute:n,verbosity:r,outDir:i}={mute:!1,debug:!1,minify:!1,verbosity:0,outDir:`dist`}){let a=(await l(base_path()))?.name??`pnpm`,o={EXTENDED_DEBUG:e?`true`:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:i,DIST_MINIFY:t,LOG_LEVEL:[`silent`,`info`,`warn`,`error`][r]},u=o.LOG_LEVEL===`silent`?`--silent`:null;if(n)return await c(a,[`tsdown`,u,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:base_path(),env:Object.assign({},process.env,o)});let d=i===`dist`?`Production`:`Development`;return await s.advancedTaskRunner([[`Creating ${d} Bundle`,`STARTED`],[`${d} Bundle Created`,`COMPLETED`]],async()=>{await c(a,[`tsdown`,u,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:base_path(),env:Object.assign({},process.env,o)})})}},D=class extends n{};String.raw`
5
+ `;description=`Build the app for production`;async handle(){try{await this.fire()}catch(e){s.error(e)}}async fire(){let t=this.option(`dev`)?`.h3ravel/serve`:env(`DIST_DIR`,`dist`),n=this.option(`minify`),r=this.getVerbosity(),i=r>0;this.newLine(),await e.build({outDir:t,minify:n,verbosity:r,debug:i,mute:!1}),this.newLine()}static async build({debug:e,minify:t,mute:n,verbosity:r,outDir:i}={mute:!1,debug:!1,minify:!1,verbosity:0,outDir:`dist`}){let a=(await u(base_path()))?.name??`pnpm`,o={EXTENDED_DEBUG:e?`true`:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:i,DIST_MINIFY:t,LOG_LEVEL:[`silent`,`info`,`warn`,`error`][r]},s=o.LOG_LEVEL===`silent`?`--silent`:null;if(n)return await l(a,[`tsdown`,s,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:base_path(),env:Object.assign({},process.env,o)});let d=i===`dist`?`Production`:`Development`;return await c.advancedTaskRunner([[`Creating ${d} Bundle`,`STARTED`],[`${d} Bundle Created`,`COMPLETED`]],async()=>{await l(a,[`tsdown`,s,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:base_path(),env:Object.assign({},process.env,o)})})}},k=class extends n{},A=class extends k{signature=`help
6
+ {command_name=help : The command name}
7
+ {--format=txt : The output format}
8
+ `;description=`Display help for a command`;async handle(){let e=this.argument(`command_name`);if(!e){this.program.outputHelp();return}let t=this.program.commands.find(t=>t.name()===e);t||(this.error(`ERROR: Unknown command: ${s.log(e,[`italic`,`grey`],!1)}.`),process.exit(1)),t.outputHelp()}};String.raw`
6
9
  111
7
10
  111111111
8
11
  1111111111 111111
@@ -24,20 +27,20 @@ import"./zero-Ddh7ucIS.js";import{createRequire as e}from"node:module";import"ts
24
27
  111111 111 111111
25
28
  111111111
26
29
  110
27
- `;const O=String.raw`
30
+ `;const j=String.raw`
28
31
  _ _ _____ _
29
32
  | | | |___ / _ __ __ ___ _____| |
30
33
  | |_| | |_ \| '__/ _ \ \ / / _ \ |
31
34
  | _ |___) | | | (_| |\ V / __/ |
32
35
  |_| |_|____/|_| \__,_| \_/ \___|_|
33
36
 
34
- `;var k=class e extends D{signature=`list`;description=`List all available commands`;async handle(){let t=[{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=>o.describe(o.log(` `+[e.short,e.long].filter(e=>!!e).join(`, `),`green`,!1),e.description,25,!1).join(``)),n=this.program.commands.map(e=>o.describe(o.log(` `+e.name(),`green`,!1),e.description(),25,!1).join(``)),r=e.groupItems(n);o.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(O),console.log(``),o.log(`Usage:`,`yellow`),o.log(` command [options] [arguments]`,`white`),console.log(``),o.log(`Options:`,`yellow`),console.log(t.join(`
35
- `).trim()),console.log(``),o.log(`Available Commands:`,`yellow`),console.log(r.join(`
37
+ `;var M=class e extends k{signature=`list`;description=`List all available commands`;async handle(){let t=[{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=>s.describe(s.log(` `+[e.short,e.long].filter(e=>!!e).join(`, `),`green`,!1),e.description,25,!1).join(``)),n=this.program.commands.map(e=>s.describe(s.log(` `+e.name(),`green`,!1),e.description(),25,!1).join(``)),r=e.groupItems(n);s.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(j),console.log(``),s.log(`Usage:`,`yellow`),s.log(` command [options] [arguments]`,`white`),console.log(``),s.log(`Options:`,`yellow`),console.log(t.join(`
38
+ `).trim()),console.log(``),s.log(`Available Commands:`,`yellow`),console.log(r.join(`
36
39
 
37
- `).trim())}static groupItems(e,t=!1){let n=e.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},{});return Object.entries(n).map(([e,n])=>{let r=e===`__root__`?``:e,i=[o.log(r,`yellow`,!1),n.join(`
40
+ `).trim())}static groupItems(e,t=!1){let n=e.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},{});return Object.entries(n).map(([e,n])=>{let r=e===`__root__`?``:e,i=[s.log(r,`yellow`,!1),n.join(`
38
41
  `)].join(`
39
42
  `);return t&&(i+=`
40
- `),i})}},A=class extends D{signature=`#make:
43
+ `),i})}},N=class extends k{signature=`#make:
41
44
  {controller : Create a new controller class.
42
45
  | {--a|api : Exclude the create and edit methods from the controller}
43
46
  | {--m|model= : Generate a resource controller for the given model}
@@ -56,8 +59,7 @@ import"./zero-Ddh7ucIS.js";import{createRequire as e}from"node:module";import"ts
56
59
  | {--force : Create the view even if it already exists}
57
60
  }
58
61
  {^name : The name of the [name] to generate}
59
- `;description=`Generate component classes`;async handle(){let e=this.dictionary.baseCommand??this.dictionary.name;this.argument(`name`)||this.program.error(`Please provide a valid name for the `+e),await this[{controller:`makeController`,resource:`makeResource`,view:`makeView`,command:`makeCommand`}[e]]()}async makeController(){let e=this.option(`api`)?`-resource`:``,t=this.argument(`name`),n=this.option(`force`),r=a.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,i=g.join(r,`dist/stubs/controller${e}.stub`),s=app_path(`Http/Controllers/${t}.ts`);t.includes(`/`)&&await d(h.beforeLast(s,`/`),{recursive:!0}),!n&&await a.fileExists(s)&&o.error(`ERORR: ${t} controller already exists`);let c=await f(i,`utf-8`);c=c.replace(/{{ name }}/g,t),await m(s,c),o.split(`INFO: Controller Created`,o.log(g.basename(s),`gray`,!1))}makeResource(){o.success(`Resource support is not yet available`)}makeCommand(){o.success(`Musket command creation is not yet available`)}async makeView(){let e=this.argument(`name`),t=this.option(`force`),n=base_path(`src/resources/views/${e}.edge`);e.includes(`/`)&&await d(h.beforeLast(n,`/`),{recursive:!0}),!t&&await a.fileExists(n)&&o.error(`ERORR: ${e} view already exists`),await m(n,`{{-- src/resources/views/${e}.edge --}}`),o.split(`INFO: View Created`,o.log(`src/resources/views/${e}.edge`,`gray`,!1))}},j=class extends D{signature=`postinstall`;description=`Default post installation command`;async handle(){this.createSqliteDB()}async createSqliteDB(){config(`database.default`)===`sqlite`&&(await a.fileExists(database_path())||await d(database_path(),{recursive:!0}),await a.fileExists(database_path(`db.sqlite`))||await m(database_path(`db.sqlite`),``))}},M=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,h;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),h=`[${f.split(`--`).at(1)?.split(`|`).at(1)??f}]`);let g=f.startsWith(`--`),_,v;if(g){let e=f.split(`|`).map(e=>e.trim());_=[];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){_.push(t.substring(0,e));let n=t.substring(e+1);v=n===`*`?[]:n===`true`||n===`false`||!n&&!p?n===`true`:isNaN(Number(n))?n:Number(n)}else _.push(t)}}n.push({name:g?_[_.length-1]:f,required:p,multiple:m,description:l,flags:_,shared:t,isFlag:g,isHidden:r,placeholder:h,defaultValue:v,nestedOptions:u})}return n}static parseSignature(t,n){let r=t.split(`
60
- `).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 N(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=C(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=b(S(e,t),r,o)},c=e.dir||x(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 P=process.env.NODE_ENV||`development`;let F=P===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(F=process.env.DIST_DIR);var I={outDir:F,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:P===`development`,minify:!!process.env.DIST_MINIFY,external:[/^@h3ravel\/.*/gi],clean:!0,shims:!0,copy:[{from:`public`,to:F},`src/resources`,`src/database`],env:P===`development`?{NODE_ENV:P,DIST_DIR:F}:{},watch:P===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,hooks(e){e.hook(`build:done`,async()=>{let e=[`database/migrations`,`database/factories`,`database/seeders`];for(let t=0;t<e.length;t++){let n=e[t];y(g.join(F,n))&&await p(g.join(F,n),{recursive:!0})}})},plugins:P===`development`&&process.env.CLI_BUILD!==`true`?[N({env:Object.assign({},process.env,{NODE_ENV:P,DIST_DIR:F}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]},L=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),await this.initialize()}loadBaseCommands(){[new A(this.app,this.kernel),new k(this.app,this.kernel),new j(this.app,this.kernel),new E(this.app,this.kernel)].forEach(e=>this.addCommand(e))}async loadDiscoveredCommands(){let e=`/${env(`DIST_DIR`,`.h3ravel/serve`)}/`.replaceAll(`//`,``),t=[...this.app.registeredCommands.map(e=>new e(this.app,this.kernel))],n=app_path(`Console/Commands/*.js`).replace(`/src/`,e);for await(let e of u(n)){let n=g.basename(e).replace(`.js`,``);try{let r=(await import(e))[n];t.push(new r(this.app,this.kernel))}catch{}}t.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(M.parseSignature(e.getSignature(),e))}async initialize(){(process.argv.includes(`--help`)||process.argv.includes(`-h`))&&(await this.rebuild(`help`),Object.keys(T.cache).forEach(e=>delete T.cache[e]));let e=o.parse([[`Musket CLI:`,`white`],[this.kernel.consolePackage.version,`green`]],` `,!1),t=o.parse([[`H3ravel Framework:`,`white`],[this.kernel.modulePackage.version,`green`]],` `,!1),n={quiet:[`-q, --quiet`,`Do not output any message except errors and warnings`],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`],noInteraction:[`-n, --no-interaction`,`Do not ask any interactive question`]};v.name(`musket`).version(`${e}\n${t}`).description(O).configureHelp({showGlobalOptions:!0}).addOption(new _(n.quiet[0],n.quiet[1])).addOption(new _(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new _(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new _(n.noInteraction[0],n.noInteraction[1])).action(async()=>{let e=new k(this.app,this.kernel);e.setInput(v.opts(),v.args,v.registeredArguments,{},v),e.handle()}),v.configureHelp({styleTitle:e=>o.log(e,`yellow`,!1),styleOptionTerm:e=>o.log(e,`green`,!1),styleArgumentTerm:e=>o.log(e,`green`,!1),styleSubcommandTerm:e=>o.log(e,`green`,!1),formatItemList(e,t){if(t.length<1)return[];let n=e=>e.replace(/[^A-Za-z0-9-,]/g,``).replace(`32m`,``),r=t.filter(e=>n(e).startsWith(`--`)||n(e).includes(`,--`));r.length>0&&(r=[o.log(`
62
+ `;description=`Generate component classes`;async handle(){let e=this.dictionary.baseCommand??this.dictionary.name;this.argument(`name`)||this.program.error(`Please provide a valid name for the `+e),await this[{controller:`makeController`,resource:`makeResource`,view:`makeView`,command:`makeCommand`}[e]]()}async makeController(){let e=this.option(`api`)?`-resource`:``,t=this.argument(`name`),n=this.option(`force`),r=o.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,i=_.join(r,`dist/stubs/controller${e}.stub`),a=app_path(`Http/Controllers/${t}.ts`);t.includes(`/`)&&await f(g.beforeLast(a,`/`),{recursive:!0}),!n&&await o.fileExists(a)&&s.error(`ERORR: ${t} controller already exists`);let c=await p(i,`utf-8`);c=c.replace(/{{ name }}/g,t),await h(a,c),s.split(`INFO: Controller Created`,s.log(_.basename(a),`gray`,!1))}makeResource(){s.success(`Resource support is not yet available`)}makeCommand(){s.success(`Musket command creation is not yet available`)}async makeView(){let e=this.argument(`name`),t=this.option(`force`),n=base_path(`src/resources/views/${e}.edge`);e.includes(`/`)&&await f(g.beforeLast(n,`/`),{recursive:!0}),!t&&await o.fileExists(n)&&s.error(`ERORR: ${e} view already exists`),await h(n,`{{-- src/resources/views/${e}.edge --}}`),s.split(`INFO: View Created`,s.log(`src/resources/views/${e}.edge`,`gray`,!1))}},P=class extends k{signature=`postinstall`;description=`Default post installation command`;async handle(){this.createSqliteDB()}async createSqliteDB(){config(`database.default`)===`sqlite`&&(await o.fileExists(database_path())||await f(database_path(),{recursive:!0}),await o.fileExists(database_path(`db.sqlite`))||await h(database_path(`db.sqlite`),``))}},F=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,m=[],h=/[^a-zA-Z0-9_|-]/.test(f),g=!1,_,v;if(f.includes(`=`)){let[e,t]=f.split(`=`);f=e.trim();let n=e.trim().split(`|`),r=(n.at(1)??n.at(0)).replace(`--`,``);v=t.trim(),_=v?`[${r}]`:`<${r}>`,h=!1}f.endsWith(`?*`)?(h=!1,g=!0,f=f.slice(0,-2)):f.endsWith(`*`)?(g=!0,f=f.slice(0,-1)):f.endsWith(`?`)&&(h=!1,f=f.slice(0,-1),_=`[${f.split(`--`).at(1)?.split(`|`).at(1)??f}]`);let y=f.startsWith(`--`);if(y){let e=f.split(`|`).map(e=>e.trim());p=[];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){p.push(t.substring(0,e));let n=t.substring(e+1);v=n===`*`?[]:n===`true`||n===`false`||!n&&!h?n===`true`:isNaN(Number(n))?n:Number(n)}else p.push(t)}}let b=l.match(/^([^:]+?)\s*:\s*\[?([\w\s,]+)\]?$/);i&&(l=b?.[1].trim()??l,m=b?.[2].split(`,`).map(e=>e.trim()).filter(Boolean)??m),n.push({name:y?p[p.length-1]:f,choices:m,required:h,multiple:g,description:l,flags:p,shared:t,isFlag:y,isHidden:r,placeholder:_,defaultValue:v,nestedOptions:u})}return n}static parseSignature(t,n){let r=t.split(`
63
+ `).map(e=>e.trim()).filter(e=>e.length>0),i=[`#`,`^`].includes(r[0][0])||/:[#^]/.test(r[0]),a=r[0].split(`{`)[0].trim().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 I(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=T(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=S(w(e,t),r,o)},c=e.dir||C(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 L=process.env.NODE_ENV||`development`;let R=L===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(R=process.env.DIST_DIR);var z={outDir:R,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:L===`development`,minify:!!process.env.DIST_MINIFY,external:[/^@h3ravel\/.*/gi],clean:!0,shims:!0,copy:[{from:`public`,to:R},`src/resources`,`src/database`],env:L===`development`?{NODE_ENV:L,DIST_DIR:R}:{},watch:L===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,hooks(e){e.hook(`build:done`,async()=>{let e=[`database/migrations`,`database/factories`,`database/seeders`];for(let t=0;t<e.length;t++){let n=e[t];x(_.join(R,n))&&await m(_.join(R,n),{recursive:!0})}})},plugins:L===`development`&&process.env.CLI_BUILD!==`true`?[I({env:Object.assign({},process.env,{NODE_ENV:L,DIST_DIR:R}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]},B=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),await this.initialize()}loadBaseCommands(){[new A(this.app,this.kernel),new N(this.app,this.kernel),new M(this.app,this.kernel),new P(this.app,this.kernel),new O(this.app,this.kernel)].forEach(e=>this.addCommand(e))}async loadDiscoveredCommands(){let e=`/${env(`DIST_DIR`,`.h3ravel/serve`)}/`.replaceAll(`//`,``),t=[...this.app.registeredCommands.map(e=>new e(this.app,this.kernel))],n=app_path(`Console/Commands/*.js`).replace(`/src/`,e);for await(let e of d(n)){let n=_.basename(e).replace(`.js`,``);try{let r=(await import(e))[n];t.push(new r(this.app,this.kernel))}catch{}}t.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(F.parseSignature(e.getSignature(),e))}async initialize(){(process.argv.includes(`--help`)||process.argv.includes(`-h`))&&(await this.rebuild(`help`),Object.keys(D.cache).forEach(e=>delete D.cache[e]));let e=s.parse([[`Musket CLI:`,`white`],[this.kernel.consolePackage.version,`green`]],` `,!1),t=s.parse([[`H3ravel Framework:`,`white`],[this.kernel.modulePackage.version,`green`]],` `,!1),n={quiet:[`-q, --quiet`,`Do not output any message except errors and warnings`],silent:[`--silent`,`Do not output any message`],verbose:[`-v, --verbose [level]`,`Increase the verbosity of messages: 1 for normal output, 2 and v for more verbose output and 3 and vv for debug`],noInteraction:[`-n, --no-interaction`,`Do not ask any interactive question`]};b.name(`musket`).version(`${e}\n${t}`).description(j).configureHelp({showGlobalOptions:!0}).addOption(new y(n.quiet[0],n.quiet[1])).addOption(new y(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new y(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`,`v`,`vv`]).default(`1`)).addOption(new y(n.noInteraction[0],n.noInteraction[1])).action(async()=>{let e=new M(this.app,this.kernel);e.setInput(b.opts(),b.args,b.registeredArguments,{},b),await this.handle(e)}),b.configureHelp({styleTitle:e=>s.log(e,`yellow`,!1),styleOptionTerm:e=>s.log(e,`green`,!1),styleArgumentTerm:e=>s.log(e,`green`,!1),styleSubcommandTerm:e=>s.log(e,`green`,!1),formatItemList(e,t){if(t.length<1)return[];if(!e.includes(`Commands:`))return t;let n=e=>e.replace(/[^A-Za-z0-9-,]/g,``).replace(`32m`,``),r=t.filter(e=>n(e).startsWith(`--`)||n(e).includes(`,--`));r.length>0&&(r=[s.log(`
61
64
  `+e+`
62
- `,`yellow`,!1)].concat(r));let i=t.filter(e=>!n(e).startsWith(`--`)&&!n(e).includes(`,--`));return i.length<1?r:r.concat(o.log(`
63
- Available Commands:`,`yellow`,!1),k.groupItems(i,!0))},showGlobalOptions:!0}),v.command(`init`).description(`Initialize H3ravel.`).action(async()=>{o.success(`Initialized: H3ravel has been initialized!`)});for(let e=0;e<this.commands.length;e++){let t=this.commands[e],n=t.commandClass;if(t.isNamespaceCommand&&t.subCommands){let e=t.isHidden?v:v.command(t.baseCommand).description(t.description??``).action(async()=>{n.setInput(e.opts(),e.args,e.registeredArguments,t,v),await n.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 r=v.command(`${t.baseCommand}:${e.name}`).description(e.description||``).action(async()=>{n.setInput(r.opts(),r.args,r.registeredArguments,e,v),await n.handle()});t.subCommands?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,r,!1,e)}),t.options?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,r,!1,e)}),e.nestedOptions&&e.nestedOptions.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(e=>{this.makeOption(e,r)})})}else{let e=v.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()=>{n.setInput(e.opts(),e.args,e.registeredArguments,t,v),await n.handle()})}}return v.hook(`preAction`,async(e,t)=>{this.rebuild(t.name())}),v}async rebuild(e){e!==`fire`&&e!==`build`&&await w({...I,watch:!1,plugins:[]})}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.replace(/^-+/,``)}`).join(`, `)??void 0;e.required&&!e.placeholder?n+=` <${a}>`:e.placeholder&&(n+=` `+e.placeholder),t.option(n||``,i,e.defaultValue)}else{let n=e.flags?.join(`, `)??``;e.required&&!e.placeholder?n+=` <${a}>`:e.placeholder&&(n+=` `+e.placeholder),t.option(n,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()}},R=class e extends r{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 L.parse(this),process.exit(0)}async loadRequirements(){this.cwd=g.join(process.cwd(),this.basePath),this.modulePath=a.findModulePkg(`@h3ravel/core`,this.cwd)??``,this.consolePath=a.findModulePkg(`@h3ravel/console`,this.cwd)??``;try{this.modulePackage=await import(g.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(g.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},z=class extends i{static priority=992;static runsInConsole=!0;runsInConsole=!0;register(){}boot(){R.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}};new class{async fire(){let e=process.env.DIST_DIR??`/.h3ravel/serve/`,n=[],r=new t(process.cwd()),i=base_path(g.join(e,`bootstrap/providers.js`));n.push(...(await import(i)).default),n.push(z),await r.quickStartup(n,[`CoreServiceProvider`])}}().fire();export{};
65
+ `,`yellow`,!1)].concat(r));let i=t.filter(e=>!n(e).startsWith(`--`)&&!n(e).includes(`,--`));if(i.length<1)return r;let a=n(e).includes(`Arguments`)?e:`Available Commands:`;return r.concat(s.log(`\n${a}`,`yellow`,!1),M.groupItems(i,!0))},showGlobalOptions:!0}),b.command(`init`).description(`Initialize H3ravel.`).action(async()=>{s.success(`Initialized: H3ravel has been initialized!`)});for(let e=0;e<this.commands.length;e++){let t=this.commands[e],n=t.commandClass;if(t.isNamespaceCommand&&t.subCommands){let e=t.isHidden?b:b.command(t.baseCommand).description(t.description??``).action(async()=>{n.setInput(e.opts(),e.args,e.registeredArguments,t,b),await this.handle(n)});(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 r=b.command(`${t.baseCommand}:${e.name}`).description(e.description||``).action(async()=>{n.setInput(r.opts(),r.args,r.registeredArguments,e,b),await this.handle(n)});t.subCommands?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,r,!1,e)}),t.options?.filter(e=>e.shared).forEach(t=>{this.makeOption(t,r,!1,e)}),e.nestedOptions&&e.nestedOptions.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(e=>{this.makeOption(e,r)})})}else{let e=b.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()=>{n.setInput(e.opts(),e.args,e.registeredArguments,t,b),await this.handle(n)})}}return b.hook(`preAction`,async(e,t)=>{this.rebuild(t.name())}),b}async rebuild(e){e!==`fire`&&e!==`build`&&await E({...z,watch:!1,plugins:[]})}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.replace(/^-+/,``)}`).join(`, `)??void 0;e.required&&!e.placeholder?n+=` <${a}>`:e.placeholder&&(n+=` `+e.placeholder);let r=new y(n||``,i).default(e.defaultValue);e.choices&&e.choices.length&&(r=r.choices(e.choices??[])),t.addOption(r)}else{let n=e.flags?.join(`, `)??``;e.required&&!e.placeholder?n+=` <${a}>`:e.placeholder&&(n+=` `+e.placeholder);let r=new y(n,i).default(e.defaultValue);e.choices&&e.choices.length&&(r=r.choices(e.choices??[])),t.addOption(r)}else{let n=e.placeholder;n||=e.required?`<${e.name}>`:`[${e.name}]`;let r=new v(n,i);e.choices&&e.choices.length&&(r=r.choices(e.choices??[])),e.defaultValue&&r.default(e.defaultValue),t.addArgument(r)}}async handle(e){await new i(this.app).resolveMethodParams(e,`handle`)}static async parse(t){return(await new e(t.app,t).build()).exitOverride(()=>{s.log(`Unknown command or argument.`,`white`),s.log([[`Run`,`white`],["`musket --help`",[`grey`,`italic`]],[`to see available commands.`,`white`]],` `)}).parseAsync(process.argv).catch(e=>e)}},V=class e extends r{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=_.join(process.cwd(),this.basePath),this.modulePath=o.findModulePkg(`@h3ravel/core`,this.cwd)??``,this.consolePath=o.findModulePkg(`@h3ravel/console`,this.cwd)??``;try{this.modulePackage=await import(_.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(_.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},H=class extends a{static priority=992;static runsInConsole=!0;runsInConsole=!0;register(){}boot(){V.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}};new class{async fire(){let e=process.env.DIST_DIR??`/.h3ravel/serve/`,n=[],r=new t(process.cwd()),i=base_path(_.join(e,`bootstrap/providers.js`));n.push(...(await import(i)).default),n.push(H),await r.quickStartup(n,[`CoreServiceProvider`])}}().fire();export{};
package/bin/spawn.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const e=require(`./zero-BT86xjc9.cjs`);new e.zero_default().spawn();
2
+ const e=require(`./zero-Ce9OzYZl.cjs`);new e.zero_default().spawn();
package/bin/spawn.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{zero_default as e}from"./zero-Ddh7ucIS.js";new e().spawn();export{};
2
+ import{zero_default as e}from"./zero-BGMatB6V.js";new e().spawn();export{};
@@ -0,0 +1 @@
1
+ import{FileSystem as e,mainTsconfig as t}from"@h3ravel/shared";import{execa as n}from"execa";import r from"preferred-pm";import{mkdir as i,readdir as a,writeFile as o}from"node:fs/promises";import s,{join as c}from"node:path";var l=class{async spawn(l=`.h3ravel/serve`){let u=(await r(process.cwd()))?.name??`npm`,d=c(process.env.DIST_DIR??l);if(await e.fileExists(d)&&(await a(d)).length>0)return;await e.fileExists(s.join(d,`tsconfig.json`))||(await i(s.join(d.replace(`/serve`,``)),{recursive:!0}),await o(s.join(d.replace(`/serve`,``),`tsconfig.json`),JSON.stringify(t,null,2)));let f={EXTENDED_DEBUG:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:d,LOG_LEVEL:`silent`};await n(u,[`tsdown`,`--silent`,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:c(process.cwd()),env:Object.assign({},process.env,f)})}};export{l as zero_default};
@@ -1 +1 @@
1
- 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));let c=require(`@h3ravel/shared`);c=s(c);let l=require(`execa`);l=s(l);let u=require(`preferred-pm`);u=s(u);let d=require(`node:fs/promises`);d=s(d);let f=require(`node:path`);f=s(f);var p=class{async spawn(e=`.h3ravel/serve`){let t=(await(0,u.default)(process.cwd()))?.name??`npm`,n=(0,f.join)(process.env.DIST_DIR??e);if(await c.FileSystem.fileExists(n))return;await c.FileSystem.fileExists(f.default.join(n,`tsconfig.json`))||(await(0,d.mkdir)(f.default.join(n.replace(`/serve`,``)),{recursive:!0}),await(0,d.writeFile)(f.default.join(n.replace(`/serve`,``),`tsconfig.json`),JSON.stringify(c.mainTsconfig,null,2)));let r={EXTENDED_DEBUG:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:n,LOG_LEVEL:`silent`};await(0,l.execa)(t,[`tsdown`,`--silent`,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:(0,f.join)(process.cwd()),env:Object.assign({},process.env,r)})}};Object.defineProperty(exports,`__toESM`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`zero_default`,{enumerable:!0,get:function(){return p}});
1
+ 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));let c=require(`@h3ravel/shared`);c=s(c);let l=require(`execa`);l=s(l);let u=require(`preferred-pm`);u=s(u);let d=require(`node:fs/promises`);d=s(d);let f=require(`node:path`);f=s(f);var p=class{async spawn(e=`.h3ravel/serve`){let t=(await(0,u.default)(process.cwd()))?.name??`npm`,n=(0,f.join)(process.env.DIST_DIR??e);if(await c.FileSystem.fileExists(n)&&(await(0,d.readdir)(n)).length>0)return;await c.FileSystem.fileExists(f.default.join(n,`tsconfig.json`))||(await(0,d.mkdir)(f.default.join(n.replace(`/serve`,``)),{recursive:!0}),await(0,d.writeFile)(f.default.join(n.replace(`/serve`,``),`tsconfig.json`),JSON.stringify(c.mainTsconfig,null,2)));let r={EXTENDED_DEBUG:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:n,LOG_LEVEL:`silent`};await(0,l.execa)(t,[`tsdown`,`--silent`,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:(0,f.join)(process.cwd()),env:Object.assign({},process.env,r)})}};Object.defineProperty(exports,`__toESM`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`zero_default`,{enumerable:!0,get:function(){return p}});
package/dist/index.cjs CHANGED
@@ -53,7 +53,7 @@ var BuildCommand = class BuildCommand extends __h3ravel_core.ConsoleCommand {
53
53
  *
54
54
  * @var string
55
55
  */
56
- signature = `build:
56
+ signature = `build
57
57
  {--m|minify : Minify your bundle output}
58
58
  {--d|dev : Build for dev but don't watch for changes}
59
59
  `;
@@ -146,6 +146,39 @@ var BuildCommand = class BuildCommand extends __h3ravel_core.ConsoleCommand {
146
146
  //#region src/Commands/Command.ts
147
147
  var Command = class extends __h3ravel_core.ConsoleCommand {};
148
148
 
149
+ //#endregion
150
+ //#region src/Commands/HelpCommand.ts
151
+ var HelpCommand = class extends Command {
152
+ /**
153
+ * The name and signature of the console command.
154
+ *
155
+ * @var string
156
+ */
157
+ signature = `help
158
+ {command_name=help : The command name}
159
+ {--format=txt : The output format}
160
+ `;
161
+ /**
162
+ * The console command description.
163
+ *
164
+ * @var string
165
+ */
166
+ description = "Display help for a command";
167
+ async handle() {
168
+ const cmd = this.argument("command_name");
169
+ if (!cmd) {
170
+ this.program.outputHelp();
171
+ return;
172
+ }
173
+ const target = this.program.commands.find((c) => c.name() === cmd);
174
+ if (!target) {
175
+ this.error(`ERROR: Unknown command: ${__h3ravel_shared.Logger.log(cmd, ["italic", "grey"], false)}.`);
176
+ process.exit(1);
177
+ }
178
+ target.outputHelp();
179
+ }
180
+ };
181
+
149
182
  //#endregion
150
183
  //#region src/logo.ts
151
184
  const logo = String.raw`
@@ -422,13 +455,28 @@ var Signature = class Signature {
422
455
  * Trim the string
423
456
  */
424
457
  description = description.trim();
425
- /**
426
- * Parse name modifiers (?, *, ?*)
427
- */
428
458
  let name = namePart;
459
+ let flags;
460
+ let choices = [];
429
461
  let required = /[^a-zA-Z0-9_|-]/.test(name);
430
462
  let multiple = false;
431
463
  let placeholder;
464
+ let defaultValue;
465
+ /**
466
+ * Parse the command name
467
+ */
468
+ if (name.includes("=")) {
469
+ const [rawName, rawDefault] = name.split("=");
470
+ name = rawName.trim();
471
+ const hold = rawName.trim().split("|");
472
+ const holder = (hold.at(1) ?? hold.at(0)).replace("--", "");
473
+ defaultValue = rawDefault.trim();
474
+ placeholder = defaultValue ? `[${holder}]` : `<${holder}>`;
475
+ required = false;
476
+ }
477
+ /**
478
+ * Parse name modifiers (?, *, ?*)
479
+ */
432
480
  if (name.endsWith("?*")) {
433
481
  required = false;
434
482
  multiple = true;
@@ -445,8 +493,6 @@ var Signature = class Signature {
445
493
  * Check if it's a flag option (starts with --)
446
494
  */
447
495
  const isFlag = name.startsWith("--");
448
- let flags;
449
- let defaultValue;
450
496
  if (isFlag) {
451
497
  /**
452
498
  * Parse flags and default values
@@ -468,8 +514,14 @@ var Signature = class Signature {
468
514
  } else flags.push(part);
469
515
  }
470
516
  }
517
+ const desc = description.match(/^([^:]+?)\s*:\s*\[?([\w\s,]+)\]?$/);
518
+ if (match) {
519
+ description = desc?.[1].trim() ?? description;
520
+ choices = desc?.[2].split(",").map((s) => s.trim()).filter(Boolean) ?? choices;
521
+ }
471
522
  options.push({
472
523
  name: isFlag ? flags[flags.length - 1] : name,
524
+ choices,
473
525
  required,
474
526
  multiple,
475
527
  description,
@@ -494,7 +546,7 @@ var Signature = class Signature {
494
546
  static parseSignature(signature, commandClass) {
495
547
  const lines = signature.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
496
548
  const isHidden = ["#", "^"].includes(lines[0][0]) || /:[#^]/.test(lines[0]);
497
- const baseCommand = lines[0].replace(/[^\w=:-]/g, "");
549
+ const baseCommand = lines[0].split("{")[0].trim().replace(/[^\w:-]/g, "");
498
550
  const description = commandClass.getDescription();
499
551
  const isNamespaceCommand = baseCommand.endsWith(":");
500
552
  /**
@@ -660,6 +712,7 @@ var Musket = class Musket {
660
712
  }
661
713
  loadBaseCommands() {
662
714
  [
715
+ new HelpCommand(this.app, this.kernel),
663
716
  new MakeCommand(this.app, this.kernel),
664
717
  new ListCommand(this.app, this.kernel),
665
718
  new PostinstallCommand(this.app, this.kernel),
@@ -698,7 +751,7 @@ var Musket = class Musket {
698
751
  const additional = {
699
752
  quiet: ["-q, --quiet", "Do not output any message except errors and warnings"],
700
753
  silent: ["--silent", "Do not output any message"],
701
- verbose: ["-v, --verbose <number>", "Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug"],
754
+ verbose: ["-v, --verbose [level]", "Increase the verbosity of messages: 1 for normal output, 2 and v for more verbose output and 3 and vv for debug"],
702
755
  noInteraction: ["-n, --no-interaction", "Do not ask any interactive question"]
703
756
  };
704
757
  /**
@@ -707,11 +760,13 @@ var Musket = class Musket {
707
760
  commander.program.name("musket").version(`${cliVersion}\n${localVersion}`).description(altLogo).configureHelp({ showGlobalOptions: true }).addOption(new commander.Option(additional.quiet[0], additional.quiet[1])).addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).addOption(new commander.Option(additional.verbose[0], additional.verbose[1]).choices([
708
761
  "1",
709
762
  "2",
710
- "3"
711
- ])).addOption(new commander.Option(additional.noInteraction[0], additional.noInteraction[1])).action(async () => {
763
+ "3",
764
+ "v",
765
+ "vv"
766
+ ]).default("1")).addOption(new commander.Option(additional.noInteraction[0], additional.noInteraction[1])).action(async () => {
712
767
  const instance = new ListCommand(this.app, this.kernel);
713
768
  instance.setInput(commander.program.opts(), commander.program.args, commander.program.registeredArguments, {}, commander.program);
714
- instance.handle();
769
+ await this.handle(instance);
715
770
  });
716
771
  /**
717
772
  * Format the help command display
@@ -723,12 +778,14 @@ var Musket = class Musket {
723
778
  styleSubcommandTerm: (str) => __h3ravel_shared.Logger.log(str, "green", false),
724
779
  formatItemList(heading, items) {
725
780
  if (items.length < 1) return [];
781
+ if (!heading.includes("Commands:")) return items;
726
782
  const c = (str) => str.replace(/[^A-Za-z0-9-,]/g, "").replace("32m", "");
727
783
  let flags = items.filter((e) => c(e).startsWith("--") || c(e).includes(",--"));
728
784
  if (flags.length > 0) flags = [__h3ravel_shared.Logger.log("\n" + heading + "\n", "yellow", false)].concat(flags);
729
785
  const list = items.filter((e) => !c(e).startsWith("--") && !c(e).includes(",--"));
730
786
  if (list.length < 1) return flags;
731
- return flags.concat(__h3ravel_shared.Logger.log("\nAvailable Commands:", "yellow", false), ListCommand.groupItems(list, true));
787
+ const _heading = c(heading).includes("Arguments") ? heading : "Available Commands:";
788
+ return flags.concat(__h3ravel_shared.Logger.log(`\n${_heading}`, "yellow", false), ListCommand.groupItems(list, true));
732
789
  },
733
790
  showGlobalOptions: true
734
791
  });
@@ -750,7 +807,7 @@ var Musket = class Musket {
750
807
  */
751
808
  const cmd = command.isHidden ? commander.program : commander.program.command(command.baseCommand).description(command.description ?? "").action(async () => {
752
809
  instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command, commander.program);
753
- await instance.handle();
810
+ await this.handle(instance);
754
811
  });
755
812
  /**
756
813
  * Add options to the base command if it has any
@@ -764,7 +821,7 @@ var Musket = class Musket {
764
821
  command.subCommands.filter((v, i$1, a) => !v.shared && a.findIndex((t) => t.name === v.name) === i$1).forEach((sub) => {
765
822
  const cmd$1 = commander.program.command(`${command.baseCommand}:${sub.name}`).description(sub.description || "").action(async () => {
766
823
  instance.setInput(cmd$1.opts(), cmd$1.args, cmd$1.registeredArguments, sub, commander.program);
767
- await instance.handle();
824
+ await this.handle(instance);
768
825
  });
769
826
  /**
770
827
  * Add the shared arguments here
@@ -795,7 +852,7 @@ var Musket = class Musket {
795
852
  });
796
853
  cmd.action(async () => {
797
854
  instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command, commander.program);
798
- await instance.handle();
855
+ await this.handle(instance);
799
856
  });
800
857
  }
801
858
  }
@@ -819,17 +876,38 @@ var Musket = class Musket {
819
876
  let flags = opt.flags?.map((f) => f.length === 1 ? `-${f}` : `--${f.replace(/^-+/, "")}`).join(", ") ?? void 0;
820
877
  if (opt.required && !opt.placeholder) flags += ` <${type}>`;
821
878
  else if (opt.placeholder) flags += " " + opt.placeholder;
822
- cmd.option(flags || "", description, opt.defaultValue);
879
+ let optn = new commander.Option(flags || "", description).default(opt.defaultValue);
880
+ if (opt.choices && opt.choices.length) optn = optn.choices(opt.choices ?? []);
881
+ cmd.addOption(optn);
823
882
  } else {
824
883
  let flags = opt.flags?.join(", ") ?? "";
825
884
  if (opt.required && !opt.placeholder) flags += ` <${type}>`;
826
885
  else if (opt.placeholder) flags += " " + opt.placeholder;
827
- cmd.option(flags, description, opt.defaultValue);
886
+ let optn = new commander.Option(flags, description).default(opt.defaultValue);
887
+ if (opt.choices && opt.choices.length) optn = optn.choices(opt.choices ?? []);
888
+ cmd.addOption(optn);
828
889
  }
829
- else cmd.argument(opt.required ? `<${opt.name}>` : `[${opt.name}]`, description, opt.defaultValue);
890
+ else {
891
+ let name = opt.placeholder;
892
+ if (!name) name = opt.required ? `<${opt.name}>` : `[${opt.name}]`;
893
+ let arg = new commander.Argument(name, description);
894
+ if (opt.choices && opt.choices.length) arg = arg.choices(opt.choices ?? []);
895
+ if (opt.defaultValue) arg.default(opt.defaultValue);
896
+ cmd.addArgument(arg);
897
+ }
898
+ }
899
+ async handle(cmd) {
900
+ await new __h3ravel_core.ContainerResolver(this.app).resolveMethodParams(cmd, "handle");
830
901
  }
831
902
  static async parse(kernel) {
832
- return (await new Musket(kernel.app, kernel).build()).parseAsync();
903
+ return (await new Musket(kernel.app, kernel).build()).exitOverride(() => {
904
+ __h3ravel_shared.Logger.log("Unknown command or argument.", "white");
905
+ __h3ravel_shared.Logger.log([
906
+ ["Run", "white"],
907
+ ["`musket --help`", ["grey", "italic"]],
908
+ ["to see available commands.", "white"]
909
+ ], " ");
910
+ }).parseAsync(process.argv).catch((e) => e);
833
911
  }
834
912
  };
835
913
 
@@ -900,6 +978,7 @@ var ConsoleServiceProvider = class extends __h3ravel_core.ServiceProvider {
900
978
  exports.BuildCommand = BuildCommand;
901
979
  exports.Command = Command;
902
980
  exports.ConsoleServiceProvider = ConsoleServiceProvider;
981
+ exports.HelpCommand = HelpCommand;
903
982
  exports.Kernel = Kernel;
904
983
  exports.ListCommand = ListCommand;
905
984
  exports.MakeCommand = MakeCommand;