@clickview/ship-it 0.0.2-dev.1 → 0.0.2-dev.2
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 +1 -1
- package/lib/src/api-clients/git-lab/GitLabApiClient.js +285 -0
- package/lib/src/api-clients/git-lab/GitLabMapper.js +51 -0
- package/lib/src/api-clients/index.js +1 -1
- package/lib/src/commands/BumpPackagesCommand.js +10 -2
- package/lib/src/commands/CommitPackageVersionsCommand.js +78 -0
- package/lib/src/commands/CreateBranchCommand.js +8 -8
- package/lib/src/commands/CreateMergeRequestCommand.js +10 -10
- package/lib/src/commands/CreateReleaseNotesCommand.js +4 -4
- package/lib/src/commands/ReleaseCommand.js +14 -14
- package/lib/src/commands/StatusCommand.js +2 -2
- package/lib/src/commands/VersionCommand.js +2 -2
- package/lib/src/constants/index.js +2 -2
- package/lib/src/errors/ShipItError.js +32 -0
- package/lib/src/errors/index.js +17 -0
- package/lib/src/interfaces/VersionType.js +2 -0
- package/lib/src/interfaces/command-options/CommitPackageVersionsCommandOptions.js +2 -0
- package/lib/src/interfaces/index.js +1 -0
- package/lib/src/inversify.config.js +1 -0
- package/lib/src/services/GitLabService.js +60 -33
- package/lib/src/startup/AddMilestoneCommand.js +2 -2
- package/lib/src/startup/SetupCommands.js +2 -2
- package/lib/src/tasks/BumpPackagesTask.js +39 -28
- package/lib/src/tasks/BumpVersionTxtTask.js +13 -26
- package/lib/src/tasks/CommitLocalPackagesTask.js +137 -0
- package/lib/src/tasks/CommitPackageVersionsTask.js +111 -0
- package/lib/src/tasks/CreateBranchTask.js +17 -32
- package/lib/src/tasks/CreateMergeRequestTask.js +21 -36
- package/lib/src/tasks/CreateReleaseNotesTask.js +2 -6
- package/lib/src/tasks/InstallPackagesTask.js +65 -92
- package/lib/src/tasks/ValidateCommitsTask.js +6 -14
- package/lib/src/tasks/ValidateDescriptionsTask.js +4 -8
- package/lib/src/tasks/ValidateTask.js +5 -6
- package/lib/src/tasks/VersionTask.js +7 -20
- package/lib/src/tasks/index.js +1 -0
- package/lib/src/types.js +2 -1
- package/lib/src/utils/Descriptions.js +5 -4
- package/lib/src/utils/ProjectIds.js +6 -2
- package/package.json +22 -22
|
@@ -54,13 +54,13 @@ var inversify_1 = require("inversify");
|
|
|
54
54
|
var types_1 = require("../types");
|
|
55
55
|
var StatusCommand = /** @class */ (function () {
|
|
56
56
|
function StatusCommand(validateTask) {
|
|
57
|
-
this.
|
|
57
|
+
this.validateTask = validateTask;
|
|
58
58
|
}
|
|
59
59
|
StatusCommand.prototype.run = function (options) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
61
61
|
return __generator(this, function (_a) {
|
|
62
62
|
switch (_a.label) {
|
|
63
|
-
case 0: return [4 /*yield*/, this.
|
|
63
|
+
case 0: return [4 /*yield*/, this.validateTask.run(options)];
|
|
64
64
|
case 1:
|
|
65
65
|
_a.sent();
|
|
66
66
|
return [2 /*return*/];
|
|
@@ -54,13 +54,13 @@ var inversify_1 = require("inversify");
|
|
|
54
54
|
var types_1 = require("../types");
|
|
55
55
|
var VersionCommand = /** @class */ (function () {
|
|
56
56
|
function VersionCommand(versionTask) {
|
|
57
|
-
this.
|
|
57
|
+
this.versionTask = versionTask;
|
|
58
58
|
}
|
|
59
59
|
VersionCommand.prototype.run = function (options) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
61
61
|
return __generator(this, function (_a) {
|
|
62
62
|
switch (_a.label) {
|
|
63
|
-
case 0: return [4 /*yield*/, this.
|
|
63
|
+
case 0: return [4 /*yield*/, this.versionTask.run(options)];
|
|
64
64
|
case 1:
|
|
65
65
|
_a.sent();
|
|
66
66
|
return [2 /*return*/];
|
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./CommandTypeMapping"), exports);
|
|
18
|
-
__exportStar(require("./MonorepoPackageJsonFiles"), exports);
|
|
17
|
+
__exportStar(require("./CommandTypeMapping.js"), exports);
|
|
18
|
+
__exportStar(require("./MonorepoPackageJsonFiles.js"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ShipItError = void 0;
|
|
19
|
+
var ShipItError = /** @class */ (function (_super) {
|
|
20
|
+
__extends(ShipItError, _super);
|
|
21
|
+
function ShipItError(message) {
|
|
22
|
+
var _this = _super.call(this, message) || this;
|
|
23
|
+
/**
|
|
24
|
+
* Need to do this to extend errors in typescript and still be able to use instanceof in a catch statement
|
|
25
|
+
* https://stackoverflow.com/questions/31626231/custom-error-class-in-typescript/41429145
|
|
26
|
+
*/
|
|
27
|
+
Object.setPrototypeOf(_this, ShipItError.prototype);
|
|
28
|
+
return _this;
|
|
29
|
+
}
|
|
30
|
+
return ShipItError;
|
|
31
|
+
}(Error));
|
|
32
|
+
exports.ShipItError = ShipItError;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ShipItError"), exports);
|
|
@@ -34,6 +34,7 @@ function createContainer(config) {
|
|
|
34
34
|
container.bind(types_1.TASKS.CreateReleaseNotesTask).to(tasks_1.CreateReleaseNotesTask);
|
|
35
35
|
container.bind(types_1.TASKS.InstallPackagesTask).to(tasks_1.InstallPackagesTask);
|
|
36
36
|
container.bind(types_1.TASKS.BumpPackagesTask).to(tasks_1.BumpPackagesTask);
|
|
37
|
+
container.bind(types_1.TASKS.CommitPackageVersionsTask).to(tasks_1.CommitPackageVersionsTask);
|
|
37
38
|
/**
|
|
38
39
|
* Commands
|
|
39
40
|
*/
|
|
@@ -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,20 @@ 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; }) })); }))];
|
|
96
98
|
}
|
|
97
99
|
});
|
|
98
100
|
});
|
|
@@ -102,7 +104,7 @@ var GitLabService = /** @class */ (function () {
|
|
|
102
104
|
var commits, lastDevCommit, title;
|
|
103
105
|
return __generator(this, function (_a) {
|
|
104
106
|
switch (_a.label) {
|
|
105
|
-
case 0: return [4 /*yield*/, this.
|
|
107
|
+
case 0: return [4 /*yield*/, this.apiClient.getCommitsSince(projectId, 'dev', sinceSha)];
|
|
106
108
|
case 1:
|
|
107
109
|
commits = _a.sent();
|
|
108
110
|
lastDevCommit = lodash_1.default.last(commits);
|
|
@@ -113,7 +115,7 @@ var GitLabService = /** @class */ (function () {
|
|
|
113
115
|
commits.pop();
|
|
114
116
|
}
|
|
115
117
|
if (!(commits === null || commits === void 0 ? void 0 : commits.length))
|
|
116
|
-
throw new
|
|
118
|
+
throw new errors_1.ShipItError("Could not find any commits in dev for projectId: ".concat(projectId, " since ").concat(sinceSha));
|
|
117
119
|
return [2 /*return*/, commits];
|
|
118
120
|
}
|
|
119
121
|
});
|
|
@@ -123,7 +125,7 @@ var GitLabService = /** @class */ (function () {
|
|
|
123
125
|
return __awaiter(this, void 0, void 0, function () {
|
|
124
126
|
return __generator(this, function (_a) {
|
|
125
127
|
switch (_a.label) {
|
|
126
|
-
case 0: return [4 /*yield*/, this.
|
|
128
|
+
case 0: return [4 /*yield*/, this.apiClient.getBranch(projectId, branchName)];
|
|
127
129
|
case 1: return [2 /*return*/, _a.sent()];
|
|
128
130
|
}
|
|
129
131
|
});
|
|
@@ -131,53 +133,47 @@ var GitLabService = /** @class */ (function () {
|
|
|
131
133
|
};
|
|
132
134
|
GitLabService.prototype.createBranch = function (project, branchFrom, branchName, cherryPick) {
|
|
133
135
|
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
-
var
|
|
136
|
+
var newBranch, i, mr;
|
|
135
137
|
return __generator(this, function (_a) {
|
|
136
138
|
switch (_a.label) {
|
|
137
139
|
case 0:
|
|
138
140
|
if (!cherryPick) return [3 /*break*/, 6];
|
|
139
|
-
return [4 /*yield*/, this.
|
|
141
|
+
return [4 /*yield*/, this.apiClient.createBranch(project.id, branchName, 'master')];
|
|
140
142
|
case 1:
|
|
141
|
-
|
|
142
|
-
if (!newBranch_1)
|
|
143
|
-
throw new Error("Failed to create branch from master for projectId: ".concat(project.id));
|
|
143
|
+
newBranch = _a.sent();
|
|
144
144
|
i = 0;
|
|
145
145
|
_a.label = 2;
|
|
146
146
|
case 2:
|
|
147
147
|
if (!(i < project.mergeRequests.length)) return [3 /*break*/, 5];
|
|
148
148
|
mr = project.mergeRequests[i];
|
|
149
149
|
if (!mr.mergeCommit)
|
|
150
|
-
throw new
|
|
151
|
-
return [4 /*yield*/, this.
|
|
150
|
+
throw new errors_1.ShipItError("Could not find the merge commit sha for MR: ".concat(mr.title, " in projectId: ").concat(project.id));
|
|
151
|
+
return [4 /*yield*/, this.apiClient.cherryPick(project.id, mr.mergeCommit, branchName)];
|
|
152
152
|
case 3:
|
|
153
153
|
_a.sent();
|
|
154
154
|
_a.label = 4;
|
|
155
155
|
case 4:
|
|
156
156
|
i++;
|
|
157
157
|
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];
|
|
158
|
+
case 5: return [2 /*return*/, newBranch];
|
|
159
|
+
case 6: return [4 /*yield*/, this.apiClient.createBranch(project.id, branchName, branchFrom)];
|
|
160
|
+
case 7: return [2 /*return*/, _a.sent()];
|
|
165
161
|
}
|
|
166
162
|
});
|
|
167
163
|
});
|
|
168
164
|
};
|
|
169
165
|
GitLabService.prototype.getMergeRequest = function (projectId, branchName) {
|
|
170
|
-
return this.
|
|
166
|
+
return this.apiClient.getMergeRequest(projectId, branchName, 'master');
|
|
171
167
|
};
|
|
172
168
|
GitLabService.prototype.createMergeRequest = function (projectId, branchName, description) {
|
|
173
|
-
return this.
|
|
169
|
+
return this.apiClient.createMergeRequest(projectId, branchName, 'master', branchName, description);
|
|
174
170
|
};
|
|
175
171
|
GitLabService.prototype.bumpVersionTxt = function (projectId, branchName, newVersion) {
|
|
176
172
|
return __awaiter(this, void 0, void 0, function () {
|
|
177
173
|
var versionTxt, buff, text;
|
|
178
174
|
return __generator(this, function (_a) {
|
|
179
175
|
switch (_a.label) {
|
|
180
|
-
case 0: return [4 /*yield*/, this.
|
|
176
|
+
case 0: return [4 /*yield*/, this.apiClient.getFile(projectId, 'version.txt', branchName)];
|
|
181
177
|
case 1:
|
|
182
178
|
versionTxt = _a.sent();
|
|
183
179
|
if (!versionTxt)
|
|
@@ -186,7 +182,7 @@ var GitLabService = /** @class */ (function () {
|
|
|
186
182
|
text = buff.toString('utf-8');
|
|
187
183
|
if (text === newVersion)
|
|
188
184
|
return [2 /*return*/, false];
|
|
189
|
-
return [4 /*yield*/, this.
|
|
185
|
+
return [4 /*yield*/, this.apiClient.updateFile(projectId, 'version.txt', branchName, newVersion, 'Bumping version.txt')];
|
|
190
186
|
case 2:
|
|
191
187
|
_a.sent();
|
|
192
188
|
return [2 /*return*/, true];
|
|
@@ -198,20 +194,20 @@ var GitLabService = /** @class */ (function () {
|
|
|
198
194
|
return __awaiter(this, void 0, void 0, function () {
|
|
199
195
|
return __generator(this, function (_a) {
|
|
200
196
|
switch (_a.label) {
|
|
201
|
-
case 0: return [4 /*yield*/, this.
|
|
197
|
+
case 0: return [4 /*yield*/, this.apiClient.getFile(projectId, file, branchName)];
|
|
202
198
|
case 1: return [2 /*return*/, _a.sent()];
|
|
203
199
|
}
|
|
204
200
|
});
|
|
205
201
|
});
|
|
206
202
|
};
|
|
207
203
|
GitLabService.prototype.updateFile = function (projectId, filePath, branchName, content, commit) {
|
|
208
|
-
return this.
|
|
204
|
+
return this.apiClient.updateFile(projectId, filePath, branchName, content, commit);
|
|
209
205
|
};
|
|
210
206
|
GitLabService.prototype.commit = function (projectId, branchName, commitMessage, files) {
|
|
211
207
|
return __awaiter(this, void 0, void 0, function () {
|
|
212
208
|
return __generator(this, function (_a) {
|
|
213
209
|
switch (_a.label) {
|
|
214
|
-
case 0: return [4 /*yield*/, this.
|
|
210
|
+
case 0: return [4 /*yield*/, this.apiClient.commit(projectId, branchName, files, commitMessage)];
|
|
215
211
|
case 1:
|
|
216
212
|
_a.sent();
|
|
217
213
|
return [2 /*return*/];
|
|
@@ -219,12 +215,16 @@ var GitLabService = /** @class */ (function () {
|
|
|
219
215
|
});
|
|
220
216
|
});
|
|
221
217
|
};
|
|
218
|
+
/**
|
|
219
|
+
* We use the latest valid semver tag in master to determine what the current version
|
|
220
|
+
* of a project is
|
|
221
|
+
*/
|
|
222
222
|
GitLabService.prototype.getCurrentVersionTag = function (projectId) {
|
|
223
223
|
return __awaiter(this, void 0, void 0, function () {
|
|
224
224
|
var tags, tagNames, sortedTagNames, currentVersion, currentTag;
|
|
225
225
|
return __generator(this, function (_a) {
|
|
226
226
|
switch (_a.label) {
|
|
227
|
-
case 0: return [4 /*yield*/, this.
|
|
227
|
+
case 0: return [4 /*yield*/, this.apiClient.getLatestTags(projectId)];
|
|
228
228
|
case 1:
|
|
229
229
|
tags = _a.sent();
|
|
230
230
|
if (!(tags === null || tags === void 0 ? void 0 : tags.length))
|
|
@@ -242,6 +242,33 @@ var GitLabService = /** @class */ (function () {
|
|
|
242
242
|
});
|
|
243
243
|
});
|
|
244
244
|
};
|
|
245
|
+
GitLabService.prototype.getNextBranchInfo = function (projectId, version) {
|
|
246
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
247
|
+
var tag, nextVersion, branchName, branch;
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
switch (_a.label) {
|
|
250
|
+
case 0: return [4 /*yield*/, this.getCurrentVersionTag(projectId)];
|
|
251
|
+
case 1:
|
|
252
|
+
tag = _a.sent();
|
|
253
|
+
if (!tag)
|
|
254
|
+
throw new errors_1.ShipItError("Could not find the latest semver tag for projectId: ".concat(projectId));
|
|
255
|
+
nextVersion = utils_1.Versions.getNextVersion(tag.name, version);
|
|
256
|
+
branchName = version === 'patch' ?
|
|
257
|
+
utils_1.BranchNames.getHotfix(nextVersion) :
|
|
258
|
+
utils_1.BranchNames.getRelease(nextVersion);
|
|
259
|
+
return [4 /*yield*/, this.getBranch(projectId, branchName)];
|
|
260
|
+
case 2:
|
|
261
|
+
branch = _a.sent();
|
|
262
|
+
return [2 /*return*/, {
|
|
263
|
+
nextVersion: nextVersion,
|
|
264
|
+
branchName: branchName,
|
|
265
|
+
branch: branch,
|
|
266
|
+
tag: tag
|
|
267
|
+
}];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
};
|
|
245
272
|
GitLabService = __decorate([
|
|
246
273
|
(0, inversify_1.injectable)(),
|
|
247
274
|
__param(0, (0, inversify_1.inject)(types_1.API_CLIENTS.GitLabApiClient)),
|
|
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getAddMilestoneCommand = void 0;
|
|
40
|
-
var
|
|
40
|
+
var CommandTypeMapping_1 = require("../constants/CommandTypeMapping");
|
|
41
41
|
var utils_1 = require("../utils");
|
|
42
42
|
function processOptions(options) {
|
|
43
43
|
var opts = {
|
|
@@ -65,7 +65,7 @@ var getAddMilestoneCommand = function (program, container) {
|
|
|
65
65
|
.option('--major')
|
|
66
66
|
.action(function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
67
67
|
return __generator(this, function (_a) {
|
|
68
|
-
container.get(
|
|
68
|
+
container.get(CommandTypeMapping_1.CommandTypeMapping[name])
|
|
69
69
|
.run(processOptions(options));
|
|
70
70
|
return [2 /*return*/];
|
|
71
71
|
});
|
|
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.setupCommands = void 0;
|
|
40
|
-
var
|
|
40
|
+
var CommandTypeMapping_1 = require("../constants/CommandTypeMapping");
|
|
41
41
|
var AddMilestoneCommand_1 = require("./AddMilestoneCommand");
|
|
42
42
|
function setupCommands(program, container) {
|
|
43
43
|
var _this = this;
|
|
@@ -57,7 +57,7 @@ function setupCommands(program, container) {
|
|
|
57
57
|
.action(function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
58
58
|
return __generator(this, function (_a) {
|
|
59
59
|
container
|
|
60
|
-
.get(
|
|
60
|
+
.get(CommandTypeMapping_1.CommandTypeMapping['bump-packages'])
|
|
61
61
|
.run(options);
|
|
62
62
|
return [2 /*return*/];
|
|
63
63
|
});
|
|
@@ -54,13 +54,13 @@ var inversify_1 = require("inversify");
|
|
|
54
54
|
var child_process_1 = require("child_process");
|
|
55
55
|
var types_1 = require("../types");
|
|
56
56
|
var services_1 = require("../services");
|
|
57
|
+
var MonorepoPackageJsonFiles_1 = require("../constants/MonorepoPackageJsonFiles");
|
|
57
58
|
var utils_1 = require("../utils");
|
|
58
|
-
var constants_1 = require("../constants");
|
|
59
59
|
var RELEASE_BRANCH_REGEX = /^release\/(\d|\.)+$/;
|
|
60
60
|
var HOTFIX_BRANCH_REGEX = /^hotfix\/(\d|\.)+$/;
|
|
61
61
|
var DEV_VERSION_REGEX = /-dev\.\d+$/;
|
|
62
62
|
var RC_VERSION_REGEX = /-rc\.\d+$/;
|
|
63
|
-
var
|
|
63
|
+
var SHARED_LERNA_OPTIONS = '--exact --no-git-tag-version --no-push --yes';
|
|
64
64
|
var BumpPackagesTask = /** @class */ (function () {
|
|
65
65
|
function BumpPackagesTask(service) {
|
|
66
66
|
this.isReleaseBranch = false;
|
|
@@ -69,23 +69,25 @@ var BumpPackagesTask = /** @class */ (function () {
|
|
|
69
69
|
}
|
|
70
70
|
BumpPackagesTask.prototype.run = function (options) {
|
|
71
71
|
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
var
|
|
72
|
+
var branch, isValid, lernaVersionCmd;
|
|
73
73
|
return __generator(this, function (_a) {
|
|
74
74
|
switch (_a.label) {
|
|
75
75
|
case 0:
|
|
76
76
|
utils_1.Logger.logTask('Bumping clickview npm package versions');
|
|
77
77
|
this.isReleaseBranch = RELEASE_BRANCH_REGEX.test(options.branchName);
|
|
78
78
|
this.isHotfixBranch = HOTFIX_BRANCH_REGEX.test(options.branchName);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
return [4 /*yield*/, this.service.getBranch(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.branchName)];
|
|
80
|
+
case 1:
|
|
81
|
+
branch = _a.sent();
|
|
82
|
+
if (!branch) {
|
|
83
|
+
utils_1.Logger.logError("Branch with name ".concat(options.branchName, " was not be found."));
|
|
82
84
|
return [2 /*return*/, false];
|
|
83
85
|
}
|
|
84
86
|
isValid = this.validateOptions(options);
|
|
85
87
|
if (!isValid)
|
|
86
88
|
return [2 /*return*/, false];
|
|
87
|
-
return [4 /*yield*/, this.
|
|
88
|
-
case
|
|
89
|
+
return [4 /*yield*/, this.getLernaCommand(options)];
|
|
90
|
+
case 2:
|
|
89
91
|
lernaVersionCmd = _a.sent();
|
|
90
92
|
if (!lernaVersionCmd) {
|
|
91
93
|
utils_1.Logger.logError('Something went wrong while trying to detect which versioning script to run with Lerna.');
|
|
@@ -133,47 +135,56 @@ var BumpPackagesTask = /** @class */ (function () {
|
|
|
133
135
|
});
|
|
134
136
|
});
|
|
135
137
|
};
|
|
136
|
-
BumpPackagesTask.prototype.
|
|
138
|
+
BumpPackagesTask.prototype.getLernaCommand = function (options) {
|
|
137
139
|
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
-
var
|
|
140
|
+
var isInPrerelease;
|
|
139
141
|
return __generator(this, function (_a) {
|
|
140
142
|
switch (_a.label) {
|
|
141
|
-
case 0: return [4 /*yield*/, this.
|
|
143
|
+
case 0: return [4 /*yield*/, this.isInPrerelease(options.branchName)];
|
|
142
144
|
case 1:
|
|
143
|
-
|
|
145
|
+
isInPrerelease = _a.sent();
|
|
146
|
+
/**
|
|
147
|
+
* The `lerna version prerelease` script only cares about incrementing the preId part
|
|
148
|
+
* of the version number. That's why we run this if `isInPrerelease` is true.
|
|
149
|
+
*
|
|
150
|
+
* E.g. this would change 0.0.1-dev.0 to 0.0.0-dev.1
|
|
151
|
+
*/
|
|
152
|
+
if (isInPrerelease && options.preId)
|
|
153
|
+
return [2 /*return*/, "lerna version prerelease --preid ".concat(options.preId, " ").concat(SHARED_LERNA_OPTIONS)];
|
|
154
|
+
// Bump the patch with the preId "dev". We currently only support dev prereleases on patch versions
|
|
155
|
+
if (options.preId === 'dev')
|
|
156
|
+
return [2 /*return*/, "lerna version prepatch --preid dev ".concat(SHARED_LERNA_OPTIONS)];
|
|
144
157
|
if (options.preId === 'rc') {
|
|
145
|
-
|
|
146
|
-
return [2 /*return*/, "lerna version prerelease --preid rc ".concat(GENERIC_LERNA_OPTIONS)];
|
|
158
|
+
// Bump the minor number with the preId "rc". Release branches always bump the minor number.
|
|
147
159
|
if (this.isReleaseBranch)
|
|
148
|
-
return [2 /*return*/, "lerna version preminor --preid rc ".concat(
|
|
160
|
+
return [2 /*return*/, "lerna version preminor --preid rc ".concat(SHARED_LERNA_OPTIONS)];
|
|
161
|
+
// Bump the patch with the preId "rc". Hotfix branches always bump the patch number.
|
|
149
162
|
if (this.isHotfixBranch)
|
|
150
|
-
return [2 /*return*/, "lerna version prepatch --preid rc ".concat(
|
|
151
|
-
}
|
|
152
|
-
if (options.preId === 'dev') {
|
|
153
|
-
if (hasBumpedOnce)
|
|
154
|
-
return [2 /*return*/, "lerna version prerelease --preid dev ".concat(GENERIC_LERNA_OPTIONS)];
|
|
155
|
-
return [2 /*return*/, "lerna version prepatch --preid dev ".concat(GENERIC_LERNA_OPTIONS)];
|
|
163
|
+
return [2 /*return*/, "lerna version prepatch --preid rc ".concat(SHARED_LERNA_OPTIONS)];
|
|
156
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* If no preId is provided, we bump the version number to a production version.
|
|
167
|
+
*
|
|
168
|
+
* Release branch = minor bump
|
|
169
|
+
* Hotfix branch = patch bump
|
|
170
|
+
*/
|
|
157
171
|
if (this.isReleaseBranch)
|
|
158
|
-
return [2 /*return*/, "lerna version minor"];
|
|
172
|
+
return [2 /*return*/, "lerna version minor ".concat(SHARED_LERNA_OPTIONS)];
|
|
159
173
|
if (this.isHotfixBranch)
|
|
160
|
-
return [2 /*return*/, "lerna version patch"];
|
|
174
|
+
return [2 /*return*/, "lerna version patch ".concat(SHARED_LERNA_OPTIONS)];
|
|
161
175
|
// Should never be reached
|
|
162
176
|
return [2 /*return*/, ''];
|
|
163
177
|
}
|
|
164
178
|
});
|
|
165
179
|
});
|
|
166
180
|
};
|
|
167
|
-
|
|
168
|
-
* If a package in the release already has a version
|
|
169
|
-
*/
|
|
170
|
-
BumpPackagesTask.prototype.hasBumpedOnce = function (branchName) {
|
|
181
|
+
BumpPackagesTask.prototype.isInPrerelease = function (branchName) {
|
|
171
182
|
return __awaiter(this, void 0, void 0, function () {
|
|
172
183
|
var _i, MONOREPO_PACKAGE_JSON_FILES_1, file, text, json;
|
|
173
184
|
return __generator(this, function (_a) {
|
|
174
185
|
switch (_a.label) {
|
|
175
186
|
case 0:
|
|
176
|
-
_i = 0, MONOREPO_PACKAGE_JSON_FILES_1 =
|
|
187
|
+
_i = 0, MONOREPO_PACKAGE_JSON_FILES_1 = MonorepoPackageJsonFiles_1.MONOREPO_PACKAGE_JSON_FILES;
|
|
177
188
|
_a.label = 1;
|
|
178
189
|
case 1:
|
|
179
190
|
if (!(_i < MONOREPO_PACKAGE_JSON_FILES_1.length)) return [3 /*break*/, 4];
|
|
@@ -54,53 +54,40 @@ var inversify_1 = require("inversify");
|
|
|
54
54
|
var Logger_1 = require("../utils/Logger");
|
|
55
55
|
var types_1 = require("../types");
|
|
56
56
|
var services_1 = require("../services");
|
|
57
|
-
var utils_1 = require("../utils");
|
|
58
57
|
var BumpVersionTxtTask = /** @class */ (function () {
|
|
59
58
|
function BumpVersionTxtTask(service) {
|
|
60
|
-
this.
|
|
59
|
+
this.service = service;
|
|
61
60
|
}
|
|
62
61
|
BumpVersionTxtTask.prototype.run = function (options) {
|
|
63
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
var projects,
|
|
65
|
-
return __generator(this, function (
|
|
66
|
-
switch (
|
|
63
|
+
var projects, _i, projects_1, project, _a, nextVersion, branchName, versionBumped;
|
|
64
|
+
return __generator(this, function (_b) {
|
|
65
|
+
switch (_b.label) {
|
|
67
66
|
case 0:
|
|
68
67
|
Logger_1.Logger.logTask('Bumping version.txt');
|
|
69
|
-
return [4 /*yield*/, this.
|
|
68
|
+
return [4 /*yield*/, this.service.getProjects(options)];
|
|
70
69
|
case 1:
|
|
71
|
-
projects =
|
|
72
|
-
if (!projects.length) {
|
|
73
|
-
Logger_1.Logger.logError("No projects could be found with the specified options");
|
|
74
|
-
return [2 /*return*/, false];
|
|
75
|
-
}
|
|
76
|
-
cont = true;
|
|
70
|
+
projects = _b.sent();
|
|
77
71
|
_i = 0, projects_1 = projects;
|
|
78
|
-
|
|
72
|
+
_b.label = 2;
|
|
79
73
|
case 2:
|
|
80
74
|
if (!(_i < projects_1.length)) return [3 /*break*/, 6];
|
|
81
75
|
project = projects_1[_i];
|
|
82
|
-
return [4 /*yield*/, this.
|
|
76
|
+
return [4 /*yield*/, this.service.getNextBranchInfo(project.id, options.version)];
|
|
83
77
|
case 3:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
Logger_1.Logger.logError("[".concat(project.title, "]: Could not find current version tag"));
|
|
87
|
-
cont = false;
|
|
88
|
-
return [3 /*break*/, 5];
|
|
89
|
-
}
|
|
90
|
-
nextVersion = utils_1.Versions.getNextVersion(currentVersionTag.name, options.version);
|
|
91
|
-
branchName = utils_1.BranchNames.getRelease(nextVersion);
|
|
92
|
-
return [4 /*yield*/, this._service.bumpVersionTxt(project.id, branchName, nextVersion)];
|
|
78
|
+
_a = _b.sent(), nextVersion = _a.nextVersion, branchName = _a.branchName;
|
|
79
|
+
return [4 /*yield*/, this.service.bumpVersionTxt(project.id, branchName, nextVersion)];
|
|
93
80
|
case 4:
|
|
94
|
-
versionBumped =
|
|
81
|
+
versionBumped = _b.sent();
|
|
95
82
|
if (versionBumped)
|
|
96
83
|
Logger_1.Logger.logMessage("[".concat(project.title, "]: Bumped to ").concat(nextVersion));
|
|
97
84
|
else
|
|
98
85
|
Logger_1.Logger.logWarning("[".concat(project.title, "]: Has already been bumped, or does not have a version.txt"));
|
|
99
|
-
|
|
86
|
+
_b.label = 5;
|
|
100
87
|
case 5:
|
|
101
88
|
_i++;
|
|
102
89
|
return [3 /*break*/, 2];
|
|
103
|
-
case 6: return [2 /*return*/,
|
|
90
|
+
case 6: return [2 /*return*/, true];
|
|
104
91
|
}
|
|
105
92
|
});
|
|
106
93
|
});
|