@cedarjs/cli 1.0.0-canary.13080 → 1.0.0-canary.13083

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.
@@ -78,15 +78,25 @@ const validateTag = (tag) => {
78
78
  }
79
79
  return tag;
80
80
  };
81
- const handler = async ({ dryRun, tag, verbose, dedupe, yes, force }) => {
81
+ function isExecaError(e) {
82
+ return e instanceof Error && ("stdout" in e || "stderr" in e || "exitCode" in e);
83
+ }
84
+ const handler = async ({
85
+ dryRun,
86
+ tag,
87
+ verbose,
88
+ dedupe,
89
+ yes,
90
+ force
91
+ }) => {
82
92
  recordTelemetryAttributes({
83
93
  command: "upgrade",
84
- dryRun,
85
- tag,
86
- verbose,
87
- dedupe,
88
- yes,
89
- force
94
+ dryRun: !!dryRun,
95
+ tag: tag ?? "latest",
96
+ verbose: !!verbose,
97
+ dedupe: !!dedupe,
98
+ yes: !!yes,
99
+ force: !!force
90
100
  });
91
101
  let preUpgradeMessage = "";
92
102
  let preUpgradeError = "";
@@ -133,10 +143,10 @@ const handler = async ({ dryRun, tag, verbose, dedupe, yes, force }) => {
133
143
  task: async (ctx, task) => {
134
144
  await runPreUpgradeScripts(ctx, task, { verbose, force });
135
145
  if (ctx.preUpgradeMessage) {
136
- preUpgradeMessage = ctx.preUpgradeMessage;
146
+ preUpgradeMessage = String(ctx.preUpgradeMessage);
137
147
  }
138
148
  if (ctx.preUpgradeError) {
139
- preUpgradeError = ctx.preUpgradeError;
149
+ preUpgradeError = String(ctx.preUpgradeError);
140
150
  }
141
151
  },
142
152
  enabled: (ctx) => !!ctx.versionToUpgradeTo
@@ -149,33 +159,33 @@ const handler = async ({ dryRun, tag, verbose, dedupe, yes, force }) => {
149
159
  {
150
160
  title: "Updating other packages in your package.json(s)",
151
161
  task: (ctx) => updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }),
152
- enabled: (ctx) => ctx.versionToUpgradeTo?.includes("canary") && !ctx.preUpgradeError
162
+ enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") && !ctx.preUpgradeError
153
163
  },
154
164
  {
155
165
  title: "Downloading yarn patches",
156
166
  task: (ctx) => downloadYarnPatches(ctx, { dryRun, verbose }),
157
- enabled: (ctx) => ctx.versionToUpgradeTo?.includes("canary") && !ctx.preUpgradeError
167
+ enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") && !ctx.preUpgradeError
158
168
  },
159
169
  {
160
170
  title: "Removing CLI cache",
161
- task: (ctx) => removeCliCache(ctx, { dryRun, verbose }),
171
+ task: () => removeCliCache({ dryRun, verbose }),
162
172
  enabled: (ctx) => !ctx.preUpgradeError
163
173
  },
164
174
  {
165
175
  title: "Running yarn install",
166
- task: (ctx) => yarnInstall(ctx, { dryRun, verbose }),
176
+ task: () => yarnInstall({ verbose }),
167
177
  enabled: (ctx) => !ctx.preUpgradeError,
168
- skip: () => dryRun
178
+ skip: () => !!dryRun
169
179
  },
170
180
  {
171
181
  title: "Refreshing the Prisma client",
172
182
  task: (_ctx, task) => refreshPrismaClient(task, { verbose }),
173
183
  enabled: (ctx) => !ctx.preUpgradeError,
174
- skip: () => dryRun
184
+ skip: () => !!dryRun
175
185
  },
176
186
  {
177
187
  title: "De-duplicating dependencies",
178
- skip: () => dryRun || !dedupe,
188
+ skip: () => !!dryRun || !dedupe,
179
189
  enabled: (ctx) => !ctx.preUpgradeError,
180
190
  task: (_ctx, task) => dedupeDeps(task, { verbose })
181
191
  },
@@ -195,8 +205,8 @@ const handler = async ({ dryRun, tag, verbose, dedupe, yes, force }) => {
195
205
  if ([void 0, "latest", "rc"].includes(tag)) {
196
206
  const ghReleasesLink = terminalLink(
197
207
  `GitHub Release notes`,
198
- `https://github.com/cedarjs/cedar/releases`
199
208
  // intentionally not linking to specific version
209
+ `https://github.com/cedarjs/cedar/releases`
200
210
  );
201
211
  const discordLink = terminalLink(
202
212
  `Discord`,
@@ -257,13 +267,16 @@ async function yarnInstall({ verbose }) {
257
267
  stdio: verbose ? "inherit" : "pipe",
258
268
  cwd: getPaths().base
259
269
  });
260
- } catch (e) {
270
+ } catch {
261
271
  throw new Error(
262
272
  "Could not finish installation. Please run `yarn install` and then `yarn dedupe`, before continuing"
263
273
  );
264
274
  }
265
275
  }
266
- async function removeCliCache(ctx, { dryRun, verbose }) {
276
+ async function removeCliCache({
277
+ dryRun,
278
+ verbose
279
+ }) {
267
280
  const cliCacheDir = path.join(
268
281
  getPaths().generated.base,
269
282
  PLUGIN_CACHE_FILENAME
@@ -283,7 +296,7 @@ async function setLatestVersionToContext(ctx, tag) {
283
296
  );
284
297
  ctx.versionToUpgradeTo = foundVersion;
285
298
  return foundVersion;
286
- } catch (e) {
299
+ } catch {
287
300
  if (tag) {
288
301
  throw new Error("Could not find the latest `" + tag + "` version");
289
302
  }
@@ -345,7 +358,7 @@ function updateCedarJSDepsForAllSides(ctx, options) {
345
358
  title: `Updating ${pkgJsonPath}`,
346
359
  task: (_ctx, task) => updatePackageJsonVersion(
347
360
  basePath,
348
- ctx.versionToUpgradeTo,
361
+ String(ctx.versionToUpgradeTo),
349
362
  task,
350
363
  options
351
364
  ),
@@ -432,7 +445,7 @@ async function downloadYarnPatches(ctx, { dryRun, verbose }) {
432
445
  "https://api.github.com/repos/cedarjs/cedar/git/trees/main?recursive=1",
433
446
  {
434
447
  headers: {
435
- Authorization: githubToken ? `Bearer ${githubToken}` : void 0,
448
+ ...githubToken && { Authorization: `Bearer ${githubToken}` },
436
449
  ["X-GitHub-Api-Version"]: "2022-11-28",
437
450
  Accept: "application/vnd.github+json"
438
451
  }
@@ -482,11 +495,12 @@ async function refreshPrismaClient(task, { verbose }) {
482
495
  force: false
483
496
  });
484
497
  } catch (e) {
498
+ const message = e instanceof Error ? e.message : String(e);
485
499
  task.skip("Refreshing the Prisma client caused an Error.");
486
500
  console.log(
487
501
  "You may need to update your prisma client manually: $ yarn cedar prisma generate"
488
502
  );
489
- console.log(c.error(e.message));
503
+ console.log(c.error(message));
490
504
  }
491
505
  }
492
506
  const dedupeDeps = async (_task, { verbose }) => {
@@ -497,7 +511,8 @@ const dedupeDeps = async (_task, { verbose }) => {
497
511
  cwd: getPaths().base
498
512
  });
499
513
  } catch (e) {
500
- console.log(c.error(e.message));
514
+ const message = e instanceof Error ? e.message : String(e);
515
+ console.log(c.error(message));
501
516
  throw new Error(
502
517
  "Could not finish de-duplication. For yarn 1.x, please run `npx yarn-deduplicate`, or for yarn >= 3 run `yarn dedupe` before continuing"
503
518
  );
@@ -508,7 +523,7 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
508
523
  if (!ctx.versionToUpgradeTo) {
509
524
  return;
510
525
  }
511
- const version = ctx.versionToUpgradeTo;
526
+ const version = typeof ctx.versionToUpgradeTo === "string" ? ctx.versionToUpgradeTo : void 0;
512
527
  const parsed = semver.parse(version);
513
528
  const baseUrl = "https://raw.githubusercontent.com/cedarjs/cedar/main/upgrade-scripts/";
514
529
  const manifestUrl = `${baseUrl}manifest.json`;
@@ -655,7 +670,7 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
655
670
  try {
656
671
  const { stdout } = await execa(
657
672
  "node",
658
- ["script.mts", "--verbose", verbose, "--force", force],
673
+ ["script.mts", "--verbose", String(verbose), "--force", String(force)],
659
674
  { cwd: tempDir }
660
675
  );
661
676
  if (stdout) {
@@ -666,15 +681,23 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
666
681
  ${stdout}`;
667
682
  }
668
683
  } catch (e) {
669
- const errorOutput = e.stdout || e.stderr || e.message || "";
670
- const verboseErrorMessage = verbose ? `Pre-upgrade check ${scriptName} failed with exit code ${e.exitCode}:
671
- ${e.stderr ? e.stderr + "\n" : ""}` : "";
684
+ let errorOutput = String(e);
685
+ let exitCode;
686
+ let stderr;
687
+ if (isExecaError(e)) {
688
+ errorOutput = e.stdout || e.message;
689
+ stderr = e.stderr;
690
+ exitCode = e.exitCode;
691
+ } else if (e instanceof Error) {
692
+ errorOutput = e.message;
693
+ }
672
694
  if (ctx.preUpgradeError) {
673
695
  ctx.preUpgradeError += "\n";
674
696
  }
675
697
  if (verbose) {
676
698
  ctx.preUpgradeError += `
677
- ${verboseErrorMessage}`;
699
+ Pre-upgrade check ${scriptName} failed with exit code ${exitCode}:
700
+ ${stderr ? stderr + "\n" : ""}`;
678
701
  }
679
702
  ctx.preUpgradeError += `
680
703
  ${errorOutput}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "1.0.0-canary.13080+a455cced0",
3
+ "version": "1.0.0-canary.13083+cb44cdf39",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,6 +21,7 @@
21
21
  "scripts": {
22
22
  "build": "tsx ./build.mts",
23
23
  "build:pack": "yarn pack -o cedarjs-cli.tgz",
24
+ "build:types": "tsc --build --verbose ./tsconfig.build.json",
24
25
  "build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build && yarn fix:permissions\"",
25
26
  "dev": "RWJS_CWD=../../__fixtures__/example-todo-main node dist/index.js",
26
27
  "fix:permissions": "chmod +x dist/index.js dist/cfw.js",
@@ -31,15 +32,15 @@
31
32
  "dependencies": {
32
33
  "@babel/preset-typescript": "7.28.5",
33
34
  "@babel/runtime-corejs3": "7.28.4",
34
- "@cedarjs/api-server": "1.0.0-canary.13080",
35
- "@cedarjs/cli-helpers": "1.0.0-canary.13080",
36
- "@cedarjs/fastify-web": "1.0.0-canary.13080",
37
- "@cedarjs/internal": "1.0.0-canary.13080",
38
- "@cedarjs/prerender": "1.0.0-canary.13080",
39
- "@cedarjs/project-config": "1.0.0-canary.13080",
40
- "@cedarjs/structure": "1.0.0-canary.13080",
41
- "@cedarjs/telemetry": "1.0.0-canary.13080",
42
- "@cedarjs/web-server": "1.0.0-canary.13080",
35
+ "@cedarjs/api-server": "1.0.0-canary.13083",
36
+ "@cedarjs/cli-helpers": "1.0.0-canary.13083",
37
+ "@cedarjs/fastify-web": "1.0.0-canary.13083",
38
+ "@cedarjs/internal": "1.0.0-canary.13083",
39
+ "@cedarjs/prerender": "1.0.0-canary.13083",
40
+ "@cedarjs/project-config": "1.0.0-canary.13083",
41
+ "@cedarjs/structure": "1.0.0-canary.13083",
42
+ "@cedarjs/telemetry": "1.0.0-canary.13083",
43
+ "@cedarjs/web-server": "1.0.0-canary.13083",
43
44
  "@listr2/prompt-adapter-enquirer": "2.0.16",
44
45
  "@opentelemetry/api": "1.8.0",
45
46
  "@opentelemetry/core": "1.22.0",
@@ -101,5 +102,5 @@
101
102
  "publishConfig": {
102
103
  "access": "public"
103
104
  },
104
- "gitHead": "a455cced08f75d4c7da246921f9ea66f3ae76f88"
105
+ "gitHead": "cb44cdf39bfa132dc6e07897372119b81aa038ae"
105
106
  }