Skip to content

Commit

Permalink
Upgrade to newer versions of the node modules
Browse files Browse the repository at this point in the history
  • Loading branch information
spruce committed Mar 24, 2018
1 parent ca6effb commit 5f506a2
Show file tree
Hide file tree
Showing 3 changed files with 589 additions and 9 deletions.
30 changes: 23 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var GitHubApi = require("github");
var Gitlab = require('gitlab');
var GitHubApi = require('@octokit/rest')
var Gitlab = require('node-gitlab-api');
var async = require('async');

try{
Expand Down Expand Up @@ -35,7 +35,8 @@ var gitlab = Gitlab({
var userProjectRe = generateUserProjectRe();

if (settings.gitlab.projectID === null) {
gitlab.projects.all(function(projects) {
gitlab.projects.all()
.then(function(projects) {
projects = projects.sort(function(a, b) {
return a.id - b.id;
});
Expand All @@ -45,6 +46,9 @@ if (settings.gitlab.projectID === null) {
console.log('\n\n');
console.log('Select which project ID should be transported to github. Edit the settings.json accordingly. (gitlab.projectID)');
console.log('\n\n');
}).catch(function(err){
console.log('An Error occured while fetching all projects:');
console.log(err);
});
} else {
// user has choosen a project
Expand All @@ -68,7 +72,7 @@ if (settings.gitlab.projectID === null) {
password: settings.github.password
});

gitlab.projects.milestones.all(settings.gitlab.projectID, function(data) {
gitlab.projects.milestones.all(settings.gitlab.projectID).then(function(data) {
console.log('Amount of gitlab milestones', data.length);
data = data.sort(function(a, b) {
return a.id - b.id;
Expand Down Expand Up @@ -97,7 +101,7 @@ if (settings.gitlab.projectID === null) {
// all milestones are created
getAllGHMilestones(function(milestoneDataA, milestoneDataMappedA) {
// create labels
gitlab.projects.labels.all(settings.gitlab.projectID, null, function(glLabels) {
gitlab.projects.labels.all(settings.gitlab.projectID).then(function(glLabels) {
getAllGHLabelNames(function(ghlabelNames) {
async.each(glLabels, function(glLabel, cb) {
if (ghlabelNames.indexOf(glLabel.name) < 0) {
Expand Down Expand Up @@ -130,17 +134,23 @@ if (settings.gitlab.projectID === null) {
});
}); //async
}); // getAllGHLabelNames
}).catch(function(err){
console.log('An Error occured while loading all labels:');
console.log(err);
}); // gitlab list labels
}); // getAllGHMilestones
}); // async
})
}).catch(function(err){
console.log('An Error occured while loading all milestones:');
console.log(err);
}); // gitlab list milestones
}


function createAllIssuesAndComments(milestoneData, callback) {
// select all issues and comments from this project
gitlab.projects.issues.list(settings.gitlab.projectID, function(issueData) {
gitlab.projects.issues.list(settings.gitlab.projectID).then(function(issueData) {
// TODO return all issues via pagination
// look whether issue is already created
issueData = issueData.sort(function(a, b) {
Expand Down Expand Up @@ -199,6 +209,9 @@ function createAllIssuesAndComments(milestoneData, callback) {
callback(err);
}); // each series
}); // getAllGHIssues
}).catch(function(err){
console.log('An Error occured while fetching all issues:');
console.log(err);
}); // gitlab project Issues
}

Expand Down Expand Up @@ -384,7 +397,7 @@ function createAllIssueComments(projectID, issueID, newIssueData, callback) {
return callback();
}
// get all comments add them to the comment
gitlab.projects.issues.notes.all(projectID, issueID, function(data) {
gitlab.projects.issues.notes.all(projectID, issueID).then(function(data) {
if (data.length) {
data = data.sort(function(a, b) {
return a.id - b.id;
Expand All @@ -410,6 +423,9 @@ function createAllIssueComments(projectID, issueID, newIssueData, callback) {
} else {
callback();
}
}).catch(function(err){
console.log(`An Error occured while fetching all notes for issue ${issueID}:`);
console.log(err);
});
}

Expand Down

0 comments on commit 5f506a2

Please sign in to comment.