@clickview/ship-it 0.0.35-dev.2 → 0.0.35-dev.21
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/commands/BumpPackagesCommand.js +3 -11
- package/lib/src/constants/MonorepoPackageJsonFiles.js +25 -1
- package/lib/src/index.js +0 -0
- package/lib/src/inversify.config.js +0 -1
- package/lib/src/tasks/BumpPackagesTask.js +69 -69
- package/lib/src/tasks/InstallPackagesTask.js +3 -3
- package/lib/src/tasks/index.js +0 -1
- package/lib/src/types.js +0 -1
- package/package.json +1 -1
- package/lib/src/tasks/CommitPackageVersionsTask.js +0 -116
|
@@ -53,22 +53,15 @@ require("reflect-metadata");
|
|
|
53
53
|
var inversify_1 = require("inversify");
|
|
54
54
|
var types_1 = require("../types");
|
|
55
55
|
var BumpPackagesCommand = /** @class */ (function () {
|
|
56
|
-
function BumpPackagesCommand(bumpPackagesTask
|
|
56
|
+
function BumpPackagesCommand(bumpPackagesTask) {
|
|
57
57
|
this.bumpPackagesTask = bumpPackagesTask;
|
|
58
|
-
this.commitPackageVersionsTask = commitPackageVersionsTask;
|
|
59
58
|
}
|
|
60
59
|
BumpPackagesCommand.prototype.run = function (options) {
|
|
61
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var cont;
|
|
63
61
|
return __generator(this, function (_a) {
|
|
64
62
|
switch (_a.label) {
|
|
65
63
|
case 0: return [4 /*yield*/, this.bumpPackagesTask.run(options)];
|
|
66
|
-
case 1:
|
|
67
|
-
cont = _a.sent();
|
|
68
|
-
if (!cont)
|
|
69
|
-
return [2 /*return*/, false];
|
|
70
|
-
return [4 /*yield*/, this.commitPackageVersionsTask.run(options)];
|
|
71
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
64
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
72
65
|
}
|
|
73
66
|
});
|
|
74
67
|
});
|
|
@@ -76,8 +69,7 @@ var BumpPackagesCommand = /** @class */ (function () {
|
|
|
76
69
|
BumpPackagesCommand = __decorate([
|
|
77
70
|
(0, inversify_1.injectable)(),
|
|
78
71
|
__param(0, (0, inversify_1.inject)(types_1.TASKS.BumpPackagesTask)),
|
|
79
|
-
|
|
80
|
-
__metadata("design:paramtypes", [Object, Object])
|
|
72
|
+
__metadata("design:paramtypes", [Object])
|
|
81
73
|
], BumpPackagesCommand);
|
|
82
74
|
return BumpPackagesCommand;
|
|
83
75
|
}());
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a, _b;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MONOREPO_PACKAGE_JSON_FILES = void 0;
|
|
4
|
+
exports.MONOREPO_DISTS_MAP = exports.MONOREPO_PACKAGE_JSON_FILES_MAP = exports.MONOREPO_PACKAGE_JSON_FILES = void 0;
|
|
5
|
+
var ProjectNames_1 = require("./ProjectNames");
|
|
4
6
|
exports.MONOREPO_PACKAGE_JSON_FILES = [
|
|
5
7
|
'packages/libs/analytics/package.json',
|
|
6
8
|
'packages/libs/styles/package.json',
|
|
@@ -15,3 +17,25 @@ exports.MONOREPO_PACKAGE_JSON_FILES = [
|
|
|
15
17
|
'packages/projects/player/package.json',
|
|
16
18
|
'packages/projects/streamable-learning/package.json'
|
|
17
19
|
];
|
|
20
|
+
exports.MONOREPO_PACKAGE_JSON_FILES_MAP = (_a = {},
|
|
21
|
+
_a[ProjectNames_1.PROJECT_NAMES.backend.auth] = 'packages/projects/auth/package.json',
|
|
22
|
+
_a[ProjectNames_1.PROJECT_NAMES.frontend.curator] = 'packages/projects/curator/package.json',
|
|
23
|
+
_a[ProjectNames_1.PROJECT_NAMES.frontend.cloud] = 'packages/projects/library-editor/package.json',
|
|
24
|
+
_a[ProjectNames_1.PROJECT_NAMES.frontend.lite] = 'packages/projects/lite/package.json',
|
|
25
|
+
_a[ProjectNames_1.PROJECT_NAMES.frontend.online] = 'packages/projects/online/package.json',
|
|
26
|
+
_a[ProjectNames_1.PROJECT_NAMES.frontend.reports] = 'packages/projects/reports/package.json',
|
|
27
|
+
_a[ProjectNames_1.PROJECT_NAMES.frontend.exchange] = 'packages/projects/exchange/package.json',
|
|
28
|
+
_a[ProjectNames_1.PROJECT_NAMES.backend.player] = 'packages/projects/player/package.json',
|
|
29
|
+
_a[ProjectNames_1.PROJECT_NAMES.frontend.streamable] = 'packages/projects/streamable-learning/package.json',
|
|
30
|
+
_a);
|
|
31
|
+
exports.MONOREPO_DISTS_MAP = (_b = {},
|
|
32
|
+
_b[ProjectNames_1.PROJECT_NAMES.backend.auth] = 'packages/projects/auth/dist',
|
|
33
|
+
_b[ProjectNames_1.PROJECT_NAMES.frontend.curator] = 'packages/projects/curator/dist',
|
|
34
|
+
_b[ProjectNames_1.PROJECT_NAMES.frontend.cloud] = 'packages/projects/library-editor/dist',
|
|
35
|
+
_b[ProjectNames_1.PROJECT_NAMES.frontend.lite] = 'packages/projects/lite/dist',
|
|
36
|
+
_b[ProjectNames_1.PROJECT_NAMES.frontend.online] = 'packages/projects/online/dist',
|
|
37
|
+
_b[ProjectNames_1.PROJECT_NAMES.frontend.reports] = 'packages/projects/reports/dist',
|
|
38
|
+
_b[ProjectNames_1.PROJECT_NAMES.frontend.exchange] = 'packages/projects/exchange/dist',
|
|
39
|
+
_b[ProjectNames_1.PROJECT_NAMES.backend.player] = 'packages/projects/player/dist',
|
|
40
|
+
_b[ProjectNames_1.PROJECT_NAMES.frontend.streamable] = 'packages/projects/streamable-learning/dist',
|
|
41
|
+
_b);
|
package/lib/src/index.js
CHANGED
|
File without changes
|
|
@@ -44,7 +44,6 @@ function createContainer(config) {
|
|
|
44
44
|
container.bind(types_1.TASKS.CreateNotesAuditTask).to(tasks_1.CreateNotesAuditTask);
|
|
45
45
|
container.bind(types_1.TASKS.InstallPackagesTask).to(tasks_1.InstallPackagesTask);
|
|
46
46
|
container.bind(types_1.TASKS.BumpPackagesTask).to(tasks_1.BumpPackagesTask);
|
|
47
|
-
container.bind(types_1.TASKS.CommitPackageVersionsTask).to(tasks_1.CommitPackageVersionsTask);
|
|
48
47
|
container.bind(types_1.TASKS.ValidateMergeRequestTask).to(tasks_1.ValidateMergeRequestTask);
|
|
49
48
|
container.bind(types_1.TASKS.StartMonorepoBuildTask).to(tasks_1.StartMonorepoBuildTask);
|
|
50
49
|
container.bind(types_1.TASKS.TagMasterTask).to(tasks_1.TagMasterTask);
|
|
@@ -50,8 +50,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
51
|
exports.BumpPackagesTask = void 0;
|
|
52
52
|
require("reflect-metadata");
|
|
53
|
+
var fs_1 = require("fs");
|
|
53
54
|
var inversify_1 = require("inversify");
|
|
54
|
-
var child_process_1 = require("child_process");
|
|
55
55
|
var types_1 = require("../types");
|
|
56
56
|
var services_1 = require("../services");
|
|
57
57
|
var MonorepoPackageJsonFiles_1 = require("../constants/MonorepoPackageJsonFiles");
|
|
@@ -60,25 +60,30 @@ 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 SHARED_LERNA_OPTIONS = '--exact --no-git-tag-version --no-push --yes';
|
|
64
63
|
var BumpPackagesTask = /** @class */ (function () {
|
|
65
64
|
function BumpPackagesTask(service) {
|
|
66
65
|
this.isReleaseBranch = false;
|
|
67
66
|
this.isHotfixBranch = false;
|
|
67
|
+
this.isInPreRelease = false;
|
|
68
68
|
this.service = service;
|
|
69
69
|
}
|
|
70
70
|
BumpPackagesTask.prototype.run = function (options) {
|
|
71
71
|
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
var branch, isValid,
|
|
73
|
-
return __generator(this, function (
|
|
74
|
-
switch (
|
|
72
|
+
var _a, branch, isValid, commitFiles, _i, commitFiles_1, file;
|
|
73
|
+
return __generator(this, function (_b) {
|
|
74
|
+
switch (_b.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
|
-
|
|
79
|
+
utils_1.Logger.logTask('Detected that monorepo is currently in a pre-release state');
|
|
80
|
+
_a = this;
|
|
81
|
+
return [4 /*yield*/, this.getIsInPrerelease(options.branchName)];
|
|
80
82
|
case 1:
|
|
81
|
-
|
|
83
|
+
_a.isInPreRelease = _b.sent();
|
|
84
|
+
return [4 /*yield*/, this.service.getBranch(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.branchName)];
|
|
85
|
+
case 2:
|
|
86
|
+
branch = _b.sent();
|
|
82
87
|
if (!branch) {
|
|
83
88
|
utils_1.Logger.logError("Branch with name ".concat(options.branchName, " was not be found."));
|
|
84
89
|
return [2 /*return*/, false];
|
|
@@ -86,15 +91,18 @@ var BumpPackagesTask = /** @class */ (function () {
|
|
|
86
91
|
isValid = this.validateOptions(options);
|
|
87
92
|
if (!isValid)
|
|
88
93
|
return [2 /*return*/, false];
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
utils_1.Logger.logInfo('Options are valid! Proceeding to bump package versions.');
|
|
95
|
+
commitFiles = this.getCommitFiles(options);
|
|
96
|
+
utils_1.Logger.logInfo('Writing new versions to package.json files...');
|
|
97
|
+
for (_i = 0, commitFiles_1 = commitFiles; _i < commitFiles_1.length; _i++) {
|
|
98
|
+
file = commitFiles_1[_i];
|
|
99
|
+
(0, fs_1.writeFileSync)(file.filePath, file.content);
|
|
95
100
|
}
|
|
96
|
-
|
|
97
|
-
utils_1.
|
|
101
|
+
utils_1.Logger.logInfo('Committing new versions...');
|
|
102
|
+
return [4 /*yield*/, this.service.commit(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.branchName, 'Bump package versions', commitFiles)];
|
|
103
|
+
case 3:
|
|
104
|
+
_b.sent();
|
|
105
|
+
utils_1.Logger.logSuccess('Successfully committed updated version numbers.');
|
|
98
106
|
return [2 /*return*/, true];
|
|
99
107
|
}
|
|
100
108
|
});
|
|
@@ -136,62 +144,54 @@ var BumpPackagesTask = /** @class */ (function () {
|
|
|
136
144
|
});
|
|
137
145
|
});
|
|
138
146
|
};
|
|
139
|
-
BumpPackagesTask.prototype.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (options.preId === 'rc') {
|
|
163
|
-
// Bump the minor number with the preId "rc". Release branches always bump the minor number.
|
|
164
|
-
if (this.isReleaseBranch) {
|
|
165
|
-
utils_1.Logger.logMessage("Incrementing the minor version for each package and appending preId: \"rc\".");
|
|
166
|
-
return [2 /*return*/, "lerna version preminor --preid rc ".concat(SHARED_LERNA_OPTIONS)];
|
|
167
|
-
}
|
|
168
|
-
// Bump the patch with the preId "rc". Hotfix branches always bump the patch number.
|
|
169
|
-
if (this.isHotfixBranch) {
|
|
170
|
-
utils_1.Logger.logMessage("Incrementing the patch version for each package and appending preId: \"rc\".");
|
|
171
|
-
return [2 /*return*/, "lerna version prepatch --preid rc ".concat(SHARED_LERNA_OPTIONS)];
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* If no preId is provided, we bump the version number to a production version.
|
|
176
|
-
*
|
|
177
|
-
* Release branch = minor bump
|
|
178
|
-
* Hotfix branch = patch bump
|
|
179
|
-
*/
|
|
180
|
-
if (this.isReleaseBranch) {
|
|
181
|
-
utils_1.Logger.logMessage('Updating each package to production release version.');
|
|
182
|
-
return [2 /*return*/, "lerna version minor ".concat(SHARED_LERNA_OPTIONS)];
|
|
183
|
-
}
|
|
184
|
-
if (this.isHotfixBranch) {
|
|
185
|
-
utils_1.Logger.logMessage('Updating each package to production hotfix version.');
|
|
186
|
-
return [2 /*return*/, "lerna version patch ".concat(SHARED_LERNA_OPTIONS)];
|
|
187
|
-
}
|
|
188
|
-
// Should never be reached
|
|
189
|
-
return [2 /*return*/, ''];
|
|
190
|
-
}
|
|
147
|
+
BumpPackagesTask.prototype.getCommitFiles = function (options) {
|
|
148
|
+
var commitFiles = [];
|
|
149
|
+
for (var _i = 0, _a = Object.entries(MonorepoPackageJsonFiles_1.MONOREPO_PACKAGE_JSON_FILES_MAP); _i < _a.length; _i++) {
|
|
150
|
+
var _b = _a[_i], projectId = _b[0], packageJsonFilePath = _b[1];
|
|
151
|
+
// Only bump versions for projects with an output directory
|
|
152
|
+
if (!(0, fs_1.existsSync)(MonorepoPackageJsonFiles_1.MONOREPO_DISTS_MAP[projectId]) || !(0, fs_1.statSync)(MonorepoPackageJsonFiles_1.MONOREPO_DISTS_MAP[projectId]).isDirectory())
|
|
153
|
+
continue;
|
|
154
|
+
var content = '';
|
|
155
|
+
try {
|
|
156
|
+
content = (0, fs_1.readFileSync)(packageJsonFilePath, { encoding: 'utf8' });
|
|
157
|
+
}
|
|
158
|
+
catch (_c) {
|
|
159
|
+
/**
|
|
160
|
+
* If the file doesn't exist, ignore the error.
|
|
161
|
+
* This will occur when TC Docker runs this script as it doesn't copy over @clickview/tooling
|
|
162
|
+
*/
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
var json = JSON.parse(content);
|
|
166
|
+
json.version = this.getNextVersion(json.version, options);
|
|
167
|
+
commitFiles.push({
|
|
168
|
+
filePath: packageJsonFilePath,
|
|
169
|
+
content: JSON.stringify(json, null, 2)
|
|
191
170
|
});
|
|
192
|
-
}
|
|
171
|
+
}
|
|
172
|
+
return commitFiles;
|
|
173
|
+
};
|
|
174
|
+
BumpPackagesTask.prototype.getNextVersion = function (version, options) {
|
|
175
|
+
// If we're in a prerelease, we only want to increment the preId part of the version number
|
|
176
|
+
if (this.isInPreRelease && options.preId) {
|
|
177
|
+
var currentPreId = Number(version[version.length - 1]);
|
|
178
|
+
return "".concat(version.substring(0, version.length - 1)).concat(currentPreId + 1);
|
|
179
|
+
}
|
|
180
|
+
if (options.preId === 'dev')
|
|
181
|
+
return "".concat(utils_1.Versions.getNextVersion(version, 'patch'), "-dev.0");
|
|
182
|
+
if (options.preId === 'rc') {
|
|
183
|
+
if (this.isReleaseBranch)
|
|
184
|
+
return "".concat(utils_1.Versions.getNextVersion(version, 'minor'), "-rc.0");
|
|
185
|
+
if (this.isHotfixBranch)
|
|
186
|
+
return "".concat(utils_1.Versions.getNextVersion(version, 'patch'), "-rc.0");
|
|
187
|
+
}
|
|
188
|
+
if (this.isReleaseBranch)
|
|
189
|
+
utils_1.Versions.getNextVersion(version, 'minor');
|
|
190
|
+
if (this.isHotfixBranch)
|
|
191
|
+
utils_1.Versions.getNextVersion(version, 'patch');
|
|
192
|
+
return version;
|
|
193
193
|
};
|
|
194
|
-
BumpPackagesTask.prototype.
|
|
194
|
+
BumpPackagesTask.prototype.getIsInPrerelease = function (branchName) {
|
|
195
195
|
return __awaiter(this, void 0, void 0, function () {
|
|
196
196
|
var _i, MONOREPO_PACKAGE_JSON_FILES_1, file, text, json;
|
|
197
197
|
return __generator(this, function (_a) {
|
|
@@ -128,7 +128,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
128
128
|
/**
|
|
129
129
|
* Run npm i to update our package log file
|
|
130
130
|
*/
|
|
131
|
-
utils_1.Logger.logInfo("[".concat(project.title, "]: Running npm i
|
|
131
|
+
utils_1.Logger.logInfo("[".concat(project.title, "]: Running npm i"));
|
|
132
132
|
this.npmInstall(project, folderName);
|
|
133
133
|
utils_1.Logger.logInfo('\n');
|
|
134
134
|
/**
|
|
@@ -221,7 +221,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
221
221
|
/**
|
|
222
222
|
* Run npm i to update our package log file
|
|
223
223
|
*/
|
|
224
|
-
utils_1.Logger.logInfo("[".concat(project.title, "]: Running npm i
|
|
224
|
+
utils_1.Logger.logInfo("[".concat(project.title, "]: Running npm i"));
|
|
225
225
|
this.npmInstall(project, options.milestone);
|
|
226
226
|
utils_1.Logger.logInfo('\n');
|
|
227
227
|
/**
|
|
@@ -280,7 +280,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
280
280
|
};
|
|
281
281
|
InstallPackagesTask.prototype.npmInstall = function (project, folderName) {
|
|
282
282
|
var outputPath = this.getOutputPath(project, folderName);
|
|
283
|
-
child_process_1.default.execSync('npm i
|
|
283
|
+
child_process_1.default.execSync('npm i', {
|
|
284
284
|
cwd: outputPath,
|
|
285
285
|
// Uncomment if we want to silence
|
|
286
286
|
// stdio: 'pipe'
|
package/lib/src/tasks/index.js
CHANGED
|
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./BumpPackagesTask"), exports);
|
|
18
18
|
__exportStar(require("./BumpVersionTxtTask"), exports);
|
|
19
|
-
__exportStar(require("./CommitPackageVersionsTask"), exports);
|
|
20
19
|
__exportStar(require("./CreateBranchTask"), exports);
|
|
21
20
|
__exportStar(require("./CreateMergeRequestTask"), exports);
|
|
22
21
|
__exportStar(require("./CreateReleaseNotesTask"), exports);
|
package/lib/src/types.js
CHANGED
|
@@ -31,7 +31,6 @@ exports.TASKS = {
|
|
|
31
31
|
CreateNotesAuditTask: Symbol.for('CreateNotesAuditTask'),
|
|
32
32
|
InstallPackagesTask: Symbol.for('InstallPackagesTask'),
|
|
33
33
|
BumpPackagesTask: Symbol.for('BumpPackagesTask'),
|
|
34
|
-
CommitPackageVersionsTask: Symbol.for('CommitPackageVersionsTask'),
|
|
35
34
|
ValidateMergeRequestTask: Symbol.for('ValidateMergeRequestTask'),
|
|
36
35
|
StartMonorepoBuildTask: Symbol.for('StartMonorepoBuildTask'),
|
|
37
36
|
StartProjectBuildsTask: Symbol.for('StartProjectBuildsTask'),
|
package/package.json
CHANGED
|
@@ -1,116 +0,0 @@
|
|
|
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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
-
function step(op) {
|
|
28
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
-
while (_) try {
|
|
30
|
-
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;
|
|
31
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
-
switch (op[0]) {
|
|
33
|
-
case 0: case 1: t = op; break;
|
|
34
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
-
default:
|
|
38
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
-
if (t[2]) _.ops.pop();
|
|
43
|
-
_.trys.pop(); continue;
|
|
44
|
-
}
|
|
45
|
-
op = body.call(thisArg, _);
|
|
46
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.CommitPackageVersionsTask = void 0;
|
|
52
|
-
require("reflect-metadata");
|
|
53
|
-
var fs_1 = require("fs");
|
|
54
|
-
var inversify_1 = require("inversify");
|
|
55
|
-
var types_1 = require("../types");
|
|
56
|
-
var services_1 = require("../services");
|
|
57
|
-
var MonorepoPackageJsonFiles_1 = require("../constants/MonorepoPackageJsonFiles");
|
|
58
|
-
var utils_1 = require("../utils");
|
|
59
|
-
var CommitPackageVersionsTask = /** @class */ (function () {
|
|
60
|
-
function CommitPackageVersionsTask(service) {
|
|
61
|
-
this.service = service;
|
|
62
|
-
}
|
|
63
|
-
CommitPackageVersionsTask.prototype.run = function (options) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var branch, commitFiles;
|
|
66
|
-
return __generator(this, function (_a) {
|
|
67
|
-
switch (_a.label) {
|
|
68
|
-
case 0:
|
|
69
|
-
utils_1.Logger.logTask('Committing clickview npm package versions');
|
|
70
|
-
return [4 /*yield*/, this.service.getBranch(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.branchName)];
|
|
71
|
-
case 1:
|
|
72
|
-
branch = _a.sent();
|
|
73
|
-
if (!branch) {
|
|
74
|
-
utils_1.Logger.logError("Branch with name ".concat(options.branchName, " was not be found."));
|
|
75
|
-
return [2 /*return*/, false];
|
|
76
|
-
}
|
|
77
|
-
commitFiles = this.getCommitFiles();
|
|
78
|
-
return [4 /*yield*/, this.service.commit(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.branchName, 'Bump package versions', commitFiles)];
|
|
79
|
-
case 2:
|
|
80
|
-
_a.sent();
|
|
81
|
-
utils_1.Logger.logSuccess('Successfully committed package versions.');
|
|
82
|
-
return [2 /*return*/, true];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
CommitPackageVersionsTask.prototype.getCommitFiles = function () {
|
|
88
|
-
var commitFiles = [];
|
|
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
|
-
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
|
-
}
|
|
102
|
-
commitFiles.push({
|
|
103
|
-
filePath: filePath,
|
|
104
|
-
content: content
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
return commitFiles;
|
|
108
|
-
};
|
|
109
|
-
CommitPackageVersionsTask = __decorate([
|
|
110
|
-
(0, inversify_1.injectable)(),
|
|
111
|
-
__param(0, (0, inversify_1.inject)(types_1.SERVICES.GitLabService)),
|
|
112
|
-
__metadata("design:paramtypes", [services_1.GitLabService])
|
|
113
|
-
], CommitPackageVersionsTask);
|
|
114
|
-
return CommitPackageVersionsTask;
|
|
115
|
-
}());
|
|
116
|
-
exports.CommitPackageVersionsTask = CommitPackageVersionsTask;
|