-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
79 lines (65 loc) · 2.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var Github = require('github-api'),
Config = require('./config.js'),
d3 = require('d3'),
fs = require('fs');
var github = new Github({
username: Config.username,
password: Config.password,
auth: Config.basic
});
var data = fs.readFileSync('data/extra_users_list.tsv','utf8')
data = d3.tsv.parse(data)
var reposNumber = data.length-1,
//var reposNumber = 4000,
reposCount = 4000;
var output = [];
var writeFinalData = function(data){
var finalData = d3.tsv.format(data);
fs.writeFile('output/new_users_repos/output.tsv', finalData, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
}
var getRepos = function(user, repo){
var myrepo = github.getRepo(user, repo);
myrepo.show(function(err, repoData) {
if(err){
console.log(reposCount + '/' + reposNumber + ' ' + err)
reposCount = reposCount + 1;
if(reposCount < reposNumber){
getRepos(data[reposCount].user, data[reposCount].repo)
}else{
writeFinalData(output)
}
}else {
fs.writeFileSync('output/new_users_repos/' + user + '_' + repo + '.json', JSON.stringify(repoData), 'utf8');
var elm = {
user:user,
name: repo,
owner: repoData.owner.login,
description: repoData.description,
fork: repoData.fork,
language: repoData.language,
forks_count: repoData.forks_count,
stargazers_count: repoData.stargazers_count,
watchers_count: repoData.watchers_count,
size: repoData.size,
default_branch: repoData.default_branch,
open_issues_count: repoData.open_issues_count,
pushed_at: repoData.pushed_at,
updated_at: repoData.updated_at
}
output.push(elm);
console.log(reposCount + '/' + reposNumber + ' ' + repoData.name)
reposCount = reposCount + 1
if(reposCount < reposNumber){
getRepos(data[reposCount].user, data[reposCount].repo)
}else{
writeFinalData(output)
}
}
});
}
getRepos(data[reposCount].user, data[reposCount].repo)