@cedarjs/cli-data-migrate 1.0.0-canary.12312 → 1.0.0-canary.12316

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 M=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var w=(t,r)=>()=>(t&&(r=t(t=0)),r);var W=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of R(r))!U.call(t,o)&&o!==e&&M(t,o,{get:()=>r[o],enumerable:!(i=N(r,o))||i.enumerable});return t};var d=(t,r,e)=>(e=t!=null?L(V(t)):{},W(r||!t||!t.__esModule?M(e,"default",{value:t,enumerable:!0}):e,t));var a,c,E=w(()=>{"use strict";a=d(require("chalk")),c={error:a.default.bold.red,warning:a.default.hex("#ffa500"),highlight:a.default.hex("#ffa500"),success:a.default.green,info:a.default.grey,bold:a.default.bold,underline:a.default.underline,note:a.default.blue,tip:a.default.green,important:a.default.magenta,caution:a.default.red,link:a.default.hex("#e8e8e8")}});async function O({importDbClientFromDist:t,distPath:r}){let e,i=!1;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 p=m.default.join(r,"lib","db.js");if(!f.default.existsSync(p)){console.error(`Can't find db.js at ${p}. Redwood expects the db.js file to be in the ${m.default.join(r,"lib")} directory`),process.exitCode=1;return}e=(await import(p)).db}else(0,u.registerApiSideBabelHook)(),i=!0,e=require(m.default.join((0,h.getPaths)().api.lib,"db")).db;let o=await B(e);if(!o.length){console.info(c.success(`
2
+ "use strict";var L=Object.create;var M=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var w=(t,r)=>()=>(t&&(r=t(t=0)),r);var W=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of R(r))!U.call(t,o)&&o!==e&&M(t,o,{get:()=>r[o],enumerable:!(i=N(r,o))||i.enumerable});return t};var c=(t,r,e)=>(e=t!=null?L(V(t)):{},W(r||!t||!t.__esModule?M(e,"default",{value:t,enumerable:!0}):e,t));var a,m,C=w(()=>{"use strict";a=c(require("chalk")),m={error:a.default.bold.red,warning:a.default.hex("#ffa500"),highlight:a.default.hex("#ffa500"),success:a.default.green,info:a.default.grey,bold:a.default.bold,underline:a.default.underline,note:a.default.blue,tip:a.default.green,important:a.default.magenta,caution:a.default.red,link:a.default.hex("#e8e8e8")}});async function O({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 rw build api`),process.exitCode=1;return}let p=f.default.join(r,"lib"),d=f.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,h.registerApiSideBabelHook)(),i=!0,e=require(f.default.join((0,b.getPaths)().api.lib,"db")).db;let o=await B(e);if(!o.length){console.info(m.success(`
3
3
  ${H}
4
- `)),process.exitCode=0;return}let s={run:0,skipped:0,error:0},n=o.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,u.registerApiSideBabelHook)();try{let{startedAt:g,finishedAt:I}=await G(e,p.path);s.run++,await T(e,{version:p.version,name:D,startedAt:g,finishedAt:I})}catch(g){s.error++,console.error(c.error(`Error in data migration: ${g.message}`))}}}}),l=new C.Listr(n,{renderer:"verbose"});try{await l.run(),await e.$disconnect(),console.log(),j(s),console.log(),s.error&&(process.exitCode=1)}catch{process.exitCode=1,await e.$disconnect(),console.log(),j(s),console.log()}}async function B(t){let r=(0,h.getPaths)().api.dataMigrations;if(!f.default.existsSync(r))return[];let e=f.default.readdirSync(r).filter(n=>["js",".ts"].some(l=>n.endsWith(l))).map(n=>{let[l]=n.split("-");return{version:l,path:m.default.join(r,n)}}),o=(await t.rW_DataMigration.findMany({orderBy:{version:"asc"}})).map(n=>n.version.toString());return e.filter(({version:n})=>!o.includes(n)).sort(q)}function q(t,r){let e=parseInt(t.version),i=parseInt(r.version);return e>i?1:e<i?-1:0}async function G(t,r){let e=require(r),i=new Date;return await e.default({db:t}),{startedAt:i,finishedAt:new Date}}async function T(t,{version:r,name:e,startedAt:i,finishedAt:o}){await t.rW_DataMigration.create({data:{version:r,name:e,startedAt:i,finishedAt:o}})}function j(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 f,m,C,u,h,H,$=w(()=>{"use strict";f=d(require("fs")),m=d(require("path")),C=require("listr2"),u=require("@cedarjs/babel-config"),h=require("@cedarjs/project-config");E();H="No pending data migrations run, already up-to-date."});var b=d(require("path")),S=require("dotenv-defaults"),_=require("yargs/helpers"),P=d(require("yargs/yargs")),y=require("@cedarjs/project-config");var v=d(require("terminal-link")),x=require("@cedarjs/project-config");var k="Run any outstanding Data Migrations against the database";function A(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,x.getPaths)().api.dist}).epilogue(`Also see the ${(0,v.default)("Redwood CLI Reference","https://redwoodjs.com/docs/cli-commands#datamigrate-up")}`)}$();process.env.REDWOOD_ENV_FILES_LOADED||((0,S.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,P.default)((0,_.hideBin)(process.argv)).scriptName("data-migrate").command("$0",k,A,O).parse();
4
+ `)),process.exitCode=0;return}let s={run:0,skipped:0,error:0},n=o.map(p=>{let d=f.default.basename(p.path,".js");return{title:d,skip(){return s.error>0?(s.skipped++,!0):!1},async task(){i||(0,h.registerApiSideBabelHook)();try{let{startedAt:u,finishedAt:I}=await G(e,p.path);s.run++,await T(e,{version:p.version,name:d,startedAt:u,finishedAt:I})}catch(u){s.error++,console.error(m.error(`Error in data migration: ${u.message}`))}}}}),l=new j.Listr(n,{renderer:"verbose"});try{await l.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=(0,b.getPaths)().api.dataMigrations;if(!g.default.existsSync(r))return[];let e=g.default.readdirSync(r).filter(n=>["js",".ts"].some(l=>n.endsWith(l))).map(n=>{let[l]=n.split("-");return{version:l,path:f.default.join(r,n)}}),o=(await t.rW_DataMigration.findMany({orderBy:{version:"asc"}})).map(n=>n.version.toString());return e.filter(({version:n})=>!o.includes(n)).sort(q)}function q(t,r){let e=parseInt(t.version),i=parseInt(r.version);return e>i?1:e<i?-1:0}async function G(t,r){let e=require(r),i=new Date;return await e.default({db:t}),{startedAt:i,finishedAt:new Date}}async function T(t,{version:r,name:e,startedAt:i,finishedAt:o}){await t.rW_DataMigration.create({data:{version:r,name:e,startedAt:i,finishedAt:o}})}function E(t){t.run&&console.info(m.success(`${t.run} data migration(s) completed successfully.`)),t.error&&console.error(m.error(`${t.error} data migration(s) exited with errors.`)),t.skipped&&console.warn(m.warning(`${t.skipped} data migration(s) skipped due to previous error.`))}var g,f,j,h,b,H,P=w(()=>{"use strict";g=c(require("fs")),f=c(require("path")),j=require("listr2"),h=require("@cedarjs/babel-config"),b=require("@cedarjs/project-config");C();H="No pending data migrations run, already up-to-date."});var y=c(require("path")),S=require("dotenv-defaults"),$=require("yargs/helpers"),_=c(require("yargs/yargs")),D=require("@cedarjs/project-config");var v=c(require("terminal-link")),x=require("@cedarjs/project-config");var k="Run any outstanding Data Migrations against the database";function A(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,x.getPaths)().api.dist}).epilogue(`Also see the ${(0,v.default)("Redwood CLI Reference","https://redwoodjs.com/docs/cli-commands#datamigrate-up")}`)}P();process.env.REDWOOD_ENV_FILES_LOADED||((0,S.config)({path:y.default.join((0,D.getPaths)().base,".env"),defaults:y.default.join((0,D.getPaths)().base,".env.defaults"),multiline:!0}),process.env.REDWOOD_ENV_FILES_LOADED="true");(0,_.default)((0,$.hideBin)(process.argv)).scriptName("data-migrate").command("$0",k,A,O).parse();
@@ -52,13 +52,11 @@ async function handler({
52
52
  process.exitCode = 1;
53
53
  return;
54
54
  }
55
- const distLibDbPath = import_path.default.join(distPath, "lib", "db.js");
55
+ const distLibPath = import_path.default.join(distPath, "lib");
56
+ const distLibDbPath = import_path.default.join(distLibPath, "db.js");
56
57
  if (!import_fs.default.existsSync(distLibDbPath)) {
57
58
  console.error(
58
- `Can't find db.js at ${distLibDbPath}. Redwood expects the db.js file to be in the ${import_path.default.join(
59
- distPath,
60
- "lib"
61
- )} directory`
59
+ `Can't find db.js at ${distLibDbPath}. CedarJS expects the db.js file to be in the ${distLibPath} directory`
62
60
  );
63
61
  process.exitCode = 1;
64
62
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli-data-migrate",
3
- "version": "1.0.0-canary.12312+d68f44bdf",
3
+ "version": "1.0.0-canary.12316+9fbbf96b8",
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.12312",
29
- "@cedarjs/project-config": "1.0.0-canary.12312",
28
+ "@cedarjs/babel-config": "1.0.0-canary.12316",
29
+ "@cedarjs/project-config": "1.0.0-canary.12316",
30
30
  "chalk": "4.1.2",
31
31
  "dotenv-defaults": "5.0.2",
32
32
  "execa": "5.1.1",
@@ -36,7 +36,7 @@
36
36
  "yargs": "17.7.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@cedarjs/framework-tools": "1.0.0-canary.12312",
39
+ "@cedarjs/framework-tools": "1.0.0-canary.12316",
40
40
  "@prisma/client": "5.20.0",
41
41
  "@types/fs-extra": "11.0.4",
42
42
  "@types/yargs": "17.0.33",
@@ -45,5 +45,5 @@
45
45
  "tsx": "4.19.4",
46
46
  "typescript": "5.6.2"
47
47
  },
48
- "gitHead": "d68f44bdff95ab34e366a37722af588649d8f046"
48
+ "gitHead": "9fbbf96b848616acb9561c86b887e355c92ef351"
49
49
  }