Created
April 5, 2020 10:24
-
-
Save toolmantim/fc39dc21e8ca58baa3cb954049ae675c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch('https://api.github.com/graphql', { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': `Bearer ${process.env.GITHUB_API_TOKEN}` | |
}, | |
body: JSON.stringify({ query: query() }) | |
}) | |
.then((res) => res.json()) | |
.then((data) => { | |
console.log(JSON.stringify(data)); | |
return data | |
}) | |
.then((data) => { | |
return processResults(data) | |
}) | |
.catch((err) => { | |
console.error(err) | |
process.exit(1) | |
}) | |
function query() { | |
return ` | |
query { | |
search(query:"topic:buildkite-plugin", first: 100, type:REPOSITORY) { | |
repositoryCount | |
nodes { | |
...on Repository { | |
createdAt | |
name | |
stargazers { | |
totalCount | |
} | |
owner { | |
login | |
avatarUrl | |
} | |
object(expression:"master:plugin.yml") { | |
... on Blob{ | |
text | |
} | |
} | |
repositoryTopics(first: 10) { | |
nodes { | |
topic { | |
name | |
} | |
} | |
} | |
releases(first: 1, orderBy: {field:NAME, direction:DESC}) { | |
nodes { | |
publishedAt | |
tag { | |
name | |
target { | |
oid | |
} | |
} | |
} | |
} | |
refs(refPrefix: "refs/tags/", first: 1, orderBy: {field:ALPHABETICAL, direction:DESC}) { | |
nodes { | |
name | |
target { | |
... on Commit { | |
pushedDate | |
} | |
} | |
} | |
} | |
pushedAt | |
} | |
} | |
} | |
} | |
` | |
} | |
function processResults(data) { | |
return { foo: "bar" } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment