@clickview/ship-it 0.0.2 → 0.0.3
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/{GitLabApiClient.js → git-lab/GitLabApiClient.js} +82 -107
- package/lib/src/api-clients/git-lab/GitLabMapper.js +60 -0
- package/lib/src/api-clients/index.js +1 -1
- package/lib/src/commands/BumpPackagesCommand.js +12 -4
- package/lib/src/commands/CreateBranchCommand.js +8 -8
- package/lib/src/commands/CreateMergeRequestCommand.js +11 -11
- package/lib/src/commands/CreateReleaseNotesCommand.js +4 -4
- package/lib/src/commands/InstallPackagesCommand.js +78 -0
- package/lib/src/commands/ReleaseCommand.js +14 -14
- package/lib/src/commands/StatusCommand.js +2 -2
- package/lib/src/commands/ValidateMergeRequestCommand.js +78 -0
- package/lib/src/commands/VersionCommand.js +2 -2
- package/lib/src/commands/index.js +2 -0
- package/lib/src/constants/CommandTypeMapping.js +15 -0
- package/lib/src/constants/MonorepoPackageJsonFiles.js +13 -0
- package/lib/src/errors/ShipItError.js +32 -0
- package/lib/src/errors/index.js +17 -0
- package/lib/src/index.js +3 -86
- package/lib/src/interfaces/command-options/BumpPackagesCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/InstallPackagesCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/MilestoneCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/ValidateMRCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/index.js +20 -0
- package/lib/src/interfaces/index.js +2 -1
- package/lib/src/interfaces/models/Milestone.js +2 -0
- package/lib/src/interfaces/models/index.js +1 -0
- package/lib/src/inversify.config.js +5 -0
- package/lib/src/services/GitLabService.js +95 -34
- package/lib/src/startup/AddMilestoneCommand.js +75 -0
- package/lib/src/startup/SetupCommands.js +92 -0
- package/lib/src/tasks/BumpPackagesTask.js +114 -238
- package/lib/src/tasks/BumpVersionTxtTask.js +13 -26
- package/lib/src/tasks/CommitPackageVersionsTask.js +105 -0
- package/lib/src/tasks/CreateBranchTask.js +17 -32
- package/lib/src/tasks/CreateMergeRequestTask.js +22 -37
- package/lib/src/tasks/CreateReleaseNotesTask.js +2 -6
- package/lib/src/tasks/InstallPackagesTask.js +358 -0
- package/lib/src/tasks/ValidateCommitsTask.js +6 -14
- package/lib/src/tasks/ValidateDescriptionsTask.js +15 -16
- package/lib/src/tasks/ValidateMergeRequestTask.js +108 -0
- package/lib/src/tasks/ValidateTask.js +7 -8
- package/lib/src/tasks/VersionTask.js +7 -20
- package/lib/src/tasks/index.js +3 -0
- package/lib/src/types.js +7 -2
- package/lib/src/utils/Descriptions.js +28 -23
- package/lib/src/utils/ProjectIds.js +7 -3
- package/package.json +22 -22
- /package/lib/src/interfaces/{ShipItOptions.js → VersionType.js} +0 -0
|
@@ -69,9 +69,11 @@ var lodash_1 = __importDefault(require("lodash"));
|
|
|
69
69
|
var semver_1 = __importDefault(require("semver"));
|
|
70
70
|
var types_1 = require("../types");
|
|
71
71
|
var api_clients_1 = require("../api-clients");
|
|
72
|
+
var errors_1 = require("../errors");
|
|
73
|
+
var utils_1 = require("../utils");
|
|
72
74
|
var GitLabService = /** @class */ (function () {
|
|
73
75
|
function GitLabService(apiClient) {
|
|
74
|
-
this.
|
|
76
|
+
this.apiClient = apiClient;
|
|
75
77
|
}
|
|
76
78
|
GitLabService.prototype.getProjects = function (options) {
|
|
77
79
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -79,20 +81,35 @@ var GitLabService = /** @class */ (function () {
|
|
|
79
81
|
return __generator(this, function (_a) {
|
|
80
82
|
switch (_a.label) {
|
|
81
83
|
case 0:
|
|
82
|
-
if (this.
|
|
83
|
-
return [2 /*return*/, this.
|
|
84
|
-
return [4 /*yield*/, this.
|
|
84
|
+
if (this.projects)
|
|
85
|
+
return [2 /*return*/, this.projects];
|
|
86
|
+
return [4 /*yield*/, this.apiClient.getMergeRequests(options)];
|
|
85
87
|
case 1:
|
|
86
88
|
mergeRequests = _a.sent();
|
|
87
89
|
if (!(mergeRequests === null || mergeRequests === void 0 ? void 0 : mergeRequests.length))
|
|
88
|
-
throw new
|
|
90
|
+
throw new errors_1.ShipItError('Could not find any merge requests for the specified options');
|
|
89
91
|
projectIds = lodash_1.default.uniqBy(mergeRequests, function (m) { return m.projectId; }).map(function (m) { return m.projectId; });
|
|
90
|
-
return [4 /*yield*/, this.
|
|
92
|
+
return [4 /*yield*/, this.apiClient.getProjectsByIds(projectIds)];
|
|
91
93
|
case 2:
|
|
92
94
|
projects = _a.sent();
|
|
93
95
|
if (!(projects === null || projects === void 0 ? void 0 : projects.length) || projects.length !== projectIds.length)
|
|
94
|
-
throw new
|
|
95
|
-
return [2 /*return*/, (this.
|
|
96
|
+
throw new errors_1.ShipItError('Could not find all projects for the found merge requests');
|
|
97
|
+
return [2 /*return*/, (this.projects = projects.map(function (p) { return (__assign(__assign({}, p), { mergeRequests: mergeRequests.filter(function (mr) { return mr.projectId === p.id; }) })); }))];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
GitLabService.prototype.getProject = function (projectId) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
var projects;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0: return [4 /*yield*/, this.apiClient.getProjectsByIds([projectId])];
|
|
108
|
+
case 1:
|
|
109
|
+
projects = _a.sent();
|
|
110
|
+
if (!projects.length)
|
|
111
|
+
throw new errors_1.ShipItError("Could not find project projectId: ".concat(projectId));
|
|
112
|
+
return [2 /*return*/, projects[0]];
|
|
96
113
|
}
|
|
97
114
|
});
|
|
98
115
|
});
|
|
@@ -102,7 +119,7 @@ var GitLabService = /** @class */ (function () {
|
|
|
102
119
|
var commits, lastDevCommit, title;
|
|
103
120
|
return __generator(this, function (_a) {
|
|
104
121
|
switch (_a.label) {
|
|
105
|
-
case 0: return [4 /*yield*/, this.
|
|
122
|
+
case 0: return [4 /*yield*/, this.apiClient.getCommitsSince(projectId, 'dev', sinceSha)];
|
|
106
123
|
case 1:
|
|
107
124
|
commits = _a.sent();
|
|
108
125
|
lastDevCommit = lodash_1.default.last(commits);
|
|
@@ -113,7 +130,7 @@ var GitLabService = /** @class */ (function () {
|
|
|
113
130
|
commits.pop();
|
|
114
131
|
}
|
|
115
132
|
if (!(commits === null || commits === void 0 ? void 0 : commits.length))
|
|
116
|
-
throw new
|
|
133
|
+
throw new errors_1.ShipItError("Could not find any commits in dev for projectId: ".concat(projectId, " since ").concat(sinceSha));
|
|
117
134
|
return [2 /*return*/, commits];
|
|
118
135
|
}
|
|
119
136
|
});
|
|
@@ -123,7 +140,7 @@ var GitLabService = /** @class */ (function () {
|
|
|
123
140
|
return __awaiter(this, void 0, void 0, function () {
|
|
124
141
|
return __generator(this, function (_a) {
|
|
125
142
|
switch (_a.label) {
|
|
126
|
-
case 0: return [4 /*yield*/, this.
|
|
143
|
+
case 0: return [4 /*yield*/, this.apiClient.getBranch(projectId, branchName)];
|
|
127
144
|
case 1: return [2 /*return*/, _a.sent()];
|
|
128
145
|
}
|
|
129
146
|
});
|
|
@@ -131,53 +148,66 @@ var GitLabService = /** @class */ (function () {
|
|
|
131
148
|
};
|
|
132
149
|
GitLabService.prototype.createBranch = function (project, branchFrom, branchName, cherryPick) {
|
|
133
150
|
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
-
var
|
|
151
|
+
var newBranch, i, mr;
|
|
135
152
|
return __generator(this, function (_a) {
|
|
136
153
|
switch (_a.label) {
|
|
137
154
|
case 0:
|
|
138
155
|
if (!cherryPick) return [3 /*break*/, 6];
|
|
139
|
-
return [4 /*yield*/, this.
|
|
156
|
+
return [4 /*yield*/, this.apiClient.createBranch(project.id, branchName, 'master')];
|
|
140
157
|
case 1:
|
|
141
|
-
|
|
142
|
-
if (!newBranch_1)
|
|
143
|
-
throw new Error("Failed to create branch from master for projectId: ".concat(project.id));
|
|
158
|
+
newBranch = _a.sent();
|
|
144
159
|
i = 0;
|
|
145
160
|
_a.label = 2;
|
|
146
161
|
case 2:
|
|
147
162
|
if (!(i < project.mergeRequests.length)) return [3 /*break*/, 5];
|
|
148
163
|
mr = project.mergeRequests[i];
|
|
149
164
|
if (!mr.mergeCommit)
|
|
150
|
-
throw new
|
|
151
|
-
return [4 /*yield*/, this.
|
|
165
|
+
throw new errors_1.ShipItError("Could not find the merge commit sha for MR: ".concat(mr.title, " in projectId: ").concat(project.id));
|
|
166
|
+
return [4 /*yield*/, this.apiClient.cherryPick(project.id, mr.mergeCommit, branchName)];
|
|
152
167
|
case 3:
|
|
153
168
|
_a.sent();
|
|
154
169
|
_a.label = 4;
|
|
155
170
|
case 4:
|
|
156
171
|
i++;
|
|
157
172
|
return [3 /*break*/, 2];
|
|
158
|
-
case 5: return [2 /*return*/,
|
|
159
|
-
case 6: return [4 /*yield*/, this.
|
|
160
|
-
case 7:
|
|
161
|
-
newBranch = _a.sent();
|
|
162
|
-
if (!newBranch)
|
|
163
|
-
throw new Error("Failed to create branch from master for projectId: ".concat(project.id));
|
|
164
|
-
return [2 /*return*/, newBranch];
|
|
173
|
+
case 5: return [2 /*return*/, newBranch];
|
|
174
|
+
case 6: return [4 /*yield*/, this.apiClient.createBranch(project.id, branchName, branchFrom)];
|
|
175
|
+
case 7: return [2 /*return*/, _a.sent()];
|
|
165
176
|
}
|
|
166
177
|
});
|
|
167
178
|
});
|
|
168
179
|
};
|
|
169
180
|
GitLabService.prototype.getMergeRequest = function (projectId, branchName) {
|
|
170
|
-
return this.
|
|
181
|
+
return this.apiClient.getMergeRequest(projectId, branchName, 'master');
|
|
171
182
|
};
|
|
172
|
-
GitLabService.prototype.
|
|
173
|
-
|
|
183
|
+
GitLabService.prototype.getMergeRequestById = function (projectId, mergeRequestId) {
|
|
184
|
+
var idAsNumber = lodash_1.default.toNumber(mergeRequestId);
|
|
185
|
+
if (!lodash_1.default.isNumber(idAsNumber))
|
|
186
|
+
throw new errors_1.ShipItError("MergeRequest Id must be a number: ".concat(mergeRequestId));
|
|
187
|
+
return this.apiClient.getMergeRequestById(projectId, idAsNumber);
|
|
188
|
+
};
|
|
189
|
+
GitLabService.prototype.createMergeRequest = function (projectId, branchName, description, milestoneName) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
+
var milestone;
|
|
192
|
+
return __generator(this, function (_a) {
|
|
193
|
+
switch (_a.label) {
|
|
194
|
+
case 0: return [4 /*yield*/, this.getMilestone(projectId, milestoneName)];
|
|
195
|
+
case 1:
|
|
196
|
+
milestone = _a.sent();
|
|
197
|
+
return [2 /*return*/, this.apiClient.createMergeRequest(projectId, branchName, 'master', branchName, description, milestone)];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
GitLabService.prototype.getMilestone = function (projectId, milestoneName) {
|
|
203
|
+
return this.apiClient.getMilestone(projectId, milestoneName);
|
|
174
204
|
};
|
|
175
205
|
GitLabService.prototype.bumpVersionTxt = function (projectId, branchName, newVersion) {
|
|
176
206
|
return __awaiter(this, void 0, void 0, function () {
|
|
177
207
|
var versionTxt, buff, text;
|
|
178
208
|
return __generator(this, function (_a) {
|
|
179
209
|
switch (_a.label) {
|
|
180
|
-
case 0: return [4 /*yield*/, this.
|
|
210
|
+
case 0: return [4 /*yield*/, this.apiClient.getFile(projectId, 'version.txt', branchName)];
|
|
181
211
|
case 1:
|
|
182
212
|
versionTxt = _a.sent();
|
|
183
213
|
if (!versionTxt)
|
|
@@ -186,7 +216,7 @@ var GitLabService = /** @class */ (function () {
|
|
|
186
216
|
text = buff.toString('utf-8');
|
|
187
217
|
if (text === newVersion)
|
|
188
218
|
return [2 /*return*/, false];
|
|
189
|
-
return [4 /*yield*/, this.
|
|
219
|
+
return [4 /*yield*/, this.apiClient.updateFile(projectId, 'version.txt', branchName, newVersion, 'Bumping version.txt')];
|
|
190
220
|
case 2:
|
|
191
221
|
_a.sent();
|
|
192
222
|
return [2 /*return*/, true];
|
|
@@ -198,20 +228,20 @@ var GitLabService = /** @class */ (function () {
|
|
|
198
228
|
return __awaiter(this, void 0, void 0, function () {
|
|
199
229
|
return __generator(this, function (_a) {
|
|
200
230
|
switch (_a.label) {
|
|
201
|
-
case 0: return [4 /*yield*/, this.
|
|
231
|
+
case 0: return [4 /*yield*/, this.apiClient.getFile(projectId, file, branchName)];
|
|
202
232
|
case 1: return [2 /*return*/, _a.sent()];
|
|
203
233
|
}
|
|
204
234
|
});
|
|
205
235
|
});
|
|
206
236
|
};
|
|
207
237
|
GitLabService.prototype.updateFile = function (projectId, filePath, branchName, content, commit) {
|
|
208
|
-
return this.
|
|
238
|
+
return this.apiClient.updateFile(projectId, filePath, branchName, content, commit);
|
|
209
239
|
};
|
|
210
240
|
GitLabService.prototype.commit = function (projectId, branchName, commitMessage, files) {
|
|
211
241
|
return __awaiter(this, void 0, void 0, function () {
|
|
212
242
|
return __generator(this, function (_a) {
|
|
213
243
|
switch (_a.label) {
|
|
214
|
-
case 0: return [4 /*yield*/, this.
|
|
244
|
+
case 0: return [4 /*yield*/, this.apiClient.commit(projectId, branchName, files, commitMessage)];
|
|
215
245
|
case 1:
|
|
216
246
|
_a.sent();
|
|
217
247
|
return [2 /*return*/];
|
|
@@ -219,12 +249,16 @@ var GitLabService = /** @class */ (function () {
|
|
|
219
249
|
});
|
|
220
250
|
});
|
|
221
251
|
};
|
|
252
|
+
/**
|
|
253
|
+
* We use the latest valid semver tag in master to determine what the current version
|
|
254
|
+
* of a project is
|
|
255
|
+
*/
|
|
222
256
|
GitLabService.prototype.getCurrentVersionTag = function (projectId) {
|
|
223
257
|
return __awaiter(this, void 0, void 0, function () {
|
|
224
258
|
var tags, tagNames, sortedTagNames, currentVersion, currentTag;
|
|
225
259
|
return __generator(this, function (_a) {
|
|
226
260
|
switch (_a.label) {
|
|
227
|
-
case 0: return [4 /*yield*/, this.
|
|
261
|
+
case 0: return [4 /*yield*/, this.apiClient.getLatestTags(projectId)];
|
|
228
262
|
case 1:
|
|
229
263
|
tags = _a.sent();
|
|
230
264
|
if (!(tags === null || tags === void 0 ? void 0 : tags.length))
|
|
@@ -242,6 +276,33 @@ var GitLabService = /** @class */ (function () {
|
|
|
242
276
|
});
|
|
243
277
|
});
|
|
244
278
|
};
|
|
279
|
+
GitLabService.prototype.getNextBranchInfo = function (projectId, version) {
|
|
280
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
281
|
+
var tag, nextVersion, branchName, branch;
|
|
282
|
+
return __generator(this, function (_a) {
|
|
283
|
+
switch (_a.label) {
|
|
284
|
+
case 0: return [4 /*yield*/, this.getCurrentVersionTag(projectId)];
|
|
285
|
+
case 1:
|
|
286
|
+
tag = _a.sent();
|
|
287
|
+
if (!tag)
|
|
288
|
+
throw new errors_1.ShipItError("Could not find the latest semver tag for projectId: ".concat(projectId));
|
|
289
|
+
nextVersion = utils_1.Versions.getNextVersion(tag.name, version);
|
|
290
|
+
branchName = version === 'patch' ?
|
|
291
|
+
utils_1.BranchNames.getHotfix(nextVersion) :
|
|
292
|
+
utils_1.BranchNames.getRelease(nextVersion);
|
|
293
|
+
return [4 /*yield*/, this.getBranch(projectId, branchName)];
|
|
294
|
+
case 2:
|
|
295
|
+
branch = _a.sent();
|
|
296
|
+
return [2 /*return*/, {
|
|
297
|
+
nextVersion: nextVersion,
|
|
298
|
+
branchName: branchName,
|
|
299
|
+
branch: branch,
|
|
300
|
+
tag: tag
|
|
301
|
+
}];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
};
|
|
245
306
|
GitLabService = __decorate([
|
|
246
307
|
(0, inversify_1.injectable)(),
|
|
247
308
|
__param(0, (0, inversify_1.inject)(types_1.API_CLIENTS.GitLabApiClient)),
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getAddMilestoneCommand = void 0;
|
|
40
|
+
var CommandTypeMapping_1 = require("../constants/CommandTypeMapping");
|
|
41
|
+
var utils_1 = require("../utils");
|
|
42
|
+
function processOptions(options) {
|
|
43
|
+
var opts = {
|
|
44
|
+
milestone: options.milestone,
|
|
45
|
+
version: 'minor'
|
|
46
|
+
};
|
|
47
|
+
if (options.projectIds)
|
|
48
|
+
opts.projectIds = utils_1.ProjectIds.getProjectIds(options.projectIds);
|
|
49
|
+
if (options.hotfix && options.major)
|
|
50
|
+
throw new Error('Cannot pass both --hotfix and --major options');
|
|
51
|
+
if (options.major)
|
|
52
|
+
opts.version = 'major';
|
|
53
|
+
if (options.hotfix)
|
|
54
|
+
opts.version = 'patch';
|
|
55
|
+
return opts;
|
|
56
|
+
}
|
|
57
|
+
var getAddMilestoneCommand = function (program, container) {
|
|
58
|
+
return function addMilestoneCommand(name, description) {
|
|
59
|
+
var _this = this;
|
|
60
|
+
program.command(name)
|
|
61
|
+
.description(description)
|
|
62
|
+
.requiredOption('-m, --milestone <milestone>')
|
|
63
|
+
.option('-p, --projectIds <projectIds...>')
|
|
64
|
+
.option('--hotfix')
|
|
65
|
+
.option('--major')
|
|
66
|
+
.action(function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
container.get(CommandTypeMapping_1.CommandTypeMapping[name])
|
|
69
|
+
.run(processOptions(options));
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
});
|
|
72
|
+
}); });
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
exports.getAddMilestoneCommand = getAddMilestoneCommand;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.setupCommands = void 0;
|
|
40
|
+
var CommandTypeMapping_1 = require("../constants/CommandTypeMapping");
|
|
41
|
+
var errors_1 = require("../errors");
|
|
42
|
+
var AddMilestoneCommand_1 = require("./AddMilestoneCommand");
|
|
43
|
+
function setupCommands(program, container) {
|
|
44
|
+
var addMilestoneCommand = (0, AddMilestoneCommand_1.getAddMilestoneCommand)(program, container);
|
|
45
|
+
// All commands below accept the same options
|
|
46
|
+
addMilestoneCommand('status', 'Get the status of all MRs in a milestone');
|
|
47
|
+
addMilestoneCommand('version', 'Display the versions that will be used for the release');
|
|
48
|
+
addMilestoneCommand('create-branches', 'Create release branches for all projects that are part of a milestone');
|
|
49
|
+
addMilestoneCommand('create-mrs', 'Create merge requests for all projects that are part of a milestone');
|
|
50
|
+
addMilestoneCommand('create-notes', 'Builds descriptions for all projects that are part of a milestone');
|
|
51
|
+
addMilestoneCommand('release', 'Create releases for all projects that are part of a milestone');
|
|
52
|
+
program.command('bump-packages')
|
|
53
|
+
.description('Bump clickview npm package versions in monorepo to their next version')
|
|
54
|
+
.requiredOption('-b, --branchName <branchName>')
|
|
55
|
+
.option('-p, --preId <preId>')
|
|
56
|
+
.action(getAction('bump-packages'));
|
|
57
|
+
program.command('install-packages')
|
|
58
|
+
.description('Install the latest clickview npm packages in all consuming projects that are part of a milestone')
|
|
59
|
+
.option('-m, --milestone <milestone>')
|
|
60
|
+
.option('-b, --branchName <branchName>')
|
|
61
|
+
.option('-p, --projectIds <projectIds...>')
|
|
62
|
+
.action(getAction('install-packages'));
|
|
63
|
+
program.command('validate-mr')
|
|
64
|
+
.description('Validate a merge request in a single project, ensuring it has a milestone and valid description')
|
|
65
|
+
.option('-p, --projectId <projectId>')
|
|
66
|
+
.option('-b, --branchName <branchName>')
|
|
67
|
+
.action(getAction('validate-mr'));
|
|
68
|
+
function getAction(command) {
|
|
69
|
+
var _this = this;
|
|
70
|
+
return function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
71
|
+
var err_1;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
_a.trys.push([0, 2, , 3]);
|
|
76
|
+
return [4 /*yield*/, container.get(CommandTypeMapping_1.CommandTypeMapping[command]).run(options)];
|
|
77
|
+
case 1:
|
|
78
|
+
_a.sent();
|
|
79
|
+
return [3 /*break*/, 3];
|
|
80
|
+
case 2:
|
|
81
|
+
err_1 = _a.sent();
|
|
82
|
+
if (!(err_1 instanceof errors_1.ShipItError))
|
|
83
|
+
throw err_1;
|
|
84
|
+
program.error(err_1.message);
|
|
85
|
+
return [3 /*break*/, 3];
|
|
86
|
+
case 3: return [2 /*return*/];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}); };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.setupCommands = setupCommands;
|