@speedkit/cli 4.45.2 → 4.46.0

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.46.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.45.2...v4.46.0) (2026-10-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * **bulk-deploy:** ask once whether QA checked the device detection changes ([dda8bbd](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/dda8bbd390b1655349747bd3bb7fe333c047d294))
7
+
1
8
  ## [4.45.2](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.45.1...v4.45.2) (2026-10-16)
2
9
 
3
10
 
@@ -38,6 +38,15 @@ export declare class BulkDeployService {
38
38
  /** Plans every configuration, without writing anything. */
39
39
  private planAll;
40
40
  private planOne;
41
+ /**
42
+ * Asks once whether the device detection changes of the plan go live.
43
+ *
44
+ * Without a yes, every configuration with such a change is skipped. A run
45
+ * with `--yes` has no keyboard, so it never confirms such a change.
46
+ *
47
+ * @returns whether the device detection changes were confirmed.
48
+ */
49
+ private settleDeviceDetection;
41
50
  /** Deploys every configuration the plan found deployable. */
42
51
  private applyAll;
43
52
  private isConfirmed;
@@ -34,9 +34,10 @@ export class BulkDeployService {
34
34
  const answers = await this.ask(configs);
35
35
  const planned = await this.planAll(configs, answers);
36
36
  this.writeTable("Plan", planned);
37
+ const confirmsDeviceDetection = await this.settleDeviceDetection(planned);
37
38
  const deployable = planned.filter((entry) => entry.result.outcome === DeployOutcome.Deployable);
38
39
  if (deployable.length > 0 && (await this.isConfirmed(deployable.length))) {
39
- await this.applyAll(deployable);
40
+ await this.applyAll(deployable, confirmsDeviceDetection);
40
41
  }
41
42
  else if (deployable.length > 0) {
42
43
  for (const entry of deployable) {
@@ -132,8 +133,40 @@ export class BulkDeployService {
132
133
  return { config, result: this.failed(config, error) };
133
134
  }
134
135
  }
136
+ /**
137
+ * Asks once whether the device detection changes of the plan go live.
138
+ *
139
+ * Without a yes, every configuration with such a change is skipped. A run
140
+ * with `--yes` has no keyboard, so it never confirms such a change.
141
+ *
142
+ * @returns whether the device detection changes were confirmed.
143
+ */
144
+ async settleDeviceDetection(planned) {
145
+ const changing = planned.filter((entry) => entry.result.outcome === DeployOutcome.Deployable &&
146
+ entry.result.deviceDetectionChanges);
147
+ if (changing.length === 0) {
148
+ return false;
149
+ }
150
+ this.cli.spacer();
151
+ this.cli.writeWarning("These customers change their device detection:");
152
+ this.cli.code(changing
153
+ .map((entry) => `${entry.config.directory}: ${entry.result.deviceDetectionChanges.join(", ")}`)
154
+ .join("\n"));
155
+ const confirmed = !this.context.assumeYes &&
156
+ (await this.cli.confirm("Was the device detection change checked by QA, so it can go live?", false));
157
+ if (!confirmed) {
158
+ for (const entry of changing) {
159
+ entry.result = {
160
+ ...entry.result,
161
+ outcome: DeployOutcome.Skipped,
162
+ reason: "the device detection change was not confirmed",
163
+ };
164
+ }
165
+ }
166
+ return confirmed;
167
+ }
135
168
  /** Deploys every configuration the plan found deployable. */
136
- async applyAll(deployable) {
169
+ async applyAll(deployable, confirmsDeviceDetection) {
137
170
  for (const entry of deployable) {
138
171
  const name = `${entry.config.directory} [${entry.config.configName}]`;
139
172
  this.cli.spacer();
@@ -141,7 +174,7 @@ export class BulkDeployService {
141
174
  try {
142
175
  // The deploy plans again, because live can change between the plan
143
176
  // and the deploy.
144
- entry.result = await entry.service.run();
177
+ entry.result = await entry.service.run(confirmsDeviceDetection);
145
178
  }
146
179
  catch (error) {
147
180
  entry.result = this.failed(entry.config, error);
@@ -14,6 +14,13 @@ export declare class DeviceDetectionChangedCheck {
14
14
  private bundler;
15
15
  constructor(cli: CliServiceInterface, fileList: FileListInterface, configApi: ConfigApiService, customerConfig: CustomerConfig, configName: string, isProduction: boolean, policy: DeployPolicyInterface, bundler: BundleService);
16
16
  check(): Promise<void>;
17
+ /**
18
+ * The device detection settings that this deploy changes in production.
19
+ *
20
+ * It is empty while the check does not apply, or the change cannot be
21
+ * evaluated.
22
+ */
23
+ changes(): Promise<string[]>;
17
24
  private checkForChangedDeviceDetection;
18
25
  private getActiveInstallResource;
19
26
  }
@@ -24,18 +24,35 @@ export class DeviceDetectionChangedCheck {
24
24
  this.bundler = bundler;
25
25
  }
26
26
  async check() {
27
+ const changes = await this.changes();
28
+ if (changes.length === 0) {
29
+ return;
30
+ }
31
+ // this.cli.table(changes, { origin: {}, type: {}, old: {}, new: {} });
32
+ const result = await this.policy.confirm(DeployQuestion.DeviceDetectionChange, `Detected change in ${changes.join(" | ")}. ${this.cli.style.red("Was this checked by QA?")}`, false);
33
+ if (!result) {
34
+ throw new DeployAbortedError("the device detection change was not confirmed");
35
+ }
36
+ }
37
+ /**
38
+ * The device detection settings that this deploy changes in production.
39
+ *
40
+ * It is empty while the check does not apply, or the change cannot be
41
+ * evaluated.
42
+ */
43
+ async changes() {
27
44
  if (
28
45
  // do not check for environments other than production
29
46
  !this.isProduction ||
30
47
  // do not check if speedKitConfigFile is not to be deployed
31
48
  !this.fileList.hasFile(INTEGRATION_FILES.CONFIG.SPEED_KIT) ||
32
49
  this.fileList.getSpeedKitConfig().shouldSkipFile()) {
33
- return;
50
+ return [];
34
51
  }
35
52
  const activeInstallResource = await this.getActiveInstallResource();
36
53
  // do not check if there is no active install resource to be updated
37
54
  if (!activeInstallResource) {
38
- return;
55
+ return [];
39
56
  }
40
57
  this.cli.startAction("PRE:CHECK:DEVICE_DETECTION", "Checking for customDeviceDetection");
41
58
  const speedKitConfigFile = this.fileList.getSpeedKitConfig();
@@ -44,20 +61,12 @@ export class DeviceDetectionChangedCheck {
44
61
  if (changesResponse.success === false) {
45
62
  this.cli.failAction("PRE:CHECK:DEVICE_DETECTION");
46
63
  this.cli.writeError(`Unable to evaluate changes: ${changesResponse.error}`);
47
- return;
64
+ return [];
48
65
  }
49
- const changes = changesResponse.data.map((value) => {
66
+ this.cli.successAction("PRE:CHECK:DEVICE_DETECTION");
67
+ return changesResponse.data.map((value) => {
50
68
  return `${INTEGRATION_FILES.CONFIG.SPEED_KIT}.${value}`;
51
69
  });
52
- this.cli.successAction("PRE:CHECK:DEVICE_DETECTION");
53
- if (changes.length === 0) {
54
- return;
55
- }
56
- // this.cli.table(changes, { origin: {}, type: {}, old: {}, new: {} });
57
- const result = await this.policy.confirm(DeployQuestion.DeviceDetectionChange, `Detected change in ${changes.join(" | ")}. ${this.cli.style.red("Was this checked by QA?")}`, false);
58
- if (!result) {
59
- throw new DeployAbortedError("the device detection change was not confirmed");
60
- }
61
70
  }
62
71
  async checkForChangedDeviceDetection(speedKitConfigFile, activeSpeedKitConfig) {
63
72
  const remoteConfigFile = await VirtualSpeedKitConfigFile.createRemote(activeSpeedKitConfig, this.bundler);
@@ -21,4 +21,6 @@ export interface MergeRequestDeployResult {
21
21
  reason?: string;
22
22
  /** The files of the merge request that this deploy never uploads. */
23
23
  notDeployed?: string[];
24
+ /** The device detection settings the deploy changes, which QA must confirm. */
25
+ deviceDetectionChanges?: string[];
24
26
  }
@@ -3,6 +3,7 @@ import { createDiffEngine } from "../../diff/index.js";
3
3
  import { GitRepository } from "../../git/index.js";
4
4
  import { IntegrationApiServiceBuildContext, IntegrationApiFactory, } from "../../integration-api/index.js";
5
5
  import { CustomerApprovalCheck } from "../checks/activation/customer-approval-check.js";
6
+ import { DeviceDetectionChangedCheck } from "../checks/pre-deploy/device-detection-changed-check.js";
6
7
  import { DeployServiceBuildContext } from "../deploy-service-build-context.js";
7
8
  import DeployServiceFactory from "../deploy-service-factory.js";
8
9
  import { AutoDeployPolicy } from "../policy/auto-deploy-policy.js";
@@ -35,7 +36,7 @@ export class MergeRequestDeployServiceFactory {
35
36
  const request = this.request ?? repository.mergeRequest(this.context.iid);
36
37
  const cliService = this.context.environment.cli;
37
38
  const policy = new AutoDeployPolicy(await resolveDescription(cliService, request, this.context.description), this.context.approval, this.context.interactive ? cliService : undefined);
38
- const deployFactory = new DeployServiceFactory(new DeployServiceBuildContext({
39
+ const deployContext = new DeployServiceBuildContext({
39
40
  environment: this.context.environment,
40
41
  customerPath: this.context.customerPath,
41
42
  configName: this.context.configName,
@@ -46,8 +47,11 @@ export class MergeRequestDeployServiceFactory {
46
47
  skipPostDeployChecks: this.context.skipPostDeployChecks,
47
48
  opensDiffTool: this.context.interactive ?? false,
48
49
  promptForLogin: this.context.interactive ?? false,
49
- }), policy);
50
+ });
51
+ const deployFactory = new DeployServiceFactory(deployContext, policy);
50
52
  const deployService = await deployFactory.buildService();
53
+ const customer = deployFactory.files.getCustomerConfig().config;
54
+ const bundler = new BundleServiceFactory("./").buildService();
51
55
  // A deploy that runs without a person never opens a diff tool, so the
52
56
  // comparison only tells whether two contents are equal.
53
57
  const diffService = createDiffEngine(this.context.environment, "none");
@@ -58,6 +62,6 @@ export class MergeRequestDeployServiceFactory {
58
62
  whitelist: [],
59
63
  }))
60
64
  .buildService()
61
- .run()), new LiveStateCheck(diffService), new CustomerApprovalCheck(cliService, deployFactory.files.getCustomerConfig().config, policy, new BundleServiceFactory("./").buildService()), deployFactory.configApi, deployFactory.files, deployFactory.configName, deployService);
65
+ .run()), new LiveStateCheck(diffService), new CustomerApprovalCheck(cliService, customer, policy, bundler), new DeviceDetectionChangedCheck(cliService, deployFactory.files, deployFactory.configApi, customer, deployFactory.configName, deployContext.isProduction, policy, bundler), policy, deployFactory.configApi, deployFactory.files, deployFactory.configName, deployService);
62
66
  }
63
67
  }
@@ -3,7 +3,9 @@ import { ConfigApiService } from "../../config-api/index.js";
3
3
  import { GitRepository, MergedRequest } from "../../git/index.js";
4
4
  import { FileListInterface } from "../../integration-api/index.js";
5
5
  import { CustomerApprovalCheck } from "../checks/activation/customer-approval-check.js";
6
+ import { DeviceDetectionChangedCheck } from "../checks/pre-deploy/device-detection-changed-check.js";
6
7
  import DeployService from "../deploy-service.js";
8
+ import { AutoDeployPolicy } from "../policy/auto-deploy-policy.js";
7
9
  import { BaseConfigReader } from "./base-config-reader.js";
8
10
  import { LiveStateCheck } from "./live-state-check.js";
9
11
  import { MergeRequestDeployResult } from "./merge-request-deploy-model.js";
@@ -22,13 +24,21 @@ export declare class MergeRequestDeployService {
22
24
  private readonly baseReader;
23
25
  private readonly liveStateCheck;
24
26
  private readonly approvalCheck;
27
+ private readonly deviceDetectionCheck;
28
+ private readonly policy;
25
29
  private readonly configApi;
26
30
  private readonly files;
27
31
  private readonly configName;
28
32
  private readonly deployService;
29
- constructor(context: MergeRequestDeployOptions, request: MergedRequest, repository: GitRepository, baseReader: BaseConfigReader, liveStateCheck: LiveStateCheck, approvalCheck: CustomerApprovalCheck, configApi: ConfigApiService, files: FileListInterface, configName: string, deployService: DeployService);
30
- /** Plans the deploy and runs it while the plan allows it. */
31
- run(): Promise<MergeRequestDeployResult>;
33
+ constructor(context: MergeRequestDeployOptions, request: MergedRequest, repository: GitRepository, baseReader: BaseConfigReader, liveStateCheck: LiveStateCheck, approvalCheck: CustomerApprovalCheck, deviceDetectionCheck: DeviceDetectionChangedCheck, policy: AutoDeployPolicy, configApi: ConfigApiService, files: FileListInterface, configName: string, deployService: DeployService);
34
+ /**
35
+ * Plans the deploy and runs it while the plan allows it.
36
+ *
37
+ * @param confirmsDeviceDetection - whether a person confirmed that the
38
+ * device detection change of the plan goes live. Without it, such a change
39
+ * stops the deploy.
40
+ */
41
+ run(confirmsDeviceDetection?: boolean): Promise<MergeRequestDeployResult>;
32
42
  /**
33
43
  * What a deploy of this configuration would do, without writing anything.
34
44
  *
@@ -1,6 +1,6 @@
1
1
  import { DEFAULT_BLOCKED_FILES, DEFAULT_BLOCKED_FOLDERS, } from "../../integration-api/index.js";
2
2
  import { DeployAbortedError } from "../error/deploy-aborted-error.js";
3
- import { ApprovalAnswer } from "../policy/auto-deploy-policy.js";
3
+ import { ApprovalAnswer, } from "../policy/auto-deploy-policy.js";
4
4
  import { LiveState } from "./live-state-check.js";
5
5
  import { DeployOutcome, } from "./merge-request-deploy-model.js";
6
6
  /** The install resource key that holds config_SpeedKit.js. */
@@ -34,28 +34,39 @@ export class MergeRequestDeployService {
34
34
  baseReader;
35
35
  liveStateCheck;
36
36
  approvalCheck;
37
+ deviceDetectionCheck;
38
+ policy;
37
39
  configApi;
38
40
  files;
39
41
  configName;
40
42
  deployService;
41
- constructor(context, request, repository, baseReader, liveStateCheck, approvalCheck, configApi, files, configName, deployService) {
43
+ constructor(context, request, repository, baseReader, liveStateCheck, approvalCheck, deviceDetectionCheck, policy, configApi, files, configName, deployService) {
42
44
  this.context = context;
43
45
  this.request = request;
44
46
  this.repository = repository;
45
47
  this.baseReader = baseReader;
46
48
  this.liveStateCheck = liveStateCheck;
47
49
  this.approvalCheck = approvalCheck;
50
+ this.deviceDetectionCheck = deviceDetectionCheck;
51
+ this.policy = policy;
48
52
  this.configApi = configApi;
49
53
  this.files = files;
50
54
  this.configName = configName;
51
55
  this.deployService = deployService;
52
56
  }
53
- /** Plans the deploy and runs it while the plan allows it. */
54
- async run() {
57
+ /**
58
+ * Plans the deploy and runs it while the plan allows it.
59
+ *
60
+ * @param confirmsDeviceDetection - whether a person confirmed that the
61
+ * device detection change of the plan goes live. Without it, such a change
62
+ * stops the deploy.
63
+ */
64
+ async run(confirmsDeviceDetection = false) {
55
65
  const plan = await this.plan();
56
66
  if (plan.outcome !== DeployOutcome.Deployable) {
57
67
  return plan;
58
68
  }
69
+ this.policy.confirmsDeviceDetection = confirmsDeviceDetection;
59
70
  return this.deploy(plan.notDeployed);
60
71
  }
61
72
  /**
@@ -74,9 +85,15 @@ export class MergeRequestDeployService {
74
85
  }
75
86
  const notDeployed = this.notDeployed(changedPaths);
76
87
  const blocked = await this.blockingState(directory);
77
- return blocked
78
- ? { ...blocked, notDeployed }
79
- : { ...this.result(DeployOutcome.Deployable), notDeployed };
88
+ if (blocked) {
89
+ return { ...blocked, notDeployed };
90
+ }
91
+ const deviceDetectionChanges = await this.deviceDetectionCheck.changes();
92
+ return {
93
+ ...this.result(DeployOutcome.Deployable),
94
+ notDeployed,
95
+ ...(deviceDetectionChanges.length > 0 && { deviceDetectionChanges }),
96
+ };
80
97
  }
81
98
  /** The reason that stops the deploy before it writes anything, if any. */
82
99
  async blockingState(directory) {
@@ -29,6 +29,13 @@ export declare class AutoDeployPolicy implements DeployPolicyInterface {
29
29
  * the merge request already answers it.
30
30
  */
31
31
  private readonly cli?;
32
+ /**
33
+ * Whether a person confirmed that the device detection change goes live.
34
+ *
35
+ * A bulk run asks this after its plan, so the answer arrives after the
36
+ * policy is built.
37
+ */
38
+ confirmsDeviceDetection: boolean;
32
39
  constructor(description: string, approval: ApprovalAnswer,
33
40
  /**
34
41
  * The person who watches this deploy, if any.
@@ -22,6 +22,13 @@ export class AutoDeployPolicy {
22
22
  description;
23
23
  approval;
24
24
  cli;
25
+ /**
26
+ * Whether a person confirmed that the device detection change goes live.
27
+ *
28
+ * A bulk run asks this after its plan, so the answer arrives after the
29
+ * policy is built.
30
+ */
31
+ confirmsDeviceDetection = false;
25
32
  constructor(description, approval,
26
33
  /**
27
34
  * The person who watches this deploy, if any.
@@ -62,6 +69,9 @@ export class AutoDeployPolicy {
62
69
  case DeployQuestion.ActivateAsTesting: {
63
70
  return this.approval === ApprovalAnswer.Testing;
64
71
  }
72
+ case DeployQuestion.DeviceDetectionChange: {
73
+ return this.confirmsDeviceDetection;
74
+ }
65
75
  // Decisions a merge request never carries.
66
76
  default: {
67
77
  return false;
@@ -53,7 +53,7 @@ function cliAnswering(confirmed, selected = ApprovalAnswer.Skip) {
53
53
  return { cli, questions };
54
54
  }
55
55
  /** A deploy that plans as told, and records what was deployed. */
56
- function deployFactory(plans, deployed, failing = []) {
56
+ function deployFactory(plans, deployed, failing = [], changingDevice = []) {
57
57
  return {
58
58
  build: async (config, answers) => {
59
59
  const name = `${config.directory}[${config.configName}]`;
@@ -67,9 +67,14 @@ function deployFactory(plans, deployed, failing = []) {
67
67
  reason: answers.description,
68
68
  });
69
69
  return {
70
- plan: async () => result(plans[name] ?? DeployOutcome.Deployable),
71
- run: async () => {
72
- deployed.push(name);
70
+ plan: async () => ({
71
+ ...result(plans[name] ?? DeployOutcome.Deployable),
72
+ ...(changingDevice.includes(name) && {
73
+ deviceDetectionChanges: ["config_SpeedKit.detectDevice"],
74
+ }),
75
+ }),
76
+ run: async (confirmsDeviceDetection) => {
77
+ deployed.push(confirmsDeviceDetection ? `${name} with its device` : name);
73
78
  return result(DeployOutcome.Applied);
74
79
  },
75
80
  };
@@ -154,4 +159,20 @@ describe("BulkDeployService", () => {
154
159
  await serviceOf(["customers/gohaus/config_SpeedKit.js"], deployFactory({}, []), cli).run();
155
160
  expect(questions).to.deep.equal(["Deploy 1 configuration(s) of !8017?"]);
156
161
  });
162
+ it("deploys a device detection change once QA confirmed it", async () => {
163
+ const deployed = [];
164
+ const { cli, questions } = cliAnswering(true);
165
+ await serviceOf(["customers/gohaus/config_SpeedKit.js"], deployFactory({}, deployed, [], ["customers/gohaus[production]"]), cli, ApprovalAnswer.Approved).run();
166
+ expect(questions[0]).to.contain("checked by QA");
167
+ expect(deployed).to.deep.equal([
168
+ "customers/gohaus[production] with its device",
169
+ ]);
170
+ });
171
+ it("skips a device detection change that QA did not confirm", async () => {
172
+ const deployed = [];
173
+ const { cli } = cliAnswering(false);
174
+ const results = await serviceOf(["customers/gohaus/config_SpeedKit.js"], deployFactory({}, deployed, [], ["customers/gohaus[production]"]), cli, ApprovalAnswer.Approved).run();
175
+ expect(deployed).to.deep.equal([]);
176
+ expect(results[0].reason).to.equal("the device detection change was not confirmed");
177
+ });
157
178
  });
@@ -78,4 +78,9 @@ describe("AutoDeployPolicy", () => {
78
78
  it("describes the installation with the merge request", async () => {
79
79
  expect(await policy(ApprovalAnswer.Approved).text(DeployQuestion.Description)).to.equal("!42 a reviewed change");
80
80
  });
81
+ it("confirms a device detection change once a person confirmed it", async () => {
82
+ const confirmed = policy(ApprovalAnswer.Approved);
83
+ confirmed.confirmsDeviceDetection = true;
84
+ expect(await confirmed.confirm(DeployQuestion.DeviceDetectionChange)).to.equal(true);
85
+ });
81
86
  });
@@ -1927,5 +1927,5 @@
1927
1927
  ]
1928
1928
  }
1929
1929
  },
1930
- "version": "4.45.2"
1930
+ "version": "4.46.0"
1931
1931
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "4.45.2",
4
+ "version": "4.46.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"