Skip to content

Latest commit

 

History

History
91 lines (55 loc) · 6.34 KB

CONTRIBUTING.md

File metadata and controls

91 lines (55 loc) · 6.34 KB

Contributing to Payload

Below you'll find a set of guidelines for how to contribute to Payload.

Opening issues

Before you submit an issue, please check all existing open and closed issues to see if your issue has previously been resolved or is already known. If there is already an issue logged, feel free to upvote it by adding a 👍 reaction. If you would like to submit a new issue, please fill out our Issue Template to the best of your ability so we can accurately understand your report.

Security issues & vulnerabilities

If you come across an issue related to security, or a potential attack vector within Payload or one of its dependencies, please DO NOT create a publicly viewable issue. Instead, please contact us directly at [email protected]. We will do everything we can to respond to the issue as soon as possible.

If you find a vulnerability within the core Payload repository, and we determine that it is remediable and of significant nature, we will be happy to pay you a reward for your findings and diligence. Contact us to find out more.

Documentation edits

Payload documentation can be found directly within its codebase and you can feel free to make changes / improvements to any of it through opening a PR. We utilize these files directly in our website and will periodically deploy documentation updates as necessary.

Building additional features

If you're an incredibly awesome person and want to help us make Payload even better through new features or additions, we would be thrilled to work with you.

Design Contributions

When it comes to design-related changes or additions, it's crucial for us to ensure a cohesive user experience and alignment with our broader design vision. Before embarking on any implementation that would affect the design or UI/UX, we ask that you first share your design proposal with us for review and approval.

Our design review ensures that proposed changes fit seamlessly with other components, both existing and planned. This step is meant to prevent unintentional design inconsistencies and to save you from investing time in implementing features that might need significant design alterations later.

Before Starting

To help us work on new features, you can create a new feature request post in GitHub Discussion or discuss it in our Discord. New functionality often has large implications across the entire Payload repo, so it is best to discuss the architecture and approach before starting work on a pull request.

Code

Most new functionality should keep testing in mind. With 1.0, testability of new features has been vastly improved. All top-level directories within the test/ directory are for testing a specific category: fields, collections, etc.

If it makes sense to add your feature to an existing test directory, please do so.

A typical directory with test/ will be structured like this:

.
├── config.ts
├── int.spec.ts
├── e2e.spec.ts
└── payload-types.ts
  • config.ts - This is the granular Payload config for testing. It should be as lightweight as possible. Reference existing configs for an example
  • int.spec.ts - This is the test file run by jest. Any test file must have a *int.spec.ts suffix.
  • e2e.spec.ts - This is the end-to-end test file that will load up the admin UI using the above config and run Playwright tests. These tests are typically only needed if a large change is being made to the Admin UI.
  • payload-types.ts - Generated types from config.ts. Generate this file by running pnpm dev:generate-types my-test-dir.

The directory split up in this way specifically to reduce friction when creating tests and to add the ability to boot up Payload with that specific config.

The following command will start Payload with your config: pnpm dev my-test-dir. This command will start up Payload using your config and refresh a test database on every restart.

By default, it will automatically log you in with the default credentials. To disable that, you can either pass in the --no-auto-login flag (example: pnpm dev my-test-dir --no-auto-login) or set the PAYLOAD_PUBLIC_DISABLE_AUTO_LOGIN environment variable to false.

If you wish to use to your own Mongo database for the test directory instead of using the in memory database, all you need to do is add the following env vars to the test/dev.ts file:

  • process.env.NODE_ENV
  • process.env.PAYLOAD_TEST_MONGO_URL
  • Simply set process.env.NODE_ENV to test and set process.env.PAYLOAD_TEST_MONGO_URL to your mongo url e.g. mongodb://127.0.0.1/your-test-db.

NOTE: It is recommended to add the test credentials (located in test/credentials.ts) to your autofill for localhost:3000/admin as this will be required on every nodemon restart. The default credentials are [email protected] as E-Mail and test as password.

Commits

We use Conventional Commits for our commit messages. Please follow this format when creating commits. Here are some examples:

  • feat: adds new feature
  • fix: fixes bug
  • docs: adds documentation
  • chore: does chore

Here's a breakdown of the format. At the top-level, we use the following types to categorize our commits:

  • feat: new feature that adds functionality. These are automatically added to the changelog when creating new releases.
  • fix: a fix to an existing feature. These are automatically added to the changelog when creating new releases.
  • docs: changes to docs only. These do not appear in the changelog.
  • chore: changes to code that is neither a fix nor a feature (e.g. refactoring, adding tests, etc.). These do not appear in the changelog.

If you are committing to templates or examples, use the chore type with the proper scope, like this:

  • chore(templates): adds feature to template
  • chore(examples): fixes bug in example

Pull Requests

For all Pull Requests, you should be extremely descriptive about both your problem and proposed solution. If there are any affected open or closed issues, please leave the issue number in your PR message.