- Node.js >= 18.0.0
- npm >= 10.0.0
# Install dependencies
npm install
# Build all packages
npm run build
# Run tests
npm run testpackages/
├── contracts/ # Core types & interfaces
├── jsonapi-codec/ # JSON:API v1.0 codec
├── transport-http/ # HTTP transport layer
├── block-authentication/ # Authentication block
├── block-search/ # Search block
├── angular/ # Angular bindings (RxJS)
├── react/ # React bindings (hooks)
└── sdk/ # Meta-package
| Script | Description |
|---|---|
npm run build |
Build all packages |
npm run build:affected |
Build only affected packages |
npm run test |
Run all tests |
npm run test:affected |
Test only affected packages |
npm run lint |
Lint all packages |
npm run typecheck |
Type-check all packages |
npm run clean |
Clean all build artifacts |
npm run graph |
Visualize dependency graph |
yalc creates a local package registry, simulating a real npm install.
# Install yalc globally (one-time)
npm install -g yalc
# Build and publish to local yalc store
npm run build
npm run yalc:publish
# In your consumer project:
cd /path/to/your/project
# Add packages from yalc
yalc add @23blocks/contracts
yalc add @23blocks/jsonapi-codec
yalc add @23blocks/transport-http
yalc add @23blocks/block-authentication
yalc add @23blocks/react # or @23blocks/angular
# Install dependencies
npm install
# When you make changes to the SDK:
cd /path/to/sdk
npm run build
npm run yalc:push # Updates all linked projects automaticallyTo remove yalc links:
yalc remove @23blocks/contracts
yalc remove --all # Remove all yalc packages# In SDK root
npm run build
# Link each package
cd packages/contracts && npm link
cd ../jsonapi-codec && npm link
cd ../transport-http && npm link
cd ../block-authentication && npm link
cd ../react && npm link
# In your consumer project
npm link @23blocks/contracts
npm link @23blocks/jsonapi-codec
npm link @23blocks/transport-http
npm link @23blocks/block-authentication
npm link @23blocks/react# Start local registry (runs on http://localhost:4873)
npm run local-registry
# In another terminal, publish to local registry
npm config set registry http://localhost:4873
npm run build
npx nx release publish --registry http://localhost:4873
# In your consumer project
npm config set registry http://localhost:4873
npm install @23blocks/react
# Reset to npm public registry when done
npm config set registry https://registry.npmjs.orgIn your consumer project's package.json:
{
"dependencies": {
"@23blocks/contracts": "file:../sdk/packages/contracts",
"@23blocks/react": "file:../sdk/packages/react"
}
}Pushing to main triggers the release workflow:
- Builds all packages
- Runs tests
- Versions packages based on conventional commits
- Generates changelogs
- Publishes to NPM
- Creates GitHub releases
# Dry run to see what would happen
npm run release:dry-run
# Version packages (interactive)
npm run release:version
# Generate changelogs
npm run release:changelog
# Publish to NPM
npm run release:publishVia GitHub Actions:
- Go to Actions > "Publish Manual"
- Select version type (patch/minor/major/prerelease)
- Optionally add prerelease identifier (alpha, beta, rc)
- Run workflow
Use conventional commit format for automatic versioning:
feat: add new feature -> minor version bump
fix: fix a bug -> patch version bump
feat!: breaking change -> major version bump
chore: maintenance work -> no version bump
docs: documentation -> no version bump
Examples:
git commit -m "feat(auth): add MFA support"
git commit -m "fix(search): handle empty results"
git commit -m "feat(react)!: change hook API"-
Generate package:
npx nx g @nx/js:lib block-{name} --directory=packages/block-{name} --bundler=swc -
Update
tsconfig.jsonto add project reference -
Update
tsconfig.base.jsonto add path alias -
Create types, mappers, services following existing patterns
-
Add framework bindings in
@23blocks/angularand@23blocks/react
# View dependency graph
npm run graph
# Check what would be affected by changes
npx nx affected:apps --plain
npx nx affected:libs --plain
# Run specific package build with verbose output
npx nx build block-authentication --verboseFor GitHub Actions to publish:
| Secret | Description |
|---|---|
NPM_TOKEN |
npm access token with publish permissions |
GITHUB_TOKEN |
Auto-provided by GitHub Actions |
To create NPM token:
- Go to npmjs.com > Access Tokens
- Generate new token (Automation type)
- Add to GitHub repo: Settings > Secrets > Actions