feat(tool): Add ability to view all open PRs for repos other than freeCodeCamp in the Dashboard app (#40453)

* feat: show open boilerplate prs on dashboard

fix:  rest of boilerplate server changes

fix: more

fix: other

* fix: update lib functions

* fix: retrofitted one-off scripts

* feat: added rateLimit for requests

* fix: reduce time

* fix: put limiter inside each route

* fix: make client show when rated limited

* fix: removed unused probot from app

* fix: renamed folders

* fix: consolidate config.js and constants.js

* chore: update octokit to latest version

* fix: remove invalid file

* fix: refactored update-db.js

* feat: add fcc logo

* fix: logo url

* fix: remove Home link

* fix: change link colors

* fix: added rate limiter to landing page

* fix: ran npm install in client to create package-lock.json

* fix: correct typo in doc

Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>

* fix: Replace favicon, Gitter => Discord

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

* fix: add extra linting guidance to package.json

* Ignore contributor app

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

* fix: revert linting rules for client

* fix: add skip_preflight_check=true for tests

Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Kris Koishigawa <scissorsneedfoodtoo@gmail.com>
Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
This commit is contained in:
Randell Dawson
2020-12-21 21:43:36 -07:00
committed by GitHub
parent 8324a5fcd7
commit c8f6d15688
114 changed files with 12956 additions and 15348 deletions

View File

@@ -0,0 +1,46 @@
const config = require('../../lib/config');
const { validLabels } = require('../validation');
const { addLabels } = require('./add-labels');
const { rateLimiter } = require('../utils');
const labeler = async (number, prFiles, currentLabels) => {
// holds potential labels to add based on file path
const labelsToAdd = {};
const existingLabels = currentLabels.map(({ name }) => name);
prFiles.forEach(({ filename }) => {
/* remove '/challenges' from filename so
language variable hold the language */
const filenameReplacement = filename.replace(
/^curriculum\/challenges\//,
'curriculum/'
);
const regex = /^(docs|curriculum)(?:\/)(english|arabic|chinese|portuguese|russian|spanish)?\/?/;
// need an array to pass to labelsAdder
const match = filenameReplacement.match(regex) || [];
const articleType = match[1];
const language = match[2];
if (articleType && validLabels[articleType]) {
labelsToAdd[validLabels[articleType]] = 1;
}
if (language && validLabels[language]) {
labelsToAdd[validLabels[language]] = 1;
}
if (articleType === 'curriculum') {
labelsToAdd['status: need to test locally'] = 1;
}
});
// only adds needed labels which are NOT currently on the PR
const newLabels = Object.keys(labelsToAdd).filter(label => {
return !existingLabels.includes(label);
});
if (newLabels.length) {
if (config.oneoff.productionRun) {
addLabels(number, newLabels);
await rateLimiter(1000);
}
}
return newLabels;
};
module.exports = { labeler };