-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
45 lines (44 loc) · 952 Bytes
/
main.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
require('dotenv').config()
const { graphql } = require('@octokit/graphql')
const fs = require('fs')
const graphqlWithAuth = graphql.defaults({
headers: {
authorization: 'token ' + process.env.GITHUB_PERSONAL_ACCESS_TOKEN,
},
})
let repos = []
graphqlWithAuth(`{
organization(login: "fdnd") {
repositories(
privacy: PUBLIC
first: 100
orderBy: {field: NAME, direction: ASC}
) {
nodes {
name
url
description
}
}
}
}`)
.then((result) => {
repos = Object.values(result.organization.repositories.nodes).filter(
(repo) => repo.name.includes('.fdnd.nl')
)
})
.catch((error) => {
console.log(
'GitHub API Request failed: ',
error.request,
'\n',
error.message
)
})
.finally(() => {
fs.writeFile('data.json', JSON.stringify(repos), function (err) {
if (err) {
console.error('Crap happens')
}
})
})