@h3ravel/console 11.9.1 → 11.10.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/README.md +1 -1
- package/bin/fire.cjs +3 -37
- package/bin/fire.js +3 -37
- package/dist/index.cjs +64 -602
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -151
- package/dist/index.d.ts +4 -151
- package/dist/index.js +53 -587
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<a href="https://h3ravel.toneflix.net" target="_blank">
|
|
3
3
|
<img src="https://raw.githubusercontent.com/h3ravel/assets/refs/heads/main/logo-full.svg" width="200" alt="H3ravel Logo">
|
|
4
4
|
</a>
|
|
5
|
-
<h1 align="center"><a href="https://h3ravel.toneflix.net/
|
|
5
|
+
<h1 align="center"><a href="https://h3ravel.toneflix.net/guide/deeper/musket">H3ravel Console</a></h1>
|
|
6
6
|
|
|
7
7
|
[![Framework][ix]][lx]
|
|
8
8
|
[![Console Package Version][i1]][l1]
|
package/bin/fire.cjs
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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(`
|
|
3
|
-
{--m|minify : Minify your bundle output}
|
|
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{},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`
|
|
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(`@h3ravel/musket`);r=e.__toESM(r);let i=require(`execa`);i=e.__toESM(i);let a=require(`preferred-pm`);a=e.__toESM(a);let o=require(`node:fs/promises`);o=e.__toESM(o),require(`@h3ravel/support`);let s=require(`node:path`);s=e.__toESM(s);let c=require(`node:fs`);c=e.__toESM(c);let l=require(`child_process`);l=e.__toESM(l);let u=require(`path`);u=e.__toESM(u);const d=String.raw`
|
|
9
3
|
111
|
|
10
4
|
111111111
|
|
11
5
|
1111111111 111111
|
|
@@ -27,39 +21,11 @@ const e=require(`./zero-Ce9OzYZl.cjs`);require(`tsx/esm`);let t=require(`@h3rave
|
|
|
27
21
|
111111 111 111111
|
|
28
22
|
111111111
|
|
29
23
|
110
|
|
30
|
-
`,
|
|
24
|
+
`,f=String.raw`
|
|
31
25
|
_ _ _____ _
|
|
32
26
|
| | | |___ / _ __ __ ___ _____| |
|
|
33
27
|
| |_| | |_ \| '__/ _ \ \ / / _ \ |
|
|
34
28
|
| _ |___) | | | (_| |\ V / __/ |
|
|
35
29
|
|_| |_|____/|_| \__,_| \_/ \___|_|
|
|
36
30
|
|
|
37
|
-
`;
|
|
38
|
-
`).trim()),console.log(``),n.Logger.log(`Available Commands:`,`yellow`),console.log(i.join(`
|
|
39
|
-
|
|
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(`
|
|
41
|
-
`)].join(`
|
|
42
|
-
`);return t&&(a+=`
|
|
43
|
-
`),a})}},y=class extends m{signature=`#make:
|
|
44
|
-
{controller : Create a new controller class.
|
|
45
|
-
| {--a|api : Exclude the create and edit methods from the controller}
|
|
46
|
-
| {--m|model= : Generate a resource controller for the given model}
|
|
47
|
-
| {--r|resource : Generate a resource controller class}
|
|
48
|
-
| {--force : Create the controller even if it already exists}
|
|
49
|
-
}
|
|
50
|
-
{resource : Create a new resource.
|
|
51
|
-
| {--c|collection : Create a resource collection}
|
|
52
|
-
| {--force : Create the resource even if it already exists}
|
|
53
|
-
}
|
|
54
|
-
{command : Create a new Musket command.
|
|
55
|
-
| {--command : The terminal command that will be used to invoke the class}
|
|
56
|
-
| {--force : Create the class even if the console command already exists}
|
|
57
|
-
}
|
|
58
|
-
{view : Create a new view.
|
|
59
|
-
| {--force : Create the view even if it already exists}
|
|
60
|
-
}
|
|
61
|
-
{^name : The name of the [name] to generate}
|
|
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(`
|
|
64
|
-
`+e+`
|
|
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();
|
|
31
|
+
`;function p(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,u.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,l.fork)((0,u.join)(e,t),r,o)},c=e.dir||(0,u.dirname)(e.file),d=Object.keys(a).find(e=>{let n=a[e];return n.isEntry&&n.facadeModuleId===t});d?(s(c,d),i&&(process.stdin.resume(),process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{let t=e.toString().trim().toLowerCase();t===`rs`||t===`restart`||e.toString().charCodeAt(0)===11?s(c,d):(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 h=m===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(h=process.env.DIST_DIR);const g={outDir:h,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:h},`src/resources`,`src/database`],env:m===`development`?{NODE_ENV:m,DIST_DIR:h}:{},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];(0,c.existsSync)(s.default.join(h,n))&&await(0,o.rm)(s.default.join(h,n),{recursive:!0})}})},plugins:m===`development`&&process.env.CLI_BUILD!==`true`?[p({env:Object.assign({},process.env,{NODE_ENV:m,DIST_DIR:h}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]};var _=g,v=class extends t.ServiceProvider{static priority=992;static runsInConsole=!0;runsInConsole=!0;register(){}boot(){let e=`/${env(`DIST_DIR`,`.h3ravel/serve`)}/`.replaceAll(`//`,``);r.Kernel.init(this.app,{logo:f,resolver:new t.ContainerResolver(this.app).resolveMethodParams,tsDownConfig:_,packages:[{name:`@h3ravel/core`,alias:`H3ravel Framework`},{name:`@h3ravel/musket`,alias:`Musket CLI`}],cliName:`musket`,hideMusketInfo:!0,discoveryPaths:[app_path(`Console/Commands/*.js`).replace(`/src/`,e)]}),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}},y=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(v),await r.quickStartup(n,[`CoreServiceProvider`])}};new y().fire();
|
package/bin/fire.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./zero-BGMatB6V.js";import
|
|
3
|
-
{--m|minify : Minify your bundle output}
|
|
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){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`
|
|
2
|
+
import"./zero-BGMatB6V.js";import"tsx/esm";import{Application as e,ContainerResolver as t,ServiceProvider as n}from"@h3ravel/core";import{FileSystem as r}from"@h3ravel/shared";import{Kernel as i}from"@h3ravel/musket";import{execa as a}from"execa";import o from"preferred-pm";import{mkdir as s,rm as c,writeFile as l}from"node:fs/promises";import"@h3ravel/support";import u from"node:path";import{existsSync as d}from"node:fs";import{fork as f}from"child_process";import{dirname as p,join as m,resolve as h}from"path";String.raw`
|
|
9
3
|
111
|
|
10
4
|
111111111
|
|
11
5
|
1111111111 111111
|
|
@@ -27,39 +21,11 @@ import"./zero-BGMatB6V.js";import{createRequire as e}from"node:module";import"ts
|
|
|
27
21
|
111111 111 111111
|
|
28
22
|
111111111
|
|
29
23
|
110
|
|
30
|
-
`;const
|
|
24
|
+
`;const g=String.raw`
|
|
31
25
|
_ _ _____ _
|
|
32
26
|
| | | |___ / _ __ __ ___ _____| |
|
|
33
27
|
| |_| | |_ \| '__/ _ \ \ / / _ \ |
|
|
34
28
|
| _ |___) | | | (_| |\ V / __/ |
|
|
35
29
|
|_| |_|____/|_| \__,_| \_/ \___|_|
|
|
36
30
|
|
|
37
|
-
`;
|
|
38
|
-
`).trim()),console.log(``),s.log(`Available Commands:`,`yellow`),console.log(r.join(`
|
|
39
|
-
|
|
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(`
|
|
41
|
-
`)].join(`
|
|
42
|
-
`);return t&&(i+=`
|
|
43
|
-
`),i})}},N=class extends k{signature=`#make:
|
|
44
|
-
{controller : Create a new controller class.
|
|
45
|
-
| {--a|api : Exclude the create and edit methods from the controller}
|
|
46
|
-
| {--m|model= : Generate a resource controller for the given model}
|
|
47
|
-
| {--r|resource : Generate a resource controller class}
|
|
48
|
-
| {--force : Create the controller even if it already exists}
|
|
49
|
-
}
|
|
50
|
-
{resource : Create a new resource.
|
|
51
|
-
| {--c|collection : Create a resource collection}
|
|
52
|
-
| {--force : Create the resource even if it already exists}
|
|
53
|
-
}
|
|
54
|
-
{command : Create a new Musket command.
|
|
55
|
-
| {--command : The terminal command that will be used to invoke the class}
|
|
56
|
-
| {--force : Create the class even if the console command already exists}
|
|
57
|
-
}
|
|
58
|
-
{view : Create a new view.
|
|
59
|
-
| {--force : Create the view even if it already exists}
|
|
60
|
-
}
|
|
61
|
-
{^name : The name of the [name] to generate}
|
|
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(`
|
|
64
|
-
`+e+`
|
|
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{};
|
|
31
|
+
`;function _(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=h(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=f(m(e,t),r,o)},c=e.dir||p(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 v=process.env.NODE_ENV||`development`;let y=v===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(y=process.env.DIST_DIR);var b={outDir:y,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:v===`development`,minify:!!process.env.DIST_MINIFY,external:[/^@h3ravel\/.*/gi],clean:!0,shims:!0,copy:[{from:`public`,to:y},`src/resources`,`src/database`],env:v===`development`?{NODE_ENV:v,DIST_DIR:y}:{},watch:v===`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];d(u.join(y,n))&&await c(u.join(y,n),{recursive:!0})}})},plugins:v===`development`&&process.env.CLI_BUILD!==`true`?[_({env:Object.assign({},process.env,{NODE_ENV:v,DIST_DIR:y}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]},x=class extends n{static priority=992;static runsInConsole=!0;runsInConsole=!0;register(){}boot(){let e=`/${env(`DIST_DIR`,`.h3ravel/serve`)}/`.replaceAll(`//`,``);i.init(this.app,{logo:g,resolver:new t(this.app).resolveMethodParams,tsDownConfig:b,packages:[{name:`@h3ravel/core`,alias:`H3ravel Framework`},{name:`@h3ravel/musket`,alias:`Musket CLI`}],cliName:`musket`,hideMusketInfo:!0,discoveryPaths:[app_path(`Console/Commands/*.js`).replace(`/src/`,e)]}),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(u.join(t,`bootstrap/providers.js`));n.push(...(await import(i)).default),n.push(x),await r.quickStartup(n,[`CoreServiceProvider`])}}().fire();export{};
|