@clickview/ship-it 0.0.4-dev.5 → 0.0.4-rc.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 (42) hide show
  1. package/config.json +0 -5
  2. package/lib/config.json +0 -5
  3. package/lib/src/api-clients/git-lab/GitLabApiClient.js +0 -24
  4. package/lib/src/api-clients/git-lab/GitLabMapper.js +0 -1
  5. package/lib/src/api-clients/index.js +0 -1
  6. package/lib/src/commands/ReleaseCommand.js +11 -16
  7. package/lib/src/commands/index.js +0 -1
  8. package/lib/src/constants/CommandTypeMapping.js +0 -1
  9. package/lib/src/interfaces/command-options/index.js +1 -2
  10. package/lib/src/interfaces/index.js +0 -1
  11. package/lib/src/inversify.config.js +0 -8
  12. package/lib/src/services/GitLabService.js +0 -33
  13. package/lib/src/services/index.js +0 -1
  14. package/lib/src/startup/AddMilestoneCommand.js +1 -2
  15. package/lib/src/startup/SetupCommands.js +2 -74
  16. package/lib/src/tasks/BumpPackagesTask.js +1 -2
  17. package/lib/src/tasks/CommitPackageVersionsTask.js +1 -8
  18. package/lib/src/tasks/CreateBranchTask.js +19 -37
  19. package/lib/src/tasks/InstallPackagesTask.js +47 -26
  20. package/lib/src/tasks/ValidateTask.js +2 -2
  21. package/lib/src/tasks/index.js +0 -2
  22. package/lib/src/types.js +0 -6
  23. package/lib/src/utils/BranchNames.js +0 -2
  24. package/lib/src/utils/ProjectIds.js +3 -3
  25. package/lib/src/utils/Versions.js +0 -1
  26. package/package.json +3 -4
  27. package/lib/src/api-clients/GitLabApiClient.js +0 -342
  28. package/lib/src/api-clients/team-city/TeamCityApiClient.js +0 -85
  29. package/lib/src/commands/CommitPackageVersionsCommand.js +0 -78
  30. package/lib/src/commands/StartConsumingProjectBuildsCommand.js +0 -76
  31. package/lib/src/constants/TeamCityBuildIDs.js +0 -13
  32. package/lib/src/interfaces/ShipItOptions.js +0 -2
  33. package/lib/src/interfaces/command-cli-options/MilestoneCommandCliOptions.js +0 -2
  34. package/lib/src/interfaces/command-cli-options/ReleaseCommandCliOptions.js +0 -2
  35. package/lib/src/interfaces/command-cli-options/index.js +0 -18
  36. package/lib/src/interfaces/command-options/CommitPackageVersionsCommandOptions.js +0 -2
  37. package/lib/src/interfaces/command-options/DockerMilestoneCommandOptions.js +0 -2
  38. package/lib/src/interfaces/command-options/ReleaseCommandOptions.js +0 -2
  39. package/lib/src/services/TeamCityService.js +0 -34
  40. package/lib/src/tasks/CommitLocalPackagesTask.js +0 -137
  41. package/lib/src/tasks/StartConsumingProjectBuildsTask.js +0 -143
  42. package/lib/src/tasks/StartMonorepoBuildTask.js +0 -95
package/config.json CHANGED
@@ -2,10 +2,5 @@
2
2
  "gitLab": {
3
3
  "accessToken": "glpat-YK8GmVgXRRf3zBe3JQze",
4
4
  "url": "https://gitlab.cvinternal.net"
5
- },
6
- "teamCity": {
7
- "url": "http://build.cvinternal.net/",
8
- "username": "shale.kuzmanovski",
9
- "password": "final2&ergot"
10
5
  }
11
6
  }
package/lib/config.json CHANGED
@@ -2,10 +2,5 @@
2
2
  "gitLab": {
3
3
  "accessToken": "glpat-YK8GmVgXRRf3zBe3JQze",
4
4
  "url": "https://gitlab.cvinternal.net"
5
- },
6
- "teamCity": {
7
- "url": "http://build.cvinternal.net/",
8
- "username": "shale.kuzmanovski",
9
- "password": "final2&ergot"
10
5
  }
11
6
  }
@@ -228,30 +228,6 @@ var GitLabApiClient = /** @class */ (function () {
228
228
  });
229
229
  });
230
230
  };
231
- GitLabApiClient.prototype.getReleaseMergeRequest = function (projectId, milestone) {
232
- return __awaiter(this, void 0, void 0, function () {
233
- var mergeRequests, releaseMR;
234
- return __generator(this, function (_a) {
235
- switch (_a.label) {
236
- case 0: return [4 /*yield*/, this.client.MergeRequests.all({
237
- projectId: projectId,
238
- targetBranch: 'master',
239
- /**
240
- * We only care about open MRs, this allows us to close any MR and run the CLI again if needed
241
- */
242
- state: 'opened',
243
- milestone: milestone
244
- })];
245
- case 1:
246
- mergeRequests = _a.sent();
247
- releaseMR = mergeRequests[0];
248
- if (!releaseMR)
249
- return [2 /*return*/, null];
250
- return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(releaseMR)];
251
- }
252
- });
253
- });
254
- };
255
231
  GitLabApiClient.prototype.createMergeRequest = function (projectId, sourceBranch, targetBranch, title, description, milestone) {
256
232
  return __awaiter(this, void 0, void 0, function () {
257
233
  var mergeRequest;
@@ -15,7 +15,6 @@ exports.GitLabMapper = {
15
15
  url: m.web_url,
16
16
  hasConflicts: m.has_conflicts,
17
17
  targetBranch: m.target_branch,
18
- sourceBranch: m.source_branch,
19
18
  milestone: exports.GitLabMapper.milestone(m.milestone)
20
19
  };
21
20
  },
@@ -15,4 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./git-lab/GitLabApiClient"), exports);
18
- __exportStar(require("./team-city/TeamCityApiClient"), exports);
@@ -53,7 +53,7 @@ require("reflect-metadata");
53
53
  var inversify_1 = require("inversify");
54
54
  var types_1 = require("../types");
55
55
  var ReleaseCommand = /** @class */ (function () {
56
- function ReleaseCommand(validateTask, versionTask, validateDescriptionsTask, validateCommitsTask, createBranchTask, bumpVersionTxtTask, createMergeRequestTask, startMonorepoBuildTask) {
56
+ function ReleaseCommand(validateTask, versionTask, validateDescriptionsTask, validateCommitsTask, createBranchTask, bumpVersionTxtTask, createMergeRequestTask) {
57
57
  this.validateTask = validateTask;
58
58
  this.versionTask = versionTask;
59
59
  this.validateDescriptionsTask = validateDescriptionsTask;
@@ -61,7 +61,6 @@ var ReleaseCommand = /** @class */ (function () {
61
61
  this.createBranchTask = createBranchTask;
62
62
  this.bumpVersionTxtTask = bumpVersionTxtTask;
63
63
  this.createMergeRequestTask = createMergeRequestTask;
64
- this.startMonorepoBuildTask = startMonorepoBuildTask;
65
64
  }
66
65
  ReleaseCommand.prototype.run = function (options) {
67
66
  return __awaiter(this, void 0, void 0, function () {
@@ -79,31 +78,28 @@ var ReleaseCommand = /** @class */ (function () {
79
78
  cont = _a.sent();
80
79
  if (!cont)
81
80
  return [2 /*return*/, false];
82
- // cont = await this.validateDescriptionsTask.run(options);
83
- if (!cont)
84
- return [2 /*return*/, false];
85
- // cont = await this.validateCommitsTask.run(options);
86
- if (!cont)
87
- return [2 /*return*/, false];
88
- return [4 /*yield*/, this.createBranchTask.run(options)];
81
+ return [4 /*yield*/, this.validateDescriptionsTask.run(options)];
89
82
  case 3:
90
83
  cont = _a.sent();
91
84
  if (!cont)
92
85
  return [2 /*return*/, false];
93
- return [4 /*yield*/, this.bumpVersionTxtTask.run(options)];
86
+ return [4 /*yield*/, this.validateCommitsTask.run(options)];
94
87
  case 4:
95
88
  cont = _a.sent();
96
89
  if (!cont)
97
90
  return [2 /*return*/, false];
98
- return [4 /*yield*/, this.createMergeRequestTask.run(options)];
91
+ return [4 /*yield*/, this.createBranchTask.run(options)];
99
92
  case 5:
100
93
  cont = _a.sent();
101
94
  if (!cont)
102
95
  return [2 /*return*/, false];
103
- if (!options.triggerMonorepoBuild)
96
+ return [4 /*yield*/, this.bumpVersionTxtTask.run(options)];
97
+ case 6:
98
+ cont = _a.sent();
99
+ if (!cont)
104
100
  return [2 /*return*/, false];
105
- return [4 /*yield*/, this.startMonorepoBuildTask.run(options)];
106
- case 6: return [2 /*return*/, _a.sent()];
101
+ return [4 /*yield*/, this.createMergeRequestTask.run(options)];
102
+ case 7: return [2 /*return*/, _a.sent()];
107
103
  }
108
104
  });
109
105
  });
@@ -117,8 +113,7 @@ var ReleaseCommand = /** @class */ (function () {
117
113
  __param(4, (0, inversify_1.inject)(types_1.TASKS.CreateBranchTask)),
118
114
  __param(5, (0, inversify_1.inject)(types_1.TASKS.BumpVersionTxtTask)),
119
115
  __param(6, (0, inversify_1.inject)(types_1.TASKS.CreateMergeRequestTask)),
120
- __param(7, (0, inversify_1.inject)(types_1.TASKS.StartMonorepoBuildTask)),
121
- __metadata("design:paramtypes", [Object, Object, Object, Object, Object, Object, Object, Object])
116
+ __metadata("design:paramtypes", [Object, Object, Object, Object, Object, Object, Object])
122
117
  ], ReleaseCommand);
123
118
  return ReleaseCommand;
124
119
  }());
@@ -20,7 +20,6 @@ __exportStar(require("./CreateMergeRequestCommand"), exports);
20
20
  __exportStar(require("./CreateReleaseNotesCommand"), exports);
21
21
  __exportStar(require("./InstallPackagesCommand"), exports);
22
22
  __exportStar(require("./ReleaseCommand"), exports);
23
- __exportStar(require("./StartConsumingProjectBuildsCommand"), exports);
24
23
  __exportStar(require("./StatusCommand"), exports);
25
24
  __exportStar(require("./ValidateMergeRequestCommand"), exports);
26
25
  __exportStar(require("./VersionCommand"), exports);
@@ -11,6 +11,5 @@ exports.CommandTypeMapping = {
11
11
  'create-notes': types_1.COMMANDS.CreateReleaseNotesCommand,
12
12
  'install-packages': types_1.COMMANDS.InstallPackagesCommand,
13
13
  'bump-packages': types_1.COMMANDS.BumpPackagesCommand,
14
- 'start-consuming-project-builds': types_1.COMMANDS.StartConsumingProjectBuildsCommand,
15
14
  'validate-mr': types_1.COMMANDS.ValidateMergeRequestCommand
16
15
  };
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./BumpPackagesCommandOptions"), exports);
18
- __exportStar(require("./DockerMilestoneCommandOptions"), exports);
18
+ __exportStar(require("./InstallPackagesCommandOptions"), exports);
19
19
  __exportStar(require("./MilestoneCommandOptions"), exports);
20
20
  __exportStar(require("./ValidateMRCommandOptions"), exports);
21
- __exportStar(require("./ReleaseCommandOptions"), exports);
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./command-cli-options"), exports);
18
17
  __exportStar(require("./command-options"), exports);
19
18
  __exportStar(require("./models"), exports);
20
19
  __exportStar(require("./view-models"), exports);
@@ -13,17 +13,14 @@ function createContainer(config) {
13
13
  * Misc
14
14
  */
15
15
  container.bind(types_1.MISC.GitLabConfig).toConstantValue(config.gitLab);
16
- container.bind(types_1.MISC.TeamCityConfig).toConstantValue(config.teamCity);
17
16
  /**
18
17
  * Clients
19
18
  */
20
19
  container.bind(types_1.API_CLIENTS.GitLabApiClient).to(api_clients_1.GitLabApiClient);
21
- container.bind(types_1.API_CLIENTS.TeamCityApiClient).to(api_clients_1.TeamCityApiClient);
22
20
  /**
23
21
  * Services
24
22
  */
25
23
  container.bind(types_1.SERVICES.GitLabService).to(services_1.GitLabService).inSingletonScope();
26
- container.bind(types_1.SERVICES.TeamCityService).to(services_1.TeamCityService).inSingletonScope();
27
24
  /**
28
25
  * Tasks
29
26
  */
@@ -39,9 +36,6 @@ function createContainer(config) {
39
36
  container.bind(types_1.TASKS.BumpPackagesTask).to(tasks_1.BumpPackagesTask);
40
37
  container.bind(types_1.TASKS.CommitPackageVersionsTask).to(tasks_1.CommitPackageVersionsTask);
41
38
  container.bind(types_1.TASKS.ValidateMergeRequestTask).to(tasks_1.ValidateMergeRequestTask);
42
- container.bind(types_1.TASKS.StartMonorepoBuildTask).to(tasks_1.StartMonorepoBuildTask);
43
- container.bind(types_1.TASKS.StartConsumingProjectBuildsTask)
44
- .to(tasks_1.StartConsumingProjectBuildsTask);
45
39
  /**
46
40
  * Commands
47
41
  */
@@ -54,8 +48,6 @@ function createContainer(config) {
54
48
  container.bind(types_1.COMMANDS.InstallPackagesCommand).to(commands_1.InstallPackagesCommand);
55
49
  container.bind(types_1.COMMANDS.BumpPackagesCommand).to(commands_1.BumpPackagesCommand);
56
50
  container.bind(types_1.COMMANDS.ValidateMergeRequestCommand).to(commands_1.ValidateMergeRequestCommand);
57
- container.bind(types_1.COMMANDS.StartConsumingProjectBuildsCommand)
58
- .to(commands_1.StartConsumingProjectBuildsCommand);
59
51
  return container;
60
52
  }
61
53
  exports.createContainer = createContainer;
@@ -202,39 +202,6 @@ var GitLabService = /** @class */ (function () {
202
202
  GitLabService.prototype.getMilestone = function (projectId, milestoneName) {
203
203
  return this.apiClient.getMilestone(projectId, milestoneName);
204
204
  };
205
- GitLabService.prototype.getReleaseBranchNameMilestone = function (projectId, milestone) {
206
- return __awaiter(this, void 0, void 0, function () {
207
- var releaseMR;
208
- return __generator(this, function (_a) {
209
- switch (_a.label) {
210
- case 0: return [4 /*yield*/, this.apiClient.getReleaseMergeRequest(projectId, milestone)];
211
- case 1:
212
- releaseMR = _a.sent();
213
- if (!releaseMR)
214
- return [2 /*return*/, null];
215
- return [2 /*return*/, releaseMR.sourceBranch];
216
- }
217
- });
218
- });
219
- };
220
- GitLabService.prototype.getMilestoneByBranchName = function (projectId, branchName) {
221
- var _a, _b;
222
- return __awaiter(this, void 0, void 0, function () {
223
- var mergeRequest;
224
- return __generator(this, function (_c) {
225
- switch (_c.label) {
226
- case 0: return [4 /*yield*/, this.getMergeRequest(projectId, branchName)];
227
- case 1:
228
- mergeRequest = _c.sent();
229
- if (!mergeRequest)
230
- throw new errors_1.ShipItError("No merge request in project \"monorepo\" with branch name \"".concat(branchName, "\" could be found."));
231
- if (!mergeRequest.milestone)
232
- throw new errors_1.ShipItError("No milestone could be found on merge request \"".concat(mergeRequest.title, "\". Please attach a milestone then try again: ").concat(mergeRequest.url));
233
- return [2 /*return*/, (_b = (_a = mergeRequest.milestone) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ''];
234
- }
235
- });
236
- });
237
- };
238
205
  GitLabService.prototype.bumpVersionTxt = function (projectId, branchName, newVersion) {
239
206
  return __awaiter(this, void 0, void 0, function () {
240
207
  var versionTxt, buff, text;
@@ -15,4 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./GitLabService"), exports);
18
- __exportStar(require("./TeamCityService"), exports);
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.processMilestoneCommandOptions = exports.getAddMilestoneCommand = void 0;
39
+ exports.getAddMilestoneCommand = void 0;
40
40
  var utils_1 = require("../utils");
41
41
  function processOptions(options) {
42
42
  var opts = {
@@ -53,7 +53,6 @@ function processOptions(options) {
53
53
  opts.version = 'patch';
54
54
  return opts;
55
55
  }
56
- exports.processMilestoneCommandOptions = processOptions;
57
56
  var getAddMilestoneCommand = function (program, getAction) {
58
57
  return function addMilestoneCommand(name, description) {
59
58
  var _this = this;
@@ -1,61 +1,9 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
29
- 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;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
2
  Object.defineProperty(exports, "__esModule", { value: true });
53
3
  exports.setupCommands = void 0;
54
- var lodash_1 = __importDefault(require("lodash"));
55
4
  var AddMilestoneCommand_1 = require("./AddMilestoneCommand");
56
5
  var GetAction_1 = require("./GetAction");
57
6
  function setupCommands(program, container) {
58
- var _this = this;
59
7
  var getAction = (0, GetAction_1.getActionBuilder)(program, container);
60
8
  var addMilestoneCommand = (0, AddMilestoneCommand_1.getAddMilestoneCommand)(program, getAction);
61
9
  // All commands below accept the same options
@@ -64,21 +12,7 @@ function setupCommands(program, container) {
64
12
  addMilestoneCommand('create-branches', 'Create release branches for all projects that are part of a milestone');
65
13
  addMilestoneCommand('create-mrs', 'Create merge requests for all projects that are part of a milestone');
66
14
  addMilestoneCommand('create-notes', 'Builds descriptions for all projects that are part of a milestone');
67
- program.command('release')
68
- .description('Create releases for all projects that are part of a milestone')
69
- .requiredOption('-m, --milestone <milestone>')
70
- .option('-p, --projectIds <projectIds...>')
71
- .option('--hotfix')
72
- .option('--major')
73
- .option('--trigger-monorepo-build')
74
- .action(function (options) { return __awaiter(_this, void 0, void 0, function () {
75
- var milestoneCommandOptions, releaseCommandOptions;
76
- return __generator(this, function (_a) {
77
- milestoneCommandOptions = (0, AddMilestoneCommand_1.processMilestoneCommandOptions)(lodash_1.default.omit(options, 'triggerMonorepoBuild'));
78
- releaseCommandOptions = __assign(__assign({}, milestoneCommandOptions), { triggerMonorepoBuild: !!options.triggerMonorepoBuild });
79
- return [2 /*return*/, getAction('release')(releaseCommandOptions)];
80
- });
81
- }); });
15
+ addMilestoneCommand('release', 'Create releases for all projects that are part of a milestone');
82
16
  program.command('bump-packages')
83
17
  .description('Bump clickview npm package versions in monorepo to their next version')
84
18
  .requiredOption('-b, --branchName <branchName>')
@@ -87,15 +21,9 @@ function setupCommands(program, container) {
87
21
  program.command('install-packages')
88
22
  .description('Install the latest clickview npm packages in all consuming projects that are part of a milestone')
89
23
  .option('-m, --milestone <milestone>')
90
- .option('-b, --branchName <monorepoBranchName>')
24
+ .option('-b, --branchName <branchName>')
91
25
  .option('-p, --projectIds <projectIds...>')
92
26
  .action(getAction('install-packages'));
93
- program.command('start-consuming-project-builds')
94
- .description('Trigger TeamCity builds in all consuming projects that are a part of a milestone')
95
- .option('-m, --milestone <milestone>')
96
- .option('--monorepoBranchName <monorepoBranchName>')
97
- .option('-p, --projectIds <projectIds...>')
98
- .action(getAction('start-consuming-project-builds'));
99
27
  program.command('validate-mr')
100
28
  .description('Validate a merge request in a single project, ensuring it has a milestone and valid description')
101
29
  .option('-p, --projectId <projectId>')
@@ -89,12 +89,11 @@ var BumpPackagesTask = /** @class */ (function () {
89
89
  return [4 /*yield*/, this.getLernaCommand(options)];
90
90
  case 2:
91
91
  lernaVersionCmd = _a.sent();
92
- console.log("Found lerna command ".concat(lernaVersionCmd, " but running dev versioning script for testing purposes"));
93
92
  if (!lernaVersionCmd) {
94
93
  utils_1.Logger.logError('Something went wrong while trying to detect which versioning script to run with Lerna.');
95
94
  return [2 /*return*/, false];
96
95
  }
97
- (0, child_process_1.execSync)("lerna version prepatch --preid dev ".concat(SHARED_LERNA_OPTIONS));
96
+ (0, child_process_1.execSync)(lernaVersionCmd);
98
97
  utils_1.Logger.logSuccess('Successfully executed Lerna versioning command.');
99
98
  return [2 /*return*/, true];
100
99
  }
@@ -88,16 +88,9 @@ var CommitPackageVersionsTask = /** @class */ (function () {
88
88
  var commitFiles = [];
89
89
  for (var _i = 0, MONOREPO_PACKAGE_JSON_FILES_1 = MonorepoPackageJsonFiles_1.MONOREPO_PACKAGE_JSON_FILES; _i < MONOREPO_PACKAGE_JSON_FILES_1.length; _i++) {
90
90
  var filePath = MONOREPO_PACKAGE_JSON_FILES_1[_i];
91
- var content = '';
92
- try {
93
- content = (0, fs_1.readFileSync)(filePath, { encoding: 'utf8' });
94
- }
95
- catch (_a) {
96
- continue;
97
- }
98
91
  commitFiles.push({
99
92
  filePath: filePath,
100
- content: content
93
+ content: (0, fs_1.readFileSync)(filePath, { encoding: 'utf8' })
101
94
  });
102
95
  }
103
96
  return commitFiles;
@@ -60,54 +60,36 @@ var CreateBranchTask = /** @class */ (function () {
60
60
  }
61
61
  CreateBranchTask.prototype.run = function (options) {
62
62
  return __awaiter(this, void 0, void 0, function () {
63
- var projects, _loop_1, this_1, _i, projects_1, project;
64
- return __generator(this, function (_a) {
65
- switch (_a.label) {
63
+ var projects, _i, projects_1, project, _a, branch, branchName, branchFrom;
64
+ return __generator(this, function (_b) {
65
+ switch (_b.label) {
66
66
  case 0:
67
67
  utils_1.Logger.logTask('Creating release branches');
68
68
  return [4 /*yield*/, this.service.getProjects(options)];
69
69
  case 1:
70
- projects = _a.sent();
71
- _loop_1 = function (project) {
72
- var _b, branch, branchName, branchFrom;
73
- return __generator(this, function (_c) {
74
- switch (_c.label) {
75
- case 0: return [4 /*yield*/, this_1.service.getNextBranchInfo(project.id, options.version)];
76
- case 1:
77
- _b = _c.sent(), branch = _b.branch, branchName = _b.branchName;
78
- if (branch) {
79
- utils_1.Logger.logWarning("[".concat(project.title, "]: [").concat(branchName, "] Already exists"));
80
- return [2 /*return*/, "continue"];
81
- }
82
- branchFrom = (function () {
83
- if (project.id.toString() === utils_1.ProjectIds.MONOREPO_PROJECT_ID)
84
- return 'docker';
85
- return options.version === 'patch' ? 'master' : 'dev';
86
- })();
87
- // const branchFrom = options.version === 'patch' ? 'master' : 'dev';
88
- return [4 /*yield*/, this_1.service.createBranch(project, branchFrom, branchName, false)];
89
- case 2:
90
- // const branchFrom = options.version === 'patch' ? 'master' : 'dev';
91
- _c.sent();
92
- utils_1.Logger.logMessage("[".concat(project.title, "]: [").concat(branchName, "] Has been created"));
93
- return [2 /*return*/];
94
- }
95
- });
96
- };
97
- this_1 = this;
70
+ projects = _b.sent();
98
71
  _i = 0, projects_1 = projects;
99
- _a.label = 2;
72
+ _b.label = 2;
100
73
  case 2:
101
- if (!(_i < projects_1.length)) return [3 /*break*/, 5];
74
+ if (!(_i < projects_1.length)) return [3 /*break*/, 6];
102
75
  project = projects_1[_i];
103
- return [5 /*yield**/, _loop_1(project)];
76
+ return [4 /*yield*/, this.service.getNextBranchInfo(project.id, options.version)];
104
77
  case 3:
105
- _a.sent();
106
- _a.label = 4;
78
+ _a = _b.sent(), branch = _a.branch, branchName = _a.branchName;
79
+ if (branch) {
80
+ utils_1.Logger.logWarning("[".concat(project.title, "]: [").concat(branchName, "] Already exists"));
81
+ return [3 /*break*/, 5];
82
+ }
83
+ branchFrom = options.version === 'patch' ? 'master' : 'dev';
84
+ return [4 /*yield*/, this.service.createBranch(project, branchFrom, branchName, false)];
107
85
  case 4:
86
+ _b.sent();
87
+ utils_1.Logger.logMessage("[".concat(project.title, "]: [").concat(branchName, "] Has been created"));
88
+ _b.label = 5;
89
+ case 5:
108
90
  _i++;
109
91
  return [3 /*break*/, 2];
110
- case 5: return [2 /*return*/, true];
92
+ case 6: return [2 /*return*/, true];
111
93
  }
112
94
  });
113
95
  });
@@ -84,28 +84,18 @@ var InstallPackagesTask = /** @class */ (function () {
84
84
  switch (_c.label) {
85
85
  case 0:
86
86
  utils_1.Logger.logTask('Installing npm packages');
87
- if (!_options.monorepoBranchName && !_options.milestone) {
88
- utils_1.Logger.logError('Please provide either a milestone or branch name argument.');
89
- return [2 /*return*/, false];
90
- }
91
- milestone = _options.milestone;
92
- if (!!milestone) return [3 /*break*/, 2];
93
- utils_1.Logger.logInfo("Searching for a merge request in project \"monorepo\" with branch name \"".concat(_options.monorepoBranchName, "\"..."));
94
- return [4 /*yield*/, this.service.getMilestoneByBranchName(utils_1.ProjectIds.MONOREPO_PROJECT_ID, _options.monorepoBranchName)];
87
+ return [4 /*yield*/, this.getMilestone(_options)];
95
88
  case 1:
96
89
  milestone = _c.sent();
97
- _c.label = 2;
98
- case 2:
99
90
  if (!milestone)
100
91
  return [2 /*return*/, false];
101
- utils_1.Logger.logInfo("Found milestone \"".concat(milestone, "\". Proceeding to install packages in consuming projects..."));
102
92
  options = {
103
93
  version: _options.version,
104
94
  projectIds: _options.projectIds,
105
95
  milestone: milestone
106
96
  };
107
97
  return [4 /*yield*/, this.service.getProjects(options)];
108
- case 3:
98
+ case 2:
109
99
  projects = _c.sent();
110
100
  monorepo = projects.find(function (p) { return p.id.toString() === utils_1.ProjectIds.MONOREPO_PROJECT_ID; });
111
101
  consumingProjects = projects.filter(function (p) { return p.id.toString() !== utils_1.ProjectIds.MONOREPO_PROJECT_ID; });
@@ -118,14 +108,14 @@ var InstallPackagesTask = /** @class */ (function () {
118
108
  return [2 /*return*/, false];
119
109
  }
120
110
  return [4 /*yield*/, this.service.getNextBranchInfo(monorepo.id, options.version)];
121
- case 4:
111
+ case 3:
122
112
  _a = _c.sent(), monorepoBranch = _a.branch, monorepoBranchName = _a.branchName;
123
113
  if (!monorepoBranch) {
124
114
  utils_1.Logger.logError("[".concat(monorepo.title, "]: [").concat(monorepoBranchName, "] branch does not exist"));
125
115
  return [2 /*return*/, false];
126
116
  }
127
117
  return [4 /*yield*/, this.getPackageVersions(monorepoBranchName)];
128
- case 5:
118
+ case 4:
129
119
  versions = _c.sent();
130
120
  utils_1.Logger.logMessage("Versions identified for ".concat(monorepoBranchName));
131
121
  Object.keys(versions).forEach(function (key) {
@@ -133,26 +123,26 @@ var InstallPackagesTask = /** @class */ (function () {
133
123
  });
134
124
  utils_1.Logger.logMessage('\nInstalling packages:\n');
135
125
  _i = 0, consumingProjects_1 = consumingProjects;
136
- _c.label = 6;
137
- case 6:
138
- if (!(_i < consumingProjects_1.length)) return [3 /*break*/, 11];
126
+ _c.label = 5;
127
+ case 5:
128
+ if (!(_i < consumingProjects_1.length)) return [3 /*break*/, 10];
139
129
  project = consumingProjects_1[_i];
140
130
  return [4 /*yield*/, this.service.getNextBranchInfo(project.id, options.version)];
141
- case 7:
131
+ case 6:
142
132
  _b = _c.sent(), branch = _b.branch, branchName = _b.branchName;
143
133
  if (!branch) {
144
134
  utils_1.Logger.logError("[".concat(project.title, "]: [").concat(branchName, "] does not exist"));
145
- return [3 /*break*/, 10];
135
+ return [3 /*break*/, 9];
146
136
  }
147
137
  return [4 /*yield*/, this.updateAndSavePackageFiles(project, options.milestone, branchName, versions)];
148
- case 8:
138
+ case 7:
149
139
  hasUpdates = _c.sent();
150
140
  /**
151
141
  * If there are no changes to the versions, we're done here
152
142
  */
153
143
  if (!hasUpdates) {
154
144
  utils_1.Logger.logWarning("[".concat(project.title, "]: [").concat(branchName, "] does not require any updates"));
155
- return [3 /*break*/, 10];
145
+ return [3 /*break*/, 9];
156
146
  }
157
147
  /**
158
148
  * Run npm i to update our package log file
@@ -164,17 +154,48 @@ var InstallPackagesTask = /** @class */ (function () {
164
154
  * Commit our updated package.json and package-lock.json
165
155
  */
166
156
  return [4 /*yield*/, this.commitUpdatedFiles(project, options.milestone, branchName)];
167
- case 9:
157
+ case 8:
168
158
  /**
169
159
  * Commit our updated package.json and package-lock.json
170
160
  */
171
161
  _c.sent();
172
162
  utils_1.Logger.logMessage("[".concat(project.title, "]: File changes committed"));
173
- _c.label = 10;
174
- case 10:
163
+ _c.label = 9;
164
+ case 9:
175
165
  _i++;
176
- return [3 /*break*/, 6];
177
- case 11: return [2 /*return*/, true];
166
+ return [3 /*break*/, 5];
167
+ case 10: return [2 /*return*/, true];
168
+ }
169
+ });
170
+ });
171
+ };
172
+ InstallPackagesTask.prototype.getMilestone = function (options) {
173
+ var _a, _b;
174
+ return __awaiter(this, void 0, void 0, function () {
175
+ var mergeRequest;
176
+ return __generator(this, function (_c) {
177
+ switch (_c.label) {
178
+ case 0:
179
+ if (options.milestone)
180
+ return [2 /*return*/, options.milestone];
181
+ if (!options.branchName) {
182
+ utils_1.Logger.logError('Please provide either a milestone or branch name argument.');
183
+ return [2 /*return*/, ''];
184
+ }
185
+ utils_1.Logger.logInfo("Searching for a merge request in project \"monorepo\" with branch name \"".concat(options.branchName, "\"..."));
186
+ return [4 /*yield*/, this.service.getMergeRequest(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.branchName)];
187
+ case 1:
188
+ mergeRequest = _c.sent();
189
+ if (!mergeRequest) {
190
+ utils_1.Logger.logError("No merge request in project \"monorepo\" with branch name \"".concat(options.branchName, "\" could be found."));
191
+ return [2 /*return*/, ''];
192
+ }
193
+ if (!mergeRequest.milestone) {
194
+ utils_1.Logger.logError("No milestone could be found on merge request \"".concat(mergeRequest.title, "\". Please attach a milestone then try again: ").concat(mergeRequest.url));
195
+ return [2 /*return*/, ''];
196
+ }
197
+ utils_1.Logger.logInfo("Found milestone \"".concat(mergeRequest.milestone.name, "\". Proceeding to install packages in consuming projects..."));
198
+ return [2 /*return*/, (_b = (_a = mergeRequest.milestone) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ''];
178
199
  }
179
200
  });
180
201
  });