@cedarjs/cli 1.0.0-canary.12573 → 1.0.0-canary.12575
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/commands/testEsm.js +36 -0
- package/dist/commands/testHandlerEsm.js +86 -0
- package/dist/index.js +3 -1
- package/package.json +11 -11
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { terminalLink } from "termi-link";
|
|
2
|
+
import c from "../lib/colors.js";
|
|
3
|
+
import { sides } from "../lib/project.js";
|
|
4
|
+
const command = "test [filter..]";
|
|
5
|
+
const description = "Run Vitest tests. Defaults to watch mode";
|
|
6
|
+
const builder = (yargs) => {
|
|
7
|
+
const cliDocsLink = terminalLink(
|
|
8
|
+
"CedarJS CLI Reference",
|
|
9
|
+
"https://cedarjs.com/docs/cli-commands#test"
|
|
10
|
+
);
|
|
11
|
+
const vitestTip = c.tip("yarn vitest --help");
|
|
12
|
+
yargs.strict(false).positional("filter", {
|
|
13
|
+
default: sides(),
|
|
14
|
+
description: "Which side(s) to test, and/or a regular expression to match against your test files to filter by",
|
|
15
|
+
type: "array"
|
|
16
|
+
}).option("db-push", {
|
|
17
|
+
describe: "Syncs the test database with your Prisma schema without requiring a migration. It creates a test database if it doesn't already exist.",
|
|
18
|
+
type: "boolean",
|
|
19
|
+
default: true
|
|
20
|
+
}).epilogue(
|
|
21
|
+
`For all available flags, run vitest cli directly ${vitestTip}
|
|
22
|
+
|
|
23
|
+
Also see the ${cliDocsLink}
|
|
24
|
+
`
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
const handler = async (options) => {
|
|
28
|
+
const { handler: handler2 } = await import("./testHandlerEsm.js");
|
|
29
|
+
return handler2(options);
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
builder,
|
|
33
|
+
command,
|
|
34
|
+
description,
|
|
35
|
+
handler
|
|
36
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import execa from "execa";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
3
|
+
import { ensurePosixPath } from "@cedarjs/project-config";
|
|
4
|
+
import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
|
|
5
|
+
import { getPaths } from "../lib/index.js";
|
|
6
|
+
import * as project from "../lib/project.js";
|
|
7
|
+
const handler = async ({
|
|
8
|
+
filter: filterParams = [],
|
|
9
|
+
dbPush = true,
|
|
10
|
+
...others
|
|
11
|
+
}) => {
|
|
12
|
+
recordTelemetryAttributes({
|
|
13
|
+
command: "test",
|
|
14
|
+
dbPush
|
|
15
|
+
});
|
|
16
|
+
let watch = true;
|
|
17
|
+
const rwjsPaths = getPaths();
|
|
18
|
+
const forwardVitestFlags = Object.keys(others).flatMap((flagName) => {
|
|
19
|
+
if (["db-push", "loadEnvFiles", "$0", "_"].includes(flagName)) {
|
|
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
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const sides = filterParams.filter(
|
|
37
|
+
(filterString) => project.sides().includes(filterString)
|
|
38
|
+
);
|
|
39
|
+
const vitestFilterArgs = [
|
|
40
|
+
...filterParams.filter(
|
|
41
|
+
(filterString) => !project.sides().includes(filterString)
|
|
42
|
+
)
|
|
43
|
+
];
|
|
44
|
+
const vitestArgs = [
|
|
45
|
+
...vitestFilterArgs,
|
|
46
|
+
...forwardVitestFlags,
|
|
47
|
+
"--passWithNoTests"
|
|
48
|
+
].filter((flagOrValue) => flagOrValue !== null);
|
|
49
|
+
if (process.env.CI) {
|
|
50
|
+
vitestArgs.push("--run");
|
|
51
|
+
}
|
|
52
|
+
if (!sides.length) {
|
|
53
|
+
project.sides().forEach((side) => sides.push(side));
|
|
54
|
+
}
|
|
55
|
+
sides.forEach((side) => vitestArgs.push("--project", side));
|
|
56
|
+
try {
|
|
57
|
+
const cacheDirDb = `file:${ensurePosixPath(
|
|
58
|
+
rwjsPaths.generated.base
|
|
59
|
+
)}/test.db`;
|
|
60
|
+
const DATABASE_URL = process.env.TEST_DATABASE_URL || cacheDirDb;
|
|
61
|
+
if (sides.includes("api") && !dbPush) {
|
|
62
|
+
process.env.SKIP_DB_PUSH = "1";
|
|
63
|
+
}
|
|
64
|
+
const runCommand = async () => {
|
|
65
|
+
await execa("yarn vitest", vitestArgs, {
|
|
66
|
+
cwd: rwjsPaths.base,
|
|
67
|
+
shell: true,
|
|
68
|
+
stdio: "inherit",
|
|
69
|
+
env: { DATABASE_URL }
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
if (watch) {
|
|
73
|
+
await runCommand();
|
|
74
|
+
} else {
|
|
75
|
+
await timedTelemetry(process.argv, { type: "test" }, async () => {
|
|
76
|
+
await runCommand();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
} catch (e) {
|
|
80
|
+
errorTelemetry(process.argv, e.message);
|
|
81
|
+
process.exit(e?.exitCode || 1);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
handler
|
|
86
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import fs from "fs-extra";
|
|
|
5
5
|
import { hideBin, Parser } from "yargs/helpers";
|
|
6
6
|
import yargs from "yargs/yargs";
|
|
7
7
|
import { loadEnvFiles, recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
8
|
+
import { projectIsEsm } from "@cedarjs/project-config";
|
|
8
9
|
import { telemetryMiddleware } from "@cedarjs/telemetry";
|
|
9
10
|
import * as buildCommand from "./commands/build.js";
|
|
10
11
|
import * as checkCommand from "./commands/check.js";
|
|
@@ -25,6 +26,7 @@ import * as serveCommand from "./commands/serve.js";
|
|
|
25
26
|
import * as setupCommand from "./commands/setup.js";
|
|
26
27
|
import * as studioCommand from "./commands/studio.js";
|
|
27
28
|
import * as testCommand from "./commands/test.js";
|
|
29
|
+
import * as testCommandEsm from "./commands/testEsm.js";
|
|
28
30
|
import * as tstojsCommand from "./commands/ts-to-js.js";
|
|
29
31
|
import * as typeCheckCommand from "./commands/type-check.js";
|
|
30
32
|
import * as upgradeCommand from "./commands/upgrade.js";
|
|
@@ -126,7 +128,7 @@ async function runYargs() {
|
|
|
126
128
|
}).example(
|
|
127
129
|
"yarn rw g page home /",
|
|
128
130
|
"Create a page component named 'Home' at path '/'"
|
|
129
|
-
).demandCommand().strict().exitProcess(false).alias("h", "help").command(buildCommand).command(checkCommand).command(consoleCommand).command(deployCommand).command(destroyCommand).command(devCommand).command(execCommand).command(experimentalCommand).command(generateCommand).command(infoCommand).command(jobsCommand).command(lintCommand).command(prerenderCommand).command(prismaCommand).command(recordCommand).command(serveCommand).command(setupCommand).command(studioCommand).command(testCommand).command(tstojsCommand).command(typeCheckCommand).command(upgradeCommand);
|
|
131
|
+
).demandCommand().strict().exitProcess(false).alias("h", "help").command(buildCommand).command(checkCommand).command(consoleCommand).command(deployCommand).command(destroyCommand).command(devCommand).command(execCommand).command(experimentalCommand).command(generateCommand).command(infoCommand).command(jobsCommand).command(lintCommand).command(prerenderCommand).command(prismaCommand).command(recordCommand).command(serveCommand).command(setupCommand).command(studioCommand).command(projectIsEsm() ? testCommandEsm : testCommand).command(tstojsCommand).command(typeCheckCommand).command(upgradeCommand);
|
|
130
132
|
await loadPlugins(yarg);
|
|
131
133
|
const pkgJson = await import("../package.json", { with: { type: "json" } });
|
|
132
134
|
yarg.version(pkgJson.default["version"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.12575+832c57eba",
|
|
4
4
|
"description": "The Redwood Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/preset-typescript": "7.27.1",
|
|
34
34
|
"@babel/runtime-corejs3": "7.27.6",
|
|
35
|
-
"@cedarjs/api-server": "1.0.0-canary.
|
|
36
|
-
"@cedarjs/cli-helpers": "1.0.0-canary.
|
|
37
|
-
"@cedarjs/fastify-web": "1.0.0-canary.
|
|
38
|
-
"@cedarjs/internal": "1.0.0-canary.
|
|
39
|
-
"@cedarjs/prerender": "1.0.0-canary.
|
|
40
|
-
"@cedarjs/project-config": "1.0.0-canary.
|
|
41
|
-
"@cedarjs/structure": "1.0.0-canary.
|
|
42
|
-
"@cedarjs/telemetry": "1.0.0-canary.
|
|
43
|
-
"@cedarjs/web-server": "1.0.0-canary.
|
|
35
|
+
"@cedarjs/api-server": "1.0.0-canary.12575",
|
|
36
|
+
"@cedarjs/cli-helpers": "1.0.0-canary.12575",
|
|
37
|
+
"@cedarjs/fastify-web": "1.0.0-canary.12575",
|
|
38
|
+
"@cedarjs/internal": "1.0.0-canary.12575",
|
|
39
|
+
"@cedarjs/prerender": "1.0.0-canary.12575",
|
|
40
|
+
"@cedarjs/project-config": "1.0.0-canary.12575",
|
|
41
|
+
"@cedarjs/structure": "1.0.0-canary.12575",
|
|
42
|
+
"@cedarjs/telemetry": "1.0.0-canary.12575",
|
|
43
|
+
"@cedarjs/web-server": "1.0.0-canary.12575",
|
|
44
44
|
"@listr2/prompt-adapter-enquirer": "2.0.16",
|
|
45
45
|
"@opentelemetry/api": "1.8.0",
|
|
46
46
|
"@opentelemetry/core": "1.22.0",
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"typescript": "5.6.2",
|
|
100
100
|
"vitest": "3.2.4"
|
|
101
101
|
},
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "832c57ebae13fea9a54bc49589b7fa26d3b71fb7"
|
|
103
103
|
}
|