- Clean git status
- Logged in to npm (
npm login) - Logged in to git (
git loginor SSH keys configured)
We use a helper script to automate version bumping, building, publishing, and git tagging.
# For patch release (0.1.0 -> 0.1.1)
pnpm release:helper patch
# For minor release (0.1.0 -> 0.2.0)
pnpm release:helper minor
# For major release (0.1.0 -> 1.0.0)
pnpm release:helper majorThe script will:
- Bump versions in all packages
- Build all packages
- Pre-validate: Check package.json for workspace leaks
- Publish: Use
pnpm publishto automatically rewriteworkspace:*to concrete versions - Post-validate: Verify npm registry has correct versions
After successful publish, the script prints the next steps:
pnpm install
git add -A
git commit -m "chore: Release vX.Y.Z"
git tag vX.Y.Z
git push origin main --tagsEnsure CHANGELOG.md is updated with the new version and date.
We use workspace:* protocol in package.json for internal dependencies. This ensures local development always uses the live code in the monorepo.
Crucial: We must NEVER publish packages with workspace:* dependencies to npm. Users cannot install them.
We use a two-layer defense:
- pnpm Publish: We strictly use
pnpm publish(notnpm publish). pnpm automatically rewritesworkspace:*to the concrete version frompackage.jsonduring the align process. - Post-publish Validation:
scripts/validate-published-deps.mjsqueries the npm registry immediately after publishing. If it detectsworkspace:*leaks, it alerts you to unpublish.
To manually check a published package:
npm view aligntrue@latest dependenciesYou should see concrete versions (e.g., ^0.2.2), NOT workspace:*.
IMPORTANT: pnpm pack creates tarballs with workspace:* dependencies intact, which npm cannot resolve during global installation.
Method 1: Use absolute path to CLI binary (RECOMMENDED)
cd /path/to/workspace
pnpm build # Build all packages first
# Use absolute path
/path/to/workspace/packages/cli/dist/index.js --versionThis is the most reliable method and always works.
Method 2: Use distribution simulation script
cd packages/cli
bash tests/scripts/test-distribution.shThis script simulates the real npm distribution experience by rewriting workspace:* to concrete versions.
pnpm link --global creates a symlink, but Node.js ESM loader cannot resolve workspace:* protocol through symlinks, even after building. This is a fundamental limitation:
- The CLI
package.jsonhasworkspace:*dependencies - Node.js follows the symlink to the workspace
- When resolving subpath exports like
@aligntrue/core/config/edit-source-patterns, Node.js looks at thepackage.jsonwhich hasworkspace:* - The ESM loader can't resolve
workspace:*protocol references
Result: ERR_PACKAGE_PATH_NOT_EXPORTED errors for all subpath imports.
Always use pnpm publish which automatically rewrites workspace:* to concrete versions.
pnpm link --globalfor testing (will fail with ERR_PACKAGE_PATH_NOT_EXPORTED)npm install -g <tarball>frompnpm pack(will fail with workspace protocol errors)
Use absolute paths or the distribution simulation script instead.