CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lerna

Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

version-management.mddocs/

Version Management

Automated versioning of packages with conventional commits, git tagging, and changelog generation.

Capabilities

Version Command

Updates package versions, creates git tags, and generates changelogs.

# Interactive version selection
lerna version

# Explicit version increment
lerna version patch
lerna version minor  
lerna version major
lerna version premajor
lerna version preminor
lerna version prepatch
lerna version prerelease

# Explicit version number
lerna version 1.2.3

# Graduate prerelease versions to stable
lerna version --conventional-graduate

# Create prerelease versions
lerna version --conventional-prerelease

# Use conventional commits for automatic version determination
lerna version --conventional-commits

# Create GitHub/GitLab release
lerna version --create-release github
lerna version --create-release gitlab

# Custom commit message
lerna version --message "chore: release %s"

# Skip git operations
lerna version --no-git-tag-version
lerna version --no-push

# Allow versioning on specific branch(es)
lerna version --allow-branch main
lerna version --allow-branch "release/*"

# Force publish all packages (ignore change detection)
lerna version --force-publish

# Include dependencies in version updates
lerna version --exact

Advanced Version Options

Additional options for fine-tuning version behavior:

# Conventional commits options
lerna version --conventional-commits
lerna version --conventional-bump-prerelease
lerna version --changelog-preset angular
lerna version --changelog-entry-additional-markdown "Additional notes"
lerna version --force-conventional-graduate

# Git and commit options  
lerna version --signoff-git-commit
lerna version --force-git-tag
lerna version --tag-version-separator "@"
lerna version --git-tag-command "custom-tag-command"
lerna version --no-granular-pathspec
lerna version --no-commit-hooks

# Package and dependency management
lerna version --sync-dist-version
lerna version --run-scripts-on-lockfile-update
lerna version --npm-client-args "--no-package-lock"
lerna version --premajor-version-bump force-patch

# Change detection and filtering
lerna version --ignore-changes "**/*.md" "**/__tests__/**"
lerna version --include-merged-tags
lerna version --no-private

# Output and automation
lerna version --json
lerna version --yes
lerna version --ignore-scripts

Advanced Option Details:

  • --conventional-bump-prerelease - Bump prerelease versions when conventional commits require it
  • --changelog-preset - Specify custom conventional-changelog preset (default: angular)
  • --changelog-entry-additional-markdown - Add custom markdown to changelog entries
  • --force-conventional-graduate - Force graduation regardless of changes
  • --signoff-git-commit - Add Signed-off-by line to commit messages
  • --force-git-tag - Force creation of git tags even if they exist
  • --tag-version-separator - Customize separator for independent versioning tags
  • --git-tag-command - Use custom command for git tag creation
  • --no-granular-pathspec - Stage all changes globally instead of file-by-file
  • --no-commit-hooks - Skip git commit hooks during version commit
  • --sync-dist-version - Update package.json in distribution directories
  • --run-scripts-on-lockfile-update - Run lifecycle scripts during lockfile updates
  • --npm-client-args - Pass additional arguments to npm client
  • --premajor-version-bump - Control pre-major version bump behavior (default, force-patch)
  • --ignore-changes - Ignore specific file patterns for change detection
  • --include-merged-tags - Include tags from merged branches in change detection
  • --no-private - Exclude private packages from versioning
  • --json - Output version information in JSON format
  • --ignore-scripts - Disable all lifecycle scripts during versioning

Version Workflow

The lerna version command performs the following steps:

  1. Change Detection: Identifies packages that have changed since the last release
  2. Version Selection: Prompts for version increments or uses conventional commits
  3. Cross-dependencies: Updates references between workspace packages
  4. Git Operations: Creates commits and tags for the new versions
  5. Release Creation: Optionally creates GitHub/GitLab releases

Conventional Commits

Lerna supports conventional commits for automatic version determination:

# Enable conventional commits
lerna version --conventional-commits

# Graduate prereleases using conventional commits
lerna version --conventional-graduate

# Create prereleases using conventional commits  
lerna version --conventional-prerelease

# Combine with release creation
lerna version --conventional-commits --create-release github

Conventional Commit Format:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Version Impact:

  • fix: → patch version
  • feat: → minor version
  • BREAKING CHANGE: or ! → major version

Version Configuration

interface VersionConfig {
  /** Branches allowed for versioning */
  allowBranch?: string | string[];
  /** Use conventional commits for version determination */
  conventionalCommits?: boolean;
  /** Commit message template (%s = version, %v = tag) */
  message?: string;
  /** Push commits and tags to remote */
  push?: boolean;
  /** Create release on GitHub/GitLab */
  createRelease?: 'github' | 'gitlab';
  /** Sign git commits and tags */
  signGitCommit?: boolean;
  /** Sign git tags */
  signGitTag?: boolean;
  /** Force publish all packages */
  forcePublish?: boolean | string | string[];
  /** Use exact versions for cross-dependencies */
  exact?: boolean;
  /** Preid for prerelease versions */
  preid?: string;
  /** Include dependencies in version updates */  
  includeDependencies?: boolean;
  /** Include dependents in version updates */
  includeDependents?: boolean;
  /** Graduate prerelease packages to stable */
  conventionalGraduate?: boolean | string | string[];
  /** Create prerelease versions */
  conventionalPrerelease?: boolean | string | string[];
}

Usage in lerna.json:

{
  "version": "independent",
  "command": {
    "version": {
      "allowBranch": ["main", "release/*"],
      "conventionalCommits": true,
      "message": "chore: release %s",
      "createRelease": "github",
      "push": true,
      "exact": true
    }
  }
}

Versioning Modes

Fixed Mode

All packages share the same version number.

{
  "version": "1.2.3"
}

Independent Mode

Each package maintains its own version.

{
  "version": "independent"
}

Git Integration

# Skip git tag creation
lerna version --no-git-tag-version

# Skip pushing to remote
lerna version --no-push

# Custom tag prefix
lerna version --tag-version-prefix="v"

# Sign commits and tags
lerna version --sign-git-commit --sign-git-tag

# Allow versioning on dirty working tree
lerna version --allow-dirty

Release Creation

# Create GitHub release with generated changelog
lerna version --create-release github

# Create GitLab release
lerna version --create-release gitlab

# Skip release creation
lerna version --no-create-release

Release creation requires:

  • GitHub: GH_TOKEN or GITHUB_TOKEN environment variable
  • GitLab: GL_TOKEN or GITLAB_TOKEN environment variable

The release will include:

  • Auto-generated changelog from conventional commits
  • Links to commits and pull requests
  • Package-specific release notes (in independent mode)

docs

change-detection.md

configuration.md

index.md

package-management.md

package-operations.md

publishing.md

script-execution.md

version-management.md

tile.json