@cedarjs/cli 6.0.0-rc.312 → 6.0.0-rc.340

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.
@@ -83,7 +83,7 @@ const handler = async ({ force }) => {
83
83
  if (transformResult.error) {
84
84
  if (transformResult.error === "RW_CODEMOD_ERR_OLD_FORMAT") {
85
85
  throw new Error(
86
- "It looks like your src/lib/db file is using the old format. Please update it as per the v8 upgrade guide: https://cedarjs.com/docs/upgrade-guides/v8#database-file-structure-change. And run again. \n\nYou can also manually modify your api/src/lib/db to include the prisma extension: https://cedarjs.com/docs/uploads/#attaching-the-prisma-extension"
86
+ "It looks like your src/lib/db file is using the old format. Please update it as per the v8 upgrade guide: https://cedarjs.com/docs/8.x/upgrade-guides/v8#database-file-structure-change. And run again. \n\nYou can also manually modify your api/src/lib/db to include the prisma extension: https://cedarjs.com/docs/uploads/#attaching-the-prisma-extension"
87
87
  );
88
88
  }
89
89
  throw new Error(
@@ -4,6 +4,7 @@ import os from "node:os";
4
4
  import path from "node:path";
5
5
  import execa from "execa";
6
6
  import semver from "semver";
7
+ const MAIN_BRANCH_PRERELEASE_TAGS = ["canary"];
7
8
  function isExecaError(e) {
8
9
  return e instanceof Error && ("stdout" in e || "stderr" in e || "exitCode" in e);
9
10
  }
@@ -33,8 +34,15 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
33
34
  if (!Array.isArray(manifest) || manifest.length === 0) {
34
35
  return;
35
36
  }
37
+ const prereleaseTag = parsed?.prerelease[0];
38
+ const isMainBranchPrerelease = typeof prereleaseTag === "string" && MAIN_BRANCH_PRERELEASE_TAGS.includes(prereleaseTag);
36
39
  const checkLevels = [];
37
- if (parsed && !parsed.prerelease.length) {
40
+ if (parsed && isMainBranchPrerelease) {
41
+ checkLevels.push({
42
+ id: "tag",
43
+ candidates: [`${prereleaseTag}.ts`, `${prereleaseTag}/index.ts`]
44
+ });
45
+ } else if (parsed) {
38
46
  checkLevels.push({
39
47
  id: "exact",
40
48
  candidates: [`${version}.ts`, `${version}/index.ts`]
@@ -50,14 +58,6 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
50
58
  id: "minor",
51
59
  candidates: [`${parsed.major}.x.ts`, `${parsed.major}.x/index.ts`]
52
60
  });
53
- } else if (parsed && parsed.prerelease.length > 0) {
54
- checkLevels.push({
55
- id: "tag",
56
- candidates: [
57
- `${parsed.prerelease[0]}.ts`,
58
- `${parsed.prerelease[0]}/index.ts`
59
- ]
60
- });
61
61
  }
62
62
  const scriptsToRun = [];
63
63
  for (const level of checkLevels) {
@@ -33,6 +33,7 @@ const handler = async (upgradeOptions) => {
33
33
  });
34
34
  let preUpgradeMessage = "";
35
35
  let preUpgradeError = "";
36
+ const notBlockedByPreUpgradeChecks = (ctx) => force || !ctx.preUpgradeError;
36
37
  const tasks = new Listr(
37
38
  [
38
39
  {
@@ -87,39 +88,46 @@ const handler = async (upgradeOptions) => {
87
88
  {
88
89
  title: "Updating your CedarJS version",
89
90
  task: (ctx) => updateCedarJSDepsForAllSides(ctx, { dryRun, verbose }),
90
- enabled: (ctx) => !!ctx.versionToUpgradeTo && !ctx.preUpgradeError
91
+ enabled: (ctx) => !!ctx.versionToUpgradeTo && notBlockedByPreUpgradeChecks(ctx)
91
92
  },
92
93
  {
93
94
  title: "Updating other packages in your package.json(s)",
94
95
  task: (ctx) => updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }),
95
- enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") && !ctx.preUpgradeError
96
+ // Canary only. This forces the template's dependency versions onto the
97
+ // project and adds back any the project is missing, which resurrects
98
+ // packages people have deliberately removed — a project that moved off
99
+ // SQLite gets better-sqlite3 back, for example. That's too blunt for
100
+ // regular upgrades, but people running canary are already signed up
101
+ // for rougher edges.
102
+ // https://github.com/redwoodjs/redwood/pull/8855
103
+ enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") && notBlockedByPreUpgradeChecks(ctx)
96
104
  },
97
105
  {
98
106
  title: "Downloading yarn patches",
99
107
  task: (ctx) => downloadYarnPatches(ctx, { dryRun, verbose }),
100
- enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") && !ctx.preUpgradeError
108
+ enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") && notBlockedByPreUpgradeChecks(ctx)
101
109
  },
102
110
  {
103
111
  title: "Removing CLI cache",
104
112
  task: () => removeCliCache({ dryRun, verbose }),
105
- enabled: (ctx) => !ctx.preUpgradeError
113
+ enabled: (ctx) => notBlockedByPreUpgradeChecks(ctx)
106
114
  },
107
115
  {
108
116
  title: `Running ${getPackageManager()} ${install()}`,
109
117
  task: () => packageManagerInstall({ verbose }),
110
- enabled: (ctx) => !ctx.preUpgradeError,
118
+ enabled: (ctx) => notBlockedByPreUpgradeChecks(ctx),
111
119
  skip: () => !!dryRun
112
120
  },
113
121
  {
114
122
  title: "Refreshing the Prisma client",
115
123
  task: (_ctx, task) => refreshPrismaClient(task, { verbose }),
116
- enabled: (ctx) => !ctx.preUpgradeError,
124
+ enabled: (ctx) => notBlockedByPreUpgradeChecks(ctx),
117
125
  skip: () => !!dryRun
118
126
  },
119
127
  {
120
128
  title: "De-duplicating dependencies",
121
129
  skip: () => !!dryRun || !dedupe2,
122
- enabled: (ctx) => dedupeIsSupported() && !ctx.preUpgradeError,
130
+ enabled: (ctx) => dedupeIsSupported() && notBlockedByPreUpgradeChecks(ctx),
123
131
  task: (_ctx, task) => dedupeDeps(task, { verbose })
124
132
  },
125
133
  {
@@ -303,6 +311,22 @@ function updateCedarJSDepsForAllSides(ctx, options) {
303
311
  })
304
312
  );
305
313
  }
314
+ function mergeTemplateDependencies(field, templatePackageJson, localPackageJson, messages, { dryRun, verbose } = {}) {
315
+ const templateDeps = templatePackageJson[field];
316
+ if (!templateDeps) {
317
+ return;
318
+ }
319
+ for (const [depName, depVersion] of Object.entries(templateDeps)) {
320
+ if (depName.startsWith("@cedarjs/")) {
321
+ continue;
322
+ }
323
+ const localDeps = localPackageJson[field] ??= {};
324
+ if (verbose || dryRun) {
325
+ messages.push(` - ${depName}: ${localDeps[depName]} => ${depVersion}`);
326
+ }
327
+ localDeps[depName] = depVersion;
328
+ }
329
+ }
306
330
  async function updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }) {
307
331
  if (!ctx.versionToUpgradeTo) {
308
332
  throw new Error("Failed to upgrade");
@@ -338,30 +362,15 @@ async function updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }) {
338
362
  const localPackageJsonText = fs.readFileSync(pkgJsonPath, "utf-8");
339
363
  const localPackageJson = JSON.parse(localPackageJsonText);
340
364
  const messages = [];
341
- Object.entries(templatePackageJson.dependencies || {}).forEach(
342
- ([depName, depVersion]) => {
343
- if (!depName.startsWith("@cedarjs/")) {
344
- if (verbose || dryRun) {
345
- messages.push(
346
- ` - ${depName}: ${localPackageJson.dependencies[depName]} => ${depVersion}`
347
- );
348
- }
349
- localPackageJson.dependencies[depName] = depVersion;
350
- }
351
- }
352
- );
353
- Object.entries(templatePackageJson.devDependencies || {}).forEach(
354
- ([depName, depVersion]) => {
355
- if (!depName.startsWith("@cedarjs/")) {
356
- if (verbose || dryRun) {
357
- messages.push(
358
- ` - ${depName}: ${localPackageJson.devDependencies[depName]} => ${depVersion}`
359
- );
360
- }
361
- localPackageJson.devDependencies[depName] = depVersion;
362
- }
363
- }
364
- );
365
+ for (const field of ["dependencies", "devDependencies"]) {
366
+ mergeTemplateDependencies(
367
+ field,
368
+ templatePackageJson,
369
+ localPackageJson,
370
+ messages,
371
+ { dryRun, verbose }
372
+ );
373
+ }
365
374
  if (messages.length > 0) {
366
375
  task.title = task.title + "\n" + messages.join("\n");
367
376
  }
@@ -469,5 +478,6 @@ async function dedupeDeps(_task, { verbose }) {
469
478
  await packageManagerInstall({ verbose });
470
479
  }
471
480
  export {
472
- handler
481
+ handler,
482
+ mergeTemplateDependencies
473
483
  };
@@ -3,6 +3,23 @@ import fs from "node:fs";
3
3
  import os from "os";
4
4
  import path from "path";
5
5
  import { getPaths } from "@cedarjs/project-config";
6
+ function quoteForWindowsShell(arg) {
7
+ let quoted = '"';
8
+ let backslashes = 0;
9
+ for (const char of arg) {
10
+ if (char === "\\") {
11
+ backslashes += 1;
12
+ continue;
13
+ }
14
+ if (char === '"') {
15
+ quoted += "\\".repeat(backslashes * 2 + 1) + '"';
16
+ } else {
17
+ quoted += "\\".repeat(backslashes) + char;
18
+ }
19
+ backslashes = 0;
20
+ }
21
+ return quoted + "\\".repeat(backslashes * 2) + '"';
22
+ }
6
23
  function spawnBackgroundProcess(name, cmd, args) {
7
24
  const logDirectory = path.join(getPaths().generated.base, "logs");
8
25
  fs.mkdirSync(logDirectory, { recursive: true });
@@ -37,7 +54,8 @@ function spawnBackgroundProcess(name, cmd, args) {
37
54
  shell: true,
38
55
  stdio: ["ignore", stdout, stderr]
39
56
  };
40
- const child = spawn(cmd + " " + args.join(" "), spawnOptions);
57
+ const command = [cmd, ...args].map(quoteForWindowsShell).join(" ");
58
+ const child = spawn(command, spawnOptions);
41
59
  child.unref();
42
60
  } else {
43
61
  const spawnOptions = {
@@ -51,5 +69,6 @@ function spawnBackgroundProcess(name, cmd, args) {
51
69
  fs.closeSync(stderr);
52
70
  }
53
71
  export {
72
+ quoteForWindowsShell,
54
73
  spawnBackgroundProcess
55
74
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "6.0.0-rc.312",
3
+ "version": "6.0.0-rc.340",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,21 +32,21 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@babel/core": "^7.26.10",
35
- "@babel/parser": "7.29.7",
35
+ "@babel/parser": "7.29.8",
36
36
  "@babel/preset-typescript": "7.29.7",
37
- "@babel/traverse": "7.29.7",
38
- "@babel/types": "7.29.7",
39
- "@cedarjs/api-server": "6.0.0-rc.312",
40
- "@cedarjs/babel-config": "6.0.0-rc.312",
41
- "@cedarjs/cli-helpers": "6.0.0-rc.312",
42
- "@cedarjs/internal": "6.0.0-rc.312",
43
- "@cedarjs/prerender": "6.0.0-rc.312",
44
- "@cedarjs/project-config": "6.0.0-rc.312",
45
- "@cedarjs/structure": "6.0.0-rc.312",
46
- "@cedarjs/telemetry": "6.0.0-rc.312",
47
- "@cedarjs/utils": "6.0.0-rc.312",
48
- "@cedarjs/vite": "6.0.0-rc.312",
49
- "@cedarjs/web-server": "6.0.0-rc.312",
37
+ "@babel/traverse": "7.29.8",
38
+ "@babel/types": "7.29.8",
39
+ "@cedarjs/api-server": "6.0.0-rc.340",
40
+ "@cedarjs/babel-config": "6.0.0-rc.340",
41
+ "@cedarjs/cli-helpers": "6.0.0-rc.340",
42
+ "@cedarjs/internal": "6.0.0-rc.340",
43
+ "@cedarjs/prerender": "6.0.0-rc.340",
44
+ "@cedarjs/project-config": "6.0.0-rc.340",
45
+ "@cedarjs/structure": "6.0.0-rc.340",
46
+ "@cedarjs/telemetry": "6.0.0-rc.340",
47
+ "@cedarjs/utils": "6.0.0-rc.340",
48
+ "@cedarjs/vite": "6.0.0-rc.340",
49
+ "@cedarjs/web-server": "6.0.0-rc.340",
50
50
  "@listr2/prompt-adapter-enquirer": "4.3.0",
51
51
  "@opentelemetry/api": "1.9.1",
52
52
  "@opentelemetry/core": "1.30.1",
@@ -86,7 +86,7 @@
86
86
  "smol-toml": "1.8.0",
87
87
  "srvx": "0.12.5",
88
88
  "string-env-interpolation": "1.0.1",
89
- "systeminformation": "5.31.7",
89
+ "systeminformation": "5.33.1",
90
90
  "termi-link": "1.1.0",
91
91
  "title-case": "3.0.3",
92
92
  "unionfs": "4.6.0",
@@ -94,7 +94,7 @@
94
94
  "yargs": "17.7.3"
95
95
  },
96
96
  "devDependencies": {
97
- "@cedarjs/framework-tools": "6.0.0-rc.312",
97
+ "@cedarjs/framework-tools": "6.0.0-rc.340",
98
98
  "@prisma/dmmf": "7.8.0",
99
99
  "@types/archiver": "^7.0.0",
100
100
  "memfs": "4.68.1",