# Contributing ### **Table of Contents** - [Getting Started](#getting-started) - [Prerequisites](#prerequisites) - [Text Editor](#text-editor) - [Git](#git) - [NodeJS and NPM](#nodejs-and-npm) - [Firebase](#firebase) - [Mongo Setup](#mongo-setup) - [Building and Running Monkeytype](#building-and-running-monkeytype) - [Standards and Guidelines](#standards-and-guidelines) - [Theme Guidelines](#theme-guidelines) - [Language Guidelines](#language-guidelines) - [Quote Guidelines](#quote-guidelines) - [Questions](#questions) ## Getting Started When contributing to Monkeytype, it's good to know our best practices, tips, and tricks. First, Monkeytype is written in ~~JavaScript~~ TypeScript, CSS, and HTML (in order of language usage within the project); thus, we assume you are comfortable in these languages or have basic knowledge of them. Our backend is in NodeJS and we use MongoDB to store our user data. Firebase is used for authentication. Furthermore, we use Prettier to format our code. ## Prerequisites While most contributions don't require that you install dependencies, there are a few tools you will need to be able to run the project (this is useful and almost always necessary for tasks like creating features and fixing bugs; running the project is also useful if you are contributing a theme and want to view it on the site before you contribute it). You will need a computer with a stable internet connection, a text editor, Git, Firebase, and NodeJS with version 16.13.2. #### Text Editor If you are not a developer and wish to contribute themes, new languages, or quotes, having a text editor will make contributions _much_ easier. To make complex edits without installing anything, we recommend using GitHub's VS Code web editor. In your fork of Monkeytype (fork it first), go to the `Code` tab of the repo and press .(the period/dot key). This will open up the repo in an online VS Code instance you can use to edit files in the browser. Once you are done making your changes, go to the Source Control tab in the activity bar with Ctrl/Cmd + Shift + G, click the `+` next to the files you've changed to stage them, type a brief message summarizing the changes made in the commit, and press Ctrl/Cmd + Enter to commit your changes to your fork. Finally, send a pull request to the Monkeytype repository when you are ready. #### Git Git is optional but we recommend you utilize it. Monkeytype uses the Git source control management (SCM) system for its version control. Assuming you don't have experience typing commands in the command line, we suggest installing [Sourcetree](https://www.sourcetreeapp.com/). You will be able to utilize the power of Git without needing to remember any cryptic commands. Using a Git client such as Sourcetree won't give you access to the full functionality of Git, but provides an easy to understand graphical user interface (GUI). Once you have downloaded Sourcetree, run the installer. While installing Sourcetree, keep your eyes peeled for the option to also install Git with Sourcetree. This is the option you will need to look for in order to install Git. **Make sure to click yes in the installer to install Git with Sourcetree.** #### NodeJS and NPM To install NodeJS, navigate to the NodeJS [website](https://nodejs.org/en/) and download the `16.13.2 LTS`. Alternatively, if you use `nvm` then you can run `nvm install` and `nvm use` (you might need to specify the exact version) to use the version of Node.js in the `.nvmrc` file (if you use Windows, use [nvm-windows](https://github.com/coreybutler/nvm-windows)). #### Firebase 1. Create a Firebase account if you already haven't done so. 1. [Create a new Firebase project.](https://console.firebase.google.com/u/0/) - The project name doesn't matter, but the name `monkeytype` would be preferred. - Google Analytics is not necessary. 1. Run `npm install -g firebase-tools` to install the Firebase Command Line Interface. 1. Run `firebase login` on your terminal to log in to the same google account you just used to create the project. 1. Git clone this project. - IMPORTANT: If you are on Windows, run `git config --global core.autocrlf false` before-hand to prevent CRLF errors. 1. Within the `frontend` directory, duplicate `.firebaserc_example`, rename the new file to `.firebaserc` and change the project name of default to the firebase project id you just created. - If `.firebaserc_example` does not exist after cloning, create your own with: ```.firebaserc { "projects": { "default": "your-firebase-project-id" } } ``` - Run `firebase projects:list` to find your firebase project id. 1. Within the `frontend/src/ts/constants` directory, duplicate `firebase-config-example.ts`, rename it to `firebase-config.ts` and paste in your firebase config - To find it, go to the Firebase console - Navigate to `Project Settings > General > Your apps` - If there are no apps in your project, create a new web app - In the `SDK setup and configuration` section, select `npm` - The Firebase config will be visible below 1. Enable Firebase Authentication (optional) - In the Firebase console, go to `Authentication > Sign-in method` - Click on `Email/Password`, enable it, and save - Click on `Google`, add a support email and save 1. Generate a Firebase Admin private key (optional, only needed if you want to work on the backend) - In your Firebase console, go to Project Settings > Service Accounts - Click "Generate New Private Key" - Save as `serviceAccountKey.json` inside the `backend/credentials/` directory. #### Backend (optional) Follow these steps if you want to work on anything involving the database/account system. Otherwise, you can skip this section. 1. Inside the backend folder, copy `example.env` to `.env` in the same directory. 2. Setup the database server | Local Server | Docker (recommended) | | --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 1. Install [MongoDB Community Edition](https://docs.mongodb.com/manual/administration/install-community/) and ensure that it is running |