@clickview/ship-it 0.0.4-dev.5 → 0.0.4

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.
Files changed (27) hide show
  1. package/lib/src/api-clients/git-lab/GitLabApiClient.js +65 -0
  2. package/lib/src/api-clients/git-lab/GitLabMapper.js +18 -1
  3. package/lib/src/commands/ReleaseCommand.js +11 -7
  4. package/lib/src/commands/{CommitPackageVersionsCommand.js → TagMasterCommand.js} +13 -15
  5. package/lib/src/commands/index.js +1 -0
  6. package/lib/src/constants/CommandTypeMapping.js +2 -1
  7. package/lib/src/interfaces/models/index.js +2 -0
  8. package/lib/src/inversify.config.js +2 -0
  9. package/lib/src/services/GitLabService.js +114 -8
  10. package/lib/src/startup/SetupCommands.js +23 -11
  11. package/lib/src/tasks/BumpPackagesTask.js +1 -2
  12. package/lib/src/tasks/CommitPackageVersionsTask.js +4 -0
  13. package/lib/src/tasks/CreateBranchTask.js +19 -37
  14. package/lib/src/tasks/{CommitLocalPackagesTask.js → TagMasterTask.js} +56 -71
  15. package/lib/src/tasks/ValidateDescriptionsTask.js +15 -11
  16. package/lib/src/tasks/ValidateMergeRequestTask.js +12 -6
  17. package/lib/src/tasks/ValidateTask.js +4 -4
  18. package/lib/src/tasks/index.js +1 -0
  19. package/lib/src/types.js +4 -2
  20. package/lib/src/utils/BranchNames.js +0 -2
  21. package/lib/src/utils/ProjectIds.js +1 -5
  22. package/lib/src/utils/Versions.js +0 -1
  23. package/package.json +1 -1
  24. package/lib/src/api-clients/GitLabApiClient.js +0 -342
  25. package/lib/src/interfaces/command-options/InstallPackagesCommandOptions.js +0 -2
  26. /package/lib/src/interfaces/{ShipItOptions.js → models/Label.js} +0 -0
  27. /package/lib/src/interfaces/{command-options/CommitPackageVersionsCommandOptions.js → models/Release.js} +0 -0
@@ -1,342 +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.GitLabApiClient = void 0;
52
- require("reflect-metadata");
53
- var inversify_1 = require("inversify");
54
- var node_1 = require("@gitbeaker/node");
55
- var types_1 = require("types");
56
- var GitLabApiClient = /** @class */ (function () {
57
- function GitLabApiClient(config) {
58
- this._config = config;
59
- this._client = new node_1.Gitlab({
60
- token: this._config.accessToken,
61
- host: this._config.url
62
- });
63
- }
64
- GitLabApiClient.prototype.getMergeRequests = function (options) {
65
- return __awaiter(this, void 0, void 0, function () {
66
- var milestone, projectIds, mergeRequests;
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
69
- case 0:
70
- milestone = options.milestone, projectIds = options.projectIds;
71
- if (!milestone && !(projectIds === null || projectIds === void 0 ? void 0 : projectIds.length))
72
- throw new Error('Must specifiy one of the following: Milestone or ProjectIds');
73
- return [4 /*yield*/, this._client.MergeRequests.all({
74
- milestone: milestone,
75
- scope: 'all'
76
- })];
77
- case 1:
78
- mergeRequests = _a.sent();
79
- /**
80
- * Filter out only projectIds we care aboutr
81
- */
82
- if (projectIds === null || projectIds === void 0 ? void 0 : projectIds.length) {
83
- mergeRequests = mergeRequests.filter(function (mr) {
84
- return projectIds.some(function (p) { return mr.project_id.toString() === p.toString(); });
85
- });
86
- }
87
- return [2 /*return*/, mergeRequests.map(function (m) {
88
- var _a;
89
- return ({
90
- title: m.title,
91
- description: m.description,
92
- status: m.state,
93
- projectId: m.project_id,
94
- mergeCommit: m.merge_commit_sha,
95
- author: m.author.name,
96
- assignee: (_a = m.assignee) === null || _a === void 0 ? void 0 : _a.name,
97
- url: m.web_url,
98
- hasConflicts: m.has_conflicts,
99
- targetBranch: m.target_branch
100
- });
101
- })];
102
- }
103
- });
104
- });
105
- };
106
- GitLabApiClient.prototype.getProjectsByIds = function (projectIds) {
107
- return __awaiter(this, void 0, void 0, function () {
108
- var projects, i, projectId, p;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0:
112
- projects = [];
113
- i = 0;
114
- _a.label = 1;
115
- case 1:
116
- if (!(i < projectIds.length)) return [3 /*break*/, 4];
117
- projectId = projectIds[i];
118
- return [4 /*yield*/, this._client.Projects.show(projectId)];
119
- case 2:
120
- p = _a.sent();
121
- projects.push(p);
122
- _a.label = 3;
123
- case 3:
124
- i++;
125
- return [3 /*break*/, 1];
126
- case 4: return [2 /*return*/, projects.map(function (p) { return ({
127
- id: p.id,
128
- title: p.name
129
- }); })];
130
- }
131
- });
132
- });
133
- };
134
- GitLabApiClient.prototype.getLatestTags = function (projectId) {
135
- return __awaiter(this, void 0, void 0, function () {
136
- var tags;
137
- return __generator(this, function (_a) {
138
- switch (_a.label) {
139
- case 0: return [4 /*yield*/, this._client.Tags.all(projectId, { maxPages: 1, perPage: 20 })];
140
- case 1:
141
- tags = _a.sent();
142
- if (!tags.length)
143
- throw new Error("Project ".concat(projectId, " does not have any tags"));
144
- return [2 /*return*/, tags.map(function (t) { return ({
145
- name: t.name,
146
- target: t.commit.id
147
- }); })];
148
- }
149
- });
150
- });
151
- };
152
- GitLabApiClient.prototype.getCommitsSince = function (projectId, branchName, sinceSha) {
153
- return __awaiter(this, void 0, void 0, function () {
154
- var commit, commits;
155
- return __generator(this, function (_a) {
156
- switch (_a.label) {
157
- case 0: return [4 /*yield*/, this._client.Commits.show(projectId, sinceSha)];
158
- case 1:
159
- commit = _a.sent();
160
- return [4 /*yield*/, this._client.Commits.all(projectId, {
161
- ref_name: branchName,
162
- since: commit.committed_date,
163
- first_parent: true
164
- })];
165
- case 2:
166
- commits = _a.sent();
167
- return [2 /*return*/, commits.map(function (c) { return ({
168
- id: c.id,
169
- title: c.title,
170
- message: c.message
171
- }); })];
172
- }
173
- });
174
- });
175
- };
176
- GitLabApiClient.prototype.getBranch = function (projectId, branchName) {
177
- return __awaiter(this, void 0, void 0, function () {
178
- var branch, _a;
179
- return __generator(this, function (_b) {
180
- switch (_b.label) {
181
- case 0:
182
- _b.trys.push([0, 2, , 3]);
183
- return [4 /*yield*/, this._client.Branches.show(projectId, branchName)];
184
- case 1:
185
- branch = _b.sent();
186
- return [2 /*return*/, {
187
- name: branch.name
188
- }];
189
- case 2:
190
- _a = _b.sent();
191
- return [2 /*return*/, null];
192
- case 3: return [2 /*return*/];
193
- }
194
- });
195
- });
196
- };
197
- GitLabApiClient.prototype.createBranch = function (projectId, branchName, branchFrom) {
198
- return __awaiter(this, void 0, void 0, function () {
199
- var newBranch;
200
- return __generator(this, function (_a) {
201
- switch (_a.label) {
202
- case 0: return [4 /*yield*/, this._client.Branches.create(projectId, branchName, branchFrom)];
203
- case 1:
204
- newBranch = _a.sent();
205
- return [2 /*return*/, {
206
- name: newBranch.name
207
- }];
208
- }
209
- });
210
- });
211
- };
212
- GitLabApiClient.prototype.cherryPick = function (projectId, sha, branchName) {
213
- return __awaiter(this, void 0, void 0, function () {
214
- return __generator(this, function (_a) {
215
- switch (_a.label) {
216
- case 0: return [4 /*yield*/, this._client.Commits.cherryPick(projectId, sha, branchName)];
217
- case 1:
218
- _a.sent();
219
- return [2 /*return*/];
220
- }
221
- });
222
- });
223
- };
224
- GitLabApiClient.prototype.getMergeRequest = function (projectId, sourceBranch, targetBranch) {
225
- var _a;
226
- return __awaiter(this, void 0, void 0, function () {
227
- var mergeRequests, mergeRequest;
228
- return __generator(this, function (_b) {
229
- switch (_b.label) {
230
- case 0: return [4 /*yield*/, this._client.MergeRequests.all({
231
- projectId: projectId,
232
- sourceBranch: sourceBranch,
233
- targetBranch: targetBranch,
234
- state: 'opened'
235
- })];
236
- case 1:
237
- mergeRequests = _b.sent();
238
- mergeRequest = mergeRequests[0];
239
- if (!mergeRequest)
240
- return [2 /*return*/, null];
241
- return [2 /*return*/, {
242
- title: mergeRequest.title,
243
- description: mergeRequest.description,
244
- status: mergeRequest.state,
245
- projectId: mergeRequest.project_id,
246
- mergeCommit: mergeRequest.merge_commit_sha,
247
- author: mergeRequest.author.name,
248
- assignee: (_a = mergeRequest.assignee) === null || _a === void 0 ? void 0 : _a.name,
249
- url: mergeRequest.web_url,
250
- hasConflicts: mergeRequest.has_conflicts,
251
- targetBranch: mergeRequest.target_branch
252
- }];
253
- }
254
- });
255
- });
256
- };
257
- GitLabApiClient.prototype.createMergeRequest = function (projectId, sourceBranch, targetBranch, title, description) {
258
- var _a;
259
- return __awaiter(this, void 0, void 0, function () {
260
- var mergeRequest;
261
- return __generator(this, function (_b) {
262
- switch (_b.label) {
263
- case 0: return [4 /*yield*/, this._client.MergeRequests.create(projectId, sourceBranch, targetBranch, title, {
264
- description: description
265
- })];
266
- case 1:
267
- mergeRequest = _b.sent();
268
- return [2 /*return*/, {
269
- title: mergeRequest.title,
270
- description: mergeRequest.description,
271
- status: mergeRequest.state,
272
- projectId: mergeRequest.project_id,
273
- mergeCommit: mergeRequest.merge_commit_sha,
274
- author: mergeRequest.author.name,
275
- assignee: (_a = mergeRequest.assignee) === null || _a === void 0 ? void 0 : _a.name,
276
- url: mergeRequest.web_url,
277
- hasConflicts: mergeRequest.has_conflicts,
278
- targetBranch: mergeRequest.target_branch
279
- }];
280
- }
281
- });
282
- });
283
- };
284
- GitLabApiClient.prototype.getFile = function (projectId, filePath, branchName) {
285
- return __awaiter(this, void 0, void 0, function () {
286
- var file, _a;
287
- return __generator(this, function (_b) {
288
- switch (_b.label) {
289
- case 0:
290
- _b.trys.push([0, 2, , 3]);
291
- return [4 /*yield*/, this._client.RepositoryFiles.show(projectId, filePath, branchName)];
292
- case 1:
293
- file = _b.sent();
294
- return [2 /*return*/, {
295
- name: file.file_name,
296
- path: file.file_path,
297
- content: file.content
298
- }];
299
- case 2:
300
- _a = _b.sent();
301
- return [2 /*return*/, null];
302
- case 3: return [2 /*return*/];
303
- }
304
- });
305
- });
306
- };
307
- GitLabApiClient.prototype.updateFile = function (projectId, filePath, branchName, content, commitMessage) {
308
- return __awaiter(this, void 0, void 0, function () {
309
- return __generator(this, function (_a) {
310
- switch (_a.label) {
311
- case 0: return [4 /*yield*/, this._client.RepositoryFiles.edit(projectId, filePath, branchName, content, commitMessage)];
312
- case 1:
313
- _a.sent();
314
- return [2 /*return*/];
315
- }
316
- });
317
- });
318
- };
319
- GitLabApiClient.prototype.commit = function (projectId, branchName, files, commitMessage) {
320
- return __awaiter(this, void 0, void 0, function () {
321
- return __generator(this, function (_a) {
322
- switch (_a.label) {
323
- case 0: return [4 /*yield*/, this._client.Commits.create(projectId, branchName, commitMessage, files.map(function (f) { return ({
324
- action: 'update',
325
- filePath: f.filePath,
326
- content: f.content
327
- }); }))];
328
- case 1:
329
- _a.sent();
330
- return [2 /*return*/];
331
- }
332
- });
333
- });
334
- };
335
- GitLabApiClient = __decorate([
336
- (0, inversify_1.injectable)(),
337
- __param(0, (0, inversify_1.inject)(types_1.MISC.GitLabConfig)),
338
- __metadata("design:paramtypes", [Object])
339
- ], GitLabApiClient);
340
- return GitLabApiClient;
341
- }());
342
- exports.GitLabApiClient = GitLabApiClient;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });