@speedkit/cli 4.35.1 → 4.36.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +42 -7
  3. package/dist/commands/bulk-deploy.d.ts +19 -0
  4. package/dist/commands/bulk-deploy.js +52 -0
  5. package/dist/commands/deploy.d.ts +2 -0
  6. package/dist/commands/deploy.js +32 -2
  7. package/dist/services/cli/cli-service.js +42 -2
  8. package/dist/services/cli/cli-service.spec.js +41 -0
  9. package/dist/services/deploy/bulk/bulk-deploy-model.d.ts +46 -0
  10. package/dist/services/deploy/bulk/bulk-deploy-model.js +27 -0
  11. package/dist/services/deploy/bulk/bulk-deploy-service-factory.d.ts +11 -0
  12. package/dist/services/deploy/bulk/bulk-deploy-service-factory.js +24 -0
  13. package/dist/services/deploy/bulk/bulk-deploy-service.d.ts +47 -0
  14. package/dist/services/deploy/bulk/bulk-deploy-service.js +201 -0
  15. package/dist/services/deploy/bulk/bulk-deploy-service.spec.d.ts +1 -0
  16. package/dist/services/deploy/bulk/bulk-deploy-service.spec.js +146 -0
  17. package/dist/services/deploy/bulk/config-deploy-factory.d.ts +13 -0
  18. package/dist/services/deploy/bulk/config-deploy-factory.js +20 -0
  19. package/dist/services/deploy/bulk/index.d.ts +5 -0
  20. package/dist/services/deploy/bulk/index.js +5 -0
  21. package/dist/services/deploy/bulk/touched-configs.d.ts +12 -0
  22. package/dist/services/deploy/bulk/touched-configs.js +54 -0
  23. package/dist/services/deploy/bulk/touched-configs.spec.d.ts +1 -0
  24. package/dist/services/deploy/bulk/touched-configs.spec.js +77 -0
  25. package/dist/services/deploy/checks/activation/customer-approval-check.d.ts +3 -1
  26. package/dist/services/deploy/checks/activation/customer-approval-check.js +5 -2
  27. package/dist/services/deploy/checks/activation/customer-approval-check.spec.js +18 -15
  28. package/dist/services/deploy/checks/post-deploy/deprecated-deployment-detection-check.d.ts +3 -1
  29. package/dist/services/deploy/checks/post-deploy/deprecated-deployment-detection-check.js +6 -3
  30. package/dist/services/deploy/checks/post-deploy/save-files-check.d.ts +3 -1
  31. package/dist/services/deploy/checks/post-deploy/save-files-check.js +5 -2
  32. package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.d.ts +3 -1
  33. package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.js +9 -5
  34. package/dist/services/deploy/checks/pre-deploy/split-change-check.d.ts +3 -1
  35. package/dist/services/deploy/checks/pre-deploy/split-change-check.js +8 -5
  36. package/dist/services/deploy/checks/pre-deploy/split-change-check.spec.d.ts +1 -0
  37. package/dist/services/deploy/checks/pre-deploy/split-change-check.spec.js +55 -0
  38. package/dist/services/deploy/context/deploy-context.d.ts +21 -1
  39. package/dist/services/deploy/context/deploy-context.js +30 -1
  40. package/dist/services/deploy/deploy-service-factory.d.ts +13 -1
  41. package/dist/services/deploy/deploy-service-factory.js +36 -15
  42. package/dist/services/deploy/error/deploy-aborted-error.d.ts +12 -0
  43. package/dist/services/deploy/error/deploy-aborted-error.js +16 -0
  44. package/dist/services/deploy/handler/customer-config-handler.d.ts +3 -1
  45. package/dist/services/deploy/handler/customer-config-handler.js +11 -7
  46. package/dist/services/deploy/handler/install-resource-handler.d.ts +3 -1
  47. package/dist/services/deploy/handler/install-resource-handler.js +12 -7
  48. package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.d.ts +3 -1
  49. package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.js +5 -2
  50. package/dist/services/deploy/handler/module-handler.d.ts +3 -1
  51. package/dist/services/deploy/handler/module-handler.js +7 -4
  52. package/dist/services/deploy/handler/module-handler.spec.d.ts +1 -0
  53. package/dist/services/deploy/handler/module-handler.spec.js +49 -0
  54. package/dist/services/deploy/handler/server-config-handler.d.ts +3 -1
  55. package/dist/services/deploy/handler/server-config-handler.js +6 -3
  56. package/dist/services/deploy/mr/base-config-reader.d.ts +25 -0
  57. package/dist/services/deploy/mr/base-config-reader.js +52 -0
  58. package/dist/services/deploy/mr/index.d.ts +6 -0
  59. package/dist/services/deploy/mr/index.js +6 -0
  60. package/dist/services/deploy/mr/live-state-check.d.ts +38 -0
  61. package/dist/services/deploy/mr/live-state-check.js +81 -0
  62. package/dist/services/deploy/mr/live-state-check.spec.d.ts +1 -0
  63. package/dist/services/deploy/mr/live-state-check.spec.js +74 -0
  64. package/dist/services/deploy/mr/merge-request-deploy-model.d.ts +59 -0
  65. package/dist/services/deploy/mr/merge-request-deploy-model.js +50 -0
  66. package/dist/services/deploy/mr/merge-request-deploy-service-factory.d.ts +20 -0
  67. package/dist/services/deploy/mr/merge-request-deploy-service-factory.js +46 -0
  68. package/dist/services/deploy/mr/merge-request-deploy-service.d.ts +61 -0
  69. package/dist/services/deploy/mr/merge-request-deploy-service.js +189 -0
  70. package/dist/services/deploy/mr/merge-request-description.d.ts +16 -0
  71. package/dist/services/deploy/mr/merge-request-description.js +27 -0
  72. package/dist/services/deploy/mr/merge-request-description.spec.d.ts +1 -0
  73. package/dist/services/deploy/mr/merge-request-description.spec.js +55 -0
  74. package/dist/services/deploy/policy/auto-deploy-policy.d.ts +43 -0
  75. package/dist/services/deploy/policy/auto-deploy-policy.js +77 -0
  76. package/dist/services/deploy/policy/auto-deploy-policy.spec.d.ts +1 -0
  77. package/dist/services/deploy/policy/auto-deploy-policy.spec.js +83 -0
  78. package/dist/services/deploy/policy/deploy-policy-model.d.ts +61 -0
  79. package/dist/services/deploy/policy/deploy-policy-model.js +41 -0
  80. package/dist/services/deploy/policy/index.d.ts +2 -0
  81. package/dist/services/deploy/policy/index.js +2 -0
  82. package/dist/services/deploy/policy/interactive-deploy-policy.d.ts +15 -0
  83. package/dist/services/deploy/policy/interactive-deploy-policy.js +16 -0
  84. package/dist/services/diff/diff-model.d.ts +5 -1
  85. package/dist/services/diff/diff-model.js +5 -1
  86. package/dist/services/diff/diff-service-factory.js +1 -1
  87. package/dist/services/diff/diff-service.d.ts +2 -1
  88. package/dist/services/diff/diff-service.js +6 -4
  89. package/dist/services/git/git-repository-model.d.ts +13 -0
  90. package/dist/services/git/git-repository-model.js +1 -0
  91. package/dist/services/git/git-repository.d.ts +35 -0
  92. package/dist/services/git/git-repository.js +120 -0
  93. package/dist/services/git/git-repository.spec.d.ts +1 -0
  94. package/dist/services/git/git-repository.spec.js +87 -0
  95. package/dist/services/git/index.d.ts +2 -0
  96. package/dist/services/git/index.js +2 -0
  97. package/dist/services/integration-api/spec/speed-kit-config-file.spec.js +1 -1
  98. package/oclif.manifest.json +140 -34
  99. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ # [4.36.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.35.1...v4.36.0) (2026-09-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deploy:** activate a customer that needs no approval in auto mode ([8a8944f](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/8a8944f77fe83fd576a64224ba383789d4796ba2))
7
+ * **deploy:** upload only the modules that were confirmed ([fd957ea](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/fd957ea0da9ec94e7e71cc63598cae4ac242d5b1))
8
+
9
+
10
+ ### Features
11
+
12
+ * **cli:** size the table columns to the terminal ([c7fe39a](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/c7fe39a96beab87d5e4d299e095f2f2b398a0dc1))
13
+ * **deploy:** ask for the description of a merge request deploy ([c191f3c](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/c191f3c7f7ec3bfe4e5b152f9cd84245552d3cb2))
14
+ * **deploy:** deploy every config of a merge request with sk deploy-mr ([8752f0a](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/8752f0a8b9f48cd55d908bc0ab6d43f3c205896a))
15
+ * **deploy:** deploy only the production config of a merge request ([6ce8baa](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/6ce8baac58332040f6befd1c00ee20a3471d6111))
16
+ * **deploy:** deploy the reviewed change of a merged merge request ([697518a](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/697518a4a667b7a07a31c69d9203243283c805c4))
17
+ * **deploy:** leave out the reason column while no row has one ([0aa276b](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/0aa276bb1553bb887c81aa0b6f7f477893aa3637))
18
+ * **deploy:** leave the checks after the upload to a single deploy ([0a63fc6](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/0a63fc695e98978371e0458612098ba8fca0d2b5))
19
+ * **deploy:** let a deploy run without a person ([9cd7d48](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/9cd7d488a08463edfc8d5e75f8ebc84728bbb9e3))
20
+ * **deploy:** review a merge request deploy in the diff tool ([f45d1f1](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/f45d1f10174ce4680207b4080a764b47395251d9))
21
+ * **git:** find a merged merge request in the local history ([06f641b](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/06f641bc3a302f117b898bc1d480dd72859e2f9b))
22
+
1
23
  ## [4.35.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.35.0...v4.35.1) (2026-09-24)
2
24
 
3
25
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @speedkit/cli
21
21
  $ sk COMMAND
22
22
  running command...
23
23
  $ sk (--version)
24
- @speedkit/cli/4.35.1 linux-x64 node-v22.23.3
24
+ @speedkit/cli/4.36.0 linux-x64 node-v22.23.3
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -74,6 +74,7 @@ By either...
74
74
  * [`sk browser update`](#sk-browser-update)
75
75
  * [`sk build-parameter-query CUSTOMERPATH`](#sk-build-parameter-query-customerpath)
76
76
  * [`sk build-prewarm-query CUSTOMERPATH`](#sk-build-prewarm-query-customerpath)
77
+ * [`sk bulk-deploy MR`](#sk-bulk-deploy-mr)
77
78
  * [`sk config edit`](#sk-config-edit)
78
79
  * [`sk config setup`](#sk-config-setup)
79
80
  * [`sk deploy CUSTOMERPATH`](#sk-deploy-customerpath)
@@ -369,6 +370,35 @@ EXAMPLES
369
370
  $ sk query prewarm customers/decathlon.de --count
370
371
  ```
371
372
 
373
+ ## `sk bulk-deploy MR`
374
+
375
+ Deploys the production config of every customer of a merged merge request at once. Use sk deploy --mr for a single customer
376
+
377
+ ```
378
+ USAGE
379
+ $ sk bulk-deploy MR [-r <value>] [--approval approved|testing|skip] [--description <value>] [-d] [-y]
380
+
381
+ ARGUMENTS
382
+ MR The number of the merged merge request
383
+
384
+ FLAGS
385
+ -d, --dryRun dry run
386
+ -r, --repository=<value> [default: .] A path in the repository that holds the customer configs
387
+ -y, --yes deploy the plan without the confirmation
388
+ --approval=<option> what to do with a customer that approves every rollout themselves
389
+ <options: approved|testing|skip>
390
+ --description=<value> the description every installation of the run gets, asked while it is left out
391
+
392
+ DESCRIPTION
393
+ Deploys the production config of every customer of a merged merge request at once. Use sk deploy --mr for a single
394
+ customer
395
+
396
+ EXAMPLES
397
+ $ sk bulk-deploy 8017
398
+
399
+ $ sk bulk-deploy 8017 -r ../sk-onboarding --approval testing
400
+ ```
401
+
372
402
  ## `sk config edit`
373
403
 
374
404
  Edit cli config
@@ -410,17 +440,22 @@ Deploys the specified customer config while comparing to the live version before
410
440
 
411
441
  ```
412
442
  USAGE
413
- $ sk deploy CUSTOMERPATH [-c <value>] [-t] [-d] [-v] [-a <value>]
443
+ $ sk deploy CUSTOMERPATH [-c <value>] [-t] [-d] [-v] [-a <value>] [--description <value> --mr <value>]
444
+ [--approval approved|testing|skip ]
414
445
 
415
446
  ARGUMENTS
416
447
  CUSTOMERPATH The customer config path
417
448
 
418
449
  FLAGS
419
- -a, --artifacts=<value> which files to upload
420
- -c, --configName=<value> [default: production] The costumer config name
421
- -d, --dryRun dry run
422
- -t, --useTestConfig Override app with configured testApp
423
- -v, --verboseLevel Show all messages
450
+ -a, --artifacts=<value> which files to upload
451
+ -c, --configName=<value> [default: production] The costumer config name
452
+ -d, --dryRun dry run
453
+ -t, --useTestConfig Override app with configured testApp
454
+ -v, --verboseLevel Show all messages
455
+ --approval=<option> [default: skip] what to do with a customer that approves every rollout themselves
456
+ <options: approved|testing|skip>
457
+ --description=<value> the description every installation of the run gets, asked while it is left out
458
+ --mr=<value> deploy the reviewed change of this merged merge request, without questions
424
459
 
425
460
  DESCRIPTION
426
461
  Deploys the specified customer config while comparing to the live version before
@@ -0,0 +1,19 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class BulkDeploy extends Command {
3
+ static args: {
4
+ mr: import("@oclif/core/interfaces").Arg<number, {
5
+ max?: number;
6
+ min?: number;
7
+ }>;
8
+ };
9
+ static description: string;
10
+ static flags: {
11
+ repository: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ approval: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ description: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ dryRun: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ };
17
+ static examples: string[];
18
+ run(): Promise<void>;
19
+ }
@@ -0,0 +1,52 @@
1
+ import { Args, Command, Flags } from "@oclif/core";
2
+ import { CliConfig } from "../helpers/cli-config.js";
3
+ import { BulkDeployContext, BulkDeployServiceFactory, } from "../services/deploy/bulk/index.js";
4
+ import { DeployOutcome } from "../services/deploy/mr/index.js";
5
+ export default class BulkDeploy extends Command {
6
+ static args = {
7
+ mr: Args.integer({
8
+ name: "mr",
9
+ required: true,
10
+ description: "The number of the merged merge request",
11
+ }),
12
+ };
13
+ static description = "Deploys the production config of every customer of a merged merge request at once. Use sk deploy --mr for a single customer";
14
+ static flags = {
15
+ repository: Flags.directory({
16
+ char: "r",
17
+ default: ".",
18
+ description: "A path in the repository that holds the customer configs",
19
+ }),
20
+ approval: Flags.string({
21
+ options: ["approved", "testing", "skip"],
22
+ description: "what to do with a customer that approves every rollout themselves",
23
+ }),
24
+ description: Flags.string({
25
+ description: "the description every installation of the run gets, asked while it is left out",
26
+ }),
27
+ dryRun: Flags.boolean({
28
+ char: "d",
29
+ default: false,
30
+ description: "dry run",
31
+ }),
32
+ yes: Flags.boolean({
33
+ char: "y",
34
+ default: false,
35
+ description: "deploy the plan without the confirmation",
36
+ }),
37
+ };
38
+ static examples = [
39
+ "$ sk bulk-deploy 8017",
40
+ "$ sk bulk-deploy 8017 -r ../sk-onboarding --approval testing",
41
+ ];
42
+ async run() {
43
+ const { args: { mr }, flags: { repository, approval, description, dryRun, yes }, } = await this.parse(BulkDeploy);
44
+ const service = new BulkDeployServiceFactory(new BulkDeployContext(repository, mr, approval, description, dryRun, yes), new CliConfig(this.config).load()).getService();
45
+ const results = await service.run();
46
+ // A failure of one configuration is a failure of the run, so a pipeline
47
+ // that calls this command sees it.
48
+ if (results.some((result) => result.outcome === DeployOutcome.Failed)) {
49
+ this.exit(1);
50
+ }
51
+ }
52
+ }
@@ -9,4 +9,6 @@ export default class Deploy extends Command {
9
9
  static description: string;
10
10
  static examples: string[];
11
11
  run(): Promise<void>;
12
+ /** Deploys the change of a merged merge request, without asking anybody. */
13
+ private deployMergeRequest;
12
14
  }
@@ -3,6 +3,8 @@ import { CliConfig } from "../helpers/cli-config.js";
3
3
  import { CLI_CUSTOMER_CONFIG, CLIParameters, CLIParametersChar, CLIParametersExample, } from "../models/cli-parameters.js";
4
4
  import DeployContext from "../services/deploy/context/deploy-context.js";
5
5
  import DeployServiceFactory from "../services/deploy/deploy-service-factory.js";
6
+ import { DeployAbortedError } from "../services/deploy/error/deploy-aborted-error.js";
7
+ import { MergeRequestDeployContext, MergeRequestDeployServiceFactory, } from "../services/deploy/mr/index.js";
6
8
  export default class Deploy extends Command {
7
9
  static args = CLI_CUSTOMER_CONFIG;
8
10
  static flags = DeployContext.flags;
@@ -12,9 +14,37 @@ export default class Deploy extends Command {
12
14
  `$ sk deploy ${CLIParametersExample.CustomerPath} -${CLIParametersChar.ConfigName} ${CLIParametersExample.ConfigName} -${CLIParametersChar.SlackToken} ${CLIParametersExample.SlackToken} -${CLIParametersChar.Artifacts} ${CLIParametersExample.Artifacts} -${CLIParametersChar.DryRun}`,
13
15
  ];
14
16
  async run() {
15
- const { args: { customerPath }, flags: { artifacts, configName, dryRun, useTestConfig }, } = await this.parse(Deploy);
17
+ const { args: { customerPath }, flags: { artifacts, configName, dryRun, useTestConfig, mr, approval, description, }, } = await this.parse(Deploy);
18
+ if (mr) {
19
+ await this.deployMergeRequest(customerPath, configName, mr, approval, description, dryRun);
20
+ return;
21
+ }
16
22
  const deployContext = new DeployContext(customerPath, configName, artifacts, dryRun, useTestConfig);
17
23
  const deployService = await new DeployServiceFactory(deployContext, new CliConfig(this.config).load()).buildService();
18
- await deployService.run();
24
+ try {
25
+ await deployService.run();
26
+ }
27
+ catch (error) {
28
+ // An answer of no stops the deploy, but it is not a failure.
29
+ if (error instanceof DeployAbortedError) {
30
+ this.log(`Deploy stopped: ${error.reason}`);
31
+ return;
32
+ }
33
+ throw error;
34
+ }
35
+ }
36
+ /** Deploys the change of a merged merge request, without asking anybody. */
37
+ async deployMergeRequest(customerPath, configName, iid, approval, description, dryRun) {
38
+ const service = await new MergeRequestDeployServiceFactory(new MergeRequestDeployContext(customerPath, configName, iid, approval, description, dryRun, false,
39
+ // A person at the keyboard reviews the change in their diff tool.
40
+ Boolean(process.stdout.isTTY)), new CliConfig(this.config).load()).buildService();
41
+ const result = await service.run();
42
+ this.log(`${result.configName}: ${result.outcome}`);
43
+ if (result.reason) {
44
+ this.log(` ${result.reason}`);
45
+ }
46
+ if (result.notDeployed?.length > 0) {
47
+ this.log(` deploy by hand: ${result.notDeployed.join(", ")}`);
48
+ }
19
49
  }
20
50
  }
@@ -18,6 +18,43 @@ import ApplicationError from "../error-handling/error/application-error.js";
18
18
  function canAnimate() {
19
19
  return Boolean(!process.env.CI && process.stderr && process.stderr.isTTY);
20
20
  }
21
+ /** The padding and the gutter that a table draws inside every column. */
22
+ const CELL_OVERHEAD = 3;
23
+ /** The left margin and the outer borders of a table. */
24
+ const TABLE_OVERHEAD = 3;
25
+ /** No column is squeezed below this, so a short name stays readable. */
26
+ const MIN_COLUMN_WIDTH = 8;
27
+ /**
28
+ * Column widths that fit the terminal.
29
+ *
30
+ * Every column starts with the width of its widest cell. While the table is
31
+ * wider than the terminal, the column with the most room to give gives way,
32
+ * so one long text does not squeeze every other column to single letters.
33
+ */
34
+ function columnWidths(entries, rows) {
35
+ const content = entries.map(([key, column], index) => Math.max((column?.header ?? key).length, column?.minWidth ?? 0, ...rows.map((row) => row[index].length)));
36
+ const widths = content.map((width) => width + CELL_OVERHEAD);
37
+ const floors = entries.map(([key, column], index) => Math.min(widths[index], CELL_OVERHEAD +
38
+ Math.max(MIN_COLUMN_WIDTH, column?.minWidth ?? 0, (column?.header ?? key).length)));
39
+ const available = (process.stdout.columns || 120) - entries.length - TABLE_OVERHEAD;
40
+ let excess = widths.reduce((total, width) => total + width, 0) - available;
41
+ while (excess > 0) {
42
+ let widest = -1;
43
+ let slack = 0;
44
+ for (const [index, width] of widths.entries()) {
45
+ if (width - floors[index] > slack) {
46
+ slack = width - floors[index];
47
+ widest = index;
48
+ }
49
+ }
50
+ if (widest === -1) {
51
+ break;
52
+ }
53
+ widths[widest] -= 1;
54
+ excess -= 1;
55
+ }
56
+ return widths;
57
+ }
21
58
  export class CliService {
22
59
  quiet;
23
60
  style;
@@ -185,13 +222,16 @@ export class CliService {
185
222
  }
186
223
  table(data, columns) {
187
224
  this.spacer();
188
- const header = Object.entries(columns).map(([key, col]) => ({
225
+ const entries = Object.entries(columns);
226
+ const rows = data.map((row) => entries.map(([key, col]) => String(col?.get ? col.get(row) : (row[key] ?? ""))));
227
+ const widths = columnWidths(entries, rows);
228
+ const header = entries.map(([key, col], index) => ({
189
229
  value: key,
190
230
  alias: col?.header,
191
231
  align: "left",
192
232
  headerAlign: "left",
233
+ width: widths[index],
193
234
  }));
194
- const rows = data.map((row) => Object.entries(columns).map(([key, col]) => String(col?.get ? col.get(row) : (row[key] ?? ""))));
195
235
  const t = Table(header, rows, { compact: true });
196
236
  console.log(t.render());
197
237
  this.spacer();
@@ -65,3 +65,44 @@ describe("CliService actions without a terminal", () => {
65
65
  expect(lines).to.have.lengthOf(0);
66
66
  });
67
67
  });
68
+ describe("CliService table", () => {
69
+ let columns;
70
+ beforeEach(() => {
71
+ columns = process.stdout.columns;
72
+ Object.defineProperty(process.stdout, "columns", {
73
+ value: 80,
74
+ configurable: true,
75
+ });
76
+ });
77
+ afterEach(() => {
78
+ Object.defineProperty(process.stdout, "columns", {
79
+ value: columns,
80
+ configurable: true,
81
+ });
82
+ });
83
+ /** A row whose last column is far too long for any terminal. */
84
+ const row = {
85
+ customer: "carhartt-wip-new",
86
+ outcome: "alreadyDeployed",
87
+ reason: "commits after !8021 change config_documentHandler.js and config_dynamicStyles.css of this customer",
88
+ };
89
+ it("keeps the short columns readable and wraps the long one", () => {
90
+ const lines = captured(() => new CliService().table([row], {
91
+ customer: {},
92
+ outcome: {},
93
+ reason: {},
94
+ }));
95
+ expect(lines.join("\n")).to.contain("carhartt-wip-new");
96
+ expect(lines.join("\n")).to.contain("alreadyDeployed");
97
+ });
98
+ it("stays inside the terminal", () => {
99
+ const lines = captured(() => new CliService().table([row], {
100
+ customer: {},
101
+ outcome: {},
102
+ reason: {},
103
+ }));
104
+ for (const line of lines.join("\n").split("\n")) {
105
+ expect(line.length, line).to.be.at.most(80);
106
+ }
107
+ });
108
+ });
@@ -0,0 +1,46 @@
1
+ import { ApprovalAnswer } from "../policy/auto-deploy-policy.js";
2
+ import { MergeRequestDeployService } from "../mr/index.js";
3
+ /** What `sk bulk-deploy` is asked to deploy. */
4
+ export declare class BulkDeployContext {
5
+ /** Any path inside the repository that holds the customer configurations. */
6
+ readonly repositoryPath: string;
7
+ /** The number of the merged merge request. */
8
+ readonly iid: number;
9
+ /** The answer for the customers that approve every rollout themselves. */
10
+ readonly approval?: ApprovalAnswer;
11
+ /** The description of the installations. */
12
+ readonly description?: string;
13
+ readonly dryRun: boolean;
14
+ /** Run without the confirmation, for a pipeline that has no keyboard. */
15
+ readonly assumeYes: boolean;
16
+ constructor(
17
+ /** Any path inside the repository that holds the customer configurations. */
18
+ repositoryPath: string,
19
+ /** The number of the merged merge request. */
20
+ iid: number,
21
+ /** The answer for the customers that approve every rollout themselves. */
22
+ approval?: ApprovalAnswer,
23
+ /** The description of the installations. */
24
+ description?: string, dryRun?: boolean,
25
+ /** Run without the confirmation, for a pipeline that has no keyboard. */
26
+ assumeYes?: boolean);
27
+ }
28
+ /** One customer configuration that a merge request touches. */
29
+ export interface TouchedConfig {
30
+ /** The customer directory, as git spells it. */
31
+ directory: string;
32
+ /** The customer directory in the working tree. */
33
+ customerPath: string;
34
+ configName: string;
35
+ /** Whether the customer approves every rollout themselves. */
36
+ needsApproval: boolean;
37
+ }
38
+ /** The answers that every configuration of the run is deployed with. */
39
+ export interface BulkAnswers {
40
+ description: string;
41
+ approval: ApprovalAnswer;
42
+ }
43
+ /** Builds the deploy of one configuration. */
44
+ export interface ConfigDeployFactoryInterface {
45
+ build(config: TouchedConfig, answers: BulkAnswers): Promise<MergeRequestDeployService>;
46
+ }
@@ -0,0 +1,27 @@
1
+ /** What `sk bulk-deploy` is asked to deploy. */
2
+ export class BulkDeployContext {
3
+ repositoryPath;
4
+ iid;
5
+ approval;
6
+ description;
7
+ dryRun;
8
+ assumeYes;
9
+ constructor(
10
+ /** Any path inside the repository that holds the customer configurations. */
11
+ repositoryPath,
12
+ /** The number of the merged merge request. */
13
+ iid,
14
+ /** The answer for the customers that approve every rollout themselves. */
15
+ approval,
16
+ /** The description of the installations. */
17
+ description, dryRun = false,
18
+ /** Run without the confirmation, for a pipeline that has no keyboard. */
19
+ assumeYes = false) {
20
+ this.repositoryPath = repositoryPath;
21
+ this.iid = iid;
22
+ this.approval = approval;
23
+ this.description = description;
24
+ this.dryRun = dryRun;
25
+ this.assumeYes = assumeYes;
26
+ }
27
+ }
@@ -0,0 +1,11 @@
1
+ import { UserCliConfig } from "../../../helpers/cli-config.js";
2
+ import { BulkDeployContext } from "./bulk-deploy-model.js";
3
+ import { BulkDeployService } from "./bulk-deploy-service.js";
4
+ export declare class BulkDeployServiceFactory {
5
+ private readonly context;
6
+ private readonly cliConfig;
7
+ private service?;
8
+ constructor(context: BulkDeployContext, cliConfig: UserCliConfig);
9
+ getService(): BulkDeployService;
10
+ private build;
11
+ }
@@ -0,0 +1,24 @@
1
+ import { CliServiceFactory } from "../../cli/index.js";
2
+ import { GitRepository } from "../../git/index.js";
3
+ import { BulkDeployService } from "./bulk-deploy-service.js";
4
+ import { ConfigDeployFactory } from "./config-deploy-factory.js";
5
+ export class BulkDeployServiceFactory {
6
+ context;
7
+ cliConfig;
8
+ service = undefined;
9
+ constructor(context, cliConfig) {
10
+ this.context = context;
11
+ this.cliConfig = cliConfig;
12
+ }
13
+ getService() {
14
+ if (!(this.service instanceof BulkDeployService)) {
15
+ this.build();
16
+ }
17
+ return this.service;
18
+ }
19
+ build() {
20
+ const repository = GitRepository.at(this.context.repositoryPath);
21
+ const request = repository.mergeRequest(this.context.iid);
22
+ this.service = new BulkDeployService(this.context, repository, request, new ConfigDeployFactory(this.cliConfig, repository, request, this.context.dryRun), new CliServiceFactory().getService());
23
+ }
24
+ }
@@ -0,0 +1,47 @@
1
+ import { CliServiceInterface } from "../../cli/index.js";
2
+ import { GitRepository, MergedRequest } from "../../git/index.js";
3
+ import { MergeRequestDeployResult } from "../mr/index.js";
4
+ import { BulkDeployContext, ConfigDeployFactoryInterface } from "./bulk-deploy-model.js";
5
+ /**
6
+ * Deploys every customer configuration of a merged merge request.
7
+ *
8
+ * The run asks its questions once, then plans every configuration without
9
+ * writing anything, and applies only what the plan found deployable. The
10
+ * summary names every configuration it left out, so a developer can take those
11
+ * over by hand.
12
+ */
13
+ export declare class BulkDeployService {
14
+ private readonly context;
15
+ private readonly repository;
16
+ private readonly request;
17
+ private readonly deployFactory;
18
+ private readonly cli;
19
+ constructor(context: BulkDeployContext, repository: GitRepository, request: MergedRequest, deployFactory: ConfigDeployFactoryInterface, cli: CliServiceInterface);
20
+ run(): Promise<MergeRequestDeployResult[]>;
21
+ /**
22
+ * The production config of every customer the merge request changes.
23
+ *
24
+ * A merge request deploys production alone. Staging and every other
25
+ * environment stay in the hand of a developer.
26
+ */
27
+ private productionConfigs;
28
+ /** The questions of the whole run, asked before the first configuration. */
29
+ private ask;
30
+ /**
31
+ * What happens with the customers that approve every rollout themselves.
32
+ *
33
+ * The answer is asked only while such a customer is part of the run, and it
34
+ * changes nothing for every other customer.
35
+ */
36
+ private resolveApproval;
37
+ /** Plans every configuration, without writing anything. */
38
+ private planAll;
39
+ private planOne;
40
+ /** Deploys every configuration the plan found deployable. */
41
+ private applyAll;
42
+ private isConfirmed;
43
+ /** The summary of the run, and everything a developer has to take over. */
44
+ private summarize;
45
+ private writeTable;
46
+ private failed;
47
+ }