@cedarjs/cli-data-migrate 5.0.7-next.338 → 5.0.7

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
- var j=(t,i,r)=>()=>{if(r)throw r[0];try{return t&&(i=t(t=0)),i}catch(a){throw r=[a],a}};import g from"node:fs";import{createRequire as C}from"node:module";import c from"node:path";import{Listr as S}from"listr2";import{registerApiSideBabelHook as D}from"@cedarjs/babel-config";import{colors as m}from"@cedarjs/cli-helpers";import{getPaths as b,getDataMigrationsPath as $}from"@cedarjs/project-config";async function y({importDbClientFromDist:t,distPath:i}){let r,a=!1;if(t){if(!g.existsSync(i)){console.warn(`Can't find api dist at ${i}. You may need to build first: yarn cedar build api`),process.exitCode=1;return}let s=c.join(i,"lib"),d=c.join(s,"db.js");if(!g.existsSync(d)){console.error(`Can't find db.js at ${d}. CedarJS expects the db.js file to be in the ${s} directory`),process.exitCode=1;return}r=(await import(d)).db}else D(),a=!0,r=h(c.join(b().api.lib,"db")).db;let n=await P(r);if(!n.length){console.info(m.success(`
3
- ${L}
4
- `)),process.exitCode=0;return}let o={run:0,skipped:0,error:0},e=n.map(s=>{let d=c.basename(s.path,".js");return{title:d,skip(){return o.error>0?(o.skipped++,!0):!1},async task(){a||D();try{let{startedAt:f,finishedAt:A}=await I(r,s.path);o.run++,await R(r,{version:s.version,name:d,startedAt:f,finishedAt:A})}catch(f){o.error++,console.error(m.error(`Error in data migration: ${f.message}`))}}}}),p=new S(e,{renderer:"verbose"});try{await p.run(),await r.$disconnect(),console.log(),M(o),console.log(),o.error&&(process.exitCode=1)}catch{process.exitCode=1,await r.$disconnect(),console.log(),M(o),console.log()}}async function P(t){let i=await $(b().api.prismaConfig);if(!g.existsSync(i))return[];let r=g.readdirSync(i).filter(e=>["js",".ts"].some(p=>e.endsWith(p))).map(e=>{let[p]=e.split("-");return{version:p,path:c.join(i,e)}}),n=(await t.rW_DataMigration.findMany({orderBy:{version:"asc"}})).map(e=>e.version.toString());return r.filter(({version:e})=>!n.includes(e)).sort(_)}function _(t,i){let r=parseInt(t.version),a=parseInt(i.version);return r>a?1:r<a?-1:0}async function I(t,i){let r=h(i),a=new Date;return await r.default({db:t}),{startedAt:a,finishedAt:new Date}}async function R(t,{version:i,name:r,startedAt:a,finishedAt:n}){await t.rW_DataMigration.create({data:{version:i,name:r,startedAt:a,finishedAt:n}})}function M(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 h,L,w=j(()=>{"use strict";h=C(import.meta.url);L="No pending data migrations run, already up-to-date."});import v from"path";import{config as N}from"dotenv-defaults";import{hideBin as O}from"yargs/helpers";import U from"yargs/yargs";import{getPaths as x}from"@cedarjs/project-config";import{terminalLink as k}from"termi-link";import{getPaths as E,projectIsEsm as W}from"@cedarjs/project-config";var l="Run any outstanding Data Migrations against the database";function u(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:E().api.dist}).epilogue(`Also see the ${k("CedarJS CLI Reference","https://cedarjs.com/docs/cli-commands#datamigrate-up")}`)}w();process.env.CEDAR_ENV_FILES_LOADED||(N({path:v.join(x().base,".env"),defaults:v.join(x().base,".env.defaults"),multiline:!0}),process.env.CEDAR_ENV_FILES_LOADED="true");U(O(process.argv)).scriptName("data-migrate").command("$0",l,u,y).parse();
2
+ "use strict";var _=Object.create;var y=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var R=(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 L(r))!O.call(t,e)&&e!==i&&y(t,e,{get:()=>r[e],enumerable:!(a=I(r,e))||a.enumerable});return t};var l=(t,r,i)=>(i=t!=null?_(N(t)):{},U(r||!t||!t.__esModule?y(i,"default",{value:t,enumerable:!0}):i,t));async function E({importDbClientFromDist:t,distPath:r}){let i,a=!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 s=p.default.join(r,"lib"),d=p.default.join(s,"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 ${s} directory`),process.exitCode=1;return}i=(await import(d)).db}else(0,M.registerApiSideBabelHook)(),a=!0,i=require(p.default.join((0,f.getPaths)().api.lib,"db")).db;let e=await V(i);if(!e.length){console.info(c.colors.success(`
3
+ ${W}
4
+ `)),process.exitCode=0;return}let n={run:0,skipped:0,error:0},o=e.map(s=>{let d=p.default.basename(s.path,".js");return{title:d,skip(){return n.error>0?(n.skipped++,!0):!1},async task(){a||(0,M.registerApiSideBabelHook)();try{let{startedAt:u,finishedAt:P}=await H(i,s.path);n.run++,await q(i,{version:s.version,name:d,startedAt:u,finishedAt:P})}catch(u){n.error++,console.error(c.colors.error(`Error in data migration: ${u.message}`))}}}}),m=new k.Listr(o,{renderer:"verbose"});try{await m.run(),await i.$disconnect(),console.log(),A(n),console.log(),n.error&&(process.exitCode=1)}catch{process.exitCode=1,await i.$disconnect(),console.log(),A(n),console.log()}}async function V(t){let r=await(0,f.getDataMigrationsPath)((0,f.getPaths)().api.prismaConfig);if(!g.default.existsSync(r))return[];let i=g.default.readdirSync(r).filter(o=>["js",".ts"].some(m=>o.endsWith(m))).map(o=>{let[m]=o.split("-");return{version:m,path:p.default.join(r,o)}}),e=(await t.rW_DataMigration.findMany({orderBy:{version:"asc"}})).map(o=>o.version.toString());return i.filter(({version:o})=>!e.includes(o)).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 H(t,r){let i=require(r),a=new Date;return await i.default({db:t}),{startedAt:a,finishedAt:new Date}}async function q(t,{version:r,name:i,startedAt:a,finishedAt:e}){await t.rW_DataMigration.create({data:{version:r,name:i,startedAt:a,finishedAt:e}})}function A(t){t.run&&console.info(c.colors.success(`${t.run} data migration(s) completed successfully.`)),t.error&&console.error(c.colors.error(`${t.error} data migration(s) exited with errors.`)),t.skipped&&console.warn(c.colors.warning(`${t.skipped} data migration(s) skipped due to previous error.`))}var g,p,k,M,c,f,W,j=R(()=>{"use strict";g=l(require("node:fs")),p=l(require("node:path")),k=require("listr2"),M=require("@cedarjs/babel-config"),c=require("@cedarjs/cli-helpers"),f=require("@cedarjs/project-config");W="No pending data migrations run, already up-to-date."});var b=l(require("path")),C=require("dotenv-defaults"),S=require("yargs/helpers"),$=l(require("yargs/yargs")),h=require("@cedarjs/project-config");var w=require("termi-link"),D=require("@cedarjs/project-config");var v="Run any outstanding Data Migrations against the database";function x(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,D.getPaths)().api.dist}).epilogue(`Also see the ${(0,w.terminalLink)("CedarJS CLI Reference","https://cedarjs.com/docs/cli-commands#datamigrate-up")}`)}j();process.env.CEDAR_ENV_FILES_LOADED||((0,C.config)({path:b.default.join((0,h.getPaths)().base,".env"),defaults:b.default.join((0,h.getPaths)().base,".env.defaults"),multiline:!0}),process.env.CEDAR_ENV_FILES_LOADED="true");(0,$.default)((0,S.hideBin)(process.argv)).scriptName("data-migrate").command("$0",v,x,E).parse();
@@ -1,9 +1,45 @@
1
- import { terminalLink } from "termi-link";
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var install_exports = {};
30
+ __export(install_exports, {
31
+ builder: () => builder,
32
+ command: () => command,
33
+ description: () => description,
34
+ handler: () => handler
35
+ });
36
+ module.exports = __toCommonJS(install_exports);
37
+ var import_termi_link = require("termi-link");
2
38
  const command = "install";
3
39
  const description = "Add the RW_DataMigration model to your schema";
4
40
  function builder(yargs) {
5
41
  return yargs.epilogue(
6
- `Also see the ${terminalLink(
42
+ `Also see the ${(0, import_termi_link.terminalLink)(
7
43
  "CedarJS CLI Reference",
8
44
  "https://cedarjs.com/docs/cli-commands#datamigrate-install"
9
45
  )}`
@@ -13,9 +49,10 @@ async function handler() {
13
49
  const { handler: dataMigrateInstallHandler } = await import("./installHandler.js");
14
50
  await dataMigrateInstallHandler();
15
51
  }
16
- export {
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
17
54
  builder,
18
55
  command,
19
56
  description,
20
57
  handler
21
- };
58
+ });
@@ -1,32 +1,64 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import execa from "execa";
4
- import { Listr } from "listr2";
5
- import { colors as c } from "@cedarjs/cli-helpers";
6
- import {
7
- getPaths,
8
- getSchemaPath,
9
- getDataMigrationsPath
10
- } from "@cedarjs/project-config";
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var installHandler_exports = {};
30
+ __export(installHandler_exports, {
31
+ RW_DATA_MIGRATION_MODEL: () => RW_DATA_MIGRATION_MODEL,
32
+ createDatabaseMigrationCommand: () => createDatabaseMigrationCommand,
33
+ handler: () => handler,
34
+ notes: () => notes
35
+ });
36
+ module.exports = __toCommonJS(installHandler_exports);
37
+ var import_node_fs = __toESM(require("node:fs"));
38
+ var import_node_path = __toESM(require("node:path"));
39
+ var import_execa = __toESM(require("execa"));
40
+ var import_listr2 = require("listr2");
41
+ var import_cli_helpers = require("@cedarjs/cli-helpers");
42
+ var import_project_config = require("@cedarjs/project-config");
11
43
  async function handler() {
12
- const cedarProjectPaths = getPaths();
44
+ const cedarProjectPaths = (0, import_project_config.getPaths)();
13
45
  const prismaConfigPath = cedarProjectPaths.api.prismaConfig;
14
- const dataMigrationsPath = await getDataMigrationsPath(prismaConfigPath);
15
- const tasks = new Listr(
46
+ const dataMigrationsPath = await (0, import_project_config.getDataMigrationsPath)(prismaConfigPath);
47
+ const tasks = new import_listr2.Listr(
16
48
  [
17
49
  {
18
50
  title: "Creating the dataMigrations directory...",
19
51
  task() {
20
- fs.mkdirSync(dataMigrationsPath, { recursive: true });
21
- fs.writeFileSync(path.join(dataMigrationsPath, ".keep"), "");
52
+ import_node_fs.default.mkdirSync(dataMigrationsPath, { recursive: true });
53
+ import_node_fs.default.writeFileSync(import_node_path.default.join(dataMigrationsPath, ".keep"), "");
22
54
  }
23
55
  },
24
56
  {
25
57
  title: "Adding the RW_DataMigration model to schema.prisma...",
26
58
  async task() {
27
- const dbSchemaFilePath = await getSchemaPath(prismaConfigPath);
28
- const dbSchemaFileContent = fs.readFileSync(dbSchemaFilePath, "utf-8");
29
- fs.writeFileSync(
59
+ const dbSchemaFilePath = await (0, import_project_config.getSchemaPath)(prismaConfigPath);
60
+ const dbSchemaFileContent = import_node_fs.default.readFileSync(dbSchemaFilePath, "utf-8");
61
+ import_node_fs.default.writeFileSync(
30
62
  dbSchemaFilePath,
31
63
  [dbSchemaFileContent.trim(), "", RW_DATA_MIGRATION_MODEL, ""].join(
32
64
  "\n"
@@ -37,7 +69,7 @@ async function handler() {
37
69
  {
38
70
  title: "Creating the database migration...",
39
71
  task() {
40
- return execa.command(createDatabaseMigrationCommand, {
72
+ return import_execa.default.command(createDatabaseMigrationCommand, {
41
73
  cwd: cedarProjectPaths.base
42
74
  }).stdout;
43
75
  }
@@ -54,7 +86,7 @@ async function handler() {
54
86
  console.log(notes);
55
87
  } catch (e) {
56
88
  process.exitCode = 1;
57
- console.error(c.error(e.message));
89
+ console.error(import_cli_helpers.colors.error(e.message));
58
90
  }
59
91
  }
60
92
  const RW_DATA_MIGRATION_MODEL = `model RW_DataMigration {
@@ -66,14 +98,15 @@ const RW_DATA_MIGRATION_MODEL = `model RW_DataMigration {
66
98
  const createDatabaseMigrationCommand = "yarn cedar prisma migrate dev --name create_data_migrations --create-only";
67
99
  const notes = [
68
100
  "",
69
- c.warning("Don't forget to apply the migration when you're ready:"),
101
+ import_cli_helpers.colors.warning("Don't forget to apply the migration when you're ready:"),
70
102
  "",
71
- ` ${c.bold("yarn cedar prisma migrate dev")}`,
103
+ ` ${import_cli_helpers.colors.bold("yarn cedar prisma migrate dev")}`,
72
104
  ""
73
105
  ].join("\n");
74
- export {
106
+ // Annotate the CommonJS export names for ESM import in node:
107
+ 0 && (module.exports = {
75
108
  RW_DATA_MIGRATION_MODEL,
76
109
  createDatabaseMigrationCommand,
77
110
  handler,
78
111
  notes
79
- };
112
+ });
@@ -1,5 +1,5 @@
1
1
  import type { Argv } from 'yargs';
2
- import type { DataMigrateUpOptions } from '../types.js';
2
+ import type { DataMigrateUpOptions } from '../types';
3
3
  export declare const command = "up";
4
4
  export declare const description = "Run any outstanding Data Migrations against the database";
5
5
  export declare function builder(yargs: Argv): Argv;
@@ -1 +1 @@
1
- {"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/commands/up.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAIjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvD,eAAO,MAAM,OAAO,OAAO,CAAA;AAC3B,eAAO,MAAM,WAAW,6DACoC,CAAA;AAE5D,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAoBzC;AAED,wBAAsB,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ1E"}
1
+ {"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/commands/up.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAIjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,eAAO,MAAM,OAAO,OAAO,CAAA;AAC3B,eAAO,MAAM,WAAW,6DACoC,CAAA;AAE5D,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAoBzC;AAED,wBAAsB,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ1E"}
@@ -1,5 +1,41 @@
1
- import { terminalLink } from "termi-link";
2
- import { getPaths, projectIsEsm } from "@cedarjs/project-config";
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var up_exports = {};
30
+ __export(up_exports, {
31
+ builder: () => builder,
32
+ command: () => command,
33
+ description: () => description,
34
+ handler: () => handler
35
+ });
36
+ module.exports = __toCommonJS(up_exports);
37
+ var import_termi_link = require("termi-link");
38
+ var import_project_config = require("@cedarjs/project-config");
3
39
  const command = "up";
4
40
  const description = "Run any outstanding Data Migrations against the database";
5
41
  function builder(yargs) {
@@ -12,16 +48,16 @@ function builder(yargs) {
12
48
  type: "string",
13
49
  alias: "d",
14
50
  description: "Path to the api dist directory",
15
- default: getPaths().api.dist
51
+ default: (0, import_project_config.getPaths)().api.dist
16
52
  }).epilogue(
17
- `Also see the ${terminalLink(
53
+ `Also see the ${(0, import_termi_link.terminalLink)(
18
54
  "CedarJS CLI Reference",
19
55
  "https://cedarjs.com/docs/cli-commands#datamigrate-up"
20
56
  )}`
21
57
  );
22
58
  }
23
59
  async function handler(options) {
24
- if (projectIsEsm()) {
60
+ if ((0, import_project_config.projectIsEsm)()) {
25
61
  const { handler: dataMigrateUpHandler } = await import("./upHandlerEsm.js");
26
62
  await dataMigrateUpHandler(options);
27
63
  } else {
@@ -29,9 +65,10 @@ async function handler(options) {
29
65
  await dataMigrateUpHandler(options);
30
66
  }
31
67
  }
32
- export {
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
33
70
  builder,
34
71
  command,
35
72
  description,
36
73
  handler
37
- };
74
+ });
@@ -1,4 +1,4 @@
1
- import type { DataMigrateUpOptions } from '../types.js';
1
+ import type { DataMigrateUpOptions } from '../types';
2
2
  export declare function handler({ importDbClientFromDist, distPath, }: DataMigrateUpOptions): Promise<void>;
3
3
  export declare const NO_PENDING_MIGRATIONS_MESSAGE = "No pending data migrations run, already up-to-date.";
4
4
  //# sourceMappingURL=upHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upHandler.d.ts","sourceRoot":"","sources":["../../src/commands/upHandler.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,aAAa,CAAA;AA2BtE,wBAAsB,OAAO,CAAC,EAC5B,sBAAsB,EACtB,QAAQ,GACT,EAAE,oBAAoB,iBA2GtB;AA8ED,eAAO,MAAM,6BAA6B,wDACa,CAAA"}
1
+ {"version":3,"file":"upHandler.d.ts","sourceRoot":"","sources":["../../src/commands/upHandler.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,UAAU,CAAA;AAoBnE,wBAAsB,OAAO,CAAC,EAC5B,sBAAsB,EACtB,QAAQ,GACT,EAAE,oBAAoB,iBA2GtB;AA8ED,eAAO,MAAM,6BAA6B,wDACa,CAAA"}
@@ -1,11 +1,43 @@
1
- import fs from "node:fs";
2
- import { createRequire } from "node:module";
3
- import path from "node:path";
4
- import { Listr } from "listr2";
5
- import { registerApiSideBabelHook } from "@cedarjs/babel-config";
6
- import { colors as c } from "@cedarjs/cli-helpers";
7
- import { getPaths, getDataMigrationsPath } from "@cedarjs/project-config";
8
- const require2 = createRequire(import.meta.url);
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var upHandler_exports = {};
30
+ __export(upHandler_exports, {
31
+ NO_PENDING_MIGRATIONS_MESSAGE: () => NO_PENDING_MIGRATIONS_MESSAGE,
32
+ handler: () => handler
33
+ });
34
+ module.exports = __toCommonJS(upHandler_exports);
35
+ var import_node_fs = __toESM(require("node:fs"));
36
+ var import_node_path = __toESM(require("node:path"));
37
+ var import_listr2 = require("listr2");
38
+ var import_babel_config = require("@cedarjs/babel-config");
39
+ var import_cli_helpers = require("@cedarjs/cli-helpers");
40
+ var import_project_config = require("@cedarjs/project-config");
9
41
  async function handler({
10
42
  importDbClientFromDist,
11
43
  distPath
@@ -13,16 +45,16 @@ async function handler({
13
45
  let db;
14
46
  let requireHookRegistered = false;
15
47
  if (importDbClientFromDist) {
16
- if (!fs.existsSync(distPath)) {
48
+ if (!import_node_fs.default.existsSync(distPath)) {
17
49
  console.warn(
18
50
  `Can't find api dist at ${distPath}. You may need to build first: yarn cedar build api`
19
51
  );
20
52
  process.exitCode = 1;
21
53
  return;
22
54
  }
23
- const distLibPath = path.join(distPath, "lib");
24
- const distLibDbPath = path.join(distLibPath, "db.js");
25
- if (!fs.existsSync(distLibDbPath)) {
55
+ const distLibPath = import_node_path.default.join(distPath, "lib");
56
+ const distLibDbPath = import_node_path.default.join(distLibPath, "db.js");
57
+ if (!import_node_fs.default.existsSync(distLibDbPath)) {
26
58
  console.error(
27
59
  `Can't find db.js at ${distLibDbPath}. CedarJS expects the db.js file to be in the ${distLibPath} directory`
28
60
  );
@@ -31,13 +63,13 @@ async function handler({
31
63
  }
32
64
  db = (await import(distLibDbPath)).db;
33
65
  } else {
34
- registerApiSideBabelHook();
66
+ (0, import_babel_config.registerApiSideBabelHook)();
35
67
  requireHookRegistered = true;
36
- db = require2(path.join(getPaths().api.lib, "db")).db;
68
+ db = require(import_node_path.default.join((0, import_project_config.getPaths)().api.lib, "db")).db;
37
69
  }
38
70
  const pendingDataMigrations = await getPendingDataMigrations(db);
39
71
  if (!pendingDataMigrations.length) {
40
- console.info(c.success(`
72
+ console.info(import_cli_helpers.colors.success(`
41
73
  ${NO_PENDING_MIGRATIONS_MESSAGE}
42
74
  `));
43
75
  process.exitCode = 0;
@@ -45,7 +77,7 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
45
77
  }
46
78
  const counters = { run: 0, skipped: 0, error: 0 };
47
79
  const dataMigrationTasks = pendingDataMigrations.map((dataMigration) => {
48
- const dataMigrationName = path.basename(dataMigration.path, ".js");
80
+ const dataMigrationName = import_node_path.default.basename(dataMigration.path, ".js");
49
81
  return {
50
82
  title: dataMigrationName,
51
83
  skip() {
@@ -58,7 +90,7 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
58
90
  },
59
91
  async task() {
60
92
  if (!requireHookRegistered) {
61
- registerApiSideBabelHook();
93
+ (0, import_babel_config.registerApiSideBabelHook)();
62
94
  }
63
95
  try {
64
96
  const { startedAt, finishedAt } = await runDataMigration(
@@ -75,13 +107,13 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
75
107
  } catch (e) {
76
108
  counters.error++;
77
109
  console.error(
78
- c.error(`Error in data migration: ${e.message}`)
110
+ import_cli_helpers.colors.error(`Error in data migration: ${e.message}`)
79
111
  );
80
112
  }
81
113
  }
82
114
  };
83
115
  });
84
- const tasks = new Listr(dataMigrationTasks, {
116
+ const tasks = new import_listr2.Listr(dataMigrationTasks, {
85
117
  renderer: "verbose"
86
118
  });
87
119
  try {
@@ -102,13 +134,13 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
102
134
  }
103
135
  }
104
136
  async function getPendingDataMigrations(db) {
105
- const dataMigrationsPath = await getDataMigrationsPath(
106
- getPaths().api.prismaConfig
137
+ const dataMigrationsPath = await (0, import_project_config.getDataMigrationsPath)(
138
+ (0, import_project_config.getPaths)().api.prismaConfig
107
139
  );
108
- if (!fs.existsSync(dataMigrationsPath)) {
140
+ if (!import_node_fs.default.existsSync(dataMigrationsPath)) {
109
141
  return [];
110
142
  }
111
- const dataMigrations = fs.readdirSync(dataMigrationsPath).filter(
143
+ const dataMigrations = import_node_fs.default.readdirSync(dataMigrationsPath).filter(
112
144
  (dataMigrationFileName) => ["js", ".ts"].some(
113
145
  (extension) => dataMigrationFileName.endsWith(extension)
114
146
  )
@@ -116,7 +148,7 @@ async function getPendingDataMigrations(db) {
116
148
  const [version] = dataMigrationFileName.split("-");
117
149
  return {
118
150
  version,
119
- path: path.join(dataMigrationsPath, dataMigrationFileName)
151
+ path: import_node_path.default.join(dataMigrationsPath, dataMigrationFileName)
120
152
  };
121
153
  });
122
154
  const ranDataMigrations = await db.rW_DataMigration.findMany(
@@ -144,7 +176,7 @@ function sortDataMigrationsByVersion(dataMigrationA, dataMigrationB) {
144
176
  return 0;
145
177
  }
146
178
  async function runDataMigration(db, dataMigrationPath) {
147
- const dataMigration = require2(dataMigrationPath);
179
+ const dataMigration = require(dataMigrationPath);
148
180
  const startedAt = /* @__PURE__ */ new Date();
149
181
  await dataMigration.default({ db });
150
182
  const finishedAt = /* @__PURE__ */ new Date();
@@ -159,23 +191,24 @@ async function recordDataMigration(db, { version, name, startedAt, finishedAt })
159
191
  function reportDataMigrations(counters) {
160
192
  if (counters.run) {
161
193
  console.info(
162
- c.success(`${counters.run} data migration(s) completed successfully.`)
194
+ import_cli_helpers.colors.success(`${counters.run} data migration(s) completed successfully.`)
163
195
  );
164
196
  }
165
197
  if (counters.error) {
166
198
  console.error(
167
- c.error(`${counters.error} data migration(s) exited with errors.`)
199
+ import_cli_helpers.colors.error(`${counters.error} data migration(s) exited with errors.`)
168
200
  );
169
201
  }
170
202
  if (counters.skipped) {
171
203
  console.warn(
172
- c.warning(
204
+ import_cli_helpers.colors.warning(
173
205
  `${counters.skipped} data migration(s) skipped due to previous error.`
174
206
  )
175
207
  );
176
208
  }
177
209
  }
178
- export {
210
+ // Annotate the CommonJS export names for ESM import in node:
211
+ 0 && (module.exports = {
179
212
  NO_PENDING_MIGRATIONS_MESSAGE,
180
213
  handler
181
- };
214
+ });
@@ -1,4 +1,4 @@
1
- import type { DataMigrateUpOptions } from '../types.js';
1
+ import type { DataMigrateUpOptions } from '../types';
2
2
  export declare function handler({ importDbClientFromDist, distPath, }: DataMigrateUpOptions): Promise<void>;
3
3
  export declare const NO_PENDING_MIGRATIONS_MESSAGE = "No pending data migrations run, already up-to-date.";
4
4
  //# sourceMappingURL=upHandlerEsm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upHandlerEsm.d.ts","sourceRoot":"","sources":["../../src/commands/upHandlerEsm.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,aAAa,CAAA;AAsCtE,wBAAsB,OAAO,CAAC,EAC5B,sBAAsB,EACtB,QAAQ,GACT,EAAE,oBAAoB,iBAoMtB;AA6DD,eAAO,MAAM,6BAA6B,wDACa,CAAA"}
1
+ {"version":3,"file":"upHandlerEsm.d.ts","sourceRoot":"","sources":["../../src/commands/upHandlerEsm.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,UAAU,CAAA;AAoBnE,wBAAsB,OAAO,CAAC,EAC5B,sBAAsB,EACtB,QAAQ,GACT,EAAE,oBAAoB,iBAuHtB;AAiFD,eAAO,MAAM,6BAA6B,wDACa,CAAA"}
@@ -1,108 +1,59 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { Listr } from "listr2";
4
- import { createServer, isRunnableDevEnvironment } from "vite";
5
- import { colors as c } from "@cedarjs/cli-helpers";
6
- import {
7
- getPaths,
8
- getDataMigrationsPath,
9
- resolveFile,
10
- importStatementPath
11
- } from "@cedarjs/project-config";
12
- function resolveId(id) {
13
- if (fs.existsSync(id) && fs.statSync(id).isFile()) {
14
- return id;
15
- }
16
- const withoutExt = /\.jsx?$/.test(id) ? id.replace(/\.jsx?$/, "") : id;
17
- for (const ext of [".ts", ".tsx", ".js", ".jsx"]) {
18
- if (fs.existsSync(withoutExt + ext)) {
19
- return withoutExt + ext;
20
- }
21
- }
22
- if (fs.existsSync(id) && fs.statSync(id).isDirectory()) {
23
- for (const base of ["index", path.basename(id)]) {
24
- for (const ext of [".ts", ".tsx", ".js", ".jsx"]) {
25
- const candidate = path.join(id, base + ext);
26
- if (fs.existsSync(candidate)) {
27
- return candidate;
28
- }
29
- }
30
- }
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
17
  }
32
- return id;
33
- }
18
+ return to;
19
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var upHandlerEsm_exports = {};
30
+ __export(upHandlerEsm_exports, {
31
+ NO_PENDING_MIGRATIONS_MESSAGE: () => NO_PENDING_MIGRATIONS_MESSAGE,
32
+ handler: () => handler
33
+ });
34
+ module.exports = __toCommonJS(upHandlerEsm_exports);
35
+ var import_node_fs = __toESM(require("node:fs"));
36
+ var import_node_path = __toESM(require("node:path"));
37
+ var import_bundle_require = require("bundle-require");
38
+ var import_listr2 = require("listr2");
39
+ var import_cli_helpers = require("@cedarjs/cli-helpers");
40
+ var import_project_config = require("@cedarjs/project-config");
34
41
  async function handler({
35
42
  importDbClientFromDist,
36
43
  distPath
37
44
  }) {
38
45
  let db;
39
- let server = null;
40
- let cedarPlugins;
41
- async function getRunner() {
42
- if (!server) {
43
- if (!cedarPlugins) {
44
- const mod = await import("@cedarjs/vite");
45
- cedarPlugins = mod;
46
- }
47
- server = await createServer({
48
- mode: "production",
49
- optimizeDeps: {
50
- noDiscovery: true,
51
- include: void 0
52
- },
53
- server: {
54
- hmr: false,
55
- watch: null
56
- },
57
- environments: {
58
- nodeRunnerEnv: {}
59
- },
60
- resolve: {
61
- alias: [
62
- {
63
- find: /^api\//,
64
- replacement: getPaths().api.base + "/"
65
- },
66
- {
67
- find: /^src\//,
68
- replacement: "src/",
69
- customResolver: (id, importer, _options) => {
70
- const apiImportBase = importStatementPath(getPaths().api.base);
71
- if (importer?.startsWith(apiImportBase)) {
72
- const apiImportSrc = importStatementPath(getPaths().api.src);
73
- const apiId = id.replace("src", apiImportSrc);
74
- return { id: resolveId(apiId) };
75
- }
76
- return null;
77
- }
78
- }
79
- ]
80
- },
81
- plugins: [
82
- cedarPlugins.cedarCjsCompatPlugin(),
83
- cedarPlugins.cedarjsResolveCedarStyleImportsPlugin(),
84
- cedarPlugins.cedarImportDirPlugin(),
85
- cedarPlugins.cedarAutoImportsPlugin()
86
- ]
87
- });
88
- }
89
- const env = server.environments.nodeRunnerEnv;
90
- if (!env || !isRunnableDevEnvironment(env)) {
91
- throw new Error("Vite environment is not runnable.");
92
- }
93
- return env.runner;
94
- }
95
46
  if (importDbClientFromDist) {
96
- if (!fs.existsSync(distPath)) {
47
+ if (!import_node_fs.default.existsSync(distPath)) {
97
48
  console.warn(
98
49
  `Can't find api dist at ${distPath}. You may need to build first: yarn cedar build api`
99
50
  );
100
51
  process.exitCode = 1;
101
52
  return;
102
53
  }
103
- const distLibPath = path.join(distPath, "lib");
104
- const distLibDbPath = path.join(distLibPath, "db.js");
105
- if (!fs.existsSync(distLibDbPath)) {
54
+ const distLibPath = import_node_path.default.join(distPath, "lib");
55
+ const distLibDbPath = import_node_path.default.join(distLibPath, "db.js");
56
+ if (!import_node_fs.default.existsSync(distLibDbPath)) {
106
57
  console.error(
107
58
  `Can't find db.js at ${distLibDbPath}. CedarJS expects the db.js file to be in the ${distLibPath} directory`
108
59
  );
@@ -111,33 +62,29 @@ async function handler({
111
62
  }
112
63
  db = (await import(distLibDbPath)).db;
113
64
  } else {
114
- const dbPath = resolveFile(path.join(getPaths().api.lib, "db"));
65
+ const dbPath = (0, import_project_config.resolveFile)(import_node_path.default.join((0, import_project_config.getPaths)().api.lib, "db"));
115
66
  if (!dbPath) {
116
- console.error(`Can't find your db file in ${getPaths().api.lib}`);
67
+ console.error(`Can't find your db file in ${(0, import_project_config.getPaths)().api.lib}`);
117
68
  process.exitCode = 1;
118
69
  return;
119
70
  }
120
- try {
121
- const runner = await getRunner();
122
- const dbModule = await runner.import(dbPath);
123
- db = dbModule.db;
124
- } catch (e) {
125
- await server?.close();
126
- throw e;
127
- }
71
+ const { mod } = await (0, import_bundle_require.bundleRequire)({
72
+ filepath: dbPath
73
+ // TODO: Add plugins
74
+ });
75
+ db = mod.db;
128
76
  }
129
77
  const pendingDataMigrations = await getPendingDataMigrations(db);
130
78
  if (!pendingDataMigrations.length) {
131
- console.info(c.success(`
79
+ console.info(import_cli_helpers.colors.success(`
132
80
  ${NO_PENDING_MIGRATIONS_MESSAGE}
133
81
  `));
134
82
  process.exitCode = 0;
135
- await server?.close();
136
83
  return;
137
84
  }
138
85
  const counters = { run: 0, skipped: 0, error: 0 };
139
86
  const dataMigrationTasks = pendingDataMigrations.map((dataMigration) => {
140
- const dataMigrationName = path.basename(dataMigration.path, ".js");
87
+ const dataMigrationName = import_node_path.default.basename(dataMigration.path, ".js");
141
88
  return {
142
89
  title: dataMigrationName,
143
90
  skip() {
@@ -163,13 +110,14 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
163
110
  });
164
111
  } catch (e) {
165
112
  counters.error++;
166
- const message = e instanceof Error ? e.message : String(e);
167
- console.error(c.error(`Error in data migration: ${message}`));
113
+ console.error(
114
+ import_cli_helpers.colors.error(`Error in data migration: ${e.message}`)
115
+ );
168
116
  }
169
117
  }
170
118
  };
171
119
  });
172
- const tasks = new Listr(dataMigrationTasks, {
120
+ const tasks = new import_listr2.Listr(dataMigrationTasks, {
173
121
  renderer: "verbose"
174
122
  });
175
123
  try {
@@ -187,29 +135,16 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
187
135
  console.log();
188
136
  reportDataMigrations(counters);
189
137
  console.log();
190
- } finally {
191
- if (server) {
192
- await server.close();
193
- }
194
- }
195
- async function runDataMigration(db2, dataMigrationPath) {
196
- const runner = await getRunner();
197
- const dataMigrationModule = await runner.import(dataMigrationPath);
198
- const dataMigration = dataMigrationModule.default;
199
- const startedAt = /* @__PURE__ */ new Date();
200
- await dataMigration({ db: db2 });
201
- const finishedAt = /* @__PURE__ */ new Date();
202
- return { startedAt, finishedAt };
203
138
  }
204
139
  }
205
140
  async function getPendingDataMigrations(db) {
206
- const dataMigrationsPath = await getDataMigrationsPath(
207
- getPaths().api.prismaConfig
141
+ const dataMigrationsPath = await (0, import_project_config.getDataMigrationsPath)(
142
+ (0, import_project_config.getPaths)().api.prismaConfig
208
143
  );
209
- if (!fs.existsSync(dataMigrationsPath)) {
144
+ if (!import_node_fs.default.existsSync(dataMigrationsPath)) {
210
145
  return [];
211
146
  }
212
- const dataMigrations = fs.readdirSync(dataMigrationsPath).filter(
147
+ const dataMigrations = import_node_fs.default.readdirSync(dataMigrationsPath).filter(
213
148
  (dataMigrationFileName) => ["js", ".ts"].some(
214
149
  (extension) => dataMigrationFileName.endsWith(extension)
215
150
  )
@@ -217,7 +152,7 @@ async function getPendingDataMigrations(db) {
217
152
  const [version] = dataMigrationFileName.split("-");
218
153
  return {
219
154
  version,
220
- path: path.join(dataMigrationsPath, dataMigrationFileName)
155
+ path: import_node_path.default.join(dataMigrationsPath, dataMigrationFileName)
221
156
  };
222
157
  });
223
158
  const ranDataMigrations = await db.rW_DataMigration.findMany(
@@ -244,6 +179,17 @@ function sortDataMigrationsByVersion(dataMigrationA, dataMigrationB) {
244
179
  }
245
180
  return 0;
246
181
  }
182
+ async function runDataMigration(db, dataMigrationPath) {
183
+ const { mod } = await (0, import_bundle_require.bundleRequire)({
184
+ filepath: dataMigrationPath
185
+ // TODO: Add plugins
186
+ });
187
+ const dataMigration = mod.default;
188
+ const startedAt = /* @__PURE__ */ new Date();
189
+ await dataMigration({ db });
190
+ const finishedAt = /* @__PURE__ */ new Date();
191
+ return { startedAt, finishedAt };
192
+ }
247
193
  const NO_PENDING_MIGRATIONS_MESSAGE = "No pending data migrations run, already up-to-date.";
248
194
  async function recordDataMigration(db, { version, name, startedAt, finishedAt }) {
249
195
  await db.rW_DataMigration.create({
@@ -253,23 +199,24 @@ async function recordDataMigration(db, { version, name, startedAt, finishedAt })
253
199
  function reportDataMigrations(counters) {
254
200
  if (counters.run) {
255
201
  console.info(
256
- c.success(`${counters.run} data migration(s) completed successfully.`)
202
+ import_cli_helpers.colors.success(`${counters.run} data migration(s) completed successfully.`)
257
203
  );
258
204
  }
259
205
  if (counters.error) {
260
206
  console.error(
261
- c.error(`${counters.error} data migration(s) exited with errors.`)
207
+ import_cli_helpers.colors.error(`${counters.error} data migration(s) exited with errors.`)
262
208
  );
263
209
  }
264
210
  if (counters.skipped) {
265
211
  console.warn(
266
- c.warning(
212
+ import_cli_helpers.colors.warning(
267
213
  `${counters.skipped} data migration(s) skipped due to previous error.`
268
214
  )
269
215
  );
270
216
  }
271
217
  }
272
- export {
218
+ // Annotate the CommonJS export names for ESM import in node:
219
+ 0 && (module.exports = {
273
220
  NO_PENDING_MIGRATIONS_MESSAGE,
274
221
  handler
275
- };
222
+ });
package/dist/index.js CHANGED
@@ -1,22 +1,35 @@
1
- import { terminalLink } from "termi-link";
2
- import {
3
- command as installCommand,
4
- description as installDescription,
5
- builder as installBuilder,
6
- handler as installHandler
7
- } from "./commands/install.js";
8
- import {
9
- command as upCommand,
10
- description as upDescription,
11
- builder as upBuilder,
12
- handler as upHandler
13
- } from "./commands/up.js";
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var index_exports = {};
20
+ __export(index_exports, {
21
+ commands: () => commands
22
+ });
23
+ module.exports = __toCommonJS(index_exports);
24
+ var import_termi_link = require("termi-link");
25
+ var import_install = require("./commands/install");
26
+ var import_up = require("./commands/up");
14
27
  const command = "data-migrate <command>";
15
28
  const aliases = ["dataMigrate", "dm"];
16
29
  const description = "Migrate the data in your database";
17
30
  function builder(yargs) {
18
- yargs.command(installCommand, installDescription, installBuilder, installHandler).command(upCommand, upDescription, upBuilder, upHandler).epilogue(
19
- `Also see the ${terminalLink(
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
+ `Also see the ${(0, import_termi_link.terminalLink)(
20
33
  "CedarJS CLI Reference",
21
34
  "https://cedarjs.com/docs/cli-commands#datamigrate"
22
35
  )}`
@@ -30,6 +43,7 @@ const commands = [
30
43
  builder
31
44
  }
32
45
  ];
33
- export {
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
34
48
  commands
35
- };
49
+ });
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@cedarjs/cli-data-migrate",
3
- "version": "5.0.7-next.338",
3
+ "version": "5.0.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
7
7
  "directory": "packages/cli-packages/dataMigrate"
8
8
  },
9
9
  "license": "MIT",
10
- "type": "module",
10
+ "type": "commonjs",
11
11
  "exports": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts",
13
13
  "bin": {
@@ -17,33 +17,32 @@
17
17
  "dist"
18
18
  ],
19
19
  "scripts": {
20
- "build": "node ./build.mts",
20
+ "build": "node ./build.mts && yarn build:types",
21
21
  "build:pack": "yarn pack -o cedarjs-cli-data-migrate.tgz",
22
- "build:types": "tsc --build --verbose ./tsconfig.build.json",
22
+ "build:types": "tsc --build --verbose",
23
23
  "prepublishOnly": "NODE_ENV=production yarn build",
24
24
  "test": "yarn test:unit && yarn test:dist",
25
25
  "test:dist": "vitest run ./dist.test.ts",
26
26
  "test:unit": "vitest run src"
27
27
  },
28
28
  "dependencies": {
29
- "@cedarjs/babel-config": "5.0.7-next.338",
30
- "@cedarjs/cli-helpers": "5.0.7-next.338",
31
- "@cedarjs/project-config": "5.0.7-next.338",
32
- "@cedarjs/vite": "5.0.7-next.338",
29
+ "@cedarjs/babel-config": "5.0.7",
30
+ "@cedarjs/cli-helpers": "5.0.7",
31
+ "@cedarjs/project-config": "5.0.7",
32
+ "bundle-require": "^5.1.0",
33
33
  "dotenv-defaults": "5.0.2",
34
34
  "execa": "5.1.1",
35
35
  "listr2": "10.2.2",
36
36
  "termi-link": "1.1.0",
37
- "vite": "7.3.6",
38
37
  "yargs": "17.7.3"
39
38
  },
40
39
  "devDependencies": {
41
- "@cedarjs/framework-tools": "5.0.7-next.338",
40
+ "@cedarjs/framework-tools": "5.0.7",
42
41
  "@prisma/client": "7.8.0",
43
42
  "@types/yargs": "17.0.35",
44
- "memfs": "4.68.1",
43
+ "memfs": "4.64.0",
45
44
  "typescript": "5.9.3",
46
- "vitest": "4.1.10"
45
+ "vitest": "3.2.6"
47
46
  },
48
47
  "engines": {
49
48
  "node": ">=24"