mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-22 09:48:06 +00:00
Use GITHUB_TOKEN if you have it
to avoid GitHub ratelimiter while indexing & injecting stargazers
This commit is contained in:
parent
9a8fd9c9d8
commit
5a23121db0
1 changed files with 18 additions and 13 deletions
|
|
@ -128,22 +128,27 @@ async function injectBundles () {
|
|||
|
||||
// re-enable after rate limiter issue is fixed
|
||||
//
|
||||
// async function injectGhStars () {
|
||||
// const Octokit = require('@octokit/rest')
|
||||
// const octokit = new Octokit()
|
||||
async function injectGhStars () {
|
||||
const opts = {}
|
||||
if ('GITHUB_TOKEN' in process.env) {
|
||||
opts.auth = process.env.GITHUB_TOKEN
|
||||
}
|
||||
|
||||
// let { headers, data } = await octokit.repos.get({
|
||||
// owner: 'transloadit',
|
||||
// repo: 'uppy'
|
||||
// })
|
||||
const Octokit = require('@octokit/rest')
|
||||
const octokit = new Octokit(opts)
|
||||
|
||||
// console.log(`${headers['x-ratelimit-remaining']} requests remaining until we hit GitHub ratelimiter`)
|
||||
let { headers, data } = await octokit.repos.get({
|
||||
owner: 'transloadit',
|
||||
repo: 'uppy'
|
||||
})
|
||||
|
||||
// let dstpath = path.join(webRoot, 'themes', 'uppy', 'layout', 'partials', 'generated_stargazers.ejs')
|
||||
// fs.writeFileSync(dstpath, data.stargazers_count, 'utf-8')
|
||||
console.log(`${headers['x-ratelimit-remaining']} requests remaining until we hit GitHub ratelimiter`)
|
||||
|
||||
// console.log(`${data.stargazers_count} stargazers written to '${dstpath}'`)
|
||||
// }
|
||||
let dstpath = path.join(webRoot, 'themes', 'uppy', 'layout', 'partials', 'generated_stargazers.ejs')
|
||||
fs.writeFileSync(dstpath, data.stargazers_count, 'utf-8')
|
||||
|
||||
console.log(`${data.stargazers_count} stargazers written to '${dstpath}'`)
|
||||
}
|
||||
|
||||
async function injectMarkdown () {
|
||||
let sources = {
|
||||
|
|
@ -181,7 +186,7 @@ async function readConfig () {
|
|||
async function inject () {
|
||||
const config = await readConfig()
|
||||
|
||||
// await injectGhStars()
|
||||
await injectGhStars()
|
||||
|
||||
await injectMarkdown()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue