@elysiumjs/styx 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/styx.js +1 -1
package/package.json
CHANGED
package/styx.js
CHANGED
|
@@ -112,4 +112,4 @@ Queue: ${X} - stream not found or empty`);continue}if(this.all){if(!this.dryRun)
|
|
|
112
112
|
name TEXT NOT NULL,
|
|
113
113
|
batch INTEGER NOT NULL,
|
|
114
114
|
applied_at TIMESTAMP NOT NULL
|
|
115
|
-
);`;let X=(await $`SELECT name FROM elysium_migrations;`).map((L)=>L.name),Q=new Bun.Glob("./src/database/migrations/**/*.sql").scan({absolute:!0,onlyFiles:!0}),J=await Array.fromAsync(Q),D=w0(J.filter((L)=>!X.includes(y$(L))),(L)=>L);if(D.length===0){this.success("No new migrations to apply.");return}let W=this.spinner(`Running migrations for tenant ${this.bold(this.tenant)}...`),[{max:I}]=await $`SELECT MAX(batch) + 1 AS max FROM elysium_migrations;`,C=I??0;for(let L of D){await $.file(L);let[{name:N}]=await $`INSERT INTO elysium_migrations (name, batch, applied_at) VALUES (${y$(L)}, ${C}, ${new Date}) RETURNING name;`;W.pause(`Migration ${this.bold(N)} applied successfully.`)}W.complete(`Migrations for tenant ${this.bold(this.tenant)} applied successfully.`)}),await Y.close()}}z([Y2.arg({description:"The name of the tenant in which the migrations will be executed.",type:$2.STRING,required:!0}),K("design:type",String)],Z2.prototype,"tenant",void 0),z([Y2.arg({description:"The name of the connection to use.",type:$2.STRING,default:"default"}),K("design:type",String)],Z2.prototype,"connection",void 0),z([Y2.arg({description:"Drop the entire schema before running the migrations.",type:$2.BOOLEAN,default:!1}),K("design:type",Boolean)],Z2.prototype,"fresh",void 0);var H2=O(_(),1);import{exists as OU,rmdir as IU}from"fs/promises";import{join as AU}from"path";import{Command as qU,CommandArgumentType as NU}from"@elysiumjs/core";class U2 extends E{static command="module:new";static description="Creates a new module.";module;convert=!1;async run(){let Y=await R();if(!this.name){let $=await H2.default({type:"text",name:"name",message:"New module name:",initial:"module",validate(Z){return Z.length>0?!0:"Module name cannot be empty"}},{onCancel:()=>process.exit(0)});this.name=V($.name)}if(Y.mono){let{module:$,convert:Z}=await H2.default([{type:"confirm",name:"convert",message:"This project is a mono-module project. Do you want to convert it to a multi-module project?",initial:!1},{type:(H)=>H?"text":null,name:"module",message:"Current module name:",initial:"main",validate(H){return H.length>0?!0:"Module name cannot be empty"}}],{onCancel:()=>process.exit(0)});if(!Z)return this.error("Operation cancelled. The project is left unchanged.");this.module=V($),this.convert=Z}if(this.convert){let $=AU(a(),"src","modules");if(await OU($))await IU($,{recursive:!0});await j1(this.module,"root"),this.success("Project converted to multi-module."),this.success(`Module '${this.module}' created.`)}await j1(this.name),this.success(`Module '${this.name}' created.`)}}z([qU.arg({description:"The name of the module to create",type:NU.STRING}),K("design:type",String)],U2.prototype,"name",void 0);var X2=O(_(),1);import{Command as c$,CommandArgumentType as l$}from"@elysiumjs/core";class Q2 extends E{static command="module:rename";static description="Renames a module.";async run(){if((await R()).mono)return this.error("This operation is not supported for mono-module projects.");if(!this.module){let{module:$}=await X2.default({type:"text",name:"module",message:"Module to rename:",validate:(Z)=>Z.length>0});this.module=$}if(!this.name){let{name:$}=await X2.default({type:"text",name:"name",message:"New module name:",initial:this.module,validate:(Z)=>Z.length>0});this.name=$}if(this.module===this.name)return this.info("Module name is the same as the current name.");await j1(this.name,this.module),this.success(`Module '${this.module}' renamed to '${this.name}'.`)}}z([c$.arg({description:"The module to rename",type:l$.STRING}),K("design:type",String)],Q2.prototype,"module",void 0),z([c$.arg({description:"The new name of the module",type:l$.STRING}),K("design:type",String)],Q2.prototype,"name",void 0);var PU=a(),{App:p$}=await import(`${PU}/src/app`);class X0 extends p${}X0=z([p$.register({commands:[J0,D0,z0,g0,d0,c0,p0,i0,o0,s0,a0,e0,Z2,U2,Q2].filter((Y)=>ELYSIUM_BUILD
|
|
115
|
+
);`;let X=(await $`SELECT name FROM elysium_migrations;`).map((L)=>L.name),Q=new Bun.Glob("./src/database/migrations/**/*.sql").scan({absolute:!0,onlyFiles:!0}),J=await Array.fromAsync(Q),D=w0(J.filter((L)=>!X.includes(y$(L))),(L)=>L);if(D.length===0){this.success("No new migrations to apply.");return}let W=this.spinner(`Running migrations for tenant ${this.bold(this.tenant)}...`),[{max:I}]=await $`SELECT MAX(batch) + 1 AS max FROM elysium_migrations;`,C=I??0;for(let L of D){await $.file(L);let[{name:N}]=await $`INSERT INTO elysium_migrations (name, batch, applied_at) VALUES (${y$(L)}, ${C}, ${new Date}) RETURNING name;`;W.pause(`Migration ${this.bold(N)} applied successfully.`)}W.complete(`Migrations for tenant ${this.bold(this.tenant)} applied successfully.`)}),await Y.close()}}z([Y2.arg({description:"The name of the tenant in which the migrations will be executed.",type:$2.STRING,required:!0}),K("design:type",String)],Z2.prototype,"tenant",void 0),z([Y2.arg({description:"The name of the connection to use.",type:$2.STRING,default:"default"}),K("design:type",String)],Z2.prototype,"connection",void 0),z([Y2.arg({description:"Drop the entire schema before running the migrations.",type:$2.BOOLEAN,default:!1}),K("design:type",Boolean)],Z2.prototype,"fresh",void 0);var H2=O(_(),1);import{exists as OU,rmdir as IU}from"fs/promises";import{join as AU}from"path";import{Command as qU,CommandArgumentType as NU}from"@elysiumjs/core";class U2 extends E{static command="module:new";static description="Creates a new module.";module;convert=!1;async run(){let Y=await R();if(!this.name){let $=await H2.default({type:"text",name:"name",message:"New module name:",initial:"module",validate(Z){return Z.length>0?!0:"Module name cannot be empty"}},{onCancel:()=>process.exit(0)});this.name=V($.name)}if(Y.mono){let{module:$,convert:Z}=await H2.default([{type:"confirm",name:"convert",message:"This project is a mono-module project. Do you want to convert it to a multi-module project?",initial:!1},{type:(H)=>H?"text":null,name:"module",message:"Current module name:",initial:"main",validate(H){return H.length>0?!0:"Module name cannot be empty"}}],{onCancel:()=>process.exit(0)});if(!Z)return this.error("Operation cancelled. The project is left unchanged.");this.module=V($),this.convert=Z}if(this.convert){let $=AU(a(),"src","modules");if(await OU($))await IU($,{recursive:!0});await j1(this.module,"root"),this.success("Project converted to multi-module."),this.success(`Module '${this.module}' created.`)}await j1(this.name),this.success(`Module '${this.name}' created.`)}}z([qU.arg({description:"The name of the module to create",type:NU.STRING}),K("design:type",String)],U2.prototype,"name",void 0);var X2=O(_(),1);import{Command as c$,CommandArgumentType as l$}from"@elysiumjs/core";class Q2 extends E{static command="module:rename";static description="Renames a module.";async run(){if((await R()).mono)return this.error("This operation is not supported for mono-module projects.");if(!this.module){let{module:$}=await X2.default({type:"text",name:"module",message:"Module to rename:",validate:(Z)=>Z.length>0});this.module=$}if(!this.name){let{name:$}=await X2.default({type:"text",name:"name",message:"New module name:",initial:this.module,validate:(Z)=>Z.length>0});this.name=$}if(this.module===this.name)return this.info("Module name is the same as the current name.");await j1(this.name,this.module),this.success(`Module '${this.module}' renamed to '${this.name}'.`)}}z([c$.arg({description:"The module to rename",type:l$.STRING}),K("design:type",String)],Q2.prototype,"module",void 0),z([c$.arg({description:"The new name of the module",type:l$.STRING}),K("design:type",String)],Q2.prototype,"name",void 0);var PU=a(),{App:p$}=await import(`${PU}/src/app`);class X0 extends p${}X0=z([p$.register({commands:[J0,D0,z0,g0,d0,c0,p0,i0,o0,s0,a0,e0,Z2,U2,Q2].filter((Y)=>ELYSIUM_BUILD?!Y.dev:!0)})],X0);new X0;
|