@cedarjs/cli-data-migrate 1.0.0-canary.12318 → 1.0.0-canary.12319
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 -12
- package/package.json +6 -6
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,o)=>{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:!(o=L(r,e))||o.enumerable});return t};var
|
|
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,o)=>{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:!(o=L(r,e))||o.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,p,k=M(()=>{"use strict";n=l(require("chalk")),p={error:n.default.bold.red,warning:n.default.hex("#ffa500"),highlight:n.default.hex("#ffa500"),success:n.default.green,info:n.default.grey,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 P({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 a=c.default.join(r,"lib"),d=c.default.join(a,"db.js");if(!f.default.existsSync(d)){console.error(`Can't find db.js at ${d}. CedarJS expects the db.js file to be in the ${a} directory`),process.exitCode=1;return}i=(await import(d)).db}else{let a=(0,m.resolveFile)(c.default.join((0,m.getPaths)().api.lib,"db"));if(!a){console.error(`Can't find your db file in ${(0,m.getPaths)().api.lib}`),process.exitCode=1;return}let{mod:d}=await(0,h.bundleRequire)({filepath:a});i=d.db}let o=await W(i);if(!o.length){console.info(p.success(`
|
|
3
3
|
${F}
|
|
4
|
-
`)),process.exitCode=0;return}let e={run:0,skipped:0,error:0},g=o.map(a=>{let d=
|
|
4
|
+
`)),process.exitCode=0;return}let e={run:0,skipped:0,error:0},g=o.map(a=>{let d=c.default.basename(a.path,".js");return{title:d,skip(){return e.error>0?(e.skipped++,!0):!1},async task(){try{let{startedAt:u,finishedAt:_}=await G(i,a.path);e.run++,await T(i,{version:a.version,name:d,startedAt:u,finishedAt:_})}catch(u){e.error++,console.error(p.error(`Error in data migration: ${u.message}`))}}}}),s=new E.Listr(g,{renderer:"verbose"});try{await s.run(),await i.$disconnect(),console.log(),A(e),console.log(),e.error&&(process.exitCode=1)}catch{process.exitCode=1,await i.$disconnect(),console.log(),A(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(a=>s.endsWith(a))).map(s=>{let[a]=s.split("-");return{version:a,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),o=parseInt(r.version);return i>o?1:i<o?-1:0}async function G(t,r){let{mod:i}=await(0,h.bundleRequire)({filepath:r}),o=i.default,e=new Date;return await o({db:t}),{startedAt:e,finishedAt:new Date}}async function T(t,{version:r,name:i,startedAt:o,finishedAt:e}){await t.rW_DataMigration.create({data:{version:r,name:i,startedAt:o,finishedAt:e}})}function A(t){t.run&&console.info(p.success(`${t.run} data migration(s) completed successfully.`)),t.error&&console.error(p.error(`${t.error} data migration(s) exited with errors.`)),t.skipped&&console.warn(p.warning(`${t.skipped} data migration(s) skipped due to previous error.`))}var f,c,h,E,m,F,$=M(()=>{"use strict";f=l(require("fs")),c=l(require("path")),h=require("bundle-require"),E=require("listr2"),m=require("@cedarjs/project-config");k();F="No pending data migrations run, already up-to-date."});var b=l(require("path")),j=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)("Redwood CLI Reference","https://redwoodjs.com/docs/cli-commands#datamigrate-up")}`)}$();process.env.REDWOOD_ENV_FILES_LOADED||((0,j.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,P).parse();
|
package/dist/commands/install.js
CHANGED
|
@@ -34,12 +34,12 @@ __export(install_exports, {
|
|
|
34
34
|
handler: () => handler
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(install_exports);
|
|
37
|
-
var
|
|
37
|
+
var import_termi_link = require("termi-link");
|
|
38
38
|
const command = "install";
|
|
39
39
|
const description = "Add the RW_DataMigration model to your schema";
|
|
40
40
|
function builder(yargs) {
|
|
41
41
|
return yargs.epilogue(
|
|
42
|
-
`Also see the ${(0,
|
|
42
|
+
`Also see the ${(0, import_termi_link.terminalLink)(
|
|
43
43
|
"Redwood CLI Reference",
|
|
44
44
|
"https://redwoodjs.com/docs/cli-commands#datamigrate-install"
|
|
45
45
|
)}`
|
package/dist/commands/up.js
CHANGED
|
@@ -34,7 +34,7 @@ __export(up_exports, {
|
|
|
34
34
|
handler: () => handler
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(up_exports);
|
|
37
|
-
var
|
|
37
|
+
var import_termi_link = require("termi-link");
|
|
38
38
|
var import_project_config = require("@cedarjs/project-config");
|
|
39
39
|
const command = "up";
|
|
40
40
|
const description = "Run any outstanding Data Migrations against the database";
|
|
@@ -50,7 +50,7 @@ function builder(yargs) {
|
|
|
50
50
|
description: "Path to the api dist directory",
|
|
51
51
|
default: (0, import_project_config.getPaths)().api.dist
|
|
52
52
|
}).epilogue(
|
|
53
|
-
`Also see the ${(0,
|
|
53
|
+
`Also see the ${(0, import_termi_link.terminalLink)(
|
|
54
54
|
"Redwood CLI Reference",
|
|
55
55
|
"https://redwoodjs.com/docs/cli-commands#datamigrate-up"
|
|
56
56
|
)}`
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,21 +15,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var index_exports = {};
|
|
30
20
|
__export(index_exports, {
|
|
31
21
|
commands: () => commands
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(index_exports);
|
|
34
|
-
var
|
|
24
|
+
var import_termi_link = require("termi-link");
|
|
35
25
|
var import_install = require("./commands/install");
|
|
36
26
|
var import_up = require("./commands/up");
|
|
37
27
|
const command = "data-migrate <command>";
|
|
@@ -39,7 +29,7 @@ const aliases = ["dataMigrate", "dm"];
|
|
|
39
29
|
const description = "Migrate the data in your database";
|
|
40
30
|
function builder(yargs) {
|
|
41
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(
|
|
42
|
-
`Also see the ${(0,
|
|
32
|
+
`Also see the ${(0, import_termi_link.terminalLink)(
|
|
43
33
|
"Redwood CLI Reference",
|
|
44
34
|
"https://redwoodjs.com/docs/cli-commands#datamigrate"
|
|
45
35
|
)}`
|
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.12319+7e59cb429",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -25,19 +25,19 @@
|
|
|
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.12319",
|
|
29
|
+
"@cedarjs/project-config": "1.0.0-canary.12319",
|
|
30
30
|
"bundle-require": "^5.1.0",
|
|
31
31
|
"chalk": "4.1.2",
|
|
32
32
|
"dotenv-defaults": "5.0.2",
|
|
33
33
|
"execa": "5.1.1",
|
|
34
34
|
"fs-extra": "11.2.0",
|
|
35
35
|
"listr2": "7.0.2",
|
|
36
|
-
"
|
|
36
|
+
"termi-link": "1.1.0",
|
|
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.12319",
|
|
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.19.4",
|
|
47
47
|
"typescript": "5.6.2"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "7e59cb429aaf21c100050a6cee2ec1c547db237c"
|
|
50
50
|
}
|