From cdd205f3e60c17e7028a167fa065fc20e385cbb2 Mon Sep 17 00:00:00 2001 From: Edward Badel Date: Sun, 27 Jun 2021 01:16:40 -0400 Subject: [PATCH] Github API fixes --- gulp/contributors.js | 27 ++++++++++++++++++++------- gulp/gulpfile.js | 21 ++++----------------- src/js/states/credits.js | 4 +++- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/gulp/contributors.js b/gulp/contributors.js index 0fc30897..3d5b5d7c 100644 --- a/gulp/contributors.js +++ b/gulp/contributors.js @@ -1,13 +1,20 @@ const fs = require("fs"); const fsp = require("fs/promises"); const path = require("path"); -const fetch = require("node-fetch"); +const nodeFetch = require("node-fetch"); const APILink = "https://api.github.com/repos/tobspr/shapez.io"; const numOfReqPerPage = 100; // Max is 100, change to something lower if loads are too long +const personalAccessToken = " res.json()) @@ -55,6 +61,7 @@ function PRIsTranslation(link) { console.log("GITHUB HAS RATE-LIMITED THIS MACHINE, PLEASE WAIT ABOUT AN HOUR"); throw new Error("rate-limit reached"); } + console.log(res); for (let file of res) { if (!file.filename.startsWith("translations/")) return false; } @@ -89,16 +96,16 @@ function reqPage(page) { .then(async res => { const prs = []; - for (let i = 0; i < res.length - 1; i++) { - if (!res[i].merged_at) continue; // Skip files that were never merged + for (let i = 0; i < res.length; i++) { + if (!res[i].merged_at) { + continue; + } // Skip files that were never merged const prInfo = { username: res[i].user.login, html_url: res[i].html_url, url: res[i].url, - user_avatar: res[i].user.avatar_url, title: res[i].title, - time: res[i].createdAt, }; prs.push(prInfo); @@ -119,7 +126,7 @@ async function downloadAllPrs() { const prs = []; - for (let i = 0; i < numOfPageReqs; i++) { + for (let i = 1; i < numOfPageReqs + 1; i++) { prs.push(...(await reqPage(i))); // Yes promise.all would be good, but I wanna keep them in order (at least for now) } @@ -149,6 +156,12 @@ async function updateContributors() { function gulpTaskContributors($, gulp) { gulp.task("contributors.build", cb => tryToUpdateContributors().then(() => cb)); gulp.task("contributors.build.force", cb => updateContributors().then(() => cb)); + + gulp.task("fetch.test", cb => { + fetch(APILink) + .then(res => console.log(res.headers.get("x-ratelimit-remaining"))) + .then(cb); + }); } module.exports = { diff --git a/gulp/gulpfile.js b/gulp/gulpfile.js index 5aecbbcc..63ff23ea 100644 --- a/gulp/gulpfile.js +++ b/gulp/gulpfile.js @@ -254,7 +254,6 @@ gulp.task( "imgres.copyImageResources", "imgres.copyNonImageResources", "translations.fullBuild", - "contributors.build", "css.dev", "html.dev" ) @@ -273,17 +272,13 @@ gulp.task( "imgres.copyImageResources", "imgres.copyNonImageResources", "translations.fullBuild", - "contributors.build", "css.dev", "html.standalone-dev" ) ); // Builds everything (staging) -gulp.task( - "step.staging.code", - gulp.series("sounds.fullbuild", "translations.fullBuild", "contributors.build", "js.staging") -); +gulp.task("step.staging.code", gulp.series("sounds.fullbuild", "translations.fullBuild", "js.staging")); gulp.task( "step.staging.mainbuild", gulp.parallel("utils.copyAdditionalBuildFiles", "step.baseResources", "step.staging.code") @@ -292,10 +287,7 @@ gulp.task("step.staging.all", gulp.series("step.staging.mainbuild", "css.prod", gulp.task("build.staging", gulp.series("utils.cleanup", "step.staging.all", "step.postbuild")); // Builds everything (prod) -gulp.task( - "step.prod.code", - gulp.series("sounds.fullbuild", "translations.fullBuild", "contributors.build", "js.prod") -); +gulp.task("step.prod.code", gulp.series("sounds.fullbuild", "translations.fullBuild", "js.prod")); gulp.task( "step.prod.mainbuild", gulp.parallel("utils.copyAdditionalBuildFiles", "step.baseResources", "step.prod.code") @@ -306,7 +298,7 @@ gulp.task("build.prod", gulp.series("utils.cleanup", "step.prod.all", "step.post // Builds everything (standalone-beta) gulp.task( "step.standalone-beta.code", - gulp.series("sounds.fullbuildHQ", "translations.fullBuild", "contributors.build", "js.standalone-beta") + gulp.series("sounds.fullbuildHQ", "translations.fullBuild", "js.standalone-beta") ); gulp.task("step.standalone-beta.mainbuild", gulp.parallel("step.baseResources", "step.standalone-beta.code")); gulp.task( @@ -323,12 +315,7 @@ gulp.task( for (const prefix of ["", "china.", "wegame."]) { gulp.task( prefix + "step.standalone-prod.code", - gulp.series( - "sounds.fullbuildHQ", - "translations.fullBuild", - "contributors.build", - prefix + "js.standalone-prod" - ) + gulp.series("sounds.fullbuildHQ", "translations.fullBuild", prefix + "js.standalone-prod") ); gulp.task( diff --git a/src/js/states/credits.js b/src/js/states/credits.js index b3de92d3..be577fe1 100644 --- a/src/js/states/credits.js +++ b/src/js/states/credits.js @@ -35,7 +35,9 @@ export class CreditsState extends TextualGameState {
Contributors:
-
Loading...
+
+ ${this.getContributorsHTML()} +
`; }