@clickview/ship-it 0.0.20-dev.1 → 0.0.20
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/team-city/TeamCityApiClient.js +15 -0
- package/lib/src/constants/MonorepoProjectNames.js +15 -0
- package/lib/src/constants/TeamCityBuildIDs.js +1 -1
- package/lib/src/services/TeamCityService.js +3 -0
- package/lib/src/tasks/InstallPackagesTask.js +18 -12
- package/lib/src/tasks/StartMonorepoBuildTask.js +16 -2
- package/package.json +1 -1
|
@@ -75,6 +75,21 @@ var TeamCityApiClient = /** @class */ (function () {
|
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
|
+
TeamCityApiClient.prototype.startCustomBuild = function (buildId, branchName, pList) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var buildXml, build;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
buildXml = "\n <build branchName=\"".concat(branchName, "\">\n <buildType id=\"").concat(buildId, "\" />\n <properties>\n <property name=\"ProjectList\" value=\"").concat(pList, "\"/>\n <property name=\"ReleaseEnvironment\" value=\"rc\"/>\n </properties>\n </build>\n ");
|
|
85
|
+
return [4 /*yield*/, this.client.builds.startBuild(buildXml)];
|
|
86
|
+
case 1:
|
|
87
|
+
build = _a.sent();
|
|
88
|
+
return [2 /*return*/, build];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
78
93
|
TeamCityApiClient = __decorate([
|
|
79
94
|
(0, inversify_1.injectable)(),
|
|
80
95
|
__param(0, (0, inversify_1.inject)(types_1.MISC.TeamCityConfig)),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MonorepoProjectNames = void 0;
|
|
5
|
+
var constants_1 = require("../constants");
|
|
6
|
+
exports.MonorepoProjectNames = (_a = {},
|
|
7
|
+
_a[constants_1.PROJECT_NAMES.frontend.online] = 'online',
|
|
8
|
+
_a[constants_1.PROJECT_NAMES.frontend.curator] = 'curator',
|
|
9
|
+
_a[constants_1.PROJECT_NAMES.frontend.cloud] = 'library-editor',
|
|
10
|
+
_a[constants_1.PROJECT_NAMES.frontend.reports] = 'reports',
|
|
11
|
+
_a[constants_1.PROJECT_NAMES.frontend.lite] = 'lite',
|
|
12
|
+
_a[constants_1.PROJECT_NAMES.backend.auth] = 'auth',
|
|
13
|
+
_a[constants_1.PROJECT_NAMES.frontend.exchange] = 'exchange',
|
|
14
|
+
_a[constants_1.PROJECT_NAMES.backend.player] = 'player',
|
|
15
|
+
_a);
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.TeamCityBuildIds = void 0;
|
|
5
5
|
var constants_1 = require("../constants");
|
|
6
6
|
exports.TeamCityBuildIds = (_a = {},
|
|
7
|
-
_a[constants_1.PROJECT_NAMES.frontend.monorepo] = '
|
|
7
|
+
_a[constants_1.PROJECT_NAMES.frontend.monorepo] = 'Monorepo_BulkBuildPublish',
|
|
8
8
|
_a[constants_1.PROJECT_NAMES.frontend.online] = 'online_web_build_and_package',
|
|
9
9
|
_a[constants_1.PROJECT_NAMES.frontend.curator] = 'curator_web_BuildAndPackageDocker',
|
|
10
10
|
_a[constants_1.PROJECT_NAMES.frontend.cloud] = 'ClickViewCloud_BuildAndPackageDocker',
|
|
@@ -24,6 +24,9 @@ var TeamCityService = /** @class */ (function () {
|
|
|
24
24
|
TeamCityService.prototype.startBuild = function (buildId, branchName) {
|
|
25
25
|
return this.apiClient.startBuild(buildId, branchName);
|
|
26
26
|
};
|
|
27
|
+
TeamCityService.prototype.startCustomBuild = function (buildId, branchName, pList) {
|
|
28
|
+
return this.apiClient.startCustomBuild(buildId, branchName, pList);
|
|
29
|
+
};
|
|
27
30
|
TeamCityService = __decorate([
|
|
28
31
|
(0, inversify_1.injectable)(),
|
|
29
32
|
__param(0, (0, inversify_1.inject)(types_1.API_CLIENTS.TeamCityApiClient)),
|
|
@@ -83,7 +83,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
83
83
|
}
|
|
84
84
|
InstallPackagesTask.prototype.run = function (_options) {
|
|
85
85
|
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
var targetBranch, projectId, project, versions_1, hasUpdates, error_1, milestone, options, projects, monorepo, consumingProjects, _a, monorepoBranch, monorepoBranchName, versions, _i, consumingProjects_1, project, _b, branch, branchName, hasUpdates, _c;
|
|
86
|
+
var targetBranch, projectId, project, versions_1, folderName, hasUpdates, error_1, milestone, options, projects, monorepo, consumingProjects, _a, monorepoBranch, monorepoBranchName, versions, _i, consumingProjects_1, project, _b, branch, branchName, hasUpdates, _c;
|
|
87
87
|
return __generator(this, function (_d) {
|
|
88
88
|
switch (_d.label) {
|
|
89
89
|
case 0:
|
|
@@ -94,6 +94,10 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
94
94
|
}
|
|
95
95
|
if (!(_options.targetBranchName && _options.monorepoBranchName && _options.projectIds)) return [3 /*break*/, 8];
|
|
96
96
|
targetBranch = _options.targetBranchName;
|
|
97
|
+
if (_options.projectIds.length > 1) {
|
|
98
|
+
utils_1.Logger.logError("Too many projects given! Maximum 1 project allowed but got ".concat(_options.projectIds.length));
|
|
99
|
+
return [2 /*return*/, false];
|
|
100
|
+
}
|
|
97
101
|
projectId = _options.projectIds[0];
|
|
98
102
|
return [4 /*yield*/, this.service.getProject(projectId)];
|
|
99
103
|
case 1:
|
|
@@ -101,6 +105,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
101
105
|
return [4 /*yield*/, this.getPackageVersions(_options.monorepoBranchName)];
|
|
102
106
|
case 2:
|
|
103
107
|
versions_1 = _d.sent();
|
|
108
|
+
folderName = 'hotfix';
|
|
104
109
|
utils_1.Logger.logMessage("Versions identified for ".concat(_options.monorepoBranchName));
|
|
105
110
|
Object.keys(versions_1).forEach(function (key) {
|
|
106
111
|
utils_1.Logger.logMessage("- [".concat(key, "]: ").concat(versions_1[key]));
|
|
@@ -108,7 +113,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
108
113
|
_d.label = 3;
|
|
109
114
|
case 3:
|
|
110
115
|
_d.trys.push([3, 6, , 7]);
|
|
111
|
-
return [4 /*yield*/, this.updateAndSavePackageFiles(project,
|
|
116
|
+
return [4 /*yield*/, this.updateAndSavePackageFiles(project, folderName, targetBranch, versions_1)];
|
|
112
117
|
case 4:
|
|
113
118
|
hasUpdates = _d.sent();
|
|
114
119
|
/**
|
|
@@ -116,17 +121,18 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
116
121
|
*/
|
|
117
122
|
if (!hasUpdates) {
|
|
118
123
|
utils_1.Logger.logWarning("[".concat(project.title, "]: [").concat(targetBranch, "] does not require any updates"));
|
|
124
|
+
return [2 /*return*/, true];
|
|
119
125
|
}
|
|
120
126
|
/**
|
|
121
127
|
* Run npm i to update our package log file
|
|
122
128
|
*/
|
|
123
129
|
utils_1.Logger.logInfo("[".concat(project.title, "]: Running npm i --package-lock-only"));
|
|
124
|
-
this.npmInstall(project,
|
|
130
|
+
this.npmInstall(project, folderName);
|
|
125
131
|
utils_1.Logger.logInfo('\n');
|
|
126
132
|
/**
|
|
127
133
|
* Commit our updated package.json and package-lock.json
|
|
128
134
|
*/
|
|
129
|
-
return [4 /*yield*/, this.commitUpdatedFiles(project,
|
|
135
|
+
return [4 /*yield*/, this.commitUpdatedFiles(project, folderName, targetBranch)];
|
|
130
136
|
case 5:
|
|
131
137
|
/**
|
|
132
138
|
* Commit our updated package.json and package-lock.json
|
|
@@ -239,7 +245,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
239
245
|
});
|
|
240
246
|
});
|
|
241
247
|
};
|
|
242
|
-
InstallPackagesTask.prototype.commitUpdatedFiles = function (project,
|
|
248
|
+
InstallPackagesTask.prototype.commitUpdatedFiles = function (project, folderName, branchName) {
|
|
243
249
|
return __awaiter(this, void 0, void 0, function () {
|
|
244
250
|
var rootDir, outputPath, commitFiles, _a;
|
|
245
251
|
var _b, _c;
|
|
@@ -247,7 +253,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
247
253
|
switch (_d.label) {
|
|
248
254
|
case 0:
|
|
249
255
|
rootDir = ROOT_DIRECTORIES[project.id];
|
|
250
|
-
outputPath = this.getOutputPath(project,
|
|
256
|
+
outputPath = this.getOutputPath(project, folderName);
|
|
251
257
|
_b = {
|
|
252
258
|
filePath: "".concat(rootDir, "/package.json")
|
|
253
259
|
};
|
|
@@ -270,15 +276,15 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
270
276
|
});
|
|
271
277
|
});
|
|
272
278
|
};
|
|
273
|
-
InstallPackagesTask.prototype.npmInstall = function (project,
|
|
274
|
-
var outputPath = this.getOutputPath(project,
|
|
279
|
+
InstallPackagesTask.prototype.npmInstall = function (project, folderName) {
|
|
280
|
+
var outputPath = this.getOutputPath(project, folderName);
|
|
275
281
|
child_process_1.default.execSync('npm i --package-lock-only', {
|
|
276
282
|
cwd: outputPath,
|
|
277
283
|
// Uncomment if we want to silence
|
|
278
284
|
// stdio: 'pipe'
|
|
279
285
|
});
|
|
280
286
|
};
|
|
281
|
-
InstallPackagesTask.prototype.updateAndSavePackageFiles = function (project,
|
|
287
|
+
InstallPackagesTask.prototype.updateAndSavePackageFiles = function (project, folderName, branchName, versions) {
|
|
282
288
|
return __awaiter(this, void 0, void 0, function () {
|
|
283
289
|
var rootDir, packageJson, packageLock, packageJsonObj, original, outputPath;
|
|
284
290
|
return __generator(this, function (_a) {
|
|
@@ -304,7 +310,7 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
304
310
|
packageJson = this.replaceVersions(packageJson, versions, packageJsonObj.dependencies);
|
|
305
311
|
if (packageJsonObj.devDependencies)
|
|
306
312
|
packageJson = this.replaceVersions(packageJson, versions, packageJsonObj.devDependencies);
|
|
307
|
-
outputPath = this.getOutputPath(project,
|
|
313
|
+
outputPath = this.getOutputPath(project, folderName);
|
|
308
314
|
return [4 /*yield*/, fs_extra_1.default.outputFile("".concat(outputPath, "/package.json"), packageJson, { encoding: 'utf8' })];
|
|
309
315
|
case 3:
|
|
310
316
|
_a.sent();
|
|
@@ -386,8 +392,8 @@ var InstallPackagesTask = /** @class */ (function () {
|
|
|
386
392
|
});
|
|
387
393
|
});
|
|
388
394
|
};
|
|
389
|
-
InstallPackagesTask.prototype.getOutputPath = function (project,
|
|
390
|
-
return "./temp/".concat(
|
|
395
|
+
InstallPackagesTask.prototype.getOutputPath = function (project, folderName) {
|
|
396
|
+
return "./temp/".concat(folderName, "/").concat(project.title);
|
|
391
397
|
};
|
|
392
398
|
InstallPackagesTask = __decorate([
|
|
393
399
|
(0, inversify_1.injectable)(),
|
|
@@ -55,6 +55,7 @@ var utils_1 = require("../utils");
|
|
|
55
55
|
var services_1 = require("../services");
|
|
56
56
|
var types_1 = require("../types");
|
|
57
57
|
var TeamCityBuildIDs_1 = require("../constants/TeamCityBuildIDs");
|
|
58
|
+
var MonorepoProjectNames_1 = require("../constants/MonorepoProjectNames");
|
|
58
59
|
var StartMonorepoBuildTask = /** @class */ (function () {
|
|
59
60
|
function StartMonorepoBuildTask(teamCityService, gitLabService) {
|
|
60
61
|
this.teamCityService = teamCityService;
|
|
@@ -62,7 +63,7 @@ var StartMonorepoBuildTask = /** @class */ (function () {
|
|
|
62
63
|
}
|
|
63
64
|
StartMonorepoBuildTask.prototype.run = function (options) {
|
|
64
65
|
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var branchName, build;
|
|
66
|
+
var branchName, projects, packageNames, bulkBuildID, _i, projects_1, project, build;
|
|
66
67
|
return __generator(this, function (_a) {
|
|
67
68
|
switch (_a.label) {
|
|
68
69
|
case 0:
|
|
@@ -74,8 +75,21 @@ var StartMonorepoBuildTask = /** @class */ (function () {
|
|
|
74
75
|
utils_1.Logger.logError("Monorepo release branch with milestone \"".concat(options.milestone, "\" was not found."));
|
|
75
76
|
return [2 /*return*/, false];
|
|
76
77
|
}
|
|
77
|
-
return [4 /*yield*/, this.
|
|
78
|
+
return [4 /*yield*/, this.gitLabService.getProjects(options)];
|
|
78
79
|
case 2:
|
|
80
|
+
projects = _a.sent();
|
|
81
|
+
packageNames = [];
|
|
82
|
+
bulkBuildID = TeamCityBuildIDs_1.TeamCityBuildIds[utils_1.ProjectIds.MONOREPO_PROJECT_ID];
|
|
83
|
+
for (_i = 0, projects_1 = projects; _i < projects_1.length; _i++) {
|
|
84
|
+
project = projects_1[_i];
|
|
85
|
+
// Find all relevant monorepo project package names in release
|
|
86
|
+
if (MonorepoProjectNames_1.MonorepoProjectNames[project.id]) {
|
|
87
|
+
packageNames.push(MonorepoProjectNames_1.MonorepoProjectNames[project.id]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
utils_1.Logger.logMessage("List of monorepo projects found in release: ".concat(String(packageNames)));
|
|
91
|
+
return [4 /*yield*/, this.teamCityService.startCustomBuild(bulkBuildID, branchName, String(packageNames))];
|
|
92
|
+
case 3:
|
|
79
93
|
build = _a.sent();
|
|
80
94
|
utils_1.Logger.logSuccess("Successfully started build in monorepo. View progress here: ".concat(build.webUrl));
|
|
81
95
|
return [2 /*return*/, true];
|