strapi/CONTRIBUTING.md

189 lines
8.9 KiB
Markdown
Raw Normal View History

# Contribute to Strapi
2016-03-18 11:12:50 +01:00
Strapi is an open-source project administered by [the Strapi team](https://strapi.io/about-us). We appreciate your interest and efforts to contribute to Strapi. See the [LICENSE](https://github.com/strapi/strapi/blob/main/LICENSE) licensing information. All work done is available on GitHub.
2016-03-18 11:12:50 +01:00
We highly appreciate your effort to contribute, but we recommend you talk to a maintainer before spending a lot of time making a pull request that may not align with the project roadmap. Whether it is from Strapi or contributors, every pull request goes through the same process.
2017-12-13 12:21:16 +01:00
2019-05-28 15:33:07 +02:00
## Feature Requests
Feature Requests by the community are highly encouraged. Feel free to submit a new one or upvote an existing feature request on [feedback.strapi.io](https://feedback.strapi.io/).
2017-12-13 12:21:16 +01:00
2022-02-04 11:19:40 +01:00
## Request For Comments (RFC)
Larger chunks of changes to Strapi that might affect many users require a thorough design phase before starting working on a PR. We will do our best to respond as soon as possible, but since we need to discuss these proposals thoroughly, please do not expect them to be merged and accepted immediately.
The Request For Comments process will help us create consensus among the core team and include as much feedback as possible from the community for these upcoming changes.
A Request For Comments has to be created on the [strapi/rfcs](https://github.com/strapi/rfcs) repository.
2019-05-27 18:57:24 +02:00
## Code of Conduct
2017-12-13 12:21:16 +01:00
This project, and everyone participating in it, are governed by the [Strapi Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold it. Make sure to read the [full text](CODE_OF_CONDUCT.md) to understand which type of actions may or may not be tolerated.
2017-12-13 12:21:16 +01:00
## Contributor License Agreement (CLA)
2022-02-04 11:19:40 +01:00
### Individual contribution
You need to sign a Contributor License Agreement (CLA) to accept your pull request. You only need to do this once. If you submit a pull request for the first time, you can complete your CLA [here](https://cla.strapi.io/strapi/strapi), or our CLA bot will automatically ask you to sign before merging the pull request.
2022-02-04 11:19:40 +01:00
### Company contribution
If you make contributions to our repositories on behalf of your company, we will need a Corporate Contributor License Agreement (CLA) signed. To do that, please get in touch with us at [contributions@strapi.io](mailto:contributions@strapi.io).
## Documentation
2022-02-04 11:19:40 +01:00
Pull requests related to fixing documentation for the latest release should be directed towards the [documentation repository](https://github.com/strapi/documentation). Please follow the [documentation contributing guide](https://github.com/strapi/documentation/blob/main/CONTRIBUTING.md) for more information.
2019-05-27 18:57:24 +02:00
## Bugs
2017-12-13 12:21:16 +01:00
Strapi is using [GitHub issues](https://github.com/strapi/strapi/issues) to manage bugs. We keep a close eye on them. Before filing a new issue, try to ensure your problem does not already exist.
2017-12-13 12:21:16 +01:00
2019-05-27 18:57:24 +02:00
---
2019-05-27 18:57:24 +02:00
## Before Submitting a Pull Request
2017-12-13 12:21:16 +01:00
The Strapi core team will review your pull request and either merge it, request changes, or close it.
2022-02-04 11:19:40 +01:00
## Contribution Prerequisites
2022-09-08 16:38:57 +02:00
- You have [Node.js](https://nodejs.org/en/) at version >= v14 and <= v18 and [Yarn](https://yarnpkg.com/en/) at v1.2.0+ installed.
2022-02-04 11:19:40 +01:00
- You are familiar with [Git](https://git-scm.com).
2017-12-13 12:21:16 +01:00
2019-05-27 20:28:15 +02:00
**Before submitting your pull request** make sure the following requirements are fulfilled:
2017-12-13 12:21:16 +01:00
- Fork the repository and create your new branch from `main`.
- Run `yarn install` in the root of the repository.
2022-01-31 09:36:03 +01:00
- Run `yarn setup` in the root of the repository.
- If you've fixed a bug or added code that should be tested, please make sure to add tests
2022-02-04 11:19:40 +01:00
- Ensure the following test suites are passing:
2019-05-27 18:57:24 +02:00
- `yarn test:unit`
- `yarn test:front`
2022-02-04 11:19:40 +01:00
- Make sure your code lints by running `yarn lint`.
2022-01-31 09:36:03 +01:00
- If your contribution fixes an existing issue, please make sure to link it in your pull request.
2018-05-04 12:44:15 +02:00
2019-05-27 18:57:24 +02:00
## Development Workflow
2017-12-13 12:21:16 +01:00
2022-02-04 11:19:40 +01:00
### 1. Fork the [repository](https://github.com/strapi/strapi)
2019-05-27 18:57:24 +02:00
2022-01-31 09:36:03 +01:00
[Go to the repository](https://github.com/strapi/strapi) and fork it using your own GitHub account.
2019-05-27 18:57:24 +02:00
2022-02-04 11:19:40 +01:00
### 2. Clone your repository
2018-08-08 14:30:40 +02:00
```bash
2019-05-27 18:57:24 +02:00
git clone git@github.com:YOUR_USERNAME/strapi.git
2018-08-08 14:30:40 +02:00
```
2022-02-04 11:19:40 +01:00
### 3. Install the dependencies
2018-08-08 14:30:40 +02:00
2022-02-04 11:19:40 +01:00
Go to the root of the repository and run the setup:
2018-08-08 14:30:40 +02:00
```bash
2022-01-31 09:36:03 +01:00
cd strapi
2023-04-24 09:11:27 +02:00
yarn install
2022-01-31 09:36:03 +01:00
yarn setup
2018-08-08 14:30:40 +02:00
```
2022-02-04 11:19:40 +01:00
### 4. Start the example application
2018-08-08 14:30:40 +02:00
```bash
2022-01-31 09:36:03 +01:00
cd ./examples/getstarted
yarn develop
```
2022-11-09 09:51:23 +01:00
Make sure to read the [`getstarted` application README](https://github.com/strapi/strapi/blob/main/examples/getstarted/README.md) for more details.
2018-08-08 14:30:40 +02:00
2022-02-04 11:19:40 +01:00
### 5. Running the administration panel in development mode
2018-08-08 14:30:40 +02:00
2022-01-31 09:36:03 +01:00
Start the administration panel server for development:
2019-05-27 18:57:24 +02:00
2018-08-08 14:30:40 +02:00
```bash
2022-01-31 09:36:03 +01:00
cd ./packages/core/admin
2019-05-27 18:57:24 +02:00
yarn develop
2018-08-08 14:30:40 +02:00
```
2022-02-04 11:19:40 +01:00
The administration panel should now be available at http://localhost:4000/admin. Make sure the example application (step 4) is still running.
2018-08-08 14:30:40 +02:00
**Awesome! You are now able to contribute to Strapi.**
2022-02-04 11:19:40 +01:00
### 6. Available commands
2019-05-27 18:57:24 +02:00
- `yarn watch` starts yarn watch in all packages.
- `yarn build` builds the `strapi-helper-plugin` (use this command when you develop in the administration panel).
2022-01-31 09:36:03 +01:00
- `yarn setup` installs dependencies.
2019-05-27 18:57:24 +02:00
- `yarn lint` lints the codebase.
2022-01-31 09:36:03 +01:00
- `yarn test:clean` removes the coverage reports.
- `yarn test:front` runs front-end related tests.
2019-05-27 18:57:24 +02:00
- `yarn test:front:watch` runs an interactive test watcher for the front-end.
- `yarn test:unit` runs the back-end unit tests.
2022-11-07 16:30:12 +01:00
- `yarn test:api` runs the api integration tests.
2019-05-27 18:57:24 +02:00
- `yarn test:generate-app` generates a test application.
- `yarn test:start-app` starts the test application.
2018-08-08 14:30:40 +02:00
---
2017-12-13 12:21:16 +01:00
## Running the API Integration tests
2021-11-29 18:46:14 +01:00
The API integration tests require a Strapi app to be able to run. You can generate a "test app" using `yarn test:generate-app <database>`:
2021-11-29 18:46:14 +01:00
```bash
$ yarn test:generate-app sqlite
$ yarn test:generate-app postgres
$ yarn test:generate-app mysql
```
2022-11-08 10:11:56 +01:00
A new app is required every time you run the API integration tests, otherwise the test suite will fail. A command is available to make this process easier: `yarn test:api`.
2022-11-08 10:11:56 +01:00
This command runs tests using jest behind the scenes. Options for jest can be passed to the command. (e.g. to update snapshots `yarn test:api -u`).
2022-02-04 11:19:40 +01:00
### Changing the database
2022-11-08 10:11:56 +01:00
By default the script run by `test:api` an app that uses `sqlite` as a database. But you can run the test suites using different databases:
2019-05-28 15:33:07 +02:00
```bash
$ yarn test:api --db=sqlite
$ yarn test:api --db=postgres
$ yarn test:api --db=mysql
```
2022-11-25 18:37:53 +08:00
### Running the tests for the Enterprise Edition (EE)
2021-11-29 18:46:14 +01:00
The test suites run the tests for the Community Edition (CE) version of Strapi by default.
In order to run the Enterprise Edition tests you need a valid license. To specify a license, you can use the environment variable `STRAPI_LICENSE`:
2021-11-29 18:46:14 +01:00
```bash
$ STRAPI_LICENSE=<license> yarn test:api
2021-11-29 18:46:14 +01:00
```
2019-05-27 18:57:24 +02:00
---
2019-05-28 15:33:07 +02:00
## Miscellaneous
2019-05-27 18:57:24 +02:00
### Repository Organization
We chose to use a monorepo design using [Yarn Workspaces](https://yarnpkg.com/en/docs/workspaces) in the way [React](https://github.com/facebook/react/tree/master/packages) or [Babel](https://github.com/babel/babel/tree/master/packages) does. This allows us to maintain the whole ecosystem keep it up-to-date and consistent.
We do our best to keep the master branch as clean as possible, with tests passing at all times. However, the master branch can move faster than the release cycle. Therefore check the [releases on npm](https://www.npmjs.com/package/@strapi/strapi) so that you are always up-to-date with the latest stable version.
2019-05-27 18:57:24 +02:00
### Reporting an issue
2016-03-18 11:12:50 +01:00
2019-05-28 15:33:07 +02:00
Before submitting an issue you need to make sure:
2019-05-27 18:57:24 +02:00
2022-01-31 09:36:03 +01:00
- You are experiencing a technical issue with Strapi.
- You have already searched for related [issues](https://github.com/strapi/strapi/issues) and found none open (if you found a related _closed_ issue, please link to it from your post).
2019-05-28 15:33:07 +02:00
- You are not asking a question about how to use Strapi or about whether or not Strapi has a certain feature. For general help using Strapi, you may:
2022-02-04 11:19:40 +01:00
- Refer to the [official Strapi documentation](https://docs.strapi.io).
- Ask a member of the community in the [Strapi Discord Community](https://discord.strapi.io/).
2022-02-04 11:19:40 +01:00
- Ask a question on the [Strapi community forum](https://forum.strapi.io).
- Your issue title is concise, on-topic, and polite.
2022-02-04 11:19:40 +01:00
- You provide steps to reproduce the issue.
- You have tried all the following (if relevant), and your issue remains:
2016-03-18 11:12:50 +01:00
- Make sure you have the right application started.
2022-11-09 09:51:23 +01:00
- Make sure the [issue template] is respected.
- Make sure your issue body is readable and [well formatted](https://guides.github.com/features/mastering-markdown).
2022-02-04 11:19:40 +01:00
- Make sure you've stopped the Strapi server with CTRL+C and restarted it.
- Make sure your application has a clean `node_modules` directory, meaning:
- you didn't link any dependencies (e.g., by running `yarn link`)
2022-02-04 11:19:40 +01:00
- you haven't made any inline changes to files in the `node_modules` directory
- you don't have any global dependency loops. If you aren't sure, the easiest way to double-check any of the above is to run: `$ rm -rf node_modules && yarn cache clean && yarn install && yarn setup`.