@cedarjs/cli-data-migrate 2.0.1-rc.2 → 2.0.2-next.24
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var L=Object.create;var w=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var v=(t,r)=>()=>(t&&(r=t(t=0)),r);var W=(t,r,i
|
|
2
|
+
"use strict";var L=Object.create;var w=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var v=(t,r)=>()=>(t&&(r=t(t=0)),r);var W=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of R(r))!V.call(t,a)&&a!==e&&w(t,a,{get:()=>r[a],enumerable:!(i=N(r,a))||i.enumerable});return t};var l=(t,r,e)=>(e=t!=null?L(U(t)):{},W(r||!t||!t.__esModule?w(e,"default",{value:t,enumerable:!0}):e,t));var o,c,A=v(()=>{"use strict";o=l(require("ansis")),c={error:o.default.bold.red,warning:o.default.hex("#ffa500"),highlight:o.default.hex("#ffa500"),success:o.default.green,info:o.default.gray,bold:o.default.bold,underline:o.default.underline,note:o.default.blue,tip:o.default.green,important:o.default.magenta,caution:o.default.red,link:o.default.hex("#e8e8e8")}});async function P({importDbClientFromDist:t,distPath:r}){let e,i=!1;if(t){if(!g.default.existsSync(r)){console.warn(`Can't find api dist at ${r}. You may need to build first: yarn cedar build api`),process.exitCode=1;return}let p=m.default.join(r,"lib"),d=m.default.join(p,"db.js");if(!g.default.existsSync(d)){console.error(`Can't find db.js at ${d}. CedarJS expects the db.js file to be in the ${p} directory`),process.exitCode=1;return}e=(await import(d)).db}else(0,y.registerApiSideBabelHook)(),i=!0,e=require(m.default.join((0,u.getPaths)().api.lib,"db")).db;let a=await B(e);if(!a.length){console.info(c.success(`
|
|
3
3
|
${G}
|
|
4
|
-
`)),process.exitCode=0;return}let s={run:0,skipped:0,error:0},n=a.map(p=>{let d=m.default.basename(p.path,".js");return{title:d,skip(){return s.error>0?(s.skipped++,!0):!1},async task(){
|
|
4
|
+
`)),process.exitCode=0;return}let s={run:0,skipped:0,error:0},n=a.map(p=>{let d=m.default.basename(p.path,".js");return{title:d,skip(){return s.error>0?(s.skipped++,!0):!1},async task(){i||(0,y.registerApiSideBabelHook)();try{let{startedAt:h,finishedAt:I}=await q(e,p.path);s.run++,await J(e,{version:p.version,name:d,startedAt:h,finishedAt:I})}catch(h){s.error++,console.error(c.error(`Error in data migration: ${h.message}`))}}}}),f=new j.Listr(n,{renderer:"verbose"});try{await f.run(),await e.$disconnect(),console.log(),E(s),console.log(),s.error&&(process.exitCode=1)}catch{process.exitCode=1,await e.$disconnect(),console.log(),E(s),console.log()}}async function B(t){let r=await(0,u.getDataMigrationsPath)((0,u.getPaths)().api.prismaConfig);if(!g.default.existsSync(r))return[];let e=g.default.readdirSync(r).filter(n=>["js",".ts"].some(f=>n.endsWith(f))).map(n=>{let[f]=n.split("-");return{version:f,path:m.default.join(r,n)}}),a=(await t.rW_DataMigration.findMany({orderBy:{version:"asc"}})).map(n=>n.version.toString());return e.filter(({version:n})=>!a.includes(n)).sort(H)}function H(t,r){let e=parseInt(t.version),i=parseInt(r.version);return e>i?1:e<i?-1:0}async function q(t,r){let e=require(r),i=new Date;return await e.default({db:t}),{startedAt:i,finishedAt:new Date}}async function J(t,{version:r,name:e,startedAt:i,finishedAt:a}){await t.rW_DataMigration.create({data:{version:r,name:e,startedAt:i,finishedAt:a}})}function E(t){t.run&&console.info(c.success(`${t.run} data migration(s) completed successfully.`)),t.error&&console.error(c.error(`${t.error} data migration(s) exited with errors.`)),t.skipped&&console.warn(c.warning(`${t.skipped} data migration(s) skipped due to previous error.`))}var g,m,j,y,u,G,S=v(()=>{"use strict";g=l(require("node:fs")),m=l(require("node:path")),j=require("listr2"),y=require("@cedarjs/babel-config"),u=require("@cedarjs/project-config");A();G="No pending data migrations run, already up-to-date."});var D=l(require("path")),O=require("dotenv-defaults"),$=require("yargs/helpers"),_=l(require("yargs/yargs")),M=require("@cedarjs/project-config");var x=require("termi-link"),b=require("@cedarjs/project-config");var C="Run any outstanding Data Migrations against the database";function k(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,b.getPaths)().api.dist}).epilogue(`Also see the ${(0,x.terminalLink)("CedarJS CLI Reference","https://cedarjs.com/docs/cli-commands#datamigrate-up")}`)}S();process.env.REDWOOD_ENV_FILES_LOADED||((0,O.config)({path:D.default.join((0,M.getPaths)().base,".env"),defaults:D.default.join((0,M.getPaths)().base,".env.defaults"),multiline:!0}),process.env.REDWOOD_ENV_FILES_LOADED="true");(0,_.default)((0,$.hideBin)(process.argv)).scriptName("data-migrate").command("$0",C,k,P).parse();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function handler(): Promise<void>;
|
|
2
2
|
export declare const RW_DATA_MIGRATION_MODEL = "model RW_DataMigration {\n version String @id\n name String\n startedAt DateTime\n finishedAt DateTime\n}";
|
|
3
|
-
export declare const createDatabaseMigrationCommand = "yarn
|
|
3
|
+
export declare const createDatabaseMigrationCommand = "yarn cedar prisma migrate dev --name create_data_migrations --create-only";
|
|
4
4
|
export declare const notes: string;
|
|
5
5
|
//# sourceMappingURL=installHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installHandler.d.ts","sourceRoot":"","sources":["../../src/commands/installHandler.ts"],"names":[],"mappings":"AAcA,wBAAsB,OAAO,kBAmD5B;AAED,eAAO,MAAM,uBAAuB,8HAMlC,CAAA;AAEF,eAAO,MAAM,8BAA8B,
|
|
1
|
+
{"version":3,"file":"installHandler.d.ts","sourceRoot":"","sources":["../../src/commands/installHandler.ts"],"names":[],"mappings":"AAcA,wBAAsB,OAAO,kBAmD5B;AAED,eAAO,MAAM,uBAAuB,8HAMlC,CAAA;AAEF,eAAO,MAAM,8BAA8B,8EACkC,CAAA;AAE7E,eAAO,MAAM,KAAK,QAMN,CAAA"}
|
|
@@ -95,12 +95,12 @@ const RW_DATA_MIGRATION_MODEL = `model RW_DataMigration {
|
|
|
95
95
|
startedAt DateTime
|
|
96
96
|
finishedAt DateTime
|
|
97
97
|
}`;
|
|
98
|
-
const createDatabaseMigrationCommand = "yarn
|
|
98
|
+
const createDatabaseMigrationCommand = "yarn cedar prisma migrate dev --name create_data_migrations --create-only";
|
|
99
99
|
const notes = [
|
|
100
100
|
"",
|
|
101
101
|
import_colors.default.warning("Don't forget to apply the migration when you're ready:"),
|
|
102
102
|
"",
|
|
103
|
-
` ${import_colors.default.bold("yarn
|
|
103
|
+
` ${import_colors.default.bold("yarn cedar prisma migrate dev")}`,
|
|
104
104
|
""
|
|
105
105
|
].join("\n");
|
|
106
106
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -47,7 +47,7 @@ async function handler({
|
|
|
47
47
|
if (importDbClientFromDist) {
|
|
48
48
|
if (!import_node_fs.default.existsSync(distPath)) {
|
|
49
49
|
console.warn(
|
|
50
|
-
`Can't find api dist at ${distPath}. You may need to build first: yarn
|
|
50
|
+
`Can't find api dist at ${distPath}. You may need to build first: yarn cedar build api`
|
|
51
51
|
);
|
|
52
52
|
process.exitCode = 1;
|
|
53
53
|
return;
|
|
@@ -46,7 +46,7 @@ async function handler({
|
|
|
46
46
|
if (importDbClientFromDist) {
|
|
47
47
|
if (!import_node_fs.default.existsSync(distPath)) {
|
|
48
48
|
console.warn(
|
|
49
|
-
`Can't find api dist at ${distPath}. You may need to build first: yarn
|
|
49
|
+
`Can't find api dist at ${distPath}. You may need to build first: yarn cedar build api`
|
|
50
50
|
);
|
|
51
51
|
process.exitCode = 1;
|
|
52
52
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli-data-migrate",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2-next.24+7d862a743",
|
|
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": "vitest run src"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@cedarjs/babel-config": "2.0.
|
|
29
|
-
"@cedarjs/project-config": "2.0.
|
|
28
|
+
"@cedarjs/babel-config": "2.0.2-next.24+7d862a743",
|
|
29
|
+
"@cedarjs/project-config": "2.0.2-next.24+7d862a743",
|
|
30
30
|
"ansis": "4.1.0",
|
|
31
31
|
"bundle-require": "^5.1.0",
|
|
32
32
|
"dotenv-defaults": "5.0.2",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"yargs": "17.7.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@cedarjs/framework-tools": "2.0.
|
|
39
|
+
"@cedarjs/framework-tools": "2.0.2-next.24",
|
|
40
40
|
"@prisma/client": "6.19.0",
|
|
41
|
-
"@types/yargs": "17.0.
|
|
41
|
+
"@types/yargs": "17.0.35",
|
|
42
42
|
"memfs": "4.17.2",
|
|
43
43
|
"tsx": "4.20.5",
|
|
44
|
-
"typescript": "5.9.
|
|
44
|
+
"typescript": "5.9.3",
|
|
45
45
|
"vitest": "3.2.4"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "7d862a7432fd0821b6da7194f2fd88f3d4adb1a0"
|
|
51
51
|
}
|