@cedarjs/cli 3.0.0-canary.13596 → 3.0.0-canary.13598

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.
@@ -8,12 +8,12 @@ import {
8
8
  isTypeScriptProject,
9
9
  getConfigPath
10
10
  } from "@cedarjs/cli-helpers";
11
- import { getPaths, getSchemaPath } from "@cedarjs/project-config";
11
+ import { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
12
12
  import { errorTelemetry } from "@cedarjs/telemetry";
13
13
  import { printSetupNotes } from "../../../../lib/index.js";
14
14
  import { serverFileExists } from "../../../../lib/project.js";
15
15
  import { addFilesTask } from "../helpers/index.js";
16
- const { getSchemaWithPath, getConfig } = prismaInternals;
16
+ const { getConfig } = prismaInternals;
17
17
  const cedarPaths = getPaths();
18
18
  const EXTENSION = isTypeScriptProject ? "ts" : "js";
19
19
  async function handler({ force }) {
@@ -58,8 +58,7 @@ async function getAddCoherenceFilesTask(force) {
58
58
  });
59
59
  }
60
60
  async function getCoherenceConfigFileContent() {
61
- const schemaPath = await getSchemaPath(cedarPaths.api.prismaConfig);
62
- const result = await getSchemaWithPath(schemaPath);
61
+ const result = await getPrismaSchemas();
63
62
  const prismaConfig = await getConfig({ datamodel: result.schemas });
64
63
  let db = prismaConfig.datasources[0].activeProvider;
65
64
  if (!SUPPORTED_DATABASES.includes(db)) {
@@ -4,7 +4,7 @@ import path from "path";
4
4
  import prismaInternals from "@prisma/internals";
5
5
  import { Listr } from "listr2";
6
6
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
7
- import { getPaths, getSchemaPath } from "@cedarjs/project-config";
7
+ import { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
8
8
  import { errorTelemetry } from "@cedarjs/telemetry";
9
9
  import c from "../../../../lib/colors.js";
10
10
  import { writeFilesTask, printSetupNotes } from "../../../../lib/index.js";
@@ -15,7 +15,7 @@ import {
15
15
  postgresDatabaseService,
16
16
  mysqlDatabaseService
17
17
  } from "../templates/flightcontrol.js";
18
- const { getSchemaWithPath, getConfig } = prismaInternals;
18
+ const { getConfig } = prismaInternals;
19
19
  const getFlightcontrolJson = async (database) => {
20
20
  if (database === "none") {
21
21
  return {
@@ -23,11 +23,7 @@ const getFlightcontrolJson = async (database) => {
23
23
  content: flightcontrolConfig
24
24
  };
25
25
  }
26
- const schemaPath = await getSchemaPath(getPaths().api.prismaConfig);
27
- if (!fs.existsSync(schemaPath)) {
28
- throw new Error(`Could not find prisma schema at ${schemaPath}`);
29
- }
30
- const result = await getSchemaWithPath(schemaPath);
26
+ const result = await getPrismaSchemas();
31
27
  const config = await getConfig({ datamodel: result.schemas });
32
28
  const detectedDatabase = config.datasources[0].activeProvider;
33
29
  if (detectedDatabase === database) {
@@ -1,9 +1,8 @@
1
- import fs from "node:fs";
2
1
  import path from "path";
3
2
  import prismaInternals from "@prisma/internals";
4
3
  import { Listr } from "listr2";
5
4
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
6
- import { getPaths, getSchemaPath } from "@cedarjs/project-config";
5
+ import { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
7
6
  import { errorTelemetry } from "@cedarjs/telemetry";
8
7
  import c from "../../../../lib/colors.js";
9
8
  import { writeFilesTask, printSetupNotes } from "../../../../lib/index.js";
@@ -14,7 +13,7 @@ import {
14
13
  RENDER_YAML,
15
14
  SQLITE_YAML
16
15
  } from "../templates/render.js";
17
- const { getSchemaWithPath, getConfig } = prismaInternals;
16
+ const { getConfig } = prismaInternals;
18
17
  const getRenderYamlContent = async (database) => {
19
18
  if (database === "none") {
20
19
  return {
@@ -22,11 +21,7 @@ const getRenderYamlContent = async (database) => {
22
21
  content: RENDER_YAML("")
23
22
  };
24
23
  }
25
- const schemaPath = await getSchemaPath(getPaths().api.prismaConfig);
26
- if (!fs.existsSync(schemaPath)) {
27
- throw new Error(`Could not find prisma schema at ${schemaPath}`);
28
- }
29
- const result = await getSchemaWithPath(schemaPath);
24
+ const result = await getPrismaSchemas();
30
25
  const config = await getConfig({ datamodel: result.schemas });
31
26
  const detectedDatabase = config.datasources[0].activeProvider;
32
27
  if (detectedDatabase === database) {
@@ -3,11 +3,11 @@ import * as path from "node:path";
3
3
  import prismaInternals from "@prisma/internals";
4
4
  import { Listr } from "listr2";
5
5
  import { addApiPackages } from "@cedarjs/cli-helpers";
6
- import { getSchemaPath } from "@cedarjs/project-config";
6
+ import { getSchemaPath, getPrismaSchemas } from "@cedarjs/project-config";
7
7
  import c from "../../../lib/colors.js";
8
8
  import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
9
9
  import { isTypeScriptProject } from "../../../lib/project.js";
10
- const { getDMMF, getSchemaWithPath } = prismaInternals;
10
+ const { getDMMF } = prismaInternals;
11
11
  const MODEL_SCHEMA = `
12
12
  model BackgroundJob {
13
13
  id Int @id @default(autoincrement())
@@ -26,8 +26,7 @@ model BackgroundJob {
26
26
  }
27
27
  `;
28
28
  const getModelNames = async () => {
29
- const schemaPath = await getSchemaPath(getPaths().api.prismaConfig);
30
- const { schemas } = await getSchemaWithPath(schemaPath);
29
+ const { schemas } = await getPrismaSchemas();
31
30
  const schema = await getDMMF({ datamodel: schemas });
32
31
  return schema.datamodel.models.map((model) => model.name);
33
32
  };
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import { createRequire } from "node:module";
3
3
  import { resolveGeneratedPrismaClient } from "@cedarjs/project-config";
4
- import { runCommandTask, getPaths } from "../lib/index.js";
4
+ import { runCommandTask, getPaths } from "./index.js";
5
5
  const generatePrismaCommand = async () => {
6
6
  const createdRequire = createRequire(import.meta.url);
7
7
  const prismaIndexPath = createdRequire.resolve("prisma/build/index.js");
@@ -18,10 +18,10 @@ const generatePrismaClient = async ({
18
18
  verbose = true,
19
19
  force = true,
20
20
  silent = false
21
- }) => {
21
+ } = {}) => {
22
22
  if (!force) {
23
- const prismaClientPath = resolveGeneratedPrismaClient();
24
- const prismaClientFile = fs.existsSync(prismaClientPath) ? fs.readFileSync(prismaClientPath, "utf8") : "";
23
+ const prismaClientPath = await resolveGeneratedPrismaClient();
24
+ const prismaClientFile = prismaClientPath && fs.existsSync(prismaClientPath) ? fs.readFileSync(prismaClientPath, "utf8") : "";
25
25
  if (!prismaClientFile.includes("@prisma/client did not initialize yet.") && prismaClientFile.includes("exports.Prisma.")) {
26
26
  return;
27
27
  }
@@ -1,9 +1,8 @@
1
1
  import prismaInternals from "@prisma/internals";
2
- import { getSchemaPath } from "@cedarjs/project-config";
2
+ import { getPrismaSchemas } from "@cedarjs/project-config";
3
3
  import { singularize, isPlural } from "@cedarjs/utils/cedarPluralize";
4
4
  import { ensureUniquePlural } from "./pluralHelpers.js";
5
- import { getPaths } from "./index.js";
6
- const { getConfig, getDMMF, getSchemaWithPath } = prismaInternals;
5
+ const { getConfig, getDMMF } = prismaInternals;
7
6
  const schemaMemo = {};
8
7
  const getExistingModelName = async (name) => {
9
8
  if (!name) {
@@ -64,9 +63,7 @@ const getEnum = async (name) => {
64
63
  return model;
65
64
  };
66
65
  const getDataModel = async () => {
67
- const prismaConfigPath = getPaths().api.prismaConfig;
68
- const schemaPath = await getSchemaPath(prismaConfigPath);
69
- const result = await getSchemaWithPath(schemaPath);
66
+ const result = await getPrismaSchemas();
70
67
  return result.schemas;
71
68
  };
72
69
  const getSchemaDefinitions = async () => {
package/dist/lib/test.js CHANGED
@@ -61,6 +61,16 @@ vi.mock("@cedarjs/project-config", async (importOriginal) => {
61
61
  getSchemaPath: () => {
62
62
  return path.join(globalThis.__dirname, "fixtures", "schema.prisma");
63
63
  },
64
+ getPrismaSchemas: async () => {
65
+ const schemaPath = path.join(
66
+ globalThis.__dirname,
67
+ "fixtures",
68
+ "schema.prisma"
69
+ );
70
+ return {
71
+ schemas: [[schemaPath, fs.readFileSync(schemaPath, "utf-8")]]
72
+ };
73
+ },
64
74
  getDataMigrationsPath: () => {
65
75
  return path.join(globalThis.__dirname, "fixtures", "migrations");
66
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "3.0.0-canary.13596+e3364d309",
3
+ "version": "3.0.0-canary.13598+4f325b500",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,16 +34,16 @@
34
34
  "@babel/parser": "7.29.0",
35
35
  "@babel/preset-typescript": "7.28.5",
36
36
  "@babel/runtime-corejs3": "7.29.0",
37
- "@cedarjs/api-server": "3.0.0-canary.13596",
38
- "@cedarjs/cli-helpers": "3.0.0-canary.13596",
39
- "@cedarjs/fastify-web": "3.0.0-canary.13596",
40
- "@cedarjs/internal": "3.0.0-canary.13596",
41
- "@cedarjs/prerender": "3.0.0-canary.13596",
42
- "@cedarjs/project-config": "3.0.0-canary.13596",
43
- "@cedarjs/structure": "3.0.0-canary.13596",
44
- "@cedarjs/telemetry": "3.0.0-canary.13596",
45
- "@cedarjs/utils": "3.0.0-canary.13596",
46
- "@cedarjs/web-server": "3.0.0-canary.13596",
37
+ "@cedarjs/api-server": "3.0.0-canary.13598",
38
+ "@cedarjs/cli-helpers": "3.0.0-canary.13598",
39
+ "@cedarjs/fastify-web": "3.0.0-canary.13598",
40
+ "@cedarjs/internal": "3.0.0-canary.13598",
41
+ "@cedarjs/prerender": "3.0.0-canary.13598",
42
+ "@cedarjs/project-config": "3.0.0-canary.13598",
43
+ "@cedarjs/structure": "3.0.0-canary.13598",
44
+ "@cedarjs/telemetry": "3.0.0-canary.13598",
45
+ "@cedarjs/utils": "3.0.0-canary.13598",
46
+ "@cedarjs/web-server": "3.0.0-canary.13598",
47
47
  "@listr2/prompt-adapter-enquirer": "4.2.1",
48
48
  "@opentelemetry/api": "1.9.0",
49
49
  "@opentelemetry/core": "1.30.1",
@@ -51,7 +51,7 @@
51
51
  "@opentelemetry/resources": "1.30.1",
52
52
  "@opentelemetry/sdk-trace-node": "1.30.1",
53
53
  "@opentelemetry/semantic-conventions": "1.38.0",
54
- "@prisma/internals": "6.19.2",
54
+ "@prisma/internals": "7.5.0",
55
55
  "ansis": "4.2.0",
56
56
  "archiver": "7.0.1",
57
57
  "boxen": "5.1.2",
@@ -78,7 +78,7 @@
78
78
  "pluralize": "8.0.0",
79
79
  "portfinder": "1.0.38",
80
80
  "prettier": "3.8.1",
81
- "prisma": "6.19.2",
81
+ "prisma": "7.5.0",
82
82
  "prompts": "2.4.2",
83
83
  "recast": "0.23.11",
84
84
  "rimraf": "6.1.3",
@@ -107,5 +107,5 @@
107
107
  "publishConfig": {
108
108
  "access": "public"
109
109
  },
110
- "gitHead": "e3364d3098475cbd73b315c90f60845f69838bc1"
110
+ "gitHead": "4f325b500632f005397e26cd80f46f8ab5a98494"
111
111
  }