@clickview/ship-it 0.0.38 → 0.0.40
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/git-lab/GitLabApiClient.js +118 -0
- package/lib/src/api-clients/git-lab/GitLabMapper.js +40 -0
- package/lib/src/commands/ConfigureProjectsCommand.js +84 -0
- package/lib/src/commands/ReleaseCommand.js +13 -6
- package/lib/src/commands/StatusCommand.js +7 -2
- package/lib/src/commands/index.js +1 -0
- package/lib/src/constants/CommandTypeMapping.js +2 -1
- package/lib/src/constants/ProjectNames.js +1 -0
- package/lib/src/constants/TeamCityBuildIDs.js +1 -0
- package/lib/src/interfaces/command-options/ConfigureProjectsOptions.js +2 -0
- package/lib/src/interfaces/command-options/index.js +1 -0
- package/lib/src/interfaces/models/ApprovalRule.js +2 -0
- package/lib/src/interfaces/models/ApprovalRuleConfiguration.js +2 -0
- package/lib/src/interfaces/models/CreateApprovalRuleRequest.js +2 -0
- package/lib/src/interfaces/models/Group.js +2 -0
- package/lib/src/interfaces/models/ProtectedBranch.js +2 -0
- package/lib/src/interfaces/models/index.js +6 -0
- package/lib/src/inversify.config.js +5 -0
- package/lib/src/services/GitLabService.js +40 -6
- package/lib/src/startup/SetupCommands.js +12 -0
- package/lib/src/tasks/BumpPackagesTask.js +44 -91
- package/lib/src/tasks/CreateBranchTask.js +1 -1
- package/lib/src/tasks/InstallPackagesTask.js +8 -0
- package/lib/src/tasks/TagMasterTask.js +14 -11
- package/lib/src/tasks/configure-projects/AddApprovalRulesTask.js +182 -0
- package/lib/src/tasks/configure-projects/CreateToolingBranchTask.js +136 -0
- package/lib/src/tasks/configure-projects/EnsureApprovalRulesTask.js +106 -0
- package/lib/src/tasks/configure-projects/index.js +18 -0
- package/lib/src/tasks/configure-projects/primitives/BaseConfigureProjectsTask.js +98 -0
- package/lib/src/tasks/index.js +1 -0
- package/lib/src/types.js +6 -2
- package/package.json +1 -1
|
@@ -104,6 +104,32 @@ var GitLabApiClient = /** @class */ (function () {
|
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
};
|
|
107
|
+
GitLabApiClient.prototype.getAllProjects = function () {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
+
var projects;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0: return [4 /*yield*/, this.client.Projects.all()];
|
|
113
|
+
case 1:
|
|
114
|
+
projects = _a.sent();
|
|
115
|
+
return [2 /*return*/, projects.map(GitLabMapper_1.GitLabMapper.project)];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
GitLabApiClient.prototype.getAllGroupProjects = function (groupId) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var projects;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0: return [4 /*yield*/, this.client.Groups.projects(groupId)];
|
|
126
|
+
case 1:
|
|
127
|
+
projects = _a.sent();
|
|
128
|
+
return [2 /*return*/, projects.map(GitLabMapper_1.GitLabMapper.project)];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
107
133
|
GitLabApiClient.prototype.getLatestTags = function (projectId) {
|
|
108
134
|
return __awaiter(this, void 0, void 0, function () {
|
|
109
135
|
var tags;
|
|
@@ -429,6 +455,98 @@ var GitLabApiClient = /** @class */ (function () {
|
|
|
429
455
|
});
|
|
430
456
|
});
|
|
431
457
|
};
|
|
458
|
+
GitLabApiClient.prototype.getApprovalRuleConfiguration = function (projectId) {
|
|
459
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
460
|
+
var configuration;
|
|
461
|
+
return __generator(this, function (_a) {
|
|
462
|
+
switch (_a.label) {
|
|
463
|
+
case 0: return [4 /*yield*/, this.client.MergeRequestApprovals.configuration(projectId)];
|
|
464
|
+
case 1:
|
|
465
|
+
configuration = _a.sent();
|
|
466
|
+
return [2 /*return*/, GitLabMapper_1.GitLabMapper.approvalRuleConfiguration(configuration)];
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
GitLabApiClient.prototype.updateApprovalRuleConfiguration = function (projectId, configuration) {
|
|
472
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
473
|
+
var mapping, response;
|
|
474
|
+
return __generator(this, function (_a) {
|
|
475
|
+
switch (_a.label) {
|
|
476
|
+
case 0:
|
|
477
|
+
mapping = GitLabMapper_1.GitLabMapper.reverseApprovalRuleConfiguration(configuration);
|
|
478
|
+
return [4 /*yield*/, this.client.MergeRequestApprovals.editConfiguration(projectId, mapping)];
|
|
479
|
+
case 1:
|
|
480
|
+
response = _a.sent();
|
|
481
|
+
return [2 /*return*/, GitLabMapper_1.GitLabMapper.approvalRuleConfiguration(response)];
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
};
|
|
486
|
+
GitLabApiClient.prototype.getApprovalRules = function (projectId) {
|
|
487
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
488
|
+
var approvalRules;
|
|
489
|
+
return __generator(this, function (_a) {
|
|
490
|
+
switch (_a.label) {
|
|
491
|
+
case 0: return [4 /*yield*/, this.client.MergeRequestApprovals.approvalRules(projectId)];
|
|
492
|
+
case 1:
|
|
493
|
+
approvalRules = _a.sent();
|
|
494
|
+
return [2 /*return*/, approvalRules.map(GitLabMapper_1.GitLabMapper.approvalRule)];
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
};
|
|
499
|
+
GitLabApiClient.prototype.createApprovalRule = function (projectId, rule) {
|
|
500
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
501
|
+
var approvalRule;
|
|
502
|
+
return __generator(this, function (_a) {
|
|
503
|
+
switch (_a.label) {
|
|
504
|
+
case 0: return [4 /*yield*/, this.client.MergeRequestApprovals.addApprovalRule(projectId, rule.name, rule.approvalsRequired, {
|
|
505
|
+
applies_to_all_protected_branches: rule.appliesToAllProtectedBranches,
|
|
506
|
+
group_ids: rule.groupIds,
|
|
507
|
+
protected_branch_ids: rule.protectedBranchIds,
|
|
508
|
+
user_ids: rule.userIds,
|
|
509
|
+
usernames: rule.usernames
|
|
510
|
+
})];
|
|
511
|
+
case 1:
|
|
512
|
+
approvalRule = _a.sent();
|
|
513
|
+
return [2 /*return*/, GitLabMapper_1.GitLabMapper.approvalRule(approvalRule)];
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
};
|
|
518
|
+
GitLabApiClient.prototype.updateApprovalRule = function (projectId, approvalRuleId, rule) {
|
|
519
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
520
|
+
var approvalRule;
|
|
521
|
+
return __generator(this, function (_a) {
|
|
522
|
+
switch (_a.label) {
|
|
523
|
+
case 0: return [4 /*yield*/, this.client.MergeRequestApprovals.editApprovalRule(projectId, approvalRuleId, rule.name, rule.approvalsRequired, {
|
|
524
|
+
applies_to_all_protected_branches: rule.appliesToAllProtectedBranches,
|
|
525
|
+
group_ids: rule.groupIds,
|
|
526
|
+
protected_branch_ids: rule.protectedBranchIds,
|
|
527
|
+
user_ids: rule.userIds,
|
|
528
|
+
usernames: rule.usernames
|
|
529
|
+
})];
|
|
530
|
+
case 1:
|
|
531
|
+
approvalRule = _a.sent();
|
|
532
|
+
return [2 /*return*/, GitLabMapper_1.GitLabMapper.approvalRule(approvalRule)];
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
};
|
|
537
|
+
GitLabApiClient.prototype.getProtectedBranches = function (projectId) {
|
|
538
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
539
|
+
var branches;
|
|
540
|
+
return __generator(this, function (_a) {
|
|
541
|
+
switch (_a.label) {
|
|
542
|
+
case 0: return [4 /*yield*/, this.client.ProtectedBranches.all(projectId)];
|
|
543
|
+
case 1:
|
|
544
|
+
branches = _a.sent();
|
|
545
|
+
return [2 /*return*/, branches.map(GitLabMapper_1.GitLabMapper.protectedBranch)];
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
};
|
|
432
550
|
GitLabApiClient = __decorate([
|
|
433
551
|
(0, inversify_1.injectable)(),
|
|
434
552
|
__param(0, (0, inversify_1.inject)(types_1.MISC.GitLabConfig)),
|
|
@@ -48,6 +48,12 @@ exports.GitLabMapper = {
|
|
|
48
48
|
name: b.name
|
|
49
49
|
};
|
|
50
50
|
},
|
|
51
|
+
protectedBranch: function (b) {
|
|
52
|
+
return {
|
|
53
|
+
id: b.id,
|
|
54
|
+
name: b.name
|
|
55
|
+
};
|
|
56
|
+
},
|
|
51
57
|
file: function (f) {
|
|
52
58
|
return {
|
|
53
59
|
name: f.file_name,
|
|
@@ -78,5 +84,39 @@ exports.GitLabMapper = {
|
|
|
78
84
|
ref: m.commit.id,
|
|
79
85
|
milestones: (_a = m.milestones) === null || _a === void 0 ? void 0 : _a.map(function (m) { return m.title; })
|
|
80
86
|
};
|
|
87
|
+
},
|
|
88
|
+
approvalRuleConfiguration: function (m) {
|
|
89
|
+
return {
|
|
90
|
+
disableOverridingApproversPerMergeRequest: m.disable_overriding_approvers_per_merge_request,
|
|
91
|
+
mergeRequestsAuthorApproval: m.merge_requests_author_approval,
|
|
92
|
+
mergeRequestsDisableCommittersApproval: m.merge_requests_disable_committers_approval,
|
|
93
|
+
requirePasswordToApprove: m.require_password_to_approve,
|
|
94
|
+
resetApprovalsOnPush: m.reset_approvals_on_push
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
reverseApprovalRuleConfiguration: function (config) {
|
|
98
|
+
return {
|
|
99
|
+
disable_overriding_approvers_per_merge_request: config.disableOverridingApproversPerMergeRequest,
|
|
100
|
+
merge_requests_author_approval: config.mergeRequestsAuthorApproval,
|
|
101
|
+
merge_requests_disable_committers_approval: config.mergeRequestsDisableCommittersApproval,
|
|
102
|
+
require_password_to_approve: config.requirePasswordToApprove,
|
|
103
|
+
reset_approvals_on_push: config.resetApprovalsOnPush,
|
|
104
|
+
approvals_before_merge: 0
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
approvalRule: function (m) {
|
|
108
|
+
var _a;
|
|
109
|
+
return {
|
|
110
|
+
id: m.id,
|
|
111
|
+
name: m.name,
|
|
112
|
+
approvalsRequired: m.approvals_required,
|
|
113
|
+
groups: (_a = m.groups) === null || _a === void 0 ? void 0 : _a.map(exports.GitLabMapper.group)
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
group: function (m) {
|
|
117
|
+
return {
|
|
118
|
+
id: m.id,
|
|
119
|
+
name: m.name
|
|
120
|
+
};
|
|
81
121
|
}
|
|
82
122
|
};
|
|
@@ -0,0 +1,84 @@
|
|
|
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.ConfigureProjectsCommand = void 0;
|
|
52
|
+
require("reflect-metadata");
|
|
53
|
+
var inversify_1 = require("inversify");
|
|
54
|
+
var types_1 = require("../types");
|
|
55
|
+
var ConfigureProjectsCommand = /** @class */ (function () {
|
|
56
|
+
function ConfigureProjectsCommand(addApprovalRulesTask, createToolingBranchTask) {
|
|
57
|
+
this.addApprovalRulesTask = addApprovalRulesTask;
|
|
58
|
+
this.createToolingBranchTask = createToolingBranchTask;
|
|
59
|
+
}
|
|
60
|
+
ConfigureProjectsCommand.prototype.run = function (options) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
+
var cont;
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
switch (_a.label) {
|
|
65
|
+
case 0: return [4 /*yield*/, this.addApprovalRulesTask.run(options)];
|
|
66
|
+
case 1:
|
|
67
|
+
cont = _a.sent();
|
|
68
|
+
if (!cont)
|
|
69
|
+
return [2 /*return*/, false];
|
|
70
|
+
return [4 /*yield*/, this.createToolingBranchTask.run(options)];
|
|
71
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
ConfigureProjectsCommand = __decorate([
|
|
77
|
+
(0, inversify_1.injectable)(),
|
|
78
|
+
__param(0, (0, inversify_1.inject)(types_1.TASKS.AddApprovalRulesTask)),
|
|
79
|
+
__param(1, (0, inversify_1.inject)(types_1.TASKS.CreateToolingBranchTask)),
|
|
80
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
81
|
+
], ConfigureProjectsCommand);
|
|
82
|
+
return ConfigureProjectsCommand;
|
|
83
|
+
}());
|
|
84
|
+
exports.ConfigureProjectsCommand = ConfigureProjectsCommand;
|
|
@@ -53,7 +53,7 @@ require("reflect-metadata");
|
|
|
53
53
|
var inversify_1 = require("inversify");
|
|
54
54
|
var types_1 = require("../types");
|
|
55
55
|
var ReleaseCommand = /** @class */ (function () {
|
|
56
|
-
function ReleaseCommand(validateTask, versionTask, validateDescriptionsTask, validateCommitsTask, createBranchTask, bumpVersionTxtTask, createMergeRequestTask, startMonorepoBuildTask) {
|
|
56
|
+
function ReleaseCommand(validateTask, versionTask, validateDescriptionsTask, validateCommitsTask, createBranchTask, bumpVersionTxtTask, createMergeRequestTask, startMonorepoBuildTask, ensureApprovalRulesTask) {
|
|
57
57
|
this.validateTask = validateTask;
|
|
58
58
|
this.versionTask = versionTask;
|
|
59
59
|
this.validateDescriptionsTask = validateDescriptionsTask;
|
|
@@ -62,6 +62,7 @@ var ReleaseCommand = /** @class */ (function () {
|
|
|
62
62
|
this.bumpVersionTxtTask = bumpVersionTxtTask;
|
|
63
63
|
this.createMergeRequestTask = createMergeRequestTask;
|
|
64
64
|
this.startMonorepoBuildTask = startMonorepoBuildTask;
|
|
65
|
+
this.ensureApprovalRulesTask = ensureApprovalRulesTask;
|
|
65
66
|
}
|
|
66
67
|
ReleaseCommand.prototype.run = function (options) {
|
|
67
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -89,25 +90,30 @@ var ReleaseCommand = /** @class */ (function () {
|
|
|
89
90
|
cont = _a.sent();
|
|
90
91
|
if (!cont)
|
|
91
92
|
return [2 /*return*/, false];
|
|
92
|
-
return [4 /*yield*/, this.
|
|
93
|
+
return [4 /*yield*/, this.ensureApprovalRulesTask.run(options)];
|
|
93
94
|
case 5:
|
|
94
95
|
cont = _a.sent();
|
|
95
96
|
if (!cont)
|
|
96
97
|
return [2 /*return*/, false];
|
|
97
|
-
return [4 /*yield*/, this.
|
|
98
|
+
return [4 /*yield*/, this.createBranchTask.run(options)];
|
|
98
99
|
case 6:
|
|
99
100
|
cont = _a.sent();
|
|
100
101
|
if (!cont)
|
|
101
102
|
return [2 /*return*/, false];
|
|
102
|
-
return [4 /*yield*/, this.
|
|
103
|
+
return [4 /*yield*/, this.bumpVersionTxtTask.run(options)];
|
|
103
104
|
case 7:
|
|
105
|
+
cont = _a.sent();
|
|
106
|
+
if (!cont)
|
|
107
|
+
return [2 /*return*/, false];
|
|
108
|
+
return [4 /*yield*/, this.createMergeRequestTask.run(options)];
|
|
109
|
+
case 8:
|
|
104
110
|
cont = _a.sent();
|
|
105
111
|
if (!cont)
|
|
106
112
|
return [2 /*return*/, false];
|
|
107
113
|
if (!options.triggerMonorepoBuild)
|
|
108
114
|
return [2 /*return*/, true];
|
|
109
115
|
return [4 /*yield*/, this.startMonorepoBuildTask.run(options)];
|
|
110
|
-
case
|
|
116
|
+
case 9: return [2 /*return*/, _a.sent()];
|
|
111
117
|
}
|
|
112
118
|
});
|
|
113
119
|
});
|
|
@@ -122,7 +128,8 @@ var ReleaseCommand = /** @class */ (function () {
|
|
|
122
128
|
__param(5, (0, inversify_1.inject)(types_1.TASKS.BumpVersionTxtTask)),
|
|
123
129
|
__param(6, (0, inversify_1.inject)(types_1.TASKS.CreateMergeRequestTask)),
|
|
124
130
|
__param(7, (0, inversify_1.inject)(types_1.TASKS.StartMonorepoBuildTask)),
|
|
125
|
-
|
|
131
|
+
__param(8, (0, inversify_1.inject)(types_1.TASKS.EnsureApprovalRulesTask)),
|
|
132
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object, Object, Object, Object, Object, Object])
|
|
126
133
|
], ReleaseCommand);
|
|
127
134
|
return ReleaseCommand;
|
|
128
135
|
}());
|
|
@@ -53,10 +53,11 @@ require("reflect-metadata");
|
|
|
53
53
|
var inversify_1 = require("inversify");
|
|
54
54
|
var types_1 = require("../types");
|
|
55
55
|
var StatusCommand = /** @class */ (function () {
|
|
56
|
-
function StatusCommand(validateTask, validateDescriptionsTask, validateCommitsTask) {
|
|
56
|
+
function StatusCommand(validateTask, validateDescriptionsTask, validateCommitsTask, ensureApprovalRulesTask) {
|
|
57
57
|
this.validateTask = validateTask;
|
|
58
58
|
this.validateDescriptionsTask = validateDescriptionsTask;
|
|
59
59
|
this.validateCommitsTask = validateCommitsTask;
|
|
60
|
+
this.ensureApprovalRulesTask = ensureApprovalRulesTask;
|
|
60
61
|
}
|
|
61
62
|
StatusCommand.prototype.run = function (options) {
|
|
62
63
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -70,6 +71,9 @@ var StatusCommand = /** @class */ (function () {
|
|
|
70
71
|
_a.sent();
|
|
71
72
|
return [4 /*yield*/, this.validateCommitsTask.run(options)];
|
|
72
73
|
case 3:
|
|
74
|
+
_a.sent();
|
|
75
|
+
return [4 /*yield*/, this.ensureApprovalRulesTask.run(options)];
|
|
76
|
+
case 4:
|
|
73
77
|
_a.sent();
|
|
74
78
|
return [2 /*return*/, true];
|
|
75
79
|
}
|
|
@@ -81,7 +85,8 @@ var StatusCommand = /** @class */ (function () {
|
|
|
81
85
|
__param(0, (0, inversify_1.inject)(types_1.TASKS.ValidateTask)),
|
|
82
86
|
__param(1, (0, inversify_1.inject)(types_1.TASKS.ValidateDescriptionsTask)),
|
|
83
87
|
__param(2, (0, inversify_1.inject)(types_1.TASKS.ValidateCommitsTask)),
|
|
84
|
-
|
|
88
|
+
__param(3, (0, inversify_1.inject)(types_1.TASKS.EnsureApprovalRulesTask)),
|
|
89
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object])
|
|
85
90
|
], StatusCommand);
|
|
86
91
|
return StatusCommand;
|
|
87
92
|
}());
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./BumpPackagesCommand"), exports);
|
|
18
|
+
__exportStar(require("./ConfigureProjectsCommand"), exports);
|
|
18
19
|
__exportStar(require("./CreateBranchCommand"), exports);
|
|
19
20
|
__exportStar(require("./CreateMergeRequestCommand"), exports);
|
|
20
21
|
__exportStar(require("./ListProjectsCommand"), exports);
|
|
@@ -16,5 +16,6 @@ exports.CommandTypeMapping = {
|
|
|
16
16
|
'start-project-builds': types_1.COMMANDS.StartProjectBuildsCommand,
|
|
17
17
|
'tag-master': types_1.COMMANDS.TagMasterCommand,
|
|
18
18
|
'list-projects': types_1.COMMANDS.ListProjectsCommand,
|
|
19
|
-
'create-trello-cards': types_1.COMMANDS.CreateTrelloCardsCommand
|
|
19
|
+
'create-trello-cards': types_1.COMMANDS.CreateTrelloCardsCommand,
|
|
20
|
+
'configure-projects': types_1.COMMANDS.ConfigureProjectsCommand
|
|
20
21
|
};
|
|
@@ -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);
|
|
@@ -20,3 +20,4 @@ __exportStar(require("./MilestoneCommandOptions"), exports);
|
|
|
20
20
|
__exportStar(require("./ValidateMRCommandOptions"), exports);
|
|
21
21
|
__exportStar(require("./ReleaseCommandOptions"), exports);
|
|
22
22
|
__exportStar(require("./StatusCommandOptions"), exports);
|
|
23
|
+
__exportStar(require("./ConfigureProjectsOptions"), exports);
|
|
@@ -14,13 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ApprovalRule"), exports);
|
|
18
|
+
__exportStar(require("./ApprovalRuleConfiguration"), exports);
|
|
17
19
|
__exportStar(require("./Branch"), exports);
|
|
18
20
|
__exportStar(require("./Commit"), exports);
|
|
19
21
|
__exportStar(require("./CommitFile"), exports);
|
|
22
|
+
__exportStar(require("./CreateApprovalRuleRequest"), exports);
|
|
20
23
|
__exportStar(require("./File"), exports);
|
|
24
|
+
__exportStar(require("./Group"), exports);
|
|
21
25
|
__exportStar(require("./Label"), exports);
|
|
22
26
|
__exportStar(require("./MergeRequest"), exports);
|
|
23
27
|
__exportStar(require("./Milestone"), exports);
|
|
24
28
|
__exportStar(require("./Project"), exports);
|
|
29
|
+
__exportStar(require("./ProjectConfig"), exports);
|
|
30
|
+
__exportStar(require("./ProtectedBranch"), exports);
|
|
25
31
|
__exportStar(require("./Release"), exports);
|
|
26
32
|
__exportStar(require("./Tag"), exports);
|
|
@@ -7,6 +7,7 @@ var services_1 = require("./services");
|
|
|
7
7
|
var commands_1 = require("./commands");
|
|
8
8
|
var tasks_1 = require("./tasks");
|
|
9
9
|
var types_1 = require("./types");
|
|
10
|
+
var EnsureApprovalRulesTask_1 = require("./tasks/configure-projects/EnsureApprovalRulesTask");
|
|
10
11
|
function createContainer(config) {
|
|
11
12
|
var container = new inversify_1.Container();
|
|
12
13
|
/**
|
|
@@ -51,6 +52,9 @@ function createContainer(config) {
|
|
|
51
52
|
container.bind(types_1.TASKS.PopulateTrelloBoardTask).to(tasks_1.PopulateTrelloBoardTask);
|
|
52
53
|
container.bind(types_1.TASKS.StartProjectBuildsTask)
|
|
53
54
|
.to(tasks_1.StartProjectBuildsTask);
|
|
55
|
+
container.bind(types_1.TASKS.AddApprovalRulesTask).to(tasks_1.AddApprovalRulesTask);
|
|
56
|
+
container.bind(types_1.TASKS.EnsureApprovalRulesTask).to(EnsureApprovalRulesTask_1.EnsureApprovalRulesTask);
|
|
57
|
+
container.bind(types_1.TASKS.CreateToolingBranchTask).to(tasks_1.CreateToolingBranchTask);
|
|
54
58
|
/**
|
|
55
59
|
* Commands
|
|
56
60
|
*/
|
|
@@ -69,6 +73,7 @@ function createContainer(config) {
|
|
|
69
73
|
container.bind(types_1.COMMANDS.CreateTrelloCardsCommand).to(commands_1.CreateTrelloCardsCommand);
|
|
70
74
|
container.bind(types_1.COMMANDS.StartProjectBuildsCommand)
|
|
71
75
|
.to(commands_1.StartProjectBuildsCommand);
|
|
76
|
+
container.bind(types_1.COMMANDS.ConfigureProjectsCommand).to(commands_1.ConfigureProjectsCommand);
|
|
72
77
|
return container;
|
|
73
78
|
}
|
|
74
79
|
exports.createContainer = createContainer;
|
|
@@ -141,6 +141,16 @@ var GitLabService = /** @class */ (function () {
|
|
|
141
141
|
});
|
|
142
142
|
});
|
|
143
143
|
};
|
|
144
|
+
GitLabService.prototype.getAllProjects = function () {
|
|
145
|
+
return this.apiClient.getAllProjects();
|
|
146
|
+
};
|
|
147
|
+
GitLabService.prototype.getAllGroupProjects = function (groupId) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
return [2 /*return*/, this.apiClient.getAllGroupProjects(groupId)];
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
};
|
|
144
154
|
/**
|
|
145
155
|
* Fetches any projects that are not already included via MRs by checking the project labels.
|
|
146
156
|
* We only do this for a whitelist of projects
|
|
@@ -227,7 +237,17 @@ var GitLabService = /** @class */ (function () {
|
|
|
227
237
|
});
|
|
228
238
|
});
|
|
229
239
|
};
|
|
230
|
-
GitLabService.prototype.createBranch = function (project, branchFrom, branchName
|
|
240
|
+
GitLabService.prototype.createBranch = function (project, branchFrom, branchName) {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
+
return __generator(this, function (_a) {
|
|
243
|
+
switch (_a.label) {
|
|
244
|
+
case 0: return [4 /*yield*/, this.apiClient.createBranch(project.id, branchName, branchFrom)];
|
|
245
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
GitLabService.prototype._createBranch = function (project, branchFrom, branchName, cherryPick) {
|
|
231
251
|
return __awaiter(this, void 0, void 0, function () {
|
|
232
252
|
var newBranch, i, mr;
|
|
233
253
|
return __generator(this, function (_a) {
|
|
@@ -494,11 +514,25 @@ var GitLabService = /** @class */ (function () {
|
|
|
494
514
|
});
|
|
495
515
|
};
|
|
496
516
|
GitLabService.prototype.updateMilestone = function (projectId, mergeRequestID, newMilestoneId) {
|
|
497
|
-
return
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
517
|
+
return this.apiClient.updateMilestone(projectId, mergeRequestID, newMilestoneId);
|
|
518
|
+
};
|
|
519
|
+
GitLabService.prototype.getApprovalRuleConfiguration = function (projectId) {
|
|
520
|
+
return this.apiClient.getApprovalRuleConfiguration(projectId);
|
|
521
|
+
};
|
|
522
|
+
GitLabService.prototype.updateApprovalRuleConfiguration = function (projectId, configuration) {
|
|
523
|
+
return this.apiClient.updateApprovalRuleConfiguration(projectId, configuration);
|
|
524
|
+
};
|
|
525
|
+
GitLabService.prototype.getApprovalRules = function (projectId) {
|
|
526
|
+
return this.apiClient.getApprovalRules(projectId);
|
|
527
|
+
};
|
|
528
|
+
GitLabService.prototype.createApprovalRule = function (projectId, rule) {
|
|
529
|
+
return this.apiClient.createApprovalRule(projectId, rule);
|
|
530
|
+
};
|
|
531
|
+
GitLabService.prototype.updateApprovalRule = function (projectId, approvalRuleId, rule) {
|
|
532
|
+
return this.apiClient.updateApprovalRule(projectId, approvalRuleId, rule);
|
|
533
|
+
};
|
|
534
|
+
GitLabService.prototype.getProtectedBranches = function (projectId) {
|
|
535
|
+
return this.apiClient.getProtectedBranches(projectId);
|
|
502
536
|
};
|
|
503
537
|
GitLabService = __decorate([
|
|
504
538
|
(0, inversify_1.injectable)(),
|
|
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.setupCommands = void 0;
|
|
40
|
+
var utils_1 = require("../utils");
|
|
40
41
|
var AddMilestoneCommand_1 = require("./AddMilestoneCommand");
|
|
41
42
|
var GetAction_1 = require("./GetAction");
|
|
42
43
|
function setupCommands(program, container) {
|
|
@@ -164,5 +165,16 @@ function setupCommands(program, container) {
|
|
|
164
165
|
program.command('list-projects')
|
|
165
166
|
.description('Displays a list of all project names that can be used with the -p argument')
|
|
166
167
|
.action(getAction('list-projects'));
|
|
168
|
+
program.command('configure-projects')
|
|
169
|
+
.description('Configures all projects using Gitlab\'s API')
|
|
170
|
+
.option('-p, --projectIds <projectIds...>')
|
|
171
|
+
.option('--allProjects')
|
|
172
|
+
.action(function (opts) { return __awaiter(_this, void 0, void 0, function () {
|
|
173
|
+
return __generator(this, function (_a) {
|
|
174
|
+
if (opts.projectIds)
|
|
175
|
+
opts.projectIds = utils_1.ProjectIds.getProjectIds(opts.projectIds);
|
|
176
|
+
return [2 /*return*/, getAction('configure-projects')(opts)];
|
|
177
|
+
});
|
|
178
|
+
}); });
|
|
167
179
|
}
|
|
168
180
|
exports.setupCommands = setupCommands;
|