@clickview/ship-it 0.0.38 → 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,98 +167,58 @@ var BumpPackagesTask = /** @class */ (function () {
174
167
  }
175
168
  return commitFiles;
176
169
  };
177
- BumpPackagesTask.prototype.getNextVersion = function (version, options) {
170
+ BumpPackagesTask.prototype.getNextVersion = function (currentVersion, options) {
178
171
  if (options.preId)
179
- return this.getNextPrereleaseVersion(version, options);
180
- return this.getNextReleaseVersion(version);
172
+ return this.getNextPrereleaseVersion(currentVersion, options);
173
+ return this.getNextReleaseVersion(currentVersion);
181
174
  };
182
- BumpPackagesTask.prototype.getNextPrereleaseVersion = function (version, options) {
183
- /**
184
- * If we're in a prerelease state already, we only want to increment the
185
- * preId part of the version number
186
- *
187
- * Example: 1.0.0-rc.0 -> 1.0.0-rc.1
188
- */
189
- if (this.isInPreRelease) {
190
- if (options.preId === 'dev') {
191
- if (DEV_VERSION_REGEX.test(version)) {
192
- var _a = version.split('-dev.'), mainVersion = _a[0], currentPreId = _a[1];
193
- return "".concat(mainVersion, "-dev.").concat(Number(currentPreId) + 1);
194
- }
195
- return "".concat(utils_1.Versions.getNextVersion(version, 'patch'), "-dev.0");
196
- }
197
- if (options.preId === 'rc') {
198
- if (RC_VERSION_REGEX.test(version)) {
199
- var _b = version.split('-rc.'), mainVersion = _b[0], currentPreId = _b[1];
200
- return "".concat(mainVersion, "-rc.").concat(Number(currentPreId) + 1);
201
- }
202
- if (this.isReleaseBranch)
203
- return "".concat(utils_1.Versions.getNextVersion(version, 'minor'), "-rc.0");
204
- if (this.isHotfixBranch)
205
- return "".concat(utils_1.Versions.getNextVersion(version, 'patch'), "-rc.0");
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);
206
182
  }
207
- // Should never run
208
- 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");
209
186
  }
210
- /**
211
- * The code below runs if we are not currently in a prerelease state,
212
- * and we want to bump to a prerelease version.
213
- *
214
- * Example: 1.0.0 -> 1.0.1-dev.0 / 1.0.0 -> 1.1.0-rc.0
215
- */
216
- if (options.preId === 'dev')
217
- return "".concat(utils_1.Versions.getNextVersion(version, 'patch'), "-dev.0");
218
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
219
196
  if (this.isReleaseBranch)
220
- 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
221
200
  if (this.isHotfixBranch)
222
- return "".concat(utils_1.Versions.getNextVersion(version, 'patch'), "-rc.0");
201
+ return "".concat(utils_1.Versions.getNextVersion(currentVersion, 'patch'), "-rc.0");
223
202
  }
224
203
  // Should never run
225
- return version;
204
+ return currentVersion;
226
205
  };
227
- BumpPackagesTask.prototype.getNextReleaseVersion = function (version) {
228
- if (this.isInPreRelease) {
229
- // Examples: 1.0.1-rc.5 -> 1.0.1 / 1.0.0-dev.0 -> 1.0.0
230
- return version.split('-')[0];
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];
231
214
  }
232
215
  // Example: 1.0.0 -> 1.1.0
233
216
  if (this.isReleaseBranch)
234
- return utils_1.Versions.getNextVersion(version, 'minor');
217
+ return utils_1.Versions.getNextVersion(currentVersion, 'minor');
235
218
  // Example: 1.0.0 -> 1.0.1
236
219
  if (this.isHotfixBranch)
237
- return utils_1.Versions.getNextVersion(version, 'patch');
238
- return version;
239
- };
240
- BumpPackagesTask.prototype.getIsInPrerelease = function (branchName) {
241
- return __awaiter(this, void 0, void 0, function () {
242
- var _i, MONOREPO_PACKAGE_JSON_FILES_1, file, text, json;
243
- return __generator(this, function (_a) {
244
- switch (_a.label) {
245
- case 0:
246
- _i = 0, MONOREPO_PACKAGE_JSON_FILES_1 = MonorepoPackageJsonFiles_1.MONOREPO_PACKAGE_JSON_FILES;
247
- _a.label = 1;
248
- case 1:
249
- if (!(_i < MONOREPO_PACKAGE_JSON_FILES_1.length)) return [3 /*break*/, 4];
250
- file = MONOREPO_PACKAGE_JSON_FILES_1[_i];
251
- if (!file.includes('projects'))
252
- return [3 /*break*/, 3];
253
- return [4 /*yield*/, this.getFileText(utils_1.ProjectIds.MONOREPO_PROJECT_ID, branchName, file)];
254
- case 2:
255
- text = _a.sent();
256
- json = JSON.parse(text);
257
- if (RC_VERSION_REGEX.test(json.version))
258
- return [2 /*return*/, true];
259
- if (DEV_VERSION_REGEX.test(json.version))
260
- return [2 /*return*/, true];
261
- _a.label = 3;
262
- case 3:
263
- _i++;
264
- return [3 /*break*/, 1];
265
- case 4: return [2 /*return*/, false];
266
- }
267
- });
268
- });
220
+ return utils_1.Versions.getNextVersion(currentVersion, 'patch');
221
+ return currentVersion;
269
222
  };
270
223
  BumpPackagesTask = __decorate([
271
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.38",
3
+ "version": "0.0.39",
4
4
  "description": "Release Manager",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {