@clickview/ship-it 0.0.50 → 0.0.52

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/config.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "gitLab": {
3
- "accessToken": "glpat-zyyMQu7nQXxPb672CawK",
4
- "url": "https://gitlab.cvinternal.net"
3
+ "accessToken": "glpat-_q31SQT2tx6dLZyB031Yo286MQp1OjF3CA.01.0y1tkjjne",
4
+ "url": "https://gitlab.cvinternal.net",
5
+ "pipelineToken": "glptt-bf0125ec1900009dbc88b7b0ec17be3c3c49a51c"
5
6
  },
6
7
  "teamCity": {
7
8
  "url": "http://build.cvinternal.net/",
package/lib/config.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "gitLab": {
3
- "accessToken": "glpat-zyyMQu7nQXxPb672CawK",
4
- "url": "https://gitlab.cvinternal.net"
3
+ "accessToken": "glpat-_q31SQT2tx6dLZyB031Yo286MQp1OjF3CA.01.0y1tkjjne",
4
+ "url": "https://gitlab.cvinternal.net",
5
+ "pipelineToken": "glptt-bf0125ec1900009dbc88b7b0ec17be3c3c49a51c"
5
6
  },
6
7
  "teamCity": {
7
8
  "url": "http://build.cvinternal.net/",
@@ -47,9 +47,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
48
  }
49
49
  };
50
+ var __importDefault = (this && this.__importDefault) || function (mod) {
51
+ return (mod && mod.__esModule) ? mod : { "default": mod };
52
+ };
50
53
  Object.defineProperty(exports, "__esModule", { value: true });
51
54
  exports.GitLabApiClient = void 0;
52
55
  require("reflect-metadata");
56
+ var https_1 = __importDefault(require("https"));
53
57
  var inversify_1 = require("inversify");
54
58
  var node_1 = require("@gitbeaker/node");
55
59
  var types_1 = require("../../types");
@@ -588,6 +592,31 @@ var GitLabApiClient = /** @class */ (function () {
588
592
  });
589
593
  });
590
594
  };
595
+ GitLabApiClient.prototype.triggerPipeline = function (projectId, ref, variables) {
596
+ var params = new URLSearchParams({ token: this.config.pipelineToken, ref: ref });
597
+ for (var _i = 0, _a = Object.entries(variables); _i < _a.length; _i++) {
598
+ var _b = _a[_i], key = _b[0], value = _b[1];
599
+ params.append("inputs[".concat(key, "]"), value);
600
+ }
601
+ var body = params.toString();
602
+ var path = "/api/v4/projects/".concat(projectId, "/trigger/pipeline");
603
+ var hostname = new URL(this.config.url).hostname;
604
+ return new Promise(function (resolve, reject) {
605
+ var req = https_1.default.request({ hostname: hostname, path: path, method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': Buffer.byteLength(body) } }, function (res) {
606
+ var data = '';
607
+ res.on('data', function (chunk) { return data += chunk; });
608
+ res.on('end', function () {
609
+ if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300)
610
+ resolve(JSON.parse(data));
611
+ else
612
+ reject(new Error("GitLab pipeline trigger failed (".concat(res.statusCode, "): ").concat(data)));
613
+ });
614
+ });
615
+ req.on('error', reject);
616
+ req.write(body);
617
+ req.end();
618
+ });
619
+ };
591
620
  GitLabApiClient = __decorate([
592
621
  (0, inversify_1.injectable)(),
593
622
  __param(0, (0, inversify_1.inject)(types_1.MISC.GitLabConfig)),
@@ -595,6 +595,9 @@ var GitLabService = /** @class */ (function () {
595
595
  GitLabService.prototype.getProtectedBranches = function (projectId) {
596
596
  return this.apiClient.getProtectedBranches(projectId);
597
597
  };
598
+ GitLabService.prototype.triggerPipeline = function (projectId, ref, variables) {
599
+ return this.apiClient.triggerPipeline(projectId, ref, variables);
600
+ };
598
601
  GitLabService = __decorate([
599
602
  (0, inversify_1.injectable)(),
600
603
  __param(0, (0, inversify_1.inject)(types_1.API_CLIENTS.GitLabApiClient)),
@@ -54,20 +54,17 @@ var inversify_1 = require("inversify");
54
54
  var utils_1 = require("../utils");
55
55
  var services_1 = require("../services");
56
56
  var types_1 = require("../types");
57
- var TeamCityBuildIDs_1 = require("../constants/TeamCityBuildIDs");
58
- var MonorepoProjectNames_1 = require("../constants/MonorepoProjectNames");
59
57
  var StartMonorepoBuildTask = /** @class */ (function () {
60
- function StartMonorepoBuildTask(teamCityService, gitLabService) {
61
- this.teamCityService = teamCityService;
58
+ function StartMonorepoBuildTask(gitLabService) {
62
59
  this.gitLabService = gitLabService;
63
60
  }
64
61
  StartMonorepoBuildTask.prototype.run = function (options) {
65
62
  return __awaiter(this, void 0, void 0, function () {
66
- var branchName, projects, packageNames, bulkBuildID, _i, projects_1, project, build;
63
+ var branchName, stage, pipeline, err_1;
67
64
  return __generator(this, function (_a) {
68
65
  switch (_a.label) {
69
66
  case 0:
70
- utils_1.Logger.logTask('Starting Monorepo build in TeamCity');
67
+ utils_1.Logger.logTask('Starting Monorepo pipeline in GitLab');
71
68
  return [4 /*yield*/, this.gitLabService.getReleaseBranchNameMilestone(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.milestone)];
72
69
  case 1:
73
70
  branchName = _a.sent();
@@ -75,34 +72,31 @@ var StartMonorepoBuildTask = /** @class */ (function () {
75
72
  utils_1.Logger.logError("Monorepo release branch with milestone \"".concat(options.milestone, "\" was not found."));
76
73
  return [2 /*return*/, false];
77
74
  }
78
- return [4 /*yield*/, this.gitLabService.getReleaseProjects(options.milestone, options.projectIds, options.omittedProjectIds, options.sourceBranch)];
75
+ stage = branchName.startsWith('hotfix/') ? 'prd' : 'rc';
76
+ _a.label = 2;
79
77
  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))];
78
+ _a.trys.push([2, 4, , 5]);
79
+ return [4 /*yield*/, this.gitLabService.triggerPipeline(utils_1.ProjectIds.MONOREPO_PROJECT_ID, branchName, {
80
+ project: 'all',
81
+ stage: stage
82
+ })];
92
83
  case 3:
93
- build = _a.sent();
94
- utils_1.Logger.logSuccess("Successfully started build in monorepo. View progress here: ".concat(build.webUrl));
84
+ pipeline = _a.sent();
85
+ utils_1.Logger.logSuccess("Successfully triggered monorepo pipeline. View progress here: ".concat(pipeline.web_url));
95
86
  return [2 /*return*/, true];
87
+ case 4:
88
+ err_1 = _a.sent();
89
+ utils_1.Logger.logError("Failed to trigger monorepo pipeline: ".concat(err_1.message));
90
+ return [2 /*return*/, false];
91
+ case 5: return [2 /*return*/];
96
92
  }
97
93
  });
98
94
  });
99
95
  };
100
96
  StartMonorepoBuildTask = __decorate([
101
97
  (0, inversify_1.injectable)(),
102
- __param(0, (0, inversify_1.inject)(types_1.SERVICES.TeamCityService)),
103
- __param(1, (0, inversify_1.inject)(types_1.SERVICES.GitLabService)),
104
- __metadata("design:paramtypes", [services_1.TeamCityService,
105
- services_1.GitLabService])
98
+ __param(0, (0, inversify_1.inject)(types_1.SERVICES.GitLabService)),
99
+ __metadata("design:paramtypes", [services_1.GitLabService])
106
100
  ], StartMonorepoBuildTask);
107
101
  return StartMonorepoBuildTask;
108
102
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickview/ship-it",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "description": "Release Manager",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {