@cedarjs/cli 2.8.1-next.116 → 2.8.1

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.
Files changed (36) hide show
  1. package/dist/commands/build/buildHandler.js +6 -9
  2. package/dist/commands/build.js +1 -2
  3. package/dist/commands/check.js +4 -2
  4. package/dist/commands/console.js +2 -2
  5. package/dist/commands/consoleHandler.js +4 -10
  6. package/dist/commands/dev/devHandler.js +4 -1
  7. package/dist/commands/execHandler.js +4 -11
  8. package/dist/commands/generate/dataMigration/dataMigration.js +2 -1
  9. package/dist/commands/generate/realtime/realtimeHandler.js +3 -3
  10. package/dist/commands/generate/service/serviceHandler.js +2 -1
  11. package/dist/commands/generate.js +1 -8
  12. package/dist/commands/jobsHandler.js +2 -4
  13. package/dist/commands/lint.js +2 -2
  14. package/dist/commands/prerenderHandler.js +35 -65
  15. package/dist/commands/prismaHandler.js +18 -41
  16. package/dist/commands/setup/deploy/providers/coherenceHandler.js +3 -3
  17. package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +12 -4
  18. package/dist/commands/setup/deploy/providers/renderHandler.js +12 -5
  19. package/dist/commands/setup/jobs/jobsHandler.js +4 -3
  20. package/dist/commands/setup/realtime/realtime.js +1 -1
  21. package/dist/commands/setup/realtime/realtimeHandler.js +1 -20
  22. package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +1 -1
  23. package/dist/commands/test.js +1 -5
  24. package/dist/commands/testEsm.js +1 -5
  25. package/dist/commands/{test/testHandler.js → testHandler.js} +30 -43
  26. package/dist/commands/{test/testHandlerEsm.js → testHandlerEsm.js} +23 -38
  27. package/dist/commands/type-checkHandler.js +12 -21
  28. package/dist/commands/upgrade/upgradeHandler.js +9 -22
  29. package/dist/lib/background.js +0 -2
  30. package/dist/lib/generatePrismaClient.js +4 -4
  31. package/dist/lib/schemaHelpers.js +6 -3
  32. package/dist/lib/test.js +0 -10
  33. package/dist/telemetry/resource.js +3 -1
  34. package/dist/testLib/cells.js +3 -5
  35. package/package.json +19 -17
  36. package/dist/commands/test/datasourceWarning.js +0 -42
@@ -4,10 +4,13 @@ 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, getPrismaSchemas } from "@cedarjs/project-config";
8
7
  import { errorTelemetry } from "@cedarjs/telemetry";
9
8
  import c from "../../../../lib/colors.js";
10
- import { writeFilesTask, printSetupNotes } from "../../../../lib/index.js";
9
+ import {
10
+ getPaths,
11
+ writeFilesTask,
12
+ printSetupNotes
13
+ } from "../../../../lib/index.js";
11
14
  import { updateApiURLTask } from "../helpers/index.js";
12
15
  import {
13
16
  flightcontrolConfig,
@@ -15,7 +18,7 @@ import {
15
18
  postgresDatabaseService,
16
19
  mysqlDatabaseService
17
20
  } from "../templates/flightcontrol.js";
18
- const { getConfig } = prismaInternals;
21
+ const { getSchemaWithPath, getConfig } = prismaInternals;
19
22
  const getFlightcontrolJson = async (database) => {
20
23
  if (database === "none") {
21
24
  return {
@@ -23,7 +26,12 @@ const getFlightcontrolJson = async (database) => {
23
26
  content: flightcontrolConfig
24
27
  };
25
28
  }
26
- const result = await getPrismaSchemas();
29
+ if (!fs.existsSync(path.join(getPaths().base, "api/db/schema.prisma"))) {
30
+ throw new Error("Could not find prisma schema at 'api/db/schema.prisma'");
31
+ }
32
+ const result = await getSchemaWithPath(
33
+ path.join(getPaths().base, "api/db/schema.prisma")
34
+ );
27
35
  const config = await getConfig({ datamodel: result.schemas });
28
36
  const detectedDatabase = config.datasources[0].activeProvider;
29
37
  if (detectedDatabase === database) {
@@ -1,11 +1,15 @@
1
+ import fs from "node:fs";
1
2
  import path from "path";
2
3
  import prismaInternals from "@prisma/internals";
3
4
  import { Listr } from "listr2";
4
5
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
5
- import { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
6
6
  import { errorTelemetry } from "@cedarjs/telemetry";
7
7
  import c from "../../../../lib/colors.js";
8
- import { writeFilesTask, printSetupNotes } from "../../../../lib/index.js";
8
+ import {
9
+ getPaths,
10
+ writeFilesTask,
11
+ printSetupNotes
12
+ } from "../../../../lib/index.js";
9
13
  import { addFilesTask, updateApiURLTask } from "../helpers/index.js";
10
14
  import {
11
15
  POSTGRES_YAML,
@@ -13,7 +17,7 @@ import {
13
17
  RENDER_YAML,
14
18
  SQLITE_YAML
15
19
  } from "../templates/render.js";
16
- const { getConfig } = prismaInternals;
20
+ const { getSchemaWithPath, getConfig } = prismaInternals;
17
21
  const getRenderYamlContent = async (database) => {
18
22
  if (database === "none") {
19
23
  return {
@@ -21,8 +25,11 @@ const getRenderYamlContent = async (database) => {
21
25
  content: RENDER_YAML("")
22
26
  };
23
27
  }
24
- const result = await getPrismaSchemas();
25
- const config = await getConfig({ datamodel: result.schemas });
28
+ if (!fs.existsSync("api/db/schema.prisma")) {
29
+ throw new Error("Could not find prisma schema at 'api/db/schema.prisma'");
30
+ }
31
+ const { schemas } = await getSchemaWithPath("api/db/schema.prisma");
32
+ const config = await getConfig({ datamodel: schemas });
26
33
  const detectedDatabase = config.datasources[0].activeProvider;
27
34
  if (detectedDatabase === database) {
28
35
  switch (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, getPrismaSchemas } from "@cedarjs/project-config";
6
+ import { getSchemaPath } 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 } = prismaInternals;
10
+ const { getDMMF, getSchemaWithPath } = prismaInternals;
11
11
  const MODEL_SCHEMA = `
12
12
  model BackgroundJob {
13
13
  id Int @id @default(autoincrement())
@@ -26,7 +26,8 @@ model BackgroundJob {
26
26
  }
27
27
  `;
28
28
  const getModelNames = async () => {
29
- const { schemas } = await getPrismaSchemas();
29
+ const schemaPath = await getSchemaPath(getPaths().api.prismaConfig);
30
+ const { schemas } = await getSchemaWithPath(schemaPath);
30
31
  const schema = await getDMMF({ datamodel: schemas });
31
32
  return schema.datamodel.models.map((model) => model.name);
32
33
  };
@@ -4,7 +4,7 @@ const description = "Setup RedwoodJS Realtime";
4
4
  function builder(yargs) {
5
5
  yargs.option("includeExamples", {
6
6
  alias: ["e", "examples"],
7
- default: void 0,
7
+ default: true,
8
8
  description: "Include examples of how to implement liveQueries and subscriptions",
9
9
  type: "boolean"
10
10
  }).option("force", {
@@ -2,7 +2,6 @@ import fs from "node:fs";
2
2
  import path from "path";
3
3
  import execa from "execa";
4
4
  import { Listr } from "listr2";
5
- import prompts from "prompts";
6
5
  import { addApiPackages } from "@cedarjs/cli-helpers";
7
6
  import { projectIsEsm } from "@cedarjs/project-config";
8
7
  import { errorTelemetry } from "@cedarjs/telemetry";
@@ -17,31 +16,13 @@ const { version } = JSON.parse(
17
16
  "utf-8"
18
17
  )
19
18
  );
20
- async function handleExamplesPreference(includeExamples) {
21
- let incl = includeExamples;
22
- if (typeof includeExamples === "undefined") {
23
- const response = await prompts({
24
- type: "toggle",
25
- name: "includeExamples",
26
- message: "Do you want to generate examples?",
27
- initial: true,
28
- active: "Yes",
29
- inactive: "No"
30
- });
31
- incl = response.includeExamples;
32
- }
33
- return incl;
34
- }
35
- async function handler(args) {
19
+ async function handler({ force, includeExamples, verbose }) {
36
20
  const redwoodPaths = getPaths();
37
21
  const ts = isTypeScriptProject();
38
22
  const realtimeLibFilePath = path.join(
39
23
  redwoodPaths.api.lib,
40
24
  `realtime.${isTypeScriptProject() ? "ts" : "js"}`
41
25
  );
42
- const force = args.force || false;
43
- const verbose = args.verbose || false;
44
- const includeExamples = await handleExamplesPreference(args.includeExamples);
45
26
  const tasks = new Listr(
46
27
  [
47
28
  addApiPackages(["ioredis@^5", `@cedarjs/realtime@${version}`]),
@@ -76,7 +76,7 @@ const handler = async ({ force, install }) => {
76
76
  install
77
77
  });
78
78
  const rwPaths = getPaths();
79
- const projectPackages = ["prettier-plugin-tailwindcss@^0.7.0"];
79
+ const projectPackages = ["prettier-plugin-tailwindcss@^0.5.12"];
80
80
  const webWorkspacePackages = [
81
81
  "postcss",
82
82
  "postcss-loader",
@@ -21,10 +21,6 @@ const builder = (yargs) => {
21
21
  describe: "Syncs the test database with your Prisma schema without requiring a migration. It creates a test database if it doesn't already exist.",
22
22
  type: "boolean",
23
23
  default: true
24
- }).option("force", {
25
- describe: "Run tests without prompting for confirmation, even when a non-standard datasource url env var is detected.",
26
- type: "boolean",
27
- default: false
28
24
  }).epilogue(
29
25
  `For all available flags, run jest cli directly ${c.tip(
30
26
  "yarn jest --help"
@@ -38,7 +34,7 @@ Also see the ${terminalLink(
38
34
  );
39
35
  };
40
36
  const handler = async (options) => {
41
- const { handler: handler2 } = await import("./test/testHandler.js");
37
+ const { handler: handler2 } = await import("./testHandler.js");
42
38
  return handler2(options);
43
39
  };
44
40
  export {
@@ -18,10 +18,6 @@ const builder = (yargs) => {
18
18
  describe: "Syncs the test database with your Prisma schema without requiring a migration. It creates a test database if it doesn't already exist.",
19
19
  type: "boolean",
20
20
  default: true
21
- }).option("force", {
22
- describe: "Skip any confirmation prompts and run tests without interruption. Useful in CI or scripted environments.",
23
- type: "boolean",
24
- default: false
25
21
  }).epilogue(
26
22
  `For all available flags, run vitest cli directly ${vitestTip}
27
23
 
@@ -30,7 +26,7 @@ Also see the ${cliDocsLink}
30
26
  );
31
27
  };
32
28
  const handler = async (options) => {
33
- const { handler: handler2 } = await import("./test/testHandlerEsm.js");
29
+ const { handler: handler2 } = await import("./testHandlerEsm.js");
34
30
  return handler2(options);
35
31
  };
36
32
  export {
@@ -1,22 +1,12 @@
1
1
  import fs from "node:fs";
2
- import path from "node:path";
2
+ import path from "path";
3
3
  import execa from "execa";
4
4
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
5
5
  import { ensurePosixPath } from "@cedarjs/project-config";
6
6
  import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
7
- import c from "../../lib/colors.js";
8
- import { getPaths } from "../../lib/index.js";
9
- import * as project from "../../lib/project.js";
10
- import { warnIfNonStandardDatasourceUrl } from "./datasourceWarning.js";
11
- function hasStringMessage(value) {
12
- return typeof value === "object" && value !== null && "message" in value && value.message === "string";
13
- }
14
- function getExitCode(value) {
15
- if (!value || typeof value !== "object" || !("exitCode" in value) || typeof value.exitCode !== "number") {
16
- return void 0;
17
- }
18
- return value.exitCode;
19
- }
7
+ import c from "../lib/colors.js";
8
+ import { getPaths } from "../lib/index.js";
9
+ import * as project from "../lib/project.js";
20
10
  function isInGitRepository() {
21
11
  try {
22
12
  execa.commandSync("git rev-parse --is-inside-work-tree");
@@ -34,24 +24,25 @@ function isInMercurialRepository() {
34
24
  }
35
25
  }
36
26
  function isJestConfigFile(sides) {
37
- for (const side of sides) {
27
+ for (let side of sides) {
38
28
  try {
39
- const jestConfigExists = fs.existsSync(path.join(side, "jest.config.js")) || fs.existsSync(path.join(side, "jest.config.ts"));
40
- if (!jestConfigExists) {
41
- console.error(
42
- c.error(
43
- `
29
+ if (sides.includes(side)) {
30
+ const jestConfigExists = fs.existsSync(path.join(side, "jest.config.js")) || fs.existsSync(path.join(side, "jest.config.ts"));
31
+ if (!jestConfigExists) {
32
+ console.error(
33
+ c.error(
34
+ `
44
35
  Error: Missing Jest config file ${side}/jest.config.js
45
36
  To add this file, run \`npx @cedarjs/codemods update-jest-config\`
46
37
  `
47
- )
48
- );
49
- throw new Error(`Error: Jest config file not found in ${side} side`);
38
+ )
39
+ );
40
+ throw new Error(`Error: Jest config file not found in ${side} side`);
41
+ }
50
42
  }
51
- } catch (error) {
52
- const message = hasStringMessage(error) ? error.message : `Error: Jest config file not found in ${side} side`;
53
- errorTelemetry(process.argv, message);
54
- process.exit(getExitCode(error) ?? 1);
43
+ } catch (e) {
44
+ errorTelemetry(process.argv, e.message);
45
+ process.exit(e?.exitCode || 1);
55
46
  }
56
47
  }
57
48
  }
@@ -60,7 +51,6 @@ const handler = async ({
60
51
  watch = true,
61
52
  collectCoverage = false,
62
53
  dbPush = true,
63
- force = false,
64
54
  ...others
65
55
  }) => {
66
56
  recordTelemetryAttributes({
@@ -74,20 +64,21 @@ const handler = async ({
74
64
  if ([
75
65
  "collect-coverage",
76
66
  "db-push",
77
- "force",
78
67
  "loadEnvFiles",
79
68
  "watch",
80
69
  "$0",
81
70
  "_"
82
71
  ].includes(flagName)) {
83
72
  return [];
73
+ } else {
74
+ const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
75
+ const flagValue = others[flagName];
76
+ if (Array.isArray(flagValue)) {
77
+ return flagValue.flatMap((val) => [flag, val]);
78
+ } else {
79
+ return [flag, flagValue];
80
+ }
84
81
  }
85
- const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
86
- const flagValue = others[flagName];
87
- if (Array.isArray(flagValue)) {
88
- return flagValue.flatMap((val) => [flag, val]);
89
- }
90
- return [flag, flagValue];
91
82
  });
92
83
  const sides = filterParams.filter(
93
84
  (filterString) => project.workspaces().includes(filterString)
@@ -122,14 +113,11 @@ const handler = async ({
122
113
  if (sides.includes("api") && !dbPush) {
123
114
  process.env.SKIP_DB_PUSH = "1";
124
115
  }
125
- if (sides.includes("api")) {
126
- await warnIfNonStandardDatasourceUrl({ force });
127
- }
128
116
  const runCommand = async () => {
129
117
  await execa("yarn", ["jest", ...jestArgs], {
130
118
  cwd: rwjsPaths.base,
131
119
  stdio: "inherit",
132
- env: { ...process.env, DATABASE_URL }
120
+ env: { DATABASE_URL }
133
121
  });
134
122
  };
135
123
  if (watch) {
@@ -139,10 +127,9 @@ const handler = async ({
139
127
  await runCommand();
140
128
  });
141
129
  }
142
- } catch (error) {
143
- const message = hasStringMessage(error) ? error.message : "Test command failed";
144
- errorTelemetry(process.argv, message);
145
- process.exit(getExitCode(error) ?? 1);
130
+ } catch (e) {
131
+ errorTelemetry(process.argv, e.message);
132
+ process.exit(e?.exitCode || 1);
146
133
  }
147
134
  };
148
135
  export {
@@ -2,22 +2,11 @@ import execa from "execa";
2
2
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
3
3
  import { ensurePosixPath } from "@cedarjs/project-config";
4
4
  import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
5
- import { getPaths } from "../../lib/index.js";
6
- import * as project from "../../lib/project.js";
7
- import { warnIfNonStandardDatasourceUrl } from "./datasourceWarning.js";
8
- function hasStringMessage(value) {
9
- return typeof value === "object" && value !== null && "message" in value && value.message === "string";
10
- }
11
- function getExitCode(value) {
12
- if (!value || typeof value !== "object" || !("exitCode" in value) || typeof value.exitCode !== "number") {
13
- return void 0;
14
- }
15
- return value.exitCode;
16
- }
5
+ import { getPaths } from "../lib/index.js";
6
+ import * as project from "../lib/project.js";
17
7
  const handler = async ({
18
8
  filter: filterParams = [],
19
9
  dbPush = true,
20
- force = false,
21
10
  ...others
22
11
  }) => {
23
12
  recordTelemetryAttributes({
@@ -27,20 +16,22 @@ const handler = async ({
27
16
  let watch = true;
28
17
  const rwjsPaths = getPaths();
29
18
  const forwardVitestFlags = Object.keys(others).flatMap((flagName) => {
30
- if (["db-push", "force", "loadEnvFiles", "$0", "_"].includes(flagName)) {
19
+ if (["db-push", "loadEnvFiles", "$0", "_"].includes(flagName)) {
31
20
  return [];
21
+ } else {
22
+ const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
23
+ const flagValue = others[flagName];
24
+ if (flagName === "watch") {
25
+ watch = flagValue === true;
26
+ } else if (flagName === "run" && flagValue) {
27
+ watch = false;
28
+ }
29
+ if (Array.isArray(flagValue)) {
30
+ return flagValue.flatMap((val) => [flag, val]);
31
+ } else {
32
+ return [flag, flagValue];
33
+ }
32
34
  }
33
- const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
34
- const flagValue = others[flagName];
35
- if (flagName === "watch") {
36
- watch = flagValue === true;
37
- } else if (flagName === "run" && flagValue) {
38
- watch = false;
39
- }
40
- if (Array.isArray(flagValue)) {
41
- return flagValue.flatMap((val) => [flag, val]);
42
- }
43
- return [flag, flagValue];
44
35
  });
45
36
  const sides = filterParams.filter(
46
37
  (filterString) => project.workspaces().includes(filterString)
@@ -58,12 +49,10 @@ const handler = async ({
58
49
  if (process.env.CI) {
59
50
  vitestArgs.push("--run");
60
51
  }
61
- if (!others["config"]) {
62
- if (!sides.length) {
63
- project.workspaces().forEach((side) => sides.push(side));
64
- }
65
- sides.forEach((side) => vitestArgs.push("--project", side));
52
+ if (!sides.length) {
53
+ project.workspaces().forEach((side) => sides.push(side));
66
54
  }
55
+ sides.forEach((side) => vitestArgs.push("--project", side));
67
56
  try {
68
57
  const cacheDirDb = `file:${ensurePosixPath(
69
58
  rwjsPaths.generated.base
@@ -72,14 +61,11 @@ const handler = async ({
72
61
  if (sides.includes("api") && !dbPush) {
73
62
  process.env.SKIP_DB_PUSH = "1";
74
63
  }
75
- if (sides.includes("api")) {
76
- await warnIfNonStandardDatasourceUrl({ force });
77
- }
78
64
  const runCommand = async () => {
79
65
  await execa("yarn", ["vitest", ...vitestArgs], {
80
66
  cwd: rwjsPaths.base,
81
67
  stdio: "inherit",
82
- env: { ...process.env, DATABASE_URL }
68
+ env: { DATABASE_URL }
83
69
  });
84
70
  };
85
71
  if (watch) {
@@ -89,10 +75,9 @@ const handler = async ({
89
75
  await runCommand();
90
76
  });
91
77
  }
92
- } catch (error) {
93
- const message = hasStringMessage(error) ? error.message : "Test command failed";
94
- errorTelemetry(process.argv, message);
95
- process.exit(getExitCode(error) ?? 1);
78
+ } catch (e) {
79
+ errorTelemetry(process.argv, e.message);
80
+ process.exit(e?.exitCode || 1);
96
81
  }
97
82
  };
98
83
  export {
@@ -1,36 +1,25 @@
1
- import path from "node:path";
1
+ import path from "path";
2
2
  import concurrently from "concurrently";
3
3
  import execa from "execa";
4
4
  import { Listr } from "listr2";
5
5
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
6
6
  import { generatePrismaClient } from "../lib/generatePrismaClient.js";
7
7
  import { getPaths } from "../lib/index.js";
8
- const isConcurrentlyErrorArray = (value) => {
9
- return Array.isArray(value);
10
- };
11
- const handler = async ({
12
- sides,
13
- verbose = false,
14
- prisma = true,
15
- generate = true
16
- }) => {
17
- const selectedSides = (Array.isArray(sides) ? sides : []).filter(
18
- (side) => typeof side === "string"
19
- );
8
+ const handler = async ({ sides, verbose, prisma, generate }) => {
20
9
  recordTelemetryAttributes({
21
10
  command: "type-check",
22
- sides: JSON.stringify(selectedSides),
11
+ sides: JSON.stringify(sides),
23
12
  verbose,
24
13
  prisma,
25
14
  generate
26
15
  });
27
16
  const typeCheck = async () => {
28
17
  let conclusiveExitCode = 0;
29
- const tscForAllSides = selectedSides.map((side) => {
18
+ const tscForAllSides = sides.map((side) => {
30
19
  const projectDir = path.join(getPaths().base, side);
31
20
  return {
32
21
  cwd: projectDir,
33
- command: "yarn tsc --noEmit --skipLibCheck"
22
+ command: `yarn tsc --noEmit --skipLibCheck`
34
23
  };
35
24
  });
36
25
  const { result } = concurrently(tscForAllSides, {
@@ -39,16 +28,18 @@ const handler = async ({
39
28
  });
40
29
  try {
41
30
  await result;
42
- } catch (error) {
43
- if (isConcurrentlyErrorArray(error)) {
44
- const exitCodes = error.map((entry) => entry.exitCode).filter((exitCode2) => Boolean(exitCode2));
31
+ } catch (err) {
32
+ if (err.length) {
33
+ const exitCodes = err.map((e) => e?.exitCode).filter(Boolean);
45
34
  conclusiveExitCode = Math.max(...exitCodes);
46
35
  }
47
36
  }
48
37
  return conclusiveExitCode;
49
38
  };
50
39
  if (generate && prisma) {
51
- await generatePrismaClient({ verbose });
40
+ await generatePrismaClient({
41
+ verbose
42
+ });
52
43
  }
53
44
  if (generate) {
54
45
  await new Listr(
@@ -62,7 +53,7 @@ const handler = async ({
62
53
  }
63
54
  ],
64
55
  {
65
- renderer: verbose ? "verbose" : "default",
56
+ renderer: verbose && "verbose",
66
57
  rendererOptions: { collapseSubtasks: false }
67
58
  }
68
59
  ).run();
@@ -331,11 +331,6 @@ async function updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }) {
331
331
  title: `Updating ${pkgJsonPath}`,
332
332
  task: async (_ctx, task) => {
333
333
  const res = await fetch(url);
334
- if (!res.ok) {
335
- throw new Error(
336
- `Failed to fetch template package.json from ${url}: ` + res.statusText
337
- );
338
- }
339
334
  const text = await res.text();
340
335
  const templatePackageJson = JSON.parse(text);
341
336
  const localPackageJsonText = fs.readFileSync(pkgJsonPath, "utf-8");
@@ -385,19 +380,16 @@ async function downloadYarnPatches(ctx, { dryRun, verbose }) {
385
380
  throw new Error("Failed to upgrade");
386
381
  }
387
382
  const githubToken = process.env.GH_TOKEN || process.env.GITHUB_TOKEN || process.env.REDWOOD_GITHUB_TOKEN;
388
- const url = "https://api.github.com/repos/cedarjs/cedar/git/trees/main?recursive=1";
389
- const res = await fetch(url, {
390
- headers: {
391
- ...githubToken && { Authorization: `Bearer ${githubToken}` },
392
- ["X-GitHub-Api-Version"]: "2022-11-28",
393
- Accept: "application/vnd.github+json"
383
+ const res = await fetch(
384
+ "https://api.github.com/repos/cedarjs/cedar/git/trees/main?recursive=1",
385
+ {
386
+ headers: {
387
+ ...githubToken && { Authorization: `Bearer ${githubToken}` },
388
+ ["X-GitHub-Api-Version"]: "2022-11-28",
389
+ Accept: "application/vnd.github+json"
390
+ }
394
391
  }
395
- });
396
- if (!res.ok) {
397
- throw new Error(
398
- `Failed to fetch list of yarn patches from ${url}: ` + res.statusText
399
- );
400
- }
392
+ );
401
393
  const json = await res.json();
402
394
  const patches = json.tree?.filter(
403
395
  (patchInfo) => patchInfo.path.startsWith(
@@ -417,11 +409,6 @@ async function downloadYarnPatches(ctx, { dryRun, verbose }) {
417
409
  title: `Downloading ${patch.path}`,
418
410
  task: async () => {
419
411
  const res2 = await fetch(patch.url);
420
- if (!res2.ok) {
421
- throw new Error(
422
- `Failed to fetch patch metadata from ${patch.url}: ` + res2.statusText
423
- );
424
- }
425
412
  const patchMeta = await res2.json();
426
413
  const patchPath = path.join(
427
414
  getPaths().base,
@@ -47,8 +47,6 @@ function spawnBackgroundProcess(name, cmd, args) {
47
47
  const child = spawn(cmd, args, spawnOptions);
48
48
  child.unref();
49
49
  }
50
- fs.closeSync(stdout);
51
- fs.closeSync(stderr);
52
50
  }
53
51
  export {
54
52
  spawnBackgroundProcess
@@ -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 "./index.js";
4
+ import { runCommandTask, getPaths } from "../lib/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 { clientPath } = await resolveGeneratedPrismaClient();
24
- const prismaClientFile = clientPath && fs.existsSync(clientPath) ? fs.readFileSync(clientPath, "utf8") : "";
23
+ const prismaClientPath = resolveGeneratedPrismaClient();
24
+ const prismaClientFile = 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,8 +1,9 @@
1
1
  import prismaInternals from "@prisma/internals";
2
- import { getPrismaSchemas } from "@cedarjs/project-config";
2
+ import { getSchemaPath } from "@cedarjs/project-config";
3
3
  import { singularize, isPlural } from "@cedarjs/utils/cedarPluralize";
4
4
  import { ensureUniquePlural } from "./pluralHelpers.js";
5
- const { getConfig, getDMMF } = prismaInternals;
5
+ import { getPaths } from "./index.js";
6
+ const { getConfig, getDMMF, getSchemaWithPath } = prismaInternals;
6
7
  const schemaMemo = {};
7
8
  const getExistingModelName = async (name) => {
8
9
  if (!name) {
@@ -63,7 +64,9 @@ const getEnum = async (name) => {
63
64
  return model;
64
65
  };
65
66
  const getDataModel = async () => {
66
- const result = await getPrismaSchemas();
67
+ const prismaConfigPath = getPaths().api.prismaConfig;
68
+ const schemaPath = await getSchemaPath(prismaConfigPath);
69
+ const result = await getSchemaWithPath(schemaPath);
67
70
  return result.schemas;
68
71
  };
69
72
  const getSchemaDefinitions = async () => {
package/dist/lib/test.js CHANGED
@@ -61,16 +61,6 @@ 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
- },
74
64
  getDataMigrationsPath: () => {
75
65
  return path.join(globalThis.__dirname, "fixtures", "migrations");
76
66
  }
@@ -55,7 +55,9 @@ async function getResources() {
55
55
  developmentEnvironment = "gitpod";
56
56
  }
57
57
  const experiments = Object.keys(getRawConfig()["experimental"] || {});
58
- const project = new RWProject();
58
+ const project = new RWProject({
59
+ projectRoot: getPaths().base
60
+ });
59
61
  const routes = project.getRouter().routes;
60
62
  const prerenderedRoutes = routes.filter((route) => route.hasPrerender);
61
63
  const complexity = [