@h3ravel/console 11.6.2 → 11.7.0
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 +8 -26
- package/bin/fire.js +8 -26
- package/dist/index.cjs +18 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -31
- package/dist/index.d.ts +6 -31
- package/dist/index.js +20 -107
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/dist/Utils-CbqNJtIj.d.ts +0 -10
- package/dist/Utils-CxAcuqeI.d.cts +0 -10
- package/dist/Utils-D6ZDNdVG.cjs +0 -33
- package/dist/Utils-D6ZDNdVG.cjs.map +0 -1
- package/dist/Utils-Dn22CO9s.js +0 -21
- package/dist/Utils-Dn22CO9s.js.map +0 -1
- package/dist/Utils.cjs +0 -4
- package/dist/Utils.d.cts +0 -2
- package/dist/Utils.d.ts +0 -2
- package/dist/Utils.js +0 -3
package/bin/fire.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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(`
|
|
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 extends t.ConsoleCommand{signature=`build:
|
|
3
3
|
{--m|minify=false : Minify your bundle output}
|
|
4
4
|
`;description=`Build the app for production`;async handle(){try{await this.fire()}catch(e){n.Logger.error(e)}}async fire(){let e=env(`DIST_DIR`,`dist`),t=(await(0,i.default)(base_path()))?.name??`pnpm`,a=this.option(`minify`),o={EXTENDED_DEBUG:Number(this.option(`verbose`,0))>0?`true`:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:e,DIST_MINIFY:a,LOG_LEVEL:[`silent`,`info`,`warn`,`error`][Number(this.option(`verbose`,0))]},s=o.LOG_LEVEL===`silent`?`--silent`:null;n.Logger.log([[`
|
|
5
|
-
INFO `,`bgBlue`],[` Creating Production Bundle`,`white`]],``),console.log(``),await n.TaskManager.taskRunner(n.Logger.log([[` SUCCESS `,`bgGreen`],[` Production Bundle Created`,`white`]],``,!1),async()=>{await(0,r.execa)(t,[`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)}),console.log(``)})}},
|
|
5
|
+
INFO `,`bgBlue`],[` Creating Production Bundle`,`white`]],``),console.log(``),await n.TaskManager.taskRunner(n.Logger.log([[` SUCCESS `,`bgGreen`],[` Production Bundle Created`,`white`]],``,!1),async()=>{await(0,r.execa)(t,[`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)}),console.log(``)})}},m=class extends t.ConsoleCommand{};const h=String.raw`
|
|
6
6
|
111
|
|
7
7
|
111111111
|
|
8
8
|
1111111111 111111
|
|
@@ -24,19 +24,19 @@ const e=require(`./zero-BT86xjc9.cjs`);require(`tsx/esm`);let t=require(`@h3rave
|
|
|
24
24
|
111111 111 111111
|
|
25
25
|
111111111
|
|
26
26
|
110
|
|
27
|
-
`,
|
|
27
|
+
`,g=String.raw`
|
|
28
28
|
_ _ _____ _
|
|
29
29
|
| | | |___ / _ __ __ ___ _____| |
|
|
30
30
|
| |_| | |_ \| '__/ _ \ \ / / _ \ |
|
|
31
31
|
| _ |___) | | | (_| |\ V / __/ |
|
|
32
32
|
|_| |_|____/|_| \__,_| \_/ \___|_|
|
|
33
33
|
|
|
34
|
-
`;var
|
|
34
|
+
`;var _=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=>n.Logger.describe(n.Logger.log(` `+[e.short,e.long].filter(e=>!!e).join(`, `),`green`,!1),e.description,25,!1).join(``)),t=this.program.commands.map(e=>n.Logger.describe(n.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},{}),r=Object.entries(t).map(([e,t])=>{let r=e===`__root__`?``:e;return[n.Logger.log(r,`yellow`,!1),t.join(`
|
|
35
35
|
`)].join(`
|
|
36
|
-
`)});n.Logger.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(
|
|
36
|
+
`)});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(e.join(`
|
|
37
37
|
`).trim()),console.log(``),n.Logger.log(`Available Commands:`,`yellow`),console.log(r.join(`
|
|
38
38
|
|
|
39
|
-
`).trim())}},
|
|
39
|
+
`).trim())}},v=class extends m{signature=`#make:
|
|
40
40
|
{controller : Create a new controller class.
|
|
41
41
|
| {--a|api : Exclude the create and edit methods from the controller}
|
|
42
42
|
| {--m|model= : Generate a resource controller for the given model}
|
|
@@ -47,31 +47,13 @@ const e=require(`./zero-BT86xjc9.cjs`);require(`tsx/esm`);let t=require(`@h3rave
|
|
|
47
47
|
| {--c|collection : Create a resource collection}
|
|
48
48
|
| {--force : Create the resource even if it already exists}
|
|
49
49
|
}
|
|
50
|
-
{migration : Generates a new database migration class.
|
|
51
|
-
| {--l|type=ts : The file type to generate}
|
|
52
|
-
| {--t|table : The table to migrate}
|
|
53
|
-
| {--c|create : The table to be created}
|
|
54
|
-
}
|
|
55
50
|
{command : Create a new Musket command.
|
|
56
51
|
| {--command : The terminal command that will be used to invoke the class}
|
|
57
52
|
| {--force : Create the class even if the console command already exists}
|
|
58
53
|
}
|
|
59
|
-
{factory : Create a new model factory.}
|
|
60
|
-
{seeder : Create a new seeder class.}
|
|
61
54
|
{view : Create a new view.
|
|
62
55
|
| {--force : Create the view even if it already exists}
|
|
63
56
|
}
|
|
64
|
-
{model : Create a new Eloquent model class.
|
|
65
|
-
| {--api : Indicates if the generated controller should be an API resource controller}
|
|
66
|
-
| {--c|controller : Create a new controller for the model}
|
|
67
|
-
| {--f|factory : Create a new factory for the model}
|
|
68
|
-
| {--m|migration : Create a new migration file for the model}
|
|
69
|
-
| {--r|resource : Indicates if the generated controller should be a resource controller}
|
|
70
|
-
| {--a|all : Generate a migration, seeder, factory, policy, resource controller, and form request classes for the model}
|
|
71
|
-
| {--s|seed : Create a new seeder for the model}
|
|
72
|
-
| {--t|type=ts : The file type to generate}
|
|
73
|
-
| {--force : Create the model even if it already exists}
|
|
74
|
-
}
|
|
75
57
|
{^name : The name of the [name] to generate}
|
|
76
|
-
`;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`,
|
|
77
|
-
`).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
|
|
58
|
+
`;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(`
|
|
59
|
+
`).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(),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))}initialize(){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`],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.program.name(`musket`).version(`${e}\n${t}`).description(g).addOption(new c.Option(r.quiet[0],r.quiet[1]).implies({silent:!0})).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.lock[0],r.lock[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.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??``).addOption(new c.Option(r.quiet[0],r.quiet[1]).implies({silent:!0})).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.lock[0],r.lock[1])).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 i=c.program.command(`${t.baseCommand}:${e.name}`).description(e.description||``).addOption(new c.Option(r.quiet[0],r.quiet[1]).implies({silent:!0})).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.lock[0],r.lock[1])).action(async()=>{n.setInput(i.opts(),i.args,i.registeredArguments,e,c.program),await n.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.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)=>{t.name()!==`fire`&&await(0,f.build)({...T,watch:!1,plugins:[]})}),c.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.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();
|
package/bin/fire.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./zero-Ddh7ucIS.js";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,TaskManager as o}from"@h3ravel/shared";import{execa as s}from"execa";import c from"preferred-pm";import{glob as l,mkdir as u,readFile as d,rm as f,writeFile as p}from"node:fs/promises";import{
|
|
2
|
+
import"./zero-Ddh7ucIS.js";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,TaskManager as o}from"@h3ravel/shared";import{execa as s}from"execa";import c from"preferred-pm";import{glob as l,mkdir as u,readFile as d,rm as f,writeFile as p}from"node:fs/promises";import{Str as m}from"@h3ravel/support";import h from"node:path";import{Option as g,program as _}from"commander";import{existsSync as v}from"node:fs";import{fork as y}from"child_process";import{dirname as b,join as x,resolve as S}from"path";import{build as C}from"tsdown";var w=class extends t{signature=`build:
|
|
3
3
|
{--m|minify=false : Minify your bundle output}
|
|
4
4
|
`;description=`Build the app for production`;async handle(){try{await this.fire()}catch(e){a.error(e)}}async fire(){let e=env(`DIST_DIR`,`dist`),t=(await c(base_path()))?.name??`pnpm`,n=this.option(`minify`),r={EXTENDED_DEBUG:Number(this.option(`verbose`,0))>0?`true`:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:e,DIST_MINIFY:n,LOG_LEVEL:[`silent`,`info`,`warn`,`error`][Number(this.option(`verbose`,0))]},i=r.LOG_LEVEL===`silent`?`--silent`:null;a.log([[`
|
|
5
|
-
INFO `,`bgBlue`],[` Creating Production Bundle`,`white`]],``),console.log(``),await o.taskRunner(a.log([[` SUCCESS `,`bgGreen`],[` Production Bundle Created`,`white`]],``,!1),async()=>{await s(t,[`tsdown`,i,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:base_path(),env:Object.assign({},process.env,r)}),console.log(``)})}},
|
|
5
|
+
INFO `,`bgBlue`],[` Creating Production Bundle`,`white`]],``),console.log(``),await o.taskRunner(a.log([[` SUCCESS `,`bgGreen`],[` Production Bundle Created`,`white`]],``,!1),async()=>{await s(t,[`tsdown`,i,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:base_path(),env:Object.assign({},process.env,r)}),console.log(``)})}},T=class extends t{};String.raw`
|
|
6
6
|
111
|
|
7
7
|
111111111
|
|
8
8
|
1111111111 111111
|
|
@@ -24,19 +24,19 @@ import"./zero-Ddh7ucIS.js";import"tsx/esm";import{Application as e,ConsoleComman
|
|
|
24
24
|
111111 111 111111
|
|
25
25
|
111111111
|
|
26
26
|
110
|
|
27
|
-
`;const
|
|
27
|
+
`;const E=String.raw`
|
|
28
28
|
_ _ _____ _
|
|
29
29
|
| | | |___ / _ __ __ ___ _____| |
|
|
30
30
|
| |_| | |_ \| '__/ _ \ \ / / _ \ |
|
|
31
31
|
| _ |___) | | | (_| |\ V / __/ |
|
|
32
32
|
|_| |_|____/|_| \__,_| \_/ \___|_|
|
|
33
33
|
|
|
34
|
-
`;var
|
|
34
|
+
`;var D=class extends T{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(`
|
|
35
35
|
`)].join(`
|
|
36
|
-
`)});a.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(
|
|
36
|
+
`)});a.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(E),console.log(``),a.log(`Usage:`,`yellow`),a.log(` command [options] [arguments]`,`white`),console.log(``),a.log(`Options:`,`yellow`),console.log(e.join(`
|
|
37
37
|
`).trim()),console.log(``),a.log(`Available Commands:`,`yellow`),console.log(n.join(`
|
|
38
38
|
|
|
39
|
-
`).trim())}},
|
|
39
|
+
`).trim())}},O=class extends T{signature=`#make:
|
|
40
40
|
{controller : Create a new controller class.
|
|
41
41
|
| {--a|api : Exclude the create and edit methods from the controller}
|
|
42
42
|
| {--m|model= : Generate a resource controller for the given model}
|
|
@@ -47,31 +47,13 @@ import"./zero-Ddh7ucIS.js";import"tsx/esm";import{Application as e,ConsoleComman
|
|
|
47
47
|
| {--c|collection : Create a resource collection}
|
|
48
48
|
| {--force : Create the resource even if it already exists}
|
|
49
49
|
}
|
|
50
|
-
{migration : Generates a new database migration class.
|
|
51
|
-
| {--l|type=ts : The file type to generate}
|
|
52
|
-
| {--t|table : The table to migrate}
|
|
53
|
-
| {--c|create : The table to be created}
|
|
54
|
-
}
|
|
55
50
|
{command : Create a new Musket command.
|
|
56
51
|
| {--command : The terminal command that will be used to invoke the class}
|
|
57
52
|
| {--force : Create the class even if the console command already exists}
|
|
58
53
|
}
|
|
59
|
-
{factory : Create a new model factory.}
|
|
60
|
-
{seeder : Create a new seeder class.}
|
|
61
54
|
{view : Create a new view.
|
|
62
55
|
| {--force : Create the view even if it already exists}
|
|
63
56
|
}
|
|
64
|
-
{model : Create a new Eloquent model class.
|
|
65
|
-
| {--api : Indicates if the generated controller should be an API resource controller}
|
|
66
|
-
| {--c|controller : Create a new controller for the model}
|
|
67
|
-
| {--f|factory : Create a new factory for the model}
|
|
68
|
-
| {--m|migration : Create a new migration file for the model}
|
|
69
|
-
| {--r|resource : Indicates if the generated controller should be a resource controller}
|
|
70
|
-
| {--a|all : Generate a migration, seeder, factory, policy, resource controller, and form request classes for the model}
|
|
71
|
-
| {--s|seed : Create a new seeder for the model}
|
|
72
|
-
| {--t|type=ts : The file type to generate}
|
|
73
|
-
| {--force : Create the model even if it already exists}
|
|
74
|
-
}
|
|
75
57
|
{^name : The name of the [name] to generate}
|
|
76
|
-
`;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`,
|
|
77
|
-
`).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
|
|
58
|
+
`;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=i.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,o=h.join(r,`dist/stubs/controller${e}.stub`),s=app_path(`Http/Controllers/${t}.ts`);t.includes(`/`)&&await u(m.beforeLast(s,`/`),{recursive:!0}),!n&&await i.fileExists(s)&&a.error(`ERORR: ${t} controller already exists`);let c=await d(o,`utf-8`);c=c.replace(/{{ name }}/g,t),await p(s,c),a.split(`INFO: Controller Created`,a.log(h.basename(s),`gray`,!1))}makeResource(){a.success(`Resource support is not yet available`)}makeCommand(){a.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 u(m.beforeLast(n,`/`),{recursive:!0}),!t&&await i.fileExists(n)&&a.error(`ERORR: ${e} view already exists`),await p(n,`{{-- src/resources/views/${e}.edge --}}`),a.split(`INFO: View Created`,a.log(`src/resources/views/${e}.edge`,`gray`,!1))}},k=class extends T{signature=`postinstall`;description=`Default post installation command`;async handle(){this.createSqliteDB()}async createSqliteDB(){config(`database.default`)===`sqlite`&&(await i.fileExists(database_path())||await u(database_path(),{recursive:!0}),await i.fileExists(database_path(`db.sqlite`))||await p(database_path(`db.sqlite`),``))}},A=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(`
|
|
59
|
+
`).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 j(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=S(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=y(x(e,t),r,o)},c=e.dir||b(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 M=process.env.NODE_ENV||`development`;let N=M===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(N=process.env.DIST_DIR);var P={outDir:N,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:M===`development`,minify:!!process.env.DIST_MINIFY,external:[/^@h3ravel\/.*/gi],clean:!0,shims:!0,copy:[{from:`public`,to:N},`src/resources`,`src/database`],env:M===`development`?{NODE_ENV:M,DIST_DIR:N}:{},watch:M===`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];v(h.join(N,n))&&await f(h.join(N,n),{recursive:!0})}})},plugins:M===`development`&&process.env.CLI_BUILD!==`true`?[j({env:Object.assign({},process.env,{NODE_ENV:M,DIST_DIR:N}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]},F=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new O(this.app,this.kernel),new D(this.app,this.kernel),new k(this.app,this.kernel),new w(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 l(n)){let n=h.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(A.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`]};_.name(`musket`).version(`${e}\n${t}`).description(E).addOption(new g(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new g(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new g(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new g(n.lock[0],n.lock[1])).action(async()=>{let e=new D(this.app,this.kernel);e.setInput(_.opts(),_.args,_.registeredArguments,{},_),e.handle()}),_.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?_:_.command(t.baseCommand).description(t.description??``).addOption(new g(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new g(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new g(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new g(n.lock[0],n.lock[1])).action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,_),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=_.command(`${t.baseCommand}:${e.name}`).description(e.description||``).addOption(new g(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new g(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new g(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new g(n.lock[0],n.lock[1])).action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,e,_),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=_.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,_),await r.handle()})}}return _.hook(`preAction`,async(e,t)=>{t.name()!==`fire`&&await C({...P,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()}},I=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 F.parse(this),process.exit(0)}async loadRequirements(){this.cwd=h.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(h.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(h.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},L=class extends r{static priority=992;static runsInConsole=!0;runsInConsole=!0;register(){}boot(){I.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}};new class{async fire(){let t=process.env.DIST_DIR??`/.h3ravel/serve/`,n=[],r=new e(process.cwd()),i=base_path(h.join(t,`bootstrap/providers.js`));n.push(...(await import(i)).default),n.push(L),await r.quickStartup(n,[`CoreServiceProvider`])}}().fire();export{};
|
package/dist/index.cjs
CHANGED
|
@@ -21,7 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_Utils = require('./Utils-D6ZDNdVG.cjs');
|
|
25
24
|
let __h3ravel_shared = require("@h3ravel/shared");
|
|
26
25
|
__h3ravel_shared = __toESM(__h3ravel_shared);
|
|
27
26
|
let __h3ravel_core = require("@h3ravel/core");
|
|
@@ -34,8 +33,6 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
34
33
|
node_fs_promises = __toESM(node_fs_promises);
|
|
35
34
|
let __h3ravel_support = require("@h3ravel/support");
|
|
36
35
|
__h3ravel_support = __toESM(__h3ravel_support);
|
|
37
|
-
let dayjs = require("dayjs");
|
|
38
|
-
dayjs = __toESM(dayjs);
|
|
39
36
|
let node_path = require("node:path");
|
|
40
37
|
node_path = __toESM(node_path);
|
|
41
38
|
let commander = require("commander");
|
|
@@ -224,31 +221,13 @@ var MakeCommand = class extends Command {
|
|
|
224
221
|
| {--c|collection : Create a resource collection}
|
|
225
222
|
| {--force : Create the resource even if it already exists}
|
|
226
223
|
}
|
|
227
|
-
{migration : Generates a new database migration class.
|
|
228
|
-
| {--l|type=ts : The file type to generate}
|
|
229
|
-
| {--t|table : The table to migrate}
|
|
230
|
-
| {--c|create : The table to be created}
|
|
231
|
-
}
|
|
232
224
|
{command : Create a new Musket command.
|
|
233
225
|
| {--command : The terminal command that will be used to invoke the class}
|
|
234
226
|
| {--force : Create the class even if the console command already exists}
|
|
235
227
|
}
|
|
236
|
-
{factory : Create a new model factory.}
|
|
237
|
-
{seeder : Create a new seeder class.}
|
|
238
228
|
{view : Create a new view.
|
|
239
229
|
| {--force : Create the view even if it already exists}
|
|
240
230
|
}
|
|
241
|
-
{model : Create a new Eloquent model class.
|
|
242
|
-
| {--api : Indicates if the generated controller should be an API resource controller}
|
|
243
|
-
| {--c|controller : Create a new controller for the model}
|
|
244
|
-
| {--f|factory : Create a new factory for the model}
|
|
245
|
-
| {--m|migration : Create a new migration file for the model}
|
|
246
|
-
| {--r|resource : Indicates if the generated controller should be a resource controller}
|
|
247
|
-
| {--a|all : Generate a migration, seeder, factory, policy, resource controller, and form request classes for the model}
|
|
248
|
-
| {--s|seed : Create a new seeder for the model}
|
|
249
|
-
| {--t|type=ts : The file type to generate}
|
|
250
|
-
| {--force : Create the model even if it already exists}
|
|
251
|
-
}
|
|
252
231
|
{^name : The name of the [name] to generate}
|
|
253
232
|
`;
|
|
254
233
|
/**
|
|
@@ -263,10 +242,6 @@ var MakeCommand = class extends Command {
|
|
|
263
242
|
await this[{
|
|
264
243
|
controller: "makeController",
|
|
265
244
|
resource: "makeResource",
|
|
266
|
-
migration: "makeMigration",
|
|
267
|
-
factory: "makeFactory",
|
|
268
|
-
seeder: "makeSeeder",
|
|
269
|
-
model: "makeModel",
|
|
270
245
|
view: "makeView",
|
|
271
246
|
command: "makeCommand"
|
|
272
247
|
}[command]]();
|
|
@@ -282,7 +257,7 @@ var MakeCommand = class extends Command {
|
|
|
282
257
|
const stubPath = node_path.default.join(crtlrPath, `dist/stubs/controller${type}.stub`);
|
|
283
258
|
const path$6 = app_path(`Http/Controllers/${name}.ts`);
|
|
284
259
|
/** The Controller is scoped to a path make sure to create the associated directories */
|
|
285
|
-
if (name.includes("/")) await (0, node_fs_promises.mkdir)(
|
|
260
|
+
if (name.includes("/")) await (0, node_fs_promises.mkdir)(__h3ravel_support.Str.beforeLast(path$6, "/"), { recursive: true });
|
|
286
261
|
/** Check if the controller already exists */
|
|
287
262
|
if (!force && await __h3ravel_shared.FileSystem.fileExists(path$6)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
|
|
288
263
|
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
@@ -294,70 +269,12 @@ var MakeCommand = class extends Command {
|
|
|
294
269
|
__h3ravel_shared.Logger.success("Resource support is not yet available");
|
|
295
270
|
}
|
|
296
271
|
/**
|
|
297
|
-
* Generate a new database migration class
|
|
298
|
-
*/
|
|
299
|
-
async makeMigration() {
|
|
300
|
-
const name = this.argument("name");
|
|
301
|
-
const datePrefix = (0, dayjs.default)().format("YYYY_MM_DD_HHmmss");
|
|
302
|
-
const path$6 = database_path(`migrations/${datePrefix}_${name}.ts`);
|
|
303
|
-
const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
|
|
304
|
-
let create = this.option("create", false);
|
|
305
|
-
let table = this.option("table");
|
|
306
|
-
if (!table && typeof create === "string") {
|
|
307
|
-
table = create;
|
|
308
|
-
create = true;
|
|
309
|
-
}
|
|
310
|
-
if (!table) {
|
|
311
|
-
const guessed = require_Utils.TableGuesser.guess(name);
|
|
312
|
-
table = guessed[0];
|
|
313
|
-
create = !!guessed[1];
|
|
314
|
-
}
|
|
315
|
-
const stubPath = node_path.default.join(crtlrPath, this.getMigrationStubName(table, create));
|
|
316
|
-
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
317
|
-
if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
|
|
318
|
-
__h3ravel_shared.Logger.info("INFO: Creating Migration");
|
|
319
|
-
await this.kernel.ensureDirectoryExists(node_path.default.dirname(path$6));
|
|
320
|
-
await (0, node_fs_promises.writeFile)(path$6, stub);
|
|
321
|
-
__h3ravel_shared.Logger.split("INFO: Migration Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$6), "gray", false));
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Create a new model factory
|
|
325
|
-
*/
|
|
326
|
-
makeFactory() {
|
|
327
|
-
__h3ravel_shared.Logger.success("Factory support is not yet available");
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
272
|
* Create a new Musket command
|
|
331
273
|
*/
|
|
332
274
|
makeCommand() {
|
|
333
275
|
__h3ravel_shared.Logger.success("Musket command creation is not yet available");
|
|
334
276
|
}
|
|
335
277
|
/**
|
|
336
|
-
* Create a new seeder class
|
|
337
|
-
*/
|
|
338
|
-
makeSeeder() {
|
|
339
|
-
__h3ravel_shared.Logger.success("Seeder support is not yet available");
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Generate a new Arquebus model class
|
|
343
|
-
*/
|
|
344
|
-
async makeModel() {
|
|
345
|
-
const type = this.option("type", "ts");
|
|
346
|
-
const name = this.argument("name");
|
|
347
|
-
const force = this.option("force");
|
|
348
|
-
const path$6 = app_path(`Models/${name.toLowerCase()}.${type}`);
|
|
349
|
-
/** The model is scoped to a path make sure to create the associated directories */
|
|
350
|
-
if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$6, "/"), { recursive: true });
|
|
351
|
-
/** Check if the model already exists */
|
|
352
|
-
if (!force && await __h3ravel_shared.FileSystem.fileExists(path$6)) __h3ravel_shared.Logger.error(`ERORR: ${name} model already exists`);
|
|
353
|
-
const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
|
|
354
|
-
const stubPath = node_path.default.join(crtlrPath, `dist/stubs/model-${type}.stub`);
|
|
355
|
-
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
356
|
-
stub = stub.replace(/{{ name }}/g, name);
|
|
357
|
-
await (0, node_fs_promises.writeFile)(path$6, stub);
|
|
358
|
-
__h3ravel_shared.Logger.split(`INFO: ${name} Model Created`, __h3ravel_shared.Logger.log(node_path.default.basename(path$6), "gray", false));
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
278
|
* Create a new view.
|
|
362
279
|
*/
|
|
363
280
|
async makeView() {
|
|
@@ -365,27 +282,12 @@ var MakeCommand = class extends Command {
|
|
|
365
282
|
const force = this.option("force");
|
|
366
283
|
const path$6 = base_path(`src/resources/views/${name}.edge`);
|
|
367
284
|
/** The view is scoped to a path make sure to create the associated directories */
|
|
368
|
-
if (name.includes("/")) await (0, node_fs_promises.mkdir)(
|
|
285
|
+
if (name.includes("/")) await (0, node_fs_promises.mkdir)(__h3ravel_support.Str.beforeLast(path$6, "/"), { recursive: true });
|
|
369
286
|
/** Check if the view already exists */
|
|
370
287
|
if (!force && await __h3ravel_shared.FileSystem.fileExists(path$6)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
|
|
371
288
|
await (0, node_fs_promises.writeFile)(path$6, `{{-- src/resources/views/${name}.edge --}}`);
|
|
372
289
|
__h3ravel_shared.Logger.split("INFO: View Created", __h3ravel_shared.Logger.log(`src/resources/views/${name}.edge`, "gray", false));
|
|
373
290
|
}
|
|
374
|
-
/**
|
|
375
|
-
* Ge the database migration file name
|
|
376
|
-
*
|
|
377
|
-
* @param table
|
|
378
|
-
* @param create
|
|
379
|
-
* @param type
|
|
380
|
-
* @returns
|
|
381
|
-
*/
|
|
382
|
-
getMigrationStubName(table, create = false, type = "ts") {
|
|
383
|
-
let stub;
|
|
384
|
-
if (!table) stub = `migration-${type}.stub`;
|
|
385
|
-
else if (create) stub = `migration.create-${type}.stub`;
|
|
386
|
-
else stub = `migration.update-${type}.stub`;
|
|
387
|
-
return "dist/stubs/" + stub;
|
|
388
|
-
}
|
|
389
291
|
};
|
|
390
292
|
|
|
391
293
|
//#endregion
|
|
@@ -479,6 +381,7 @@ var Signature = class Signature {
|
|
|
479
381
|
let name = namePart;
|
|
480
382
|
let required = /[^a-zA-Z0-9_|-]/.test(name);
|
|
481
383
|
let multiple = false;
|
|
384
|
+
let placeholder;
|
|
482
385
|
if (name.endsWith("?*")) {
|
|
483
386
|
required = false;
|
|
484
387
|
multiple = true;
|
|
@@ -489,6 +392,7 @@ var Signature = class Signature {
|
|
|
489
392
|
} else if (name.endsWith("?")) {
|
|
490
393
|
required = false;
|
|
491
394
|
name = name.slice(0, -1);
|
|
395
|
+
placeholder = `[${name.split("--").at(1)?.split("|").at(1) ?? name}]`;
|
|
492
396
|
}
|
|
493
397
|
/**
|
|
494
398
|
* Check if it's a flag option (starts with --)
|
|
@@ -526,6 +430,7 @@ var Signature = class Signature {
|
|
|
526
430
|
shared,
|
|
527
431
|
isFlag,
|
|
528
432
|
isHidden,
|
|
433
|
+
placeholder,
|
|
529
434
|
defaultValue,
|
|
530
435
|
nestedOptions
|
|
531
436
|
});
|
|
@@ -583,7 +488,7 @@ var Signature = class Signature {
|
|
|
583
488
|
};
|
|
584
489
|
|
|
585
490
|
//#endregion
|
|
586
|
-
//#region ../../node_modules/.pnpm/@rollup+plugin-run@3.1.
|
|
491
|
+
//#region ../../node_modules/.pnpm/@rollup+plugin-run@3.1.0_rollup@4.52.3/node_modules/@rollup/plugin-run/dist/es/index.js
|
|
587
492
|
function run(opts = {}) {
|
|
588
493
|
let input;
|
|
589
494
|
let proc;
|
|
@@ -843,9 +748,16 @@ var Musket = class Musket {
|
|
|
843
748
|
const description = opt.description?.replace(/\[(\w+)\]/g, (_, k) => parent?.[k] ?? `[${k}]`) ?? "";
|
|
844
749
|
const type = opt.name.replaceAll("-", "");
|
|
845
750
|
if (opt.isFlag) if (parse) {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
751
|
+
let flags = opt.flags?.map((f) => f.length === 1 ? `-${f}` : `--${f.replace(/^-+/, "")}`).join(", ") ?? void 0;
|
|
752
|
+
if (opt.required && !opt.placeholder) flags += ` <${type}>`;
|
|
753
|
+
else if (opt.placeholder) flags += " " + opt.placeholder;
|
|
754
|
+
cmd.option(flags || "", description, opt.defaultValue);
|
|
755
|
+
} else {
|
|
756
|
+
let flags = opt.flags?.join(", ") ?? "";
|
|
757
|
+
if (opt.required && !opt.placeholder) flags += ` <${type}>`;
|
|
758
|
+
else if (opt.placeholder) flags += " " + opt.placeholder;
|
|
759
|
+
cmd.option(flags, description, opt.defaultValue);
|
|
760
|
+
}
|
|
849
761
|
else cmd.argument(opt.required ? `<${opt.name}>` : `[${opt.name}]`, description, opt.defaultValue);
|
|
850
762
|
}
|
|
851
763
|
static async parse(kernel) {
|
|
@@ -902,8 +814,8 @@ var ConsoleServiceProvider = class extends __h3ravel_core.ServiceProvider {
|
|
|
902
814
|
/**
|
|
903
815
|
* Indicate that this service provider only runs in console
|
|
904
816
|
*/
|
|
905
|
-
static
|
|
906
|
-
|
|
817
|
+
static runsInConsole = true;
|
|
818
|
+
runsInConsole = true;
|
|
907
819
|
register() {}
|
|
908
820
|
boot() {
|
|
909
821
|
Kernel.init(this.app);
|
|
@@ -926,9 +838,7 @@ exports.MakeCommand = MakeCommand;
|
|
|
926
838
|
exports.Musket = Musket;
|
|
927
839
|
exports.PostinstallCommand = PostinstallCommand;
|
|
928
840
|
exports.Signature = Signature;
|
|
929
|
-
exports.TableGuesser = require_Utils.TableGuesser;
|
|
930
841
|
exports.TsDownConfig = TsDownConfig;
|
|
931
|
-
exports.Utils = require_Utils.Utils;
|
|
932
842
|
exports.altLogo = altLogo;
|
|
933
843
|
exports.logo = logo;
|
|
934
844
|
//# sourceMappingURL=index.cjs.map
|