@clickview/ship-it 0.0.37 → 0.0.39

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.
@@ -23,6 +23,7 @@ exports.PROJECT_NAMES = {
23
23
  * it will still be detected by `ProjectIds.ts`
24
24
  */
25
25
  backend: {
26
+ account: '1175',
26
27
  integrations: '850',
27
28
  auth: '54',
28
29
  online: '41',
@@ -42,4 +42,5 @@ exports.TeamCityBuildIds = (_a = {},
42
42
  _a[constants_1.PROJECT_NAMES.backend.clients] = 'Tooling_Clients_PublishToNuget',
43
43
  _a[constants_1.PROJECT_NAMES.backend.goodstuff] = 'Tooling_GoodStuffInternal_PublishToNuget',
44
44
  _a[constants_1.PROJECT_NAMES.backend.share] = 'Api_ShareApi_BuildAndPackageDocker',
45
+ _a[constants_1.PROJECT_NAMES.backend.account] = 'Api_AccountApi_BuildAndPackageDocker',
45
46
  _a);
@@ -64,27 +64,20 @@ var BumpPackagesTask = /** @class */ (function () {
64
64
  function BumpPackagesTask(service) {
65
65
  this.isReleaseBranch = false;
66
66
  this.isHotfixBranch = false;
67
- this.isInPreRelease = false;
68
67
  this.service = service;
69
68
  }
70
69
  BumpPackagesTask.prototype.run = function (options) {
71
70
  return __awaiter(this, void 0, void 0, function () {
72
- var _a, branch, isValid, commitFiles, _i, commitFiles_1, file, newJsonFile;
73
- return __generator(this, function (_b) {
74
- switch (_b.label) {
71
+ var branch, isValid, commitFiles, _i, commitFiles_1, file, newJsonFile;
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
75
74
  case 0:
76
75
  utils_1.Logger.logTask('Bumping clickview npm package versions');
77
76
  this.isReleaseBranch = RELEASE_BRANCH_REGEX.test(options.branchName);
78
77
  this.isHotfixBranch = HOTFIX_BRANCH_REGEX.test(options.branchName);
79
- _a = this;
80
- return [4 /*yield*/, this.getIsInPrerelease(options.branchName)];
81
- case 1:
82
- _a.isInPreRelease = _b.sent();
83
- if (this.isInPreRelease)
84
- utils_1.Logger.logTask('Detected that monorepo is currently in a pre-release state');
85
78
  return [4 /*yield*/, this.service.getBranch(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.branchName)];
86
- case 2:
87
- branch = _b.sent();
79
+ case 1:
80
+ branch = _a.sent();
88
81
  if (!branch) {
89
82
  utils_1.Logger.logError("Branch with name ".concat(options.branchName, " was not be found."));
90
83
  return [2 /*return*/, false];
@@ -103,8 +96,8 @@ var BumpPackagesTask = /** @class */ (function () {
103
96
  }
104
97
  utils_1.Logger.logInfo('Committing new versions...');
105
98
  return [4 /*yield*/, this.service.commit(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.branchName, 'Bump package versions', commitFiles)];
106
- case 3:
107
- _b.sent();
99
+ case 2:
100
+ _a.sent();
108
101
  utils_1.Logger.logSuccess('Successfully committed updated version numbers.');
109
102
  return [2 /*return*/, true];
110
103
  }
@@ -174,71 +167,58 @@ var BumpPackagesTask = /** @class */ (function () {
174
167
  }
175
168
  return commitFiles;
176
169
  };
177
- BumpPackagesTask.prototype.getNextVersion = function (version, options) {
178
- // If we're in a prerelease, we only want to increment the preId part of the version number
179
- if (this.isInPreRelease && options.preId) {
180
- if (options.preId === 'dev') {
181
- if (DEV_VERSION_REGEX.test(version)) {
182
- var _a = version.split('-dev.'), mainVersion = _a[0], currentPreId = _a[1];
183
- return "".concat(mainVersion, "-dev.").concat(Number(currentPreId) + 1);
184
- }
185
- return "".concat(utils_1.Versions.getNextVersion(version, 'patch'), "-dev.0");
186
- }
187
- if (options.preId === 'rc') {
188
- if (RC_VERSION_REGEX.test(version)) {
189
- var _b = version.split('-rc.'), mainVersion = _b[0], currentPreId = _b[1];
190
- return "".concat(mainVersion, "-rc.").concat(Number(currentPreId) + 1);
191
- }
192
- if (this.isReleaseBranch)
193
- return "".concat(utils_1.Versions.getNextVersion(version, 'minor'), "-rc.0");
194
- if (this.isHotfixBranch)
195
- return "".concat(utils_1.Versions.getNextVersion(version, 'patch'), "-rc.0");
170
+ BumpPackagesTask.prototype.getNextVersion = function (currentVersion, options) {
171
+ if (options.preId)
172
+ return this.getNextPrereleaseVersion(currentVersion, options);
173
+ return this.getNextReleaseVersion(currentVersion);
174
+ };
175
+ BumpPackagesTask.prototype.getNextPrereleaseVersion = function (currentVersion, options) {
176
+ if (options.preId === 'dev') {
177
+ // If version is already a dev version, increment the preId
178
+ // Example: 1.0.0-dev.5 -> 1.0.0-dev.6
179
+ if (DEV_VERSION_REGEX.test(currentVersion)) {
180
+ var _a = currentVersion.split('-dev.'), mainVersion = _a[0], currentPreId = _a[1];
181
+ return "".concat(mainVersion, "-dev.").concat(Number(currentPreId) + 1);
196
182
  }
197
- return version;
183
+ // Bump the patch version and add the dev preId
184
+ // Example: 1.0.0 -> 1.0.1-dev.0
185
+ return "".concat(utils_1.Versions.getNextVersion(currentVersion, 'patch'), "-dev.0");
198
186
  }
199
- if (options.preId === 'dev')
200
- return "".concat(utils_1.Versions.getNextVersion(version, 'patch'), "-dev.0");
201
187
  if (options.preId === 'rc') {
188
+ // If version is already an rc version, increment the preId
189
+ // Example: 1.0.0-rc.5 -> 1.0.0-rc.6
190
+ if (RC_VERSION_REGEX.test(currentVersion)) {
191
+ var _b = currentVersion.split('-rc.'), mainVersion = _b[0], currentPreId = _b[1];
192
+ return "".concat(mainVersion, "-rc.").concat(Number(currentPreId) + 1);
193
+ }
194
+ // For release branches, bump the minor version and add the rc preId
195
+ // Example: 1.0.0 -> 1.1.0-rc.0
202
196
  if (this.isReleaseBranch)
203
- return "".concat(utils_1.Versions.getNextVersion(version, 'minor'), "-rc.0");
197
+ return "".concat(utils_1.Versions.getNextVersion(currentVersion, 'minor'), "-rc.0");
198
+ // For hotfix branches, bump the patch version and add the rc preId
199
+ // Example: 1.0.0 -> 1.0.1-rc.0
204
200
  if (this.isHotfixBranch)
205
- return "".concat(utils_1.Versions.getNextVersion(version, 'patch'), "-rc.0");
201
+ return "".concat(utils_1.Versions.getNextVersion(currentVersion, 'patch'), "-rc.0");
202
+ }
203
+ // Should never run
204
+ return currentVersion;
205
+ };
206
+ BumpPackagesTask.prototype.getNextReleaseVersion = function (currentVersion) {
207
+ // Example: 1.0.1-dev.0 -> 1.0.1
208
+ if (DEV_VERSION_REGEX.test(currentVersion)) {
209
+ return currentVersion.split('-')[0];
210
+ }
211
+ // Example: 1.0.1-rc.5 -> 1.0.1
212
+ if (RC_VERSION_REGEX.test(currentVersion)) {
213
+ return currentVersion.split('-')[0];
206
214
  }
215
+ // Example: 1.0.0 -> 1.1.0
207
216
  if (this.isReleaseBranch)
208
- return utils_1.Versions.getNextVersion(version, 'minor');
217
+ return utils_1.Versions.getNextVersion(currentVersion, 'minor');
218
+ // Example: 1.0.0 -> 1.0.1
209
219
  if (this.isHotfixBranch)
210
- return utils_1.Versions.getNextVersion(version, 'patch');
211
- return version;
212
- };
213
- BumpPackagesTask.prototype.getIsInPrerelease = function (branchName) {
214
- return __awaiter(this, void 0, void 0, function () {
215
- var _i, MONOREPO_PACKAGE_JSON_FILES_1, file, text, json;
216
- return __generator(this, function (_a) {
217
- switch (_a.label) {
218
- case 0:
219
- _i = 0, MONOREPO_PACKAGE_JSON_FILES_1 = MonorepoPackageJsonFiles_1.MONOREPO_PACKAGE_JSON_FILES;
220
- _a.label = 1;
221
- case 1:
222
- if (!(_i < MONOREPO_PACKAGE_JSON_FILES_1.length)) return [3 /*break*/, 4];
223
- file = MONOREPO_PACKAGE_JSON_FILES_1[_i];
224
- if (!file.includes('projects'))
225
- return [3 /*break*/, 3];
226
- return [4 /*yield*/, this.getFileText(utils_1.ProjectIds.MONOREPO_PROJECT_ID, branchName, file)];
227
- case 2:
228
- text = _a.sent();
229
- json = JSON.parse(text);
230
- if (RC_VERSION_REGEX.test(json.version))
231
- return [2 /*return*/, true];
232
- if (DEV_VERSION_REGEX.test(json.version))
233
- return [2 /*return*/, true];
234
- _a.label = 3;
235
- case 3:
236
- _i++;
237
- return [3 /*break*/, 1];
238
- case 4: return [2 /*return*/, false];
239
- }
240
- });
241
- });
220
+ return utils_1.Versions.getNextVersion(currentVersion, 'patch');
221
+ return currentVersion;
242
222
  };
243
223
  BumpPackagesTask = __decorate([
244
224
  (0, inversify_1.injectable)(),
@@ -96,6 +96,14 @@ var InstallPackagesTask = /** @class */ (function () {
96
96
  }
97
97
  if (!(_options.targetBranchName && _options.monorepoBranchName && _options.projectIds)) return [3 /*break*/, 8];
98
98
  targetBranch = _options.targetBranchName;
99
+ if (targetBranch.startsWith('release') && !_options.monorepoBranchName.startsWith('release')) {
100
+ utils_1.Logger.logError('Attempting to target release with non release branch.');
101
+ return [2 /*return*/, false];
102
+ }
103
+ if (targetBranch.startsWith('hotfix') && !_options.monorepoBranchName.startsWith('hotfix')) {
104
+ utils_1.Logger.logError('Attempting to target hotfix with non hotfix branch.');
105
+ return [2 /*return*/, false];
106
+ }
99
107
  if (_options.projectIds.length > 1) {
100
108
  utils_1.Logger.logError("Too many projects given! Maximum 1 project allowed but got ".concat(_options.projectIds.length));
101
109
  return [2 /*return*/, false];
@@ -62,7 +62,7 @@ var TagMasterTask = /** @class */ (function () {
62
62
  }
63
63
  TagMasterTask.prototype.run = function (options) {
64
64
  return __awaiter(this, void 0, void 0, function () {
65
- var projects, cont, logMessageSlack, _i, projects_1, project, _a, branchName, nextVersion, mergeRequest, existingTag, _b, threadLabel, statusCleanMessage;
65
+ var projects, cont, logMessageSlack, _i, projects_1, project, _a, branchName, nextVersion, existingTag, mergeRequest, _b, threadLabel, statusCleanMessage;
66
66
  return __generator(this, function (_c) {
67
67
  switch (_c.label) {
68
68
  case 0:
@@ -80,19 +80,19 @@ var TagMasterTask = /** @class */ (function () {
80
80
  return [4 /*yield*/, this.service.getNextBranchInfo(project.id, options.version)];
81
81
  case 3:
82
82
  _a = _c.sent(), branchName = _a.branchName, nextVersion = _a.nextVersion;
83
- return [4 /*yield*/, this.service.getMergeRequest(project.id, branchName)];
83
+ return [4 /*yield*/, this.service.getTag(project.id, nextVersion)];
84
84
  case 4:
85
- mergeRequest = _c.sent();
86
- if (!(mergeRequest === null || mergeRequest === void 0 ? void 0 : mergeRequest.mergeCommit)) {
87
- Logger_1.Logger.logError("[".concat(project.title, "]: [").concat(branchName, "] has not been merged"));
85
+ existingTag = _c.sent();
86
+ if (existingTag) {
87
+ Logger_1.Logger.logWarning("[".concat(project.title, "]: [").concat(existingTag.name, "] tag already exists"));
88
88
  cont = false;
89
89
  return [3 /*break*/, 8];
90
90
  }
91
- return [4 /*yield*/, this.service.getTag(project.id, nextVersion)];
91
+ return [4 /*yield*/, this.service.getMergeRequest(project.id, branchName)];
92
92
  case 5:
93
- existingTag = _c.sent();
94
- if (existingTag) {
95
- Logger_1.Logger.logWarning("[".concat(project.title, "]: [").concat(existingTag.name, "] tag already exists"));
93
+ mergeRequest = _c.sent();
94
+ if (!(mergeRequest === null || mergeRequest === void 0 ? void 0 : mergeRequest.mergeCommit)) {
95
+ Logger_1.Logger.logError("[".concat(project.title, "]: [").concat(branchName, "] has not been merged"));
96
96
  cont = false;
97
97
  return [3 /*break*/, 8];
98
98
  }
@@ -115,7 +115,7 @@ var TagMasterTask = /** @class */ (function () {
115
115
  return [3 /*break*/, 2];
116
116
  case 9:
117
117
  if (!(options.slackNotifier && logMessageSlack !== '')) return [3 /*break*/, 11];
118
- threadLabel = "".concat(options.milestone, " merge conflicts found when merging master into dev.");
118
+ threadLabel = "".concat(options.milestone, " merge issues found when merging master into dev.");
119
119
  statusCleanMessage = 'No projects require manual merging.';
120
120
  return [4 /*yield*/, this.slackService.sendSlackStatusMessage({
121
121
  emailList: [],
@@ -143,7 +143,7 @@ var TagMasterTask = /** @class */ (function () {
143
143
  case 1:
144
144
  mergeRequest = _a.sent();
145
145
  // Add delay to give time before we merge created MR
146
- return [4 /*yield*/, delay(5000)];
146
+ return [4 /*yield*/, delay(10000)];
147
147
  case 2:
148
148
  // Add delay to give time before we merge created MR
149
149
  _a.sent();
@@ -168,6 +168,9 @@ var TagMasterTask = /** @class */ (function () {
168
168
  }
169
169
  else {
170
170
  Logger_1.Logger.logError("Could not merge master into dev.");
171
+ logMessageSlack += "[".concat(project.title, "]: Requires manual merging. An issue was found when trying to merge master into dev.\n");
172
+ logMessageSlack += " - ".concat(updatedMergeRequest.url, "\n");
173
+ return [2 /*return*/, logMessageSlack];
171
174
  }
172
175
  return [2 /*return*/, logMessageSlack];
173
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickview/ship-it",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "description": "Release Manager",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {