|
| 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 | +- questions and answers stay available for public viewing so your question / answer might help someone else |
| 26 | +- Stack Overflow's voting system assures that the best answers are prominently visible. |
| 27 | + |
| 28 | +To save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow. |
| 29 | + |
| 30 | +If you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter]. |
| 31 | + |
| 32 | +## <a name="issue"></a> Found a Bug? |
| 33 | +If you find a bug in the source code, you can help us by |
| 34 | +[submitting an issue](#submit-issue) to our [GitHub Repository][github]. Even better, you can |
| 35 | +[submit a Pull Request](#submit-pr) with a fix. |
| 36 | + |
| 37 | +## <a name="feature"></a> Missing a Feature? |
| 38 | +You can *request* a new feature by [submitting an issue](#submit-issue) to our GitHub |
| 39 | +Repository. If you would like to *implement* a new feature, please submit an issue with |
| 40 | +a proposal for your work first, to be sure that we can use it. |
| 41 | +Please consider what kind of change it is: |
| 42 | + |
| 43 | +* For a **Major Feature**, first open an issue and outline your proposal so that it can be |
| 44 | +discussed. This will also allow us to better coordinate our efforts, prevent duplication of work, |
| 45 | +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". |
| 46 | +* **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr). |
| 47 | + |
| 48 | +## <a name="submit"></a> Submission Guidelines |
| 49 | + |
| 50 | +### <a name="submit-issue"></a> Submitting an Issue |
| 51 | + |
| 52 | +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. |
| 53 | + |
| 54 | +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: |
| 55 | + |
| 56 | +- version of NestJS used |
| 57 | +- 3rd-party libraries and their versions |
| 58 | +- and most importantly - a use-case that fails |
| 59 | + |
| 60 | +<!-- |
| 61 | +// TODO we need to create a playground, similar to plunkr |
| 62 | +
|
| 63 | +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. --> |
| 64 | + |
| 65 | +<!-- 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. --> |
| 66 | + |
| 67 | +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. |
| 68 | + |
| 69 | +You can file new issues by filling out our [new issue form](https://github.com/nestjs/nest/issues/new). |
| 70 | + |
| 71 | + |
| 72 | +### <a name="submit-pr"></a> Submitting a Pull Request (PR) |
| 73 | +Before you submit your Pull Request (PR) consider the following guidelines: |
| 74 | + |
| 75 | +1. Search [GitHub](https://github.com/nestjs/nest/pulls) for an open or closed PR |
| 76 | + that relates to your submission. You don't want to duplicate effort. |
| 77 | +<!-- 1. Please sign our [Contributor License Agreement (CLA)](#cla) before sending PRs. |
| 78 | + We cannot accept code without this. --> |
| 79 | +1. Fork the nestjs/nest repo. |
| 80 | +1. Make your changes in a new git branch: |
| 81 | + |
| 82 | + ```shell |
| 83 | + git checkout -b my-fix-branch master |
| 84 | + ``` |
| 85 | + |
| 86 | +1. Create your patch, **including appropriate test cases**. |
| 87 | +1. Follow our [Coding Rules](#rules). |
| 88 | +1. Run the full Nest test suite, as described in the [developer documentation][dev-doc], |
| 89 | + and ensure that all tests pass. |
| 90 | +1. Commit your changes using a descriptive commit message that follows our |
| 91 | + [commit message conventions](#commit). Adherence to these conventions |
| 92 | + is necessary because release notes are automatically generated from these messages. |
| 93 | + |
| 94 | + ```shell |
| 95 | + git commit -a |
| 96 | + ``` |
| 97 | + Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files. |
| 98 | + |
| 99 | +1. Push your branch to GitHub: |
| 100 | + |
| 101 | + ```shell |
| 102 | + git push origin my-fix-branch |
| 103 | + ``` |
| 104 | + |
| 105 | +1. In GitHub, send a pull request to `nestjs:master`. |
| 106 | +* If we suggest changes then: |
| 107 | + * Make the required updates. |
| 108 | + * Re-run the Nest test suites to ensure tests are still passing. |
| 109 | + * Rebase your branch and force push to your GitHub repository (this will update your Pull Request): |
| 110 | + |
| 111 | + ```shell |
| 112 | + git rebase master -i |
| 113 | + git push -f |
| 114 | + ``` |
| 115 | + |
| 116 | +That's it! Thank you for your contribution! |
| 117 | +
|
| 118 | +#### After your pull request is merged |
| 119 | +
|
| 120 | +After your pull request is merged, you can safely delete your branch and pull the changes |
| 121 | +from the main (upstream) repository: |
| 122 | +
|
| 123 | +* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows: |
| 124 | +
|
| 125 | + ```shell |
| 126 | + git push origin --delete my-fix-branch |
| 127 | + ``` |
| 128 | +
|
| 129 | +* Check out the master branch: |
| 130 | +
|
| 131 | + ```shell |
| 132 | + git checkout master -f |
| 133 | + ``` |
| 134 | +
|
| 135 | +* Delete the local branch: |
| 136 | +
|
| 137 | + ```shell |
| 138 | + git branch -D my-fix-branch |
| 139 | + ``` |
| 140 | +
|
| 141 | +* Update your master with the latest upstream version: |
| 142 | +
|
| 143 | + ```shell |
| 144 | + git pull --ff upstream master |
| 145 | + ``` |
| 146 | +
|
| 147 | +## <a name="rules"></a> Coding Rules |
| 148 | +To ensure consistency throughout the source code, keep these rules in mind as you are working: |
| 149 | +
|
| 150 | +* All features or bug fixes **must be tested** by one or more specs (unit-tests). |
| 151 | +<!-- |
| 152 | +// We're working on auto-documentation. |
| 153 | +* All public API methods **must be documented**. (Details TBC). --> |
| 154 | +* We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at |
| 155 | + **100 characters**. An automated formatter is available, see |
| 156 | + [DEVELOPER.md](docs/DEVELOPER.md#clang-format). |
| 157 | +
|
| 158 | +## <a name="commit"></a> Commit Message Guidelines |
| 159 | +
|
| 160 | +We have very precise rules over how our git commit messages can be formatted. This leads to **more |
| 161 | +readable messages** that are easy to follow when looking through the **project history**. But also, |
| 162 | +we use the git commit messages to **generate the Nest change log**. |
| 163 | +
|
| 164 | +### Commit Message Format |
| 165 | +Each commit message consists of a **header**, a **body** and a **footer**. The header has a special |
| 166 | +format that includes a **type**, a **scope** and a **subject**: |
| 167 | +
|
| 168 | +``` |
| 169 | +<type>(<scope>): <subject> |
| 170 | +<BLANK LINE> |
| 171 | +<body> |
| 172 | +<BLANK LINE> |
| 173 | +<footer> |
| 174 | +``` |
| 175 | +
|
| 176 | +The **header** is mandatory and the **scope** of the header is optional. |
| 177 | +
|
| 178 | +Any line of the commit message cannot be longer 100 characters! This allows the message to be easier |
| 179 | +to read on GitHub as well as in various git tools. |
| 180 | +
|
| 181 | +Footer should contain a [closing reference to an issue](https://help.github.com/articles/closing-issues-via-commit-messages/) if any. |
| 182 | +
|
| 183 | +Samples: (even more [samples](https://github.com/nestjs/nest/commits/master)) |
| 184 | +
|
| 185 | +``` |
| 186 | +docs(changelog): update change log to beta.5 |
| 187 | +``` |
| 188 | +``` |
| 189 | +fix(release): need to depend on latest rxjs and zone.js |
| 190 | +
|
| 191 | +The version in our package.json gets copied to the one we publish, and users need the latest of these. |
| 192 | +``` |
| 193 | +
|
| 194 | +### Revert |
| 195 | +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. |
| 196 | +
|
| 197 | +### Type |
| 198 | +Must be one of the following: |
| 199 | +
|
| 200 | +* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) |
| 201 | +* **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) |
| 202 | +* **docs**: Documentation only changes |
| 203 | +* **feat**: A new feature |
| 204 | +* **fix**: A bug fix |
| 205 | +* **perf**: A code change that improves performance |
| 206 | +* **refactor**: A code change that neither fixes a bug nor adds a feature |
| 207 | +* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) |
| 208 | +* **test**: Adding missing tests or correcting existing tests |
| 209 | +
|
| 210 | +### Scope |
| 211 | +The scope should be the name of the npm package affected (as perceived by person reading changelog generated from commit messages. |
| 212 | +
|
| 213 | +The following is the list of supported scopes: |
| 214 | +
|
| 215 | +* **common** |
| 216 | +* **core** |
| 217 | +* **examples** |
| 218 | +* **microservices** |
| 219 | +* **testing** |
| 220 | +* **websockets** |
| 221 | +
|
| 222 | +There are currently a few exceptions to the "use package name" rule: |
| 223 | +
|
| 224 | +* **packaging**: used for changes that change the npm package layout in all of our packages, e.g. public path changes, package.json changes done to all packages, d.ts file/format changes, changes to bundles, etc. |
| 225 | +* **changelog**: used for updating the release notes in CHANGELOG.md |
| 226 | +* **examples/#**: for the example apps directory, replacing # with the example app number |
| 227 | +<!-- * **aio**: used for docs-app (angular.io) related changes within the /aio directory of the repo --> |
| 228 | +* none/empty string: useful for `style`, `test` and `refactor` changes that are done across all packages (e.g. `style: add missing semicolons`) |
| 229 | +
|
| 230 | +### Subject |
| 231 | +The subject contains succinct description of the change: |
| 232 | +
|
| 233 | +* use the imperative, present tense: "change" not "changed" nor "changes" |
| 234 | +* don't capitalize first letter |
| 235 | +* no dot (.) at the end |
| 236 | + |
| 237 | +### Body |
| 238 | +Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". |
| 239 | +The body should include the motivation for the change and contrast this with previous behavior. |
| 240 | + |
| 241 | +### Footer |
| 242 | +The footer should contain any information about **Breaking Changes** and is also the place to |
| 243 | +reference GitHub issues that this commit **Closes**. |
| 244 | + |
| 245 | +**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. |
| 246 | + |
| 247 | +A detailed explanation can be found in this [document][commit-message-format]. |
| 248 | + |
| 249 | +<!-- ## <a name="cla"></a> Signing the CLA |
| 250 | + |
| 251 | +Please sign our Contributor License Agreement (CLA) before sending pull requests. For any code |
| 252 | +changes to be accepted, the CLA must be signed. It's a quick process, we promise! |
| 253 | +
|
| 254 | +* For individuals we have a [simple click-through form][individual-cla]. |
| 255 | +* For corporations we'll need you to |
| 256 | + [print, sign and one of scan+email, fax or mail the form][corporate-cla]. --> |
| 257 | + |
| 258 | + |
| 259 | +<!-- [angular-group]: https://groups.google.com/forum/#!forum/angular --> |
| 260 | +<!-- [coc]: https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md --> |
| 261 | +[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit# |
| 262 | +[corporate-cla]: http://code.google.com/legal/corporate-cla-v1.0.html |
| 263 | +[dev-doc]: https://github.com/nestjs/nest/blob/master/docs/DEVELOPER.md |
| 264 | +[github]: https://github.com/nestjs/nest |
| 265 | +[gitter]: https://gitter.im/nestjs/nest |
| 266 | +[individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html |
| 267 | +[js-style-guide]: https://google.github.io/styleguide/jsguide.html |
| 268 | +[jsfiddle]: http://jsfiddle.net |
| 269 | +[plunker]: http://plnkr.co/edit |
| 270 | +[runnable]: http://runnable.com |
| 271 | +<!-- [stackoverflow]: http://stackoverflow.com/questions/tagged/angular --> |
0 commit comments