@speedkit/cli 4.45.2 → 4.47.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 +14 -0
- package/dist/services/deploy/bulk/bulk-deploy-service.d.ts +9 -0
- package/dist/services/deploy/bulk/bulk-deploy-service.js +43 -7
- package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.d.ts +7 -0
- package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.js +22 -13
- package/dist/services/deploy/mr/merge-request-deploy-model.d.ts +2 -0
- package/dist/services/deploy/mr/merge-request-deploy-service-factory.js +7 -3
- package/dist/services/deploy/mr/merge-request-deploy-service.d.ts +13 -3
- package/dist/services/deploy/mr/merge-request-deploy-service.js +24 -7
- package/dist/services/deploy/policy/auto-deploy-policy.d.ts +7 -0
- package/dist/services/deploy/policy/auto-deploy-policy.js +10 -0
- package/dist/services/deploy/spec/bulk/bulk-deploy-service.spec.js +40 -7
- package/dist/services/deploy/spec/policy/auto-deploy-policy.spec.js +5 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [4.47.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.46.0...v4.47.0) (2026-10-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **bulk-deploy:** count a configuration that is live already as deployed ([c8a3e11](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/c8a3e11460bd13dc6c46a16ca5551aa80213c1e1))
|
|
7
|
+
|
|
8
|
+
# [4.46.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.45.2...v4.46.0) (2026-10-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **bulk-deploy:** ask once whether QA checked the device detection changes ([dda8bbd](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/dda8bbd390b1655349747bd3bb7fe333c047d294))
|
|
14
|
+
|
|
1
15
|
## [4.45.2](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.45.1...v4.45.2) (2026-10-16)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -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);
|
|
@@ -158,10 +191,13 @@ export class BulkDeployService {
|
|
|
158
191
|
/** The summary of the run, and everything a developer has to take over. */
|
|
159
192
|
summarize(planned) {
|
|
160
193
|
const results = planned.map((entry) => entry.result);
|
|
161
|
-
|
|
194
|
+
// A configuration that already carries the merge request is deployed too.
|
|
195
|
+
const isLive = (result) => result.outcome === DeployOutcome.Applied ||
|
|
196
|
+
result.outcome === DeployOutcome.AlreadyDeployed;
|
|
197
|
+
const live = results.filter(isLive);
|
|
162
198
|
// Without a deploy the plan above already is the summary.
|
|
163
|
-
if (
|
|
164
|
-
this.writeTable("Summary", planned.filter((entry) => entry.result
|
|
199
|
+
if (results.some((result) => result.outcome === DeployOutcome.Applied)) {
|
|
200
|
+
this.writeTable("Summary", planned.filter((entry) => !isLive(entry.result)));
|
|
165
201
|
}
|
|
166
202
|
const byHand = results.flatMap((result) => result.notDeployed ?? []);
|
|
167
203
|
if (byHand.length > 0) {
|
|
@@ -169,7 +205,7 @@ export class BulkDeployService {
|
|
|
169
205
|
this.cli.code([...new Set(byHand)].join(", "));
|
|
170
206
|
}
|
|
171
207
|
this.cli.spacer();
|
|
172
|
-
this.cli.write(`${
|
|
208
|
+
this.cli.write(`${live.length} of ${results.length} configuration(s) deployed`);
|
|
173
209
|
return results;
|
|
174
210
|
}
|
|
175
211
|
writeTable(title, planned) {
|
|
@@ -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
|
-
|
|
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
|
|
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
|
-
})
|
|
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.
|
|
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
|
-
/**
|
|
31
|
-
|
|
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
|
-
/**
|
|
54
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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;
|
|
@@ -32,12 +32,14 @@ function writeCustomer(directory, config) {
|
|
|
32
32
|
/** A CLI that answers every question the same way, and records them. */
|
|
33
33
|
function cliAnswering(confirmed, selected = ApprovalAnswer.Skip) {
|
|
34
34
|
const questions = [];
|
|
35
|
+
const written = [];
|
|
36
|
+
const tables = [];
|
|
35
37
|
const cli = {
|
|
36
38
|
spacer: () => undefined,
|
|
37
|
-
write: () =>
|
|
39
|
+
write: (line) => written.push(line),
|
|
38
40
|
writeWarning: () => undefined,
|
|
39
41
|
code: () => undefined,
|
|
40
|
-
table: () =>
|
|
42
|
+
table: (rows) => tables.push(rows),
|
|
41
43
|
startAction: () => undefined,
|
|
42
44
|
successAction: () => undefined,
|
|
43
45
|
prompt: async () => "a description",
|
|
@@ -50,10 +52,10 @@ function cliAnswering(confirmed, selected = ApprovalAnswer.Skip) {
|
|
|
50
52
|
return selected;
|
|
51
53
|
},
|
|
52
54
|
};
|
|
53
|
-
return { cli, questions };
|
|
55
|
+
return { cli, questions, written, tables };
|
|
54
56
|
}
|
|
55
57
|
/** A deploy that plans as told, and records what was deployed. */
|
|
56
|
-
function deployFactory(plans, deployed, failing = []) {
|
|
58
|
+
function deployFactory(plans, deployed, failing = [], changingDevice = []) {
|
|
57
59
|
return {
|
|
58
60
|
build: async (config, answers) => {
|
|
59
61
|
const name = `${config.directory}[${config.configName}]`;
|
|
@@ -67,9 +69,14 @@ function deployFactory(plans, deployed, failing = []) {
|
|
|
67
69
|
reason: answers.description,
|
|
68
70
|
});
|
|
69
71
|
return {
|
|
70
|
-
plan: async () =>
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
plan: async () => ({
|
|
73
|
+
...result(plans[name] ?? DeployOutcome.Deployable),
|
|
74
|
+
...(changingDevice.includes(name) && {
|
|
75
|
+
deviceDetectionChanges: ["config_SpeedKit.detectDevice"],
|
|
76
|
+
}),
|
|
77
|
+
}),
|
|
78
|
+
run: async (confirmsDeviceDetection) => {
|
|
79
|
+
deployed.push(confirmsDeviceDetection ? `${name} with its device` : name);
|
|
73
80
|
return result(DeployOutcome.Applied);
|
|
74
81
|
},
|
|
75
82
|
};
|
|
@@ -154,4 +161,30 @@ describe("BulkDeployService", () => {
|
|
|
154
161
|
await serviceOf(["customers/gohaus/config_SpeedKit.js"], deployFactory({}, []), cli).run();
|
|
155
162
|
expect(questions).to.deep.equal(["Deploy 1 configuration(s) of !8017?"]);
|
|
156
163
|
});
|
|
164
|
+
it("deploys a device detection change once QA confirmed it", async () => {
|
|
165
|
+
const deployed = [];
|
|
166
|
+
const { cli, questions } = cliAnswering(true);
|
|
167
|
+
await serviceOf(["customers/gohaus/config_SpeedKit.js"], deployFactory({}, deployed, [], ["customers/gohaus[production]"]), cli, ApprovalAnswer.Approved).run();
|
|
168
|
+
expect(questions[0]).to.contain("checked by QA");
|
|
169
|
+
expect(deployed).to.deep.equal([
|
|
170
|
+
"customers/gohaus[production] with its device",
|
|
171
|
+
]);
|
|
172
|
+
});
|
|
173
|
+
it("skips a device detection change that QA did not confirm", async () => {
|
|
174
|
+
const deployed = [];
|
|
175
|
+
const { cli } = cliAnswering(false);
|
|
176
|
+
const results = await serviceOf(["customers/gohaus/config_SpeedKit.js"], deployFactory({}, deployed, [], ["customers/gohaus[production]"]), cli, ApprovalAnswer.Approved).run();
|
|
177
|
+
expect(deployed).to.deep.equal([]);
|
|
178
|
+
expect(results[0].reason).to.equal("the device detection change was not confirmed");
|
|
179
|
+
});
|
|
180
|
+
it("counts a configuration that is live already as deployed", async () => {
|
|
181
|
+
const { cli, written, tables } = cliAnswering(true);
|
|
182
|
+
await serviceOf([
|
|
183
|
+
"customers/gohaus/config_SpeedKit.js",
|
|
184
|
+
"customers/bonprix/config_SpeedKit.js",
|
|
185
|
+
], deployFactory({ "customers/bonprix[production]": DeployOutcome.AlreadyDeployed }, []), cli, ApprovalAnswer.Approved).run();
|
|
186
|
+
expect(written.at(-1)).to.equal("2 of 2 configuration(s) deployed");
|
|
187
|
+
// The plan is the one table: the summary leaves out every live config.
|
|
188
|
+
expect(tables).to.have.length(1);
|
|
189
|
+
});
|
|
157
190
|
});
|
|
@@ -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
|
});
|
package/oclif.manifest.json
CHANGED