-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-pinned-repositories.js
64 lines (59 loc) · 1.1 KB
/
get-pinned-repositories.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
const get = require('lodash/get')
const graphqlGot = require('graphql-got')
const query = `
query PinnedRepositoriesQuery($username: String!, $last: Int = 10) {
user(login: $username) {
pinnedRepositories(last: $last){
totalCount
nodes {
createdAt
description
descriptionHTML
diskUsage
hasIssuesEnabled
hasWikiEnabled
homepageUrl
licenseInfo {
name
nickname
key
url
}
name
nameWithOwner
openGraphImageUrl
primaryLanguage {
color
name
}
updatedAt
pushedAt
url
usesCustomOpenGraphImage
}
}
}
}`
const MAX_REPOS = 10
const getPinnedRepositories = async ({ config }) => {
const {
github: {
access_token: token,
pinned_repository_max: last = MAX_REPOS,
username
}
} = config
const { body } = await graphqlGot('https://api.github.com/graphql', {
query,
token,
variables: {
username,
last
}
})
const pinnedRepositories = get(body, 'user.pinnedRepositories.nodes', [])
return {
pinnedRepositories
}
}
module.exports = getPinnedRepositories