@h3ravel/console 11.2.0 → 11.3.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 +69 -1
- package/bin/fire.js +69 -1
- package/dist/Utils-CbqNJtIj.d.ts +10 -0
- package/dist/Utils-CxAcuqeI.d.cts +10 -0
- package/dist/Utils-D6ZDNdVG.cjs +33 -0
- package/dist/Utils-D6ZDNdVG.cjs.map +1 -0
- package/dist/Utils-Dn22CO9s.js +21 -0
- package/dist/Utils-Dn22CO9s.js.map +1 -0
- package/dist/Utils.cjs +1 -1
- package/dist/Utils.d.cts +1 -1
- package/dist/Utils.d.ts +1 -1
- package/dist/Utils.js +1 -1
- package/dist/index.cjs +105 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -7
- package/dist/index.d.ts +24 -7
- package/dist/index.js +72 -72
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/Utils-CpiQZ3n9.cjs +0 -122
- package/dist/Utils-CpiQZ3n9.cjs.map +0 -1
- package/dist/Utils-Dvclc4Pc.js +0 -73
- package/dist/Utils-Dvclc4Pc.js.map +0 -1
- package/dist/Utils-cBgwEyTl.d.ts +0 -20
- package/dist/Utils-rIdzILgO.d.cts +0 -20
package/bin/fire.cjs
CHANGED
|
@@ -1,2 +1,70 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
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));require(`tsx/esm`);let c=require(`@h3ravel/core`);c=s(c);let l=require(`@h3ravel/
|
|
2
|
+
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));require(`tsx/esm`);let c=require(`@h3ravel/core`);c=s(c);let l=require(`@h3ravel/shared`);l=s(l);let u=require(`node:fs/promises`);u=s(u);let d=require(`@h3ravel/support`);d=s(d);let f=require(`dayjs`);f=s(f);let p=require(`node:fs`);p=s(p);let m=require(`node:path`);m=s(m);let h=require(`@h3ravel/http`);h=s(h);let g=require(`@h3ravel/router`);g=s(g);let _=require(`@h3ravel/database`);_=s(_);let v=require(`@h3ravel/cache`);v=s(v);let y=require(`@h3ravel/queue`);y=s(y);let b=require(`@h3ravel/mail`);b=s(b);let x=require(`@h3ravel/config`);x=s(x);let S=require(`commander`);S=s(S);let C=require(`path`);C=s(C);let w=require(`child_process`);w=s(w);let T=require(`tsdown`);T=s(T);var E=class extends c.ConsoleCommand{};const D=String.raw`
|
|
3
|
+
111
|
|
4
|
+
111111111
|
|
5
|
+
1111111111 111111
|
|
6
|
+
111111 111 111111
|
|
7
|
+
111111 111 111111
|
|
8
|
+
11111 111 11111
|
|
9
|
+
1111111 111 1111111
|
|
10
|
+
111 11111 111 111111 111 1111 1111 11111111 1111
|
|
11
|
+
111 11111 1111 111111 111 1111 1111 1111 11111 1111
|
|
12
|
+
111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
|
|
13
|
+
111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
|
|
14
|
+
111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
|
|
15
|
+
111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
|
|
16
|
+
111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
|
|
17
|
+
1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
|
|
18
|
+
11011 111111 11 11111
|
|
19
|
+
111111 11101 111111
|
|
20
|
+
111111 111 111111
|
|
21
|
+
111111 111 111111
|
|
22
|
+
111111111
|
|
23
|
+
110
|
|
24
|
+
`,O=String.raw`
|
|
25
|
+
_ _ _____ _
|
|
26
|
+
| | | |___ / _ __ __ ___ _____| |
|
|
27
|
+
| |_| | |_ \| '__/ _ \ \ / / _ \ |
|
|
28
|
+
| _ |___) | | | (_| |\ V / __/ |
|
|
29
|
+
|_| |_|____/|_| \__,_| \_/ \___|_|
|
|
30
|
+
|
|
31
|
+
`;var k=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=>l.Logger.describe(l.Logger.log(` `+[e.short,e.long].filter(e=>!!e).join(`, `),`green`,!1),e.description,25,!1).join(``)),t=this.program.commands.map(e=>l.Logger.describe(l.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},{}),n=Object.entries(t).map(([e,t])=>{let n=e===`__root__`?``:e;return[l.Logger.log(n,`yellow`,!1),t.join(`
|
|
32
|
+
`)].join(`
|
|
33
|
+
`)});l.Logger.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(O),console.log(``),l.Logger.log(`Usage:`,`yellow`),l.Logger.log(` command [options] [arguments]`,`white`),console.log(``),l.Logger.log(`Options:`,`yellow`),console.log(e.join(`
|
|
34
|
+
`).trim()),console.log(``),l.Logger.log(`Available Commands:`,`yellow`),console.log(n.join(`
|
|
35
|
+
|
|
36
|
+
`).trim())}},A=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[]}},j=class extends E{signature=`#make:
|
|
37
|
+
{controller : Create a new controller class.
|
|
38
|
+
| {--a|api : Exclude the create and edit methods from the controller}
|
|
39
|
+
| {--m|model= : Generate a resource controller for the given model}
|
|
40
|
+
| {--r|resource : Generate a resource controller class}
|
|
41
|
+
| {--force : Create the controller even if it already exists}
|
|
42
|
+
}
|
|
43
|
+
{resource : Create a new resource.
|
|
44
|
+
| {--c|collection : Create a resource collection}
|
|
45
|
+
| {--force : Create the resource even if it already exists}
|
|
46
|
+
}
|
|
47
|
+
{migration : Generates a new database migration class.
|
|
48
|
+
| {--l|type=ts : The file type to generate}
|
|
49
|
+
| {--t|table : The table to migrate}
|
|
50
|
+
| {--c|create : The table to be created}
|
|
51
|
+
}
|
|
52
|
+
{factory : Create a new model factory.}
|
|
53
|
+
{seeder : Create a new seeder class.}
|
|
54
|
+
{view : Create a new view.
|
|
55
|
+
| {--force : Create the view even if it already exists}
|
|
56
|
+
}
|
|
57
|
+
{model : Create a new Eloquent model class.
|
|
58
|
+
| {--api : Indicates if the generated controller should be an API resource controller}
|
|
59
|
+
| {--c|controller : Create a new controller for the model}
|
|
60
|
+
| {--f|factory : Create a new factory for the model}
|
|
61
|
+
| {--m|migration : Create a new migration file for the model}
|
|
62
|
+
| {--r|resource : Indicates if the generated controller should be a resource controller}
|
|
63
|
+
| {--a|all : Generate a migration, seeder, factory, policy, resource controller, and form request classes for the model}
|
|
64
|
+
| {--s|seed : Create a new seeder for the model}
|
|
65
|
+
| {--t|type=ts : The file type to generate}
|
|
66
|
+
| {--force : Create the model even if it already exists}
|
|
67
|
+
}
|
|
68
|
+
{^name : The name of the [name] to generate}
|
|
69
|
+
`;description=`Generate component classes`;async handle(){let e=this.dictionary.baseCommand??this.dictionary.name,t={controller:`makeController`,resource:`makeResource`,migration:`makeMigration`,factory:`makeFactory`,seeder:`makeSeeder`,model:`makeModel`,view:`makeView`};try{await this?.[t[e]]()}catch(e){l.Logger.error(e)}}async makeController(){let e=this.option(`api`)?`-resource`:``,t=this.argument(`name`),n=this.option(`force`),r=m.default.join(app_path(`Http/Controllers`),t+`.ts`),i=l.FileSystem.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,a=m.default.join(i,`dist/stubs/controller${e}.stub`);!n&&(0,p.existsSync)(r)&&l.Logger.error(`ERORR: ${t} controller already exists`);let o=await(0,u.readFile)(a,`utf-8`);o=o.replace(/{{ name }}/g,t),await(0,u.writeFile)(r,o),l.Logger.split(`INFO: Controller Created`,l.Logger.log(m.default.basename(r),`gray`,!1))}makeResource(){l.Logger.success(`Resource support is not yet available`)}async makeMigration(){let e=this.argument(`name`),t=(0,f.default)().format(`YYYY_MM_DD_HHmmss`),n=m.default.join(database_path(`migrations`),`${t}_${e}.ts`),r=l.FileSystem.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,i=this.option(`create`,!1),a=this.option(`table`);if(!a&&typeof i==`string`&&(a=i,i=!0),!a){let t=A.guess(e);a=t[0],i=!!t[1]}let o=m.default.join(r,this.getMigrationStubName(a,i)),s=await(0,u.readFile)(o,`utf-8`);a!==null&&(s=s.replace(/DummyTable|{{\s*table\s*}}/g,a)),l.Logger.info(`INFO: Creating Migration`),await this.kernel.ensureDirectoryExists(m.default.dirname(n)),await(0,u.writeFile)(n,s),l.Logger.split(`INFO: Migration Created`,l.Logger.log(m.default.basename(n),`gray`,!1))}makeFactory(){l.Logger.success(`Factory support is not yet available`)}makeSeeder(){l.Logger.success(`Seeder support is not yet available`)}async makeModel(){let e=this.option(`type`,`ts`),t=this.argument(`name`),n=this.argument(`force`),r=m.default.join(app_path(`Models`),t.toLowerCase(),`.`+e);!n&&(0,p.existsSync)(r)&&l.Logger.error(`ERORR: ${t} view already exists`);let i=l.FileSystem.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,a=m.default.join(i,`dist/stubs/model-${e}.stub`),o=await(0,u.readFile)(a,`utf-8`);o=o.replace(/{{ name }}/g,t),await(0,u.writeFile)(r,o),l.Logger.split(`INFO: Model Created`,l.Logger.log(m.default.basename(r),`gray`,!1))}async makeView(){let e=this.argument(`name`),t=this.option(`force`),n=m.default.join(base_path(`src/resources/views`),e+`.edge`);e.includes(`/`)&&await(0,u.mkdir)((0,d.beforeLast)(n,`/`),{recursive:!0}),!t&&(0,p.existsSync)(n)&&l.Logger.error(`ERORR: ${e} view already exists`),await(0,u.writeFile)(n,`{{-- src/resources/views/${e}.edge --}}`),l.Logger.split(`INFO: View Created`,l.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}},M=class extends E{signature=`postinstall`;description=`Default post installation command`;async handle(){this.createSqliteDB()}async createSqliteDB(){await l.FileSystem.fileExists(database_path())||await(0,u.mkdir)(database_path(),{recursive:!0}),await l.FileSystem.fileExists(database_path(`db.sqlite`))||await(0,u.writeFile)(database_path(`db.sqlite`),``)}},N=[h.HttpServiceProvider,x.ConfigServiceProvider,g.RouteServiceProvider,g.AssetsServiceProvider,_.DatabaseServiceProvider,v.CacheServiceProvider,y.QueueServiceProvider,b.MailServiceProvider],P=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(`
|
|
70
|
+
`).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 F(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,C.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,w.fork)((0,C.join)(e,t),r,o)},c=e.dir||(0,C.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 I=process.env.NODE_ENV||`development`,L=I===`development`?`.h3ravel/serve`:`dist`,R={outDir:L,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:I===`development`,clean:!0,shims:!0,copy:[{from:`public`,to:L},`src/resources`,`src/database`],env:I===`development`?{NODE_ENV:I,SRC_PATH:L}:{},watch:I===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,plugins:I===`development`&&process.env.CLI_BUILD!==`true`?[F({env:Object.assign({},process.env,{NODE_ENV:I,SRC_PATH:L}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]};var z=R,B=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new j(this.app,this.kernel),new k(this.app,this.kernel),new M(this.app,this.kernel)].forEach(e=>this.addCommand(e))}async loadDiscoveredCommands(){let e=[...this.app.registeredCommands.map(e=>new e(this.app,this.kernel))],t=app_path(`Console/Commands/*.js`).replace(`/src/`,`/.h3ravel/serve/`);for await(let n of(0,u.glob)(t)){let t=m.default.basename(n).replace(`.js`,``);try{let r=(await import(n))[t];e.push(new r(this.app,this.kernel))}catch{}}e.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(P.parseSignature(e.getSignature(),e))}initialize(){let e=l.Logger.parse([[`Musket CLI:`,`white`],[this.kernel.consolePackage.version,`green`]],` `,!1),t=l.Logger.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`]};S.program.name(`musket`).version(`${e}\n${t}`).description(O).addOption(new S.Option(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S.Option(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S.Option(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S.Option(n.lock[0],n.lock[1])).action(async()=>{let e=new k(this.app,this.kernel);e.setInput(S.program.opts(),S.program.args,S.program.registeredArguments,{},S.program),e.handle()}),S.program.command(`init`).description(`Initialize H3ravel.`).action(async()=>{l.Logger.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?S.program:S.program.command(t.baseCommand).description(t.description??``).addOption(new S.Option(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S.Option(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S.Option(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S.Option(n.lock[0],n.lock[1])).action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,S.program),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=S.program.command(`${t.baseCommand}:${e.name}`).description(e.description||``).addOption(new S.Option(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S.Option(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S.Option(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S.Option(n.lock[0],n.lock[1])).action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,e,S.program),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=S.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()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,S.program),await r.handle()})}}return S.program.hook(`preAction`,async(e,t)=>{t.name()!==`fire`&&await(0,T.build)({...z,watch:!1,plugins:[]})}),S.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()}},V=class e extends c.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 B.parse(this),process.exit(0)}async loadRequirements(){this.cwd=m.default.join(process.cwd(),this.basePath),this.modulePath=l.FileSystem.findModulePkg(`@h3ravel/core`,this.cwd)??``,this.consolePath=l.FileSystem.findModulePkg(`@h3ravel/console`,this.cwd)??``;try{this.modulePackage=await import(m.default.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(m.default.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},H=class extends c.ServiceProvider{static priority=992;static console=!0;register(){}boot(){V.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}},U=class{async fire(){let e=new c.Application(process.cwd()),t=app_path(`Providers/*.js`).replace(`/src/`,`/.h3ravel/serve/`);for await(let e of(0,u.glob)(t)){let t=m.default.basename(e).replace(`.js`,``);try{N.push((await import(e))[t])}catch{}}N.push(H),e.registerProviders(N),await e.registerConfiguredProviders(),await e.boot()}};new U().fire();
|
package/bin/fire.js
CHANGED
|
@@ -1,2 +1,70 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"tsx/esm";import{Application as e}from"@h3ravel/core";import{
|
|
2
|
+
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}from"@h3ravel/shared";import{glob as o,mkdir as s,readFile as c,writeFile as l}from"node:fs/promises";import{beforeLast as u}from"@h3ravel/support";import d from"dayjs";import{existsSync as f}from"node:fs";import p from"node:path";import{HttpServiceProvider as m}from"@h3ravel/http";import{AssetsServiceProvider as h,RouteServiceProvider as g}from"@h3ravel/router";import{DatabaseServiceProvider as _}from"@h3ravel/database";import{CacheServiceProvider as v}from"@h3ravel/cache";import{QueueServiceProvider as y}from"@h3ravel/queue";import{MailServiceProvider as b}from"@h3ravel/mail";import{ConfigServiceProvider as x}from"@h3ravel/config";import{Option as S,program as C}from"commander";import{dirname as w,join as T,resolve as E}from"path";import{fork as D}from"child_process";import{build as O}from"tsdown";var k=class extends t{};String.raw`
|
|
3
|
+
111
|
|
4
|
+
111111111
|
|
5
|
+
1111111111 111111
|
|
6
|
+
111111 111 111111
|
|
7
|
+
111111 111 111111
|
|
8
|
+
11111 111 11111
|
|
9
|
+
1111111 111 1111111
|
|
10
|
+
111 11111 111 111111 111 1111 1111 11111111 1111
|
|
11
|
+
111 11111 1111 111111 111 1111 1111 1111 11111 1111
|
|
12
|
+
111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
|
|
13
|
+
111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
|
|
14
|
+
111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
|
|
15
|
+
111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
|
|
16
|
+
111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
|
|
17
|
+
1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
|
|
18
|
+
11011 111111 11 11111
|
|
19
|
+
111111 11101 111111
|
|
20
|
+
111111 111 111111
|
|
21
|
+
111111 111 111111
|
|
22
|
+
111111111
|
|
23
|
+
110
|
|
24
|
+
`;const A=String.raw`
|
|
25
|
+
_ _ _____ _
|
|
26
|
+
| | | |___ / _ __ __ ___ _____| |
|
|
27
|
+
| |_| | |_ \| '__/ _ \ \ / / _ \ |
|
|
28
|
+
| _ |___) | | | (_| |\ V / __/ |
|
|
29
|
+
|_| |_|____/|_| \__,_| \_/ \___|_|
|
|
30
|
+
|
|
31
|
+
`;var j=class extends k{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(`
|
|
32
|
+
`)].join(`
|
|
33
|
+
`)});a.log([[`H3ravel Framework`,`white`],[this.kernel.modulePackage.version,`green`]],` `),console.log(``),console.log(A),console.log(``),a.log(`Usage:`,`yellow`),a.log(` command [options] [arguments]`,`white`),console.log(``),a.log(`Options:`,`yellow`),console.log(e.join(`
|
|
34
|
+
`).trim()),console.log(``),a.log(`Available Commands:`,`yellow`),console.log(n.join(`
|
|
35
|
+
|
|
36
|
+
`).trim())}},M=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[]}},N=class extends k{signature=`#make:
|
|
37
|
+
{controller : Create a new controller class.
|
|
38
|
+
| {--a|api : Exclude the create and edit methods from the controller}
|
|
39
|
+
| {--m|model= : Generate a resource controller for the given model}
|
|
40
|
+
| {--r|resource : Generate a resource controller class}
|
|
41
|
+
| {--force : Create the controller even if it already exists}
|
|
42
|
+
}
|
|
43
|
+
{resource : Create a new resource.
|
|
44
|
+
| {--c|collection : Create a resource collection}
|
|
45
|
+
| {--force : Create the resource even if it already exists}
|
|
46
|
+
}
|
|
47
|
+
{migration : Generates a new database migration class.
|
|
48
|
+
| {--l|type=ts : The file type to generate}
|
|
49
|
+
| {--t|table : The table to migrate}
|
|
50
|
+
| {--c|create : The table to be created}
|
|
51
|
+
}
|
|
52
|
+
{factory : Create a new model factory.}
|
|
53
|
+
{seeder : Create a new seeder class.}
|
|
54
|
+
{view : Create a new view.
|
|
55
|
+
| {--force : Create the view even if it already exists}
|
|
56
|
+
}
|
|
57
|
+
{model : Create a new Eloquent model class.
|
|
58
|
+
| {--api : Indicates if the generated controller should be an API resource controller}
|
|
59
|
+
| {--c|controller : Create a new controller for the model}
|
|
60
|
+
| {--f|factory : Create a new factory for the model}
|
|
61
|
+
| {--m|migration : Create a new migration file for the model}
|
|
62
|
+
| {--r|resource : Indicates if the generated controller should be a resource controller}
|
|
63
|
+
| {--a|all : Generate a migration, seeder, factory, policy, resource controller, and form request classes for the model}
|
|
64
|
+
| {--s|seed : Create a new seeder for the model}
|
|
65
|
+
| {--t|type=ts : The file type to generate}
|
|
66
|
+
| {--force : Create the model even if it already exists}
|
|
67
|
+
}
|
|
68
|
+
{^name : The name of the [name] to generate}
|
|
69
|
+
`;description=`Generate component classes`;async handle(){let e=this.dictionary.baseCommand??this.dictionary.name,t={controller:`makeController`,resource:`makeResource`,migration:`makeMigration`,factory:`makeFactory`,seeder:`makeSeeder`,model:`makeModel`,view:`makeView`};try{await this?.[t[e]]()}catch(e){a.error(e)}}async makeController(){let e=this.option(`api`)?`-resource`:``,t=this.argument(`name`),n=this.option(`force`),r=p.join(app_path(`Http/Controllers`),t+`.ts`),o=i.findModulePkg(`@h3ravel/http`,this.kernel.cwd)??``,s=p.join(o,`dist/stubs/controller${e}.stub`);!n&&f(r)&&a.error(`ERORR: ${t} controller already exists`);let u=await c(s,`utf-8`);u=u.replace(/{{ name }}/g,t),await l(r,u),a.split(`INFO: Controller Created`,a.log(p.basename(r),`gray`,!1))}makeResource(){a.success(`Resource support is not yet available`)}async makeMigration(){let e=this.argument(`name`),t=d().format(`YYYY_MM_DD_HHmmss`),n=p.join(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=M.guess(e);s=t[0],o=!!t[1]}let u=p.join(r,this.getMigrationStubName(s,o)),f=await c(u,`utf-8`);s!==null&&(f=f.replace(/DummyTable|{{\s*table\s*}}/g,s)),a.info(`INFO: Creating Migration`),await this.kernel.ensureDirectoryExists(p.dirname(n)),await l(n,f),a.split(`INFO: Migration Created`,a.log(p.basename(n),`gray`,!1))}makeFactory(){a.success(`Factory support 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.argument(`force`),r=p.join(app_path(`Models`),t.toLowerCase(),`.`+e);!n&&f(r)&&a.error(`ERORR: ${t} view already exists`);let o=i.findModulePkg(`@h3ravel/database`,this.kernel.cwd)??``,s=p.join(o,`dist/stubs/model-${e}.stub`),u=await c(s,`utf-8`);u=u.replace(/{{ name }}/g,t),await l(r,u),a.split(`INFO: Model Created`,a.log(p.basename(r),`gray`,!1))}async makeView(){let e=this.argument(`name`),t=this.option(`force`),n=p.join(base_path(`src/resources/views`),e+`.edge`);e.includes(`/`)&&await s(u(n,`/`),{recursive:!0}),!t&&f(n)&&a.error(`ERORR: ${e} view already exists`),await l(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}},P=class extends k{signature=`postinstall`;description=`Default post installation command`;async handle(){this.createSqliteDB()}async createSqliteDB(){await i.fileExists(database_path())||await s(database_path(),{recursive:!0}),await i.fileExists(database_path(`db.sqlite`))||await l(database_path(`db.sqlite`),``)}},F=[m,x,g,h,_,v,y,b],I=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(`
|
|
70
|
+
`).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 L(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=E(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=D(T(e,t),r,o)},c=e.dir||w(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 R=process.env.NODE_ENV||`development`,z=R===`development`?`.h3ravel/serve`:`dist`;var B={outDir:z,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:R===`development`,clean:!0,shims:!0,copy:[{from:`public`,to:z},`src/resources`,`src/database`],env:R===`development`?{NODE_ENV:R,SRC_PATH:z}:{},watch:R===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,plugins:R===`development`&&process.env.CLI_BUILD!==`true`?[L({env:Object.assign({},process.env,{NODE_ENV:R,SRC_PATH:z}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]},V=class e{commands=[];constructor(e,t){this.app=e,this.kernel=t}async build(){return this.loadBaseCommands(),await this.loadDiscoveredCommands(),this.initialize()}loadBaseCommands(){[new N(this.app,this.kernel),new j(this.app,this.kernel),new P(this.app,this.kernel)].forEach(e=>this.addCommand(e))}async loadDiscoveredCommands(){let e=[...this.app.registeredCommands.map(e=>new e(this.app,this.kernel))],t=app_path(`Console/Commands/*.js`).replace(`/src/`,`/.h3ravel/serve/`);for await(let n of o(t)){let t=p.basename(n).replace(`.js`,``);try{let r=(await import(n))[t];e.push(new r(this.app,this.kernel))}catch{}}e.forEach(e=>this.addCommand(e))}addCommand(e){this.commands.push(I.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`]};C.name(`musket`).version(`${e}\n${t}`).description(A).addOption(new S(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S(n.lock[0],n.lock[1])).action(async()=>{let e=new j(this.app,this.kernel);e.setInput(C.opts(),C.args,C.registeredArguments,{},C),e.handle()}),C.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?C:C.command(t.baseCommand).description(t.description??``).addOption(new S(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S(n.lock[0],n.lock[1])).action(async()=>{r.setInput(e.opts(),e.args,e.registeredArguments,t,C),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=C.command(`${t.baseCommand}:${e.name}`).description(e.description||``).addOption(new S(n.quiet[0],n.quiet[1]).implies({silent:!0})).addOption(new S(n.silent[0],n.silent[1]).implies({quiet:!0})).addOption(new S(n.verbose[0],n.verbose[1]).choices([`1`,`2`,`3`])).addOption(new S(n.lock[0],n.lock[1])).action(async()=>{r.setInput(i.opts(),i.args,i.registeredArguments,e,C),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=C.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,C),await r.handle()})}}return C.hook(`preAction`,async(e,t)=>{t.name()!==`fire`&&await O({...B,watch:!1,plugins:[]})}),C}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()}},H=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 V.parse(this),process.exit(0)}async loadRequirements(){this.cwd=p.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(p.join(this.modulePath,`package.json`))}catch{this.modulePackage={version:`N/A`}}try{this.consolePackage=await import(p.join(this.consolePath,`package.json`))}catch{this.consolePackage={version:`N/A`}}return this}},U=class extends r{static priority=992;static console=!0;register(){}boot(){H.init(this.app),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}};new class{async fire(){let t=new e(process.cwd()),n=(app_path(`Providers/*.js`).replace(`/src/`,`/.h3ravel/serve/`));for await(let e of o(n)){let t=(p.basename(e).replace(`.js`,``));try{F.push((await import(e))[t])}catch{}}F.push(U),t.registerProviders(F),await t.registerConfiguredProviders(),await t.boot()}}().fire();export{};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/Utils.d.ts
|
|
2
|
+
declare class Utils {}
|
|
3
|
+
declare class TableGuesser {
|
|
4
|
+
static CREATE_PATTERNS: RegExp[];
|
|
5
|
+
static CHANGE_PATTERNS: RegExp[];
|
|
6
|
+
static guess(migration: string): (string | boolean)[];
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { TableGuesser, Utils };
|
|
10
|
+
//# sourceMappingURL=Utils-CbqNJtIj.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/Utils.d.ts
|
|
2
|
+
declare class Utils {}
|
|
3
|
+
declare class TableGuesser {
|
|
4
|
+
static CREATE_PATTERNS: RegExp[];
|
|
5
|
+
static CHANGE_PATTERNS: RegExp[];
|
|
6
|
+
static guess(migration: string): (string | boolean)[];
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { TableGuesser, Utils };
|
|
10
|
+
//# sourceMappingURL=Utils-CxAcuqeI.d.cts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/Utils.ts
|
|
3
|
+
var Utils = class {};
|
|
4
|
+
var TableGuesser = class TableGuesser {
|
|
5
|
+
static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
|
|
6
|
+
static CHANGE_PATTERNS = [/.+_(to|from|in)_(\w+)_table$/, /.+_(to|from|in)_(\w+)$/];
|
|
7
|
+
static guess(migration) {
|
|
8
|
+
for (const pattern of TableGuesser.CREATE_PATTERNS) {
|
|
9
|
+
const matches = migration.match(pattern);
|
|
10
|
+
if (matches) return [matches[1], true];
|
|
11
|
+
}
|
|
12
|
+
for (const pattern of TableGuesser.CHANGE_PATTERNS) {
|
|
13
|
+
const matches = migration.match(pattern);
|
|
14
|
+
if (matches) return [matches[2], false];
|
|
15
|
+
}
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
Object.defineProperty(exports, 'TableGuesser', {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return TableGuesser;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, 'Utils', {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return Utils;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=Utils-D6ZDNdVG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils-D6ZDNdVG.cjs","names":[],"sources":["../src/Utils.ts"],"sourcesContent":["export class Utils {\n}\n\nclass TableGuesser {\n static CREATE_PATTERNS = [\n /^create_(\\w+)_table$/,\n /^create_(\\w+)$/\n ]\n static CHANGE_PATTERNS = [\n /.+_(to|from|in)_(\\w+)_table$/,\n /.+_(to|from|in)_(\\w+)$/\n ]\n static guess (migration: string) {\n for (const pattern of TableGuesser.CREATE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[1], true]\n }\n }\n for (const pattern of TableGuesser.CHANGE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[2], false]\n }\n }\n return []\n }\n}\n\nexport { TableGuesser }\n"],"mappings":";;AAAA,IAAa,QAAb,MAAmB;AAGnB,IAAM,eAAN,MAAM,aAAa;CACjB,OAAO,kBAAkB,CACvB,wBACA,iBACD;CACD,OAAO,kBAAkB,CACvB,gCACA,yBACD;CACD,OAAO,MAAO,WAAmB;AAC/B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,KAAK;;AAG7B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,MAAM;;AAG9B,SAAO,EAAE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/Utils.ts
|
|
2
|
+
var Utils = class {};
|
|
3
|
+
var TableGuesser = class TableGuesser {
|
|
4
|
+
static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
|
|
5
|
+
static CHANGE_PATTERNS = [/.+_(to|from|in)_(\w+)_table$/, /.+_(to|from|in)_(\w+)$/];
|
|
6
|
+
static guess(migration) {
|
|
7
|
+
for (const pattern of TableGuesser.CREATE_PATTERNS) {
|
|
8
|
+
const matches = migration.match(pattern);
|
|
9
|
+
if (matches) return [matches[1], true];
|
|
10
|
+
}
|
|
11
|
+
for (const pattern of TableGuesser.CHANGE_PATTERNS) {
|
|
12
|
+
const matches = migration.match(pattern);
|
|
13
|
+
if (matches) return [matches[2], false];
|
|
14
|
+
}
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { TableGuesser, Utils };
|
|
21
|
+
//# sourceMappingURL=Utils-Dn22CO9s.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils-Dn22CO9s.js","names":[],"sources":["../src/Utils.ts"],"sourcesContent":["export class Utils {\n}\n\nclass TableGuesser {\n static CREATE_PATTERNS = [\n /^create_(\\w+)_table$/,\n /^create_(\\w+)$/\n ]\n static CHANGE_PATTERNS = [\n /.+_(to|from|in)_(\\w+)_table$/,\n /.+_(to|from|in)_(\\w+)$/\n ]\n static guess (migration: string) {\n for (const pattern of TableGuesser.CREATE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[1], true]\n }\n }\n for (const pattern of TableGuesser.CHANGE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[2], false]\n }\n }\n return []\n }\n}\n\nexport { TableGuesser }\n"],"mappings":";AAAA,IAAa,QAAb,MAAmB;AAGnB,IAAM,eAAN,MAAM,aAAa;CACjB,OAAO,kBAAkB,CACvB,wBACA,iBACD;CACD,OAAO,kBAAkB,CACvB,gCACA,yBACD;CACD,OAAO,MAAO,WAAmB;AAC/B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,KAAK;;AAG7B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,MAAM;;AAG9B,SAAO,EAAE"}
|
package/dist/Utils.cjs
CHANGED
package/dist/Utils.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TableGuesser, Utils } from "./Utils-
|
|
1
|
+
import { TableGuesser, Utils } from "./Utils-CxAcuqeI.cjs";
|
|
2
2
|
export { TableGuesser, Utils };
|
package/dist/Utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TableGuesser, Utils } from "./Utils-
|
|
1
|
+
import { TableGuesser, Utils } from "./Utils-CbqNJtIj.js";
|
|
2
2
|
export { TableGuesser, Utils };
|
package/dist/Utils.js
CHANGED