@clickview/ship-it 0.0.25 → 0.0.26

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 (109) hide show
  1. package/Dockerfile +33 -0
  2. package/README.md +48 -48
  3. package/config.json +19 -10
  4. package/lib/config.json +20 -11
  5. package/lib/src/api-clients/git-lab/GitLabApiClient.js +404 -404
  6. package/lib/src/api-clients/git-lab/GitLabMapper.js +81 -81
  7. package/lib/src/api-clients/index.js +20 -18
  8. package/lib/src/api-clients/slack/SlackApiClient.js +206 -0
  9. package/lib/src/api-clients/team-city/TeamCityApiClient.js +100 -100
  10. package/lib/src/api-clients/trello/TrelloApiClient.js +145 -0
  11. package/lib/src/commands/BumpPackagesCommand.js +84 -84
  12. package/lib/src/commands/CreateBranchCommand.js +100 -100
  13. package/lib/src/commands/CreateMergeRequestCommand.js +107 -107
  14. package/lib/src/commands/CreateReleaseNotesCommand.js +84 -84
  15. package/lib/src/commands/CreateTestingNotesCommand.js +84 -84
  16. package/lib/src/commands/{StartConsumingProjectBuildsCommand.js → CreateTrelloCardsCommand.js} +77 -76
  17. package/lib/src/commands/InstallPackagesCommand.js +76 -76
  18. package/lib/src/commands/ListProjectsCommand.js +76 -76
  19. package/lib/src/commands/ReleaseCommand.js +129 -129
  20. package/lib/src/commands/StartProjectBuildsCommand.js +76 -76
  21. package/lib/src/commands/StatusCommand.js +88 -88
  22. package/lib/src/commands/TagMasterCommand.js +76 -76
  23. package/lib/src/commands/ValidateMergeRequestCommand.js +76 -76
  24. package/lib/src/commands/VersionCommand.js +76 -76
  25. package/lib/src/commands/index.js +30 -29
  26. package/lib/src/constants/CommandTypeMapping.js +20 -19
  27. package/lib/src/constants/GitLabMemberIds.js +6 -6
  28. package/lib/src/constants/MonorepoPackageJsonFiles.js +17 -17
  29. package/lib/src/constants/MonorepoProjectNames.js +16 -16
  30. package/lib/src/constants/ProjectNames.js +67 -67
  31. package/lib/src/constants/SlackUserEmailList.js +13 -0
  32. package/lib/src/constants/TeamCityBuildIDs.js +44 -44
  33. package/lib/src/constants/index.js +19 -19
  34. package/lib/src/errors/ShipItError.js +32 -32
  35. package/lib/src/errors/index.js +17 -17
  36. package/lib/src/index.js +18 -18
  37. package/lib/src/interfaces/Config.js +2 -2
  38. package/lib/src/interfaces/MergeRequestState.js +2 -2
  39. package/lib/src/interfaces/ProjectNames.js +2 -2
  40. package/lib/src/interfaces/ShipItCommand.js +2 -2
  41. package/lib/src/interfaces/ShipItTask.js +2 -2
  42. package/lib/src/interfaces/VersionType.js +2 -2
  43. package/lib/src/interfaces/command-cli-options/MilestoneCommandCliOptions.js +2 -2
  44. package/lib/src/interfaces/command-cli-options/ReleaseCommandCliOptions.js +2 -2
  45. package/lib/src/interfaces/command-cli-options/StatusCommandCliOptions.js +2 -0
  46. package/lib/src/interfaces/command-cli-options/index.js +19 -18
  47. package/lib/src/interfaces/command-options/BaseCommandOptions.js +2 -2
  48. package/lib/src/interfaces/command-options/BumpPackagesCommandOptions.js +2 -2
  49. package/lib/src/interfaces/command-options/DockerMilestoneCommandOptions.js +2 -2
  50. package/lib/src/interfaces/command-options/MilestoneCommandOptions.js +2 -2
  51. package/lib/src/interfaces/command-options/ReleaseCommandOptions.js +2 -2
  52. package/lib/src/interfaces/command-options/StatusCommandOptions.js +2 -0
  53. package/lib/src/interfaces/command-options/ValidateMRCommandOptions.js +2 -2
  54. package/lib/src/interfaces/command-options/index.js +22 -21
  55. package/lib/src/interfaces/index.js +26 -26
  56. package/lib/src/interfaces/models/Branch.js +2 -2
  57. package/lib/src/interfaces/models/Commit.js +2 -2
  58. package/lib/src/interfaces/models/CommitFile.js +2 -2
  59. package/lib/src/interfaces/models/File.js +2 -2
  60. package/lib/src/interfaces/models/Label.js +2 -2
  61. package/lib/src/interfaces/models/MergeRequest.js +2 -2
  62. package/lib/src/interfaces/models/Milestone.js +2 -2
  63. package/lib/src/interfaces/models/Project.js +2 -2
  64. package/lib/src/interfaces/models/ProjectConfig.js +9 -9
  65. package/lib/src/interfaces/models/Release.js +2 -2
  66. package/lib/src/interfaces/models/Tag.js +2 -2
  67. package/lib/src/interfaces/models/index.js +26 -26
  68. package/lib/src/interfaces/view-models/MilestoneProject.js +2 -2
  69. package/lib/src/interfaces/view-models/index.js +17 -17
  70. package/lib/src/inversify.config.js +75 -67
  71. package/lib/src/services/GitLabService.js +498 -498
  72. package/lib/src/services/SlackService.js +142 -0
  73. package/lib/src/services/TeamCityService.js +37 -37
  74. package/lib/src/services/TrelloService.js +84 -0
  75. package/lib/src/services/index.js +20 -18
  76. package/lib/src/startup/AddMilestoneCommand.js +95 -95
  77. package/lib/src/startup/GetAction.js +68 -68
  78. package/lib/src/startup/SetupCommands.js +166 -128
  79. package/lib/src/tasks/BumpPackagesTask.js +229 -229
  80. package/lib/src/tasks/BumpVersionTxtTask.js +110 -110
  81. package/lib/src/tasks/CommitPackageVersionsTask.js +116 -116
  82. package/lib/src/tasks/CreateBranchTask.js +104 -104
  83. package/lib/src/tasks/CreateMergeRequestTask.js +118 -118
  84. package/lib/src/tasks/CreateReleaseNotesTask.js +144 -122
  85. package/lib/src/tasks/CreateTestingNotesTask.js +135 -135
  86. package/lib/src/tasks/InstallPackagesTask.js +407 -407
  87. package/lib/src/tasks/ListProjectsTask.js +87 -87
  88. package/lib/src/tasks/PopulateTrelloBoardTask.js +140 -0
  89. package/lib/src/tasks/StartMonorepoBuildTask.js +109 -109
  90. package/lib/src/tasks/StartProjectBuildsTask.js +149 -149
  91. package/lib/src/tasks/TagMasterTask.js +121 -121
  92. package/lib/src/tasks/ValidateCommitsTask.js +143 -119
  93. package/lib/src/tasks/ValidateDescriptionsTask.js +178 -151
  94. package/lib/src/tasks/ValidateMergeRequestTask.js +115 -115
  95. package/lib/src/tasks/ValidateTask.js +344 -240
  96. package/lib/src/tasks/VersionTask.js +98 -98
  97. package/lib/src/tasks/index.js +34 -33
  98. package/lib/src/types.js +57 -49
  99. package/lib/src/utils/BranchNames.js +11 -11
  100. package/lib/src/utils/Commits.js +55 -55
  101. package/lib/src/utils/Csv.js +54 -54
  102. package/lib/src/utils/Descriptions.js +237 -237
  103. package/lib/src/utils/GroupIds.js +6 -6
  104. package/lib/src/utils/Logger.js +62 -62
  105. package/lib/src/utils/ProjectIds.js +47 -47
  106. package/lib/src/utils/Versions.js +20 -20
  107. package/lib/src/utils/index.js +22 -22
  108. package/package.json +50 -47
  109. package/lib/src/tasks/StartConsumingProjectBuildsTask.js +0 -149
@@ -1,47 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProjectIds = void 0;
4
- var lodash_1 = require("lodash");
5
- var constants_1 = require("../constants");
6
- var errors_1 = require("../errors");
7
- exports.ProjectIds = {
8
- MONOREPO_PROJECT_ID: constants_1.PROJECT_NAMES.frontend.monorepo,
9
- /**
10
- * This allows project names to be passed into the CLI.
11
- * For example `ship-it release -m S2 -p lite`
12
- */
13
- getProjectIds: function (projects) {
14
- var projectIds = [];
15
- for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) {
16
- var project = projects_1[_i];
17
- if (!isNaN(+project)) {
18
- projectIds.push(project);
19
- continue;
20
- }
21
- var mappedId = getMappedId(project);
22
- if (!mappedId)
23
- throw new errors_1.ShipItError("Could not find project id mapping for ".concat(project));
24
- projectIds.push(mappedId);
25
- }
26
- return (0, lodash_1.uniq)(projectIds);
27
- }
28
- };
29
- function getMappedId(project) {
30
- for (var projectGroup in constants_1.PROJECT_NAMES) {
31
- var projectGroupIds = constants_1.PROJECT_NAMES[projectGroup];
32
- if (projectGroupIds[project])
33
- return projectGroupIds[project];
34
- // Support arguments such as "emailapi"
35
- if (projectGroupIds[project.replace('api', '')])
36
- return projectGroupIds[project.replace('api', '')];
37
- // Support arguments such as "emailservice"
38
- if (projectGroupIds[project.replace('service', '')])
39
- return projectGroupIds[project.replace('service', '')];
40
- // Support arguments such as "launchweb"
41
- if (projectGroupIds[project.replace('web', '')])
42
- return projectGroupIds[project.replace('web', '')];
43
- // Support arguments such as "hydrationapp"
44
- if (projectGroupIds[project.replace('app', '')])
45
- return projectGroupIds[project.replace('app', '')];
46
- }
47
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectIds = void 0;
4
+ var lodash_1 = require("lodash");
5
+ var constants_1 = require("../constants");
6
+ var errors_1 = require("../errors");
7
+ exports.ProjectIds = {
8
+ MONOREPO_PROJECT_ID: constants_1.PROJECT_NAMES.frontend.monorepo,
9
+ /**
10
+ * This allows project names to be passed into the CLI.
11
+ * For example `ship-it release -m S2 -p lite`
12
+ */
13
+ getProjectIds: function (projects) {
14
+ var projectIds = [];
15
+ for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) {
16
+ var project = projects_1[_i];
17
+ if (!isNaN(+project)) {
18
+ projectIds.push(project);
19
+ continue;
20
+ }
21
+ var mappedId = getMappedId(project);
22
+ if (!mappedId)
23
+ throw new errors_1.ShipItError("Could not find project id mapping for ".concat(project));
24
+ projectIds.push(mappedId);
25
+ }
26
+ return (0, lodash_1.uniq)(projectIds);
27
+ }
28
+ };
29
+ function getMappedId(project) {
30
+ for (var projectGroup in constants_1.PROJECT_NAMES) {
31
+ var projectGroupIds = constants_1.PROJECT_NAMES[projectGroup];
32
+ if (projectGroupIds[project])
33
+ return projectGroupIds[project];
34
+ // Support arguments such as "emailapi"
35
+ if (projectGroupIds[project.replace('api', '')])
36
+ return projectGroupIds[project.replace('api', '')];
37
+ // Support arguments such as "emailservice"
38
+ if (projectGroupIds[project.replace('service', '')])
39
+ return projectGroupIds[project.replace('service', '')];
40
+ // Support arguments such as "launchweb"
41
+ if (projectGroupIds[project.replace('web', '')])
42
+ return projectGroupIds[project.replace('web', '')];
43
+ // Support arguments such as "hydrationapp"
44
+ if (projectGroupIds[project.replace('app', '')])
45
+ return projectGroupIds[project.replace('app', '')];
46
+ }
47
+ }
@@ -1,20 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Versions = void 0;
7
- var semver_1 = __importDefault(require("semver"));
8
- exports.Versions = {
9
- getNextVersion: function (currentVersion, type) {
10
- var curr = new semver_1.default.SemVer(currentVersion);
11
- switch (type) {
12
- case 'major':
13
- return "".concat(curr.major + 1, ".0.0");
14
- case 'minor':
15
- return "".concat(curr.major, ".").concat(curr.minor + 1, ".0");
16
- case 'patch':
17
- return "".concat(curr.major, ".").concat(curr.minor, ".").concat(curr.patch + 1);
18
- }
19
- }
20
- };
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Versions = void 0;
7
+ var semver_1 = __importDefault(require("semver"));
8
+ exports.Versions = {
9
+ getNextVersion: function (currentVersion, type) {
10
+ var curr = new semver_1.default.SemVer(currentVersion);
11
+ switch (type) {
12
+ case 'major':
13
+ return "".concat(curr.major + 1, ".0.0");
14
+ case 'minor':
15
+ return "".concat(curr.major, ".").concat(curr.minor + 1, ".0");
16
+ case 'patch':
17
+ return "".concat(curr.major, ".").concat(curr.minor, ".").concat(curr.patch + 1);
18
+ }
19
+ }
20
+ };
@@ -1,22 +1,22 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./BranchNames"), exports);
18
- __exportStar(require("./Commits"), exports);
19
- __exportStar(require("./Descriptions"), exports);
20
- __exportStar(require("./Logger"), exports);
21
- __exportStar(require("./ProjectIds"), exports);
22
- __exportStar(require("./Versions"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./BranchNames"), exports);
18
+ __exportStar(require("./Commits"), exports);
19
+ __exportStar(require("./Descriptions"), exports);
20
+ __exportStar(require("./Logger"), exports);
21
+ __exportStar(require("./ProjectIds"), exports);
22
+ __exportStar(require("./Versions"), exports);
package/package.json CHANGED
@@ -1,47 +1,50 @@
1
- {
2
- "name": "@clickview/ship-it",
3
- "version": "0.0.25",
4
- "description": "Release Manager",
5
- "main": "./lib/index.js",
6
- "bin": {
7
- "ship-it": "./lib/src/index.js"
8
- },
9
- "scripts": {
10
- "start": "npm run lint && ts-node --files src/index.ts",
11
- "build": "npm run lint && tsc -p . && tsc-alias -p tsconfig.json",
12
- "lint": "eslint . --ext .ts"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "https://gitlab.cvinternal.net/front-end/ship-it.git"
17
- },
18
- "author": "Joshua Taylor, Shale Kuzmanovski",
19
- "license": "ISC",
20
- "dependencies": {
21
- "@gitbeaker/node": "35.6.0",
22
- "chalk": "4.1.2",
23
- "commander": "9.1.0",
24
- "fast-csv": "4.3.6",
25
- "fs-extra": "10.0.1",
26
- "inversify": "6.0.1",
27
- "lodash": "4.17.21",
28
- "reflect-metadata": "0.1.13",
29
- "semver": "7.3.5",
30
- "teamcity-rest-api": "0.0.8"
31
- },
32
- "devDependencies": {
33
- "@clickview/eslint-config": "1.0.3",
34
- "@types/fs-extra": "9.0.13",
35
- "@types/lodash": "4.14.181",
36
- "@types/node": "17.0.23",
37
- "@types/semver": "7.3.9",
38
- "@typescript-eslint/eslint-plugin": "5.17.0",
39
- "@typescript-eslint/parser": "5.17.0",
40
- "eslint": "8.12.0",
41
- "eslint-plugin-react-hooks": "4.4.0",
42
- "ts-node": "10.7.0",
43
- "tsc-alias": "1.6.6",
44
- "tsconfig-paths": "3.14.1",
45
- "typescript": "4.6.3"
46
- }
47
- }
1
+ {
2
+ "name": "@clickview/ship-it",
3
+ "version": "0.0.26",
4
+ "description": "Release Manager",
5
+ "main": "./lib/index.js",
6
+ "bin": {
7
+ "ship-it": "./lib/src/index.js"
8
+ },
9
+ "scripts": {
10
+ "start": "npm run lint && ts-node --files src/index.ts",
11
+ "build": "npm run lint && tsc -p . && tsc-alias -p tsconfig.json",
12
+ "lint": "eslint . --ext .ts"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://gitlab.cvinternal.net/front-end/ship-it.git"
17
+ },
18
+ "author": "Joshua Taylor, Shale Kuzmanovski",
19
+ "license": "ISC",
20
+ "dependencies": {
21
+ "@gitbeaker/node": "35.6.0",
22
+ "chalk": "4.1.2",
23
+ "commander": "9.1.0",
24
+ "fast-csv": "4.3.6",
25
+ "fs-extra": "10.0.1",
26
+ "inversify": "6.0.1",
27
+ "lodash": "4.17.21",
28
+ "reflect-metadata": "0.1.13",
29
+ "semver": "7.3.5",
30
+ "teamcity-rest-api": "0.0.8"
31
+ },
32
+ "devDependencies": {
33
+ "@clickview/eslint-config": "1.0.3",
34
+ "@types/fs-extra": "9.0.13",
35
+ "@types/lodash": "4.14.181",
36
+ "@types/node": "17.0.23",
37
+ "@types/semver": "7.3.9",
38
+ "@typescript-eslint/eslint-plugin": "5.17.0",
39
+ "@typescript-eslint/parser": "5.17.0",
40
+ "@slack/webhook": "7.0.2",
41
+ "@slack/web-api":"6.11.2",
42
+ "eslint": "8.12.0",
43
+ "eslint-plugin-react-hooks": "4.4.0",
44
+ "trello": "0.11.0",
45
+ "ts-node": "10.7.0",
46
+ "tsc-alias": "1.6.6",
47
+ "tsconfig-paths": "3.14.1",
48
+ "typescript": "4.6.3"
49
+ }
50
+ }
@@ -1,149 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- var __generator = (this && this.__generator) || function (thisArg, body) {
24
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
- function verb(n) { return function (v) { return step([n, v]); }; }
27
- function step(op) {
28
- if (f) throw new TypeError("Generator is already executing.");
29
- while (_) try {
30
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
31
- if (y = 0, t) op = [op[0] & 2, t.value];
32
- switch (op[0]) {
33
- case 0: case 1: t = op; break;
34
- case 4: _.label++; return { value: op[1], done: false };
35
- case 5: _.label++; y = op[1]; op = [0]; continue;
36
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
- default:
38
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
- if (t[2]) _.ops.pop();
43
- _.trys.pop(); continue;
44
- }
45
- op = body.call(thisArg, _);
46
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
- }
49
- };
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.StartConsumingProjectBuildsTask = void 0;
52
- require("reflect-metadata");
53
- var inversify_1 = require("inversify");
54
- var utils_1 = require("../utils");
55
- var services_1 = require("../services");
56
- var types_1 = require("../types");
57
- var TeamCityBuildIDs_1 = require("../constants/TeamCityBuildIDs");
58
- var StartConsumingProjectBuildsTask = /** @class */ (function () {
59
- function StartConsumingProjectBuildsTask(teamCityService, gitLabService) {
60
- this.teamCityService = teamCityService;
61
- this.gitLabService = gitLabService;
62
- }
63
- StartConsumingProjectBuildsTask.prototype.run = function (_options) {
64
- return __awaiter(this, void 0, void 0, function () {
65
- var milestone, options, projects, consumingProjects, projectBuildMap, _i, consumingProjects_1, project, branchName, buildId, build, totalBuilds, project;
66
- return __generator(this, function (_a) {
67
- switch (_a.label) {
68
- case 0:
69
- utils_1.Logger.logTask('Starting builds for consuming projects in TeamCity');
70
- if (!_options.monorepoBranchName && !_options.milestone) {
71
- utils_1.Logger.logError('Please provide either a milestone or branch name argument.');
72
- return [2 /*return*/, false];
73
- }
74
- milestone = _options.milestone;
75
- if (!!milestone) return [3 /*break*/, 2];
76
- utils_1.Logger.logInfo("Searching for a merge request in project \"monorepo\" with branch name \"".concat(_options.monorepoBranchName, "\"..."));
77
- return [4 /*yield*/, this.gitLabService.getMilestoneByBranchName(utils_1.ProjectIds.MONOREPO_PROJECT_ID, _options.monorepoBranchName)];
78
- case 1:
79
- milestone = _a.sent();
80
- _a.label = 2;
81
- case 2:
82
- if (!milestone)
83
- return [2 /*return*/, false];
84
- utils_1.Logger.logInfo("Found milestone \"".concat(milestone, "\". Proceeding to run builds for consuming projects..."));
85
- options = {
86
- version: _options.version,
87
- projectIds: _options.projectIds,
88
- omittedProjectIds: _options.omittedProjectIds,
89
- milestone: milestone
90
- };
91
- return [4 /*yield*/, this.gitLabService.getProjects(options)];
92
- case 3:
93
- projects = _a.sent();
94
- consumingProjects = projects.filter(function (p) { return p.id.toString() !== utils_1.ProjectIds.MONOREPO_PROJECT_ID; });
95
- if (!consumingProjects.length) {
96
- utils_1.Logger.logError("No projects that consume monorepo could be found");
97
- return [2 /*return*/, false];
98
- }
99
- projectBuildMap = {};
100
- _i = 0, consumingProjects_1 = consumingProjects;
101
- _a.label = 4;
102
- case 4:
103
- if (!(_i < consumingProjects_1.length)) return [3 /*break*/, 8];
104
- project = consumingProjects_1[_i];
105
- return [4 /*yield*/, this.gitLabService.getReleaseBranchNameMilestone(project.id, options.milestone)];
106
- case 5:
107
- branchName = _a.sent();
108
- if (!branchName) {
109
- utils_1.Logger.logWarning("Release branch in project \"".concat(project.title, "\" with milestone \"").concat(options.milestone, "\" was not found. Skipping project..."));
110
- return [3 /*break*/, 7];
111
- }
112
- buildId = TeamCityBuildIDs_1.TeamCityBuildIds[project.id.toString()];
113
- if (!buildId) {
114
- utils_1.Logger.logWarning("Skipping build for ".concat(project.title, " as no Team City build ID has been specified"));
115
- return [3 /*break*/, 7];
116
- }
117
- return [4 /*yield*/, this.teamCityService.startBuild(buildId, branchName)];
118
- case 6:
119
- build = _a.sent();
120
- projectBuildMap[project.title] = build;
121
- _a.label = 7;
122
- case 7:
123
- _i++;
124
- return [3 /*break*/, 4];
125
- case 8:
126
- totalBuilds = Object.keys(projectBuildMap).length;
127
- if (!totalBuilds) {
128
- utils_1.Logger.logWarning("No releases found in consuming projects with milestone \"".concat(options.milestone, "\"."));
129
- return [2 /*return*/, true];
130
- }
131
- utils_1.Logger.logSuccess("Successfully started builds in ".concat(totalBuilds, " projects."));
132
- for (project in projectBuildMap) {
133
- utils_1.Logger.logInfo("[".concat(project, "]: ").concat(projectBuildMap[project].webUrl));
134
- }
135
- return [2 /*return*/, true];
136
- }
137
- });
138
- });
139
- };
140
- StartConsumingProjectBuildsTask = __decorate([
141
- (0, inversify_1.injectable)(),
142
- __param(0, (0, inversify_1.inject)(types_1.SERVICES.TeamCityService)),
143
- __param(1, (0, inversify_1.inject)(types_1.SERVICES.GitLabService)),
144
- __metadata("design:paramtypes", [services_1.TeamCityService,
145
- services_1.GitLabService])
146
- ], StartConsumingProjectBuildsTask);
147
- return StartConsumingProjectBuildsTask;
148
- }());
149
- exports.StartConsumingProjectBuildsTask = StartConsumingProjectBuildsTask;