freeCodeCamp/tools/contributor/docs
Randell Dawson c8f6d15688
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>
2020-12-22 13:43:36 +09:00
..
CONTRIBUTING.md feat(tool): Add ability to view all open PRs for repos other than freeCodeCamp in the Dashboard app (#40453) 2020-12-22 13:43:36 +09:00
README.md feat(tool): Add ability to view all open PRs for repos other than freeCodeCamp in the Dashboard app (#40453) 2020-12-22 13:43:36 +09:00

README.md

Local Setup

  • Follow the steps below to get this running on your local machine

1. Copy .env

  • Copy the sample.env file into .env. The command below will do that in the terminal if your CWD(current working directory) is the contribute folder.
cp sample.env .env
  • If you do not want to populate the database with the freeCodeCamp PR's you can skip to step 5

2. Update .env

  • Use your GitHub username as the GITHUB_USERNAME variable of the .env file
  • Use your GitHub Personal Access Token as the GITHUB_ACCESS_TOKEN variable of the .env file

3. Run mongoDB

  • Make sure a mongoDB instance is running by running the command below in the terminal.
mongod —dbpath=./database_folder

4. Update the Database

  • Run the command below to populate your local database with PRs from the freeCodeCamp repo. Note that you must have mongoDB running.
node dashboard-app/server/tools/update-db.js
  • This will take a while. If it stops running partway through, it's probably a timeout error. Run the command again and it should finish

5. Start the app in development mode

  • In a new terminal window or tab, run these three commands to start the program. Wait for one command to finish running before starting the next.
npm ci
npm run develop

6. Start the app in production mode

  • In a new terminal window or tab, run these three commands to start the program. Wait for one command to finish running before starting the next.
npm ci
npm run build
npm start

Caveats & Notes

Local Ports when developing locally

Using npm run develop will start both the api server and the Create React App(Dashboard) in development mode. The app server runs on port 3001 and the React app runs on port 3000.

The one-off scripts will error out on actions performed by repository admins

For example, if an admin removes a label from a Pull Request, the script can not add that label back. This is usually because the script is acting on behalf of a non-admin user with write access. This is usually the case with the use of access tokens for scripts.

Setting up Cron jobs for Sweeper Scripts

For updating dashboard data we use PM2 like so:

pm2 start --no-autorestart dashboard-app/server/tools/update-db.js --cron "*/10 * * * *"

This will start the script in the "no restart" mode and re-run it every 10 minutes. A useful link to calculate a Cron expression: https://crontab.guru/every-10-minutes

Starting the express server (via probot)

pm2 start "npm start" --name "contribute-app"

Note: Start only one instance of this app, you can't have multiple probot apps running. Starting multiple instances will crash the app.