* docs: add 'cd zod' step to development setup instructions * docs: add 'cd zod' in the third point in a clean way
3.4 KiB
Contributing
⚠ The default branch has just been switched to
mainfrommaster(as of May 15th, 2024). Follow the following instructions to update your local fork.git branch -m master main # rename local branch git fetch origin # fetch from remote git branch -u origin/main main # set upstream git remote set-head origin -a # update remote
When it comes to open source, there are different ways you can contribute, all of which are valuable. Here's few guidelines that should help you as you prepare your contribution.
Initial steps
Before you start working on a contribution, create an issue describing what you want to build. It's possible someone else is already working on something similar, or perhaps there is a reason that feature isn't implemented. The maintainers will point you in the right direction.
Development
The following steps will get you setup to contribute changes to this repo:
-
Fork this repo.
-
Clone your forked repo:
git clone [email protected]:{your_username}/zod.git -
Navigate into the project directory:
cd zod -
Run
yarnto install dependencies. -
Start playing with the code! You can do some simple experimentation in
playground.ts(seeyarn playbelow) or start implementing a feature right away.
Alternative: VSCode Dev Container setup
For an officially supported isolated dev environment that automatically installs dependencies for you:
F1in VSCode and start typingDev Containers: Clone Repository in Named Container Volumeto run the command.- For the repo, paste
[email protected]:{your_username}/zod.gitif you're using ssh. - Click
Create a new volume...and name itzodand the folder name aszod.
Note: if you can't see Dev Containers in the F1 menu, follow this guide to install the needed extension.
In the OSS version of VSCode the extension may be not available.
Commands
yarn build
- deletes
liband re-compilessrctolib
yarn test
- runs all Jest tests and generates coverage badge
yarn test enum
- runs a single test file (e.g.
enum.test.ts)
yarn play
- executes
playground.ts, watches for changes. useful for experimentation
Tests
Zod uses Jest for testing. After implementing your contribution, write tests for it. Just create a new file under src/__tests__ or add additional tests to the appropriate existing file.
Before submitting your PR, run yarn test to make sure there are no (unintended) breaking changes.
Documentation
The Zod documentation lives in the README.md. Be sure to document any API changes you implement.
License
By contributing your code to the zod GitHub repository, you agree to license your contribution under the MIT license.