From: AJ ONeal Date: Thu, 30 Jul 2020 06:35:34 +0000 (-0600) Subject: hotfix for github release API rate limit token X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=8fa367de83c4ce9e8808e78735a58834ebcc9e74;p=webi-installers%2F.git hotfix for github release API rate limit token --- diff --git a/.gitignore b/.gitignore index 7821601..a1144c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.env node_modules install-*.sh install-*.bat diff --git a/_common/github.js b/_common/github.js index 442b16b..aa98074 100644 --- a/_common/github.js +++ b/_common/github.js @@ -1,5 +1,7 @@ 'use strict'; +require('dotenv').config(); + /** * Gets the releases for 'ripgrep'. This function could be trimmed down and made * for use with any github release. @@ -21,10 +23,20 @@ function getAllReleases( if (!repo) { return Promise.reject('missing repo name'); } - return request({ + + var req = { url: `${baseurl}/repos/${owner}/${repo}/releases`, json: true - }).then((resp) => { + }; + // TODO I really don't like global config, find a way to do better + if (process.env.GITHUB_USERNAME) { + req.auth = { + user: process.env.GITHUB_USERNAME, + pass: process.env.GITHUB_TOKEN + }; + } + + return request(req).then((resp) => { const gHubResp = resp.body; const all = { releases: [], diff --git a/package-lock.json b/package-lock.json index 69f044a..304b4e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,11 @@ "resolved": "https://registry.npmjs.org/@root/request/-/request-1.6.1.tgz", "integrity": "sha512-8wrWyeBLRp7T8J36GkT3RODJ6zYmL0/maWlAUD5LOXT28D3TDquUepyYDKYANNA3Gc8R5ZCgf+AXvSTYpJEWwQ==" }, + "dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" + }, "marked": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/marked/-/marked-1.1.0.tgz", diff --git a/package.json b/package.json index 105bbe4..a6961af 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "homepage": "https://github.com/webinstall/packages#readme", "dependencies": { "@root/request": "^1.6.1", + "dotenv": "^8.2.0", "shmatter": "^1.0.1" } }