@cedarjs/cli-data-migrate 1.0.0-canary.12505 → 1.0.0-canary.12508
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/dist/bin.js +2 -2
- package/dist/commands/install.js +2 -2
- package/dist/commands/up.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +5 -5
package/dist/bin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var I=Object.create;var D=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var M=(t,r)=>()=>(t&&(r=t(t=0)),r);var U=(t,r,i,
|
|
2
|
+
"use strict";var I=Object.create;var D=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var M=(t,r)=>()=>(t&&(r=t(t=0)),r);var U=(t,r,i,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of N(r))!V.call(t,e)&&e!==i&&D(t,e,{get:()=>r[e],enumerable:!(a=L(r,e))||a.enumerable});return t};var l=(t,r,i)=>(i=t!=null?I(R(t)):{},U(r||!t||!t.__esModule?D(i,"default",{value:t,enumerable:!0}):i,t));var n,d,A=M(()=>{"use strict";n=l(require("ansis")),d={error:n.default.bold.red,warning:n.default.hex("#ffa500"),highlight:n.default.hex("#ffa500"),success:n.default.green,info:n.default.gray,bold:n.default.bold,underline:n.default.underline,note:n.default.blue,tip:n.default.green,important:n.default.magenta,caution:n.default.red,link:n.default.hex("#e8e8e8")}});async function $({importDbClientFromDist:t,distPath:r}){let i;if(t){if(!f.default.existsSync(r)){console.warn(`Can't find api dist at ${r}. You may need to build first: yarn rw build api`),process.exitCode=1;return}let o=c.default.join(r,"lib"),p=c.default.join(o,"db.js");if(!f.default.existsSync(p)){console.error(`Can't find db.js at ${p}. CedarJS expects the db.js file to be in the ${o} directory`),process.exitCode=1;return}i=(await import(p)).db}else{let o=(0,m.resolveFile)(c.default.join((0,m.getPaths)().api.lib,"db"));if(!o){console.error(`Can't find your db file in ${(0,m.getPaths)().api.lib}`),process.exitCode=1;return}let{mod:p}=await(0,h.bundleRequire)({filepath:o});i=p.db}let a=await W(i);if(!a.length){console.info(d.success(`
|
|
3
3
|
${F}
|
|
4
|
-
`)),process.exitCode=0;return}let e={run:0,skipped:0,error:0},g=
|
|
4
|
+
`)),process.exitCode=0;return}let e={run:0,skipped:0,error:0},g=a.map(o=>{let p=c.default.basename(o.path,".js");return{title:p,skip(){return e.error>0?(e.skipped++,!0):!1},async task(){try{let{startedAt:u,finishedAt:_}=await G(i,o.path);e.run++,await J(i,{version:o.version,name:p,startedAt:u,finishedAt:_})}catch(u){e.error++,console.error(d.error(`Error in data migration: ${u.message}`))}}}}),s=new P.Listr(g,{renderer:"verbose"});try{await s.run(),await i.$disconnect(),console.log(),E(e),console.log(),e.error&&(process.exitCode=1)}catch{process.exitCode=1,await i.$disconnect(),console.log(),E(e),console.log()}}async function W(t){let r=(0,m.getPaths)().api.dataMigrations;if(!f.default.existsSync(r))return[];let i=f.default.readdirSync(r).filter(s=>["js",".ts"].some(o=>s.endsWith(o))).map(s=>{let[o]=s.split("-");return{version:o,path:c.default.join(r,s)}}),e=(await t.rW_DataMigration.findMany({orderBy:{version:"asc"}})).map(s=>s.version.toString());return i.filter(({version:s})=>!e.includes(s)).sort(B)}function B(t,r){let i=parseInt(t.version),a=parseInt(r.version);return i>a?1:i<a?-1:0}async function G(t,r){let{mod:i}=await(0,h.bundleRequire)({filepath:r}),a=i.default,e=new Date;return await a({db:t}),{startedAt:e,finishedAt:new Date}}async function J(t,{version:r,name:i,startedAt:a,finishedAt:e}){await t.rW_DataMigration.create({data:{version:r,name:i,startedAt:a,finishedAt:e}})}function E(t){t.run&&console.info(d.success(`${t.run} data migration(s) completed successfully.`)),t.error&&console.error(d.error(`${t.error} data migration(s) exited with errors.`)),t.skipped&&console.warn(d.warning(`${t.skipped} data migration(s) skipped due to previous error.`))}var f,c,h,P,m,F,j=M(()=>{"use strict";f=l(require("fs")),c=l(require("path")),h=require("bundle-require"),P=require("listr2"),m=require("@cedarjs/project-config");A();F="No pending data migrations run, already up-to-date."});var b=l(require("path")),k=require("dotenv-defaults"),O=require("yargs/helpers"),S=l(require("yargs/yargs")),y=require("@cedarjs/project-config");var w=require("termi-link"),v=require("@cedarjs/project-config");var x="Run any outstanding Data Migrations against the database";function C(t){return t.option("import-db-client-from-dist",{type:"boolean",alias:["db-from-dist"],description:"Import the db client from dist",default:!1}).option("dist-path",{type:"string",alias:"d",description:"Path to the api dist directory",default:(0,v.getPaths)().api.dist}).epilogue(`Also see the ${(0,w.terminalLink)("CedarJS CLI Reference","https://cedarjs.com/docs/cli-commands#datamigrate-up")}`)}j();process.env.REDWOOD_ENV_FILES_LOADED||((0,k.config)({path:b.default.join((0,y.getPaths)().base,".env"),defaults:b.default.join((0,y.getPaths)().base,".env.defaults"),multiline:!0}),process.env.REDWOOD_ENV_FILES_LOADED="true");(0,S.default)((0,O.hideBin)(process.argv)).scriptName("data-migrate").command("$0",x,C,$).parse();
|
package/dist/commands/install.js
CHANGED
|
@@ -40,8 +40,8 @@ const description = "Add the RW_DataMigration model to your schema";
|
|
|
40
40
|
function builder(yargs) {
|
|
41
41
|
return yargs.epilogue(
|
|
42
42
|
`Also see the ${(0, import_termi_link.terminalLink)(
|
|
43
|
-
"
|
|
44
|
-
"https://
|
|
43
|
+
"CedarJS CLI Reference",
|
|
44
|
+
"https://cedarjs.com/docs/cli-commands#datamigrate-install"
|
|
45
45
|
)}`
|
|
46
46
|
);
|
|
47
47
|
}
|
package/dist/commands/up.js
CHANGED
|
@@ -51,8 +51,8 @@ function builder(yargs) {
|
|
|
51
51
|
default: (0, import_project_config.getPaths)().api.dist
|
|
52
52
|
}).epilogue(
|
|
53
53
|
`Also see the ${(0, import_termi_link.terminalLink)(
|
|
54
|
-
"
|
|
55
|
-
"https://
|
|
54
|
+
"CedarJS CLI Reference",
|
|
55
|
+
"https://cedarjs.com/docs/cli-commands#datamigrate-up"
|
|
56
56
|
)}`
|
|
57
57
|
);
|
|
58
58
|
}
|
package/dist/index.js
CHANGED
|
@@ -30,8 +30,8 @@ const description = "Migrate the data in your database";
|
|
|
30
30
|
function builder(yargs) {
|
|
31
31
|
yargs.command(import_install.command, import_install.description, import_install.builder, import_install.handler).command(import_up.command, import_up.description, import_up.builder, import_up.handler).epilogue(
|
|
32
32
|
`Also see the ${(0, import_termi_link.terminalLink)(
|
|
33
|
-
"
|
|
34
|
-
"https://
|
|
33
|
+
"CedarJS CLI Reference",
|
|
34
|
+
"https://cedarjs.com/docs/cli-commands#datamigrate"
|
|
35
35
|
)}`
|
|
36
36
|
);
|
|
37
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli-data-migrate",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.12508+f4e57f8d0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"test:unit": "yarn jest src"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@cedarjs/babel-config": "1.0.0-canary.
|
|
29
|
-
"@cedarjs/project-config": "1.0.0-canary.
|
|
28
|
+
"@cedarjs/babel-config": "1.0.0-canary.12508",
|
|
29
|
+
"@cedarjs/project-config": "1.0.0-canary.12508",
|
|
30
30
|
"ansis": "4.1.0",
|
|
31
31
|
"bundle-require": "^5.1.0",
|
|
32
32
|
"dotenv-defaults": "5.0.2",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"yargs": "17.7.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@cedarjs/framework-tools": "1.0.0-canary.
|
|
40
|
+
"@cedarjs/framework-tools": "1.0.0-canary.12508",
|
|
41
41
|
"@prisma/client": "5.20.0",
|
|
42
42
|
"@types/fs-extra": "11.0.4",
|
|
43
43
|
"@types/yargs": "17.0.33",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"tsx": "4.20.3",
|
|
47
47
|
"typescript": "5.6.2"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "f4e57f8d0eecf3e4be1ab1fa01866004fb0a9c25"
|
|
50
50
|
}
|