@cedarjs/cli 7.0.0-canary.3093 → 7.0.0-canary.3094
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.
|
@@ -5,6 +5,7 @@ import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
|
|
|
5
5
|
import { getPaths } from "../../lib/index.js";
|
|
6
6
|
import * as project from "../../lib/project.js";
|
|
7
7
|
import { warnIfNonStandardDatasourceUrl } from "./datasourceWarning.js";
|
|
8
|
+
import { assertSingleViteVersion } from "./viteVersionCheck.js";
|
|
8
9
|
function hasStringMessage(value) {
|
|
9
10
|
return typeof value === "object" && value !== null && "message" in value && value.message === "string";
|
|
10
11
|
}
|
|
@@ -75,6 +76,9 @@ const handler = async ({
|
|
|
75
76
|
if (sides.includes("api")) {
|
|
76
77
|
await warnIfNonStandardDatasourceUrl({ force });
|
|
77
78
|
}
|
|
79
|
+
if (sides.includes("web")) {
|
|
80
|
+
assertSingleViteVersion();
|
|
81
|
+
}
|
|
78
82
|
const runCommand = async () => {
|
|
79
83
|
await runBin("vitest", vitestArgs, {
|
|
80
84
|
cwd: rwjsPaths.base,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
5
|
+
function resolvePackage(fromFile, packageName) {
|
|
6
|
+
try {
|
|
7
|
+
const require2 = createRequire(fromFile);
|
|
8
|
+
const packageJsonPath = require2.resolve(`${packageName}/package.json`);
|
|
9
|
+
const packageJson = JSON.parse(
|
|
10
|
+
fs.readFileSync(packageJsonPath, "utf-8")
|
|
11
|
+
);
|
|
12
|
+
if (typeof packageJson !== "object" || packageJson === null || !("version" in packageJson) || typeof packageJson.version !== "string") {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
version: packageJson.version,
|
|
17
|
+
dir: path.dirname(packageJsonPath)
|
|
18
|
+
};
|
|
19
|
+
} catch {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function resolveViteVersions({
|
|
24
|
+
projectBase,
|
|
25
|
+
webBase
|
|
26
|
+
}) {
|
|
27
|
+
const vitest = resolvePackage(
|
|
28
|
+
path.join(projectBase, "package.json"),
|
|
29
|
+
"vitest"
|
|
30
|
+
);
|
|
31
|
+
const vitestVite = vitest ? resolvePackage(path.join(vitest.dir, "package.json"), "vite") : void 0;
|
|
32
|
+
const cedarVite = resolvePackage(
|
|
33
|
+
path.join(webBase, "package.json"),
|
|
34
|
+
"@cedarjs/vite"
|
|
35
|
+
);
|
|
36
|
+
const frameworkVite = cedarVite ? resolvePackage(path.join(cedarVite.dir, "package.json"), "vite") : void 0;
|
|
37
|
+
return { vitestVite, frameworkVite };
|
|
38
|
+
}
|
|
39
|
+
function getViteVersionMismatchMessage({
|
|
40
|
+
vitestVite,
|
|
41
|
+
frameworkVite
|
|
42
|
+
}) {
|
|
43
|
+
if (!vitestVite || !frameworkVite) {
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
if (vitestVite.version === frameworkVite.version) {
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
return `Vitest is using Vite ${vitestVite.version} from
|
|
50
|
+
${vitestVite.dir}
|
|
51
|
+
but CedarJS is built against Vite ${frameworkVite.version} from
|
|
52
|
+
${frameworkVite.dir}
|
|
53
|
+
|
|
54
|
+
The CedarJS Vite plugins only work with the Vite version they're built against, so web tests can't run while Vitest uses a different copy. This happens when the project doesn't pin \`vite\`, because Vitest accepts a wide range of Vite versions and installs the newest one.
|
|
55
|
+
|
|
56
|
+
Please add an override/resolution that pins vite to ${frameworkVite.version}, then reinstall your dependencies.`;
|
|
57
|
+
}
|
|
58
|
+
function assertSingleViteVersion() {
|
|
59
|
+
const cedarPaths = getPaths();
|
|
60
|
+
const message = getViteVersionMismatchMessage(
|
|
61
|
+
resolveViteVersions({
|
|
62
|
+
projectBase: cedarPaths.base,
|
|
63
|
+
webBase: cedarPaths.web.base
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
if (message) {
|
|
67
|
+
console.error(message);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
assertSingleViteVersion,
|
|
73
|
+
getViteVersionMismatchMessage,
|
|
74
|
+
resolveViteVersions
|
|
75
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "7.0.0-canary.
|
|
3
|
+
"version": "7.0.0-canary.3094",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"@babel/preset-typescript": "7.29.7",
|
|
37
37
|
"@babel/traverse": "7.29.8",
|
|
38
38
|
"@babel/types": "7.29.8",
|
|
39
|
-
"@cedarjs/api-server": "7.0.0-canary.
|
|
40
|
-
"@cedarjs/babel-config": "7.0.0-canary.
|
|
41
|
-
"@cedarjs/cli-helpers": "7.0.0-canary.
|
|
42
|
-
"@cedarjs/internal": "7.0.0-canary.
|
|
43
|
-
"@cedarjs/prerender": "7.0.0-canary.
|
|
44
|
-
"@cedarjs/project-config": "7.0.0-canary.
|
|
45
|
-
"@cedarjs/structure": "7.0.0-canary.
|
|
46
|
-
"@cedarjs/telemetry": "7.0.0-canary.
|
|
47
|
-
"@cedarjs/utils": "7.0.0-canary.
|
|
48
|
-
"@cedarjs/vite": "7.0.0-canary.
|
|
49
|
-
"@cedarjs/web-server": "7.0.0-canary.
|
|
39
|
+
"@cedarjs/api-server": "7.0.0-canary.3094",
|
|
40
|
+
"@cedarjs/babel-config": "7.0.0-canary.3094",
|
|
41
|
+
"@cedarjs/cli-helpers": "7.0.0-canary.3094",
|
|
42
|
+
"@cedarjs/internal": "7.0.0-canary.3094",
|
|
43
|
+
"@cedarjs/prerender": "7.0.0-canary.3094",
|
|
44
|
+
"@cedarjs/project-config": "7.0.0-canary.3094",
|
|
45
|
+
"@cedarjs/structure": "7.0.0-canary.3094",
|
|
46
|
+
"@cedarjs/telemetry": "7.0.0-canary.3094",
|
|
47
|
+
"@cedarjs/utils": "7.0.0-canary.3094",
|
|
48
|
+
"@cedarjs/vite": "7.0.0-canary.3094",
|
|
49
|
+
"@cedarjs/web-server": "7.0.0-canary.3094",
|
|
50
50
|
"@listr2/prompt-adapter-enquirer": "4.3.1",
|
|
51
51
|
"@opentelemetry/api": "1.9.1",
|
|
52
52
|
"@opentelemetry/core": "1.30.1",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"yargs": "17.7.3"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@cedarjs/framework-tools": "7.0.0-canary.
|
|
97
|
+
"@cedarjs/framework-tools": "7.0.0-canary.3094",
|
|
98
98
|
"@prisma/dmmf": "7.10.0",
|
|
99
99
|
"@types/archiver": "^7.0.0",
|
|
100
100
|
"memfs": "4.68.2",
|