Skip to content

Commit 5526c5a

Browse files
Update contributor docs
1 parent 0ca5b4e commit 5526c5a

File tree

2 files changed

+183
-29
lines changed

2 files changed

+183
-29
lines changed

CONTRIBUTING.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# Getting started
2+
3+
## Set up your environment
4+
5+
- Install [Node.js v20](https://nodejs.dev/) - we recommend using a Node version manager like [nvm](https://github.com/nvm-sh/nvm) or [volta](https://volta.sh/).
6+
- Install a code editor - we recommend using [VS Code](https://code.visualstudio.com/).
7+
- Install the [git](https://git-scm.com/) version control tool.
8+
- Install the [pnpm](https://pnpm.io/installation) package manager tool.
9+
10+
## Fork and clone this repository
11+
12+
Any contributions you make will be via [Pull Requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) on [GitHub](https://github.com/) developed in a local git repository and pushed to your own fork of the repository.
13+
14+
- Ensure you have [created an account](https://docs.github.com/en/get-started/onboarding/getting-started-with-your-github-account) on GitHub.
15+
- [Create your own fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) of [this repository](https://github.com/opennextjs/opennextjs-cloudflare).
16+
- Clone your fork to your local machine
17+
18+
```sh
19+
> git clone https://github.com/<your-github-username>/opennextjs-cloudflare
20+
> cd opennextjs-cloudflare
21+
```
22+
23+
You can see that your fork is setup as the `origin` remote repository.
24+
Any changes you wish to make should be in a local branch that is then pushed to this origin remote.
25+
26+
```sh
27+
> git remote -v
28+
origin https://github.com/<your-github-username>/opennextjs-cloudflare (fetch)
29+
origin https://github.com/<your-github-username>/opennextjs-cloudflare (push)
30+
```
31+
32+
- Add `opennextjs/opennextjs-cloudflare` as the `upstream` remote repository.
33+
34+
```sh
35+
> git remote add upstream https://github.com/opennextjs/opennextjs-cloudflare
36+
> git remote -v
37+
origin https://github.com/<your-github-username>/opennextjs-cloudflare (fetch)
38+
origin https://github.com/<your-github-username>/opennextjs-cloudflare (push)
39+
upstream https://github.com/opennextjs/opennextjs-cloudflare (fetch)
40+
upstream https://github.com/opennextjs/opennextjs-cloudflare (push)
41+
```
42+
43+
- You should regularly pull from the `main` branch of the `upstream` repository to keep up to date with the latest changes to the project.
44+
45+
```sh
46+
> git switch main
47+
> git pull upstream main
48+
From https://github.com/opennextjs/opennextjs-cloudflare
49+
* branch main -> FETCH_HEAD
50+
Already up to date.
51+
```
52+
53+
## Install dependencies
54+
55+
The Node.js dependencies of the project are managed by the [`pnpm`](https://pnpm.io/) tool.
56+
57+
This repository is setup as a [mono-repo](https://pnpm.io/workspaces) of workspaces. The workspaces are stored in the [`packages`](https://github.com/opennextjs/opennextjs-cloudflare/tree/main/packages) directory.
58+
59+
While each workspace has its own dependencies, you install the dependencies using `pnpm` at the root of the project.
60+
61+
- Install all the dependencies
62+
63+
```sh
64+
> cd opennextjs-cloudflare
65+
> pnpm install
66+
```
67+
68+
## Building and running
69+
70+
Build the cloudflare adaptor tool with:
71+
72+
```sh
73+
pnpm --filter cloudflare build
74+
```
75+
76+
or in watch mode with:
77+
78+
```sh
79+
pnpm --filter cloudflare build:watch
80+
```
81+
82+
Build and preview a Next.js sample application. For example, the `api` application:
83+
84+
```sh
85+
pnpm --filter api preview:worker
86+
```
87+
88+
You can skip building the Next.js app when it has not been modified, and only run the Cloudflare adaptor tool:
89+
90+
```sh
91+
SKIP_NEXT_APP_BUILD=true pnpm --filter api preview:worker
92+
```
93+
94+
## Checking the code
95+
96+
Run the format, lint and type checks on the code:
97+
98+
```sh
99+
pnpm run code:checks
100+
```
101+
102+
Attempt to auto-fix any issues with the format, lint and type checks:
103+
104+
```sh
105+
pnpm run fix:checks
106+
```
107+
108+
## Testing the code
109+
110+
Run all the unit tests, via Vitest:
111+
112+
```sh
113+
pnpm run test
114+
```
115+
116+
Run all the e2e tests, via Playwright:
117+
118+
```sh
119+
pnpm run e2e
120+
```
121+
122+
## Changesets
123+
124+
Every non-trivial change to the project - those that should appear in the changelog - must be captured in a "changeset".
125+
We use the [`changesets`](https://github.com/changesets/changesets/blob/main/README.md) tool for creating changesets, publishing versions and updating the changelog.
126+
127+
- Create a changeset for the current change.
128+
129+
```sh
130+
> pnpm changeset
131+
```
132+
133+
- Select which workspaces are affected by the change and whether the version requires a major, minor or patch release.
134+
- Update the generated changeset with a description of the change.
135+
- Include the generate changeset in the current commit.
136+
137+
```sh
138+
> git add ./changeset/*.md
139+
```
140+
141+
### Changeset message format
142+
143+
Each changeset is a file that describes the change being merged. This file is used to generate the changelog when the changes are released.
144+
145+
To help maintain consistency in the changelog, changesets should have the following format:
146+
147+
```text
148+
<TYPE>: <TITLE>
149+
150+
<BODY>
151+
152+
[BREAKING CHANGES <BREAKING_CHANGE_NOTES>]
153+
```
154+
155+
- `TYPE` should be a single word describing the "type" of the change. For example, one of `feature`, `fix`, `refactor`, `docs` or `chore`.
156+
- `TITLE` should be a single sentence containing an imperative description of the change.
157+
- `BODY` should be one or more paragraphs that go into more detail about the reason for the change and anything notable about the approach taken.
158+
- `BREAKING_CHANGE_NOTES` (optional) should be one or more paragraphs describing how this change breaks current usage and how to migrate to the new usage.
159+
160+
### Changeset file example
161+
162+
The generated changeset file will contain the package name and type of change (eg. `patch`, `minor`, or `major`), followed by our changeset format described above.
163+
164+
Here's an example of a `patch` to the `@opennextjs/cloudflare` package, which provides a `fix`:
165+
166+
```md
167+
---
168+
"@opennextjs/cloudflare": patch
169+
---
170+
171+
fix: replace the word "publish" with "deploy" everywhere.
172+
173+
We should be consistent with the word that describes how we get a worker to the edge. The command is `deploy`, so let's use that everywhere.
174+
```
175+
176+
### Types of changes
177+
178+
We use the following guidelines to determine the kind of change for a PR:
179+
180+
- Bugfixes and experimental features are considered to be 'patch' changes. Be sure to log warnings when experimental features are used.
181+
- New stable features and new deprecation warnings for future breaking changes are considered 'minor' changes. These changes shouldn't break existing code, but the deprecation warnings should suggest alternate solutions to not trigger the warning.
182+
- Breaking changes are considered to be 'major' changes. These are usually when deprecations take effect, or functional breaking behaviour is added with relevant logs (either as errors or warnings.)

README.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,4 @@ The repository contains two directories:
1919

2020
### How to try out/develop in the repository
2121

22-
Install the dependencies:
23-
24-
```sh
25-
pnpm i
26-
```
27-
28-
build the worker with:
29-
30-
```sh
31-
pnpm --filter cloudflare build
32-
```
33-
34-
or in watch mode with:
35-
36-
```sh
37-
pnpm --filter cloudflare build:watch
38-
```
39-
40-
build and preview the worker for the `api` application:
41-
42-
```sh
43-
pnpm --filter api preview:worker
44-
```
45-
46-
You can skip building the next app when it has not been modified:
47-
48-
```sh
49-
SKIP_NEXT_APP_BUILD=true pnpm --filter api preview:worker
50-
```
22+
See the [CONTRIBUTING](./CONTRIBUTING.md) page for how to get started with this repository.

0 commit comments

Comments
 (0)