@cedarjs/cli 8.0.0-canary.3532 → 8.0.0-canary.3536
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/setup/middleware/ogImage/__codemod_tests__/middleware.js +14 -17
- package/dist/commands/setup/middleware/ogImage/__codemod_tests__/vitePlugin.js +5 -8
- package/dist/commands/setup/tenancy/authCodemod.js +4 -1
- package/dist/commands/upgrade/upgradeHandler.js +136 -1
- package/dist/telemetry/resource.js +5 -5
- package/package.json +18 -15
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { describe, it } from "vitest";
|
|
2
|
-
describe
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
);
|
|
2
|
+
describe("Middleware codemod", () => {
|
|
3
|
+
it("Handles the default TSX case", async () => {
|
|
4
|
+
await matchTransformSnapshot("codemodMiddleware", "defaultTsx");
|
|
5
|
+
});
|
|
6
|
+
it("Handles when OgImageMiddleware is already imported", async () => {
|
|
7
|
+
await matchTransformSnapshot("codemodMiddleware", "alreadyContainsImport");
|
|
8
|
+
});
|
|
9
|
+
it("Handles when registerMiddleware function is already defined", async () => {
|
|
10
|
+
await matchTransformSnapshot(
|
|
11
|
+
"codemodMiddleware",
|
|
12
|
+
"registerFunctionAlreadyDefined"
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { describe, it } from "vitest";
|
|
2
|
-
describe
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
);
|
|
2
|
+
describe("Vite plugin codemod", () => {
|
|
3
|
+
it("Handles the default vite config case", async () => {
|
|
4
|
+
await matchTransformSnapshot("codemodVitePlugin", "defaultViteConfig");
|
|
5
|
+
});
|
|
6
|
+
});
|
|
@@ -21,6 +21,7 @@ function buildMembershipsSelectProperty() {
|
|
|
21
21
|
function transform(fileInfo) {
|
|
22
22
|
const root = j.withParser("tsx")(fileInfo.source);
|
|
23
23
|
let selectFound = false;
|
|
24
|
+
let changed = false;
|
|
24
25
|
root.find(j.CallExpression, {
|
|
25
26
|
callee: {
|
|
26
27
|
type: "MemberExpression",
|
|
@@ -47,6 +48,7 @@ function transform(fileInfo) {
|
|
|
47
48
|
);
|
|
48
49
|
if (!alreadyHasMemberships) {
|
|
49
50
|
selectProperty.value.properties.push(buildMembershipsSelectProperty());
|
|
51
|
+
changed = true;
|
|
50
52
|
}
|
|
51
53
|
selectFound = true;
|
|
52
54
|
});
|
|
@@ -72,8 +74,9 @@ function transform(fileInfo) {
|
|
|
72
74
|
root.find(j.Program).forEach((path) => {
|
|
73
75
|
path.node.body.push(tenancyExport);
|
|
74
76
|
});
|
|
77
|
+
changed = true;
|
|
75
78
|
}
|
|
76
|
-
return root.toSource();
|
|
79
|
+
return changed ? root.toSource() : fileInfo.source;
|
|
77
80
|
}
|
|
78
81
|
export {
|
|
79
82
|
transform as default
|
|
@@ -4,6 +4,7 @@ import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
|
4
4
|
import execa from "execa";
|
|
5
5
|
import latestVersion from "latest-version";
|
|
6
6
|
import { Listr } from "listr2";
|
|
7
|
+
import packageJson from "package-json";
|
|
7
8
|
import { terminalLink } from "termi-link";
|
|
8
9
|
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
9
10
|
import {
|
|
@@ -103,6 +104,13 @@ const handler = async (upgradeOptions) => {
|
|
|
103
104
|
// https://github.com/redwoodjs/redwood/pull/8855
|
|
104
105
|
enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") && notBlockedByPreUpgradeChecks(ctx)
|
|
105
106
|
},
|
|
107
|
+
{
|
|
108
|
+
title: "Updating Prisma to the version CedarJS supports",
|
|
109
|
+
// Runs after the canary template sync, so the Prisma versions come
|
|
110
|
+
// from the target release rather than from the template on main
|
|
111
|
+
task: (ctx, task) => updatePrismaDeps(ctx, task, { dryRun, verbose }),
|
|
112
|
+
enabled: (ctx) => !!ctx.versionToUpgradeTo && notBlockedByPreUpgradeChecks(ctx)
|
|
113
|
+
},
|
|
106
114
|
{
|
|
107
115
|
title: "Downloading yarn patches",
|
|
108
116
|
task: (ctx) => downloadYarnPatches(ctx, { dryRun, verbose }),
|
|
@@ -312,6 +320,130 @@ function updateCedarJSDepsForAllSides(ctx, options) {
|
|
|
312
320
|
})
|
|
313
321
|
);
|
|
314
322
|
}
|
|
323
|
+
async function fetchPrismaPeerVersion(cedarVersion) {
|
|
324
|
+
const version = cedarVersion.split("+")[0];
|
|
325
|
+
let manifest;
|
|
326
|
+
try {
|
|
327
|
+
manifest = await packageJson("@cedarjs/cli", { version });
|
|
328
|
+
} catch (e) {
|
|
329
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
330
|
+
throw new Error(
|
|
331
|
+
`Failed to fetch @cedarjs/cli@${version} from the npm registry: ` + message
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
const prismaVersion = manifest.peerDependencies?.["prisma"];
|
|
335
|
+
return typeof prismaVersion === "string" ? prismaVersion : void 0;
|
|
336
|
+
}
|
|
337
|
+
function isPrismaReleasePackage(depName) {
|
|
338
|
+
return depName === "prisma" || depName === "@prisma/client" || depName.startsWith("@prisma/adapter-");
|
|
339
|
+
}
|
|
340
|
+
function updatePrismaDependencies(pkg, prismaVersion, messages, { dryRun, verbose } = {}) {
|
|
341
|
+
let updated = false;
|
|
342
|
+
for (const field of ["dependencies", "devDependencies"]) {
|
|
343
|
+
const deps = pkg[field] ?? {};
|
|
344
|
+
for (const [depName, depVersion] of Object.entries(deps)) {
|
|
345
|
+
if (!isPrismaReleasePackage(depName) || depVersion === prismaVersion) {
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if (verbose || dryRun) {
|
|
349
|
+
messages.push(` - ${depName}: ${depVersion} => ${prismaVersion}`);
|
|
350
|
+
}
|
|
351
|
+
deps[depName] = prismaVersion;
|
|
352
|
+
updated = true;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return updated;
|
|
356
|
+
}
|
|
357
|
+
function addMissingDependency(pkg, field, depName, version, messages, { onlyInField = false } = {}) {
|
|
358
|
+
const otherField = field === "dependencies" ? "devDependencies" : "dependencies";
|
|
359
|
+
if (pkg[field]?.[depName]) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
const otherVersion = pkg[otherField]?.[depName];
|
|
363
|
+
if (otherVersion && !onlyInField) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
if (otherVersion) {
|
|
367
|
+
const { [depName]: _moved, ...otherDeps } = pkg[otherField] ?? {};
|
|
368
|
+
pkg[otherField] = otherDeps;
|
|
369
|
+
messages.push(` - ${depName}: moved from ${otherField} to ${field}`);
|
|
370
|
+
} else {
|
|
371
|
+
messages.push(` - ${depName}: added at ${version}`);
|
|
372
|
+
}
|
|
373
|
+
const deps = { ...pkg[field], [depName]: otherVersion ?? version };
|
|
374
|
+
pkg[field] = Object.fromEntries(
|
|
375
|
+
Object.entries(deps).sort(([a], [b]) => a.localeCompare(b))
|
|
376
|
+
);
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
async function updatePrismaDeps(ctx, task, { dryRun, verbose }) {
|
|
380
|
+
if (!ctx.versionToUpgradeTo) {
|
|
381
|
+
throw new Error("Failed to upgrade");
|
|
382
|
+
}
|
|
383
|
+
const prismaVersion = await fetchPrismaPeerVersion(
|
|
384
|
+
String(ctx.versionToUpgradeTo)
|
|
385
|
+
);
|
|
386
|
+
if (!prismaVersion) {
|
|
387
|
+
task.skip(
|
|
388
|
+
`CedarJS ${ctx.versionToUpgradeTo} doesn't declare a Prisma version`
|
|
389
|
+
);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const messages = [];
|
|
393
|
+
const hasApiSide = fs.existsSync(
|
|
394
|
+
path.join(getPaths().api.base, "package.json")
|
|
395
|
+
);
|
|
396
|
+
const projectPackages = [
|
|
397
|
+
{
|
|
398
|
+
basePath: getPaths().base,
|
|
399
|
+
required: {
|
|
400
|
+
field: "devDependencies",
|
|
401
|
+
depName: "prisma",
|
|
402
|
+
onlyInField: false
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
basePath: getPaths().api.base,
|
|
407
|
+
// The api side imports the generated Prisma client at runtime
|
|
408
|
+
required: {
|
|
409
|
+
field: "dependencies",
|
|
410
|
+
depName: "@prisma/client",
|
|
411
|
+
onlyInField: true
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
];
|
|
415
|
+
for (const { basePath, required } of projectPackages) {
|
|
416
|
+
const pkgJsonPath = path.join(basePath, "package.json");
|
|
417
|
+
if (!fs.existsSync(pkgJsonPath)) {
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
421
|
+
const pkgMessages = [];
|
|
422
|
+
const added = hasApiSide && addMissingDependency(
|
|
423
|
+
pkg,
|
|
424
|
+
required.field,
|
|
425
|
+
required.depName,
|
|
426
|
+
prismaVersion,
|
|
427
|
+
pkgMessages,
|
|
428
|
+
{ onlyInField: required.onlyInField }
|
|
429
|
+
);
|
|
430
|
+
const updated = updatePrismaDependencies(pkg, prismaVersion, pkgMessages, {
|
|
431
|
+
dryRun,
|
|
432
|
+
verbose
|
|
433
|
+
});
|
|
434
|
+
if (added || updated) {
|
|
435
|
+
if (pkgMessages.length > 0) {
|
|
436
|
+
messages.push(`Updating ${pkgJsonPath}`, ...pkgMessages);
|
|
437
|
+
}
|
|
438
|
+
if (!dryRun) {
|
|
439
|
+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkg, void 0, 2));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (messages.length > 0) {
|
|
444
|
+
task.title = task.title + "\n" + messages.join("\n");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
315
447
|
function mergeTemplateDependencies(field, templatePackageJson, localPackageJson, messages, { dryRun, verbose } = {}) {
|
|
316
448
|
const templateDeps = templatePackageJson[field];
|
|
317
449
|
if (!templateDeps) {
|
|
@@ -479,6 +611,9 @@ async function dedupeDeps(_task, { verbose }) {
|
|
|
479
611
|
await packageManagerInstall({ verbose });
|
|
480
612
|
}
|
|
481
613
|
export {
|
|
614
|
+
addMissingDependency,
|
|
615
|
+
fetchPrismaPeerVersion,
|
|
482
616
|
handler,
|
|
483
|
-
mergeTemplateDependencies
|
|
617
|
+
mergeTemplateDependencies,
|
|
618
|
+
updatePrismaDependencies
|
|
484
619
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
|
|
4
5
|
import ci from "ci-info";
|
|
5
6
|
import envinfo from "envinfo";
|
|
6
|
-
import system from "systeminformation";
|
|
7
7
|
import { v4 as uuidv4, validate as validateUUID } from "uuid";
|
|
8
8
|
import { getPaths, getRawConfig } from "@cedarjs/project-config";
|
|
9
9
|
import { RWProject } from "@cedarjs/structure/dist/model/RWProject";
|
|
@@ -47,8 +47,8 @@ async function getResources() {
|
|
|
47
47
|
} else if (shell?.path.match("\\")) {
|
|
48
48
|
info.System.Shell.name = info.System.Shell.path.split("\\").pop();
|
|
49
49
|
}
|
|
50
|
-
const
|
|
51
|
-
const
|
|
50
|
+
const cpuCount = os.availableParallelism();
|
|
51
|
+
const memoryGb = Math.round(os.totalmem() / 1073741824);
|
|
52
52
|
let developmentEnvironment = void 0;
|
|
53
53
|
if (Object.keys(process.env).some((key) => key.startsWith("GITPOD_"))) {
|
|
54
54
|
developmentEnvironment = "gitpod";
|
|
@@ -77,8 +77,8 @@ async function getResources() {
|
|
|
77
77
|
"yarn.version": info.Binaries?.Yarn?.version,
|
|
78
78
|
"npm.version": info.Binaries?.npm?.version,
|
|
79
79
|
"vscode.version": info.IDEs?.VSCode?.version,
|
|
80
|
-
"cpu.count":
|
|
81
|
-
"memory.gb":
|
|
80
|
+
"cpu.count": cpuCount,
|
|
81
|
+
"memory.gb": memoryGb,
|
|
82
82
|
"env.node_env": process.env.NODE_ENV || void 0,
|
|
83
83
|
"ci.redwood": !!process.env.CEDAR_CI,
|
|
84
84
|
"ci.isci": ci.isCI,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "8.0.0-canary.
|
|
3
|
+
"version": "8.0.0-canary.3536",
|
|
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.10",
|
|
38
38
|
"@babel/types": "7.29.8",
|
|
39
|
-
"@cedarjs/api-server": "8.0.0-canary.
|
|
40
|
-
"@cedarjs/babel-config": "8.0.0-canary.
|
|
41
|
-
"@cedarjs/cli-helpers": "8.0.0-canary.
|
|
42
|
-
"@cedarjs/internal": "8.0.0-canary.
|
|
43
|
-
"@cedarjs/prerender": "8.0.0-canary.
|
|
44
|
-
"@cedarjs/project-config": "8.0.0-canary.
|
|
45
|
-
"@cedarjs/structure": "8.0.0-canary.
|
|
46
|
-
"@cedarjs/telemetry": "8.0.0-canary.
|
|
47
|
-
"@cedarjs/utils": "8.0.0-canary.
|
|
48
|
-
"@cedarjs/vite": "8.0.0-canary.
|
|
49
|
-
"@cedarjs/web-server": "8.0.0-canary.
|
|
39
|
+
"@cedarjs/api-server": "8.0.0-canary.3536",
|
|
40
|
+
"@cedarjs/babel-config": "8.0.0-canary.3536",
|
|
41
|
+
"@cedarjs/cli-helpers": "8.0.0-canary.3536",
|
|
42
|
+
"@cedarjs/internal": "8.0.0-canary.3536",
|
|
43
|
+
"@cedarjs/prerender": "8.0.0-canary.3536",
|
|
44
|
+
"@cedarjs/project-config": "8.0.0-canary.3536",
|
|
45
|
+
"@cedarjs/structure": "8.0.0-canary.3536",
|
|
46
|
+
"@cedarjs/telemetry": "8.0.0-canary.3536",
|
|
47
|
+
"@cedarjs/utils": "8.0.0-canary.3536",
|
|
48
|
+
"@cedarjs/vite": "8.0.0-canary.3536",
|
|
49
|
+
"@cedarjs/web-server": "8.0.0-canary.3536",
|
|
50
50
|
"@listr2/prompt-adapter-enquirer": "4.4.3",
|
|
51
51
|
"@opentelemetry/api": "1.9.1",
|
|
52
52
|
"@opentelemetry/core": "2.12.0",
|
|
@@ -76,16 +76,15 @@
|
|
|
76
76
|
"latest-version": "9.0.0",
|
|
77
77
|
"listr2": "10.2.2",
|
|
78
78
|
"lodash": "4.18.1",
|
|
79
|
+
"package-json": "10.0.1",
|
|
79
80
|
"pascalcase": "1.0.0",
|
|
80
81
|
"pluralize": "8.0.0",
|
|
81
82
|
"portfinder": "1.0.38",
|
|
82
83
|
"prettier": "3.9.10",
|
|
83
|
-
"prisma": "7.10.1",
|
|
84
84
|
"prompts": "2.4.2",
|
|
85
85
|
"smol-toml": "1.9.1",
|
|
86
86
|
"srvx": "0.12.8",
|
|
87
87
|
"string-env-interpolation": "1.0.1",
|
|
88
|
-
"systeminformation": "5.33.16",
|
|
89
88
|
"termi-link": "1.1.0",
|
|
90
89
|
"title-case": "3.0.3",
|
|
91
90
|
"unionfs": "4.6.0",
|
|
@@ -94,15 +93,19 @@
|
|
|
94
93
|
"yargs": "18.2.0"
|
|
95
94
|
},
|
|
96
95
|
"devDependencies": {
|
|
97
|
-
"@cedarjs/framework-tools": "8.0.0-canary.
|
|
96
|
+
"@cedarjs/framework-tools": "8.0.0-canary.3536",
|
|
98
97
|
"@prisma/dmmf": "7.10.1",
|
|
99
98
|
"@types/archiver": "^7.0.0",
|
|
100
99
|
"memfs": "4.80.0",
|
|
101
100
|
"node-ssh": "13.2.1",
|
|
101
|
+
"prisma": "7.10.1",
|
|
102
102
|
"ts-dedent": "2.3.0",
|
|
103
103
|
"typescript": "5.9.3",
|
|
104
104
|
"vitest": "4.1.12"
|
|
105
105
|
},
|
|
106
|
+
"peerDependencies": {
|
|
107
|
+
"prisma": "7.10.1"
|
|
108
|
+
},
|
|
106
109
|
"engines": {
|
|
107
110
|
"node": ">=24"
|
|
108
111
|
},
|