Skip to content

Commit fa75bfa

Browse files
committed
Fix types after gitbeaker update
1 parent 941ac30 commit fa75bfa

1 file changed

Lines changed: 27 additions & 18 deletions

File tree

src/index.ts

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ import GithubHelper from './githubHelper';
22
import GitlabHelper from './gitlabHelper';
33
import settings from '../settings';
44

5-
import {Octokit as GitHubApi} from '@octokit/rest';
6-
import {throttling} from '@octokit/plugin-throttling';
7-
import { Gitlab } from '@gitbeaker/node'
5+
import { Octokit as GitHubApi } from '@octokit/rest';
6+
import { throttling } from '@octokit/plugin-throttling';
7+
import { Gitlab } from '@gitbeaker/node';
88

99
import * as fs from 'fs';
1010

1111
import AWS from 'aws-sdk';
1212
import { sleep } from './utils';
13+
import { LabelSchema } from '@gitbeaker/core/dist/types/types';
14+
15+
type Label = Pick<LabelSchema, 'name' | 'color' | 'description'>;
1316

1417
const issueCounters = {
1518
nrOfPlaceholderIssues: 0,
@@ -85,10 +88,12 @@ const githubApi = new MyOctokit({
8588
});
8689

8790
const gitlabHelper = new GitlabHelper(gitlabApi, settings.gitlab);
88-
const githubHelper = new GithubHelper(githubApi,
89-
settings.github,
90-
gitlabHelper,
91-
settings.useIssuesForAllMergeRequests);
91+
const githubHelper = new GithubHelper(
92+
githubApi,
93+
settings.github,
94+
gitlabHelper,
95+
settings.useIssuesForAllMergeRequests
96+
);
9297

9398
// If no project id is given in settings.js, just return
9499
// all of the projects that this user is associated with.
@@ -143,7 +148,6 @@ async function migrate() {
143148
//
144149

145150
try {
146-
147151
await githubHelper.registerRepoId();
148152
await gitlabHelper.registerProjectPath(settings.gitlab.projectId);
149153

@@ -222,21 +226,26 @@ async function transferLabels(attachmentLabel = true, useLowerCase = true) {
222226
inform('Transferring Labels');
223227

224228
// Get a list of all labels associated with this project
225-
let labels = await gitlabApi.Labels.all(settings.gitlab.projectId);
229+
let labels: Label[] = await gitlabApi.Labels.all(settings.gitlab.projectId);
226230

227231
// get a list of the current label names in the new GitHub repo (likely to be just the defaults)
228-
let githubLabels = await githubHelper.getAllGithubLabelNames();
232+
let githubLabels: string[] = await githubHelper.getAllGithubLabelNames();
229233

230234
// create a hasAttachment label for manual attachment migration
231235
if (attachmentLabel) {
232-
const hasAttachmentLabel = { name: 'has attachment', color: '#fbca04' };
236+
const hasAttachmentLabel = {
237+
name: 'has attachment',
238+
color: '#fbca04',
239+
description: 'Issue has attachments which might not have been migrated',
240+
};
233241
labels.push(hasAttachmentLabel);
234242
}
235243

236-
// create gitlabMergeRequest label for non-migratable merge requests
237244
const gitlabMergeRequestLabel = {
238245
name: 'gitlab merge request',
239246
color: '#b36b00',
247+
description:
248+
'An issue replacing a merge request which cannot be migrated because of deleted branches',
240249
};
241250
labels.push(gitlabMergeRequestLabel);
242251

@@ -275,10 +284,10 @@ async function transferIssues() {
275284

276285
// get a list of all GitLab issues associated with this project
277286
// TODO return all issues via pagination
278-
let issues = await gitlabApi.Issues.all({
287+
let issues = (await gitlabApi.Issues.all({
279288
projectId: settings.gitlab.projectId,
280289
labels: settings.filterByLabel,
281-
}) as any[];
290+
})) as any[];
282291

283292
// sort issues in ascending order of their issue number (by iid)
284293
issues = issues.sort((a, b) => a.iid - b.iid);
@@ -392,10 +401,10 @@ async function transferMergeRequests() {
392401

393402
// Get a list of all pull requests (merge request equivalent) associated with
394403
// this project
395-
let mergeRequests = await gitlabApi.MergeRequests.all({
404+
let mergeRequests = (await gitlabApi.MergeRequests.all({
396405
projectId: settings.gitlab.projectId,
397406
labels: settings.filterByLabel,
398-
}) as any;
407+
})) as any;
399408

400409
// Sort merge requests in ascending order of their number (by iid)
401410
mergeRequests = mergeRequests.sort((a, b) => a.iid - b.iid);
@@ -475,10 +484,10 @@ async function logMergeRequests(logFile) {
475484

476485
// get a list of all GitLab merge requests associated with this project
477486
// TODO return all MRs via pagination
478-
let mergeRequests = await gitlabApi.MergeRequests.all({
487+
let mergeRequests = (await gitlabApi.MergeRequests.all({
479488
projectId: settings.gitlab.projectId,
480489
labels: settings.filterByLabel,
481-
}) as any;
490+
})) as any;
482491

483492
// sort MRs in ascending order of when they were created (by id)
484493
mergeRequests = mergeRequests.sort((a, b) => a.id - b.id);

0 commit comments

Comments
 (0)