UNPKG

4.53 kBMarkdownView Raw
1# Contributing to API Platform
2
3First of all, thank you for contributing, you're awesome!
4
5To have your code integrated in the API Platform project, there is some rules to follow, but don't panic, it's easy!
6
7## Reporting bugs
8
9If you happen to find a bug, we kindly request you to report it. However, before submitting it, please:
10
11 * Check the [project documentation available online](https://api-platform.com/docs/)
12
13Then, if it appears that it's a real bug, you may report it using Github by following these 3 points:
14
15 * Check if the bug is not already reported!
16 * A clear title to resume the issue
17 * A description of the workflow needed to reproduce the bug,
18
19> _NOTE:_ Don’t hesitate giving as much information as you can
20
21## Pull requests
22
23### Installing the source version
24
25To install the source version of the API Platform Client Generator in your project and contribute a patch, run the following commands:
26
27```console
28$ git clone git@github.com:api-platform/client-generator.git
29$ cd client-generator
30$ yarn install
31$ yarn watch
32```
33
34You can now hack in the cloned repository of `client-generator`. If you want to test your work, a `lib/index.js` file containing your last changes will be created each time you invoke `yarn build`. You can also use `yarn watch` to make it created each time a change is performed in your code!
35
36### Testing your changes
37
38To test your changes, generate a client in a `pwa` directory of an api-platform distribution:
39
40```console
41$ git clean -df && NODE_TLS_REJECT_UNAUTHORIZED=0 <absolutePathOfYourClonedRepo>/lib/index.js https://localhost/ .
42```
43
44and see the `pwa` logs:
45
46```console
47$ docker-compose logs -f pwa
48```
49
50Before sending a Pull Request, make sure the tests pass correctly:
51
52```console
53$ yarn test
54```
55
56### Matching coding standards
57
58The API Platform Client Generator project is inspired by the [Airbnb JavaScript style guide](https://github.com/airbnb/javascript).
59But don't worry, you can fix CS issues automatically using [ESLint](https://eslint.org/) tool:
60
61```console
62$ yarn fix
63```
64
65And then, add fixed file to your commit before push.
66Be sure to add only **your modified files**. If another files are fixed by cs tools, just revert it before commit.
67
68### Sending a Pull Request
69
70When you send a PR, just make sure that:
71
72* You add valid test cases (you can run them using `yarn test`).
73* Tests are green.
74* You make a PR on the related documentation in the [api-platform/doc](https://github.com/api-platform/doc) repository.
75* You make the PR on the same branch you based your changes on. If you see commits that you did not make in your PR, you're doing it wrong.
76* Also don't forget to add a comment when you update a PR with a ping to [the maintainer](https://github.com/orgs/api-platform/people), so he/she will get a notification.
77* Squash your commits into one commit. (see the next chapter)
78
79All Pull Requests must include the following header:
80
81```markdown
82| Q | A
83| ------------- | ---
84| Bug fix? | yes/no
85| New feature? | yes/no
86| BC breaks? | no
87| Deprecations? | no
88| Tests pass? | yes
89| Fixed tickets | #1234, #5678
90| License | MIT
91| Doc PR | api-platform/doc#1234
92```
93
94## Squash your commits
95
96If you have 3 commits. So start with:
97
98```console
99$ git rebase -i HEAD~3
100```
101
102An editor will be opened with your 3 commits, all prefixed by `pick`.
103
104Replace all `pick` prefixes by `fixup` (or `f`) **except the first commit** of the list.
105
106Save and quit the editor.
107
108After that, all your commits where squashed into the first one and the commit message of the first commit.
109
110If you would like to rename your commit message type:
111
112```console
113$ git commit --amend
114```
115
116Now force push to update your PR:
117
118```console
119$ git push --force
120```
121
122# Tag a new version (contributors only)
123
124Always test before releasing a new one:
125
126```console
127$ yarn build
128$ yarn test
129$ yarn lint
130```
131
132To fix linting errors, you can use `yarn fix`.
133
134To release a new version:
135
136```console
137$ yarn version # this creates a tag
138$ git push
139$ git push --tags
140```
141
142Travis will then publish the version on npm.
143
144# License and copyright attribution
145
146When you open a Pull Request to the API Platform project, you agree to license your code under the [MIT license](LICENSE)
147and to transfer the copyright on the submitted code to Kévin Dunglas.
148
149Be sure to you have the right to do that (if you are a professional, ask your company)!
150
151If you include code from another project, please mention it in the Pull Request description and credit the original author.