Development Workflow
Setup, build, testing, and common tasks for UCD.js contributors
Development Workflow
This guide covers the essential steps for setting up the UCD.js monorepo, building packages, running tests, and performing common development tasks.
Setup
UCD.js is a monorepo managed with pnpm workspaces and Turborepo.
Prerequisites
- Node.js:
>= 24.13 - pnpm: Check the
packageManagerfield inpackage.jsonfor the exact version.
Installation
Clone the repository and install dependencies:
git clone https://github.com/ucdjs/ucd.git
cd ucdpnpm installBuilding
The monorepo separates building packages, applications, and the VS Code extension.
Build all JavaScript and TypeScript packages in the packages/ directory:
pnpm run buildBuild all applications in the apps/ directory (API, Store, Web, Docs):
pnpm run build:appsBuild the VS Code extension:
pnpm run build:vscodeBuild a specific package using Turborepo filtering. Always run this from the repository root.
turbo run build --filter "@ucdjs/<package>"Do not run pnpm run build --filter <package> for individual packages. Always use the turbo filter to specify packages if needed.
Testing
UCD.js uses Vitest for testing. By default, running tests will output coverage reports.
Run all tests across the monorepo:
pnpm run testRun tests in watch mode during development:
pnpm run test:watchRun tests with the Vitest UI:
pnpm run test:uiRun tests for a specific project from the repository root. The project name corresponds to the folder name in packages/ or apps/.
vitest run --project=<project>Testing Patterns
When writing tests, follow these common patterns:
- HTTP Mocking: Use
mockFetchfrom#test-utils/mswfor HTTP/MSW-driven tests. - API Mocking: Prefer
mockStoreApifrom#test-utils/mock-storeso tests stay consistent with the API surface. - Filesystem Tests: Use
testdir()fromvitest-testdirsto get a temporary directory that is cleaned up automatically. - Shared Helpers: Rely on
@ucdjs/test-utils(via#test-utils/*) for helpers that need to be shared across packages.
Code Quality
Ensure your code meets the project's quality standards before submitting a pull request.
# Run ESLint across the monorepo
pnpm run lint
# Run TypeScript type checking
pnpm run typecheckCommon Tasks
Modifying Code
- Packages: Run
pnpm devfor package watch mode and test withvitest run --project=<project>. - Apps: Run
pnpm dev:appsfor app development servers when needed. - CLI: Run the CLI from the repository root using the workspace sources:
./packages/cli/bin/ucd.js <command>
Adding a New Feature
- Implement the feature in the appropriate package or app.
- Add tests for the new functionality.
- Update documentation when public APIs change.
- Run relevant linters and tests for the scope you touched.
API Changes
After changing API routes or Zod schemas in apps/api:
- Run
pnpm build:openapiinapps/api. - Update client expectations if schemas or response formats change.