Wrangler2 is an open source project and we welcome contributions from you. Thank you!
Below you can find some guidance on how to be most effective when contributing to the project.
Wrangler2 is built and run on the Node.js JavaScript runtime.
- Install the latest LTS version of Node.js - we recommend using a Node version manager like nvm.
- Install a code editor - we recommend using VS Code.
- When opening the project in VS Code for the first time, it will prompt you to install the recommended VS Code extensions for the project.
- Install the git version control tool.
Any contributions you make will be via Pull Requests on GitHub developed in a local git repository and pushed to your own fork of the repository.
- Ensure you have created an account on GitHub.
- Create your own fork of this repository.
- Clone your fork to your local machine
You can see that your fork is setup as the
> git clone https://github.com/<your-github-username>/wrangler2 > cd wrangler2
origin
remote repository. Any changes you wish to make should be in a local branch that is then pushed to this origin remote.> git remote -v origin https://github.com/<your-github-username>/wrangler2 (fetch) origin https://github.com/<your-github-username>/wrangler2 (push)
- Add
cloudflare/wrangler2
as theupstream
remote repository.> git remote add upstream https://github.com/cloudflare/wrangler2 > git remote -v origin https://github.com/<your-github-username>/wrangler2 (fetch) origin https://github.com/<your-github-username>/wrangler2 (push) upstream https://github.com/cloudflare/wrangler2 (fetch) upstream https://github.com/cloudflare/wrangler2 (push)
- You should regularly pull from the
main
branch of theupstream
repository to keep up to date with the latest changes to the project.> git switch main > git pull upstream main From https://github.com/cloudflare/wrangler2 * branch main -> FETCH_HEAD Already up to date.
The Node.js dependencies of the project are managed by the npm
tool.
This repository is setup as a mono-repo of workspaces. The workspaces are stored in the packages
directory.
While each workspace has its own dependencies, you install the dependencies using npm
at the root of the project.
- Install all the dependencies
> cd wrangler2 > npm install
Do not run npm install
in any of the workspaces directly.
Each wrangler workspace in this project is written in TypeScript and compiled, by esbuild, into JavaScript bundles for distribution.
- Run a distributable for a specific workspace (e.g. wrangler)
> npm start -w wrangler
- Build a distributable for a specific workspace(e.g. wrangler)
> npm run build -w wrangler
The code in the repository is checked for type checking, formatting, linting and testing errors.
- Run all checks in all the workspaces
> npm run check
When doing normal development you may want to run these checks individually.
The code is checked for type errors by TypeScript.
- Type check all the code in the repository
> npm run check:type
- VS Code will also run type-checking while editing source code, providing immediate feedback.
The code is checked for linting errors by ESLint.
- Run the linting checks
> npm run check:lint
- The repository has a recommended VS Code plugin to run ESLint checks while editing source code, providing immediate feedback.
The code is checked for formatting errors by Prettier.
- Run the formatting checks
> npm run check:format
- The repository has a recommended VS Code plugin to run Prettier checks, and to automatically format using Prettier, while editing source code, providing immediate feedback.
Tests in a workspace are executed, by Jest, which is configured to automatically compile and bundle the TypeScript before running the tests.
- Run the tests for all the workspaces
> npm run test
- Run the tests for a specific workspace (e.g. wrangler)
> npm run test -w wrangler
- Watch the files in a specific workspace (e.g. wrangler), and run the tests when anything changes
This will also run all the tests in a single process (rather than in parallel shards) and will increase the test-timeout to 50 seconds, which is helpful when debugging.
> npm run test-watch -w wrangler
Every change you make should be stored in a git commit. Changes should be committed to a new local branch, which then gets pushed to your fork of the repository on GitHub.
- Ensure your
main
branch is up to date> git switch main > git pull upstream main
- Create a new branch, based off the
main
branch> git checkout -b <new-branch-name> main
- Stage files to include in a commit
- Use VS Code
- Or add and commit files via the command line
> git add <paths-to-changes-files> > git commit
- Push changes to your fork
git push -u origin <new-branch-name>
- Once you are happy with your changes, create a Pull Request on GitHub
Every non-trivial change to the project - those that should appear in the changelog - must be captured in a "changeset".
We use the changesets
tool for creating changesets, publishing versions and updating the changelog.
- Create a changeset for the current change.
> npx changeset
- Select which workspaces are affected by the change and whether the version requires a major, minor or patch release.
- Update the generated changeset with a description of the change.
- Include the generate changeset in the current commit.
> git add ./changeset/*.md
Each changeset is a file that describes the change being merged. This file is used to generate the changelog when the changes are released.
To help maintain consistency in the changelog, changesets should have the following format:
<TYPE>: <TITLE>
<BODY>
[BREAKING CHANGES <BREAKING_CHANGE_NOTES>]
TYPE
should be a single word describing the "type" of the change. For example, one offeature
,fix
,refactor
,docs
orchore
.TITLE
should be a single sentence containing an imperative description of the change.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.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.