1 | # Contributing to API Platform
|
2 |
|
3 | First of all, thank you for contributing, you're awesome!
|
4 |
|
5 | To 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 |
|
9 | If 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 |
|
13 | Then, 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 |
|
25 | To 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 |
|
34 | You 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 |
|
38 | To 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 |
|
44 | and see the `pwa` logs:
|
45 |
|
46 | ```console
|
47 | $ docker-compose logs -f pwa
|
48 | ```
|
49 |
|
50 | Before sending a Pull Request, make sure the tests pass correctly:
|
51 |
|
52 | ```console
|
53 | $ yarn test
|
54 | ```
|
55 |
|
56 | ### Matching coding standards
|
57 |
|
58 | The API Platform Client Generator project is inspired by the [Airbnb JavaScript style guide](https://github.com/airbnb/javascript).
|
59 | But don't worry, you can fix CS issues automatically using [ESLint](https://eslint.org/) tool:
|
60 |
|
61 | ```console
|
62 | $ yarn fix
|
63 | ```
|
64 |
|
65 | And then, add fixed file to your commit before push.
|
66 | Be 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 |
|
70 | When 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 |
|
79 | All 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 |
|
96 | If you have 3 commits. So start with:
|
97 |
|
98 | ```console
|
99 | $ git rebase -i HEAD~3
|
100 | ```
|
101 |
|
102 | An editor will be opened with your 3 commits, all prefixed by `pick`.
|
103 |
|
104 | Replace all `pick` prefixes by `fixup` (or `f`) **except the first commit** of the list.
|
105 |
|
106 | Save and quit the editor.
|
107 |
|
108 | After that, all your commits where squashed into the first one and the commit message of the first commit.
|
109 |
|
110 | If you would like to rename your commit message type:
|
111 |
|
112 | ```console
|
113 | $ git commit --amend
|
114 | ```
|
115 |
|
116 | Now force push to update your PR:
|
117 |
|
118 | ```console
|
119 | $ git push --force
|
120 | ```
|
121 |
|
122 | # Tag a new version (contributors only)
|
123 |
|
124 | Always test before releasing a new one:
|
125 |
|
126 | ```console
|
127 | $ yarn build
|
128 | $ yarn test
|
129 | $ yarn lint
|
130 | ```
|
131 |
|
132 | To fix linting errors, you can use `yarn fix`.
|
133 |
|
134 | To release a new version:
|
135 |
|
136 | ```console
|
137 | $ yarn version # this creates a tag
|
138 | $ git push
|
139 | $ git push --tags
|
140 | ```
|
141 |
|
142 | Travis will then publish the version on npm.
|
143 |
|
144 | # License and copyright attribution
|
145 |
|
146 | When you open a Pull Request to the API Platform project, you agree to license your code under the [MIT license](LICENSE)
|
147 | and to transfer the copyright on the submitted code to Kévin Dunglas.
|
148 |
|
149 | Be sure to you have the right to do that (if you are a professional, ask your company)!
|
150 |
|
151 | If you include code from another project, please mention it in the Pull Request description and credit the original author.
|