I want to think you first for considering contributing to ZenStack 🙏🏻. It's people like you who make ZenStack a better toolkit that benefits more and more developers! This document will help you get started, and please join our Discord if you have any questions.
-
Make a fork of the repository
Make sure all branches are included.
-
Clone your fork
-
Switch to the "dev" branch
git checkout dev
-
Install dependencies
pnpm install
-
Build the project
ZenStack uses pnpm workspace to manage packages in the monorepo. To build the project, run the following command in the root directory:
pnpm build
-
Run tests
pnpm test
ZenStack adopts a very simple development workflow:
-
Changes should be made in branches created off the "dev" branch.
-
After coding and testing, create a PR to merge the changes into the "dev" branch.
-
After code review is done, the PR is squashed and merged into the "dev" branch.
-
Periodically, the "dev" branch is merged back to the "main" branch to create a new release.
ZenStack is a monorepo consisting of multiple NPM packages managed by pnpm workspace. The packages reside in the "packages" folder:
The ZModel language's definition, including its syntax definition and parser/linker implementation. The compiler is implemented with the Langium toolkit.
The zenstack
CLI and ZModel VSCode extension implementation. The package also contains several built-in plugins: @core/prisma
, @core/model-meta
, @core/access-policy
, and core/zod
.
Runtime enhancements to PrismaClient, including infrastructure for creating transparent proxies and concrete implementations for the withPolicy
, withPassword
, and withOmit
proxies.
The server
package contains two main parts:
-
Framework-agnostic API handlers: defining input/output format and API routes in a framework-independent way. Currently supports "rpc" and "rest" styles.
-
Framework-specific adapters: translating framework-dependent request and response formats.
Contains utilities for building ZenStack plugins.
Plugins for generating different artifacts from the ZModel schema.
You can use one of the two ways to test changed packages locally:
-
Copy built packages to overwrite the installed ones
After making changes, run
pnpm build
and then copy the generated artifacts from thedist
folder to thenode_modules
folder of your test project to overwrite the installed code. -
Publish packages to a local registry
You can run a local NPM registry (like Verdaccio) and publish the changed packages to it. There's a preconfigured
pnpm publish-preview
command that publishes all locally built packages to a local Verdaccio registry (http://localhost:4873).The easiest way to install Verdaccio locally is to use Docker.