monkeytype/CONTRIBUTING.md

153 lines
9.5 KiB
Markdown
Raw Normal View History

2020-09-15 22:28:15 +08:00
# Contributing
### **Table of Contents**
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
2021-07-13 06:17:12 +08:00
- [Text Editor](#text-editor)
- [Git](#git)
- [NodeJS and NPM](#nodejs-and-npm)
2021-07-13 06:17:12 +08:00
- [Firebase](#firebase)
- [Mongo Setup](#mongo-setup)
- [Building and Running Monkeytype](#building-and-running-monkeytype)
- [Standards and Guidelines](#standards-and-guidelines)
2021-07-13 06:17:12 +08:00
- [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.
2021-09-29 08:48:42 +08:00
## Prerequisites
2021-07-13 06:17:12 +08:00
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 <kbd>.</kbd>(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 <kbd>Ctrl/Cmd + Shift + G</kbd>, 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 <kbd>Ctrl/Cmd + Enter</kbd> to commit your changes to your fork. Finally, send a pull request to the Monkeytype repository when you are ready.
2021-07-13 06:17:12 +08:00
#### 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
2021-07-13 06:17:12 +08:00
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.
#### Mongo Setup
Follow these steps if you want to work on anything involving the database/account system. Otherwise, you can skip this section.
1. Install [MongoDB Community Edition](https://docs.mongodb.com/manual/administration/install-community/) and ensure that it is running
1. Inside the backend folder, copy `example.env` to `.env` in the same directory.
1. If necessary, uncomment the lines in the `.env` file to use credentials to login to MongoDB.
1. Optional - Install [MongoDB-compass](https://www.mongodb.com/try/download/compass?tck=docs_compass). This tool can be used to see and manipulate your data visually.
1. To connect, type `mongodb://localhost:27017` in the connection string box and press connect. The monkeytype database will be created and shown after the server is started.
2021-03-12 01:08:12 +08:00
2021-09-29 08:48:42 +08:00
## Building and Running Monkeytype
2021-07-13 06:17:12 +08:00
Once you have completed the above steps, you are ready to build and run Monkeytype.
1. Run `npm run install:all` in the project root to install all dependencies.
- If you are on Windows, use `npm run install:windows`.
- If neither works, you will have to run `npm install` in root, frontend, and backend directories.
v1.14.1 (#2745) * updated default config to fix incorrect font button being highlighted * Convert account controller to ts (#2731) * using modular sdk * removing last script * replacing more code * unused code * removed unused code * removed unused code * importing auth * using analytics controller * importing auth and analytics * importing auth * updated git ignore * fixed path * removed live config from gitignore * added error message when failing to initialize firebase * added live config using live config when building production * removed unused code * fixed incorrect function use * added example config * added a step to the contributing guide * optional steps * fixed path * using example in source code so that github actions dont cry like little babies * using function correctly * using function correctly * ignoring live * removed * added action webpack config * bruce said "no-no" This reverts commit 0a1e5e1660200fe30378d36cb6778772e2f79cc8. * Fix * Add ignore * updated instructions * using correct functions * using correct function * missing parameter * using correct function * using correct function * removed ts ignores * using new functions * removed refresh * using new functions * merge fix * fixed merge * regenereated lockfile * using correct function * defaulting to the email thats already entered * storing default snap in a file * optional parameter * made parameters non optional * converted file to ts * removed unused parameters * removed unnecessary optional chaining * destructuring array * added a function to create error message * removed type * removed duplicate gitignore * removed no check Co-authored-by: Bruception <bberr022@fiu.edu> * Include dev branch in CI (#2739) * Decreased filesize and introduced chunk splitting (#2732) Rizwanmustafa * Decreased filesize * Introduce splitting for vendors * Added HTML webpack plugin for dynamic change of chunkhash and minification on production * Added bundle analyzer plugin for webpack * Prevent analyzer from opening on its own * updated contributors list * Package lock update * Created separate webpack config for analysing bundle * Standardize paths in webpack base config * Added devtool in dev webpack config * Minor issues * Based audit config off of the production config, saved exact packages and renamed some constants * Saved exact version of packages * Rename Config * Added intellisense for webpack configs * Added script for using audit config * Simple changes * Removed unnecessary cd and replaced webpack with npx wepback * added npm script accessible from root dir since audit is now a separate script, reenabled auto opening Co-authored-by: Miodec <bartnikjack@gmail.com> * Enable live reloading (#2738) bruception * Enable live reloading * Update scripts and documentation * Fix resolve * Use resolve * Fix layoutfluid timer warnings (#2740) Ferotiq * reduced date-fns import size * using inline source map so that code is debuggable * removed tinycolor2 dependency * Migrate Chart.js to 3.7.1 (#2735) DanGonite57 * Migrate Chart.js to 3.7.1 * Show funbox label with StartGraphsAtZero disabled * Fix label positioners * Include dev branch in CI (#2739) * Remove draw animation * Avoid RangeError with no data * Disable account chart initial render animation * Add temporary type assertion for options.animation * Test disabling animations via updateColors * Test re-update chart after resetting animation duration * Test dataset specific animation duration * Disable animations for now * Remove unused annotation Co-authored-by: Bruce Berrios <58147810+Bruception@users.noreply.github.com> * installed dev dependency to stop audit from complaining * removed mr mime dev dependency regenerate package-lock * not updating live burst when its disabled * using vanilla js to increase performance * updating chart once instead of 3 times * made log async * increased minimum wordset length to disable repeating words to 4 this stops infinite A B C sequences closes #2742 * increased tick padding * added some padding to stop data points from being cut off * fixed account graphs not being responsive * removed unnecessary style * updated button active color * Server version (#2746) Bruception * Add server version * typo * Fix logic * Moved to utility * Actually save version * Move logic order * updated metric name * removed unnecessary else Co-authored-by: Bruception <bberr022@fiu.edu> Co-authored-by: Bruce Berrios <58147810+Bruception@users.noreply.github.com> Co-authored-by: Rizwan Mustafa <rizwanmustafa0000@gmail.com> Co-authored-by: Evan <64989416+Ferotiq@users.noreply.github.com> Co-authored-by: DanGonite57 <danzinc57@gmail.com>
2022-03-22 04:22:47 +08:00
2. Run `npm run dev` (`npm run dev:fe` if you skipped the mongo section) to start a local dev server on [port 5000](http://localhost:5000). It will watch for changes and rebuild when you edit files in `src/` or `public/` directories. Note that rebuilding doesn't happen instantaneously so be patient for changes to appear. Use <kbd>Ctrl+C</kbd> to kill it.
2022-01-29 21:41:42 +08:00
**Mac Users:** If you get 403 Forbidden errors while trying to access the local server, go into System Preferences > Sharing and disable AirPlay Receiver - it also runs on port 5000 and takes priority, causing 403 errors.
2021-09-29 08:48:42 +08:00
## Standards and Guidelines
Code style is enforced by [Prettier](https://prettier.io/docs/en/install.html), which automatically runs every time you make a commit (`git commit`) (if you've followed the above instructions properly).
We recommend following the guidelines below to increase your chances of getting your change accepted.
#### Theme Guidelines
2021-07-13 06:17:12 +08:00
<!-- TODO: add screenshots to provide examples for dos and don'ts -->
2021-07-13 06:17:12 +08:00
2021-10-07 21:30:52 +08:00
Before submitting a theme make sure...
2021-09-29 08:44:41 +08:00
- your theme is unique and isn't visually similar to any we already have.
- the text color is either black or white (or very close to these colors)
- your theme has been added to the `_list` file and the `textColor` property is the theme's main color
- your theme is clear and readable with both `flip test colors` and `colorful mode` enabled and disabled
(If you want to contribute themes but don't know how, check [THEMES.md](./THEMES.md))
#### Language Guidelines
2021-07-13 06:17:12 +08:00
- Do not include swear words
- Ensure that your contribution meets JSON standards (no trailing comma at the end of a list)
- Be sure to add your language to the `_list` and `_groups` files
- Make sure the number of words in the file corresponds to the file name (for example: `languageName.json` is 200 words, `languageName_1k.json` is 1000 words, and so on)
(If you want to contribute languages but don't know how, check [LANGUAGES.md](./LANGUAGES.md))
#### Quote Guidelines
- Do not include content that contains any libelous or otherwise unlawful, abusive or obscene text.
- Ensure that your contribution meets JSON standards (no trailing comma at the end of a list)
- Verify quotes added aren't duplicates of any already present
- Verify the `length` property is correct (length of the text in characters)
- Verify the `id` property is incremented correctly
- Please do not add extremely short quotes (less than 60 characters)
(If you want to contribute quotes but don't know how, check [QUOTES.md](./QUOTES.md))
2022-03-19 22:27:59 +08:00
2020-09-15 22:28:15 +08:00
## Questions
If you have any questions, comments, concerns, or problems let me know on [GitHub](https://github.com/Miodec), [Discord](https://discord.gg/monkeytype) in the `#development` channel, or ask a question on Monkeytype's [GitHub discussions](https://github.com/monkeytypegame/monkeytype/discussions) and a contributor will be happy to assist you.