@speedkit/cli 4.52.1 → 4.52.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [4.52.2](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.52.1...v4.52.2) (2026-11-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **revalidate:** show a failed job's cause and warn when the job was cancelled ([e1706e5](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/e1706e593a40407a3ae13bbc7106d23011178c98))
7
+
1
8
  ## [4.52.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.52.0...v4.52.1) (2026-11-11)
2
9
 
3
10
 
@@ -1,6 +1,6 @@
1
1
  {
2
- "commit": "6a06bc86",
2
+ "commit": "f2ba430f",
3
3
  "dirty": true,
4
- "buildId": "983acead3885",
5
- "builtAt": "2026-11-11T14:31:43.638Z"
4
+ "buildId": "70b320f2d397",
5
+ "builtAt": "2026-11-12T14:47:11.383Z"
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import { SkCommand } from "../../base/sk-command.js";
2
- import { RevalidateFactory, RevalidateStartBuildContext, } from "../../services/revalidate/index.js";
2
+ import { jobFailure, jobNotice, RevalidateFactory, RevalidateStartBuildContext, } from "../../services/revalidate/index.js";
3
3
  export default class RevalidateStart extends SkCommand {
4
4
  static description = "Start a scheduled revalidation job now instead of after its wait.";
5
5
  static buildContext = RevalidateStartBuildContext;
@@ -16,10 +16,13 @@ export default class RevalidateStart extends SkCommand {
16
16
  this.log(`started ${args.revId}`);
17
17
  if (!flags["wait"])
18
18
  return;
19
- // A detected deployment that follows replaces the job, so CANCELLED is a normal end.
20
19
  const job = await service.waitFor(args.revId);
21
20
  this.log(`ended as ${job.state}, refreshed ${job.refreshedCount ?? 0}`);
22
- if (job.state === "ERROR")
23
- this.error(`the job failed: ${job.error}`);
21
+ const notice = jobNotice(job);
22
+ if (notice)
23
+ this.warn(notice);
24
+ const failure = jobFailure(job);
25
+ if (failure)
26
+ this.error(failure);
24
27
  }
25
28
  }
@@ -1,5 +1,5 @@
1
1
  import { SkCommand } from "../base/sk-command.js";
2
- import { CONFIRMATION_THRESHOLD, DROPPING_TYPES, RevalidateServiceBuildContext, RevalidateFactory, } from "../services/revalidate/index.js";
2
+ import { CONFIRMATION_THRESHOLD, DROPPING_TYPES, jobFailure, jobNotice, RevalidateServiceBuildContext, RevalidateFactory, } from "../services/revalidate/index.js";
3
3
  const SAMPLE_SIZE = 10;
4
4
  export default class Revalidate extends SkCommand {
5
5
  static description = "Purge or refresh cached assets by prefix and query. Run it after a config that narrows scope goes live, so returning visitors stop receiving the cached HTML.";
@@ -70,9 +70,12 @@ export default class Revalidate extends SkCommand {
70
70
  }
71
71
  const status = await service.waitFor(statusId);
72
72
  this.log(`assets ${status.assetCount ?? 0}, refreshed ${status.refreshedCount ?? 0}, changed ${status.changedCount ?? 0}`);
73
- if (status.state !== "FINISHED") {
74
- this.error(`job ${statusId} ended as ${status.state}: ${status.error}`);
75
- }
73
+ const notice = jobNotice(status);
74
+ if (notice)
75
+ this.warn(`job ${statusId}: ${notice}`);
76
+ const failure = jobFailure(status);
77
+ if (failure)
78
+ this.error(`job ${statusId}: ${failure}`);
76
79
  }
77
80
  /** A malformed query would otherwise reach the backend as an opaque 400. */
78
81
  parseQuery(raw) {
@@ -33,8 +33,27 @@ export interface RevalidateJobStatusInterface {
33
33
  assetCount?: number;
34
34
  refreshedCount?: number;
35
35
  changedCount?: number;
36
- error?: string | null;
36
+ error?: RevalidateJobErrorInterface | null;
37
37
  }
38
+ /**
39
+ * Why a job failed, as the server's RestException sends it. With server debug on
40
+ * the object also carries `className`, the Java `stackTrace` and a nested `cause`,
41
+ * so print it with `describeJobError`, never as a whole.
42
+ */
43
+ export interface RevalidateJobErrorInterface {
44
+ message?: string;
45
+ reason?: string;
46
+ status?: number;
47
+ }
48
+ /** Renders a job's `error` as `reason (status): message`, or undefined when it names no cause. */
49
+ export declare function describeJobError(error: RevalidateJobErrorInterface | null | undefined): string | undefined;
50
+ /** Why a finished job counts as failed, or undefined when it did not fail. Only ERROR fails. */
51
+ export declare function jobFailure(job: RevalidateJobStatusInterface): string | undefined;
52
+ /**
53
+ * What to tell the user about a job that ended without finishing but did not
54
+ * fail. CANCELLED is a normal end — worth saying, not worth a failing exit.
55
+ */
56
+ export declare function jobNotice(job: RevalidateJobStatusInterface): string | undefined;
38
57
  export declare const JOB_STATES: readonly ["CREATED", "SCHEDULED", "DEFERRED", "RUNNING", "FINISHED", "ERROR", "CANCELLED"];
39
58
  export type JobState = (typeof JOB_STATES)[number];
40
59
  /** The states of a job that has not ended yet. */
@@ -24,6 +24,36 @@ export const DROPPING_TYPES = new Set([
24
24
  "PURGE",
25
25
  "DEPLOYMENT",
26
26
  ]);
27
+ /** Renders a job's `error` as `reason (status): message`, or undefined when it names no cause. */
28
+ export function describeJobError(error) {
29
+ if (!error)
30
+ return undefined;
31
+ const { message, reason, status } = error;
32
+ const head = [reason, status === undefined ? undefined : `(${status})`]
33
+ .filter(Boolean)
34
+ .join(" ");
35
+ if (head && message)
36
+ return `${head}: ${message}`;
37
+ return head || message || undefined;
38
+ }
39
+ /** Why a finished job counts as failed, or undefined when it did not fail. Only ERROR fails. */
40
+ export function jobFailure(job) {
41
+ if (job.state !== "ERROR")
42
+ return undefined;
43
+ const cause = describeJobError(job.error);
44
+ return cause
45
+ ? `the job failed: ${cause}`
46
+ : "the job failed (no cause reported)";
47
+ }
48
+ /**
49
+ * What to tell the user about a job that ended without finishing but did not
50
+ * fail. CANCELLED is a normal end — worth saying, not worth a failing exit.
51
+ */
52
+ export function jobNotice(job) {
53
+ if (job.state !== "CANCELLED")
54
+ return undefined;
55
+ return "the job was cancelled before it finished: another job took over its scope, or it was cancelled through the API";
56
+ }
27
57
  export const JOB_STATES = [
28
58
  "CREATED",
29
59
  "SCHEDULED",
@@ -1,6 +1,7 @@
1
1
  import { expect } from "chai";
2
2
  import { afterEach, describe, it } from "mocha";
3
3
  import nock from "nock";
4
+ import { describeJobError, jobFailure, jobNotice, } from "../revalidate-model.js";
4
5
  import { RevalidateService } from "../revalidate-service.js";
5
6
  const HOST = "https://example-shop.app.baqend.com";
6
7
  function service(written = []) {
@@ -94,6 +95,67 @@ describe("RevalidateService jobs", () => {
94
95
  "0 deployment job(s) block the HTML",
95
96
  ]);
96
97
  }).timeout(10000);
98
+ describe("describeJobError", () => {
99
+ it("prints reason, status and message", () => {
100
+ expect(describeJobError({
101
+ message: "render failed",
102
+ reason: "Internal Server Error",
103
+ status: 500,
104
+ })).to.equal("Internal Server Error (500): render failed");
105
+ });
106
+ it("leaves out the server's debug fields", () => {
107
+ const debug = {
108
+ message: "render failed",
109
+ reason: "Internal Server Error",
110
+ status: 500,
111
+ className: "info.orestes.common.error.RestException",
112
+ stackTrace: ["at info.orestes.Foo.bar(Foo.java:1)"],
113
+ cause: { message: "nested" },
114
+ };
115
+ expect(describeJobError(debug)).to.equal("Internal Server Error (500): render failed");
116
+ });
117
+ it("prints whichever parts the error has", () => {
118
+ expect(describeJobError({ message: "render failed" })).to.equal("render failed");
119
+ expect(describeJobError({ reason: "Bad Request", status: 400 })).to.equal("Bad Request (400)");
120
+ });
121
+ it("names no cause when the job reports none", () => {
122
+ expect(describeJobError(null)).to.equal(undefined);
123
+ expect(describeJobError(undefined)).to.equal(undefined);
124
+ expect(describeJobError({})).to.equal(undefined);
125
+ });
126
+ });
127
+ describe("jobFailure", () => {
128
+ it("names the cause of a failed job, not [object Object]", () => {
129
+ const failure = jobFailure({
130
+ state: "ERROR",
131
+ error: {
132
+ message: "render failed",
133
+ reason: "Internal Server Error",
134
+ status: 500,
135
+ },
136
+ });
137
+ expect(failure).to.equal("the job failed: Internal Server Error (500): render failed");
138
+ });
139
+ it("still fails a job that ended in ERROR without a cause", () => {
140
+ expect(jobFailure({ state: "ERROR" })).to.equal("the job failed (no cause reported)");
141
+ expect(jobFailure({ state: "ERROR", error: null })).to.equal("the job failed (no cause reported)");
142
+ });
143
+ it("does not fail a finished or a cancelled job", () => {
144
+ expect(jobFailure({ state: "FINISHED" })).to.equal(undefined);
145
+ expect(jobFailure({ state: "CANCELLED" })).to.equal(undefined);
146
+ });
147
+ });
148
+ describe("jobNotice", () => {
149
+ it("names both ways a job gets cancelled", () => {
150
+ const notice = jobNotice({ state: "CANCELLED" });
151
+ expect(notice).to.contain("another job took over its scope");
152
+ expect(notice).to.contain("cancelled through the API");
153
+ });
154
+ it("has nothing to say about a finished or a failed job", () => {
155
+ expect(jobNotice({ state: "FINISHED" })).to.equal(undefined);
156
+ expect(jobNotice({ state: "ERROR" })).to.equal(undefined);
157
+ });
158
+ });
97
159
  describe("settleDeployments", () => {
98
160
  it("starts only the scheduled deployment jobs, until none blocks the HTML", async () => {
99
161
  const started = [];
@@ -1411,87 +1411,6 @@
1411
1411
  "fish.js"
1412
1412
  ]
1413
1413
  },
1414
- "browser:clean": {
1415
- "aliases": [],
1416
- "args": {},
1417
- "description": "Remove puppeteer-managed browser builds from the cache",
1418
- "examples": [
1419
- "$ sk browser clean",
1420
- "$ sk browser clean --all"
1421
- ],
1422
- "flags": {
1423
- "all": {
1424
- "char": "a",
1425
- "description": "Remove all cached browser builds without prompting",
1426
- "name": "all",
1427
- "allowNo": false,
1428
- "type": "boolean"
1429
- }
1430
- },
1431
- "hasDynamicHelp": false,
1432
- "hiddenAliases": [],
1433
- "id": "browser:clean",
1434
- "pluginAlias": "@speedkit/cli",
1435
- "pluginName": "@speedkit/cli",
1436
- "pluginType": "core",
1437
- "strict": true,
1438
- "enableJsonFlag": false,
1439
- "isESM": true,
1440
- "relativePath": [
1441
- "dist",
1442
- "commands",
1443
- "browser",
1444
- "clean.js"
1445
- ]
1446
- },
1447
- "browser:list": {
1448
- "aliases": [],
1449
- "args": {},
1450
- "description": "List detected system browsers and puppeteer-managed builds",
1451
- "examples": [
1452
- "$ sk browser list"
1453
- ],
1454
- "flags": {},
1455
- "hasDynamicHelp": false,
1456
- "hiddenAliases": [],
1457
- "id": "browser:list",
1458
- "pluginAlias": "@speedkit/cli",
1459
- "pluginName": "@speedkit/cli",
1460
- "pluginType": "core",
1461
- "strict": true,
1462
- "enableJsonFlag": false,
1463
- "isESM": true,
1464
- "relativePath": [
1465
- "dist",
1466
- "commands",
1467
- "browser",
1468
- "list.js"
1469
- ]
1470
- },
1471
- "browser:update": {
1472
- "aliases": [],
1473
- "args": {},
1474
- "description": "Update the puppeteer-managed browser to the latest build of its channel",
1475
- "examples": [
1476
- "$ sk browser update"
1477
- ],
1478
- "flags": {},
1479
- "hasDynamicHelp": false,
1480
- "hiddenAliases": [],
1481
- "id": "browser:update",
1482
- "pluginAlias": "@speedkit/cli",
1483
- "pluginName": "@speedkit/cli",
1484
- "pluginType": "core",
1485
- "strict": true,
1486
- "enableJsonFlag": false,
1487
- "isESM": true,
1488
- "relativePath": [
1489
- "dist",
1490
- "commands",
1491
- "browser",
1492
- "update.js"
1493
- ]
1494
- },
1495
1414
  "config:edit": {
1496
1415
  "aliases": [],
1497
1416
  "args": {},
@@ -1699,6 +1618,87 @@
1699
1618
  "update.js"
1700
1619
  ]
1701
1620
  },
1621
+ "browser:clean": {
1622
+ "aliases": [],
1623
+ "args": {},
1624
+ "description": "Remove puppeteer-managed browser builds from the cache",
1625
+ "examples": [
1626
+ "$ sk browser clean",
1627
+ "$ sk browser clean --all"
1628
+ ],
1629
+ "flags": {
1630
+ "all": {
1631
+ "char": "a",
1632
+ "description": "Remove all cached browser builds without prompting",
1633
+ "name": "all",
1634
+ "allowNo": false,
1635
+ "type": "boolean"
1636
+ }
1637
+ },
1638
+ "hasDynamicHelp": false,
1639
+ "hiddenAliases": [],
1640
+ "id": "browser:clean",
1641
+ "pluginAlias": "@speedkit/cli",
1642
+ "pluginName": "@speedkit/cli",
1643
+ "pluginType": "core",
1644
+ "strict": true,
1645
+ "enableJsonFlag": false,
1646
+ "isESM": true,
1647
+ "relativePath": [
1648
+ "dist",
1649
+ "commands",
1650
+ "browser",
1651
+ "clean.js"
1652
+ ]
1653
+ },
1654
+ "browser:list": {
1655
+ "aliases": [],
1656
+ "args": {},
1657
+ "description": "List detected system browsers and puppeteer-managed builds",
1658
+ "examples": [
1659
+ "$ sk browser list"
1660
+ ],
1661
+ "flags": {},
1662
+ "hasDynamicHelp": false,
1663
+ "hiddenAliases": [],
1664
+ "id": "browser:list",
1665
+ "pluginAlias": "@speedkit/cli",
1666
+ "pluginName": "@speedkit/cli",
1667
+ "pluginType": "core",
1668
+ "strict": true,
1669
+ "enableJsonFlag": false,
1670
+ "isESM": true,
1671
+ "relativePath": [
1672
+ "dist",
1673
+ "commands",
1674
+ "browser",
1675
+ "list.js"
1676
+ ]
1677
+ },
1678
+ "browser:update": {
1679
+ "aliases": [],
1680
+ "args": {},
1681
+ "description": "Update the puppeteer-managed browser to the latest build of its channel",
1682
+ "examples": [
1683
+ "$ sk browser update"
1684
+ ],
1685
+ "flags": {},
1686
+ "hasDynamicHelp": false,
1687
+ "hiddenAliases": [],
1688
+ "id": "browser:update",
1689
+ "pluginAlias": "@speedkit/cli",
1690
+ "pluginName": "@speedkit/cli",
1691
+ "pluginType": "core",
1692
+ "strict": true,
1693
+ "enableJsonFlag": false,
1694
+ "isESM": true,
1695
+ "relativePath": [
1696
+ "dist",
1697
+ "commands",
1698
+ "browser",
1699
+ "update.js"
1700
+ ]
1701
+ },
1702
1702
  "onboarding:cdp": {
1703
1703
  "aliases": [],
1704
1704
  "args": {
@@ -5234,5 +5234,5 @@
5234
5234
  ]
5235
5235
  }
5236
5236
  },
5237
- "version": "4.52.1"
5237
+ "version": "4.52.2"
5238
5238
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "4.52.1",
4
+ "version": "4.52.2",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"