@clickview/ship-it 0.0.41 → 0.0.42-dev.1
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/lib/src/api-clients/git-lab/GitLabApiClient.js +15 -12
- package/lib/src/commands/CreateTrelloCardsCommand.js +3 -4
- package/lib/src/interfaces/command-cli-options/DockerMilestoneCommandCliOptions.js +2 -0
- package/lib/src/services/GitLabService.js +37 -28
- package/lib/src/startup/AddMilestoneCommand.js +11 -19
- package/lib/src/startup/SetupCommands.js +14 -3
- package/lib/src/tasks/BumpVersionTxtTask.js +1 -1
- package/lib/src/tasks/CreateBranchTask.js +1 -1
- package/lib/src/tasks/CreateMergeRequestTask.js +10 -2
- package/lib/src/tasks/CreateNotesAuditTask.js +1 -1
- package/lib/src/tasks/CreateReleaseNotesTask.js +1 -1
- package/lib/src/tasks/InstallPackagesTask.js +19 -25
- package/lib/src/tasks/PopulateTrelloBoardTask.js +1 -1
- package/lib/src/tasks/StartMonorepoBuildTask.js +1 -1
- package/lib/src/tasks/StartProjectBuildsTask.js +15 -21
- package/lib/src/tasks/TagMasterTask.js +9 -2
- package/lib/src/tasks/ValidateCommitsTask.js +111 -44
- package/lib/src/tasks/ValidateDescriptionsTask.js +1 -1
- package/lib/src/tasks/ValidateTask.js +1 -1
- package/lib/src/tasks/VersionTask.js +1 -1
- package/lib/src/tasks/configure-projects/EnsureApprovalRulesTask.js +1 -1
- package/lib/src/utils/Commits.js +27 -0
- package/lib/src/utils/ProjectIds.js +1 -0
- package/package.json +27 -27
|
@@ -65,13 +65,13 @@ var GitLabApiClient = /** @class */ (function () {
|
|
|
65
65
|
host: this.config.url
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
GitLabApiClient.prototype.getMergeRequests = function (
|
|
68
|
+
GitLabApiClient.prototype.getMergeRequests = function (milestone, projectIds) {
|
|
69
|
+
if (projectIds === void 0) { projectIds = []; }
|
|
69
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
-
var
|
|
71
|
+
var updatedAfter, mergeRequests;
|
|
71
72
|
return __generator(this, function (_a) {
|
|
72
73
|
switch (_a.label) {
|
|
73
74
|
case 0:
|
|
74
|
-
milestone = options.milestone, projectIds = options.projectIds;
|
|
75
75
|
if (!milestone && !(projectIds === null || projectIds === void 0 ? void 0 : projectIds.length))
|
|
76
76
|
throw new errors_1.ShipItError('Must specify one of the following: Milestone or ProjectIds');
|
|
77
77
|
updatedAfter = new Date();
|
|
@@ -198,13 +198,13 @@ var GitLabApiClient = /** @class */ (function () {
|
|
|
198
198
|
});
|
|
199
199
|
});
|
|
200
200
|
};
|
|
201
|
-
GitLabApiClient.prototype.
|
|
201
|
+
GitLabApiClient.prototype.getCommitsForBranch = function (branchName, projectId, dateSince) {
|
|
202
202
|
return __awaiter(this, void 0, void 0, function () {
|
|
203
203
|
var commits;
|
|
204
204
|
return __generator(this, function (_a) {
|
|
205
205
|
switch (_a.label) {
|
|
206
206
|
case 0: return [4 /*yield*/, this.client.Commits.all(projectId, {
|
|
207
|
-
ref_name:
|
|
207
|
+
ref_name: branchName,
|
|
208
208
|
since: dateSince,
|
|
209
209
|
/**
|
|
210
210
|
* This allows us to get merge commits of MRs being accepted
|
|
@@ -328,16 +328,19 @@ var GitLabApiClient = /** @class */ (function () {
|
|
|
328
328
|
});
|
|
329
329
|
});
|
|
330
330
|
};
|
|
331
|
-
GitLabApiClient.prototype.createMergeRequest = function (
|
|
331
|
+
GitLabApiClient.prototype.createMergeRequest = function (options) {
|
|
332
332
|
return __awaiter(this, void 0, void 0, function () {
|
|
333
|
-
var mergeRequest;
|
|
333
|
+
var projectId, sourceBranch, targetBranch, title, description, milestone, removeSourceBranch, mergeRequest;
|
|
334
334
|
return __generator(this, function (_a) {
|
|
335
335
|
switch (_a.label) {
|
|
336
|
-
case 0:
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
336
|
+
case 0:
|
|
337
|
+
projectId = options.projectId, sourceBranch = options.sourceBranch, targetBranch = options.targetBranch, title = options.title, description = options.description, milestone = options.milestone, removeSourceBranch = options.removeSourceBranch;
|
|
338
|
+
return [4 /*yield*/, this.client.MergeRequests.create(projectId, sourceBranch, targetBranch, title, {
|
|
339
|
+
description: description,
|
|
340
|
+
milestoneId: milestone.id,
|
|
341
|
+
assigneeId: GitLabMemberIds_1.GitLabMemberIds.SHIP_IT,
|
|
342
|
+
removeSourceBranch: removeSourceBranch
|
|
343
|
+
})];
|
|
341
344
|
case 1:
|
|
342
345
|
mergeRequest = _a.sent();
|
|
343
346
|
return [2 /*return*/, GitLabMapper_1.GitLabMapper.mergeRequest(mergeRequest)];
|
|
@@ -53,7 +53,7 @@ require("reflect-metadata");
|
|
|
53
53
|
var inversify_1 = require("inversify");
|
|
54
54
|
var types_1 = require("../types");
|
|
55
55
|
var CreateTrelloCardsCommand = /** @class */ (function () {
|
|
56
|
-
function CreateTrelloCardsCommand(
|
|
56
|
+
function CreateTrelloCardsCommand(populateTrelloBoardTask) {
|
|
57
57
|
this.populateTrelloBoardTask = populateTrelloBoardTask;
|
|
58
58
|
}
|
|
59
59
|
CreateTrelloCardsCommand.prototype.run = function (options) {
|
|
@@ -68,9 +68,8 @@ var CreateTrelloCardsCommand = /** @class */ (function () {
|
|
|
68
68
|
};
|
|
69
69
|
CreateTrelloCardsCommand = __decorate([
|
|
70
70
|
(0, inversify_1.injectable)(),
|
|
71
|
-
__param(0, (0, inversify_1.inject)(types_1.TASKS.
|
|
72
|
-
|
|
73
|
-
__metadata("design:paramtypes", [Object, Object])
|
|
71
|
+
__param(0, (0, inversify_1.inject)(types_1.TASKS.PopulateTrelloBoardTask)),
|
|
72
|
+
__metadata("design:paramtypes", [Object])
|
|
74
73
|
], CreateTrelloCardsCommand);
|
|
75
74
|
return CreateTrelloCardsCommand;
|
|
76
75
|
}());
|
|
@@ -83,40 +83,41 @@ var GitLabService = /** @class */ (function () {
|
|
|
83
83
|
this.projectConfigCache = {};
|
|
84
84
|
this.apiClient = apiClient;
|
|
85
85
|
}
|
|
86
|
-
GitLabService.prototype.getProjects = function (
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
GitLabService.prototype.getProjects = function (milestone, projectIds, omittedProjectIds, _a) {
|
|
87
|
+
if (projectIds === void 0) { projectIds = []; }
|
|
88
|
+
if (omittedProjectIds === void 0) { omittedProjectIds = []; }
|
|
89
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.invalidateCache, invalidateCache = _c === void 0 ? false : _c;
|
|
89
90
|
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
-
var allMergeRequests, mergeRequests,
|
|
91
|
-
return __generator(this, function (
|
|
92
|
-
switch (
|
|
91
|
+
var allMergeRequests, mergeRequests, releaseProjectIds, projects, mappedProjects, _i, mappedProjects_1, mappedProject, extraProjects;
|
|
92
|
+
return __generator(this, function (_d) {
|
|
93
|
+
switch (_d.label) {
|
|
93
94
|
case 0:
|
|
94
95
|
// If invalidateCache is false and projects are cached, return the cached projects
|
|
95
96
|
if (!invalidateCache && this.projects)
|
|
96
97
|
return [2 /*return*/, this.projects];
|
|
97
|
-
return [4 /*yield*/, this.apiClient.getMergeRequests(
|
|
98
|
+
return [4 /*yield*/, this.apiClient.getMergeRequests(milestone, projectIds)];
|
|
98
99
|
case 1:
|
|
99
|
-
allMergeRequests =
|
|
100
|
+
allMergeRequests = _d.sent();
|
|
100
101
|
mergeRequests = allMergeRequests.filter(function (mr) { return mr.targetBranch !== 'master'; });
|
|
101
102
|
if (!(mergeRequests === null || mergeRequests === void 0 ? void 0 : mergeRequests.length))
|
|
102
103
|
throw new errors_1.ShipItError('Could not find any merge requests for the specified options');
|
|
103
|
-
|
|
104
|
-
return [4 /*yield*/, this.apiClient.getProjectsByIds(
|
|
104
|
+
releaseProjectIds = lodash_1.default.uniqBy(mergeRequests, function (m) { return m.projectId; }).map(function (m) { return m.projectId; });
|
|
105
|
+
return [4 /*yield*/, this.apiClient.getProjectsByIds(releaseProjectIds)];
|
|
105
106
|
case 2:
|
|
106
|
-
projects =
|
|
107
|
-
if (!(projects === null || projects === void 0 ? void 0 : projects.length) || projects.length !==
|
|
107
|
+
projects = _d.sent();
|
|
108
|
+
if (!(projects === null || projects === void 0 ? void 0 : projects.length) || projects.length !== releaseProjectIds.length)
|
|
108
109
|
throw new errors_1.ShipItError('Could not find all projects for the found merge requests');
|
|
109
110
|
mappedProjects = projects.map(function (p) { return (__assign(__assign({}, p), { mergeRequests: mergeRequests.filter(function (mr) { return mr.projectId === p.id; }) })); });
|
|
110
111
|
_i = 0, mappedProjects_1 = mappedProjects;
|
|
111
|
-
|
|
112
|
+
_d.label = 3;
|
|
112
113
|
case 3:
|
|
113
114
|
if (!(_i < mappedProjects_1.length)) return [3 /*break*/, 6];
|
|
114
115
|
mappedProject = mappedProjects_1[_i];
|
|
115
|
-
return [4 /*yield*/, this.getExtraProjects(mappedProject,
|
|
116
|
+
return [4 /*yield*/, this.getExtraProjects(mappedProject, releaseProjectIds)];
|
|
116
117
|
case 4:
|
|
117
|
-
extraProjects =
|
|
118
|
+
extraProjects = _d.sent();
|
|
118
119
|
Array.prototype.push.apply(mappedProjects, extraProjects.map(function (p) { return (__assign(__assign({}, p), { mergeRequests: [] })); }));
|
|
119
|
-
|
|
120
|
+
_d.label = 5;
|
|
120
121
|
case 5:
|
|
121
122
|
_i++;
|
|
122
123
|
return [3 /*break*/, 3];
|
|
@@ -124,16 +125,14 @@ var GitLabService = /** @class */ (function () {
|
|
|
124
125
|
/**
|
|
125
126
|
* We need to filter our relevant projects after we've added extra projects via tags
|
|
126
127
|
*/
|
|
127
|
-
if (
|
|
128
|
+
if (projectIds === null || projectIds === void 0 ? void 0 : projectIds.length) {
|
|
128
129
|
mappedProjects = mappedProjects.filter(function (p) {
|
|
129
|
-
|
|
130
|
-
return (_a = options.projectIds) === null || _a === void 0 ? void 0 : _a.some(function (pid) { return p.id.toString() === pid; });
|
|
130
|
+
return projectIds === null || projectIds === void 0 ? void 0 : projectIds.some(function (pid) { return p.id.toString() === pid; });
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
if (
|
|
133
|
+
if (omittedProjectIds === null || omittedProjectIds === void 0 ? void 0 : omittedProjectIds.length) {
|
|
134
134
|
mappedProjects = mappedProjects.filter(function (p) {
|
|
135
|
-
|
|
136
|
-
return !((_a = options.omittedProjectIds) === null || _a === void 0 ? void 0 : _a.some(function (pid) { return p.id.toString() === pid; }));
|
|
135
|
+
return !(omittedProjectIds === null || omittedProjectIds === void 0 ? void 0 : omittedProjectIds.some(function (pid) { return p.id.toString() === pid; }));
|
|
137
136
|
});
|
|
138
137
|
}
|
|
139
138
|
return [2 /*return*/, (this.projects = mappedProjects)];
|
|
@@ -217,11 +216,11 @@ var GitLabService = /** @class */ (function () {
|
|
|
217
216
|
});
|
|
218
217
|
});
|
|
219
218
|
};
|
|
220
|
-
GitLabService.prototype.
|
|
219
|
+
GitLabService.prototype.getCommitsForBranch = function (branch, projectId, dateSince) {
|
|
221
220
|
return __awaiter(this, void 0, void 0, function () {
|
|
222
221
|
return __generator(this, function (_a) {
|
|
223
222
|
switch (_a.label) {
|
|
224
|
-
case 0: return [4 /*yield*/, this.apiClient.
|
|
223
|
+
case 0: return [4 /*yield*/, this.apiClient.getCommitsForBranch(branch, projectId, dateSince)];
|
|
225
224
|
case 1: return [2 /*return*/, _a.sent()];
|
|
226
225
|
}
|
|
227
226
|
});
|
|
@@ -286,15 +285,25 @@ var GitLabService = /** @class */ (function () {
|
|
|
286
285
|
throw new errors_1.ShipItError("MergeRequest Id must be a number: ".concat(mergeRequestId));
|
|
287
286
|
return this.apiClient.getMergeRequestById(projectId, +mergeRequestId);
|
|
288
287
|
};
|
|
289
|
-
GitLabService.prototype.createMergeRequest = function (
|
|
288
|
+
GitLabService.prototype.createMergeRequest = function (options) {
|
|
290
289
|
return __awaiter(this, void 0, void 0, function () {
|
|
291
|
-
var milestone;
|
|
290
|
+
var projectId, sourceBranch, targetBranch, title, description, milestoneName, removeSourceBranch, milestone;
|
|
292
291
|
return __generator(this, function (_a) {
|
|
293
292
|
switch (_a.label) {
|
|
294
|
-
case 0:
|
|
293
|
+
case 0:
|
|
294
|
+
projectId = options.projectId, sourceBranch = options.sourceBranch, targetBranch = options.targetBranch, title = options.title, description = options.description, milestoneName = options.milestoneName, removeSourceBranch = options.removeSourceBranch;
|
|
295
|
+
return [4 /*yield*/, this.getMilestone(milestoneName, projectId)];
|
|
295
296
|
case 1:
|
|
296
297
|
milestone = _a.sent();
|
|
297
|
-
return [2 /*return*/, this.apiClient.createMergeRequest(
|
|
298
|
+
return [2 /*return*/, this.apiClient.createMergeRequest({
|
|
299
|
+
projectId: projectId,
|
|
300
|
+
sourceBranch: sourceBranch,
|
|
301
|
+
targetBranch: targetBranch,
|
|
302
|
+
title: title,
|
|
303
|
+
description: description,
|
|
304
|
+
milestone: milestone,
|
|
305
|
+
removeSourceBranch: removeSourceBranch
|
|
306
|
+
})];
|
|
298
307
|
}
|
|
299
308
|
});
|
|
300
309
|
});
|
|
@@ -1,15 +1,4 @@
|
|
|
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
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -51,20 +40,23 @@ exports.processMilestoneCommandOptions = exports.getAddMilestoneCommand = void 0
|
|
|
51
40
|
var utils_1 = require("../utils");
|
|
52
41
|
function processOptions(options) {
|
|
53
42
|
var _a, _b;
|
|
54
|
-
var opts = __assign(__assign({}, options), { version: 'minor' });
|
|
55
43
|
if (((_a = options.projectIds) === null || _a === void 0 ? void 0 : _a.length) && ((_b = options.omit) === null || _b === void 0 ? void 0 : _b.length))
|
|
56
44
|
throw new Error("Cannot provide both project IDs and omitted project IDs in the same command");
|
|
57
|
-
if (options.projectIds)
|
|
58
|
-
opts.projectIds = utils_1.ProjectIds.getProjectIds(options.projectIds);
|
|
59
|
-
if (options.omit)
|
|
60
|
-
opts.omittedProjectIds = utils_1.ProjectIds.getProjectIds(options.omit);
|
|
61
45
|
if (options.hotfix && options.major)
|
|
62
46
|
throw new Error('Cannot pass both --hotfix and --major options');
|
|
47
|
+
var commandOptions = {
|
|
48
|
+
milestone: options.milestone,
|
|
49
|
+
version: 'minor',
|
|
50
|
+
slackNotifier: options.slackNotifier || false,
|
|
51
|
+
projectIds: utils_1.ProjectIds.getProjectIds(options.projectIds),
|
|
52
|
+
omittedProjectIds: utils_1.ProjectIds.getProjectIds(options.omit),
|
|
53
|
+
nextMilestone: options.nextMilestone || null
|
|
54
|
+
};
|
|
63
55
|
if (options.major)
|
|
64
|
-
|
|
56
|
+
commandOptions.version = 'major';
|
|
65
57
|
if (options.hotfix)
|
|
66
|
-
|
|
67
|
-
return
|
|
58
|
+
commandOptions.version = 'patch';
|
|
59
|
+
return commandOptions;
|
|
68
60
|
}
|
|
69
61
|
exports.processMilestoneCommandOptions = processOptions;
|
|
70
62
|
var getAddMilestoneCommand = function (program, getAction) {
|
|
@@ -1,4 +1,15 @@
|
|
|
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
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -104,7 +115,7 @@ function setupCommands(program, container) {
|
|
|
104
115
|
return __generator(this, function (_a) {
|
|
105
116
|
switch (_a.label) {
|
|
106
117
|
case 0:
|
|
107
|
-
options = (0, AddMilestoneCommand_1.processMilestoneCommandOptions)(opts);
|
|
118
|
+
options = __assign(__assign({}, (0, AddMilestoneCommand_1.processMilestoneCommandOptions)(opts)), { triggerMonorepoBuild: opts.triggerMonorepoBuild || false });
|
|
108
119
|
return [4 /*yield*/, getAction('release')(options)];
|
|
109
120
|
case 1:
|
|
110
121
|
_a.sent();
|
|
@@ -129,7 +140,7 @@ function setupCommands(program, container) {
|
|
|
129
140
|
return __generator(this, function (_a) {
|
|
130
141
|
switch (_a.label) {
|
|
131
142
|
case 0:
|
|
132
|
-
options = (0, AddMilestoneCommand_1.processMilestoneCommandOptions)(opts);
|
|
143
|
+
options = __assign(__assign({}, (0, AddMilestoneCommand_1.processMilestoneCommandOptions)(opts)), { targetBranchName: opts.targetBranchName || null, monorepoBranchName: opts.monorepoBranchName || null });
|
|
133
144
|
return [4 /*yield*/, getAction('install-packages')(options)];
|
|
134
145
|
case 1:
|
|
135
146
|
_a.sent();
|
|
@@ -154,7 +165,7 @@ function setupCommands(program, container) {
|
|
|
154
165
|
return __generator(this, function (_a) {
|
|
155
166
|
switch (_a.label) {
|
|
156
167
|
case 0:
|
|
157
|
-
options = (0, AddMilestoneCommand_1.processMilestoneCommandOptions)(opts);
|
|
168
|
+
options = __assign(__assign({}, (0, AddMilestoneCommand_1.processMilestoneCommandOptions)(opts)), { targetBranchName: opts.targetBranchName || null, monorepoBranchName: opts.monorepoBranchName || null });
|
|
158
169
|
return [4 /*yield*/, getAction('start-project-builds')(options)];
|
|
159
170
|
case 1:
|
|
160
171
|
_a.sent();
|
|
@@ -66,7 +66,7 @@ var BumpVersionTxtTask = /** @class */ (function () {
|
|
|
66
66
|
switch (_b.label) {
|
|
67
67
|
case 0:
|
|
68
68
|
Logger_1.Logger.logTask('Bumping version.txt');
|
|
69
|
-
return [4 /*yield*/, this.service.getProjects(options)];
|
|
69
|
+
return [4 /*yield*/, this.service.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
70
70
|
case 1:
|
|
71
71
|
projects = _b.sent();
|
|
72
72
|
_i = 0, projects_1 = projects;
|
|
@@ -65,7 +65,7 @@ var CreateBranchTask = /** @class */ (function () {
|
|
|
65
65
|
switch (_b.label) {
|
|
66
66
|
case 0:
|
|
67
67
|
utils_1.Logger.logTask('Creating release branches');
|
|
68
|
-
return [4 /*yield*/, this.service.getProjects(options)];
|
|
68
|
+
return [4 /*yield*/, this.service.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
69
69
|
case 1:
|
|
70
70
|
projects = _b.sent();
|
|
71
71
|
_i = 0, projects_1 = projects;
|
|
@@ -65,7 +65,7 @@ var CreateMergeRequestTask = /** @class */ (function () {
|
|
|
65
65
|
switch (_b.label) {
|
|
66
66
|
case 0:
|
|
67
67
|
utils_1.Logger.logTask('Creating Merge Requests');
|
|
68
|
-
return [4 /*yield*/, this.service.getProjects(options)];
|
|
68
|
+
return [4 /*yield*/, this.service.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
69
69
|
case 1:
|
|
70
70
|
projects = _b.sent();
|
|
71
71
|
_i = 0, projects_1 = projects;
|
|
@@ -94,7 +94,15 @@ var CreateMergeRequestTask = /** @class */ (function () {
|
|
|
94
94
|
description = projectConfig.monorepo.enabled ?
|
|
95
95
|
utils_1.Descriptions.getMonorepoCombinedDescription(project.mergeRequests) :
|
|
96
96
|
utils_1.Descriptions.getCombinedDescription(project.mergeRequests);
|
|
97
|
-
return [4 /*yield*/, this.service.createMergeRequest(
|
|
97
|
+
return [4 /*yield*/, this.service.createMergeRequest({
|
|
98
|
+
projectId: project.id,
|
|
99
|
+
sourceBranch: branchName,
|
|
100
|
+
targetBranch: 'master',
|
|
101
|
+
title: branchName,
|
|
102
|
+
description: description,
|
|
103
|
+
milestoneName: options.milestone,
|
|
104
|
+
removeSourceBranch: true
|
|
105
|
+
})];
|
|
98
106
|
case 6:
|
|
99
107
|
mergeRequest = _b.sent();
|
|
100
108
|
utils_1.Logger.logMessage("[".concat(project.title, "]: MR created"));
|
|
@@ -71,7 +71,7 @@ var CreateNotesAuditTask = /** @class */ (function () {
|
|
|
71
71
|
switch (_c.label) {
|
|
72
72
|
case 0:
|
|
73
73
|
utils_1.Logger.logTask('Creating release notes audit');
|
|
74
|
-
return [4 /*yield*/, this.service.getProjects(options)];
|
|
74
|
+
return [4 /*yield*/, this.service.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
75
75
|
case 1:
|
|
76
76
|
projects = _c.sent();
|
|
77
77
|
projectTestingNotes = [];
|
|
@@ -72,7 +72,7 @@ var CreateReleaseNotesTask = /** @class */ (function () {
|
|
|
72
72
|
switch (_c.label) {
|
|
73
73
|
case 0:
|
|
74
74
|
utils_1.Logger.logTask('Creating release notes');
|
|
75
|
-
return [4 /*yield*/, this.gitlabService.getProjects(options)];
|
|
75
|
+
return [4 /*yield*/, this.gitlabService.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
76
76
|
case 1:
|
|
77
77
|
projects = _c.sent();
|
|
78
78
|
combinedDescription = '';
|
|
@@ -83,40 +83,40 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
83
83
|
function InstallPackagesTask(service) {
|
|
84
84
|
this.service = service;
|
|
85
85
|
}
|
|
86
|
-
InstallPackagesTask.prototype.run = function (
|
|
86
|
+
InstallPackagesTask.prototype.run = function (options) {
|
|
87
87
|
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
-
var targetBranch, projectId, project, versions_1, folderName, hasUpdates, error_1, milestone,
|
|
88
|
+
var targetBranch, projectId, project, versions_1, folderName, hasUpdates, error_1, milestone, projects, monorepo, consumingProjects, _a, monorepoBranch, monorepoBranchName, versions, _i, consumingProjects_1, project, _b, branch, branchName, hasUpdates, _c;
|
|
89
89
|
return __generator(this, function (_d) {
|
|
90
90
|
switch (_d.label) {
|
|
91
91
|
case 0:
|
|
92
92
|
utils_1.Logger.logTask('Installing npm packages');
|
|
93
|
-
if (!
|
|
93
|
+
if (!options.monorepoBranchName && !options.milestone) {
|
|
94
94
|
utils_1.Logger.logError('Please provide either a milestone or branch name argument.');
|
|
95
95
|
return [2 /*return*/, false];
|
|
96
96
|
}
|
|
97
|
-
if (!(
|
|
98
|
-
targetBranch =
|
|
99
|
-
if (targetBranch.startsWith('release') && !
|
|
97
|
+
if (!(options.targetBranchName && options.monorepoBranchName && options.projectIds)) return [3 /*break*/, 8];
|
|
98
|
+
targetBranch = options.targetBranchName;
|
|
99
|
+
if (targetBranch.startsWith('release') && !options.monorepoBranchName.startsWith('release')) {
|
|
100
100
|
utils_1.Logger.logError('Attempting to target release with non release branch.');
|
|
101
101
|
return [2 /*return*/, false];
|
|
102
102
|
}
|
|
103
|
-
if (targetBranch.startsWith('hotfix') && !
|
|
103
|
+
if (targetBranch.startsWith('hotfix') && !options.monorepoBranchName.startsWith('hotfix')) {
|
|
104
104
|
utils_1.Logger.logError('Attempting to target hotfix with non hotfix branch.');
|
|
105
105
|
return [2 /*return*/, false];
|
|
106
106
|
}
|
|
107
|
-
if (
|
|
108
|
-
utils_1.Logger.logError("Too many projects given! Maximum 1 project allowed but got ".concat(
|
|
107
|
+
if (options.projectIds.length > 1) {
|
|
108
|
+
utils_1.Logger.logError("Too many projects given! Maximum 1 project allowed but got ".concat(options.projectIds.length));
|
|
109
109
|
return [2 /*return*/, false];
|
|
110
110
|
}
|
|
111
|
-
projectId =
|
|
111
|
+
projectId = options.projectIds[0];
|
|
112
112
|
return [4 /*yield*/, this.service.getProject(projectId)];
|
|
113
113
|
case 1:
|
|
114
114
|
project = _d.sent();
|
|
115
|
-
return [4 /*yield*/, this.getPackageVersions(
|
|
115
|
+
return [4 /*yield*/, this.getPackageVersions(options.monorepoBranchName)];
|
|
116
116
|
case 2:
|
|
117
117
|
versions_1 = _d.sent();
|
|
118
118
|
folderName = 'hotfix';
|
|
119
|
-
utils_1.Logger.logMessage("Versions identified for ".concat(
|
|
119
|
+
utils_1.Logger.logMessage("Versions identified for ".concat(options.monorepoBranchName));
|
|
120
120
|
Object.keys(versions_1).forEach(function (key) {
|
|
121
121
|
utils_1.Logger.logMessage("- [".concat(key, "]: ").concat(versions_1[key]));
|
|
122
122
|
});
|
|
@@ -156,10 +156,10 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
156
156
|
return [3 /*break*/, 7];
|
|
157
157
|
case 7: return [2 /*return*/, true];
|
|
158
158
|
case 8:
|
|
159
|
-
milestone =
|
|
159
|
+
milestone = options.milestone;
|
|
160
160
|
if (!!milestone) return [3 /*break*/, 10];
|
|
161
|
-
utils_1.Logger.logInfo("Searching for a merge request in project \"monorepo\" with branch name \"".concat(
|
|
162
|
-
return [4 /*yield*/, this.service.getMilestoneByBranchName(utils_1.ProjectIds.MONOREPO_PROJECT_ID,
|
|
161
|
+
utils_1.Logger.logInfo("Searching for a merge request in project \"monorepo\" with branch name \"".concat(options.monorepoBranchName, "\"..."));
|
|
162
|
+
return [4 /*yield*/, this.service.getMilestoneByBranchName(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.monorepoBranchName)];
|
|
163
163
|
case 9:
|
|
164
164
|
milestone = _d.sent();
|
|
165
165
|
_d.label = 10;
|
|
@@ -167,13 +167,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
167
167
|
if (!milestone)
|
|
168
168
|
return [2 /*return*/, false];
|
|
169
169
|
utils_1.Logger.logInfo("Found milestone \"".concat(milestone, "\". Proceeding to install packages in consuming projects..."));
|
|
170
|
-
options
|
|
171
|
-
version: _options.version,
|
|
172
|
-
projectIds: _options.projectIds,
|
|
173
|
-
omittedProjectIds: _options.omittedProjectIds,
|
|
174
|
-
milestone: milestone
|
|
175
|
-
};
|
|
176
|
-
return [4 /*yield*/, this.service.getProjects(options)];
|
|
170
|
+
return [4 /*yield*/, this.service.getProjects(milestone, options.projectIds, options.omittedProjectIds)];
|
|
177
171
|
case 11:
|
|
178
172
|
projects = _d.sent();
|
|
179
173
|
monorepo = projects.find(function (p) { return p.id.toString() === utils_1.ProjectIds.MONOREPO_PROJECT_ID; });
|
|
@@ -216,7 +210,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
216
210
|
utils_1.Logger.logError("[".concat(project.title, "]: [").concat(branchName, "] does not exist"));
|
|
217
211
|
return [3 /*break*/, 20];
|
|
218
212
|
}
|
|
219
|
-
return [4 /*yield*/, this.updateAndSavePackageFiles(project,
|
|
213
|
+
return [4 /*yield*/, this.updateAndSavePackageFiles(project, milestone, branchName, versions)];
|
|
220
214
|
case 17:
|
|
221
215
|
hasUpdates = _d.sent();
|
|
222
216
|
/**
|
|
@@ -230,12 +224,12 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
230
224
|
* Run npm i to update our package log file
|
|
231
225
|
*/
|
|
232
226
|
utils_1.Logger.logInfo("[".concat(project.title, "]: Running npm i --package-lock-only --verbose"));
|
|
233
|
-
this.npmInstall(project,
|
|
227
|
+
this.npmInstall(project, milestone);
|
|
234
228
|
utils_1.Logger.logInfo('\n');
|
|
235
229
|
/**
|
|
236
230
|
* Commit our updated package.json and package-lock.json
|
|
237
231
|
*/
|
|
238
|
-
return [4 /*yield*/, this.commitUpdatedFiles(project,
|
|
232
|
+
return [4 /*yield*/, this.commitUpdatedFiles(project, milestone, branchName)];
|
|
239
233
|
case 18:
|
|
240
234
|
/**
|
|
241
235
|
* Commit our updated package.json and package-lock.json
|
|
@@ -68,7 +68,7 @@ var PopulateTrelloBoardTask = /** @class */ (function () {
|
|
|
68
68
|
switch (_b.label) {
|
|
69
69
|
case 0:
|
|
70
70
|
utils_1.Logger.logTask('Starting Trello Board population');
|
|
71
|
-
return [4 /*yield*/, this.service.getProjects(options)];
|
|
71
|
+
return [4 /*yield*/, this.service.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
72
72
|
case 1:
|
|
73
73
|
projects = _b.sent();
|
|
74
74
|
utils_1.Logger.logMessage("Found ".concat(projects.length, " projects that need to be released"));
|
|
@@ -75,7 +75,7 @@ var StartMonorepoBuildTask = /** @class */ (function () {
|
|
|
75
75
|
utils_1.Logger.logError("Monorepo release branch with milestone \"".concat(options.milestone, "\" was not found."));
|
|
76
76
|
return [2 /*return*/, false];
|
|
77
77
|
}
|
|
78
|
-
return [4 /*yield*/, this.gitLabService.getProjects(options)];
|
|
78
|
+
return [4 /*yield*/, this.gitLabService.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
79
79
|
case 2:
|
|
80
80
|
projects = _a.sent();
|
|
81
81
|
packageNames = [];
|
|
@@ -60,20 +60,20 @@ var StartProjectBuildsTask = /** @class */ (function () {
|
|
|
60
60
|
this.teamCityService = teamCityService;
|
|
61
61
|
this.gitLabService = gitLabService;
|
|
62
62
|
}
|
|
63
|
-
StartProjectBuildsTask.prototype.run = function (
|
|
63
|
+
StartProjectBuildsTask.prototype.run = function (options) {
|
|
64
64
|
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var projectName, project, buildId, build, milestone,
|
|
65
|
+
var projectName, project, buildId, build, milestone, projects, consumingProjects, projectBuildMap, _i, consumingProjects_1, project, branchName, buildId, build, totalBuilds, project;
|
|
66
66
|
return __generator(this, function (_a) {
|
|
67
67
|
switch (_a.label) {
|
|
68
68
|
case 0:
|
|
69
69
|
utils_1.Logger.logTask('Starting builds for consuming projects in TeamCity');
|
|
70
|
-
if (!(
|
|
71
|
-
utils_1.Logger.logMessage("Starting consuming project build for given target branch ".concat(
|
|
72
|
-
if (
|
|
70
|
+
if (!(options.targetBranchName && options.projectIds)) return [3 /*break*/, 3];
|
|
71
|
+
utils_1.Logger.logMessage("Starting consuming project build for given target branch ".concat(options.targetBranchName));
|
|
72
|
+
if (options.projectIds.length > 1) {
|
|
73
73
|
utils_1.Logger.logError("More than one project found!");
|
|
74
74
|
return [2 /*return*/, false];
|
|
75
75
|
}
|
|
76
|
-
projectName =
|
|
76
|
+
projectName = options.projectIds[0];
|
|
77
77
|
return [4 /*yield*/, this.gitLabService.getProject(projectName)];
|
|
78
78
|
case 1:
|
|
79
79
|
project = _a.sent();
|
|
@@ -82,20 +82,20 @@ var StartProjectBuildsTask = /** @class */ (function () {
|
|
|
82
82
|
utils_1.Logger.logWarning("Skipping build for ".concat(project.title, " as no Team City build ID has been specified"));
|
|
83
83
|
return [2 /*return*/, false];
|
|
84
84
|
}
|
|
85
|
-
return [4 /*yield*/, this.teamCityService.startBuild(buildId,
|
|
85
|
+
return [4 /*yield*/, this.teamCityService.startBuild(buildId, options.targetBranchName)];
|
|
86
86
|
case 2:
|
|
87
87
|
build = _a.sent();
|
|
88
88
|
utils_1.Logger.logInfo("[".concat(project.title, "]: ").concat(build.webUrl));
|
|
89
89
|
return [2 /*return*/, true];
|
|
90
90
|
case 3:
|
|
91
|
-
if (!
|
|
91
|
+
if (!options.monorepoBranchName && !options.milestone) {
|
|
92
92
|
utils_1.Logger.logError('Please provide either a milestone or branch name argument.');
|
|
93
93
|
return [2 /*return*/, false];
|
|
94
94
|
}
|
|
95
|
-
milestone =
|
|
95
|
+
milestone = options.milestone;
|
|
96
96
|
if (!!milestone) return [3 /*break*/, 5];
|
|
97
|
-
utils_1.Logger.logInfo("Searching for a merge request in project \"monorepo\" with branch name \"".concat(
|
|
98
|
-
return [4 /*yield*/, this.gitLabService.getMilestoneByBranchName(utils_1.ProjectIds.MONOREPO_PROJECT_ID,
|
|
97
|
+
utils_1.Logger.logInfo("Searching for a merge request in project \"monorepo\" with branch name \"".concat(options.monorepoBranchName, "\"..."));
|
|
98
|
+
return [4 /*yield*/, this.gitLabService.getMilestoneByBranchName(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.monorepoBranchName)];
|
|
99
99
|
case 4:
|
|
100
100
|
milestone = _a.sent();
|
|
101
101
|
_a.label = 5;
|
|
@@ -103,13 +103,7 @@ var StartProjectBuildsTask = /** @class */ (function () {
|
|
|
103
103
|
if (!milestone)
|
|
104
104
|
return [2 /*return*/, false];
|
|
105
105
|
utils_1.Logger.logInfo("Found milestone \"".concat(milestone, "\". Proceeding to run builds for consuming projects..."));
|
|
106
|
-
options
|
|
107
|
-
version: _options.version,
|
|
108
|
-
projectIds: _options.projectIds,
|
|
109
|
-
omittedProjectIds: _options.omittedProjectIds,
|
|
110
|
-
milestone: milestone
|
|
111
|
-
};
|
|
112
|
-
return [4 /*yield*/, this.gitLabService.getProjects(options)];
|
|
106
|
+
return [4 /*yield*/, this.gitLabService.getProjects(milestone, options.projectIds, options.omittedProjectIds)];
|
|
113
107
|
case 6:
|
|
114
108
|
projects = _a.sent();
|
|
115
109
|
consumingProjects = projects.filter(function (p) { return p.id.toString() !== utils_1.ProjectIds.MONOREPO_PROJECT_ID; });
|
|
@@ -123,11 +117,11 @@ var StartProjectBuildsTask = /** @class */ (function () {
|
|
|
123
117
|
case 7:
|
|
124
118
|
if (!(_i < consumingProjects_1.length)) return [3 /*break*/, 11];
|
|
125
119
|
project = consumingProjects_1[_i];
|
|
126
|
-
return [4 /*yield*/, this.gitLabService.getReleaseBranchNameMilestone(project.id,
|
|
120
|
+
return [4 /*yield*/, this.gitLabService.getReleaseBranchNameMilestone(project.id, milestone)];
|
|
127
121
|
case 8:
|
|
128
122
|
branchName = _a.sent();
|
|
129
123
|
if (!branchName) {
|
|
130
|
-
utils_1.Logger.logWarning("Release branch in project \"".concat(project.title, "\" with milestone \"").concat(
|
|
124
|
+
utils_1.Logger.logWarning("Release branch in project \"".concat(project.title, "\" with milestone \"").concat(milestone, "\" was not found. Skipping project..."));
|
|
131
125
|
return [3 /*break*/, 10];
|
|
132
126
|
}
|
|
133
127
|
buildId = TeamCityBuildIDs_1.TeamCityBuildIds[project.id.toString()];
|
|
@@ -146,7 +140,7 @@ var StartProjectBuildsTask = /** @class */ (function () {
|
|
|
146
140
|
case 11:
|
|
147
141
|
totalBuilds = Object.keys(projectBuildMap).length;
|
|
148
142
|
if (!totalBuilds) {
|
|
149
|
-
utils_1.Logger.logWarning("No releases found in consuming projects with milestone \"".concat(
|
|
143
|
+
utils_1.Logger.logWarning("No releases found in consuming projects with milestone \"".concat(milestone, "\"."));
|
|
150
144
|
return [2 /*return*/, true];
|
|
151
145
|
}
|
|
152
146
|
utils_1.Logger.logSuccess("Successfully started builds in ".concat(totalBuilds, " projects."));
|
|
@@ -67,7 +67,7 @@ var TagMasterTask = /** @class */ (function () {
|
|
|
67
67
|
switch (_c.label) {
|
|
68
68
|
case 0:
|
|
69
69
|
Logger_1.Logger.logTask('Tagging master and merging into dev');
|
|
70
|
-
return [4 /*yield*/, this.service.getProjects(options)];
|
|
70
|
+
return [4 /*yield*/, this.service.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
71
71
|
case 1:
|
|
72
72
|
projects = _c.sent();
|
|
73
73
|
cont = true;
|
|
@@ -139,7 +139,14 @@ var TagMasterTask = /** @class */ (function () {
|
|
|
139
139
|
case 0:
|
|
140
140
|
logMessageSlack = '';
|
|
141
141
|
delay = (0, util_1.promisify)(setTimeout);
|
|
142
|
-
return [4 /*yield*/, this.service.createMergeRequest(
|
|
142
|
+
return [4 /*yield*/, this.service.createMergeRequest({
|
|
143
|
+
projectId: project.id,
|
|
144
|
+
sourceBranch: 'master',
|
|
145
|
+
targetBranch: 'dev',
|
|
146
|
+
title: "Merge ".concat(milestone, " master into dev"),
|
|
147
|
+
description: 'Merging master into dev',
|
|
148
|
+
milestoneName: milestone
|
|
149
|
+
})];
|
|
143
150
|
case 1:
|
|
144
151
|
mergeRequest = _a.sent();
|
|
145
152
|
// Add delay to give time before we merge created MR
|
|
@@ -56,81 +56,148 @@ var services_1 = require("../services");
|
|
|
56
56
|
var utils_1 = require("../utils");
|
|
57
57
|
var ValidateCommitsTask = /** @class */ (function () {
|
|
58
58
|
function ValidateCommitsTask(gitLabService, slackService) {
|
|
59
|
+
this.cont = true;
|
|
60
|
+
this.commitsMessage = '';
|
|
61
|
+
this.mrMessage = '';
|
|
59
62
|
this.gitLabService = gitLabService;
|
|
60
63
|
this.slackService = slackService;
|
|
61
64
|
}
|
|
62
65
|
ValidateCommitsTask.prototype.run = function (options) {
|
|
63
|
-
var _a;
|
|
64
66
|
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var projects,
|
|
66
|
-
return __generator(this, function (
|
|
67
|
-
switch (
|
|
67
|
+
var projects, _i, projects_1, project, _a, branch, tag;
|
|
68
|
+
return __generator(this, function (_b) {
|
|
69
|
+
switch (_b.label) {
|
|
68
70
|
case 0:
|
|
69
71
|
utils_1.Logger.logTask('Validating dev commits');
|
|
70
|
-
return [4 /*yield*/, this.gitLabService.getProjects(options)];
|
|
72
|
+
return [4 /*yield*/, this.gitLabService.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
71
73
|
case 1:
|
|
72
|
-
projects =
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
projects = _b.sent();
|
|
75
|
+
/**
|
|
76
|
+
* Clear all the instance values we're using to store state
|
|
77
|
+
*/
|
|
78
|
+
this.cont = true;
|
|
79
|
+
this.commitsMessage = '';
|
|
80
|
+
this.mrMessage = '';
|
|
75
81
|
_i = 0, projects_1 = projects;
|
|
76
|
-
|
|
82
|
+
_b.label = 2;
|
|
77
83
|
case 2:
|
|
78
|
-
if (!(_i < projects_1.length)) return [3 /*break*/,
|
|
84
|
+
if (!(_i < projects_1.length)) return [3 /*break*/, 5];
|
|
79
85
|
project = projects_1[_i];
|
|
80
86
|
return [4 /*yield*/, this.gitLabService.getNextBranchInfo(project.id, options.version)];
|
|
81
87
|
case 3:
|
|
82
|
-
|
|
88
|
+
_a = _b.sent(), branch = _a.branch, tag = _a.tag;
|
|
83
89
|
/**
|
|
84
|
-
* If the
|
|
85
|
-
* validation is only required when creating a new release
|
|
90
|
+
* If the branch already exists, ensure we don't have a stale branch.
|
|
86
91
|
*/
|
|
87
|
-
if (branch)
|
|
88
|
-
|
|
92
|
+
if (branch) {
|
|
93
|
+
this.validateBranch(project, branch, tag);
|
|
94
|
+
return [3 /*break*/, 4];
|
|
95
|
+
}
|
|
96
|
+
this.validateCommits(project, tag);
|
|
97
|
+
_b.label = 4;
|
|
98
|
+
case 4:
|
|
99
|
+
_i++;
|
|
100
|
+
return [3 /*break*/, 2];
|
|
101
|
+
case 5: return [4 /*yield*/, this.notifySlack(options.slackNotifier, options.milestone)];
|
|
102
|
+
case 6:
|
|
103
|
+
_b.sent();
|
|
104
|
+
if (this.cont)
|
|
105
|
+
utils_1.Logger.logSuccess('No projects require cherrypicking');
|
|
106
|
+
return [2 /*return*/, this.cont];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
ValidateCommitsTask.prototype.validateBranch = function (project, branch, tag) {
|
|
112
|
+
var _a;
|
|
113
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
+
var previousReleaseBranchName, previousReleaseMergeRequest, commits, missingMergeRequests, _i, missingMergeRequests_1, mergeRequest;
|
|
115
|
+
return __generator(this, function (_b) {
|
|
116
|
+
switch (_b.label) {
|
|
117
|
+
case 0:
|
|
89
118
|
previousReleaseBranchName = utils_1.BranchNames.getRelease(tag.name);
|
|
90
119
|
return [4 /*yield*/, this.gitLabService
|
|
91
120
|
.getMergeRequest(project.id, previousReleaseBranchName)];
|
|
92
|
-
case
|
|
93
|
-
previousReleaseMergeRequest =
|
|
94
|
-
return [4 /*yield*/, this.gitLabService.
|
|
95
|
-
case
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
121
|
+
case 1:
|
|
122
|
+
previousReleaseMergeRequest = _b.sent();
|
|
123
|
+
return [4 /*yield*/, this.gitLabService.getCommitsForBranch(branch.name, project.id, (_a = previousReleaseMergeRequest === null || previousReleaseMergeRequest === void 0 ? void 0 : previousReleaseMergeRequest.dateCreated) !== null && _a !== void 0 ? _a : '')];
|
|
124
|
+
case 2:
|
|
125
|
+
commits = _b.sent();
|
|
126
|
+
missingMergeRequests = utils_1.Commits.findMissingMergeRequests(project, commits);
|
|
127
|
+
if (!missingMergeRequests.length)
|
|
128
|
+
return [2 /*return*/];
|
|
129
|
+
this.cont = false;
|
|
130
|
+
this.logHelper(utils_1.Logger.logError, 'mr', "[".concat(project.title, "]: [").concat(branch.name, "] is out of date. Please delete the branch and re-run ship-it."));
|
|
131
|
+
this.logHelper(utils_1.Logger.logInfo, 'mr', 'These are the missing MRs:');
|
|
132
|
+
for (_i = 0, missingMergeRequests_1 = missingMergeRequests; _i < missingMergeRequests_1.length; _i++) {
|
|
133
|
+
mergeRequest = missingMergeRequests_1[_i];
|
|
134
|
+
this.logHelper(utils_1.Logger.logInfo, 'mr', "- ".concat(mergeRequest.url));
|
|
106
135
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
136
|
+
this.logHelper(utils_1.Logger.logInfo, 'mr', '');
|
|
137
|
+
return [2 /*return*/];
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
ValidateCommitsTask.prototype.validateCommits = function (project, tag) {
|
|
143
|
+
var _a;
|
|
144
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
+
var previousReleaseBranchName, previousReleaseMergeRequest, devCommits, _b, shouldCherryPick, invalidCommits;
|
|
146
|
+
var _this = this;
|
|
147
|
+
return __generator(this, function (_c) {
|
|
148
|
+
switch (_c.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
previousReleaseBranchName = utils_1.BranchNames.getRelease(tag.name);
|
|
151
|
+
return [4 /*yield*/, this.gitLabService
|
|
152
|
+
.getMergeRequest(project.id, previousReleaseBranchName)];
|
|
153
|
+
case 1:
|
|
154
|
+
previousReleaseMergeRequest = _c.sent();
|
|
155
|
+
return [4 /*yield*/, this.gitLabService.getCommitsForBranch('dev', project.id, (_a = previousReleaseMergeRequest === null || previousReleaseMergeRequest === void 0 ? void 0 : previousReleaseMergeRequest.dateCreated) !== null && _a !== void 0 ? _a : '')];
|
|
156
|
+
case 2:
|
|
157
|
+
devCommits = _c.sent();
|
|
158
|
+
_b = utils_1.Commits.shouldCherryPick(project, devCommits), shouldCherryPick = _b.shouldCherryPick, invalidCommits = _b.invalidCommits;
|
|
159
|
+
if (!shouldCherryPick)
|
|
160
|
+
return [2 /*return*/];
|
|
161
|
+
this.cont = false;
|
|
162
|
+
this.logHelper(utils_1.Logger.logError, 'commit', "[".concat(project.title, "]: Requires cherrypicking. These are the merge commits that either have the wrong milestone, or no milestone:"));
|
|
163
|
+
invalidCommits.forEach(function (commit) { return _this.logHelper(utils_1.Logger.logError, 'commit', "- ".concat(commit.id)); });
|
|
164
|
+
return [2 /*return*/];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
ValidateCommitsTask.prototype.notifySlack = function (slackNotifier, milestone) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
171
|
+
var threadLabel, statusCleanMessage;
|
|
172
|
+
return __generator(this, function (_a) {
|
|
173
|
+
switch (_a.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
if (!slackNotifier)
|
|
176
|
+
return [2 /*return*/];
|
|
177
|
+
threadLabel = "".concat(milestone, " Invalid Commits!");
|
|
114
178
|
statusCleanMessage = 'No projects require cherrypicking';
|
|
115
179
|
// Send formated status update in slack
|
|
116
180
|
return [4 /*yield*/, this.slackService.sendSlackStatusMessage({
|
|
117
181
|
emailList: [],
|
|
118
182
|
threadLabel: threadLabel,
|
|
119
|
-
statusMessage:
|
|
183
|
+
statusMessage: this.commitsMessage + this.mrMessage,
|
|
120
184
|
statusCleanMessage: statusCleanMessage
|
|
121
185
|
})];
|
|
122
|
-
case
|
|
186
|
+
case 1:
|
|
123
187
|
// Send formated status update in slack
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
case 9:
|
|
127
|
-
if (cont)
|
|
128
|
-
utils_1.Logger.logSuccess('No projects require cherrypicking');
|
|
129
|
-
return [2 /*return*/, cont];
|
|
188
|
+
_a.sent();
|
|
189
|
+
return [2 /*return*/];
|
|
130
190
|
}
|
|
131
191
|
});
|
|
132
192
|
});
|
|
133
193
|
};
|
|
194
|
+
ValidateCommitsTask.prototype.logHelper = function (func, type, message) {
|
|
195
|
+
func(message);
|
|
196
|
+
if (type === 'commit')
|
|
197
|
+
this.commitsMessage += message + '\n';
|
|
198
|
+
else if (type === 'mr')
|
|
199
|
+
this.mrMessage += message + '\n';
|
|
200
|
+
};
|
|
134
201
|
ValidateCommitsTask = __decorate([
|
|
135
202
|
(0, inversify_1.injectable)(),
|
|
136
203
|
__param(0, (0, inversify_1.inject)(types_1.SERVICES.GitLabService)),
|
|
@@ -71,7 +71,7 @@ var ValidateDescriptionsTask = /** @class */ (function () {
|
|
|
71
71
|
switch (_b.label) {
|
|
72
72
|
case 0:
|
|
73
73
|
utils_1.Logger.logTask('Validating descriptions');
|
|
74
|
-
return [4 /*yield*/, this.gitLabService.getProjects(options)];
|
|
74
|
+
return [4 /*yield*/, this.gitLabService.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
75
75
|
case 1:
|
|
76
76
|
projects = _b.sent();
|
|
77
77
|
cont = true;
|
|
@@ -83,7 +83,7 @@ var ValidateTask = /** @class */ (function () {
|
|
|
83
83
|
switch (_a.label) {
|
|
84
84
|
case 0:
|
|
85
85
|
utils_1.Logger.logTask('Validating the release');
|
|
86
|
-
return [4 /*yield*/, this.gitLabService.getProjects(options)];
|
|
86
|
+
return [4 /*yield*/, this.gitLabService.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
87
87
|
case 1:
|
|
88
88
|
projects = _a.sent();
|
|
89
89
|
utils_1.Logger.logMessage("Found ".concat(projects.length, " projects that need to be released"));
|
|
@@ -65,7 +65,7 @@ var VersionTask = /** @class */ (function () {
|
|
|
65
65
|
switch (_a.label) {
|
|
66
66
|
case 0:
|
|
67
67
|
utils_1.Logger.logTask('Calculating versions');
|
|
68
|
-
return [4 /*yield*/, this.service.getProjects(options, { invalidateCache: true })];
|
|
68
|
+
return [4 /*yield*/, this.service.getProjects(options.milestone, options.projectIds, options.omittedProjectIds, { invalidateCache: true })];
|
|
69
69
|
case 1:
|
|
70
70
|
projects = _a.sent();
|
|
71
71
|
utils_1.Logger.logMessage('Versions:');
|
|
@@ -67,7 +67,7 @@ var EnsureApprovalRulesTask = /** @class */ (function () {
|
|
|
67
67
|
case 0:
|
|
68
68
|
utils_1.Logger.logTask('Ensuring Approval Rules');
|
|
69
69
|
success = true;
|
|
70
|
-
return [4 /*yield*/, this.service.getProjects(options)];
|
|
70
|
+
return [4 /*yield*/, this.service.getProjects(options.milestone, options.projectIds, options.omittedProjectIds)];
|
|
71
71
|
case 1:
|
|
72
72
|
projects = _a.sent();
|
|
73
73
|
_i = 0, projects_1 = projects;
|
package/lib/src/utils/Commits.js
CHANGED
|
@@ -51,5 +51,32 @@ exports.Commits = {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
return { shouldCherryPick: false, invalidCommits: [] };
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Ensure that all the project commits are in the provided list of commits
|
|
57
|
+
*/
|
|
58
|
+
findMissingMergeRequests: function (project, commits) {
|
|
59
|
+
/**
|
|
60
|
+
* Build a lookup table of every commit
|
|
61
|
+
*/
|
|
62
|
+
var commitLookup = commits.reduce(function (acc, current) {
|
|
63
|
+
var _a;
|
|
64
|
+
return (__assign(__assign({}, acc), (_a = {}, _a[current.id] = current, _a)));
|
|
65
|
+
}, {});
|
|
66
|
+
return project.mergeRequests.filter(function (mergeRequest) {
|
|
67
|
+
/**
|
|
68
|
+
* Skip MRs that have not been merged yet
|
|
69
|
+
*/
|
|
70
|
+
if (!mergeRequest.mergeCommit)
|
|
71
|
+
return false;
|
|
72
|
+
/**
|
|
73
|
+
* Skip any MRs that don't target dev
|
|
74
|
+
*/
|
|
75
|
+
if (mergeRequest.targetBranch !== 'dev')
|
|
76
|
+
return false;
|
|
77
|
+
if (commitLookup[mergeRequest.mergeCommit])
|
|
78
|
+
return false;
|
|
79
|
+
return true;
|
|
80
|
+
});
|
|
54
81
|
}
|
|
55
82
|
};
|
|
@@ -11,6 +11,7 @@ exports.ProjectIds = {
|
|
|
11
11
|
* For example `ship-it release -m S2 -p lite`
|
|
12
12
|
*/
|
|
13
13
|
getProjectIds: function (projects) {
|
|
14
|
+
if (projects === void 0) { projects = []; }
|
|
14
15
|
var projectIds = [];
|
|
15
16
|
for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) {
|
|
16
17
|
var project = projects_1[_i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clickview/ship-it",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42-dev.1",
|
|
4
4
|
"description": "Release Manager",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -18,33 +18,33 @@
|
|
|
18
18
|
"author": "Joshua Taylor, Shale Kuzmanovski",
|
|
19
19
|
"license": "ISC",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@gitbeaker/node": "35.
|
|
22
|
-
"@slack/
|
|
23
|
-
"@slack/
|
|
24
|
-
"chalk": "4.1.2",
|
|
25
|
-
"commander": "9.1.0",
|
|
26
|
-
"fast-csv": "4.3.6",
|
|
27
|
-
"fs-extra": "10.0.1",
|
|
28
|
-
"inversify": "6.0.1",
|
|
29
|
-
"lodash": "4.17.21",
|
|
30
|
-
"reflect-metadata": "0.1.13",
|
|
31
|
-
"semver": "7.3
|
|
32
|
-
"teamcity-rest-api": "0.0.8",
|
|
33
|
-
"trello": "0.11.0"
|
|
21
|
+
"@gitbeaker/node": "^35.8.1",
|
|
22
|
+
"@slack/web-api": "^6.11.2",
|
|
23
|
+
"@slack/webhook": "^7.0.2",
|
|
24
|
+
"chalk": "^4.1.2",
|
|
25
|
+
"commander": "^9.1.0",
|
|
26
|
+
"fast-csv": "^4.3.6",
|
|
27
|
+
"fs-extra": "^10.0.1",
|
|
28
|
+
"inversify": "^6.0.1",
|
|
29
|
+
"lodash": "^4.17.21",
|
|
30
|
+
"reflect-metadata": "^0.1.13",
|
|
31
|
+
"semver": "^7.6.3",
|
|
32
|
+
"teamcity-rest-api": "^0.0.8",
|
|
33
|
+
"trello": "^0.11.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@clickview/eslint-config": "1.0.3",
|
|
37
|
-
"@types/fs-extra": "9.0.13",
|
|
38
|
-
"@types/lodash": "4.14.181",
|
|
39
|
-
"@types/node": "17.0.23",
|
|
40
|
-
"@types/semver": "7.3.9",
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "5.17.0",
|
|
42
|
-
"@typescript-eslint/parser": "5.17.0",
|
|
43
|
-
"eslint": "8.12.0",
|
|
44
|
-
"eslint-plugin-react-hooks": "4.4.0",
|
|
45
|
-
"ts-node": "10.7.0",
|
|
46
|
-
"tsc-alias": "1.6.6",
|
|
47
|
-
"tsconfig-paths": "3.14.1",
|
|
48
|
-
"typescript": "4.6.3"
|
|
36
|
+
"@clickview/eslint-config": "^1.0.3",
|
|
37
|
+
"@types/fs-extra": "^9.0.13",
|
|
38
|
+
"@types/lodash": "^4.14.181",
|
|
39
|
+
"@types/node": "^17.0.23",
|
|
40
|
+
"@types/semver": "^7.3.9",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
42
|
+
"@typescript-eslint/parser": "^5.17.0",
|
|
43
|
+
"eslint": "^8.12.0",
|
|
44
|
+
"eslint-plugin-react-hooks": "^4.4.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
49
|
}
|
|
50
50
|
}
|