@h3ravel/console 11.5.2 → 11.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/fire.cjs CHANGED
@@ -1,2 +1,77 @@
1
1
  #!/usr/bin/env node
2
- const e=require(`./app-PHgmg_5L.cjs`);require(`tsx/esm`),new e.app_default().fire();
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(`dayjs`);s=e.__toESM(s);let c=require(`node:path`);c=e.__toESM(c);let l=require(`commander`);l=e.__toESM(l);let u=require(`node:fs`);u=e.__toESM(u);let d=require(`child_process`);d=e.__toESM(d);let f=require(`path`);f=e.__toESM(f);let p=require(`tsdown`);p=e.__toESM(p);var m=class extends t.ConsoleCommand{signature=`build:
3
+ {--m|minify=false : Minify your bundle output}
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(``)})}},h=class extends t.ConsoleCommand{};const g=String.raw`
6
+ 111
7
+ 111111111
8
+ 1111111111 111111
9
+ 111111 111 111111
10
+ 111111 111 111111
11
+ 11111 111 11111
12
+ 1111111 111 1111111
13
+ 111 11111 111 111111 111 1111 1111 11111111 1111
14
+ 111 11111 1111 111111 111 1111 1111 1111 11111 1111
15
+ 111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
16
+ 111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
17
+ 111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
18
+ 111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
19
+ 111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
20
+ 1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
21
+ 11011 111111 11 11111
22
+ 111111 11101 111111
23
+ 111111 111 111111
24
+ 111111 111 111111
25
+ 111111111
26
+ 110
27
+ `,_=String.raw`
28
+ _ _ _____ _
29
+ | | | |___ / _ __ __ ___ _____| |
30
+ | |_| | |_ \| '__/ _ \ \ / / _ \ |
31
+ | _ |___) | | | (_| |\ V / __/ |
32
+ |_| |_|____/|_| \__,_| \_/ \___|_|
33
+
34
+ `;var v=class extends h{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
+ `)].join(`
36
+ `)});n.Logger.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(_),console.log(``),n.Logger.log(`Usage:`,`yellow`),n.Logger.log(` command [options] [arguments]`,`white`),console.log(``),n.Logger.log(`Options:`,`yellow`),console.log(e.join(`
37
+ `).trim()),console.log(``),n.Logger.log(`Available Commands:`,`yellow`),console.log(r.join(`
38
+
39
+ `).trim())}},y=class e{static CREATE_PATTERNS=[/^create_(\w+)_table$/,/^create_(\w+)$/];static CHANGE_PATTERNS=[/.+_(to|from|in)_(\w+)_table$/,/.+_(to|from|in)_(\w+)$/];static guess(t){for(let n of e.CREATE_PATTERNS){let e=t.match(n);if(e)return[e[1],!0]}for(let n of e.CHANGE_PATTERNS){let e=t.match(n);if(e)return[e[2],!1]}return[]}},b=class extends h{signature=`#make:
40
+ {controller : Create a new controller class.
41
+ | {--a|api : Exclude the create and edit methods from the controller}
42
+ | {--m|model= : Generate a resource controller for the given model}
43
+ | {--r|resource : Generate a resource controller class}
44
+ | {--force : Create the controller even if it already exists}
45
+ }
46
+ {resource : Create a new resource.
47
+ | {--c|collection : Create a resource collection}
48
+ | {--force : Create the resource even if it already exists}
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
+ {command : Create a new Musket command.
56
+ | {--command : The terminal command that will be used to invoke the class}
57
+ | {--force : Create the class even if the console command already exists}
58
+ }
59
+ {factory : Create a new model factory.}
60
+ {seeder : Create a new seeder class.}
61
+ {view : Create a new view.
62
+ | {--force : Create the view even if it already exists}
63
+ }
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
+ {^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`,migration:`makeMigration`,factory:`makeFactory`,seeder:`makeSeeder`,model:`makeModel`,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)??``,s=c.default.join(i,`dist/stubs/controller${e}.stub`),l=app_path(`Http/Controllers/${t}.ts`);t.includes(`/`)&&await(0,a.mkdir)((0,o.beforeLast)(l,`/`),{recursive:!0}),!r&&await n.FileSystem.fileExists(l)&&n.Logger.error(`ERORR: ${t} controller already exists`);let u=await(0,a.readFile)(s,`utf-8`);u=u.replace(/{{ name }}/g,t),await(0,a.writeFile)(l,u),n.Logger.split(`INFO: Controller Created`,n.Logger.log(c.default.basename(l),`gray`,!1))}makeResource(){n.Logger.success(`Resource support is not yet available`)}async makeMigration(){let e=this.argument(`name`),t=(0,s.default)().format(`YYYY_MM_DD_HHmmss`),r=database_path(`migrations/${t}_${e}.ts`),i=n.FileSystem.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,o=this.option(`create`,!1),l=this.option(`table`);if(!l&&typeof o==`string`&&(l=o,o=!0),!l){let t=y.guess(e);l=t[0],o=!!t[1]}let u=c.default.join(i,this.getMigrationStubName(l,o)),d=await(0,a.readFile)(u,`utf-8`);l!==null&&(d=d.replace(/DummyTable|{{\s*table\s*}}/g,l)),n.Logger.info(`INFO: Creating Migration`),await this.kernel.ensureDirectoryExists(c.default.dirname(r)),await(0,a.writeFile)(r,d),n.Logger.split(`INFO: Migration Created`,n.Logger.log(c.default.basename(r),`gray`,!1))}makeFactory(){n.Logger.success(`Factory support is not yet available`)}makeCommand(){n.Logger.success(`Musket command creation is not yet available`)}makeSeeder(){n.Logger.success(`Seeder support is not yet available`)}async makeModel(){let e=this.option(`type`,`ts`),t=this.argument(`name`),r=this.option(`force`),i=app_path(`Models/${t.toLowerCase()}.${e}`);t.includes(`/`)&&await(0,a.mkdir)((0,o.beforeLast)(i,`/`),{recursive:!0}),!r&&await n.FileSystem.fileExists(i)&&n.Logger.error(`ERORR: ${t} model already exists`);let s=n.FileSystem.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,l=c.default.join(s,`dist/stubs/model-${e}.stub`),u=await(0,a.readFile)(l,`utf-8`);u=u.replace(/{{ name }}/g,t),await(0,a.writeFile)(i,u),n.Logger.split(`INFO: ${t} Model Created`,n.Logger.log(c.default.basename(i),`gray`,!1))}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)((0,o.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))}getMigrationStubName(e,t=!1,n=`ts`){let r;return r=e?t?`migration.create-${n}.stub`:`migration.update-${n}.stub`:`migration-${n}.stub`,`dist/stubs/`+r}},x=class extends h{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`),``))}},S=class e{static parseOptions(t){let n=[],r=/\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g,i;for(;(i=r.exec(t))!==null;){let t=i[1][0]===`^`||/:[#^]/.test(i[1]),r=([`#`,`^`].includes(i[1][0])||/:[#^]/.test(i[1]))&&!t,a=i[1].trim().replace(/[#^]/,``),o=a.indexOf(`:`);if(o===-1){n.push({name:a});continue}let s=a.substring(0,o).trim(),c=a.substring(o+1).trim(),l=c,u,d=c.indexOf(`|`);if(d!==-1){l=c.substring(0,d).trim();let t=c.substring(d+1).trim().replace(/^\{/,``).trim();u=e.parseOptions(`{`+t+`}`)}else l=l.trim();let f=s,p=/[^a-zA-Z0-9_|-]/.test(f),m=!1;f.endsWith(`?*`)?(p=!1,m=!0,f=f.slice(0,-2)):f.endsWith(`*`)?(m=!0,f=f.slice(0,-1)):f.endsWith(`?`)&&(p=!1,f=f.slice(0,-1));let h=f.startsWith(`--`),g,_;if(h){let e=f.split(`|`).map(e=>e.trim());g=[];for(let t of e){t.startsWith(`--`)&&t.slice(2).length===1?t=`-`+t.slice(2):t.startsWith(`-`)&&!t.startsWith(`--`)&&t.slice(1).length>1?t=`--`+t.slice(1):!t.startsWith(`-`)&&t.slice(1).length>1&&(t=`--`+t);let e=t.indexOf(`=`);if(e!==-1){g.push(t.substring(0,e));let n=t.substring(e+1);_=n===`*`?[]:n===`true`||n===`false`||!n&&!p?n===`true`:isNaN(Number(n))?n:Number(n)}else g.push(t)}}n.push({name:h?g[g.length-1]:f,required:p,multiple:m,description:l,flags:g,shared:t,isFlag:h,isHidden:r,defaultValue:_,nestedOptions:u})}return n}static parseSignature(t,n){let r=t.split(`
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 C(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,f.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,d.fork)((0,f.join)(e,t),r,o)},c=e.dir||(0,f.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 w=process.env.NODE_ENV||`development`;let T=w===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(T=process.env.DIST_DIR);const E={outDir:T,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:w===`development`,minify:!!process.env.DIST_MINIFY,external:[/^@h3ravel\/.*/gi],clean:!0,shims:!0,copy:[{from:`public`,to:T},`src/resources`,`src/database`],env:w===`development`?{NODE_ENV:w,DIST_DIR:T}:{},watch:w===`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,u.existsSync)(c.default.join(T,n))&&await(0,a.rm)(c.default.join(T,n),{recursive:!0})}})},plugins:w===`development`&&process.env.CLI_BUILD!==`true`?[C({env:Object.assign({},process.env,{NODE_ENV:w,DIST_DIR:T}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]};var D=E,O=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new b(this.app,this.kernel),new v(this.app,this.kernel),new x(this.app,this.kernel),new m(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=c.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(S.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`]};l.program.name(`musket`).version(`${e}\n${t}`).description(_).addOption(new l.Option(r.quiet[0],r.quiet[1]).implies({silent:!0})).addOption(new l.Option(r.silent[0],r.silent[1]).implies({quiet:!0})).addOption(new l.Option(r.verbose[0],r.verbose[1]).choices([`1`,`2`,`3`])).addOption(new l.Option(r.lock[0],r.lock[1])).action(async()=>{let e=new v(this.app,this.kernel);e.setInput(l.program.opts(),l.program.args,l.program.registeredArguments,{},l.program),e.handle()}),l.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?l.program:l.program.command(t.baseCommand).description(t.description??``).addOption(new l.Option(r.quiet[0],r.quiet[1]).implies({silent:!0})).addOption(new l.Option(r.silent[0],r.silent[1]).implies({quiet:!0})).addOption(new l.Option(r.verbose[0],r.verbose[1]).choices([`1`,`2`,`3`])).addOption(new l.Option(r.lock[0],r.lock[1])).action(async()=>{n.setInput(e.opts(),e.args,e.registeredArguments,t,l.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=l.program.command(`${t.baseCommand}:${e.name}`).description(e.description||``).addOption(new l.Option(r.quiet[0],r.quiet[1]).implies({silent:!0})).addOption(new l.Option(r.silent[0],r.silent[1]).implies({quiet:!0})).addOption(new l.Option(r.verbose[0],r.verbose[1]).choices([`1`,`2`,`3`])).addOption(new l.Option(r.lock[0],r.lock[1])).action(async()=>{n.setInput(i.opts(),i.args,i.registeredArguments,e,l.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=l.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,l.program),await n.handle()})}}return l.program.hook(`preAction`,async(e,t)=>{t.name()!==`fire`&&await(0,p.build)({...D,watch:!1,plugins:[]})}),l.program}makeOption(e,t,n,r){let i=e.description?.replace(/\[(\w+)\]/g,(e,t)=>r?.[t]??`[${t}]`)??``,a=e.name.replaceAll(`-`,``);if(e.isFlag)if(n){let n=e.flags?.map(e=>e.length===1?`-${e}`:`--${e}`).join(`, `).replaceAll(`----`,`--`).replaceAll(`---`,`-`);t.option(n||``,i,String(e.defaultValue)||void 0)}else t.option(e.flags?.join(`, `)+(e.required?` <${a}>`:``),i,e.defaultValue);else t.argument(e.required?`<${e.name}>`:`[${e.name}]`,i,e.defaultValue)}static async parse(t){return(await new e(t.app,t).build()).parseAsync()}},k=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 O.parse(this),process.exit(0)}async loadRequirements(){this.cwd=c.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(c.default.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(c.default.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},A=class extends t.ServiceProvider{static priority=992;static console=!0;console=!0;register(){}boot(){k.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}},j=class{async fire(){let e=process.env.DIST_DIR??`/.h3ravel/serve/`,n=[],r=new t.Application(process.cwd()),i=base_path(c.default.join(e,`bootstrap/providers.js`));n.push(...(await import(i)).default),n.push(A),await r.quickStartup(n,[`CoreServiceProvider`])}};new j().fire();
package/bin/fire.js CHANGED
@@ -1,2 +1,77 @@
1
1
  #!/usr/bin/env node
2
- import{app_default as e}from"./app-Dd20fScu.js";import"tsx/esm";new e().fire();export{};
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{beforeLast as m}from"@h3ravel/support";import h from"dayjs";import g from"node:path";import{Option as _,program as v}from"commander";import{existsSync as y}from"node:fs";import{fork as b}from"child_process";import{dirname as x,join as S,resolve as C}from"path";import{build as w}from"tsdown";var T=class extends t{signature=`build:
3
+ {--m|minify=false : Minify your bundle output}
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(``)})}},E=class extends t{};String.raw`
6
+ 111
7
+ 111111111
8
+ 1111111111 111111
9
+ 111111 111 111111
10
+ 111111 111 111111
11
+ 11111 111 11111
12
+ 1111111 111 1111111
13
+ 111 11111 111 111111 111 1111 1111 11111111 1111
14
+ 111 11111 1111 111111 111 1111 1111 1111 11111 1111
15
+ 111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
16
+ 111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
17
+ 111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
18
+ 111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
19
+ 111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
20
+ 1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
21
+ 11011 111111 11 11111
22
+ 111111 11101 111111
23
+ 111111 111 111111
24
+ 111111 111 111111
25
+ 111111111
26
+ 110
27
+ `;const D=String.raw`
28
+ _ _ _____ _
29
+ | | | |___ / _ __ __ ___ _____| |
30
+ | |_| | |_ \| '__/ _ \ \ / / _ \ |
31
+ | _ |___) | | | (_| |\ V / __/ |
32
+ |_| |_|____/|_| \__,_| \_/ \___|_|
33
+
34
+ `;var O=class extends E{signature=`list`;description=`List all available commands`;async handle(){let e=[{short:`-h`,long:`--help`,description:`Display help for the given command. When no command is given display help for the list command`}].concat(this.program.options).map(e=>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
+ `)].join(`
36
+ `)});a.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(D),console.log(``),a.log(`Usage:`,`yellow`),a.log(` command [options] [arguments]`,`white`),console.log(``),a.log(`Options:`,`yellow`),console.log(e.join(`
37
+ `).trim()),console.log(``),a.log(`Available Commands:`,`yellow`),console.log(n.join(`
38
+
39
+ `).trim())}},k=class e{static CREATE_PATTERNS=[/^create_(\w+)_table$/,/^create_(\w+)$/];static CHANGE_PATTERNS=[/.+_(to|from|in)_(\w+)_table$/,/.+_(to|from|in)_(\w+)$/];static guess(t){for(let n of e.CREATE_PATTERNS){let e=t.match(n);if(e)return[e[1],!0]}for(let n of e.CHANGE_PATTERNS){let e=t.match(n);if(e)return[e[2],!1]}return[]}},A=class extends E{signature=`#make:
40
+ {controller : Create a new controller class.
41
+ | {--a|api : Exclude the create and edit methods from the controller}
42
+ | {--m|model= : Generate a resource controller for the given model}
43
+ | {--r|resource : Generate a resource controller class}
44
+ | {--force : Create the controller even if it already exists}
45
+ }
46
+ {resource : Create a new resource.
47
+ | {--c|collection : Create a resource collection}
48
+ | {--force : Create the resource even if it already exists}
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
+ {command : Create a new Musket command.
56
+ | {--command : The terminal command that will be used to invoke the class}
57
+ | {--force : Create the class even if the console command already exists}
58
+ }
59
+ {factory : Create a new model factory.}
60
+ {seeder : Create a new seeder class.}
61
+ {view : Create a new view.
62
+ | {--force : Create the view even if it already exists}
63
+ }
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
+ {^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`,migration:`makeMigration`,factory:`makeFactory`,seeder:`makeSeeder`,model:`makeModel`,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=g.join(r,`dist/stubs/controller${e}.stub`),s=app_path(`Http/Controllers/${t}.ts`);t.includes(`/`)&&await u(m(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(g.basename(s),`gray`,!1))}makeResource(){a.success(`Resource support is not yet available`)}async makeMigration(){let e=this.argument(`name`),t=h().format(`YYYY_MM_DD_HHmmss`),n=database_path(`migrations/${t}_${e}.ts`),r=i.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,o=this.option(`create`,!1),s=this.option(`table`);if(!s&&typeof o==`string`&&(s=o,o=!0),!s){let t=k.guess(e);s=t[0],o=!!t[1]}let c=g.join(r,this.getMigrationStubName(s,o)),l=await d(c,`utf-8`);s!==null&&(l=l.replace(/DummyTable|{{\s*table\s*}}/g,s)),a.info(`INFO: Creating Migration`),await this.kernel.ensureDirectoryExists(g.dirname(n)),await p(n,l),a.split(`INFO: Migration Created`,a.log(g.basename(n),`gray`,!1))}makeFactory(){a.success(`Factory support is not yet available`)}makeCommand(){a.success(`Musket command creation is not yet available`)}makeSeeder(){a.success(`Seeder support is not yet available`)}async makeModel(){let e=this.option(`type`,`ts`),t=this.argument(`name`),n=this.option(`force`),r=app_path(`Models/${t.toLowerCase()}.${e}`);t.includes(`/`)&&await u(m(r,`/`),{recursive:!0}),!n&&await i.fileExists(r)&&a.error(`ERORR: ${t} model already exists`);let o=i.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,s=g.join(o,`dist/stubs/model-${e}.stub`),c=await d(s,`utf-8`);c=c.replace(/{{ name }}/g,t),await p(r,c),a.split(`INFO: ${t} Model Created`,a.log(g.basename(r),`gray`,!1))}async makeView(){let e=this.argument(`name`),t=this.option(`force`),n=base_path(`src/resources/views/${e}.edge`);e.includes(`/`)&&await u(m(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))}getMigrationStubName(e,t=!1,n=`ts`){let r;return r=e?t?`migration.create-${n}.stub`:`migration.update-${n}.stub`:`migration-${n}.stub`,`dist/stubs/`+r}},j=class extends E{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`),``))}},M=class e{static parseOptions(t){let n=[],r=/\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g,i;for(;(i=r.exec(t))!==null;){let t=i[1][0]===`^`||/:[#^]/.test(i[1]),r=([`#`,`^`].includes(i[1][0])||/:[#^]/.test(i[1]))&&!t,a=i[1].trim().replace(/[#^]/,``),o=a.indexOf(`:`);if(o===-1){n.push({name:a});continue}let s=a.substring(0,o).trim(),c=a.substring(o+1).trim(),l=c,u,d=c.indexOf(`|`);if(d!==-1){l=c.substring(0,d).trim();let t=c.substring(d+1).trim().replace(/^\{/,``).trim();u=e.parseOptions(`{`+t+`}`)}else l=l.trim();let f=s,p=/[^a-zA-Z0-9_|-]/.test(f),m=!1;f.endsWith(`?*`)?(p=!1,m=!0,f=f.slice(0,-2)):f.endsWith(`*`)?(m=!0,f=f.slice(0,-1)):f.endsWith(`?`)&&(p=!1,f=f.slice(0,-1));let h=f.startsWith(`--`),g,_;if(h){let e=f.split(`|`).map(e=>e.trim());g=[];for(let t of e){t.startsWith(`--`)&&t.slice(2).length===1?t=`-`+t.slice(2):t.startsWith(`-`)&&!t.startsWith(`--`)&&t.slice(1).length>1?t=`--`+t.slice(1):!t.startsWith(`-`)&&t.slice(1).length>1&&(t=`--`+t);let e=t.indexOf(`=`);if(e!==-1){g.push(t.substring(0,e));let n=t.substring(e+1);_=n===`*`?[]:n===`true`||n===`false`||!n&&!p?n===`true`:isNaN(Number(n))?n:Number(n)}else g.push(t)}}n.push({name:h?g[g.length-1]:f,required:p,multiple:m,description:l,flags:g,shared:t,isFlag:h,isHidden:r,defaultValue:_,nestedOptions:u})}return n}static parseSignature(t,n){let r=t.split(`
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 N(e={}){let t,n,r=e.args||[],i=e.allowRestarts||!1,a=e.input,o=e.options||e;return delete o.args,delete o.allowRestarts,{name:`run`,buildStart(e){let n=a??e.input;if(typeof n==`string`&&(n=[n]),typeof n==`object`&&(n=Object.values(n)),n.length>1)throw Error("@rollup/plugin-run must have a single entry point; consider setting the `input` option");t=C(n[0])},generateBundle(e,t,n){n||this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`)},writeBundle(e,a){let s=(e,t)=>{n&&n.kill(),n=b(S(e,t),r,o)},c=e.dir||x(e.file),l=Object.keys(a).find(e=>{let n=a[e];return n.isEntry&&n.facadeModuleId===t});l?(s(c,l),i&&(process.stdin.resume(),process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{let t=e.toString().trim().toLowerCase();t===`rs`||t===`restart`||e.toString().charCodeAt(0)===11?s(c,l):(t===`cls`||t===`clear`||e.toString().charCodeAt(0)===12)&&console.clear()}))):this.error(`@rollup/plugin-run could not find output chunk`)}}}const P=process.env.NODE_ENV||`development`;let F=P===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(F=process.env.DIST_DIR);var I={outDir:F,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:P===`development`,minify:!!process.env.DIST_MINIFY,external:[/^@h3ravel\/.*/gi],clean:!0,shims:!0,copy:[{from:`public`,to:F},`src/resources`,`src/database`],env:P===`development`?{NODE_ENV:P,DIST_DIR:F}:{},watch:P===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,hooks(e){e.hook(`build:done`,async()=>{let e=[`database/migrations`,`database/factories`,`database/seeders`];for(let t=0;t<e.length;t++){let n=e[t];y(g.join(F,n))&&await f(g.join(F,n),{recursive:!0})}})},plugins:P===`development`&&process.env.CLI_BUILD!==`true`?[N({env:Object.assign({},process.env,{NODE_ENV:P,DIST_DIR:F}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]},L=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new A(this.app,this.kernel),new O(this.app,this.kernel),new j(this.app,this.kernel),new T(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=g.basename(e).replace(`.js`,``);try{let r=(await import(e))[n];t.push(new r(this.app,this.kernel))}catch{}}t.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(M.parseSignature(e.getSignature(),e))}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`]};v.name(`musket`).version(`${e}\n${t}`).description(D).addOption(new _(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new _(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new _(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new _(n.lock[0],n.lock[1])).action(async()=>{let e=new O(this.app,this.kernel);e.setInput(v.opts(),v.args,v.registeredArguments,{},v),e.handle()}),v.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?v:v.command(t.baseCommand).description(t.description??``).addOption(new _(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new _(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new _(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new _(n.lock[0],n.lock[1])).action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,v),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=v.command(`${t.baseCommand}:${e.name}`).description(e.description||``).addOption(new _(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new _(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new _(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new _(n.lock[0],n.lock[1])).action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,e,v),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=v.command(t.baseCommand).description(t.description??``);t?.options?.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).forEach(t=>{this.makeOption(t,e,!0)}),e.action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,v),await r.handle()})}}return v.hook(`preAction`,async(e,t)=>{t.name()!==`fire`&&await w({...I,watch:!1,plugins:[]})}),v}makeOption(e,t,n,r){let i=e.description?.replace(/\[(\w+)\]/g,(e,t)=>r?.[t]??`[${t}]`)??``,a=e.name.replaceAll(`-`,``);if(e.isFlag)if(n){let n=e.flags?.map(e=>e.length===1?`-${e}`:`--${e}`).join(`, `).replaceAll(`----`,`--`).replaceAll(`---`,`-`);t.option(n||``,i,String(e.defaultValue)||void 0)}else t.option(e.flags?.join(`, `)+(e.required?` <${a}>`:``),i,e.defaultValue);else t.argument(e.required?`<${e.name}>`:`[${e.name}]`,i,e.defaultValue)}static async parse(t){return(await new e(t.app,t).build()).parseAsync()}},R=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 L.parse(this),process.exit(0)}async loadRequirements(){this.cwd=g.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(g.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(g.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},z=class extends r{static priority=992;static console=!0;console=!0;register(){}boot(){R.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(g.join(t,`bootstrap/providers.js`)));n.push(...(await import(i)).default),n.push(z),await r.quickStartup(n,[`CoreServiceProvider`])}}().fire();export{};
package/bin/spawn.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const e=require(`./app-PHgmg_5L.cjs`);new e.app_default().spawn();
2
+ const e=require(`./zero-BT86xjc9.cjs`);new e.zero_default().spawn();
package/bin/spawn.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{app_default as e}from"./app-Dd20fScu.js";new e().spawn();export{};
2
+ import{zero_default as e}from"./zero-Ddh7ucIS.js";new e().spawn();export{};
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@h3ravel/shared`);c=s(c);let l=require(`execa`);l=s(l);let u=require(`preferred-pm`);u=s(u);let d=require(`node:fs/promises`);d=s(d);let f=require(`node:path`);f=s(f);var p=class{async spawn(e=`.h3ravel/serve`){let t=(await(0,u.default)(process.cwd()))?.name??`npm`,n=(0,f.join)(process.env.DIST_DIR??e);if(await c.FileSystem.fileExists(n))return;await c.FileSystem.fileExists(f.default.join(n,`tsconfig.json`))||(await(0,d.mkdir)(f.default.join(n.replace(`/serve`,``)),{recursive:!0}),await(0,d.writeFile)(f.default.join(n.replace(`/serve`,``),`tsconfig.json`),JSON.stringify(c.mainTsconfig,null,2)));let r={EXTENDED_DEBUG:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:n,LOG_LEVEL:`silent`};await(0,l.execa)(t,[`tsdown`,`--silent`,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:(0,f.join)(process.cwd()),env:Object.assign({},process.env,r)})}};Object.defineProperty(exports,`__toESM`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`zero_default`,{enumerable:!0,get:function(){return p}});
@@ -0,0 +1 @@
1
+ import{FileSystem as e,mainTsconfig as t}from"@h3ravel/shared";import{execa as n}from"execa";import r from"preferred-pm";import{mkdir as i,writeFile as a}from"node:fs/promises";import o,{join as s}from"node:path";var c=class{async spawn(c=`.h3ravel/serve`){let l=(await r(process.cwd()))?.name??`npm`,u=s(process.env.DIST_DIR??c);if(await e.fileExists(u))return;await e.fileExists(o.join(u,`tsconfig.json`))||(await i(o.join(u.replace(`/serve`,``)),{recursive:!0}),await a(o.join(u.replace(`/serve`,``),`tsconfig.json`),JSON.stringify(t,null,2)));let d={EXTENDED_DEBUG:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:u,LOG_LEVEL:`silent`};await n(l,[`tsdown`,`--silent`,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:s(process.cwd()),env:Object.assign({},process.env,d)})}};export{c as zero_default};
package/dist/index.cjs CHANGED
@@ -260,7 +260,7 @@ var MakeCommand = class extends Command {
260
260
  async handle() {
261
261
  const command = this.dictionary.baseCommand ?? this.dictionary.name;
262
262
  if (!this.argument("name")) this.program.error("Please provide a valid name for the " + command);
263
- const methods = {
263
+ await this[{
264
264
  controller: "makeController",
265
265
  resource: "makeResource",
266
266
  migration: "makeMigration",
@@ -269,12 +269,7 @@ var MakeCommand = class extends Command {
269
269
  model: "makeModel",
270
270
  view: "makeView",
271
271
  command: "makeCommand"
272
- };
273
- try {
274
- await this?.[methods[command]]();
275
- } catch (e) {
276
- __h3ravel_shared.Logger.error(e);
277
- }
272
+ }[command]]();
278
273
  }
279
274
  /**
280
275
  * Create a new controller class.
@@ -285,15 +280,15 @@ var MakeCommand = class extends Command {
285
280
  const force = this.option("force");
286
281
  const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
287
282
  const stubPath = node_path.default.join(crtlrPath, `dist/stubs/controller${type}.stub`);
288
- const path$5 = app_path(`Http/Controllers/${name}.ts`);
283
+ const path$6 = app_path(`Http/Controllers/${name}.ts`);
289
284
  /** The Controller is scoped to a path make sure to create the associated directories */
290
- if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$5, "/"), { recursive: true });
285
+ if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$6, "/"), { recursive: true });
291
286
  /** Check if the controller already exists */
292
- if (!force && await __h3ravel_shared.FileSystem.fileExists(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
287
+ if (!force && await __h3ravel_shared.FileSystem.fileExists(path$6)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
293
288
  let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
294
289
  stub = stub.replace(/{{ name }}/g, name);
295
- await (0, node_fs_promises.writeFile)(path$5, stub);
296
- __h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
290
+ await (0, node_fs_promises.writeFile)(path$6, stub);
291
+ __h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$6), "gray", false));
297
292
  }
298
293
  makeResource() {
299
294
  __h3ravel_shared.Logger.success("Resource support is not yet available");
@@ -304,7 +299,7 @@ var MakeCommand = class extends Command {
304
299
  async makeMigration() {
305
300
  const name = this.argument("name");
306
301
  const datePrefix = (0, dayjs.default)().format("YYYY_MM_DD_HHmmss");
307
- const path$5 = database_path(`migrations/${datePrefix}_${name}.ts`);
302
+ const path$6 = database_path(`migrations/${datePrefix}_${name}.ts`);
308
303
  const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
309
304
  let create = this.option("create", false);
310
305
  let table = this.option("table");
@@ -321,9 +316,9 @@ var MakeCommand = class extends Command {
321
316
  let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
322
317
  if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
323
318
  __h3ravel_shared.Logger.info("INFO: Creating Migration");
324
- await this.kernel.ensureDirectoryExists(node_path.default.dirname(path$5));
325
- await (0, node_fs_promises.writeFile)(path$5, stub);
326
- __h3ravel_shared.Logger.split("INFO: Migration Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
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));
327
322
  }
328
323
  /**
329
324
  * Create a new model factory
@@ -350,17 +345,17 @@ var MakeCommand = class extends Command {
350
345
  const type = this.option("type", "ts");
351
346
  const name = this.argument("name");
352
347
  const force = this.option("force");
353
- const path$5 = app_path(`Models/${name.toLowerCase()}.${type}`);
348
+ const path$6 = app_path(`Models/${name.toLowerCase()}.${type}`);
354
349
  /** The model is scoped to a path make sure to create the associated directories */
355
- if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$5, "/"), { recursive: true });
350
+ if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$6, "/"), { recursive: true });
356
351
  /** Check if the model already exists */
357
- if (!force && await __h3ravel_shared.FileSystem.fileExists(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} model already exists`);
352
+ if (!force && await __h3ravel_shared.FileSystem.fileExists(path$6)) __h3ravel_shared.Logger.error(`ERORR: ${name} model already exists`);
358
353
  const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
359
354
  const stubPath = node_path.default.join(crtlrPath, `dist/stubs/model-${type}.stub`);
360
355
  let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
361
356
  stub = stub.replace(/{{ name }}/g, name);
362
- await (0, node_fs_promises.writeFile)(path$5, stub);
363
- __h3ravel_shared.Logger.split(`INFO: ${name} Model Created`, __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
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));
364
359
  }
365
360
  /**
366
361
  * Create a new view.
@@ -368,12 +363,12 @@ var MakeCommand = class extends Command {
368
363
  async makeView() {
369
364
  const name = this.argument("name");
370
365
  const force = this.option("force");
371
- const path$5 = base_path(`src/resources/views/${name}.edge`);
366
+ const path$6 = base_path(`src/resources/views/${name}.edge`);
372
367
  /** The view is scoped to a path make sure to create the associated directories */
373
- if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$5, "/"), { recursive: true });
368
+ if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$6, "/"), { recursive: true });
374
369
  /** Check if the view already exists */
375
- if (!force && await __h3ravel_shared.FileSystem.fileExists(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
376
- await (0, node_fs_promises.writeFile)(path$5, `{{-- src/resources/views/${name}.edge --}}`);
370
+ if (!force && await __h3ravel_shared.FileSystem.fileExists(path$6)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
371
+ await (0, node_fs_promises.writeFile)(path$6, `{{-- src/resources/views/${name}.edge --}}`);
377
372
  __h3ravel_shared.Logger.split("INFO: View Created", __h3ravel_shared.Logger.log(`src/resources/views/${name}.edge`, "gray", false));
378
373
  }
379
374
  /**
@@ -648,6 +643,7 @@ const TsDownConfig = {
648
643
  target: "node22",
649
644
  sourcemap: env$1 === "development",
650
645
  minify: !!process.env.DIST_MINIFY,
646
+ external: [/^@h3ravel\/.*/gi],
651
647
  clean: true,
652
648
  shims: true,
653
649
  copy: [