@cedarjs/testing 3.0.0-canary.13596 → 3.0.0-canary.13597
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/config/jest/api/globalSetup.d.ts.map +1 -1
- package/config/jest/api/globalSetup.js +5 -14
- package/config/jest/api/jest-preset.d.ts.map +1 -1
- package/config/jest/api/jest-preset.js +5 -4
- package/config/jest/api/jest.setup.js +8 -12
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +0 -1
- package/dist/api/vitest/CedarApiVitestEnv.d.ts.map +1 -1
- package/dist/api/vitest/CedarApiVitestEnv.js +5 -13
- package/dist/api/vitest/vitest-api.setup.js +5 -7
- package/dist/cjs/api/index.d.ts +0 -1
- package/dist/cjs/api/index.d.ts.map +1 -1
- package/dist/cjs/api/index.js +1 -3
- package/dist/cjs/api/vitest/CedarApiVitestEnv.js +4 -12
- package/dist/cjs/api/vitest/vitest-api.setup.js +4 -6
- package/dist/cjs/config/jest/api/globalSetup.d.ts.map +1 -1
- package/dist/cjs/config/jest/api/globalSetup.js +5 -14
- package/dist/cjs/config/jest/api/jest-preset.d.ts.map +1 -1
- package/dist/cjs/config/jest/api/jest-preset.js +5 -4
- package/dist/cjs/config/jest/api/jest.setup.js +8 -12
- package/dist/config/jest/api/globalSetup.d.ts.map +1 -1
- package/dist/config/jest/api/globalSetup.js +6 -18
- package/dist/config/jest/api/jest-preset.d.ts.map +1 -1
- package/dist/config/jest/api/jest-preset.js +5 -4
- package/dist/config/jest/api/jest.setup.js +8 -12
- package/package.json +10 -10
- package/dist/api/directUrlHelpers.d.ts +0 -3
- package/dist/api/directUrlHelpers.d.ts.map +0 -1
- package/dist/api/directUrlHelpers.js +0 -25
- package/dist/cjs/api/directUrlHelpers.d.ts +0 -3
- package/dist/cjs/api/directUrlHelpers.d.ts.map +0 -1
- package/dist/cjs/api/directUrlHelpers.js +0 -60
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalSetup.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/api/globalSetup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"globalSetup.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/api/globalSetup.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAA;AAK/B,0CAyBC"}
|
|
@@ -31,32 +31,23 @@ __export(globalSetup_exports, {
|
|
|
31
31
|
default: () => globalSetup_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(globalSetup_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
35
|
var import_config = require("dotenv-defaults/config");
|
|
36
36
|
var import_execa = __toESM(require("execa"), 1);
|
|
37
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
var import_directUrlHelpers = require("@cedarjs/testing/dist/cjs/api/directUrlHelpers.js");
|
|
39
|
-
const { getSchemaWithPath } = import_internals.default;
|
|
40
|
-
const rwjsPaths = (0, import_project_config.getPaths)();
|
|
41
38
|
async function globalSetup_default() {
|
|
42
39
|
if (process.env.SKIP_DB_PUSH === "1") {
|
|
43
40
|
return;
|
|
44
41
|
}
|
|
45
|
-
const
|
|
42
|
+
const cedarPaths = (0, import_project_config.getPaths)();
|
|
43
|
+
const defaultDb = `file:${import_node_path.default.join(cedarPaths.base, ".redwood", "test.db")}`;
|
|
46
44
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
47
|
-
const
|
|
48
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
49
|
-
const prismaSchema = result.schemas.map(([, content]) => content).join("\n");
|
|
50
|
-
const directUrlEnvVar = (0, import_directUrlHelpers.checkAndReplaceDirectUrl)(prismaSchema, defaultDb);
|
|
51
|
-
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force", "--skip-seed"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
45
|
+
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
52
46
|
const env = {
|
|
53
47
|
DATABASE_URL: process.env.DATABASE_URL
|
|
54
48
|
};
|
|
55
|
-
if (directUrlEnvVar) {
|
|
56
|
-
env[directUrlEnvVar] = process.env[directUrlEnvVar];
|
|
57
|
-
}
|
|
58
49
|
import_execa.default.sync("yarn", ["cedar", ...command], {
|
|
59
|
-
cwd:
|
|
50
|
+
cwd: cedarPaths.api.base,
|
|
60
51
|
stdio: "inherit",
|
|
61
52
|
env
|
|
62
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/api/jest-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AASlC,QAAA,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/api/jest-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AASlC,QAAA,MAAM,MAAM,EAAE,MA0Db,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -50,8 +50,7 @@ const config = {
|
|
|
50
50
|
tearDownCachePath: import_node_path.default.join(
|
|
51
51
|
rwjsPaths.generated.base,
|
|
52
52
|
"scenarioTeardown.json"
|
|
53
|
-
)
|
|
54
|
-
prismaConfigPath: rwjsPaths.api.prismaConfig
|
|
53
|
+
)
|
|
55
54
|
}
|
|
56
55
|
},
|
|
57
56
|
sandboxInjectedGlobals: ["__RWJS__TEST_IMPORTS"],
|
|
@@ -60,7 +59,7 @@ const config = {
|
|
|
60
59
|
name: "api"
|
|
61
60
|
},
|
|
62
61
|
collectCoverageFrom: [
|
|
63
|
-
"**/*.{js,jsx,ts,tsx}",
|
|
62
|
+
"**/*.{js,jsx,ts,tsx,mts,cts}",
|
|
64
63
|
"!**/node_modules/**",
|
|
65
64
|
"!**/dist/**"
|
|
66
65
|
],
|
|
@@ -74,6 +73,8 @@ const config = {
|
|
|
74
73
|
// Note this setup runs for each test file!
|
|
75
74
|
setupFilesAfterEnv: [import_node_path.default.join(__dirname, "./jest.setup.js")],
|
|
76
75
|
moduleNameMapper: {
|
|
76
|
+
"^api/(.*)$": import_node_path.default.join(rwjsPaths.base, "api/$1"),
|
|
77
|
+
"^src/(.*)$": import_node_path.default.join(rwjsPaths.api.src, "$1"),
|
|
77
78
|
// @NOTE: Import @cedarjs/testing in api tests, and it automatically remaps to the api side only
|
|
78
79
|
// This is to prevent web stuff leaking into api, and vice versa
|
|
79
80
|
"^@cedarjs/testing$": import_node_path.default.join(NODE_MODULES_PATH, "@cedarjs/testing/api"),
|
|
@@ -81,7 +82,7 @@ const config = {
|
|
|
81
82
|
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
82
83
|
},
|
|
83
84
|
transform: {
|
|
84
|
-
"\\.[jt]sx?$": [
|
|
85
|
+
"\\.[cm]?[jt]sx?$": [
|
|
85
86
|
"babel-jest",
|
|
86
87
|
// When jest runs tests in parallel, it serializes the config before passing down options to babel
|
|
87
88
|
// that's why these must be serializable. So ideally, we should just pass reference to a
|
|
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
25
25
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
26
26
|
var import_scenario = require("@cedarjs/testing/dist/cjs/api/scenario.js");
|
|
27
|
-
const { apiSrcPath, tearDownCachePath
|
|
27
|
+
const { apiSrcPath, tearDownCachePath } = global.__RWJS__TEST_IMPORTS;
|
|
28
28
|
global.defineScenario = import_scenario.defineScenario;
|
|
29
29
|
const mockContextStore = /* @__PURE__ */ new Map();
|
|
30
30
|
const mockContext = new Proxy(
|
|
@@ -58,10 +58,9 @@ const isIdenticalArray = (a, b) => {
|
|
|
58
58
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
59
59
|
};
|
|
60
60
|
const configureTeardown = async () => {
|
|
61
|
-
const { getDMMF
|
|
62
|
-
const {
|
|
63
|
-
const
|
|
64
|
-
const { schemas } = await getSchemaWithPath(schemaPath);
|
|
61
|
+
const { getDMMF } = require("@prisma/internals");
|
|
62
|
+
const { getPrismaSchemas } = require("@cedarjs/project-config");
|
|
63
|
+
const { schemas } = await getPrismaSchemas();
|
|
65
64
|
const schema = await getDMMF({ datamodel: schemas });
|
|
66
65
|
const schemaModels = schema.datamodel.models.map(
|
|
67
66
|
(m) => m.dbName || m.name
|
|
@@ -76,14 +75,11 @@ const configureTeardown = async () => {
|
|
|
76
75
|
};
|
|
77
76
|
let quoteStyle;
|
|
78
77
|
const getQuoteStyle = async () => {
|
|
79
|
-
const { getConfig: getPrismaConfig
|
|
80
|
-
const {
|
|
81
|
-
const
|
|
82
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
78
|
+
const { getConfig: getPrismaConfig } = require("@prisma/internals");
|
|
79
|
+
const { getPrismaSchemas } = require("@cedarjs/project-config");
|
|
80
|
+
const result = await getPrismaSchemas();
|
|
83
81
|
if (!quoteStyle) {
|
|
84
|
-
const config = await getPrismaConfig({
|
|
85
|
-
datamodel: result.schemas
|
|
86
|
-
});
|
|
82
|
+
const config = await getPrismaConfig({ datamodel: result.schemas });
|
|
87
83
|
switch (config.datasources?.[0]?.provider) {
|
|
88
84
|
case "mysql":
|
|
89
85
|
quoteStyle = "`";
|
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
|
package/dist/api/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CedarApiVitestEnv.d.ts","sourceRoot":"","sources":["../../../src/api/vitest/CedarApiVitestEnv.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CedarApiVitestEnv.d.ts","sourceRoot":"","sources":["../../../src/api/vitest/CedarApiVitestEnv.ts"],"names":[],"mappings":"AAEA,OAAO,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAItD,QAAA,MAAM,yBAAyB,EAAE,WAkChC,CAAA;AAED,eAAe,yBAAyB,CAAA"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from "node:path";
|
|
2
2
|
import "dotenv-defaults/config.js";
|
|
3
3
|
import execa from "execa";
|
|
4
|
-
import { getPaths
|
|
5
|
-
import { getDefaultDb, checkAndReplaceDirectUrl } from "../directUrlHelpers.js";
|
|
6
|
-
const { getSchemaWithPath } = prismaInternals;
|
|
4
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
7
5
|
const CedarApiVitestEnvironment = {
|
|
8
6
|
name: "cedar-api",
|
|
9
7
|
transformMode: "ssr",
|
|
@@ -15,20 +13,14 @@ const CedarApiVitestEnvironment = {
|
|
|
15
13
|
};
|
|
16
14
|
}
|
|
17
15
|
const cedarPaths = getPaths();
|
|
18
|
-
const defaultDb =
|
|
16
|
+
const defaultDb = `file:${path.join(cedarPaths.base, ".redwood", "test.db")}`;
|
|
19
17
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
20
|
-
const
|
|
21
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
22
|
-
const prismaSchema = result.schemas.map(([, content]) => content).join("\n");
|
|
23
|
-
const directUrlEnvVar = checkAndReplaceDirectUrl(prismaSchema, defaultDb);
|
|
24
|
-
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force", "--skip-seed"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
25
|
-
const directUrlDefinition = directUrlEnvVar ? { [directUrlEnvVar]: process.env[directUrlEnvVar] } : {};
|
|
18
|
+
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
26
19
|
execa.sync("yarn", ["cedar", ...command], {
|
|
27
20
|
cwd: cedarPaths.api.base,
|
|
28
21
|
stdio: "inherit",
|
|
29
22
|
env: {
|
|
30
|
-
DATABASE_URL: process.env.DATABASE_URL
|
|
31
|
-
...directUrlDefinition
|
|
23
|
+
DATABASE_URL: process.env.DATABASE_URL
|
|
32
24
|
}
|
|
33
25
|
});
|
|
34
26
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { afterAll, beforeEach, it, describe, vi, beforeAll } from "vitest";
|
|
4
|
-
import { getPaths,
|
|
4
|
+
import { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
|
|
5
5
|
import { defineScenario } from "@cedarjs/testing/api";
|
|
6
6
|
const mockContextStore = vi.hoisted(() => /* @__PURE__ */ new Map());
|
|
7
7
|
const mockContext = vi.hoisted(
|
|
@@ -106,9 +106,8 @@ async function configureTeardown() {
|
|
|
106
106
|
if (!wasDbImported()) {
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
const { getDMMF
|
|
110
|
-
const
|
|
111
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
109
|
+
const { getDMMF } = await import("@prisma/internals");
|
|
110
|
+
const result = await getPrismaSchemas();
|
|
112
111
|
const schema = await getDMMF({ datamodel: result.schemas });
|
|
113
112
|
const schemaModels = schema.datamodel.models.map((m) => {
|
|
114
113
|
return m.dbName || m.name;
|
|
@@ -210,9 +209,8 @@ const wasDbImported = () => {
|
|
|
210
209
|
};
|
|
211
210
|
let quoteStyle;
|
|
212
211
|
async function getQuoteStyle() {
|
|
213
|
-
const { getConfig: getPrismaConfig
|
|
214
|
-
const
|
|
215
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
212
|
+
const { getConfig: getPrismaConfig } = await import("@prisma/internals");
|
|
213
|
+
const result = await getPrismaSchemas();
|
|
216
214
|
if (!quoteStyle) {
|
|
217
215
|
const config = await getPrismaConfig({
|
|
218
216
|
datamodel: result.schemas
|
package/dist/cjs/api/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
|
package/dist/cjs/api/index.js
CHANGED
|
@@ -18,11 +18,9 @@ module.exports = __toCommonJS(api_exports);
|
|
|
18
18
|
__reExport(api_exports, require("./apiFunction.js"), module.exports);
|
|
19
19
|
__reExport(api_exports, require("./scenario.js"), module.exports);
|
|
20
20
|
__reExport(api_exports, require("./directive.js"), module.exports);
|
|
21
|
-
__reExport(api_exports, require("./directUrlHelpers.js"), module.exports);
|
|
22
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23
22
|
0 && (module.exports = {
|
|
24
23
|
...require("./apiFunction.js"),
|
|
25
24
|
...require("./scenario.js"),
|
|
26
|
-
...require("./directive.js")
|
|
27
|
-
...require("./directUrlHelpers.js")
|
|
25
|
+
...require("./directive.js")
|
|
28
26
|
});
|
|
@@ -31,12 +31,10 @@ __export(CedarApiVitestEnv_exports, {
|
|
|
31
31
|
default: () => CedarApiVitestEnv_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(CedarApiVitestEnv_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
35
|
var import_config = require("dotenv-defaults/config.js");
|
|
36
36
|
var import_execa = __toESM(require("execa"), 1);
|
|
37
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
var import_directUrlHelpers = require("../directUrlHelpers.js");
|
|
39
|
-
const { getSchemaWithPath } = import_internals.default;
|
|
40
38
|
const CedarApiVitestEnvironment = {
|
|
41
39
|
name: "cedar-api",
|
|
42
40
|
transformMode: "ssr",
|
|
@@ -48,20 +46,14 @@ const CedarApiVitestEnvironment = {
|
|
|
48
46
|
};
|
|
49
47
|
}
|
|
50
48
|
const cedarPaths = (0, import_project_config.getPaths)();
|
|
51
|
-
const defaultDb = (
|
|
49
|
+
const defaultDb = `file:${import_node_path.default.join(cedarPaths.base, ".redwood", "test.db")}`;
|
|
52
50
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
53
|
-
const
|
|
54
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
55
|
-
const prismaSchema = result.schemas.map(([, content]) => content).join("\n");
|
|
56
|
-
const directUrlEnvVar = (0, import_directUrlHelpers.checkAndReplaceDirectUrl)(prismaSchema, defaultDb);
|
|
57
|
-
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force", "--skip-seed"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
58
|
-
const directUrlDefinition = directUrlEnvVar ? { [directUrlEnvVar]: process.env[directUrlEnvVar] } : {};
|
|
51
|
+
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
59
52
|
import_execa.default.sync("yarn", ["cedar", ...command], {
|
|
60
53
|
cwd: cedarPaths.api.base,
|
|
61
54
|
stdio: "inherit",
|
|
62
55
|
env: {
|
|
63
|
-
DATABASE_URL: process.env.DATABASE_URL
|
|
64
|
-
...directUrlDefinition
|
|
56
|
+
DATABASE_URL: process.env.DATABASE_URL
|
|
65
57
|
}
|
|
66
58
|
});
|
|
67
59
|
return {
|
|
@@ -129,9 +129,8 @@ async function configureTeardown() {
|
|
|
129
129
|
if (!wasDbImported()) {
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
-
const { getDMMF
|
|
133
|
-
const
|
|
134
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
132
|
+
const { getDMMF } = await import("@prisma/internals");
|
|
133
|
+
const result = await (0, import_project_config.getPrismaSchemas)();
|
|
135
134
|
const schema = await getDMMF({ datamodel: result.schemas });
|
|
136
135
|
const schemaModels = schema.datamodel.models.map((m) => {
|
|
137
136
|
return m.dbName || m.name;
|
|
@@ -233,9 +232,8 @@ const wasDbImported = () => {
|
|
|
233
232
|
};
|
|
234
233
|
let quoteStyle;
|
|
235
234
|
async function getQuoteStyle() {
|
|
236
|
-
const { getConfig: getPrismaConfig
|
|
237
|
-
const
|
|
238
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
235
|
+
const { getConfig: getPrismaConfig } = await import("@prisma/internals");
|
|
236
|
+
const result = await (0, import_project_config.getPrismaSchemas)();
|
|
239
237
|
if (!quoteStyle) {
|
|
240
238
|
const config = await getPrismaConfig({
|
|
241
239
|
datamodel: result.schemas
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalSetup.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/api/globalSetup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"globalSetup.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/api/globalSetup.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAA;AAK/B,0CAyBC"}
|
|
@@ -31,32 +31,23 @@ __export(globalSetup_exports, {
|
|
|
31
31
|
default: () => globalSetup_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(globalSetup_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
35
|
var import_config = require("dotenv-defaults/config");
|
|
36
36
|
var import_execa = __toESM(require("execa"), 1);
|
|
37
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
var import_directUrlHelpers = require("../../../api/directUrlHelpers.js");
|
|
39
|
-
const { getSchemaWithPath } = import_internals.default;
|
|
40
|
-
const rwjsPaths = (0, import_project_config.getPaths)();
|
|
41
38
|
async function globalSetup_default() {
|
|
42
39
|
if (process.env.SKIP_DB_PUSH === "1") {
|
|
43
40
|
return;
|
|
44
41
|
}
|
|
45
|
-
const
|
|
42
|
+
const cedarPaths = (0, import_project_config.getPaths)();
|
|
43
|
+
const defaultDb = `file:${import_node_path.default.join(cedarPaths.base, ".redwood", "test.db")}`;
|
|
46
44
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
47
|
-
const
|
|
48
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
49
|
-
const prismaSchema = result.schemas.map(([, content]) => content).join("\n");
|
|
50
|
-
const directUrlEnvVar = (0, import_directUrlHelpers.checkAndReplaceDirectUrl)(prismaSchema, defaultDb);
|
|
51
|
-
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force", "--skip-seed"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
45
|
+
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
52
46
|
const env = {
|
|
53
47
|
DATABASE_URL: process.env.DATABASE_URL
|
|
54
48
|
};
|
|
55
|
-
if (directUrlEnvVar) {
|
|
56
|
-
env[directUrlEnvVar] = process.env[directUrlEnvVar];
|
|
57
|
-
}
|
|
58
49
|
import_execa.default.sync("yarn", ["cedar", ...command], {
|
|
59
|
-
cwd:
|
|
50
|
+
cwd: cedarPaths.api.base,
|
|
60
51
|
stdio: "inherit",
|
|
61
52
|
env
|
|
62
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/api/jest-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AASlC,QAAA,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/api/jest-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AASlC,QAAA,MAAM,MAAM,EAAE,MA0Db,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -50,8 +50,7 @@ const config = {
|
|
|
50
50
|
tearDownCachePath: import_node_path.default.join(
|
|
51
51
|
rwjsPaths.generated.base,
|
|
52
52
|
"scenarioTeardown.json"
|
|
53
|
-
)
|
|
54
|
-
prismaConfigPath: rwjsPaths.api.prismaConfig
|
|
53
|
+
)
|
|
55
54
|
}
|
|
56
55
|
},
|
|
57
56
|
sandboxInjectedGlobals: ["__RWJS__TEST_IMPORTS"],
|
|
@@ -60,7 +59,7 @@ const config = {
|
|
|
60
59
|
name: "api"
|
|
61
60
|
},
|
|
62
61
|
collectCoverageFrom: [
|
|
63
|
-
"**/*.{js,jsx,ts,tsx}",
|
|
62
|
+
"**/*.{js,jsx,ts,tsx,mts,cts}",
|
|
64
63
|
"!**/node_modules/**",
|
|
65
64
|
"!**/dist/**"
|
|
66
65
|
],
|
|
@@ -74,6 +73,8 @@ const config = {
|
|
|
74
73
|
// Note this setup runs for each test file!
|
|
75
74
|
setupFilesAfterEnv: [import_node_path.default.join(__dirname, "./jest.setup.js")],
|
|
76
75
|
moduleNameMapper: {
|
|
76
|
+
"^api/(.*)$": import_node_path.default.join(rwjsPaths.base, "api/$1"),
|
|
77
|
+
"^src/(.*)$": import_node_path.default.join(rwjsPaths.api.src, "$1"),
|
|
77
78
|
// @NOTE: Import @cedarjs/testing in api tests, and it automatically remaps to the api side only
|
|
78
79
|
// This is to prevent web stuff leaking into api, and vice versa
|
|
79
80
|
"^@cedarjs/testing$": import_node_path.default.join(NODE_MODULES_PATH, "@cedarjs/testing/api"),
|
|
@@ -81,7 +82,7 @@ const config = {
|
|
|
81
82
|
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
82
83
|
},
|
|
83
84
|
transform: {
|
|
84
|
-
"\\.[jt]sx?$": [
|
|
85
|
+
"\\.[cm]?[jt]sx?$": [
|
|
85
86
|
"babel-jest",
|
|
86
87
|
// When jest runs tests in parallel, it serializes the config before passing down options to babel
|
|
87
88
|
// that's why these must be serializable. So ideally, we should just pass reference to a
|
|
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
25
25
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
26
26
|
var import_scenario = require("../../../api/scenario.js");
|
|
27
|
-
const { apiSrcPath, tearDownCachePath
|
|
27
|
+
const { apiSrcPath, tearDownCachePath } = global.__RWJS__TEST_IMPORTS;
|
|
28
28
|
global.defineScenario = import_scenario.defineScenario;
|
|
29
29
|
const mockContextStore = /* @__PURE__ */ new Map();
|
|
30
30
|
const mockContext = new Proxy(
|
|
@@ -58,10 +58,9 @@ const isIdenticalArray = (a, b) => {
|
|
|
58
58
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
59
59
|
};
|
|
60
60
|
const configureTeardown = async () => {
|
|
61
|
-
const { getDMMF
|
|
62
|
-
const {
|
|
63
|
-
const
|
|
64
|
-
const { schemas } = await getSchemaWithPath(schemaPath);
|
|
61
|
+
const { getDMMF } = await import("@prisma/internals");
|
|
62
|
+
const { getPrismaSchemas } = await import("@cedarjs/project-config");
|
|
63
|
+
const { schemas } = await getPrismaSchemas();
|
|
65
64
|
const schema = await getDMMF({ datamodel: schemas });
|
|
66
65
|
const schemaModels = schema.datamodel.models.map(
|
|
67
66
|
(m) => m.dbName || m.name
|
|
@@ -76,14 +75,11 @@ const configureTeardown = async () => {
|
|
|
76
75
|
};
|
|
77
76
|
let quoteStyle;
|
|
78
77
|
const getQuoteStyle = async () => {
|
|
79
|
-
const { getConfig: getPrismaConfig
|
|
80
|
-
const {
|
|
81
|
-
const
|
|
82
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
78
|
+
const { getConfig: getPrismaConfig } = await import("@prisma/internals");
|
|
79
|
+
const { getPrismaSchemas } = await import("@cedarjs/project-config");
|
|
80
|
+
const result = await getPrismaSchemas();
|
|
83
81
|
if (!quoteStyle) {
|
|
84
|
-
const config = await getPrismaConfig({
|
|
85
|
-
datamodel: result.schemas
|
|
86
|
-
});
|
|
82
|
+
const config = await getPrismaConfig({ datamodel: result.schemas });
|
|
87
83
|
switch (config.datasources?.[0]?.provider) {
|
|
88
84
|
case "mysql":
|
|
89
85
|
quoteStyle = "`";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalSetup.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/globalSetup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"globalSetup.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/globalSetup.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAA;AAK/B,0CAyBC"}
|
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from "node:path";
|
|
2
2
|
import "dotenv-defaults/config";
|
|
3
3
|
import execa from "execa";
|
|
4
|
-
import { getPaths
|
|
5
|
-
import {
|
|
6
|
-
getDefaultDb,
|
|
7
|
-
checkAndReplaceDirectUrl
|
|
8
|
-
} from "../../../api/directUrlHelpers.js";
|
|
9
|
-
const { getSchemaWithPath } = prismaInternals;
|
|
10
|
-
const rwjsPaths = getPaths();
|
|
4
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
11
5
|
async function globalSetup_default() {
|
|
12
6
|
if (process.env.SKIP_DB_PUSH === "1") {
|
|
13
7
|
return;
|
|
14
8
|
}
|
|
15
|
-
const
|
|
9
|
+
const cedarPaths = getPaths();
|
|
10
|
+
const defaultDb = `file:${path.join(cedarPaths.base, ".redwood", "test.db")}`;
|
|
16
11
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
17
|
-
const
|
|
18
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
19
|
-
const prismaSchema = result.schemas.map(([, content]) => content).join("\n");
|
|
20
|
-
const directUrlEnvVar = checkAndReplaceDirectUrl(prismaSchema, defaultDb);
|
|
21
|
-
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force", "--skip-seed"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
12
|
+
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
22
13
|
const env = {
|
|
23
14
|
DATABASE_URL: process.env.DATABASE_URL
|
|
24
15
|
};
|
|
25
|
-
if (directUrlEnvVar) {
|
|
26
|
-
env[directUrlEnvVar] = process.env[directUrlEnvVar];
|
|
27
|
-
}
|
|
28
16
|
execa.sync("yarn", ["cedar", ...command], {
|
|
29
|
-
cwd:
|
|
17
|
+
cwd: cedarPaths.api.base,
|
|
30
18
|
stdio: "inherit",
|
|
31
19
|
env
|
|
32
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/jest-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AASlC,QAAA,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/jest-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AASlC,QAAA,MAAM,MAAM,EAAE,MA0Db,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -17,8 +17,7 @@ const config = {
|
|
|
17
17
|
tearDownCachePath: path.join(
|
|
18
18
|
rwjsPaths.generated.base,
|
|
19
19
|
"scenarioTeardown.json"
|
|
20
|
-
)
|
|
21
|
-
prismaConfigPath: rwjsPaths.api.prismaConfig
|
|
20
|
+
)
|
|
22
21
|
}
|
|
23
22
|
},
|
|
24
23
|
sandboxInjectedGlobals: ["__RWJS__TEST_IMPORTS"],
|
|
@@ -27,7 +26,7 @@ const config = {
|
|
|
27
26
|
name: "api"
|
|
28
27
|
},
|
|
29
28
|
collectCoverageFrom: [
|
|
30
|
-
"**/*.{js,jsx,ts,tsx}",
|
|
29
|
+
"**/*.{js,jsx,ts,tsx,mts,cts}",
|
|
31
30
|
"!**/node_modules/**",
|
|
32
31
|
"!**/dist/**"
|
|
33
32
|
],
|
|
@@ -41,6 +40,8 @@ const config = {
|
|
|
41
40
|
// Note this setup runs for each test file!
|
|
42
41
|
setupFilesAfterEnv: [path.join(__dirname, "./jest.setup.js")],
|
|
43
42
|
moduleNameMapper: {
|
|
43
|
+
"^api/(.*)$": path.join(rwjsPaths.base, "api/$1"),
|
|
44
|
+
"^src/(.*)$": path.join(rwjsPaths.api.src, "$1"),
|
|
44
45
|
// @NOTE: Import @cedarjs/testing in api tests, and it automatically remaps to the api side only
|
|
45
46
|
// This is to prevent web stuff leaking into api, and vice versa
|
|
46
47
|
"^@cedarjs/testing$": path.join(NODE_MODULES_PATH, "@cedarjs/testing/api"),
|
|
@@ -48,7 +49,7 @@ const config = {
|
|
|
48
49
|
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
49
50
|
},
|
|
50
51
|
transform: {
|
|
51
|
-
"\\.[jt]sx?$": [
|
|
52
|
+
"\\.[cm]?[jt]sx?$": [
|
|
52
53
|
"babel-jest",
|
|
53
54
|
// When jest runs tests in parallel, it serializes the config before passing down options to babel
|
|
54
55
|
// that's why these must be serializable. So ideally, we should just pass reference to a
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { defineScenario } from "../../../api/scenario.js";
|
|
4
|
-
const { apiSrcPath, tearDownCachePath
|
|
4
|
+
const { apiSrcPath, tearDownCachePath } = global.__RWJS__TEST_IMPORTS;
|
|
5
5
|
global.defineScenario = defineScenario;
|
|
6
6
|
const mockContextStore = /* @__PURE__ */ new Map();
|
|
7
7
|
const mockContext = new Proxy(
|
|
@@ -35,10 +35,9 @@ const isIdenticalArray = (a, b) => {
|
|
|
35
35
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
36
36
|
};
|
|
37
37
|
const configureTeardown = async () => {
|
|
38
|
-
const { getDMMF
|
|
39
|
-
const {
|
|
40
|
-
const
|
|
41
|
-
const { schemas } = await getSchemaWithPath(schemaPath);
|
|
38
|
+
const { getDMMF } = await import("@prisma/internals");
|
|
39
|
+
const { getPrismaSchemas } = await import("@cedarjs/project-config");
|
|
40
|
+
const { schemas } = await getPrismaSchemas();
|
|
42
41
|
const schema = await getDMMF({ datamodel: schemas });
|
|
43
42
|
const schemaModels = schema.datamodel.models.map(
|
|
44
43
|
(m) => m.dbName || m.name
|
|
@@ -53,14 +52,11 @@ const configureTeardown = async () => {
|
|
|
53
52
|
};
|
|
54
53
|
let quoteStyle;
|
|
55
54
|
const getQuoteStyle = async () => {
|
|
56
|
-
const { getConfig: getPrismaConfig
|
|
57
|
-
const {
|
|
58
|
-
const
|
|
59
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
55
|
+
const { getConfig: getPrismaConfig } = await import("@prisma/internals");
|
|
56
|
+
const { getPrismaSchemas } = await import("@cedarjs/project-config");
|
|
57
|
+
const result = await getPrismaSchemas();
|
|
60
58
|
if (!quoteStyle) {
|
|
61
|
-
const config = await getPrismaConfig({
|
|
62
|
-
datamodel: result.schemas
|
|
63
|
-
});
|
|
59
|
+
const config = await getPrismaConfig({ datamodel: result.schemas });
|
|
64
60
|
switch (config.datasources?.[0]?.provider) {
|
|
65
61
|
case "mysql":
|
|
66
62
|
quoteStyle = "`";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/testing",
|
|
3
|
-
"version": "3.0.0-canary.
|
|
3
|
+
"version": "3.0.0-canary.13597+48d06b4d0",
|
|
4
4
|
"description": "Tools, wrappers and configuration for testing a Cedar project.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -119,13 +119,13 @@
|
|
|
119
119
|
"test:watch": "vitest watch"
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
122
|
-
"@cedarjs/auth": "3.0.0-canary.
|
|
123
|
-
"@cedarjs/babel-config": "3.0.0-canary.
|
|
124
|
-
"@cedarjs/context": "3.0.0-canary.
|
|
125
|
-
"@cedarjs/graphql-server": "3.0.0-canary.
|
|
126
|
-
"@cedarjs/project-config": "3.0.0-canary.
|
|
127
|
-
"@cedarjs/router": "3.0.0-canary.
|
|
128
|
-
"@cedarjs/web": "3.0.0-canary.
|
|
122
|
+
"@cedarjs/auth": "3.0.0-canary.13597",
|
|
123
|
+
"@cedarjs/babel-config": "3.0.0-canary.13597",
|
|
124
|
+
"@cedarjs/context": "3.0.0-canary.13597",
|
|
125
|
+
"@cedarjs/graphql-server": "3.0.0-canary.13597",
|
|
126
|
+
"@cedarjs/project-config": "3.0.0-canary.13597",
|
|
127
|
+
"@cedarjs/router": "3.0.0-canary.13597",
|
|
128
|
+
"@cedarjs/web": "3.0.0-canary.13597",
|
|
129
129
|
"@testing-library/jest-dom": "6.9.1",
|
|
130
130
|
"@testing-library/react": "14.3.1",
|
|
131
131
|
"@testing-library/user-event": "14.6.1",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"whatwg-fetch": "3.6.20"
|
|
146
146
|
},
|
|
147
147
|
"devDependencies": {
|
|
148
|
-
"@cedarjs/framework-tools": "3.0.0-canary.
|
|
148
|
+
"@cedarjs/framework-tools": "3.0.0-canary.13597",
|
|
149
149
|
"concurrently": "9.2.1",
|
|
150
150
|
"jsdom": "27.4.0",
|
|
151
151
|
"publint": "0.3.18",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"publishConfig": {
|
|
165
165
|
"access": "public"
|
|
166
166
|
},
|
|
167
|
-
"gitHead": "
|
|
167
|
+
"gitHead": "48d06b4d0cd4972ec0b019b7fd236ef0e0af1220",
|
|
168
168
|
"nx": {
|
|
169
169
|
"targets": {
|
|
170
170
|
"build": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directUrlHelpers.d.ts","sourceRoot":"","sources":["../../src/api/directUrlHelpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,cAAc,EAAE,MAAM,UAElD;AAED,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,sBA+BlB"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
function getDefaultDb(projectBaseDir) {
|
|
3
|
-
return `file:${path.join(projectBaseDir, ".redwood", "test.db")}`;
|
|
4
|
-
}
|
|
5
|
-
function checkAndReplaceDirectUrl(prismaSchema, defaultDb) {
|
|
6
|
-
const directUrl = prismaSchema.match(PRISMA_DIRECT_URL_REGEXP);
|
|
7
|
-
if (!directUrl) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const directUrlEnvMatch = directUrl[0].match(BETWEEN_PARENTHESES_REGEXP);
|
|
11
|
-
if (!directUrlEnvMatch) {
|
|
12
|
-
throw new Error(
|
|
13
|
-
"Error parsing `directUrl` from schema.prisma. Proceeding with this env var could be dangerous. Please check your schema.prisma file; if everything looks ok, file an issue."
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
const directUrlEnv = directUrlEnvMatch[2];
|
|
17
|
-
process.env[directUrlEnv] = process.env.TEST_DIRECT_URL || process.env.TEST_DATABASE_URL || defaultDb;
|
|
18
|
-
return directUrlEnv;
|
|
19
|
-
}
|
|
20
|
-
const PRISMA_DIRECT_URL_REGEXP = /directUrl(\s*)=(\s*)env\(('|")(.*)('|")\)/g;
|
|
21
|
-
const BETWEEN_PARENTHESES_REGEXP = /\(('|")([^)]+)('|")\)/;
|
|
22
|
-
export {
|
|
23
|
-
checkAndReplaceDirectUrl,
|
|
24
|
-
getDefaultDb
|
|
25
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directUrlHelpers.d.ts","sourceRoot":"","sources":["../../../src/api/directUrlHelpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,cAAc,EAAE,MAAM,UAElD;AAED,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,sBA+BlB"}
|
|
@@ -1,60 +0,0 @@
|
|
|
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 directUrlHelpers_exports = {};
|
|
30
|
-
__export(directUrlHelpers_exports, {
|
|
31
|
-
checkAndReplaceDirectUrl: () => checkAndReplaceDirectUrl,
|
|
32
|
-
getDefaultDb: () => getDefaultDb
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(directUrlHelpers_exports);
|
|
35
|
-
var import_path = __toESM(require("path"), 1);
|
|
36
|
-
function getDefaultDb(projectBaseDir) {
|
|
37
|
-
return `file:${import_path.default.join(projectBaseDir, ".redwood", "test.db")}`;
|
|
38
|
-
}
|
|
39
|
-
function checkAndReplaceDirectUrl(prismaSchema, defaultDb) {
|
|
40
|
-
const directUrl = prismaSchema.match(PRISMA_DIRECT_URL_REGEXP);
|
|
41
|
-
if (!directUrl) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const directUrlEnvMatch = directUrl[0].match(BETWEEN_PARENTHESES_REGEXP);
|
|
45
|
-
if (!directUrlEnvMatch) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
"Error parsing `directUrl` from schema.prisma. Proceeding with this env var could be dangerous. Please check your schema.prisma file; if everything looks ok, file an issue."
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
const directUrlEnv = directUrlEnvMatch[2];
|
|
51
|
-
process.env[directUrlEnv] = process.env.TEST_DIRECT_URL || process.env.TEST_DATABASE_URL || defaultDb;
|
|
52
|
-
return directUrlEnv;
|
|
53
|
-
}
|
|
54
|
-
const PRISMA_DIRECT_URL_REGEXP = /directUrl(\s*)=(\s*)env\(('|")(.*)('|")\)/g;
|
|
55
|
-
const BETWEEN_PARENTHESES_REGEXP = /\(('|")([^)]+)('|")\)/;
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
0 && (module.exports = {
|
|
58
|
-
checkAndReplaceDirectUrl,
|
|
59
|
-
getDefaultDb
|
|
60
|
-
});
|