@cedarjs/cli 3.0.0-canary.13580 → 3.0.0-canary.13581
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.
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import Enquirer from "enquirer";
|
|
3
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
4
|
+
async function warnIfNonStandardDatasourceUrl({ force } = {}) {
|
|
5
|
+
const cedarPaths = getPaths();
|
|
6
|
+
if (!fs.existsSync(cedarPaths.api.prismaConfig)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const prismaConfig = await fs.promises.readFile(
|
|
10
|
+
cedarPaths.api.prismaConfig,
|
|
11
|
+
"utf-8"
|
|
12
|
+
);
|
|
13
|
+
const prismaConfigLines = prismaConfig.split("\n");
|
|
14
|
+
for (const line of prismaConfigLines) {
|
|
15
|
+
const envVarName = (line.match(
|
|
16
|
+
/^\s*url: process\.env\.(\w+),?(\s*\/\/.*)?$/
|
|
17
|
+
) ?? line.match(/^\s*url: env\(['"](\w+)['"]\),?(\s*\/\/.*)?$/) ?? line.match(/[{,] url: process\.env\.(\w+)(?:,| })/) ?? line.match(/[{,] url: env\(['"](\w+)['"]\)(?:,| })/))?.[1];
|
|
18
|
+
if (envVarName && envVarName !== "DATABASE_URL") {
|
|
19
|
+
if (force) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
console.warn(
|
|
23
|
+
`Found a non-standard prisma config datasource url env var: "${envVarName}".
|
|
24
|
+
Cedar will not override this env var, potentially running destructive commands against your production database.`
|
|
25
|
+
);
|
|
26
|
+
const { proceed } = await Enquirer.prompt({
|
|
27
|
+
type: "confirm",
|
|
28
|
+
name: "proceed",
|
|
29
|
+
message: "Are you sure you want to run tests against this database?",
|
|
30
|
+
initial: false
|
|
31
|
+
});
|
|
32
|
+
if (!proceed) {
|
|
33
|
+
console.log("Aborting.");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
warnIfNonStandardDatasourceUrl
|
|
42
|
+
};
|
|
@@ -4,9 +4,10 @@ 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 "
|
|
8
|
-
import { getPaths } from "
|
|
9
|
-
import * as project from "
|
|
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";
|
|
10
11
|
function hasStringMessage(value) {
|
|
11
12
|
return typeof value === "object" && value !== null && "message" in value && value.message === "string";
|
|
12
13
|
}
|
|
@@ -59,6 +60,7 @@ const handler = async ({
|
|
|
59
60
|
watch = true,
|
|
60
61
|
collectCoverage = false,
|
|
61
62
|
dbPush = true,
|
|
63
|
+
force = false,
|
|
62
64
|
...others
|
|
63
65
|
}) => {
|
|
64
66
|
recordTelemetryAttributes({
|
|
@@ -72,6 +74,7 @@ const handler = async ({
|
|
|
72
74
|
if ([
|
|
73
75
|
"collect-coverage",
|
|
74
76
|
"db-push",
|
|
77
|
+
"force",
|
|
75
78
|
"loadEnvFiles",
|
|
76
79
|
"watch",
|
|
77
80
|
"$0",
|
|
@@ -119,6 +122,9 @@ const handler = async ({
|
|
|
119
122
|
if (sides.includes("api") && !dbPush) {
|
|
120
123
|
process.env.SKIP_DB_PUSH = "1";
|
|
121
124
|
}
|
|
125
|
+
if (sides.includes("api")) {
|
|
126
|
+
await warnIfNonStandardDatasourceUrl({ force });
|
|
127
|
+
}
|
|
122
128
|
const runCommand = async () => {
|
|
123
129
|
await execa("yarn", ["jest", ...jestArgs], {
|
|
124
130
|
cwd: rwjsPaths.base,
|
|
@@ -2,8 +2,9 @@ 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 "
|
|
6
|
-
import * as project from "
|
|
5
|
+
import { getPaths } from "../../lib/index.js";
|
|
6
|
+
import * as project from "../../lib/project.js";
|
|
7
|
+
import { warnIfNonStandardDatasourceUrl } from "./datasourceWarning.js";
|
|
7
8
|
function hasStringMessage(value) {
|
|
8
9
|
return typeof value === "object" && value !== null && "message" in value && value.message === "string";
|
|
9
10
|
}
|
|
@@ -16,6 +17,7 @@ function getExitCode(value) {
|
|
|
16
17
|
const handler = async ({
|
|
17
18
|
filter: filterParams = [],
|
|
18
19
|
dbPush = true,
|
|
20
|
+
force = false,
|
|
19
21
|
...others
|
|
20
22
|
}) => {
|
|
21
23
|
recordTelemetryAttributes({
|
|
@@ -25,7 +27,7 @@ const handler = async ({
|
|
|
25
27
|
let watch = true;
|
|
26
28
|
const rwjsPaths = getPaths();
|
|
27
29
|
const forwardVitestFlags = Object.keys(others).flatMap((flagName) => {
|
|
28
|
-
if (["db-push", "loadEnvFiles", "$0", "_"].includes(flagName)) {
|
|
30
|
+
if (["db-push", "force", "loadEnvFiles", "$0", "_"].includes(flagName)) {
|
|
29
31
|
return [];
|
|
30
32
|
}
|
|
31
33
|
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
@@ -68,6 +70,9 @@ const handler = async ({
|
|
|
68
70
|
if (sides.includes("api") && !dbPush) {
|
|
69
71
|
process.env.SKIP_DB_PUSH = "1";
|
|
70
72
|
}
|
|
73
|
+
if (sides.includes("api")) {
|
|
74
|
+
await warnIfNonStandardDatasourceUrl({ force });
|
|
75
|
+
}
|
|
71
76
|
const runCommand = async () => {
|
|
72
77
|
await execa("yarn", ["vitest", ...vitestArgs], {
|
|
73
78
|
cwd: rwjsPaths.base,
|
package/dist/commands/test.js
CHANGED
|
@@ -21,6 +21,10 @@ 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
|
|
24
28
|
}).epilogue(
|
|
25
29
|
`For all available flags, run jest cli directly ${c.tip(
|
|
26
30
|
"yarn jest --help"
|
|
@@ -34,7 +38,7 @@ Also see the ${terminalLink(
|
|
|
34
38
|
);
|
|
35
39
|
};
|
|
36
40
|
const handler = async (options) => {
|
|
37
|
-
const { handler: handler2 } = await import("./testHandler.js");
|
|
41
|
+
const { handler: handler2 } = await import("./test/testHandler.js");
|
|
38
42
|
return handler2(options);
|
|
39
43
|
};
|
|
40
44
|
export {
|
package/dist/commands/testEsm.js
CHANGED
|
@@ -18,6 +18,10 @@ 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
|
|
21
25
|
}).epilogue(
|
|
22
26
|
`For all available flags, run vitest cli directly ${vitestTip}
|
|
23
27
|
|
|
@@ -26,7 +30,7 @@ Also see the ${cliDocsLink}
|
|
|
26
30
|
);
|
|
27
31
|
};
|
|
28
32
|
const handler = async (options) => {
|
|
29
|
-
const { handler: handler2 } = await import("./testHandlerEsm.js");
|
|
33
|
+
const { handler: handler2 } = await import("./test/testHandlerEsm.js");
|
|
30
34
|
return handler2(options);
|
|
31
35
|
};
|
|
32
36
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "3.0.0-canary.
|
|
3
|
+
"version": "3.0.0-canary.13581+780b26aa3",
|
|
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.
|
|
38
|
-
"@cedarjs/cli-helpers": "3.0.0-canary.
|
|
39
|
-
"@cedarjs/fastify-web": "3.0.0-canary.
|
|
40
|
-
"@cedarjs/internal": "3.0.0-canary.
|
|
41
|
-
"@cedarjs/prerender": "3.0.0-canary.
|
|
42
|
-
"@cedarjs/project-config": "3.0.0-canary.
|
|
43
|
-
"@cedarjs/structure": "3.0.0-canary.
|
|
44
|
-
"@cedarjs/telemetry": "3.0.0-canary.
|
|
45
|
-
"@cedarjs/utils": "3.0.0-canary.
|
|
46
|
-
"@cedarjs/web-server": "3.0.0-canary.
|
|
37
|
+
"@cedarjs/api-server": "3.0.0-canary.13581",
|
|
38
|
+
"@cedarjs/cli-helpers": "3.0.0-canary.13581",
|
|
39
|
+
"@cedarjs/fastify-web": "3.0.0-canary.13581",
|
|
40
|
+
"@cedarjs/internal": "3.0.0-canary.13581",
|
|
41
|
+
"@cedarjs/prerender": "3.0.0-canary.13581",
|
|
42
|
+
"@cedarjs/project-config": "3.0.0-canary.13581",
|
|
43
|
+
"@cedarjs/structure": "3.0.0-canary.13581",
|
|
44
|
+
"@cedarjs/telemetry": "3.0.0-canary.13581",
|
|
45
|
+
"@cedarjs/utils": "3.0.0-canary.13581",
|
|
46
|
+
"@cedarjs/web-server": "3.0.0-canary.13581",
|
|
47
47
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
48
48
|
"@opentelemetry/api": "1.9.0",
|
|
49
49
|
"@opentelemetry/core": "1.30.1",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"publishConfig": {
|
|
108
108
|
"access": "public"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "780b26aa33b971df661e9d0850f4eaa8302f90a3"
|
|
111
111
|
}
|