@h3ravel/console 11.0.4 → 11.0.5
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/run.cjs +6 -6
- package/bin/run.js +6 -6
- package/dist/Commands/ServeCommand.cjs +1 -1
- package/dist/Commands/ServeCommand.js +1 -1
- package/dist/IO/app.cjs +7 -6
- package/dist/IO/app.js +6 -6
- package/dist/IO/providers.cjs +3 -1
- package/dist/IO/providers.js +5 -5
- package/dist/Kernel.cjs +1 -1
- package/dist/Kernel.js +3 -3
- package/dist/Musket.cjs +1 -1
- package/dist/Musket.js +2 -2
- package/dist/Providers/ConsoleServiceProvider.cjs +1 -1
- package/dist/Providers/ConsoleServiceProvider.js +4 -4
- package/dist/chunk-2O2AYFAG.js +63 -0
- package/dist/chunk-3VCNSA6P.js +14 -0
- package/dist/chunk-3WHUADTN.js +6 -0
- package/dist/chunk-6OCHCPBP.js +36 -0
- package/dist/chunk-E5XIGIEX.js +14 -0
- package/dist/chunk-GVGO5OAK.js +8 -0
- package/dist/chunk-GXRCTWKL.js +16 -0
- package/dist/chunk-HVKW7JK4.js +8 -0
- package/dist/chunk-JXL4VJHZ.js +36 -0
- package/dist/chunk-M4ZRDJJ2.js +68 -0
- package/dist/chunk-MAQAT3PU.js +32 -0
- package/dist/chunk-P7M5PEDY.js +18 -0
- package/dist/chunk-RRP7K5LI.js +36 -0
- package/dist/chunk-TJZCDDEV.js +36 -0
- package/dist/chunk-U6TOLKGJ.js +22 -0
- package/dist/chunk-XCOSZXAE.js +133 -0
- package/dist/chunk-YAYU7VOK.js +8 -0
- package/dist/chunk-ZTIO25VB.js +8 -0
- package/dist/index.cjs +7 -8
- package/dist/index.js +7 -7
- package/dist/run.cjs +7 -10
- package/dist/run.js +7 -7
- package/package.json +7 -5
package/bin/run.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var events=require('events'),
|
|
2
|
+
'use strict';var core=require('@h3ravel/core'),events=require('events'),config=require('@h3ravel/config'),database=require('@h3ravel/database'),promises=require('fs/promises'),d=require('chalk'),g=require('path'),fs=require('fs'),te=require('dayjs'),arquebus=require('@h3ravel/arquebus'),child_process=require('child_process'),commander=require('commander'),http=require('@h3ravel/http');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var d__default=/*#__PURE__*/_interopDefault(d);var g__default=/*#__PURE__*/_interopDefault(g);var te__default=/*#__PURE__*/_interopDefault(te);var K=Object.defineProperty;var c=(u,e)=>K(u,"name",{value:e,configurable:true});function F(u,e){let t=g.resolve(".",u),s;for(fs.statSync(t).isDirectory()||(t=g.dirname(t));;){if(s=e(t,fs.readdirSync(t)),s)return g.resolve(t,s);if(t=g.dirname(s=t),s===t)break}}c(F,"default");var Y=g__default.default.join,f=class{static{c(this,"Utils");}static textFormat(e,t){return String(e).split(":").map((s,a,r)=>a==0&&r.length>1?t(" "+s+": "):s).join("")}static output(){return {success:c((e,t=false)=>{console.log(d__default.default.green("\u2713"),this.textFormat(e,d__default.default.bgGreen),`
|
|
3
3
|
`),t&&process.exit(0);},"success"),info:c((e,t=false)=>{console.log(d__default.default.blue("\u2139"),this.textFormat(e,d__default.default.bgBlue),`
|
|
4
4
|
`),t&&process.exit(0);},"info"),error:c((e,t=true)=>{e instanceof Error?(e.message&&console.error(d__default.default.red("\u2716"),this.textFormat("ERROR:"+e.message,d__default.default.bgRed)),console.error(d__default.default.red(`${e.detail?`${e.detail}
|
|
5
5
|
`:""}${e.stack}`),`
|
|
6
6
|
`)):console.error(d__default.default.red("\u2716"),this.textFormat(e,d__default.default.bgRed),`
|
|
7
|
-
`),t&&process.exit(1);},"error"),split:c((e,t,s,
|
|
7
|
+
`),t&&process.exit(1);},"error"),split:c((e,t,s,a=false)=>{s??="info";let r={success:d__default.default.bgGreen,info:d__default.default.bgBlue,error:d__default.default.bgRed},i=/\x1b\[\d+m/g,n=Math.min(process.stdout.columns,100),o=Math.max(n-e.replace(i,"").length-t.replace(i,"").length-10,0);console.log(this.textFormat(e,r[s]),d__default.default.gray(".".repeat(o)),t),a&&process.exit(0);},"split"),quiet:c(()=>{process.exit(0);},"quiet")}}static findModulePkg(e,t){let s=e.replace(/\\/g,"/").split("/"),a="";s.length>0&&s[0][0]==="@"&&(a+=s.shift()+"/"),a+=s.shift();let r=g__default.default.join(t??process.cwd(),"node_modules",a),i=this.findUpConfig(r,"package",["json"]);if(i)return g__default.default.join(g__default.default.dirname(i),s.join("/"))}static async getMigrationPaths(e,t,s,a){return a?[Y(e,a)]:[...t.getPaths(),Y(e,s)]}static twoColumnDetail(e,t){let s=/\x1b\[\d+m/g,a=Math.min(process.stdout.columns,100),r=Math.max(a-e.replace(s,"").length-t.replace(s,"").length-10,0);return console.log(e,d__default.default.gray(".".repeat(r)),t)}static async fileExists(e){try{return await promises.access(e),!0}catch{return false}}static findUpConfig(e,t,s){return F(e,(a,r)=>{for(let i of s){let n=`${t}.${i}`;if(r.includes(n))return n}return false})}},J=class D{static{c(this,"TableGuesser");}static CREATE_PATTERNS=[/^create_(\w+)_table$/,/^create_(\w+)$/];static CHANGE_PATTERNS=[/.+_(to|from|in)_(\w+)_table$/,/.+_(to|from|in)_(\w+)$/];static guess(e){for(let t of D.CREATE_PATTERNS){let s=e.match(t);if(s)return [s[1],true]}for(let t of D.CHANGE_PATTERNS){let s=e.match(t);if(s)return [s[2],false]}return []}};var k=class{static{c(this,"Command");}app;kernel;constructor(e,t){this.app=e,this.kernel=t;}signature;dictionary={};description;input={options:{},arguments:{}};async handle(...e){}setApplication(e){this.app=e;}setInput(e,t,s,a){this.dictionary=a,this.input.options=e,this.input.arguments=s.map((r,i)=>({[r.name()]:t[i]})).reduce((r,i)=>Object.assign(r,i),{});}getSignature(){return this.signature}getDescription(){return this.description}option(e,t){return this.input.options[e]??t}options(e){return e?this.input.options[e]:this.input.options}argument(e,t){return this.input.arguments[e]??t}arguments(){return this.input.arguments}};var S=class extends k{static{c(this,"MakeCommand");}signature=`#make:
|
|
8
8
|
{controller : Generates a new controller class. | {--a|api : Generate an API resource controller} | {--force : Overide existing controller.} }
|
|
9
9
|
{resource : Generates a new API resource class.}
|
|
10
10
|
{migration : Generates a new database migration class. | {--l|type=ts : The file type to generate} | {--t|table : The table to migrate} | {--c|create : The table to be created} }
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
{seeder : Generates a new database seeder class.}
|
|
13
13
|
{model : Generates a new Arquebus model class. | {--t|type=ts : The file type to generate}}
|
|
14
14
|
{^name : The name of the [name] to generate}
|
|
15
|
-
`;description="Generate component classes";async handle(){let e=this.dictionary.baseCommand,t={controller:"makeController",resource:"makeResource",migration:"makeMigration",factory:"makeFactory",seeder:"makeSeeder",model:"makeModel"};try{await this?.[t[e]]();}catch(s){this.kernel.output.error(s);}}async makeController(){let e=this.option("api")?"-resource":"",t=this.argument("name"),s=this.option("force"),
|
|
15
|
+
`;description="Generate component classes";async handle(){let e=this.dictionary.baseCommand,t={controller:"makeController",resource:"makeResource",migration:"makeMigration",factory:"makeFactory",seeder:"makeSeeder",model:"makeModel"};try{await this?.[t[e]]();}catch(s){this.kernel.output.error(s);}}async makeController(){let e=this.option("api")?"-resource":"",t=this.argument("name"),s=this.option("force"),a=g__default.default.join(app_path("Http/Controllers"),t+".ts"),r=f.findModulePkg("@h3ravel/http",this.kernel.cwd)??"",i=g__default.default.join(r,`dist/stubs/controller${e}.stub`);!s&&fs.existsSync(a)&&this.kernel.output.error(`ERORR: ${t} controller already exists`);let n=await promises.readFile(i,"utf-8");n=n.replace(/{{ name }}/g,t),await promises.writeFile(a,n),this.kernel.output.split("INFO: Controller Created",d__default.default.gray(g__default.default.basename(a)));}makeResource(){this.kernel.output.success("Resource support is not yet available");}async makeMigration(){let e=this.argument("name"),t=te__default.default().format("YYYY_MM_DD_HHmmss"),s=g__default.default.join(database_path("migrations"),`${t}_${e}.ts`),a=f.findModulePkg("@h3ravel/database",this.kernel.cwd)??"",r=this.option("create",false),i=this.option("table");if(!i&&typeof r=="string"&&(i=r,r=true),!i){let l=J.guess(e);i=l[0],r=!!l[1];}let n=g__default.default.join(a,this.getMigrationStubName(i,r)),o=await promises.readFile(n,"utf-8");i!==null&&(o=o.replace(/DummyTable|{{\s*table\s*}}/g,i)),this.kernel.output.info("INFO: Creating Migration"),await this.kernel.ensureDirectoryExists(g__default.default.dirname(s)),await promises.writeFile(s,o),this.kernel.output.split("INFO: Migration Created",d__default.default.gray(g__default.default.basename(s)));}makeFactory(){this.kernel.output.success("Factory support is not yet available");}makeSeeder(){this.kernel.output.success("Seeder support is not yet available");}async makeModel(){let e=this.option("type","ts"),t=this.argument("name"),s=g__default.default.join(app_path("Models"),t.toLowerCase()+"."+e),a=f.findModulePkg("@h3ravel/database",this.kernel.cwd)??"",r=g__default.default.join(a,`dist/stubs/model-${e}.stub`),i=await promises.readFile(r,"utf-8");i=i.replace(/{{ name }}/g,t),await promises.writeFile(s,i),this.kernel.output.split("INFO: Model Created",d__default.default.gray(g__default.default.basename(s)));}getMigrationStubName(e,t=false,s="ts"){let a;return e?t?a=`migration.create-${s}.stub`:a=`migration.update-${s}.stub`:a=`migration-${s}.stub`,"dist/stubs/"+a}};var I=class extends k{static{c(this,"MigrateCommand");}signature=`migrate:
|
|
16
16
|
{fresh : Drop all tables and re-run all migrations.}
|
|
17
17
|
{install : Create the migration repository.}
|
|
18
18
|
{refresh : Reset and re-run all migrations.}
|
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
{status : Show the status of each migration.}
|
|
22
22
|
{publish : Publish any migration files from installed packages.}
|
|
23
23
|
{^--s|seed : Seed the database}
|
|
24
|
-
`;description="Run all pending migrations.";async handle(){let e=this.dictionary.name??this.dictionary.baseCommand;await this?.[{migrate:"migrateRun",fresh:"migrateFresh",install:"migrateInstall",refresh:"migrateRefresh",reset:"migrateReset",rollback:"migrateRollback",status:"migrateStatus",publish:"migratePublish"}[e]]();}async migrateRun(){this.kernel.output.success("Running migrations are not yet supported.");}async migrateFresh(){this.kernel.output.success("Drop all tables and re-run all migrations.");}async migrateInstall(){this.kernel.output.success("Create the migration repository.");}async migrateRefresh(){this.kernel.output.success("Resetting and re-running migrations is not yet supported.");}async migrateReset(){this.kernel.output.success("Rolling back all migration is not yet supported.");}async migrateRollback(){this.kernel.output.success("Rolling back the last migration is not yet supported.");}async migrateStatus(){app_path();console.log(arquebus.arquebus.connection()),this.kernel.output.success("Show the status of each migration.");}async migratePublish(){this.kernel.output.success("Publish any migration files from installed packages.");}};var
|
|
25
|
-
`).map(
|
|
26
|
-
${t}`),commander.program.command("init").description("Initialize H3ravel.").action(async()=>{this.output.success("Initialized: H3ravel has been initialized!");});for(let s=0;s<this.commands.length;s++){let
|
|
24
|
+
`;description="Run all pending migrations.";async handle(){let e=this.dictionary.name??this.dictionary.baseCommand;await this?.[{migrate:"migrateRun",fresh:"migrateFresh",install:"migrateInstall",refresh:"migrateRefresh",reset:"migrateReset",rollback:"migrateRollback",status:"migrateStatus",publish:"migratePublish"}[e]]();}async migrateRun(){this.kernel.output.success("Running migrations are not yet supported.");}async migrateFresh(){this.kernel.output.success("Drop all tables and re-run all migrations.");}async migrateInstall(){this.kernel.output.success("Create the migration repository.");}async migrateRefresh(){this.kernel.output.success("Resetting and re-running migrations is not yet supported.");}async migrateReset(){this.kernel.output.success("Rolling back all migration is not yet supported.");}async migrateRollback(){this.kernel.output.success("Rolling back the last migration is not yet supported.");}async migrateStatus(){app_path();console.log(arquebus.arquebus.connection()),this.kernel.output.success("Show the status of each migration.");}async migratePublish(){this.kernel.output.success("Publish any migration files from installed packages.");}};var E=class extends k{static{c(this,"ServeCommand");}signature="serve";description="Start the Developement Server";async handle(){try{await this.serve();}catch(e){this.kernel.output.error(e);}}async serve(){let e=child_process.spawn("tsup-node",{stdio:"inherit",shell:true,env:Object.assign({},process.env,{NODE_ENV:"development"}),detached:true}),t=c(()=>{console.log(111111),e.pid&&process.kill(e.pid,"SIGTERM");},"cleanup");process.on("SIGINT",()=>e.kill("SIGINT")),process.on("SIGTERM",()=>e.kill("SIGTERM")),process.on("SIGINT",()=>{t(),process.exit(0);}),process.on("SIGTERM",()=>{t(),process.exit(0);});}};var T=class u{static{c(this,"Signature");}static parseOptions(e){let t=[],s=/\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g,a;for(;(a=s.exec(e))!==null;){let r=a[1][0]==="^"||/:[#^]/.test(a[1]),i=(["#","^"].includes(a[1][0])||/:[#^]/.test(a[1]))&&!r,n=a[1].trim().replace(/[#^]/,""),o=n.indexOf(":");if(o===-1){t.push({name:n});continue}let l=n.substring(0,o).trim(),m=n.substring(o+1).trim(),x=m,v,O=m.indexOf("|");if(O!==-1){x=m.substring(0,O).trim();let p=m.substring(O+1).trim().replace(/^\{/,"").trim();v=u.parseOptions("{"+p+"}");}else x=x.trim();let h=l,C=/[^a-zA-Z0-9_|-]/.test(h),G=false;h.endsWith("?*")?(C=false,G=true,h=h.slice(0,-2)):h.endsWith("*")?(G=true,h=h.slice(0,-1)):h.endsWith("?")&&(C=false,h=h.slice(0,-1));let A=h.startsWith("--"),w,P;if(A){let z=h.split("|").map(p=>p.trim());w=[];for(let p of z){p.startsWith("--")&&p.slice(2).length===1?p="-"+p.slice(2):p.startsWith("-")&&!p.startsWith("--")&&p.slice(1).length>1?p="--"+p.slice(1):!p.startsWith("-")&&p.slice(1).length>1&&(p="--"+p);let _=p.indexOf("=");if(_!==-1){w.push(p.substring(0,_));let b=p.substring(_+1);b==="*"?P=[]:b==="true"||b==="false"||!b&&!C?P=b==="true":isNaN(Number(b))?P=b:P=Number(b);}else w.push(p);}}t.push({name:A?w[w.length-1]:h,required:C,multiple:G,description:x,flags:w,shared:r,isFlag:A,isHidden:i,defaultValue:P,nestedOptions:v});}return t}static parseSignature(e,t){let s=e.split(`
|
|
25
|
+
`).map(m=>m.trim()).filter(m=>m.length>0),a=["#","^"].includes(s[0][0])||/:[#^]/.test(s[0]),r=s[0].replace(/[^\w=:-]/g,""),i=t.getDescription(),n=r.endsWith(":"),o=s.slice(1).join(" "),l=u.parseOptions(o);return n?{baseCommand:r.slice(0,-1),isNamespaceCommand:n,subCommands:l.filter(m=>!m.flags&&!m.isHidden),description:i,commandClass:t,options:l.filter(m=>!!m.flags),isHidden:a}:{baseCommand:r,isNamespaceCommand:n,options:l,description:i,commandClass:t,isHidden:a}}};var N=class u{static{c(this,"Musket");}app;kernel;output=f.output();commands=[];constructor(e,t){this.app=e,this.kernel=t;}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new E(this.app,this.kernel),new S(this.app,this.kernel),new I(this.app,this.kernel)].forEach(t=>this.addCommand(t));}async loadDiscoveredCommands(){[].forEach(t=>this.addCommand(t));}addCommand(e){this.commands.push(T.parseSignature(e.getSignature(),e));}initialize(){let e=["H3ravel Version:",d__default.default.green(this.kernel.consolePackage.version)].join(" "),t=["Musket Version:",d__default.default.green(this.kernel.modulePackage.version||"None")].join(" ");commander.program.name("musket").version(`${e}
|
|
26
|
+
${t}`),commander.program.command("init").description("Initialize H3ravel.").action(async()=>{this.output.success("Initialized: H3ravel has been initialized!");});for(let s=0;s<this.commands.length;s++){let a=this.commands[s],r=a.commandClass;if(a.isNamespaceCommand&&a.subCommands){let i=a.isHidden?commander.program:commander.program.command(a.baseCommand).description(a.description??"").action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,a),await r.handle();});(a.options?.length??0)>0&&a.options?.filter((n,o,l)=>l.findIndex(m=>m.name===n.name)===o).forEach(n=>{this.makeOption(n,i);}),a.subCommands.filter((n,o,l)=>!n.shared&&l.findIndex(m=>m.name===n.name)===o).forEach(n=>{let o=commander.program.command(`${a.baseCommand}:${n.name}`).description(n.description||"").action(async()=>{r.setInput(o.opts(),o.args,o.registeredArguments,n),await r.handle();});a.subCommands?.filter(l=>l.shared).forEach(l=>{this.makeOption(l,o,false,n);}),a.options?.filter(l=>l.shared).forEach(l=>{this.makeOption(l,o,false,n);}),n.nestedOptions&&n.nestedOptions.filter((l,m,x)=>x.findIndex(v=>v.name===l.name)===m).forEach(l=>{this.makeOption(l,o);});});}else {let i=commander.program.command(a.baseCommand).description(a.description??"");a?.options?.filter((n,o,l)=>l.findIndex(m=>m.name===n.name)===o).forEach(n=>{this.makeOption(n,i,true);}),i.action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,a),await r.handle();});}}return commander.program}makeOption(e,t,s,a){let r=e.description?.replace(/\[(\w+)\]/g,(n,o)=>a?.[o]??`[${o}]`)??"",i=e.name.replaceAll("-","");if(e.isFlag)if(s){let n=e.flags?.map(o=>o.length===1?`-${o}`:`--${o}`).join(", ");t.option(n||"",r,String(e.defaultValue)||void 0);}else t.option(e.flags?.join(", ")+(e.required?` <${i}>`:""),r,e.defaultValue);else t.argument(e.required?`<${e.name}>`:`[${e.name}]`,r,e.defaultValue);}static async parse(e){return (await new u(e.app,e).build()).parseAsync()}};var M=class u{static{c(this,"Kernel");}app;cwd;output=f.output();basePath="";modulePath;consolePath;modulePackage;consolePackage;constructor(e,t){this.app=e;}static init(e){let t=new u(e);Promise.all([t.loadRequirements()]).then(([s])=>s.run());}async run(){await N.parse(this),process.exit(0);}async ensureDirectoryExists(e){await promises.mkdir(e,{recursive:true});}async loadRequirements(){this.cwd=g__default.default.join(process.cwd(),this.basePath),this.modulePath=f.findModulePkg("@h3ravel/core",this.cwd)??"",this.consolePath=f.findModulePkg("@h3ravel/console",this.cwd)??"";try{this.modulePackage=await import(g__default.default.join(this.modulePath,"package.json"));}catch{this.modulePackage={version:"N/A"};}try{this.consolePackage=await import(g__default.default.join(this.consolePath,"package.json"));}catch{this.consolePackage={version:"N/A"};}return this}};var $=class extends core.ServiceProvider{static{c(this,"ConsoleServiceProvider");}static priority=992;register(){M.init(this.app);}};var Z=[http.HttpServiceProvider,config.ConfigServiceProvider,database.DatabaseServiceProvider,$];var j=class{static{c(this,"default");}async bootstrap(){let u=new core.Application(process.cwd());u.registerProviders(Z),await u.registerConfiguredProviders(),await u.boot(),new events.EventEmitter().once("SIGINT",()=>process.exit(0)),process.on("SIGINT",()=>{process.exit(0);}),process.on("SIGTERM",()=>{process.exit(0);});}};new j().bootstrap();
|
package/bin/run.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {EventEmitter}from'events';import {
|
|
2
|
+
import {ServiceProvider,Application}from'@h3ravel/core';import {EventEmitter}from'events';import {ConfigServiceProvider}from'@h3ravel/config';import {DatabaseServiceProvider}from'@h3ravel/database';import {access,readFile,writeFile,mkdir}from'fs/promises';import d from'chalk';import g,{resolve,dirname}from'path';import {existsSync,statSync,readdirSync}from'fs';import te from'dayjs';import {arquebus}from'@h3ravel/arquebus';import {spawn}from'child_process';import {program}from'commander';import {HttpServiceProvider}from'@h3ravel/http';var K=Object.defineProperty;var c=(u,e)=>K(u,"name",{value:e,configurable:true});function F(u,e){let t=resolve(".",u),s;for(statSync(t).isDirectory()||(t=dirname(t));;){if(s=e(t,readdirSync(t)),s)return resolve(t,s);if(t=dirname(s=t),s===t)break}}c(F,"default");var Y=g.join,f=class{static{c(this,"Utils");}static textFormat(e,t){return String(e).split(":").map((s,a,r)=>a==0&&r.length>1?t(" "+s+": "):s).join("")}static output(){return {success:c((e,t=false)=>{console.log(d.green("\u2713"),this.textFormat(e,d.bgGreen),`
|
|
3
3
|
`),t&&process.exit(0);},"success"),info:c((e,t=false)=>{console.log(d.blue("\u2139"),this.textFormat(e,d.bgBlue),`
|
|
4
4
|
`),t&&process.exit(0);},"info"),error:c((e,t=true)=>{e instanceof Error?(e.message&&console.error(d.red("\u2716"),this.textFormat("ERROR:"+e.message,d.bgRed)),console.error(d.red(`${e.detail?`${e.detail}
|
|
5
5
|
`:""}${e.stack}`),`
|
|
6
6
|
`)):console.error(d.red("\u2716"),this.textFormat(e,d.bgRed),`
|
|
7
|
-
`),t&&process.exit(1);},"error"),split:c((e,t,s,
|
|
7
|
+
`),t&&process.exit(1);},"error"),split:c((e,t,s,a=false)=>{s??="info";let r={success:d.bgGreen,info:d.bgBlue,error:d.bgRed},i=/\x1b\[\d+m/g,n=Math.min(process.stdout.columns,100),o=Math.max(n-e.replace(i,"").length-t.replace(i,"").length-10,0);console.log(this.textFormat(e,r[s]),d.gray(".".repeat(o)),t),a&&process.exit(0);},"split"),quiet:c(()=>{process.exit(0);},"quiet")}}static findModulePkg(e,t){let s=e.replace(/\\/g,"/").split("/"),a="";s.length>0&&s[0][0]==="@"&&(a+=s.shift()+"/"),a+=s.shift();let r=g.join(t??process.cwd(),"node_modules",a),i=this.findUpConfig(r,"package",["json"]);if(i)return g.join(g.dirname(i),s.join("/"))}static async getMigrationPaths(e,t,s,a){return a?[Y(e,a)]:[...t.getPaths(),Y(e,s)]}static twoColumnDetail(e,t){let s=/\x1b\[\d+m/g,a=Math.min(process.stdout.columns,100),r=Math.max(a-e.replace(s,"").length-t.replace(s,"").length-10,0);return console.log(e,d.gray(".".repeat(r)),t)}static async fileExists(e){try{return await access(e),!0}catch{return false}}static findUpConfig(e,t,s){return F(e,(a,r)=>{for(let i of s){let n=`${t}.${i}`;if(r.includes(n))return n}return false})}},J=class D{static{c(this,"TableGuesser");}static CREATE_PATTERNS=[/^create_(\w+)_table$/,/^create_(\w+)$/];static CHANGE_PATTERNS=[/.+_(to|from|in)_(\w+)_table$/,/.+_(to|from|in)_(\w+)$/];static guess(e){for(let t of D.CREATE_PATTERNS){let s=e.match(t);if(s)return [s[1],true]}for(let t of D.CHANGE_PATTERNS){let s=e.match(t);if(s)return [s[2],false]}return []}};var k=class{static{c(this,"Command");}app;kernel;constructor(e,t){this.app=e,this.kernel=t;}signature;dictionary={};description;input={options:{},arguments:{}};async handle(...e){}setApplication(e){this.app=e;}setInput(e,t,s,a){this.dictionary=a,this.input.options=e,this.input.arguments=s.map((r,i)=>({[r.name()]:t[i]})).reduce((r,i)=>Object.assign(r,i),{});}getSignature(){return this.signature}getDescription(){return this.description}option(e,t){return this.input.options[e]??t}options(e){return e?this.input.options[e]:this.input.options}argument(e,t){return this.input.arguments[e]??t}arguments(){return this.input.arguments}};var S=class extends k{static{c(this,"MakeCommand");}signature=`#make:
|
|
8
8
|
{controller : Generates a new controller class. | {--a|api : Generate an API resource controller} | {--force : Overide existing controller.} }
|
|
9
9
|
{resource : Generates a new API resource class.}
|
|
10
10
|
{migration : Generates a new database migration class. | {--l|type=ts : The file type to generate} | {--t|table : The table to migrate} | {--c|create : The table to be created} }
|
|
@@ -12,7 +12,7 @@ import {EventEmitter}from'events';import {ServiceProvider,Application}from'@h3ra
|
|
|
12
12
|
{seeder : Generates a new database seeder class.}
|
|
13
13
|
{model : Generates a new Arquebus model class. | {--t|type=ts : The file type to generate}}
|
|
14
14
|
{^name : The name of the [name] to generate}
|
|
15
|
-
`;description="Generate component classes";async handle(){let e=this.dictionary.baseCommand,t={controller:"makeController",resource:"makeResource",migration:"makeMigration",factory:"makeFactory",seeder:"makeSeeder",model:"makeModel"};try{await this?.[t[e]]();}catch(s){this.kernel.output.error(s);}}async makeController(){let e=this.option("api")?"-resource":"",t=this.argument("name"),s=this.option("force"),
|
|
15
|
+
`;description="Generate component classes";async handle(){let e=this.dictionary.baseCommand,t={controller:"makeController",resource:"makeResource",migration:"makeMigration",factory:"makeFactory",seeder:"makeSeeder",model:"makeModel"};try{await this?.[t[e]]();}catch(s){this.kernel.output.error(s);}}async makeController(){let e=this.option("api")?"-resource":"",t=this.argument("name"),s=this.option("force"),a=g.join(app_path("Http/Controllers"),t+".ts"),r=f.findModulePkg("@h3ravel/http",this.kernel.cwd)??"",i=g.join(r,`dist/stubs/controller${e}.stub`);!s&&existsSync(a)&&this.kernel.output.error(`ERORR: ${t} controller already exists`);let n=await readFile(i,"utf-8");n=n.replace(/{{ name }}/g,t),await writeFile(a,n),this.kernel.output.split("INFO: Controller Created",d.gray(g.basename(a)));}makeResource(){this.kernel.output.success("Resource support is not yet available");}async makeMigration(){let e=this.argument("name"),t=te().format("YYYY_MM_DD_HHmmss"),s=g.join(database_path("migrations"),`${t}_${e}.ts`),a=f.findModulePkg("@h3ravel/database",this.kernel.cwd)??"",r=this.option("create",false),i=this.option("table");if(!i&&typeof r=="string"&&(i=r,r=true),!i){let l=J.guess(e);i=l[0],r=!!l[1];}let n=g.join(a,this.getMigrationStubName(i,r)),o=await readFile(n,"utf-8");i!==null&&(o=o.replace(/DummyTable|{{\s*table\s*}}/g,i)),this.kernel.output.info("INFO: Creating Migration"),await this.kernel.ensureDirectoryExists(g.dirname(s)),await writeFile(s,o),this.kernel.output.split("INFO: Migration Created",d.gray(g.basename(s)));}makeFactory(){this.kernel.output.success("Factory support is not yet available");}makeSeeder(){this.kernel.output.success("Seeder support is not yet available");}async makeModel(){let e=this.option("type","ts"),t=this.argument("name"),s=g.join(app_path("Models"),t.toLowerCase()+"."+e),a=f.findModulePkg("@h3ravel/database",this.kernel.cwd)??"",r=g.join(a,`dist/stubs/model-${e}.stub`),i=await readFile(r,"utf-8");i=i.replace(/{{ name }}/g,t),await writeFile(s,i),this.kernel.output.split("INFO: Model Created",d.gray(g.basename(s)));}getMigrationStubName(e,t=false,s="ts"){let a;return e?t?a=`migration.create-${s}.stub`:a=`migration.update-${s}.stub`:a=`migration-${s}.stub`,"dist/stubs/"+a}};var I=class extends k{static{c(this,"MigrateCommand");}signature=`migrate:
|
|
16
16
|
{fresh : Drop all tables and re-run all migrations.}
|
|
17
17
|
{install : Create the migration repository.}
|
|
18
18
|
{refresh : Reset and re-run all migrations.}
|
|
@@ -21,6 +21,6 @@ import {EventEmitter}from'events';import {ServiceProvider,Application}from'@h3ra
|
|
|
21
21
|
{status : Show the status of each migration.}
|
|
22
22
|
{publish : Publish any migration files from installed packages.}
|
|
23
23
|
{^--s|seed : Seed the database}
|
|
24
|
-
`;description="Run all pending migrations.";async handle(){let e=this.dictionary.name??this.dictionary.baseCommand;await this?.[{migrate:"migrateRun",fresh:"migrateFresh",install:"migrateInstall",refresh:"migrateRefresh",reset:"migrateReset",rollback:"migrateRollback",status:"migrateStatus",publish:"migratePublish"}[e]]();}async migrateRun(){this.kernel.output.success("Running migrations are not yet supported.");}async migrateFresh(){this.kernel.output.success("Drop all tables and re-run all migrations.");}async migrateInstall(){this.kernel.output.success("Create the migration repository.");}async migrateRefresh(){this.kernel.output.success("Resetting and re-running migrations is not yet supported.");}async migrateReset(){this.kernel.output.success("Rolling back all migration is not yet supported.");}async migrateRollback(){this.kernel.output.success("Rolling back the last migration is not yet supported.");}async migrateStatus(){app_path();console.log(arquebus.connection()),this.kernel.output.success("Show the status of each migration.");}async migratePublish(){this.kernel.output.success("Publish any migration files from installed packages.");}};var
|
|
25
|
-
`).map(
|
|
26
|
-
${t}`),program.command("init").description("Initialize H3ravel.").action(async()=>{this.output.success("Initialized: H3ravel has been initialized!");});for(let s=0;s<this.commands.length;s++){let
|
|
24
|
+
`;description="Run all pending migrations.";async handle(){let e=this.dictionary.name??this.dictionary.baseCommand;await this?.[{migrate:"migrateRun",fresh:"migrateFresh",install:"migrateInstall",refresh:"migrateRefresh",reset:"migrateReset",rollback:"migrateRollback",status:"migrateStatus",publish:"migratePublish"}[e]]();}async migrateRun(){this.kernel.output.success("Running migrations are not yet supported.");}async migrateFresh(){this.kernel.output.success("Drop all tables and re-run all migrations.");}async migrateInstall(){this.kernel.output.success("Create the migration repository.");}async migrateRefresh(){this.kernel.output.success("Resetting and re-running migrations is not yet supported.");}async migrateReset(){this.kernel.output.success("Rolling back all migration is not yet supported.");}async migrateRollback(){this.kernel.output.success("Rolling back the last migration is not yet supported.");}async migrateStatus(){app_path();console.log(arquebus.connection()),this.kernel.output.success("Show the status of each migration.");}async migratePublish(){this.kernel.output.success("Publish any migration files from installed packages.");}};var E=class extends k{static{c(this,"ServeCommand");}signature="serve";description="Start the Developement Server";async handle(){try{await this.serve();}catch(e){this.kernel.output.error(e);}}async serve(){let e=spawn("tsup-node",{stdio:"inherit",shell:true,env:Object.assign({},process.env,{NODE_ENV:"development"}),detached:true}),t=c(()=>{console.log(111111),e.pid&&process.kill(e.pid,"SIGTERM");},"cleanup");process.on("SIGINT",()=>e.kill("SIGINT")),process.on("SIGTERM",()=>e.kill("SIGTERM")),process.on("SIGINT",()=>{t(),process.exit(0);}),process.on("SIGTERM",()=>{t(),process.exit(0);});}};var T=class u{static{c(this,"Signature");}static parseOptions(e){let t=[],s=/\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g,a;for(;(a=s.exec(e))!==null;){let r=a[1][0]==="^"||/:[#^]/.test(a[1]),i=(["#","^"].includes(a[1][0])||/:[#^]/.test(a[1]))&&!r,n=a[1].trim().replace(/[#^]/,""),o=n.indexOf(":");if(o===-1){t.push({name:n});continue}let l=n.substring(0,o).trim(),m=n.substring(o+1).trim(),x=m,v,O=m.indexOf("|");if(O!==-1){x=m.substring(0,O).trim();let p=m.substring(O+1).trim().replace(/^\{/,"").trim();v=u.parseOptions("{"+p+"}");}else x=x.trim();let h=l,C=/[^a-zA-Z0-9_|-]/.test(h),G=false;h.endsWith("?*")?(C=false,G=true,h=h.slice(0,-2)):h.endsWith("*")?(G=true,h=h.slice(0,-1)):h.endsWith("?")&&(C=false,h=h.slice(0,-1));let A=h.startsWith("--"),w,P;if(A){let z=h.split("|").map(p=>p.trim());w=[];for(let p of z){p.startsWith("--")&&p.slice(2).length===1?p="-"+p.slice(2):p.startsWith("-")&&!p.startsWith("--")&&p.slice(1).length>1?p="--"+p.slice(1):!p.startsWith("-")&&p.slice(1).length>1&&(p="--"+p);let _=p.indexOf("=");if(_!==-1){w.push(p.substring(0,_));let b=p.substring(_+1);b==="*"?P=[]:b==="true"||b==="false"||!b&&!C?P=b==="true":isNaN(Number(b))?P=b:P=Number(b);}else w.push(p);}}t.push({name:A?w[w.length-1]:h,required:C,multiple:G,description:x,flags:w,shared:r,isFlag:A,isHidden:i,defaultValue:P,nestedOptions:v});}return t}static parseSignature(e,t){let s=e.split(`
|
|
25
|
+
`).map(m=>m.trim()).filter(m=>m.length>0),a=["#","^"].includes(s[0][0])||/:[#^]/.test(s[0]),r=s[0].replace(/[^\w=:-]/g,""),i=t.getDescription(),n=r.endsWith(":"),o=s.slice(1).join(" "),l=u.parseOptions(o);return n?{baseCommand:r.slice(0,-1),isNamespaceCommand:n,subCommands:l.filter(m=>!m.flags&&!m.isHidden),description:i,commandClass:t,options:l.filter(m=>!!m.flags),isHidden:a}:{baseCommand:r,isNamespaceCommand:n,options:l,description:i,commandClass:t,isHidden:a}}};var N=class u{static{c(this,"Musket");}app;kernel;output=f.output();commands=[];constructor(e,t){this.app=e,this.kernel=t;}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new E(this.app,this.kernel),new S(this.app,this.kernel),new I(this.app,this.kernel)].forEach(t=>this.addCommand(t));}async loadDiscoveredCommands(){[].forEach(t=>this.addCommand(t));}addCommand(e){this.commands.push(T.parseSignature(e.getSignature(),e));}initialize(){let e=["H3ravel Version:",d.green(this.kernel.consolePackage.version)].join(" "),t=["Musket Version:",d.green(this.kernel.modulePackage.version||"None")].join(" ");program.name("musket").version(`${e}
|
|
26
|
+
${t}`),program.command("init").description("Initialize H3ravel.").action(async()=>{this.output.success("Initialized: H3ravel has been initialized!");});for(let s=0;s<this.commands.length;s++){let a=this.commands[s],r=a.commandClass;if(a.isNamespaceCommand&&a.subCommands){let i=a.isHidden?program:program.command(a.baseCommand).description(a.description??"").action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,a),await r.handle();});(a.options?.length??0)>0&&a.options?.filter((n,o,l)=>l.findIndex(m=>m.name===n.name)===o).forEach(n=>{this.makeOption(n,i);}),a.subCommands.filter((n,o,l)=>!n.shared&&l.findIndex(m=>m.name===n.name)===o).forEach(n=>{let o=program.command(`${a.baseCommand}:${n.name}`).description(n.description||"").action(async()=>{r.setInput(o.opts(),o.args,o.registeredArguments,n),await r.handle();});a.subCommands?.filter(l=>l.shared).forEach(l=>{this.makeOption(l,o,false,n);}),a.options?.filter(l=>l.shared).forEach(l=>{this.makeOption(l,o,false,n);}),n.nestedOptions&&n.nestedOptions.filter((l,m,x)=>x.findIndex(v=>v.name===l.name)===m).forEach(l=>{this.makeOption(l,o);});});}else {let i=program.command(a.baseCommand).description(a.description??"");a?.options?.filter((n,o,l)=>l.findIndex(m=>m.name===n.name)===o).forEach(n=>{this.makeOption(n,i,true);}),i.action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,a),await r.handle();});}}return program}makeOption(e,t,s,a){let r=e.description?.replace(/\[(\w+)\]/g,(n,o)=>a?.[o]??`[${o}]`)??"",i=e.name.replaceAll("-","");if(e.isFlag)if(s){let n=e.flags?.map(o=>o.length===1?`-${o}`:`--${o}`).join(", ");t.option(n||"",r,String(e.defaultValue)||void 0);}else t.option(e.flags?.join(", ")+(e.required?` <${i}>`:""),r,e.defaultValue);else t.argument(e.required?`<${e.name}>`:`[${e.name}]`,r,e.defaultValue);}static async parse(e){return (await new u(e.app,e).build()).parseAsync()}};var M=class u{static{c(this,"Kernel");}app;cwd;output=f.output();basePath="";modulePath;consolePath;modulePackage;consolePackage;constructor(e,t){this.app=e;}static init(e){let t=new u(e);Promise.all([t.loadRequirements()]).then(([s])=>s.run());}async run(){await N.parse(this),process.exit(0);}async ensureDirectoryExists(e){await mkdir(e,{recursive:true});}async loadRequirements(){this.cwd=g.join(process.cwd(),this.basePath),this.modulePath=f.findModulePkg("@h3ravel/core",this.cwd)??"",this.consolePath=f.findModulePkg("@h3ravel/console",this.cwd)??"";try{this.modulePackage=await import(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}};var $=class extends ServiceProvider{static{c(this,"ConsoleServiceProvider");}static priority=992;register(){M.init(this.app);}};var Z=[HttpServiceProvider,ConfigServiceProvider,DatabaseServiceProvider,$];var j=class{static{c(this,"default");}async bootstrap(){let u=new Application(process.cwd());u.registerProviders(Z),await u.registerConfiguredProviders(),await u.boot(),new EventEmitter().once("SIGINT",()=>process.exit(0)),process.on("SIGINT",()=>{process.exit(0);}),process.on("SIGTERM",()=>{process.exit(0);});}};new j().bootstrap();
|
package/dist/IO/app.cjs
CHANGED
|
@@ -37,6 +37,10 @@ module.exports = __toCommonJS(app_exports);
|
|
|
37
37
|
var import_core2 = require("@h3ravel/core");
|
|
38
38
|
var import_node_events = require("events");
|
|
39
39
|
|
|
40
|
+
// src/IO/providers.ts
|
|
41
|
+
var import_config = require("@h3ravel/config");
|
|
42
|
+
var import_database = require("@h3ravel/database");
|
|
43
|
+
|
|
40
44
|
// src/Utils.ts
|
|
41
45
|
var import_promises = require("fs/promises");
|
|
42
46
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
@@ -561,7 +565,7 @@ var ServeCommand = class extends Command {
|
|
|
561
565
|
detached: true
|
|
562
566
|
});
|
|
563
567
|
const cleanup = /* @__PURE__ */ __name(() => {
|
|
564
|
-
console.log(
|
|
568
|
+
console.log(111111);
|
|
565
569
|
if (child.pid) {
|
|
566
570
|
process.kill(child.pid, "SIGTERM");
|
|
567
571
|
}
|
|
@@ -889,10 +893,6 @@ var Kernel = class _Kernel {
|
|
|
889
893
|
}
|
|
890
894
|
};
|
|
891
895
|
|
|
892
|
-
// src/IO/providers.ts
|
|
893
|
-
var import_config = require("@h3ravel/config");
|
|
894
|
-
var import_database = require("@h3ravel/database");
|
|
895
|
-
|
|
896
896
|
// src/Providers/ConsoleServiceProvider.ts
|
|
897
897
|
var import_core = require("@h3ravel/core");
|
|
898
898
|
var ConsoleServiceProvider = class extends import_core.ServiceProvider {
|
|
@@ -906,7 +906,9 @@ var ConsoleServiceProvider = class extends import_core.ServiceProvider {
|
|
|
906
906
|
};
|
|
907
907
|
|
|
908
908
|
// src/IO/providers.ts
|
|
909
|
+
var import_http = require("@h3ravel/http");
|
|
909
910
|
var providers_default = [
|
|
911
|
+
import_http.HttpServiceProvider,
|
|
910
912
|
import_config.ConfigServiceProvider,
|
|
911
913
|
import_database.DatabaseServiceProvider,
|
|
912
914
|
ConsoleServiceProvider
|
|
@@ -922,7 +924,6 @@ var app_default = class {
|
|
|
922
924
|
app.registerProviders(providers_default);
|
|
923
925
|
await app.registerConfiguredProviders();
|
|
924
926
|
await app.boot();
|
|
925
|
-
new Kernel(app);
|
|
926
927
|
new import_node_events.EventEmitter().once("SIGINT", () => process.exit(0));
|
|
927
928
|
process.on("SIGINT", () => {
|
|
928
929
|
process.exit(0);
|
package/dist/IO/app.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
app_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-MAQAT3PU.js";
|
|
4
|
+
import "../chunk-P7M5PEDY.js";
|
|
5
|
+
import "../chunk-U6TOLKGJ.js";
|
|
6
|
+
import "../chunk-M4ZRDJJ2.js";
|
|
7
|
+
import "../chunk-XCOSZXAE.js";
|
|
8
8
|
import "../chunk-FOSDCKCR.js";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-2O2AYFAG.js";
|
|
10
10
|
import "../chunk-3FVPHQCH.js";
|
|
11
11
|
import "../chunk-PMV4TMFS.js";
|
|
12
12
|
import "../chunk-POF4JGTX.js";
|
package/dist/IO/providers.cjs
CHANGED
|
@@ -561,7 +561,7 @@ var ServeCommand = class extends Command {
|
|
|
561
561
|
detached: true
|
|
562
562
|
});
|
|
563
563
|
const cleanup = /* @__PURE__ */ __name(() => {
|
|
564
|
-
console.log(
|
|
564
|
+
console.log(111111);
|
|
565
565
|
if (child.pid) {
|
|
566
566
|
process.kill(child.pid, "SIGTERM");
|
|
567
567
|
}
|
|
@@ -902,7 +902,9 @@ var ConsoleServiceProvider = class extends import_core.ServiceProvider {
|
|
|
902
902
|
};
|
|
903
903
|
|
|
904
904
|
// src/IO/providers.ts
|
|
905
|
+
var import_http = require("@h3ravel/http");
|
|
905
906
|
var providers_default = [
|
|
907
|
+
import_http.HttpServiceProvider,
|
|
906
908
|
import_config.ConfigServiceProvider,
|
|
907
909
|
import_database.DatabaseServiceProvider,
|
|
908
910
|
ConsoleServiceProvider
|
package/dist/IO/providers.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
providers_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-P7M5PEDY.js";
|
|
4
|
+
import "../chunk-U6TOLKGJ.js";
|
|
5
|
+
import "../chunk-M4ZRDJJ2.js";
|
|
6
|
+
import "../chunk-XCOSZXAE.js";
|
|
7
7
|
import "../chunk-FOSDCKCR.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-2O2AYFAG.js";
|
|
9
9
|
import "../chunk-3FVPHQCH.js";
|
|
10
10
|
import "../chunk-PMV4TMFS.js";
|
|
11
11
|
import "../chunk-POF4JGTX.js";
|
package/dist/Kernel.cjs
CHANGED
package/dist/Kernel.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Kernel
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-M4ZRDJJ2.js";
|
|
4
|
+
import "./chunk-XCOSZXAE.js";
|
|
5
5
|
import "./chunk-FOSDCKCR.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-2O2AYFAG.js";
|
|
7
7
|
import "./chunk-3FVPHQCH.js";
|
|
8
8
|
import "./chunk-PMV4TMFS.js";
|
|
9
9
|
import "./chunk-POF4JGTX.js";
|
package/dist/Musket.cjs
CHANGED
package/dist/Musket.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Musket
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XCOSZXAE.js";
|
|
4
4
|
import "./chunk-FOSDCKCR.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-2O2AYFAG.js";
|
|
6
6
|
import "./chunk-3FVPHQCH.js";
|
|
7
7
|
import "./chunk-PMV4TMFS.js";
|
|
8
8
|
import "./chunk-POF4JGTX.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConsoleServiceProvider
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-U6TOLKGJ.js";
|
|
4
|
+
import "../chunk-M4ZRDJJ2.js";
|
|
5
|
+
import "../chunk-XCOSZXAE.js";
|
|
6
6
|
import "../chunk-FOSDCKCR.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-2O2AYFAG.js";
|
|
8
8
|
import "../chunk-3FVPHQCH.js";
|
|
9
9
|
import "../chunk-PMV4TMFS.js";
|
|
10
10
|
import "../chunk-POF4JGTX.js";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Command
|
|
3
|
+
} from "./chunk-O45AB4MX.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-SHUYVCID.js";
|
|
7
|
+
|
|
8
|
+
// src/Commands/ServeCommand.ts
|
|
9
|
+
import { spawn } from "child_process";
|
|
10
|
+
var ServeCommand = class extends Command {
|
|
11
|
+
static {
|
|
12
|
+
__name(this, "ServeCommand");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The name and signature of the console command.
|
|
16
|
+
*
|
|
17
|
+
* @var string
|
|
18
|
+
*/
|
|
19
|
+
signature = "serve";
|
|
20
|
+
/**
|
|
21
|
+
* The console command description.
|
|
22
|
+
*
|
|
23
|
+
* @var string
|
|
24
|
+
*/
|
|
25
|
+
description = "Start the Developement Server";
|
|
26
|
+
async handle() {
|
|
27
|
+
try {
|
|
28
|
+
await this.serve();
|
|
29
|
+
} catch (e) {
|
|
30
|
+
this.kernel.output.error(e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async serve() {
|
|
34
|
+
const child = spawn("tsup-node", {
|
|
35
|
+
stdio: "inherit",
|
|
36
|
+
shell: true,
|
|
37
|
+
env: Object.assign({}, process.env, {
|
|
38
|
+
NODE_ENV: "development"
|
|
39
|
+
}),
|
|
40
|
+
detached: true
|
|
41
|
+
});
|
|
42
|
+
const cleanup = /* @__PURE__ */ __name(() => {
|
|
43
|
+
console.log(111111);
|
|
44
|
+
if (child.pid) {
|
|
45
|
+
process.kill(child.pid, "SIGTERM");
|
|
46
|
+
}
|
|
47
|
+
}, "cleanup");
|
|
48
|
+
process.on("SIGINT", () => child.kill("SIGINT"));
|
|
49
|
+
process.on("SIGTERM", () => child.kill("SIGTERM"));
|
|
50
|
+
process.on("SIGINT", () => {
|
|
51
|
+
cleanup();
|
|
52
|
+
process.exit(0);
|
|
53
|
+
});
|
|
54
|
+
process.on("SIGTERM", () => {
|
|
55
|
+
cleanup();
|
|
56
|
+
process.exit(0);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
ServeCommand
|
|
63
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConsoleServiceProvider
|
|
3
|
+
} from "./chunk-U6TOLKGJ.js";
|
|
4
|
+
|
|
5
|
+
// src/IO/providers.ts
|
|
6
|
+
import { DatabaseServiceProvider } from "@h3ravel/database";
|
|
7
|
+
var providers_default = [
|
|
8
|
+
DatabaseServiceProvider,
|
|
9
|
+
ConsoleServiceProvider
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
providers_default
|
|
14
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
providers_default
|
|
3
|
+
} from "./chunk-E5XIGIEX.js";
|
|
4
|
+
import {
|
|
5
|
+
Kernel
|
|
6
|
+
} from "./chunk-URLTFJET.js";
|
|
7
|
+
import {
|
|
8
|
+
__name
|
|
9
|
+
} from "./chunk-SHUYVCID.js";
|
|
10
|
+
|
|
11
|
+
// src/IO/app.ts
|
|
12
|
+
import { Application } from "@h3ravel/core";
|
|
13
|
+
import { EventEmitter } from "events";
|
|
14
|
+
var app_default = class {
|
|
15
|
+
static {
|
|
16
|
+
__name(this, "default");
|
|
17
|
+
}
|
|
18
|
+
async bootstrap() {
|
|
19
|
+
const app = new Application(process.cwd());
|
|
20
|
+
app.registerProviders(providers_default);
|
|
21
|
+
await app.registerConfiguredProviders();
|
|
22
|
+
await app.boot();
|
|
23
|
+
new Kernel(app);
|
|
24
|
+
new EventEmitter().once("SIGINT", () => process.exit(0));
|
|
25
|
+
process.on("SIGINT", () => {
|
|
26
|
+
process.exit(0);
|
|
27
|
+
});
|
|
28
|
+
process.on("SIGTERM", () => {
|
|
29
|
+
process.exit(0);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
app_default
|
|
36
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConsoleServiceProvider
|
|
3
|
+
} from "./chunk-IGEFNODG.js";
|
|
4
|
+
|
|
5
|
+
// src/IO/providers.ts
|
|
6
|
+
import { DatabaseServiceProvider } from "@h3ravel/database";
|
|
7
|
+
var providers_default = [
|
|
8
|
+
DatabaseServiceProvider,
|
|
9
|
+
ConsoleServiceProvider
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
providers_default
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConsoleServiceProvider
|
|
3
|
+
} from "./chunk-U6TOLKGJ.js";
|
|
4
|
+
|
|
5
|
+
// src/IO/providers.ts
|
|
6
|
+
import { ConfigServiceProvider } from "@h3ravel/config";
|
|
7
|
+
import { DatabaseServiceProvider } from "@h3ravel/database";
|
|
8
|
+
var providers_default = [
|
|
9
|
+
ConfigServiceProvider,
|
|
10
|
+
DatabaseServiceProvider,
|
|
11
|
+
ConsoleServiceProvider
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
providers_default
|
|
16
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
providers_default
|
|
3
|
+
} from "./chunk-P7M5PEDY.js";
|
|
4
|
+
import {
|
|
5
|
+
Kernel
|
|
6
|
+
} from "./chunk-M4ZRDJJ2.js";
|
|
7
|
+
import {
|
|
8
|
+
__name
|
|
9
|
+
} from "./chunk-SHUYVCID.js";
|
|
10
|
+
|
|
11
|
+
// src/IO/app.ts
|
|
12
|
+
import { Application } from "@h3ravel/core";
|
|
13
|
+
import { EventEmitter } from "events";
|
|
14
|
+
var app_default = class {
|
|
15
|
+
static {
|
|
16
|
+
__name(this, "default");
|
|
17
|
+
}
|
|
18
|
+
async bootstrap() {
|
|
19
|
+
const app = new Application(process.cwd());
|
|
20
|
+
app.registerProviders(providers_default);
|
|
21
|
+
await app.registerConfiguredProviders();
|
|
22
|
+
await app.boot();
|
|
23
|
+
new Kernel(app);
|
|
24
|
+
new EventEmitter().once("SIGINT", () => process.exit(0));
|
|
25
|
+
process.on("SIGINT", () => {
|
|
26
|
+
process.exit(0);
|
|
27
|
+
});
|
|
28
|
+
process.on("SIGTERM", () => {
|
|
29
|
+
process.exit(0);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
app_default
|
|
36
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Musket
|
|
3
|
+
} from "./chunk-XCOSZXAE.js";
|
|
4
|
+
import {
|
|
5
|
+
Utils
|
|
6
|
+
} from "./chunk-POF4JGTX.js";
|
|
7
|
+
import {
|
|
8
|
+
__name
|
|
9
|
+
} from "./chunk-SHUYVCID.js";
|
|
10
|
+
|
|
11
|
+
// src/Kernel.ts
|
|
12
|
+
import { mkdir } from "fs/promises";
|
|
13
|
+
import path from "path";
|
|
14
|
+
var Kernel = class _Kernel {
|
|
15
|
+
static {
|
|
16
|
+
__name(this, "Kernel");
|
|
17
|
+
}
|
|
18
|
+
app;
|
|
19
|
+
cwd;
|
|
20
|
+
output = Utils.output();
|
|
21
|
+
basePath = "";
|
|
22
|
+
modulePath;
|
|
23
|
+
consolePath;
|
|
24
|
+
modulePackage;
|
|
25
|
+
consolePackage;
|
|
26
|
+
constructor(app, basePath) {
|
|
27
|
+
this.app = app;
|
|
28
|
+
}
|
|
29
|
+
static init(app) {
|
|
30
|
+
const instance = new _Kernel(app);
|
|
31
|
+
Promise.all([
|
|
32
|
+
instance.loadRequirements()
|
|
33
|
+
]).then(([e]) => e.run());
|
|
34
|
+
}
|
|
35
|
+
async run() {
|
|
36
|
+
await Musket.parse(this);
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
async ensureDirectoryExists(dir) {
|
|
40
|
+
await mkdir(dir, {
|
|
41
|
+
recursive: true
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async loadRequirements() {
|
|
45
|
+
this.cwd = path.join(process.cwd(), this.basePath);
|
|
46
|
+
this.modulePath = Utils.findModulePkg("@h3ravel/core", this.cwd) ?? "";
|
|
47
|
+
this.consolePath = Utils.findModulePkg("@h3ravel/console", this.cwd) ?? "";
|
|
48
|
+
try {
|
|
49
|
+
this.modulePackage = await import(path.join(this.modulePath, "package.json"));
|
|
50
|
+
} catch {
|
|
51
|
+
this.modulePackage = {
|
|
52
|
+
version: "N/A"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
this.consolePackage = await import(path.join(this.consolePath, "package.json"));
|
|
57
|
+
} catch {
|
|
58
|
+
this.consolePackage = {
|
|
59
|
+
version: "N/A"
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
Kernel
|
|
68
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
providers_default
|
|
3
|
+
} from "./chunk-P7M5PEDY.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-SHUYVCID.js";
|
|
7
|
+
|
|
8
|
+
// src/IO/app.ts
|
|
9
|
+
import { Application } from "@h3ravel/core";
|
|
10
|
+
import { EventEmitter } from "events";
|
|
11
|
+
var app_default = class {
|
|
12
|
+
static {
|
|
13
|
+
__name(this, "default");
|
|
14
|
+
}
|
|
15
|
+
async bootstrap() {
|
|
16
|
+
const app = new Application(process.cwd());
|
|
17
|
+
app.registerProviders(providers_default);
|
|
18
|
+
await app.registerConfiguredProviders();
|
|
19
|
+
await app.boot();
|
|
20
|
+
new EventEmitter().once("SIGINT", () => process.exit(0));
|
|
21
|
+
process.on("SIGINT", () => {
|
|
22
|
+
process.exit(0);
|
|
23
|
+
});
|
|
24
|
+
process.on("SIGTERM", () => {
|
|
25
|
+
process.exit(0);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
app_default
|
|
32
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConsoleServiceProvider
|
|
3
|
+
} from "./chunk-U6TOLKGJ.js";
|
|
4
|
+
|
|
5
|
+
// src/IO/providers.ts
|
|
6
|
+
import { ConfigServiceProvider } from "@h3ravel/config";
|
|
7
|
+
import { DatabaseServiceProvider } from "@h3ravel/database";
|
|
8
|
+
import { HttpServiceProvider } from "@h3ravel/http";
|
|
9
|
+
var providers_default = [
|
|
10
|
+
HttpServiceProvider,
|
|
11
|
+
ConfigServiceProvider,
|
|
12
|
+
DatabaseServiceProvider,
|
|
13
|
+
ConsoleServiceProvider
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
providers_default
|
|
18
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
providers_default
|
|
3
|
+
} from "./chunk-3VCNSA6P.js";
|
|
4
|
+
import {
|
|
5
|
+
Kernel
|
|
6
|
+
} from "./chunk-M4ZRDJJ2.js";
|
|
7
|
+
import {
|
|
8
|
+
__name
|
|
9
|
+
} from "./chunk-SHUYVCID.js";
|
|
10
|
+
|
|
11
|
+
// src/IO/app.ts
|
|
12
|
+
import { Application } from "@h3ravel/core";
|
|
13
|
+
import { EventEmitter } from "events";
|
|
14
|
+
var app_default = class {
|
|
15
|
+
static {
|
|
16
|
+
__name(this, "default");
|
|
17
|
+
}
|
|
18
|
+
async bootstrap() {
|
|
19
|
+
const app = new Application(process.cwd());
|
|
20
|
+
app.registerProviders(providers_default);
|
|
21
|
+
await app.registerConfiguredProviders();
|
|
22
|
+
await app.boot();
|
|
23
|
+
new Kernel(app);
|
|
24
|
+
new EventEmitter().once("SIGINT", () => process.exit(0));
|
|
25
|
+
process.on("SIGINT", () => {
|
|
26
|
+
process.exit(0);
|
|
27
|
+
});
|
|
28
|
+
process.on("SIGTERM", () => {
|
|
29
|
+
process.exit(0);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
app_default
|
|
36
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
providers_default
|
|
3
|
+
} from "./chunk-GXRCTWKL.js";
|
|
4
|
+
import {
|
|
5
|
+
Kernel
|
|
6
|
+
} from "./chunk-M4ZRDJJ2.js";
|
|
7
|
+
import {
|
|
8
|
+
__name
|
|
9
|
+
} from "./chunk-SHUYVCID.js";
|
|
10
|
+
|
|
11
|
+
// src/IO/app.ts
|
|
12
|
+
import { Application } from "@h3ravel/core";
|
|
13
|
+
import { EventEmitter } from "events";
|
|
14
|
+
var app_default = class {
|
|
15
|
+
static {
|
|
16
|
+
__name(this, "default");
|
|
17
|
+
}
|
|
18
|
+
async bootstrap() {
|
|
19
|
+
const app = new Application(process.cwd());
|
|
20
|
+
app.registerProviders(providers_default);
|
|
21
|
+
await app.registerConfiguredProviders();
|
|
22
|
+
await app.boot();
|
|
23
|
+
new Kernel(app);
|
|
24
|
+
new EventEmitter().once("SIGINT", () => process.exit(0));
|
|
25
|
+
process.on("SIGINT", () => {
|
|
26
|
+
process.exit(0);
|
|
27
|
+
});
|
|
28
|
+
process.on("SIGTERM", () => {
|
|
29
|
+
process.exit(0);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
app_default
|
|
36
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Kernel
|
|
3
|
+
} from "./chunk-M4ZRDJJ2.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-SHUYVCID.js";
|
|
7
|
+
|
|
8
|
+
// src/Providers/ConsoleServiceProvider.ts
|
|
9
|
+
import { ServiceProvider } from "@h3ravel/core";
|
|
10
|
+
var ConsoleServiceProvider = class extends ServiceProvider {
|
|
11
|
+
static {
|
|
12
|
+
__name(this, "ConsoleServiceProvider");
|
|
13
|
+
}
|
|
14
|
+
static priority = 992;
|
|
15
|
+
register() {
|
|
16
|
+
Kernel.init(this.app);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
ConsoleServiceProvider
|
|
22
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MigrateCommand
|
|
3
|
+
} from "./chunk-FOSDCKCR.js";
|
|
4
|
+
import {
|
|
5
|
+
ServeCommand
|
|
6
|
+
} from "./chunk-2O2AYFAG.js";
|
|
7
|
+
import {
|
|
8
|
+
Signature
|
|
9
|
+
} from "./chunk-3FVPHQCH.js";
|
|
10
|
+
import {
|
|
11
|
+
MakeCommand
|
|
12
|
+
} from "./chunk-PMV4TMFS.js";
|
|
13
|
+
import {
|
|
14
|
+
Utils
|
|
15
|
+
} from "./chunk-POF4JGTX.js";
|
|
16
|
+
import {
|
|
17
|
+
__name
|
|
18
|
+
} from "./chunk-SHUYVCID.js";
|
|
19
|
+
|
|
20
|
+
// src/Musket.ts
|
|
21
|
+
import chalk from "chalk";
|
|
22
|
+
import { program } from "commander";
|
|
23
|
+
var Musket = class _Musket {
|
|
24
|
+
static {
|
|
25
|
+
__name(this, "Musket");
|
|
26
|
+
}
|
|
27
|
+
app;
|
|
28
|
+
kernel;
|
|
29
|
+
output = Utils.output();
|
|
30
|
+
commands = [];
|
|
31
|
+
constructor(app, kernel) {
|
|
32
|
+
this.app = app;
|
|
33
|
+
this.kernel = kernel;
|
|
34
|
+
}
|
|
35
|
+
async build() {
|
|
36
|
+
this.loadBaseCommands();
|
|
37
|
+
await this.loadDiscoveredCommands();
|
|
38
|
+
return this.initialize();
|
|
39
|
+
}
|
|
40
|
+
loadBaseCommands() {
|
|
41
|
+
const commands = [
|
|
42
|
+
new ServeCommand(this.app, this.kernel),
|
|
43
|
+
new MakeCommand(this.app, this.kernel),
|
|
44
|
+
new MigrateCommand(this.app, this.kernel)
|
|
45
|
+
];
|
|
46
|
+
commands.forEach((e) => this.addCommand(e));
|
|
47
|
+
}
|
|
48
|
+
async loadDiscoveredCommands() {
|
|
49
|
+
const commands = [];
|
|
50
|
+
commands.forEach((e) => this.addCommand(e));
|
|
51
|
+
}
|
|
52
|
+
addCommand(command) {
|
|
53
|
+
this.commands.push(Signature.parseSignature(command.getSignature(), command));
|
|
54
|
+
}
|
|
55
|
+
initialize() {
|
|
56
|
+
const cliVersion = [
|
|
57
|
+
"H3ravel Version:",
|
|
58
|
+
chalk.green(this.kernel.consolePackage.version)
|
|
59
|
+
].join(" ");
|
|
60
|
+
const localVersion = [
|
|
61
|
+
"Musket Version:",
|
|
62
|
+
chalk.green(this.kernel.modulePackage.version || "None")
|
|
63
|
+
].join(" ");
|
|
64
|
+
program.name("musket").version(`${cliVersion}
|
|
65
|
+
${localVersion}`);
|
|
66
|
+
program.command("init").description("Initialize H3ravel.").action(async () => {
|
|
67
|
+
this.output.success(`Initialized: H3ravel has been initialized!`);
|
|
68
|
+
});
|
|
69
|
+
for (let i = 0; i < this.commands.length; i++) {
|
|
70
|
+
const command = this.commands[i];
|
|
71
|
+
const instance = command.commandClass;
|
|
72
|
+
if (command.isNamespaceCommand && command.subCommands) {
|
|
73
|
+
const cmd = command.isHidden ? program : program.command(command.baseCommand).description(command.description ?? "").action(async () => {
|
|
74
|
+
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command);
|
|
75
|
+
await instance.handle();
|
|
76
|
+
});
|
|
77
|
+
if ((command.options?.length ?? 0) > 0) {
|
|
78
|
+
command.options?.filter((v, i2, a) => a.findIndex((t) => t.name === v.name) === i2).forEach((opt) => {
|
|
79
|
+
this.makeOption(opt, cmd);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
command.subCommands.filter((v, i2, a) => !v.shared && a.findIndex((t) => t.name === v.name) === i2).forEach((sub) => {
|
|
83
|
+
const cmd2 = program.command(`${command.baseCommand}:${sub.name}`).description(sub.description || "").action(async () => {
|
|
84
|
+
instance.setInput(cmd2.opts(), cmd2.args, cmd2.registeredArguments, sub);
|
|
85
|
+
await instance.handle();
|
|
86
|
+
});
|
|
87
|
+
command.subCommands?.filter((e) => e.shared).forEach((opt) => {
|
|
88
|
+
this.makeOption(opt, cmd2, false, sub);
|
|
89
|
+
});
|
|
90
|
+
command.options?.filter((e) => e.shared).forEach((opt) => {
|
|
91
|
+
this.makeOption(opt, cmd2, false, sub);
|
|
92
|
+
});
|
|
93
|
+
if (sub.nestedOptions) {
|
|
94
|
+
sub.nestedOptions.filter((v, i2, a) => a.findIndex((t) => t.name === v.name) === i2).forEach((opt) => {
|
|
95
|
+
this.makeOption(opt, cmd2);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
const cmd = program.command(command.baseCommand).description(command.description ?? "");
|
|
101
|
+
command?.options?.filter((v, i2, a) => a.findIndex((t) => t.name === v.name) === i2).forEach((opt) => {
|
|
102
|
+
this.makeOption(opt, cmd, true);
|
|
103
|
+
});
|
|
104
|
+
cmd.action(async () => {
|
|
105
|
+
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command);
|
|
106
|
+
await instance.handle();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return program;
|
|
111
|
+
}
|
|
112
|
+
makeOption(opt, cmd, parse, parent) {
|
|
113
|
+
const description = opt.description?.replace(/\[(\w+)\]/g, (_, k) => parent?.[k] ?? `[${k}]`) ?? "";
|
|
114
|
+
const type = opt.name.replaceAll("-", "");
|
|
115
|
+
if (opt.isFlag) {
|
|
116
|
+
if (parse) {
|
|
117
|
+
const flags = opt.flags?.map((f) => f.length === 1 ? `-${f}` : `--${f}`).join(", ");
|
|
118
|
+
cmd.option(flags || "", description, String(opt.defaultValue) || void 0);
|
|
119
|
+
} else {
|
|
120
|
+
cmd.option(opt.flags?.join(", ") + (opt.required ? ` <${type}>` : ""), description, opt.defaultValue);
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
cmd.argument(opt.required ? `<${opt.name}>` : `[${opt.name}]`, description, opt.defaultValue);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
static async parse(kernel) {
|
|
127
|
+
return (await new _Musket(kernel.app, kernel).build()).parseAsync();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
Musket
|
|
133
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -566,7 +566,7 @@ var ServeCommand = class extends Command {
|
|
|
566
566
|
detached: true
|
|
567
567
|
});
|
|
568
568
|
const cleanup = /* @__PURE__ */ __name(() => {
|
|
569
|
-
console.log(
|
|
569
|
+
console.log(111111);
|
|
570
570
|
if (child.pid) {
|
|
571
571
|
process.kill(child.pid, "SIGTERM");
|
|
572
572
|
}
|
|
@@ -588,6 +588,10 @@ var ServeCommand = class extends Command {
|
|
|
588
588
|
var import_core2 = require("@h3ravel/core");
|
|
589
589
|
var import_node_events = require("events");
|
|
590
590
|
|
|
591
|
+
// src/IO/providers.ts
|
|
592
|
+
var import_config = require("@h3ravel/config");
|
|
593
|
+
var import_database = require("@h3ravel/database");
|
|
594
|
+
|
|
591
595
|
// src/Signature.ts
|
|
592
596
|
var Signature = class _Signature {
|
|
593
597
|
static {
|
|
@@ -898,10 +902,6 @@ var Kernel = class _Kernel {
|
|
|
898
902
|
}
|
|
899
903
|
};
|
|
900
904
|
|
|
901
|
-
// src/IO/providers.ts
|
|
902
|
-
var import_config = require("@h3ravel/config");
|
|
903
|
-
var import_database = require("@h3ravel/database");
|
|
904
|
-
|
|
905
905
|
// src/Providers/ConsoleServiceProvider.ts
|
|
906
906
|
var import_core = require("@h3ravel/core");
|
|
907
907
|
var ConsoleServiceProvider = class extends import_core.ServiceProvider {
|
|
@@ -915,7 +915,9 @@ var ConsoleServiceProvider = class extends import_core.ServiceProvider {
|
|
|
915
915
|
};
|
|
916
916
|
|
|
917
917
|
// src/IO/providers.ts
|
|
918
|
+
var import_http = require("@h3ravel/http");
|
|
918
919
|
var providers_default = [
|
|
920
|
+
import_http.HttpServiceProvider,
|
|
919
921
|
import_config.ConfigServiceProvider,
|
|
920
922
|
import_database.DatabaseServiceProvider,
|
|
921
923
|
ConsoleServiceProvider
|
|
@@ -931,7 +933,6 @@ var app_default = class {
|
|
|
931
933
|
app.registerProviders(providers_default);
|
|
932
934
|
await app.registerConfiguredProviders();
|
|
933
935
|
await app.boot();
|
|
934
|
-
new Kernel(app);
|
|
935
936
|
new import_node_events.EventEmitter().once("SIGINT", () => process.exit(0));
|
|
936
937
|
process.on("SIGINT", () => {
|
|
937
938
|
process.exit(0);
|
|
@@ -943,9 +944,7 @@ var app_default = class {
|
|
|
943
944
|
};
|
|
944
945
|
|
|
945
946
|
// src/run.ts
|
|
946
|
-
var import_node_events2 = require("events");
|
|
947
947
|
new app_default().bootstrap();
|
|
948
|
-
new import_node_events2.EventEmitter().once("SIGINT", () => process.exit(0));
|
|
949
948
|
// Annotate the CommonJS export names for ESM import in node:
|
|
950
949
|
0 && (module.exports = {
|
|
951
950
|
Command,
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import "./chunk-NADN2PHB.js";
|
|
2
|
-
import "./chunk-
|
|
3
|
-
import "./chunk-
|
|
4
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-3WHUADTN.js";
|
|
3
|
+
import "./chunk-MAQAT3PU.js";
|
|
4
|
+
import "./chunk-P7M5PEDY.js";
|
|
5
5
|
import {
|
|
6
6
|
ConsoleServiceProvider
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-U6TOLKGJ.js";
|
|
8
8
|
import {
|
|
9
9
|
Kernel
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-M4ZRDJJ2.js";
|
|
11
11
|
import {
|
|
12
12
|
Musket
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XCOSZXAE.js";
|
|
14
14
|
import {
|
|
15
15
|
MigrateCommand
|
|
16
16
|
} from "./chunk-FOSDCKCR.js";
|
|
17
17
|
import {
|
|
18
18
|
ServeCommand
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-2O2AYFAG.js";
|
|
20
20
|
import {
|
|
21
21
|
Signature
|
|
22
22
|
} from "./chunk-3FVPHQCH.js";
|
package/dist/run.cjs
CHANGED
|
@@ -24,13 +24,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
mod
|
|
25
25
|
));
|
|
26
26
|
|
|
27
|
-
// src/run.ts
|
|
28
|
-
var import_node_events2 = require("events");
|
|
29
|
-
|
|
30
27
|
// src/IO/app.ts
|
|
31
28
|
var import_core2 = require("@h3ravel/core");
|
|
32
29
|
var import_node_events = require("events");
|
|
33
30
|
|
|
31
|
+
// src/IO/providers.ts
|
|
32
|
+
var import_config = require("@h3ravel/config");
|
|
33
|
+
var import_database = require("@h3ravel/database");
|
|
34
|
+
|
|
34
35
|
// src/Utils.ts
|
|
35
36
|
var import_promises = require("fs/promises");
|
|
36
37
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
@@ -555,7 +556,7 @@ var ServeCommand = class extends Command {
|
|
|
555
556
|
detached: true
|
|
556
557
|
});
|
|
557
558
|
const cleanup = /* @__PURE__ */ __name(() => {
|
|
558
|
-
console.log(
|
|
559
|
+
console.log(111111);
|
|
559
560
|
if (child.pid) {
|
|
560
561
|
process.kill(child.pid, "SIGTERM");
|
|
561
562
|
}
|
|
@@ -883,10 +884,6 @@ var Kernel = class _Kernel {
|
|
|
883
884
|
}
|
|
884
885
|
};
|
|
885
886
|
|
|
886
|
-
// src/IO/providers.ts
|
|
887
|
-
var import_config = require("@h3ravel/config");
|
|
888
|
-
var import_database = require("@h3ravel/database");
|
|
889
|
-
|
|
890
887
|
// src/Providers/ConsoleServiceProvider.ts
|
|
891
888
|
var import_core = require("@h3ravel/core");
|
|
892
889
|
var ConsoleServiceProvider = class extends import_core.ServiceProvider {
|
|
@@ -900,7 +897,9 @@ var ConsoleServiceProvider = class extends import_core.ServiceProvider {
|
|
|
900
897
|
};
|
|
901
898
|
|
|
902
899
|
// src/IO/providers.ts
|
|
900
|
+
var import_http = require("@h3ravel/http");
|
|
903
901
|
var providers_default = [
|
|
902
|
+
import_http.HttpServiceProvider,
|
|
904
903
|
import_config.ConfigServiceProvider,
|
|
905
904
|
import_database.DatabaseServiceProvider,
|
|
906
905
|
ConsoleServiceProvider
|
|
@@ -916,7 +915,6 @@ var app_default = class {
|
|
|
916
915
|
app.registerProviders(providers_default);
|
|
917
916
|
await app.registerConfiguredProviders();
|
|
918
917
|
await app.boot();
|
|
919
|
-
new Kernel(app);
|
|
920
918
|
new import_node_events.EventEmitter().once("SIGINT", () => process.exit(0));
|
|
921
919
|
process.on("SIGINT", () => {
|
|
922
920
|
process.exit(0);
|
|
@@ -929,4 +927,3 @@ var app_default = class {
|
|
|
929
927
|
|
|
930
928
|
// src/run.ts
|
|
931
929
|
new app_default().bootstrap();
|
|
932
|
-
new import_node_events2.EventEmitter().once("SIGINT", () => process.exit(0));
|
package/dist/run.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./chunk-
|
|
3
|
-
import "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-3WHUADTN.js";
|
|
3
|
+
import "./chunk-MAQAT3PU.js";
|
|
4
|
+
import "./chunk-P7M5PEDY.js";
|
|
5
|
+
import "./chunk-U6TOLKGJ.js";
|
|
6
|
+
import "./chunk-M4ZRDJJ2.js";
|
|
7
|
+
import "./chunk-XCOSZXAE.js";
|
|
8
8
|
import "./chunk-FOSDCKCR.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-2O2AYFAG.js";
|
|
10
10
|
import "./chunk-3FVPHQCH.js";
|
|
11
11
|
import "./chunk-PMV4TMFS.js";
|
|
12
12
|
import "./chunk-POF4JGTX.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/console",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.5",
|
|
4
4
|
"description": "CLI utilities for scaffolding, running migrations, tasks and for H3ravel.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@h3ravel/arquebus": "^0.2.14",
|
|
44
|
-
"@h3ravel/
|
|
45
|
-
"@h3ravel/
|
|
44
|
+
"@h3ravel/support": "^0.9.0",
|
|
45
|
+
"@h3ravel/core": "^1.7.4"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"typescript": "^5.9.2"
|
|
@@ -50,10 +50,11 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@h3ravel/config": "^1.3.7",
|
|
52
52
|
"@h3ravel/database": "^11.0.0",
|
|
53
|
+
"@h3ravel/http": "^11.0.0",
|
|
53
54
|
"@h3ravel/shared": "^0.17.2",
|
|
54
55
|
"chalk": "^5.6.0",
|
|
55
56
|
"commander": "^14.0.0",
|
|
56
|
-
"dayjs": "^1.11.
|
|
57
|
+
"dayjs": "^1.11.14",
|
|
57
58
|
"radashi": "^12.6.2",
|
|
58
59
|
"resolve-from": "^5.0.0"
|
|
59
60
|
},
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
"lint": "eslint . --ext .ts",
|
|
66
67
|
"test": "jest --passWithNoTests",
|
|
67
68
|
"musket": "cross-env TEST=true APP_DEBUG=false tsx --experimental-specifier-resolution=node src/musket",
|
|
68
|
-
"musket:watch": "cross-env TEST=true APP_DEBUG=false tsx watch --experimental-specifier-resolution=node src/musket"
|
|
69
|
+
"musket:watch": "cross-env TEST=true APP_DEBUG=false tsx watch --experimental-specifier-resolution=node src/musket",
|
|
70
|
+
"release:patch": "pnpm build && pnpm version patch && git add . && git commit -m \"version: bump version and publish\" && pnpm publish --tag latest"
|
|
69
71
|
}
|
|
70
72
|
}
|