* 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>
70 lines
1.9 KiB
JavaScript
70 lines
1.9 KiB
JavaScript
/*
|
|
This is a one-off script to run on all open PRs to add the
|
|
"status: need to test locally" label to any PR with an existing
|
|
"scope: learn" label on it.
|
|
*/
|
|
|
|
const {
|
|
github: { freeCodeCampRepo, defaultBase },
|
|
oneoff: { productionRun }
|
|
} = require('../lib/config');
|
|
|
|
const { getPRs, getUserInput } = require('../lib/get-prs');
|
|
const { addLabels } = require('../lib/pr-tasks');
|
|
const { rateLimiter, ProcessingLog } = require('../lib/utils');
|
|
|
|
const log = new ProcessingLog('all-locally-tested-labels');
|
|
|
|
(async () => {
|
|
const { totalPRs, firstPR, lastPR } = await getUserInput(
|
|
freeCodeCampRepo,
|
|
defaultBase
|
|
);
|
|
const prPropsToGet = ['number', 'labels'];
|
|
const { openPRs } = await getPRs(
|
|
freeCodeCampRepo,
|
|
defaultBase,
|
|
totalPRs,
|
|
firstPR,
|
|
lastPR,
|
|
prPropsToGet
|
|
);
|
|
|
|
if (openPRs.length) {
|
|
log.start();
|
|
console.log('Starting labeling process...');
|
|
for (let count = 0; count < openPRs.length; count++) {
|
|
let { number, labels } = openPRs[count];
|
|
// holds potential labels to add based on file path
|
|
const labelsToAdd = {};
|
|
const existingLabels = labels.map(({ name }) => name);
|
|
if (existingLabels.includes('scope: learn')) {
|
|
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) {
|
|
log.add(number, { number, labels: newLabels });
|
|
if (productionRun) {
|
|
addLabels(number, newLabels, log);
|
|
await rateLimiter();
|
|
}
|
|
} else {
|
|
log.add(number, { number, labels: 'none added' });
|
|
}
|
|
}
|
|
}
|
|
})()
|
|
.then(() => {
|
|
log.finish();
|
|
console.log('Successfully completed labeling');
|
|
})
|
|
.catch(err => {
|
|
log.finish();
|
|
console.log(err);
|
|
});
|