@cedarjs/cli-data-migrate 6.0.0-canary.2766 → 6.0.0-canary.2768

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 _=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,i,r)=>()=>{if(r)throw r[0];try{return t&&(i=t(t=0)),i}catch(a){throw r=[a],a}};var U=(t,i,r,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of L(i))!O.call(t,e)&&e!==r&&y(t,e,{get:()=>i[e],enumerable:!(a=I(i,e))||a.enumerable});return t};var l=(t,i,r)=>(r=t!=null?_(N(t)):{},U(i||!t||!t.__esModule?y(r,"default",{value:t,enumerable:!0}):r,t));async function E({importDbClientFromDist:t,distPath:i}){let r,a=!1;if(t){if(!g.default.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=p.default.join(i,"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}r=(await import(d)).db}else(0,M.registerApiSideBabelHook)(),a=!0,r=require(p.default.join((0,f.getPaths)().api.lib,"db")).db;let e=await V(r);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(r,s.path);n.run++,await q(r,{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 r.$disconnect(),console.log(),A(n),console.log(),n.error&&(process.exitCode=1)}catch{process.exitCode=1,await r.$disconnect(),console.log(),A(n),console.log()}}async function V(t){let i=await(0,f.getDataMigrationsPath)((0,f.getPaths)().api.prismaConfig);if(!g.default.existsSync(i))return[];let r=g.default.readdirSync(i).filter(o=>["js",".ts"].some(m=>o.endsWith(m))).map(o=>{let[m]=o.split("-");return{version:m,path:p.default.join(i,o)}}),e=(await t.rW_DataMigration.findMany({orderBy:{version:"asc"}})).map(o=>o.version.toString());return r.filter(({version:o})=>!e.includes(o)).sort(B)}function B(t,i){let r=parseInt(t.version),a=parseInt(i.version);return r>a?1:r<a?-1:0}async function H(t,i){let r=require(i),a=new Date;return await r.default({db:t}),{startedAt:a,finishedAt:new Date}}async function q(t,{version:i,name:r,startedAt:a,finishedAt:e}){await t.rW_DataMigration.create({data:{version:i,name:r,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();
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();
@@ -1,45 +1,9 @@
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");
1
+ import { terminalLink } from "termi-link";
38
2
  const command = "install";
39
3
  const description = "Add the RW_DataMigration model to your schema";
40
4
  function builder(yargs) {
41
5
  return yargs.epilogue(
42
- `Also see the ${(0, import_termi_link.terminalLink)(
6
+ `Also see the ${terminalLink(
43
7
  "CedarJS CLI Reference",
44
8
  "https://cedarjs.com/docs/cli-commands#datamigrate-install"
45
9
  )}`
@@ -49,10 +13,9 @@ async function handler() {
49
13
  const { handler: dataMigrateInstallHandler } = await import("./installHandler.js");
50
14
  await dataMigrateInstallHandler();
51
15
  }
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
16
+ export {
54
17
  builder,
55
18
  command,
56
19
  description,
57
20
  handler
58
- });
21
+ };
@@ -1,64 +1,32 @@
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");
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";
43
11
  async function handler() {
44
- const cedarProjectPaths = (0, import_project_config.getPaths)();
12
+ const cedarProjectPaths = getPaths();
45
13
  const prismaConfigPath = cedarProjectPaths.api.prismaConfig;
46
- const dataMigrationsPath = await (0, import_project_config.getDataMigrationsPath)(prismaConfigPath);
47
- const tasks = new import_listr2.Listr(
14
+ const dataMigrationsPath = await getDataMigrationsPath(prismaConfigPath);
15
+ const tasks = new Listr(
48
16
  [
49
17
  {
50
18
  title: "Creating the dataMigrations directory...",
51
19
  task() {
52
- import_node_fs.default.mkdirSync(dataMigrationsPath, { recursive: true });
53
- import_node_fs.default.writeFileSync(import_node_path.default.join(dataMigrationsPath, ".keep"), "");
20
+ fs.mkdirSync(dataMigrationsPath, { recursive: true });
21
+ fs.writeFileSync(path.join(dataMigrationsPath, ".keep"), "");
54
22
  }
55
23
  },
56
24
  {
57
25
  title: "Adding the RW_DataMigration model to schema.prisma...",
58
26
  async task() {
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(
27
+ const dbSchemaFilePath = await getSchemaPath(prismaConfigPath);
28
+ const dbSchemaFileContent = fs.readFileSync(dbSchemaFilePath, "utf-8");
29
+ fs.writeFileSync(
62
30
  dbSchemaFilePath,
63
31
  [dbSchemaFileContent.trim(), "", RW_DATA_MIGRATION_MODEL, ""].join(
64
32
  "\n"
@@ -69,7 +37,7 @@ async function handler() {
69
37
  {
70
38
  title: "Creating the database migration...",
71
39
  task() {
72
- return import_execa.default.command(createDatabaseMigrationCommand, {
40
+ return execa.command(createDatabaseMigrationCommand, {
73
41
  cwd: cedarProjectPaths.base
74
42
  }).stdout;
75
43
  }
@@ -86,7 +54,7 @@ async function handler() {
86
54
  console.log(notes);
87
55
  } catch (e) {
88
56
  process.exitCode = 1;
89
- console.error(import_cli_helpers.colors.error(e.message));
57
+ console.error(c.error(e.message));
90
58
  }
91
59
  }
92
60
  const RW_DATA_MIGRATION_MODEL = `model RW_DataMigration {
@@ -98,15 +66,14 @@ const RW_DATA_MIGRATION_MODEL = `model RW_DataMigration {
98
66
  const createDatabaseMigrationCommand = "yarn cedar prisma migrate dev --name create_data_migrations --create-only";
99
67
  const notes = [
100
68
  "",
101
- import_cli_helpers.colors.warning("Don't forget to apply the migration when you're ready:"),
69
+ c.warning("Don't forget to apply the migration when you're ready:"),
102
70
  "",
103
- ` ${import_cli_helpers.colors.bold("yarn cedar prisma migrate dev")}`,
71
+ ` ${c.bold("yarn cedar prisma migrate dev")}`,
104
72
  ""
105
73
  ].join("\n");
106
- // Annotate the CommonJS export names for ESM import in node:
107
- 0 && (module.exports = {
74
+ export {
108
75
  RW_DATA_MIGRATION_MODEL,
109
76
  createDatabaseMigrationCommand,
110
77
  handler,
111
78
  notes
112
- });
79
+ };
@@ -1,5 +1,5 @@
1
1
  import type { Argv } from 'yargs';
2
- import type { DataMigrateUpOptions } from '../types';
2
+ import type { DataMigrateUpOptions } from '../types.js';
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,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
+ {"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,41 +1,5 @@
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");
1
+ import { terminalLink } from "termi-link";
2
+ import { getPaths, projectIsEsm } from "@cedarjs/project-config";
39
3
  const command = "up";
40
4
  const description = "Run any outstanding Data Migrations against the database";
41
5
  function builder(yargs) {
@@ -48,16 +12,16 @@ function builder(yargs) {
48
12
  type: "string",
49
13
  alias: "d",
50
14
  description: "Path to the api dist directory",
51
- default: (0, import_project_config.getPaths)().api.dist
15
+ default: getPaths().api.dist
52
16
  }).epilogue(
53
- `Also see the ${(0, import_termi_link.terminalLink)(
17
+ `Also see the ${terminalLink(
54
18
  "CedarJS CLI Reference",
55
19
  "https://cedarjs.com/docs/cli-commands#datamigrate-up"
56
20
  )}`
57
21
  );
58
22
  }
59
23
  async function handler(options) {
60
- if ((0, import_project_config.projectIsEsm)()) {
24
+ if (projectIsEsm()) {
61
25
  const { handler: dataMigrateUpHandler } = await import("./upHandlerEsm.js");
62
26
  await dataMigrateUpHandler(options);
63
27
  } else {
@@ -65,10 +29,9 @@ async function handler(options) {
65
29
  await dataMigrateUpHandler(options);
66
30
  }
67
31
  }
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
32
+ export {
70
33
  builder,
71
34
  command,
72
35
  description,
73
36
  handler
74
- });
37
+ };
@@ -1,4 +1,4 @@
1
- import type { DataMigrateUpOptions } from '../types';
1
+ import type { DataMigrateUpOptions } from '../types.js';
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":"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
+ {"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,43 +1,11 @@
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");
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);
41
9
  async function handler({
42
10
  importDbClientFromDist,
43
11
  distPath
@@ -45,16 +13,16 @@ async function handler({
45
13
  let db;
46
14
  let requireHookRegistered = false;
47
15
  if (importDbClientFromDist) {
48
- if (!import_node_fs.default.existsSync(distPath)) {
16
+ if (!fs.existsSync(distPath)) {
49
17
  console.warn(
50
18
  `Can't find api dist at ${distPath}. You may need to build first: yarn cedar build api`
51
19
  );
52
20
  process.exitCode = 1;
53
21
  return;
54
22
  }
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)) {
23
+ const distLibPath = path.join(distPath, "lib");
24
+ const distLibDbPath = path.join(distLibPath, "db.js");
25
+ if (!fs.existsSync(distLibDbPath)) {
58
26
  console.error(
59
27
  `Can't find db.js at ${distLibDbPath}. CedarJS expects the db.js file to be in the ${distLibPath} directory`
60
28
  );
@@ -63,13 +31,13 @@ async function handler({
63
31
  }
64
32
  db = (await import(distLibDbPath)).db;
65
33
  } else {
66
- (0, import_babel_config.registerApiSideBabelHook)();
34
+ registerApiSideBabelHook();
67
35
  requireHookRegistered = true;
68
- db = require(import_node_path.default.join((0, import_project_config.getPaths)().api.lib, "db")).db;
36
+ db = require2(path.join(getPaths().api.lib, "db")).db;
69
37
  }
70
38
  const pendingDataMigrations = await getPendingDataMigrations(db);
71
39
  if (!pendingDataMigrations.length) {
72
- console.info(import_cli_helpers.colors.success(`
40
+ console.info(c.success(`
73
41
  ${NO_PENDING_MIGRATIONS_MESSAGE}
74
42
  `));
75
43
  process.exitCode = 0;
@@ -77,7 +45,7 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
77
45
  }
78
46
  const counters = { run: 0, skipped: 0, error: 0 };
79
47
  const dataMigrationTasks = pendingDataMigrations.map((dataMigration) => {
80
- const dataMigrationName = import_node_path.default.basename(dataMigration.path, ".js");
48
+ const dataMigrationName = path.basename(dataMigration.path, ".js");
81
49
  return {
82
50
  title: dataMigrationName,
83
51
  skip() {
@@ -90,7 +58,7 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
90
58
  },
91
59
  async task() {
92
60
  if (!requireHookRegistered) {
93
- (0, import_babel_config.registerApiSideBabelHook)();
61
+ registerApiSideBabelHook();
94
62
  }
95
63
  try {
96
64
  const { startedAt, finishedAt } = await runDataMigration(
@@ -107,13 +75,13 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
107
75
  } catch (e) {
108
76
  counters.error++;
109
77
  console.error(
110
- import_cli_helpers.colors.error(`Error in data migration: ${e.message}`)
78
+ c.error(`Error in data migration: ${e.message}`)
111
79
  );
112
80
  }
113
81
  }
114
82
  };
115
83
  });
116
- const tasks = new import_listr2.Listr(dataMigrationTasks, {
84
+ const tasks = new Listr(dataMigrationTasks, {
117
85
  renderer: "verbose"
118
86
  });
119
87
  try {
@@ -134,13 +102,13 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
134
102
  }
135
103
  }
136
104
  async function getPendingDataMigrations(db) {
137
- const dataMigrationsPath = await (0, import_project_config.getDataMigrationsPath)(
138
- (0, import_project_config.getPaths)().api.prismaConfig
105
+ const dataMigrationsPath = await getDataMigrationsPath(
106
+ getPaths().api.prismaConfig
139
107
  );
140
- if (!import_node_fs.default.existsSync(dataMigrationsPath)) {
108
+ if (!fs.existsSync(dataMigrationsPath)) {
141
109
  return [];
142
110
  }
143
- const dataMigrations = import_node_fs.default.readdirSync(dataMigrationsPath).filter(
111
+ const dataMigrations = fs.readdirSync(dataMigrationsPath).filter(
144
112
  (dataMigrationFileName) => ["js", ".ts"].some(
145
113
  (extension) => dataMigrationFileName.endsWith(extension)
146
114
  )
@@ -148,7 +116,7 @@ async function getPendingDataMigrations(db) {
148
116
  const [version] = dataMigrationFileName.split("-");
149
117
  return {
150
118
  version,
151
- path: import_node_path.default.join(dataMigrationsPath, dataMigrationFileName)
119
+ path: path.join(dataMigrationsPath, dataMigrationFileName)
152
120
  };
153
121
  });
154
122
  const ranDataMigrations = await db.rW_DataMigration.findMany(
@@ -176,7 +144,7 @@ function sortDataMigrationsByVersion(dataMigrationA, dataMigrationB) {
176
144
  return 0;
177
145
  }
178
146
  async function runDataMigration(db, dataMigrationPath) {
179
- const dataMigration = require(dataMigrationPath);
147
+ const dataMigration = require2(dataMigrationPath);
180
148
  const startedAt = /* @__PURE__ */ new Date();
181
149
  await dataMigration.default({ db });
182
150
  const finishedAt = /* @__PURE__ */ new Date();
@@ -191,24 +159,23 @@ async function recordDataMigration(db, { version, name, startedAt, finishedAt })
191
159
  function reportDataMigrations(counters) {
192
160
  if (counters.run) {
193
161
  console.info(
194
- import_cli_helpers.colors.success(`${counters.run} data migration(s) completed successfully.`)
162
+ c.success(`${counters.run} data migration(s) completed successfully.`)
195
163
  );
196
164
  }
197
165
  if (counters.error) {
198
166
  console.error(
199
- import_cli_helpers.colors.error(`${counters.error} data migration(s) exited with errors.`)
167
+ c.error(`${counters.error} data migration(s) exited with errors.`)
200
168
  );
201
169
  }
202
170
  if (counters.skipped) {
203
171
  console.warn(
204
- import_cli_helpers.colors.warning(
172
+ c.warning(
205
173
  `${counters.skipped} data migration(s) skipped due to previous error.`
206
174
  )
207
175
  );
208
176
  }
209
177
  }
210
- // Annotate the CommonJS export names for ESM import in node:
211
- 0 && (module.exports = {
178
+ export {
212
179
  NO_PENDING_MIGRATIONS_MESSAGE,
213
180
  handler
214
- });
181
+ };
@@ -1,4 +1,4 @@
1
- import type { DataMigrateUpOptions } from '../types';
1
+ import type { DataMigrateUpOptions } from '../types.js';
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,UAAU,CAAA;AAsCnE,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":"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,58 +1,29 @@
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 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_listr2 = require("listr2");
38
- var import_vite = require("vite");
39
- var import_cli_helpers = require("@cedarjs/cli-helpers");
40
- var import_project_config = require("@cedarjs/project-config");
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";
41
12
  function resolveId(id) {
42
- if (import_node_fs.default.existsSync(id) && import_node_fs.default.statSync(id).isFile()) {
13
+ if (fs.existsSync(id) && fs.statSync(id).isFile()) {
43
14
  return id;
44
15
  }
45
16
  const withoutExt = /\.jsx?$/.test(id) ? id.replace(/\.jsx?$/, "") : id;
46
17
  for (const ext of [".ts", ".tsx", ".js", ".jsx"]) {
47
- if (import_node_fs.default.existsSync(withoutExt + ext)) {
18
+ if (fs.existsSync(withoutExt + ext)) {
48
19
  return withoutExt + ext;
49
20
  }
50
21
  }
51
- if (import_node_fs.default.existsSync(id) && import_node_fs.default.statSync(id).isDirectory()) {
52
- for (const base of ["index", import_node_path.default.basename(id)]) {
22
+ if (fs.existsSync(id) && fs.statSync(id).isDirectory()) {
23
+ for (const base of ["index", path.basename(id)]) {
53
24
  for (const ext of [".ts", ".tsx", ".js", ".jsx"]) {
54
- const candidate = import_node_path.default.join(id, base + ext);
55
- if (import_node_fs.default.existsSync(candidate)) {
25
+ const candidate = path.join(id, base + ext);
26
+ if (fs.existsSync(candidate)) {
56
27
  return candidate;
57
28
  }
58
29
  }
@@ -73,7 +44,7 @@ async function handler({
73
44
  const mod = await import("@cedarjs/vite");
74
45
  cedarPlugins = mod;
75
46
  }
76
- server = await (0, import_vite.createServer)({
47
+ server = await createServer({
77
48
  mode: "production",
78
49
  optimizeDeps: {
79
50
  noDiscovery: true,
@@ -90,15 +61,15 @@ async function handler({
90
61
  alias: [
91
62
  {
92
63
  find: /^api\//,
93
- replacement: (0, import_project_config.getPaths)().api.base + "/"
64
+ replacement: getPaths().api.base + "/"
94
65
  },
95
66
  {
96
67
  find: /^src\//,
97
68
  replacement: "src/",
98
69
  customResolver: (id, importer, _options) => {
99
- const apiImportBase = (0, import_project_config.importStatementPath)((0, import_project_config.getPaths)().api.base);
70
+ const apiImportBase = importStatementPath(getPaths().api.base);
100
71
  if (importer?.startsWith(apiImportBase)) {
101
- const apiImportSrc = (0, import_project_config.importStatementPath)((0, import_project_config.getPaths)().api.src);
72
+ const apiImportSrc = importStatementPath(getPaths().api.src);
102
73
  const apiId = id.replace("src", apiImportSrc);
103
74
  return { id: resolveId(apiId) };
104
75
  }
@@ -116,22 +87,22 @@ async function handler({
116
87
  });
117
88
  }
118
89
  const env = server.environments.nodeRunnerEnv;
119
- if (!env || !(0, import_vite.isRunnableDevEnvironment)(env)) {
90
+ if (!env || !isRunnableDevEnvironment(env)) {
120
91
  throw new Error("Vite environment is not runnable.");
121
92
  }
122
93
  return env.runner;
123
94
  }
124
95
  if (importDbClientFromDist) {
125
- if (!import_node_fs.default.existsSync(distPath)) {
96
+ if (!fs.existsSync(distPath)) {
126
97
  console.warn(
127
98
  `Can't find api dist at ${distPath}. You may need to build first: yarn cedar build api`
128
99
  );
129
100
  process.exitCode = 1;
130
101
  return;
131
102
  }
132
- const distLibPath = import_node_path.default.join(distPath, "lib");
133
- const distLibDbPath = import_node_path.default.join(distLibPath, "db.js");
134
- if (!import_node_fs.default.existsSync(distLibDbPath)) {
103
+ const distLibPath = path.join(distPath, "lib");
104
+ const distLibDbPath = path.join(distLibPath, "db.js");
105
+ if (!fs.existsSync(distLibDbPath)) {
135
106
  console.error(
136
107
  `Can't find db.js at ${distLibDbPath}. CedarJS expects the db.js file to be in the ${distLibPath} directory`
137
108
  );
@@ -140,9 +111,9 @@ async function handler({
140
111
  }
141
112
  db = (await import(distLibDbPath)).db;
142
113
  } else {
143
- const dbPath = (0, import_project_config.resolveFile)(import_node_path.default.join((0, import_project_config.getPaths)().api.lib, "db"));
114
+ const dbPath = resolveFile(path.join(getPaths().api.lib, "db"));
144
115
  if (!dbPath) {
145
- console.error(`Can't find your db file in ${(0, import_project_config.getPaths)().api.lib}`);
116
+ console.error(`Can't find your db file in ${getPaths().api.lib}`);
146
117
  process.exitCode = 1;
147
118
  return;
148
119
  }
@@ -157,7 +128,7 @@ async function handler({
157
128
  }
158
129
  const pendingDataMigrations = await getPendingDataMigrations(db);
159
130
  if (!pendingDataMigrations.length) {
160
- console.info(import_cli_helpers.colors.success(`
131
+ console.info(c.success(`
161
132
  ${NO_PENDING_MIGRATIONS_MESSAGE}
162
133
  `));
163
134
  process.exitCode = 0;
@@ -166,7 +137,7 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
166
137
  }
167
138
  const counters = { run: 0, skipped: 0, error: 0 };
168
139
  const dataMigrationTasks = pendingDataMigrations.map((dataMigration) => {
169
- const dataMigrationName = import_node_path.default.basename(dataMigration.path, ".js");
140
+ const dataMigrationName = path.basename(dataMigration.path, ".js");
170
141
  return {
171
142
  title: dataMigrationName,
172
143
  skip() {
@@ -193,12 +164,12 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
193
164
  } catch (e) {
194
165
  counters.error++;
195
166
  const message = e instanceof Error ? e.message : String(e);
196
- console.error(import_cli_helpers.colors.error(`Error in data migration: ${message}`));
167
+ console.error(c.error(`Error in data migration: ${message}`));
197
168
  }
198
169
  }
199
170
  };
200
171
  });
201
- const tasks = new import_listr2.Listr(dataMigrationTasks, {
172
+ const tasks = new Listr(dataMigrationTasks, {
202
173
  renderer: "verbose"
203
174
  });
204
175
  try {
@@ -232,13 +203,13 @@ ${NO_PENDING_MIGRATIONS_MESSAGE}
232
203
  }
233
204
  }
234
205
  async function getPendingDataMigrations(db) {
235
- const dataMigrationsPath = await (0, import_project_config.getDataMigrationsPath)(
236
- (0, import_project_config.getPaths)().api.prismaConfig
206
+ const dataMigrationsPath = await getDataMigrationsPath(
207
+ getPaths().api.prismaConfig
237
208
  );
238
- if (!import_node_fs.default.existsSync(dataMigrationsPath)) {
209
+ if (!fs.existsSync(dataMigrationsPath)) {
239
210
  return [];
240
211
  }
241
- const dataMigrations = import_node_fs.default.readdirSync(dataMigrationsPath).filter(
212
+ const dataMigrations = fs.readdirSync(dataMigrationsPath).filter(
242
213
  (dataMigrationFileName) => ["js", ".ts"].some(
243
214
  (extension) => dataMigrationFileName.endsWith(extension)
244
215
  )
@@ -246,7 +217,7 @@ async function getPendingDataMigrations(db) {
246
217
  const [version] = dataMigrationFileName.split("-");
247
218
  return {
248
219
  version,
249
- path: import_node_path.default.join(dataMigrationsPath, dataMigrationFileName)
220
+ path: path.join(dataMigrationsPath, dataMigrationFileName)
250
221
  };
251
222
  });
252
223
  const ranDataMigrations = await db.rW_DataMigration.findMany(
@@ -282,24 +253,23 @@ async function recordDataMigration(db, { version, name, startedAt, finishedAt })
282
253
  function reportDataMigrations(counters) {
283
254
  if (counters.run) {
284
255
  console.info(
285
- import_cli_helpers.colors.success(`${counters.run} data migration(s) completed successfully.`)
256
+ c.success(`${counters.run} data migration(s) completed successfully.`)
286
257
  );
287
258
  }
288
259
  if (counters.error) {
289
260
  console.error(
290
- import_cli_helpers.colors.error(`${counters.error} data migration(s) exited with errors.`)
261
+ c.error(`${counters.error} data migration(s) exited with errors.`)
291
262
  );
292
263
  }
293
264
  if (counters.skipped) {
294
265
  console.warn(
295
- import_cli_helpers.colors.warning(
266
+ c.warning(
296
267
  `${counters.skipped} data migration(s) skipped due to previous error.`
297
268
  )
298
269
  );
299
270
  }
300
271
  }
301
- // Annotate the CommonJS export names for ESM import in node:
302
- 0 && (module.exports = {
272
+ export {
303
273
  NO_PENDING_MIGRATIONS_MESSAGE,
304
274
  handler
305
- });
275
+ };
package/dist/index.js CHANGED
@@ -1,35 +1,22 @@
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");
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";
27
14
  const command = "data-migrate <command>";
28
15
  const aliases = ["dataMigrate", "dm"];
29
16
  const description = "Migrate the data in your database";
30
17
  function builder(yargs) {
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)(
18
+ yargs.command(installCommand, installDescription, installBuilder, installHandler).command(upCommand, upDescription, upBuilder, upHandler).epilogue(
19
+ `Also see the ${terminalLink(
33
20
  "CedarJS CLI Reference",
34
21
  "https://cedarjs.com/docs/cli-commands#datamigrate"
35
22
  )}`
@@ -43,7 +30,6 @@ const commands = [
43
30
  builder
44
31
  }
45
32
  ];
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
33
+ export {
48
34
  commands
49
- });
35
+ };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@cedarjs/cli-data-migrate",
3
- "version": "6.0.0-canary.2766",
3
+ "version": "6.0.0-canary.2768",
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": "commonjs",
10
+ "type": "module",
11
11
  "exports": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts",
13
13
  "bin": {
@@ -17,19 +17,19 @@
17
17
  "dist"
18
18
  ],
19
19
  "scripts": {
20
- "build": "node ./build.mts && yarn build:types",
20
+ "build": "node ./build.mts",
21
21
  "build:pack": "yarn pack -o cedarjs-cli-data-migrate.tgz",
22
- "build:types": "tsc --build --verbose",
22
+ "build:types": "tsc --build --verbose ./tsconfig.build.json",
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": "6.0.0-canary.2766",
30
- "@cedarjs/cli-helpers": "6.0.0-canary.2766",
31
- "@cedarjs/project-config": "6.0.0-canary.2766",
32
- "@cedarjs/vite": "6.0.0-canary.2766",
29
+ "@cedarjs/babel-config": "6.0.0-canary.2768",
30
+ "@cedarjs/cli-helpers": "6.0.0-canary.2768",
31
+ "@cedarjs/project-config": "6.0.0-canary.2768",
32
+ "@cedarjs/vite": "6.0.0-canary.2768",
33
33
  "dotenv-defaults": "5.0.2",
34
34
  "execa": "5.1.1",
35
35
  "listr2": "10.2.2",
@@ -38,7 +38,7 @@
38
38
  "yargs": "17.7.3"
39
39
  },
40
40
  "devDependencies": {
41
- "@cedarjs/framework-tools": "6.0.0-canary.2766",
41
+ "@cedarjs/framework-tools": "6.0.0-canary.2768",
42
42
  "@prisma/client": "7.8.0",
43
43
  "@types/yargs": "17.0.35",
44
44
  "memfs": "4.64.0",