@speedkit/cli 4.52.1 → 4.52.3

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,17 @@
1
+ ## [4.52.3](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.52.2...v4.52.3) (2026-11-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deploy:** ask for the customer approval in a single --mr deploy ([537c66a](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/537c66a0f2a4c9bcd3b0ade514018efd2c28161f))
7
+
8
+ ## [4.52.2](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.52.1...v4.52.2) (2026-11-12)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **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))
14
+
1
15
  ## [4.52.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.52.0...v4.52.1) (2026-11-11)
2
16
 
3
17
 
@@ -1,6 +1,6 @@
1
1
  {
2
- "commit": "6a06bc86",
2
+ "commit": "267e2f69",
3
3
  "dirty": true,
4
- "buildId": "983acead3885",
5
- "builtAt": "2026-11-11T14:31:43.638Z"
4
+ "buildId": "3bb8c56d65c3",
5
+ "builtAt": "2026-11-16T14:41:41.046Z"
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) {
@@ -4,17 +4,21 @@ import { ApprovalAnswer } from "../policy/auto-deploy-policy.js";
4
4
  export class MergeRequestDeployServiceBuildContext extends Context() {
5
5
  /** The `--mr` deploy of `sk deploy`, from that command's args and flags. */
6
6
  static create(parsedArgs, parsedFlags, environment) {
7
+ // A person at the keyboard reviews the change in their diff tool.
8
+ const interactive = Boolean(process.stdout.isTTY);
7
9
  return new MergeRequestDeployServiceBuildContext({
8
10
  environment,
9
11
  customerPath: parsedArgs.customerPath,
10
12
  configName: parsedFlags.configName,
11
13
  iid: parsedFlags.mr,
12
- approval: (parsedFlags.approval ?? ApprovalAnswer.Skip),
14
+ approval: (parsedFlags.approval ??
15
+ (interactive
16
+ ? ApprovalAnswer.Ask
17
+ : ApprovalAnswer.Skip)),
13
18
  description: parsedFlags.description,
14
19
  dryRun: parsedFlags.dryRun,
15
20
  skipPostDeployChecks: false,
16
- // A person at the keyboard reviews the change in their diff tool.
17
- interactive: Boolean(process.stdout.isTTY),
21
+ interactive,
18
22
  });
19
23
  }
20
24
  }
@@ -7,16 +7,22 @@ export declare enum ApprovalAnswer {
7
7
  /** The installation goes live under the debug parameter only. */
8
8
  Testing = "testing",
9
9
  /** The configurations that need an approval are not deployed at all. */
10
- Skip = "skip"
10
+ Skip = "skip",
11
+ /**
12
+ * The person who watches the deploy answers both questions themselves.
13
+ * Without such a person, both questions are declined.
14
+ */
15
+ Ask = "ask"
11
16
  }
12
17
  /**
13
- * The policy of a deploy that runs without a person.
18
+ * The policy of a deploy that applies a merged merge request.
14
19
  *
15
20
  * Every question that the merge request already answers is confirmed: the live
16
21
  * installation was compared with the state before the merge request, so the
17
22
  * deploy applies exactly the reviewed change. Every question that the merge
18
- * request cannot answer is declined, which stops this configuration and leaves
19
- * it to a developer.
23
+ * request cannot answer goes to the person who watches the deploy. Without a
24
+ * person, such a question is declined, which stops this configuration and
25
+ * leaves it to a developer.
20
26
  */
21
27
  export declare class AutoDeployPolicy implements DeployPolicyInterface {
22
28
  private readonly description;
@@ -45,6 +51,6 @@ export declare class AutoDeployPolicy implements DeployPolicyInterface {
45
51
  * the merge request already answers it.
46
52
  */
47
53
  cli?: CliServiceInterface);
48
- confirm(question: DeployQuestion, message?: string): Promise<boolean>;
54
+ confirm(question: DeployQuestion, message?: string, defaultAnswer?: boolean): Promise<boolean>;
49
55
  text(question: DeployQuestion): Promise<string>;
50
56
  }
@@ -8,15 +8,21 @@ export var ApprovalAnswer;
8
8
  ApprovalAnswer["Testing"] = "testing";
9
9
  /** The configurations that need an approval are not deployed at all. */
10
10
  ApprovalAnswer["Skip"] = "skip";
11
+ /**
12
+ * The person who watches the deploy answers both questions themselves.
13
+ * Without such a person, both questions are declined.
14
+ */
15
+ ApprovalAnswer["Ask"] = "ask";
11
16
  })(ApprovalAnswer || (ApprovalAnswer = {}));
12
17
  /**
13
- * The policy of a deploy that runs without a person.
18
+ * The policy of a deploy that applies a merged merge request.
14
19
  *
15
20
  * Every question that the merge request already answers is confirmed: the live
16
21
  * installation was compared with the state before the merge request, so the
17
22
  * deploy applies exactly the reviewed change. Every question that the merge
18
- * request cannot answer is declined, which stops this configuration and leaves
19
- * it to a developer.
23
+ * request cannot answer goes to the person who watches the deploy. Without a
24
+ * person, such a question is declined, which stops this configuration and
25
+ * leaves it to a developer.
20
26
  */
21
27
  export class AutoDeployPolicy {
22
28
  description;
@@ -42,7 +48,7 @@ export class AutoDeployPolicy {
42
48
  this.approval = approval;
43
49
  this.cli = cli;
44
50
  }
45
- async confirm(question, message) {
51
+ async confirm(question, message, defaultAnswer) {
46
52
  switch (question) {
47
53
  // The one question a watching person answers, after the diffs.
48
54
  case DeployQuestion.UploadInstallResource: {
@@ -66,17 +72,29 @@ export class AutoDeployPolicy {
66
72
  return true;
67
73
  }
68
74
  case DeployQuestion.CustomerApproval: {
75
+ if (this.approval === ApprovalAnswer.Ask) {
76
+ return this.cli ? this.cli.confirm(message, false) : false;
77
+ }
69
78
  return this.approval === ApprovalAnswer.Approved;
70
79
  }
71
80
  case DeployQuestion.ActivateAsTesting: {
81
+ if (this.approval === ApprovalAnswer.Ask) {
82
+ return this.cli ? this.cli.confirm(message, true) : false;
83
+ }
72
84
  return this.approval === ApprovalAnswer.Testing;
73
85
  }
86
+ // A bulk run confirms it after its plan. Otherwise the watching person
87
+ // is asked, and without a person it is declined.
74
88
  case DeployQuestion.DeviceDetectionChange: {
75
- return this.confirmsDeviceDetection;
89
+ return (this.confirmsDeviceDetection ||
90
+ (this.cli ? this.cli.confirm(message, defaultAnswer ?? false) : false));
76
91
  }
77
- // Decisions a merge request never carries.
92
+ // Decisions a merge request never carries: the watching person is
93
+ // asked, and without a person they are declined.
78
94
  default: {
79
- return false;
95
+ return this.cli
96
+ ? this.cli.confirm(message, defaultAnswer ?? true)
97
+ : false;
80
98
  }
81
99
  }
82
100
  }
@@ -63,6 +63,21 @@ describe("AutoDeployPolicy", () => {
63
63
  expect(await skip.confirm(DeployQuestion.CustomerApproval)).to.equal(false);
64
64
  expect(await skip.confirm(DeployQuestion.ActivateAsTesting)).to.equal(false);
65
65
  });
66
+ it("asks the watching person about such a customer", async () => {
67
+ const { cli, questions } = personAnswering(true);
68
+ const ask = new AutoDeployPolicy("a change", ApprovalAnswer.Ask, cli);
69
+ expect(await ask.confirm(DeployQuestion.CustomerApproval, "Was this change approved by customer?")).to.equal(true);
70
+ expect(await ask.confirm(DeployQuestion.ActivateAsTesting, "Activate as testing installation?")).to.equal(true);
71
+ expect(questions).to.deep.equal([
72
+ "Was this change approved by customer?",
73
+ "Activate as testing installation?",
74
+ ]);
75
+ });
76
+ it("activates nothing of such a customer when nobody watches to answer", async () => {
77
+ const ask = policy(ApprovalAnswer.Ask);
78
+ expect(await ask.confirm(DeployQuestion.CustomerApproval)).to.equal(false);
79
+ expect(await ask.confirm(DeployQuestion.ActivateAsTesting)).to.equal(false);
80
+ });
66
81
  it("leaves the upload to the person who watches the deploy", async () => {
67
82
  const { cli, questions } = personAnswering(false);
68
83
  const policy = new AutoDeployPolicy("a change", ApprovalAnswer.Approved, cli);
@@ -77,6 +92,25 @@ describe("AutoDeployPolicy", () => {
77
92
  expect(await policy.confirm(DeployQuestion.UpdateFile, "Update config?")).to.equal(true);
78
93
  expect(questions).to.deep.equal([]);
79
94
  });
95
+ it("asks the watching person every decision a merge request does not carry", async () => {
96
+ for (const answer of [true, false]) {
97
+ const { cli, questions } = personAnswering(answer);
98
+ const watched = new AutoDeployPolicy("a change", ApprovalAnswer.Approved, cli);
99
+ expect(await watched.confirm(DeployQuestion.SplitChange, "Change the split?")).to.equal(answer);
100
+ expect(await watched.confirm(DeployQuestion.DeviceDetectionChange, "Change the device detection?")).to.equal(answer);
101
+ expect(questions).to.deep.equal([
102
+ "Change the split?",
103
+ "Change the device detection?",
104
+ ]);
105
+ }
106
+ });
107
+ it("asks nobody about a device detection change a person already confirmed", async () => {
108
+ const { cli, questions } = personAnswering(false);
109
+ const watched = new AutoDeployPolicy("a change", ApprovalAnswer.Approved, cli);
110
+ watched.confirmsDeviceDetection = true;
111
+ expect(await watched.confirm(DeployQuestion.DeviceDetectionChange)).to.equal(true);
112
+ expect(questions).to.deep.equal([]);
113
+ });
80
114
  it("describes the installation with the merge request", async () => {
81
115
  expect(await policy(ApprovalAnswer.Approved).text(DeployQuestion.Description)).to.equal("!42 a reviewed change");
82
116
  });
@@ -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 = [];