|
| 1 | +# Contributing to Nest |
| 2 | + |
| 3 | +We would love for you to contribute to Nest and help make it even better than it is |
| 4 | +today! As a contributor, here are the guidelines we would like you to follow: |
| 5 | + |
| 6 | +- [Code of Conduct](#coc) |
| 7 | +- [Question or Problem?](#question) |
| 8 | +- [Issues and Bugs](#issue) |
| 9 | +- [Feature Requests](#feature) |
| 10 | +- [Submission Guidelines](#submit) |
| 11 | +- [Coding Rules](#rules) |
| 12 | +- [Commit Message Guidelines](#commit) |
| 13 | + <!-- - [Signing the CLA](#cla) --> |
| 14 | + |
| 15 | +<!-- ## <a name="coc"></a> Code of Conduct |
| 16 | +Help us keep Nest open and inclusive. Please read and follow our [Code of Conduct][coc]. --> |
| 17 | + |
| 18 | +## <a name="question"></a> Got a Question or Problem? |
| 19 | + |
| 20 | +**Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests.** You've got much better chances of getting your question answered on [Stack Overflow](https://stackoverflow.com/questions/tagged/nestjs) where the questions should be tagged with tag `nestjs`. |
| 21 | + |
| 22 | +Stack Overflow is a much better place to ask questions since: |
| 23 | + |
| 24 | +<!-- - there are thousands of people willing to help on Stack Overflow [maybe one day] --> |
| 25 | + |
| 26 | +- questions and answers stay available for public viewing so your question / answer might help someone else |
| 27 | +- Stack Overflow's voting system assures that the best answers are prominently visible. |
| 28 | + |
| 29 | +To save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow. |
| 30 | + |
| 31 | +If you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter]. |
| 32 | + |
| 33 | +## <a name="issue"></a> Found a Bug? |
| 34 | + |
| 35 | +If you find a bug in the source code, you can help us by |
| 36 | +[submitting an issue](#submit-issue) to our [GitHub Repository][github]. Even better, you can |
| 37 | +[submit a Pull Request](#submit-pr) with a fix. |
| 38 | + |
| 39 | +## <a name="feature"></a> Missing a Feature? |
| 40 | + |
| 41 | +You can _request_ a new feature by [submitting an issue](#submit-issue) to our GitHub |
| 42 | +Repository. If you would like to _implement_ a new feature, please submit an issue with |
| 43 | +a proposal for your work first, to be sure that we can use it. |
| 44 | +Please consider what kind of change it is: |
| 45 | + |
| 46 | +- For a **Major Feature**, first open an issue and outline your proposal so that it can be |
| 47 | + discussed. This will also allow us to better coordinate our efforts, prevent duplication of work, |
| 48 | + and help you to craft the change so that it is successfully accepted into the project. For your issue name, please prefix your proposal with `[discussion]`, for example "[discussion]: your feature idea". |
| 49 | +- **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr). |
| 50 | + |
| 51 | +## <a name="submit"></a> Submission Guidelines |
| 52 | + |
| 53 | +### <a name="submit-issue"></a> Submitting an Issue |
| 54 | + |
| 55 | +Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available. |
| 56 | + |
| 57 | +We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. In order to reproduce bugs we will systematically ask you to provide a minimal reproduction scenario using a repository or [Gist](https://gist.github.com/). Having a live, reproducible scenario gives us wealth of important information without going back & forth to you with additional questions like: |
| 58 | + |
| 59 | +- version of NestJS used |
| 60 | +- 3rd-party libraries and their versions |
| 61 | +- and most importantly - a use-case that fails |
| 62 | + |
| 63 | +<!-- |
| 64 | +// TODO we need to create a playground, similar to plunkr |
| 65 | +
|
| 66 | +A minimal reproduce scenario using a repository or Gist allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem. If neither of these are not a suitable way to demonstrate the problem (for example for issues related to our npm packaging), please create a standalone git repository demonstrating the problem. --> |
| 67 | + |
| 68 | +<!-- We will be insisting on a minimal reproduce scenario in order to save maintainers time and ultimately be able to fix more bugs. Interestingly, from our experience users often find coding problems themselves while preparing a minimal plunk. We understand that sometimes it might be hard to extract essentials bits of code from a larger code-base but we really need to isolate the problem before we can fix it. --> |
| 69 | + |
| 70 | +Unfortunately, we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you we are going to close an issue that don't have enough info to be reproduced. |
| 71 | + |
| 72 | +You can file new issues by filling out our [new issue form](https://github.com/nestjs/nest/issues/new). |
| 73 | + |
| 74 | +### <a name="submit-pr"></a> Submitting a Pull Request (PR) |
| 75 | + |
| 76 | +Before you submit your Pull Request (PR) consider the following guidelines: |
| 77 | + |
| 78 | +1. Search [GitHub](https://github.com/nestjs/nest/pulls) for an open or closed PR |
| 79 | + that relates to your submission. You don't want to duplicate effort. |
| 80 | + <!-- 1. Please sign our [Contributor License Agreement (CLA)](#cla) before sending PRs. |
| 81 | + We cannot accept code without this. --> |
| 82 | +1. Fork the nestjs/nest repo. |
| 83 | +1. Make your changes in a new git branch: |
| 84 | + |
| 85 | + ```shell |
| 86 | + git checkout -b my-fix-branch master |
| 87 | + ``` |
| 88 | + |
| 89 | +1. Create your patch, **including appropriate test cases**. |
| 90 | +1. Follow our [Coding Rules](#rules). |
| 91 | +1. Run the full Nest test suite, as described in the [developer documentation][dev-doc], |
| 92 | + and ensure that all tests pass. |
| 93 | +1. Commit your changes using a descriptive commit message that follows our |
| 94 | + [commit message conventions](#commit). Adherence to these conventions |
| 95 | + is necessary because release notes are automatically generated from these messages. |
| 96 | + |
| 97 | + ```shell |
| 98 | + git commit -a |
| 99 | + ``` |
| 100 | + |
| 101 | + Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files. |
| 102 | + |
| 103 | +1. Push your branch to GitHub: |
| 104 | + |
| 105 | + ```shell |
| 106 | + git push origin my-fix-branch |
| 107 | + ``` |
| 108 | + |
| 109 | +1. In GitHub, send a pull request to `nestjs:master`. |
| 110 | + |
| 111 | +- If we suggest changes then: |
| 112 | + |
| 113 | + - Make the required updates. |
| 114 | + - Re-run the Nest test suites to ensure tests are still passing. |
| 115 | + - Rebase your branch and force push to your GitHub repository (this will update your Pull Request): |
| 116 | + |
| 117 | + ```shell |
| 118 | + git rebase master -i |
| 119 | + git push -f |
| 120 | + ``` |
| 121 | + |
| 122 | +That's it! Thank you for your contribution! |
| 123 | +
|
| 124 | +#### After your pull request is merged |
| 125 | +
|
| 126 | +After your pull request is merged, you can safely delete your branch and pull the changes |
| 127 | +from the main (upstream) repository: |
| 128 | +
|
| 129 | +- Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows: |
| 130 | +
|
| 131 | + ```shell |
| 132 | + git push origin --delete my-fix-branch |
| 133 | + ``` |
| 134 | +
|
| 135 | +- Check out the master branch: |
| 136 | +
|
| 137 | + ```shell |
| 138 | + git checkout master -f |
| 139 | + ``` |
| 140 | +
|
| 141 | +- Delete the local branch: |
| 142 | +
|
| 143 | + ```shell |
| 144 | + git branch -D my-fix-branch |
| 145 | + ``` |
| 146 | +
|
| 147 | +- Update your master with the latest upstream version: |
| 148 | +
|
| 149 | + ```shell |
| 150 | + git pull --ff upstream master |
| 151 | + ``` |
| 152 | +
|
| 153 | +## <a name="rules"></a> Coding Rules |
| 154 | +
|
| 155 | +To ensure consistency throughout the source code, keep these rules in mind as you are working: |
| 156 | +
|
| 157 | +- All features or bug fixes **must be tested** by one or more specs (unit-tests). |
| 158 | + <!-- |
| 159 | + // We're working on auto-documentation. |
| 160 | +- All public API methods **must be documented**. (Details TBC). --> |
| 161 | +- We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at |
| 162 | + **100 characters**. An automated formatter is available, see |
| 163 | + [DEVELOPER.md](docs/DEVELOPER.md#clang-format). |
| 164 | +
|
| 165 | +## <a name="commit"></a> Commit Message Guidelines |
| 166 | +
|
| 167 | +We have very precise rules over how our git commit messages can be formatted. This leads to **more |
| 168 | +readable messages** that are easy to follow when looking through the **project history**. But also, |
| 169 | +we use the git commit messages to **generate the Nest change log**. |
| 170 | +
|
| 171 | +### Commit Message Format |
| 172 | +
|
| 173 | +Each commit message consists of a **header**, a **body** and a **footer**. The header has a special |
| 174 | +format that includes a **type**, a **scope** and a **subject**: |
| 175 | +
|
| 176 | +``` |
| 177 | +<type>(<scope>): <subject> |
| 178 | +<BLANK LINE> |
| 179 | +<body> |
| 180 | +<BLANK LINE> |
| 181 | +<footer> |
| 182 | +``` |
| 183 | +
|
| 184 | +The **header** is mandatory and the **scope** of the header is optional. |
| 185 | +
|
| 186 | +Any line of the commit message cannot be longer 100 characters! This allows the message to be easier |
| 187 | +to read on GitHub as well as in various git tools. |
| 188 | +
|
| 189 | +Footer should contain a [closing reference to an issue](https://help.github.com/articles/closing-issues-via-commit-messages/) if any. |
| 190 | +
|
| 191 | +Samples: (even more [samples](https://github.com/nestjs/nest/commits/master)) |
| 192 | +
|
| 193 | +``` |
| 194 | +docs(changelog) update change log to beta.5 |
| 195 | +``` |
| 196 | +
|
| 197 | +``` |
| 198 | +bugfix(@nestjs/core) need to depend on latest rxjs and zone.js |
| 199 | +
|
| 200 | +The version in our package.json gets copied to the one we publish, and users need the latest of these. |
| 201 | +``` |
| 202 | +
|
| 203 | +### Revert |
| 204 | +
|
| 205 | +If the commit reverts a previous commit, it should begin with `revert:`, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted. |
| 206 | +
|
| 207 | +### Type |
| 208 | +
|
| 209 | +Must be one of the following: |
| 210 | +
|
| 211 | +- **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) |
| 212 | +- **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) |
| 213 | +- **docs**: Documentation only changes |
| 214 | +- **feature**: A new feature |
| 215 | +- **bugfix**: A bug fix |
| 216 | +- **perf**: A code change that improves performance |
| 217 | +- **refactor**: A code change that neither fixes a bug nor adds a feature |
| 218 | +- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) |
| 219 | +- **test**: Adding missing tests or correcting existing tests |
| 220 | +
|
| 221 | +### Subject |
| 222 | +
|
| 223 | +The subject contains succinct description of the change: |
| 224 | +
|
| 225 | +- use the imperative, present tense: "change" not "changed" nor "changes" |
| 226 | +- don't capitalize first letter |
| 227 | +- no dot (.) at the end |
| 228 | + |
| 229 | +### Body |
| 230 | + |
| 231 | +Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". |
| 232 | +The body should include the motivation for the change and contrast this with previous behavior. |
| 233 | + |
| 234 | +### Footer |
| 235 | + |
| 236 | +The footer should contain any information about **Breaking Changes** and is also the place to |
| 237 | +reference GitHub issues that this commit **Closes**. |
| 238 | + |
| 239 | +**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this. |
| 240 | + |
| 241 | +A detailed explanation can be found in this [document][commit-message-format]. |
| 242 | + |
| 243 | +<!-- ## <a name="cla"></a> Signing the CLA |
| 244 | + |
| 245 | +Please sign our Contributor License Agreement (CLA) before sending pull requests. For any code |
| 246 | +changes to be accepted, the CLA must be signed. It's a quick process, we promise! |
| 247 | +
|
| 248 | +* For individuals we have a [simple click-through form][individual-cla]. |
| 249 | +* For corporations we'll need you to |
| 250 | + [print, sign and one of scan+email, fax or mail the form][corporate-cla]. --> |
| 251 | + |
| 252 | +<!-- [angular-group]: https://groups.google.com/forum/#!forum/angular --> |
| 253 | +<!-- [coc]: https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md --> |
| 254 | + |
| 255 | +[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit# |
| 256 | +[corporate-cla]: http://code.google.com/legal/corporate-cla-v1.0.html |
| 257 | +[dev-doc]: https://github.com/nestjs/nest/blob/master/docs/DEVELOPER.md |
| 258 | +[github]: https://github.com/nestjs/nest |
| 259 | +[gitter]: https://gitter.im/nestjs/nest |
| 260 | +[individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html |
| 261 | +[js-style-guide]: https://google.github.io/styleguide/jsguide.html |
| 262 | +[jsfiddle]: http://jsfiddle.net |
| 263 | +[plunker]: http://plnkr.co/edit |
| 264 | +[runnable]: http://runnable.com |
| 265 | + |
| 266 | +<!-- [stackoverflow]: http://stackoverflow.com/questions/tagged/angular --> |
0 commit comments