CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-release-it--conventional-changelog

Conventional changelog plugin for release-it that automates changelog generation and semantic version bumping based on conventional commits

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

Conventional Changelog Plugin for release-it

The @release-it/conventional-changelog plugin automates changelog generation and semantic version bumping for release-it. It analyzes conventional commits to determine the appropriate version bump (major, minor, patch) and generates comprehensive changelog files using conventional changelog standards.

Package Information

  • Package Name: @release-it/conventional-changelog
  • Package Type: npm
  • Language: JavaScript (ES Module)
  • Node.js: ^20.9.0 || >=22.0.0
  • Installation: npm install --save-dev @release-it/conventional-changelog

Core Imports

This plugin is typically configured in release-it rather than imported directly. However, for programmatic usage or extension:

import ConventionalChangelog from "@release-it/conventional-changelog";

For CommonJS environments:

const ConventionalChangelog = require("@release-it/conventional-changelog");

Basic Usage

This plugin is typically configured in the release-it configuration file:

{
  "plugins": {
    "@release-it/conventional-changelog": {
      "preset": {
        "name": "angular"
      },
      "infile": "CHANGELOG.md"
    }
  }
}

Architecture

The plugin extends the release-it Plugin base class and integrates with the conventional changelog ecosystem:

  • Plugin Integration: Extends release-it's Plugin class to provide lifecycle hooks
  • Version Bump Analysis: Uses conventional-recommended-bump to analyze commits and determine version changes
  • Changelog Generation: Leverages conventional-changelog-core for generating formatted changelog content
  • File Management: Handles reading/writing changelog files with proper formatting and headers
  • Git Integration: Works with git tags and commit history to build comprehensive changelogs

Capabilities

Plugin Class

Main plugin class that provides conventional changelog functionality for release-it.

class ConventionalChangelog extends Plugin {
  /**
   * Determines whether to disable the plugin based on options
   * @param {Object} options - Plugin configuration options
   * @returns {string|null} 'version' if plugin should be disabled, null otherwise
   */
  static disablePlugin(options);

  /**
   * Processes initial plugin options and sets tag prefix
   * @param {Object} options - Configuration options
   * @param {string} namespace - Plugin namespace
   * @returns {Object} Processed options for namespace
   */
  getInitialOptions(options, namespace);

  /**
   * Generates changelog for given version
   * @param {string} latestVersion - Latest version string
   * @returns {Promise<string>} Generated changelog
   */
  async getChangelog(latestVersion);

  /**
   * Calculates recommended version based on conventional commits
   * @param {Object} options - Configuration with increment, latestVersion, isPreRelease, preReleaseId
   * @param {string} options.increment - Increment type (major, minor, patch)
   * @param {string} options.latestVersion - Latest version string
   * @param {boolean} options.isPreRelease - Whether this is a pre-release
   * @param {string} options.preReleaseId - Pre-release identifier
   * @returns {Promise<string|null>} Recommended version or null
   */
  async getRecommendedVersion({ increment, latestVersion, isPreRelease, preReleaseId });

  /**
   * Creates a stream for generating changelog content
   * @param {Object} rawOptions - Optional raw options for changelog generation (defaults to {})
   * @returns {NodeJS.ReadableStream} conventional-changelog stream
   */
  getChangelogStream(rawOptions = {});

  /**
   * Generates changelog as a string promise
   * @param {Object} options - Optional changelog generation options
   * @returns {Promise<string>} Generated changelog
   */
  generateChangelog(options);

  /**
   * Reads existing changelog from infile
   * @returns {Promise<string>} Existing changelog content
   */
  getPreviousChangelog();

  /**
   * Writes generated changelog to file
   * @returns {Promise<void>}
   */
  async writeChangelog();

  /**
   * Gets incremented version if not ignoring recommended bump
   * @param {Object} options - Version increment options
   * @returns {Promise<string|null>} Incremented version or null
   */
  getIncrementedVersion(options);

  /**
   * Gets incremented version for CI environments
   * @param {Object} options - Version increment options
   * @returns {Promise<string|null>} Incremented version or null
   */
  getIncrementedVersionCI(options);

  /**
   * Sets version context and generates changelog if needed
   * @param {string} version - Target version
   * @returns {Promise<void>}
   */
  async bump(version);

  /**
   * Hook executed before release, writes changelog to file
   * @returns {Promise<void>}
   */
  async beforeRelease();
}

Configuration Options

Core Configuration

interface PluginOptions {
  /** Conventional changelog preset configuration */
  preset?: PresetConfig | string;
  /** Path to changelog file */
  infile?: string | false;
  /** Header for changelog file (defaults to "# Changelog") */
  header?: string;
  /** Whether to ignore recommended version bump */
  ignoreRecommendedBump?: boolean;
  /** Whether to strictly follow semver for pre-releases */
  strictSemVer?: boolean;
}

interface PresetConfig {
  /** Preset name (angular, conventionalcommits, etc.) */
  name: string;
  /** Custom commit types configuration */
  types?: Array<{
    type: string;
    section: string;
  }>;
}

Advanced Configuration

interface AdvancedOptions {
  /** Options for commit analysis */
  commitsOpts?: Object;
  /** Options for git tag handling */
  tagOpts?: Object;
  /** Custom bump determination function or false to skip */
  whatBump?: Function | false;
  /** Additional context for changelog generation */
  context?: Object;
  /** Options for git-raw-commits */
  gitRawCommitsOpts?: Object;
  /** Options for conventional-commits-parser */
  parserOpts?: Object;
  /** Options for conventional-changelog-writer */
  writerOpts?: Object;
  /** Lerna package name for monorepo support */
  lernaPackage?: string;
  /** Current working directory for git operations */
  cwd?: string;
  /** Git tag prefix for version tags */
  tagPrefix?: string;
}

Supported Presets

The plugin supports multiple conventional changelog presets:

  • angular - Angular commit convention
  • atom - Atom editor convention
  • codemirror - CodeMirror convention
  • conventionalcommits - Conventional Commits specification
  • ember - Ember.js convention
  • eslint - ESLint convention
  • express - Express.js convention
  • jquery - jQuery convention
  • jscs - JSCS convention
  • jshint - JSHint convention

Integration with release-it

Command Line Usage

Plugin options can be configured via command line:

# Set changelog file
release-it --plugins.@release-it/conventional-changelog.infile=history.md

# Disable changelog file writing
release-it --no-plugins.@release-it/conventional-changelog.infile

# Use dot notation for nested options
release-it --plugins.@release-it/conventional-changelog.preset.name=angular

GitHub Actions Integration

When using in GitHub Actions, ensure fetch-depth: 0 is set to access full git history:

- uses: actions/checkout@v4
  with:
    fetch-depth: 0

Dependencies

Required Dependencies

  • concat-stream ^2.0.0 - Stream concatenation utility
  • conventional-changelog ^6.0.0 - Core conventional changelog functionality
  • conventional-recommended-bump ^10.0.0 - Version bump recommendations
  • git-semver-tags ^8.0.0 - Git semver tag utilities
  • semver ^7.6.3 - Semantic version handling

Peer Dependencies

  • release-it ^18.0.0 || ^19.0.0 - Required release-it framework

Error Handling

The plugin handles various error conditions gracefully:

  • Missing git repository: Throws appropriate errors when git history is unavailable
  • Invalid configurations: Validates preset and option configurations
  • File system errors: Handles missing changelog files by creating them with full history
  • Parse errors: Reports commit parsing issues with detailed error messages
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@release-it/conventional-changelog@10.0.x
Publish Source
CLI
Badge
tessl/npm-release-it--conventional-changelog badge