@clickview/ship-it 0.0.4-rc.0 → 0.0.4
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/config.json +5 -0
- package/lib/config.json +5 -0
- package/lib/src/api-clients/git-lab/GitLabApiClient.js +89 -0
- package/lib/src/api-clients/git-lab/GitLabMapper.js +19 -1
- package/lib/src/api-clients/index.js +1 -0
- package/lib/src/api-clients/team-city/TeamCityApiClient.js +85 -0
- package/lib/src/commands/ReleaseCommand.js +12 -3
- package/lib/src/commands/StartConsumingProjectBuildsCommand.js +76 -0
- package/lib/src/commands/TagMasterCommand.js +76 -0
- package/lib/src/commands/index.js +2 -0
- package/lib/src/constants/CommandTypeMapping.js +3 -1
- package/lib/src/constants/TeamCityBuildIDs.js +13 -0
- package/lib/src/interfaces/command-cli-options/ReleaseCommandCliOptions.js +2 -0
- package/lib/src/interfaces/command-cli-options/index.js +18 -0
- package/lib/src/interfaces/command-options/DockerMilestoneCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/ReleaseCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/index.js +2 -1
- package/lib/src/interfaces/index.js +1 -0
- package/lib/src/interfaces/models/Label.js +2 -0
- package/lib/src/interfaces/models/Release.js +2 -0
- package/lib/src/interfaces/models/index.js +2 -0
- package/lib/src/inversify.config.js +10 -0
- package/lib/src/services/GitLabService.js +147 -8
- package/lib/src/services/TeamCityService.js +34 -0
- package/lib/src/services/index.js +1 -0
- package/lib/src/startup/AddMilestoneCommand.js +2 -1
- package/lib/src/startup/SetupCommands.js +86 -2
- package/lib/src/tasks/CommitPackageVersionsTask.js +12 -1
- package/lib/src/tasks/InstallPackagesTask.js +26 -47
- package/lib/src/tasks/StartConsumingProjectBuildsTask.js +143 -0
- package/lib/src/tasks/StartMonorepoBuildTask.js +95 -0
- package/lib/src/tasks/TagMasterTask.js +122 -0
- package/lib/src/tasks/ValidateDescriptionsTask.js +15 -11
- package/lib/src/tasks/ValidateMergeRequestTask.js +12 -6
- package/lib/src/tasks/ValidateTask.js +2 -2
- package/lib/src/tasks/index.js +3 -0
- package/lib/src/types.js +10 -2
- package/lib/src/utils/ProjectIds.js +4 -8
- package/package.json +4 -3
- /package/lib/src/interfaces/{command-options/InstallPackagesCommandOptions.js → command-cli-options/MilestoneCommandCliOptions.js} +0 -0
|
@@ -71,13 +71,19 @@ var types_1 = require("../types");
|
|
|
71
71
|
var api_clients_1 = require("../api-clients");
|
|
72
72
|
var errors_1 = require("../errors");
|
|
73
73
|
var utils_1 = require("../utils");
|
|
74
|
+
/**
|
|
75
|
+
* These are projects that will try to use tags to pull in extra projects
|
|
76
|
+
*/
|
|
77
|
+
var MONOREPO_IDS = [
|
|
78
|
+
utils_1.ProjectIds.MONOREPO_PROJECT_ID
|
|
79
|
+
];
|
|
74
80
|
var GitLabService = /** @class */ (function () {
|
|
75
81
|
function GitLabService(apiClient) {
|
|
76
82
|
this.apiClient = apiClient;
|
|
77
83
|
}
|
|
78
84
|
GitLabService.prototype.getProjects = function (options) {
|
|
79
85
|
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
-
var mergeRequests, projectIds, projects;
|
|
86
|
+
var allMergeRequests, mergeRequests, projectIds, projects, mappedProjects, _i, mappedProjects_1, mappedProject, extraProjects;
|
|
81
87
|
return __generator(this, function (_a) {
|
|
82
88
|
switch (_a.label) {
|
|
83
89
|
case 0:
|
|
@@ -85,7 +91,8 @@ var GitLabService = /** @class */ (function () {
|
|
|
85
91
|
return [2 /*return*/, this.projects];
|
|
86
92
|
return [4 /*yield*/, this.apiClient.getMergeRequests(options)];
|
|
87
93
|
case 1:
|
|
88
|
-
|
|
94
|
+
allMergeRequests = _a.sent();
|
|
95
|
+
mergeRequests = allMergeRequests.filter(function (mr) { return mr.targetBranch !== 'master'; });
|
|
89
96
|
if (!(mergeRequests === null || mergeRequests === void 0 ? void 0 : mergeRequests.length))
|
|
90
97
|
throw new errors_1.ShipItError('Could not find any merge requests for the specified options');
|
|
91
98
|
projectIds = lodash_1.default.uniqBy(mergeRequests, function (m) { return m.projectId; }).map(function (m) { return m.projectId; });
|
|
@@ -94,7 +101,72 @@ var GitLabService = /** @class */ (function () {
|
|
|
94
101
|
projects = _a.sent();
|
|
95
102
|
if (!(projects === null || projects === void 0 ? void 0 : projects.length) || projects.length !== projectIds.length)
|
|
96
103
|
throw new errors_1.ShipItError('Could not find all projects for the found merge requests');
|
|
97
|
-
|
|
104
|
+
mappedProjects = projects.map(function (p) { return (__assign(__assign({}, p), { mergeRequests: mergeRequests.filter(function (mr) { return mr.projectId === p.id; }) })); });
|
|
105
|
+
_i = 0, mappedProjects_1 = mappedProjects;
|
|
106
|
+
_a.label = 3;
|
|
107
|
+
case 3:
|
|
108
|
+
if (!(_i < mappedProjects_1.length)) return [3 /*break*/, 6];
|
|
109
|
+
mappedProject = mappedProjects_1[_i];
|
|
110
|
+
return [4 /*yield*/, this.getExtraProjects(mappedProject, projectIds)];
|
|
111
|
+
case 4:
|
|
112
|
+
extraProjects = _a.sent();
|
|
113
|
+
Array.prototype.push.apply(mappedProjects, extraProjects.map(function (p) { return (__assign(__assign({}, p), { mergeRequests: [] })); }));
|
|
114
|
+
_a.label = 5;
|
|
115
|
+
case 5:
|
|
116
|
+
_i++;
|
|
117
|
+
return [3 /*break*/, 3];
|
|
118
|
+
case 6: return [2 /*return*/, (this.projects = mappedProjects)];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Fetches any projects that are not already included via MRs by checking the project labels.
|
|
125
|
+
* We only do this for a whitelist of projects
|
|
126
|
+
*/
|
|
127
|
+
GitLabService.prototype.getExtraProjects = function (project, existingProjectIds) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
var labels, mrLabelNames, mrLabels, projectIds, extraProjectIds;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
switch (_a.label) {
|
|
132
|
+
case 0:
|
|
133
|
+
if (!MONOREPO_IDS.includes(project.id.toString()))
|
|
134
|
+
return [2 /*return*/, []];
|
|
135
|
+
return [4 /*yield*/, this.getProjectLabels(project.id)];
|
|
136
|
+
case 1:
|
|
137
|
+
labels = _a.sent();
|
|
138
|
+
mrLabelNames = lodash_1.default.chain(project.mergeRequests)
|
|
139
|
+
.map(function (m) { return m.labels; })
|
|
140
|
+
.flatten()
|
|
141
|
+
.uniq()
|
|
142
|
+
.value();
|
|
143
|
+
mrLabels = lodash_1.default.intersection(labels.map(function (l) { return l.name; }), mrLabelNames);
|
|
144
|
+
projectIds = mrLabels.map(function (m) { var _a; return (_a = labels.find(function (l) { return l.name === m; })) === null || _a === void 0 ? void 0 : _a.description; });
|
|
145
|
+
extraProjectIds = lodash_1.default.difference(projectIds, existingProjectIds.map(function (p) { return p.toString(); }));
|
|
146
|
+
return [4 /*yield*/, this.apiClient.getProjectsByIds(extraProjectIds)];
|
|
147
|
+
case 2:
|
|
148
|
+
// fetches and returns the extra projects
|
|
149
|
+
return [2 /*return*/, _a.sent()];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Gets labels that have a projectId as their description
|
|
156
|
+
*/
|
|
157
|
+
GitLabService.prototype.getProjectLabels = function (projectId) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
159
|
+
var labels;
|
|
160
|
+
return __generator(this, function (_a) {
|
|
161
|
+
switch (_a.label) {
|
|
162
|
+
case 0: return [4 /*yield*/, this.apiClient.getLabels(projectId)];
|
|
163
|
+
case 1:
|
|
164
|
+
labels = _a.sent();
|
|
165
|
+
return [2 /*return*/, labels.filter(function (l) {
|
|
166
|
+
if (!l.description)
|
|
167
|
+
return false;
|
|
168
|
+
return !isNaN(+l.description);
|
|
169
|
+
})];
|
|
98
170
|
}
|
|
99
171
|
});
|
|
100
172
|
});
|
|
@@ -129,8 +201,13 @@ var GitLabService = /** @class */ (function () {
|
|
|
129
201
|
(title === null || title === void 0 ? void 0 : title.includes('dev'))) {
|
|
130
202
|
commits.pop();
|
|
131
203
|
}
|
|
132
|
-
|
|
133
|
-
|
|
204
|
+
/**
|
|
205
|
+
* This is commented out right now because of a problem with the logic of this approach of validating MRs.
|
|
206
|
+
* We need to find a way to fetch all commits that will be included in this release. Leaving this commented
|
|
207
|
+
* until we figure that out - Sha
|
|
208
|
+
*/
|
|
209
|
+
// if (!commits?.length)
|
|
210
|
+
// throw new ShipItError(`Could not find any commits in dev for projectId: ${projectId} since ${sinceSha}`);
|
|
134
211
|
return [2 /*return*/, commits];
|
|
135
212
|
}
|
|
136
213
|
});
|
|
@@ -181,10 +258,9 @@ var GitLabService = /** @class */ (function () {
|
|
|
181
258
|
return this.apiClient.getMergeRequest(projectId, branchName, 'master');
|
|
182
259
|
};
|
|
183
260
|
GitLabService.prototype.getMergeRequestById = function (projectId, mergeRequestId) {
|
|
184
|
-
|
|
185
|
-
if (!lodash_1.default.isNumber(idAsNumber))
|
|
261
|
+
if (isNaN(+mergeRequestId))
|
|
186
262
|
throw new errors_1.ShipItError("MergeRequest Id must be a number: ".concat(mergeRequestId));
|
|
187
|
-
return this.apiClient.getMergeRequestById(projectId,
|
|
263
|
+
return this.apiClient.getMergeRequestById(projectId, +mergeRequestId);
|
|
188
264
|
};
|
|
189
265
|
GitLabService.prototype.createMergeRequest = function (projectId, branchName, description, milestoneName) {
|
|
190
266
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -202,6 +278,39 @@ var GitLabService = /** @class */ (function () {
|
|
|
202
278
|
GitLabService.prototype.getMilestone = function (projectId, milestoneName) {
|
|
203
279
|
return this.apiClient.getMilestone(projectId, milestoneName);
|
|
204
280
|
};
|
|
281
|
+
GitLabService.prototype.getReleaseBranchNameMilestone = function (projectId, milestone) {
|
|
282
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
283
|
+
var releaseMR;
|
|
284
|
+
return __generator(this, function (_a) {
|
|
285
|
+
switch (_a.label) {
|
|
286
|
+
case 0: return [4 /*yield*/, this.apiClient.getReleaseMergeRequest(projectId, milestone)];
|
|
287
|
+
case 1:
|
|
288
|
+
releaseMR = _a.sent();
|
|
289
|
+
if (!releaseMR)
|
|
290
|
+
return [2 /*return*/, null];
|
|
291
|
+
return [2 /*return*/, releaseMR.sourceBranch];
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
GitLabService.prototype.getMilestoneByBranchName = function (projectId, branchName) {
|
|
297
|
+
var _a, _b;
|
|
298
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
299
|
+
var mergeRequest;
|
|
300
|
+
return __generator(this, function (_c) {
|
|
301
|
+
switch (_c.label) {
|
|
302
|
+
case 0: return [4 /*yield*/, this.getMergeRequest(projectId, branchName)];
|
|
303
|
+
case 1:
|
|
304
|
+
mergeRequest = _c.sent();
|
|
305
|
+
if (!mergeRequest)
|
|
306
|
+
throw new errors_1.ShipItError("No merge request in project \"monorepo\" with branch name \"".concat(branchName, "\" could be found."));
|
|
307
|
+
if (!mergeRequest.milestone)
|
|
308
|
+
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));
|
|
309
|
+
return [2 /*return*/, (_b = (_a = mergeRequest.milestone) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ''];
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
};
|
|
205
314
|
GitLabService.prototype.bumpVersionTxt = function (projectId, branchName, newVersion) {
|
|
206
315
|
return __awaiter(this, void 0, void 0, function () {
|
|
207
316
|
var versionTxt, buff, text;
|
|
@@ -249,6 +358,36 @@ var GitLabService = /** @class */ (function () {
|
|
|
249
358
|
});
|
|
250
359
|
});
|
|
251
360
|
};
|
|
361
|
+
GitLabService.prototype.getTag = function (projectId, tagName) {
|
|
362
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
363
|
+
return __generator(this, function (_a) {
|
|
364
|
+
switch (_a.label) {
|
|
365
|
+
case 0: return [4 /*yield*/, this.apiClient.getTag(projectId, tagName)];
|
|
366
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
};
|
|
371
|
+
GitLabService.prototype.createTag = function (projectId, tagName, sha) {
|
|
372
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
373
|
+
return __generator(this, function (_a) {
|
|
374
|
+
switch (_a.label) {
|
|
375
|
+
case 0: return [4 /*yield*/, this.apiClient.createTag(projectId, tagName, sha)];
|
|
376
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
};
|
|
381
|
+
GitLabService.prototype.createRelease = function (projectId, release) {
|
|
382
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
383
|
+
return __generator(this, function (_a) {
|
|
384
|
+
switch (_a.label) {
|
|
385
|
+
case 0: return [4 /*yield*/, this.apiClient.createRelease(projectId, release)];
|
|
386
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
};
|
|
252
391
|
/**
|
|
253
392
|
* We use the latest valid semver tag in master to determine what the current version
|
|
254
393
|
* of a project is
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TeamCityService = void 0;
|
|
16
|
+
require("reflect-metadata");
|
|
17
|
+
var inversify_1 = require("inversify");
|
|
18
|
+
var types_1 = require("../types");
|
|
19
|
+
var api_clients_1 = require("../api-clients");
|
|
20
|
+
var TeamCityService = /** @class */ (function () {
|
|
21
|
+
function TeamCityService(apiClient) {
|
|
22
|
+
this.apiClient = apiClient;
|
|
23
|
+
}
|
|
24
|
+
TeamCityService.prototype.startBuild = function (buildId, branchName) {
|
|
25
|
+
return this.apiClient.startBuild(buildId, branchName);
|
|
26
|
+
};
|
|
27
|
+
TeamCityService = __decorate([
|
|
28
|
+
(0, inversify_1.injectable)(),
|
|
29
|
+
__param(0, (0, inversify_1.inject)(types_1.API_CLIENTS.TeamCityApiClient)),
|
|
30
|
+
__metadata("design:paramtypes", [api_clients_1.TeamCityApiClient])
|
|
31
|
+
], TeamCityService);
|
|
32
|
+
return TeamCityService;
|
|
33
|
+
}());
|
|
34
|
+
exports.TeamCityService = TeamCityService;
|
|
@@ -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.getAddMilestoneCommand = void 0;
|
|
39
|
+
exports.processMilestoneCommandOptions = exports.getAddMilestoneCommand = void 0;
|
|
40
40
|
var utils_1 = require("../utils");
|
|
41
41
|
function processOptions(options) {
|
|
42
42
|
var opts = {
|
|
@@ -53,6 +53,7 @@ function processOptions(options) {
|
|
|
53
53
|
opts.version = 'patch';
|
|
54
54
|
return opts;
|
|
55
55
|
}
|
|
56
|
+
exports.processMilestoneCommandOptions = processOptions;
|
|
56
57
|
var getAddMilestoneCommand = function (program, getAction) {
|
|
57
58
|
return function addMilestoneCommand(name, description) {
|
|
58
59
|
var _this = this;
|
|
@@ -1,9 +1,61 @@
|
|
|
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
|
+
};
|
|
2
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
53
|
exports.setupCommands = void 0;
|
|
54
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
4
55
|
var AddMilestoneCommand_1 = require("./AddMilestoneCommand");
|
|
5
56
|
var GetAction_1 = require("./GetAction");
|
|
6
57
|
function setupCommands(program, container) {
|
|
58
|
+
var _this = this;
|
|
7
59
|
var getAction = (0, GetAction_1.getActionBuilder)(program, container);
|
|
8
60
|
var addMilestoneCommand = (0, AddMilestoneCommand_1.getAddMilestoneCommand)(program, getAction);
|
|
9
61
|
// All commands below accept the same options
|
|
@@ -12,7 +64,27 @@ function setupCommands(program, container) {
|
|
|
12
64
|
addMilestoneCommand('create-branches', 'Create release branches for all projects that are part of a milestone');
|
|
13
65
|
addMilestoneCommand('create-mrs', 'Create merge requests for all projects that are part of a milestone');
|
|
14
66
|
addMilestoneCommand('create-notes', 'Builds descriptions for all projects that are part of a milestone');
|
|
15
|
-
addMilestoneCommand('
|
|
67
|
+
addMilestoneCommand('tag-master', 'Tags master for all release MRs that are part of a milestone');
|
|
68
|
+
program.command('release')
|
|
69
|
+
.description('Create releases for all projects that are part of a milestone')
|
|
70
|
+
.requiredOption('-m, --milestone <milestone>')
|
|
71
|
+
.option('-p, --projectIds <projectIds...>')
|
|
72
|
+
.option('--hotfix')
|
|
73
|
+
.option('--major')
|
|
74
|
+
.option('--trigger-monorepo-build')
|
|
75
|
+
.action(function (opts) { return __awaiter(_this, void 0, void 0, function () {
|
|
76
|
+
var options;
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
switch (_a.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
options = __assign(__assign({}, (0, AddMilestoneCommand_1.processMilestoneCommandOptions)(lodash_1.default.omit(opts, 'triggerMonorepoBuild'))), { triggerMonorepoBuild: !!opts.triggerMonorepoBuild });
|
|
81
|
+
return [4 /*yield*/, getAction('release')(options)];
|
|
82
|
+
case 1:
|
|
83
|
+
_a.sent();
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}); });
|
|
16
88
|
program.command('bump-packages')
|
|
17
89
|
.description('Bump clickview npm package versions in monorepo to their next version')
|
|
18
90
|
.requiredOption('-b, --branchName <branchName>')
|
|
@@ -21,7 +93,7 @@ function setupCommands(program, container) {
|
|
|
21
93
|
program.command('install-packages')
|
|
22
94
|
.description('Install the latest clickview npm packages in all consuming projects that are part of a milestone')
|
|
23
95
|
.option('-m, --milestone <milestone>')
|
|
24
|
-
.option('-b, --
|
|
96
|
+
.option('-b, --monorepoBranchName <monorepoBranchName>')
|
|
25
97
|
.option('-p, --projectIds <projectIds...>')
|
|
26
98
|
.action(getAction('install-packages'));
|
|
27
99
|
program.command('validate-mr')
|
|
@@ -29,5 +101,17 @@ function setupCommands(program, container) {
|
|
|
29
101
|
.option('-p, --projectId <projectId>')
|
|
30
102
|
.option('-b, --branchName <branchName>')
|
|
31
103
|
.action(getAction('validate-mr'));
|
|
104
|
+
program.command('start-consuming-project-builds')
|
|
105
|
+
.description('Trigger TeamCity builds in all consuming projects that are a part of a milestone')
|
|
106
|
+
.option('-m, --milestone <milestone>')
|
|
107
|
+
.option('--monorepoBranchName <monorepoBranchName>')
|
|
108
|
+
.option('-p, --projectIds <projectIds...>')
|
|
109
|
+
.action(getAction('start-consuming-project-builds'));
|
|
110
|
+
program.command('start-consuming-project-builds')
|
|
111
|
+
.description('Trigger TeamCity builds in all consuming projects that are a part of a milestone')
|
|
112
|
+
.option('-m, --milestone <milestone>')
|
|
113
|
+
.option('--monorepoBranchName <monorepoBranchName>')
|
|
114
|
+
.option('-p, --projectIds <projectIds...>')
|
|
115
|
+
.action(getAction('start-consuming-project-builds'));
|
|
32
116
|
}
|
|
33
117
|
exports.setupCommands = setupCommands;
|
|
@@ -88,9 +88,20 @@ 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
|
+
/**
|
|
97
|
+
* If the file doesn't exist, ignore the error.
|
|
98
|
+
* This will occur when TC Docker runs this script as it doesn't copy over @clickview/tooling
|
|
99
|
+
*/
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
91
102
|
commitFiles.push({
|
|
92
103
|
filePath: filePath,
|
|
93
|
-
content:
|
|
104
|
+
content: content
|
|
94
105
|
});
|
|
95
106
|
}
|
|
96
107
|
return commitFiles;
|
|
@@ -84,18 +84,28 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
84
84
|
switch (_c.label) {
|
|
85
85
|
case 0:
|
|
86
86
|
utils_1.Logger.logTask('Installing npm packages');
|
|
87
|
-
|
|
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)];
|
|
88
95
|
case 1:
|
|
89
96
|
milestone = _c.sent();
|
|
97
|
+
_c.label = 2;
|
|
98
|
+
case 2:
|
|
90
99
|
if (!milestone)
|
|
91
100
|
return [2 /*return*/, false];
|
|
101
|
+
utils_1.Logger.logInfo("Found milestone \"".concat(milestone, "\". Proceeding to install packages in consuming projects..."));
|
|
92
102
|
options = {
|
|
93
103
|
version: _options.version,
|
|
94
104
|
projectIds: _options.projectIds,
|
|
95
105
|
milestone: milestone
|
|
96
106
|
};
|
|
97
107
|
return [4 /*yield*/, this.service.getProjects(options)];
|
|
98
|
-
case
|
|
108
|
+
case 3:
|
|
99
109
|
projects = _c.sent();
|
|
100
110
|
monorepo = projects.find(function (p) { return p.id.toString() === utils_1.ProjectIds.MONOREPO_PROJECT_ID; });
|
|
101
111
|
consumingProjects = projects.filter(function (p) { return p.id.toString() !== utils_1.ProjectIds.MONOREPO_PROJECT_ID; });
|
|
@@ -108,14 +118,14 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
108
118
|
return [2 /*return*/, false];
|
|
109
119
|
}
|
|
110
120
|
return [4 /*yield*/, this.service.getNextBranchInfo(monorepo.id, options.version)];
|
|
111
|
-
case
|
|
121
|
+
case 4:
|
|
112
122
|
_a = _c.sent(), monorepoBranch = _a.branch, monorepoBranchName = _a.branchName;
|
|
113
123
|
if (!monorepoBranch) {
|
|
114
124
|
utils_1.Logger.logError("[".concat(monorepo.title, "]: [").concat(monorepoBranchName, "] branch does not exist"));
|
|
115
125
|
return [2 /*return*/, false];
|
|
116
126
|
}
|
|
117
127
|
return [4 /*yield*/, this.getPackageVersions(monorepoBranchName)];
|
|
118
|
-
case
|
|
128
|
+
case 5:
|
|
119
129
|
versions = _c.sent();
|
|
120
130
|
utils_1.Logger.logMessage("Versions identified for ".concat(monorepoBranchName));
|
|
121
131
|
Object.keys(versions).forEach(function (key) {
|
|
@@ -123,26 +133,26 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
123
133
|
});
|
|
124
134
|
utils_1.Logger.logMessage('\nInstalling packages:\n');
|
|
125
135
|
_i = 0, consumingProjects_1 = consumingProjects;
|
|
126
|
-
_c.label =
|
|
127
|
-
case
|
|
128
|
-
if (!(_i < consumingProjects_1.length)) return [3 /*break*/,
|
|
136
|
+
_c.label = 6;
|
|
137
|
+
case 6:
|
|
138
|
+
if (!(_i < consumingProjects_1.length)) return [3 /*break*/, 11];
|
|
129
139
|
project = consumingProjects_1[_i];
|
|
130
140
|
return [4 /*yield*/, this.service.getNextBranchInfo(project.id, options.version)];
|
|
131
|
-
case
|
|
141
|
+
case 7:
|
|
132
142
|
_b = _c.sent(), branch = _b.branch, branchName = _b.branchName;
|
|
133
143
|
if (!branch) {
|
|
134
144
|
utils_1.Logger.logError("[".concat(project.title, "]: [").concat(branchName, "] does not exist"));
|
|
135
|
-
return [3 /*break*/,
|
|
145
|
+
return [3 /*break*/, 10];
|
|
136
146
|
}
|
|
137
147
|
return [4 /*yield*/, this.updateAndSavePackageFiles(project, options.milestone, branchName, versions)];
|
|
138
|
-
case
|
|
148
|
+
case 8:
|
|
139
149
|
hasUpdates = _c.sent();
|
|
140
150
|
/**
|
|
141
151
|
* If there are no changes to the versions, we're done here
|
|
142
152
|
*/
|
|
143
153
|
if (!hasUpdates) {
|
|
144
154
|
utils_1.Logger.logWarning("[".concat(project.title, "]: [").concat(branchName, "] does not require any updates"));
|
|
145
|
-
return [3 /*break*/,
|
|
155
|
+
return [3 /*break*/, 10];
|
|
146
156
|
}
|
|
147
157
|
/**
|
|
148
158
|
* Run npm i to update our package log file
|
|
@@ -154,48 +164,17 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
154
164
|
* Commit our updated package.json and package-lock.json
|
|
155
165
|
*/
|
|
156
166
|
return [4 /*yield*/, this.commitUpdatedFiles(project, options.milestone, branchName)];
|
|
157
|
-
case
|
|
167
|
+
case 9:
|
|
158
168
|
/**
|
|
159
169
|
* Commit our updated package.json and package-lock.json
|
|
160
170
|
*/
|
|
161
171
|
_c.sent();
|
|
162
172
|
utils_1.Logger.logMessage("[".concat(project.title, "]: File changes committed"));
|
|
163
|
-
_c.label =
|
|
164
|
-
case
|
|
173
|
+
_c.label = 10;
|
|
174
|
+
case 10:
|
|
165
175
|
_i++;
|
|
166
|
-
return [3 /*break*/,
|
|
167
|
-
case
|
|
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 : ''];
|
|
176
|
+
return [3 /*break*/, 6];
|
|
177
|
+
case 11: return [2 /*return*/, true];
|
|
199
178
|
}
|
|
200
179
|
});
|
|
201
180
|
});
|