When it comes to open source, there are different ways you can contribute, all of which are valuable. Here's a few guidelines that should help you as you prepare your contribution.
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.
The following steps will get you set up to contribute changes to this repo:
Install Nub v0.8.3 first. Nub manages dependencies, runs scripts and TypeScript, and provisions the Node version in .nvmrc. The existing pnpm-lock.yaml is the lockfile format, not a requirement to install pnpm.
curl -fsSL https://raw.githubusercontent.com/nubjs/nub/0ae8783f1f93763c56dfc827892cfb679e8a0a77/install.sh | bash -s -- 0.8.3Restart the shell after installation so Nub is on PATH.
-
Fork this repo.
-
Clone your forked repo:
git clone git@github.com:{your_username}/zod.git -
Run
nub install --frozen-lockfileto install dependencies. -
Start playing with the code! You can do some simple experimentation in
play.ts(seenub run dev:playbelow) or start implementing a feature right away.
To start a dev server, run:
nub run --filter=@zod/docs devTo build @zod/docs for production, you will need to set the GITHUB_TOKEN environment variable to a personal access token. Create a granular personal access token and accept the defaults (no extra permissions are necessary). Then:
export GITHUB_TOKEN=your_token_here # persists in shell session
nub run --filter=@zod/docs buildThe
GITHUB_TOKENenvironment variable is used to fetch stargazer counts of projects in Zod's ecosystem.
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
git@github.com:{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 not be available.
| Command | Purpose |
|---|---|
nub run build |
Build Zod and Zod Mini, including their declarations |
nub run test |
Run all Vitest projects, including compile mode and type checks |
nub run test:watch |
Start Vitest in watch mode |
nub run test <file> |
Run test files matching <file> |
nub run dev:play |
Execute play.ts against source |
nub run dev:watch play.ts |
Re-run the playground when its imports change |
nub run --filter @zod/resolution test:all |
Check the built package's declarations and module resolution |
nub add -Dw <package> |
Add a root development dependency |
Run nub run build before testing built-package resolution and bundle sizes. Repository scripts use nub exec --node for third-party tools so tests retain plain Node semantics.
Zod uses Vitest for testing. After implementing your contribution, write tests for it. Just create a new file in the tests directory of any workspace, or add additional tests to an existing file if appropriate.
Zod uses git hooks to execute tests before
git push. Before submitting your PR, runnub run testto make sure there are no (unintended) breaking changes.
The documentation site lives in packages/docs with content located at packages/docs/content. Be sure to document any API changes you implement.
By contributing your code to the zod GitHub repository, you agree to license your contribution under the MIT license.