You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/contributing.md
+125-22
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,29 @@ Thanks for contributing, you rock!
9
9
10
10
When it comes to open source, there are many different kinds of contributions that can be made, all of which are valuable. Here are a few guidelines that should help you as you prepare your contribution.
11
11
12
+
## Setup
13
+
14
+
Before you can contribute to the codebase, you will need to fork the repo. This will look a bit different depending on what type of contribution you are making:
15
+
16
+
- All new features, bug-fixes, or **anything that touches `react-router` code** should be branched off of and merged into the `dev` branch
17
+
- Changes that only touch documentation can be branched off of and merged into the `main` branch
18
+
19
+
The following steps will get you setup to contribute changes to this repo:
20
+
21
+
1. Fork the repo (click the <kbd>Fork</kbd> button at the top right of [this page](https://github.com/remix-run/react-router))
22
+
2. Clone your fork locally
23
+
24
+
```bash
25
+
# in a terminal, cd to parent directory where you want your clone to be, then
# if you are making *any* code changes, make sure to checkout the dev branch
30
+
git checkout dev
31
+
```
32
+
33
+
3. Install dependencies and build. React Router uses [`yarn` (version 1)](https://classic.yarnpkg.com/lang/en/docs/install), so you should too. If you install using `npm`, unnecessary `package-lock.json` files will be generated.
34
+
12
35
## Think You Found a Bug?
13
36
14
37
Please conform to the issue template and provide a clear path to reproduction with a code example. Best is a pull request with a failing test. Next best is a link to CodeSandbox or repository that illustrates the bug.
@@ -23,11 +46,13 @@ We have learned by experience that small APIs are usually better, so we may be a
23
46
24
47
If you need a bug fixed and nobody is fixing it, your best bet is to provide a fix for it and make a [pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request). Open source code belongs to all of us, and it's all of our responsibility to push it forward.
25
48
26
-
Issues with no activity for 60 days will be automatically closed, with a warning 7 days before closing.
27
-
28
49
## Making a Pull Request?
29
50
30
-
Pull requests need only the :+1: of two or more collaborators to be merged; when the PR author is a collaborator, that counts as one.
51
+
Pull requests need only the approval of two or more collaborators to be merged; when the PR author is a collaborator, that counts as one.
52
+
53
+
> **Important:** When creating the PR in GitHub, make sure that you set the base to the correct branch. If you are submitting a PR that touches any code, this should be the `dev` branch. You set the base in GitHub when authoring the PR with the dropdown below the "Compare changes" heading:
@@ -39,37 +64,115 @@ All commits that fix bugs or add features need a test.
39
64
40
65
All commits that change or add to the API must be done in a pull request that also updates all relevant examples and docs.
41
66
42
-
## Setup
67
+
## Development
43
68
44
-
The following steps will get you setup to contribute changes to this repo:
69
+
### Packages
70
+
71
+
React Router uses a monorepo to host code for multiple packages. These packages live in the `packages` directory.
45
72
46
-
1. Fork the repo (click the <kbd>Fork</kbd> button at the top right of [this
47
-
page](https://github.com/remix-run/react-router))
73
+
We use [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) to manage installation of dependencies and running various scripts. To get everything installed, make sure you have [Yarn (version 1) installed](https://classic.yarnpkg.com/lang/en/docs/install), and then run `yarn` or `yarn install` from the repo root.
48
74
49
-
2. Clone your fork locally
75
+
### Building
76
+
77
+
Calling `yarn build` from the root directory will run the build, which should take only a few seconds. It's important to build all the packages together because `react-router-dom` and `react-router-native` both use `react-router` as a dependency.
78
+
79
+
### Testing
80
+
81
+
Before running the tests, you need to run a build. After you build, running `yarn test` from the root directory will run **every** package's tests. If you want to run tests for a specific package, use `yarn test --projects packages/<package-name>`:
50
82
51
83
```bash
52
-
# in a terminal, cd to parent directory where you want your clone to be, then
3. Install dependencies and build. React Router uses `yarn` (version 1), so you
58
-
should too. If you install using `npm`, unnecessary `package-lock.json` files
59
-
will be generated.
91
+
## Repository Branching
60
92
61
-
## Development
93
+
This repo maintains separate branches for different purposes. They will look something like this:
62
94
63
-
### Packages
95
+
```
96
+
- main > the most recent release and current docs
97
+
- dev > code under active development between stable releases
98
+
- v5 > the most recent code for a specific major release
99
+
```
64
100
65
-
React Router uses a monorepo to host code for multiple packages. These packages live in the `packages` directory.
101
+
There may be other branches for various features and experimentation, but all of the magic happens from these branches.
66
102
67
-
We use [Yarn workspaces](https://legacy.yarnpkg.com/en/docs/workspaces/) to manage installation of dependencies and running various scripts. To get everything installed, just run `yarn` or `yarn install` from the repo root.
103
+
## New Releases
68
104
69
-
### Building
105
+
When it's time to cut a new release, we follow a process based on our branching strategy depending on the type of release.
70
106
71
-
Calling `yarn build` from the root directory will run the build, which should take only a few seconds. It's important to build all the packages together because `react-router-dom` and `react-router-native` both use `react-router` as a dependency.
107
+
### `react-router@next` Releases
72
108
73
-
### Testing
109
+
We create experimental releases from the current state of the `dev` branch. They can be installed by using the `@next` tag:
110
+
111
+
```bash
112
+
yarn add react-router-dom@next
113
+
# or
114
+
npm install react-router-dom@next
115
+
```
116
+
117
+
These releases will be automated as PRs are merged into the `dev` branch.
118
+
119
+
### Latest Major Releases
120
+
121
+
```bash
122
+
# Start from the dev branch.
123
+
git checkout dev
74
124
75
-
Before running the tests, you need to run a build. After you build, running `yarn test` from the root directory will run **every** package's tests. If you want to run tests for a specific package, use e.g. `jest --projects package/react-router`.
125
+
# Merge the main branch into dev to ensure that any hotfixes and
126
+
# docs updates are available in the release.
127
+
git merge main
128
+
129
+
# Create a new release branch from dev.
130
+
git checkout -b release/v6.1.0
131
+
132
+
# Create a new tag and update version references throughout the
133
+
# codebase.
134
+
yarn run version minor # | "patch" | "major"
135
+
136
+
# Push the release branch along with the new release tag.
137
+
git push origin release/v6.1.0 --follow-tags
138
+
139
+
# Wait for GitHub actions to run all tests. If the tests pass, the
140
+
# release is ready to go! Merge the release branch into main and dev.
141
+
git checkout main
142
+
git merge release/v6.1.0
143
+
git checkout dev
144
+
git merge release/v6.1.0
145
+
146
+
# The release branch can now be deleted.
147
+
git branch -D release/v6.1.0
148
+
git push origin --delete release/v6.1.0
149
+
150
+
# Now go to GitHub and create the release from the new tag. Let
151
+
# GitHub Actions take care of the rest!
152
+
```
153
+
154
+
### Hot-fix Releases
155
+
156
+
Sometimes we have a crucial bug that needs to be patched right away. If the bug affects the latest release, we can create a new version directly from `main` (or the relevant major release branch where the bug exists):
157
+
158
+
```bash
159
+
# From the main branch, make sure to run the build and all tests
160
+
# before creating a new release.
161
+
yarn && yarn build && yarn test
162
+
163
+
# Assuming the tests pass, create the release tag and update
164
+
# version references throughout the codebase.
165
+
yarn run version patch
166
+
167
+
# Push changes along with the new release tag.
168
+
git push origin main --follow-tags
169
+
170
+
# In GitHub, create the release from the new tag and it will be
171
+
# published via GitHub actions
172
+
173
+
# When the hot-fix is done, merge the changes into dev and clean
0 commit comments