Gulp Conventional Changelog is a Gulp plugin that wraps the conventional-changelog library to generate changelogs as part of Gulp-based build workflows. It provides a streaming interface that integrates with Gulp's file system and supports both buffer and streaming modes for processing changelog files.
npm install --save-dev gulp-conventional-changelogconst conventionalChangelog = require("gulp-conventional-changelog");For ESM:
import conventionalChangelog from "gulp-conventional-changelog";The most common usage pattern for generating changelogs in a Gulp build process:
const gulp = require("gulp");
const conventionalChangelog = require("gulp-conventional-changelog");
gulp.task("changelog", function () {
return gulp.src("CHANGELOG.md")
.pipe(conventionalChangelog({
preset: "angular"
}))
.pipe(gulp.dest("./"));
});The plugin is built around the Node.js Transform stream pattern:
Creates a Gulp transform stream for changelog generation with flexible configuration options.
/**
* Creates a Gulp transform stream for changelog generation
* @param opts - Configuration options for conventional-changelog
* @param context - Context object for changelog generation
* @param gitRawCommitsOpts - Options for git-raw-commits module
* @param parserOpts - Options for conventional-commits-parser
* @param writerOpts - Options for conventional-changelog-writer
* @returns Transform stream for Gulp pipeline
*/
function conventionalChangelog(
opts?: ChangelogOptions,
context?: ChangelogContext,
gitRawCommitsOpts?: GitRawCommitsOptions,
parserOpts?: ParserOptions,
writerOpts?: WriterOptions
): NodeJS.Transform;Usage Examples:
// Basic usage with preset
gulp.src("CHANGELOG.md")
.pipe(conventionalChangelog({
preset: "angular"
}))
.pipe(gulp.dest("./"));
// Full configuration with all options
gulp.src("CHANGELOG.md")
.pipe(conventionalChangelog({
preset: "angular",
releaseCount: 1,
append: false,
verbose: true
}, {
version: "1.0.0",
date: new Date().toISOString()
}, {
from: "HEAD~10"
}, {
noteKeywords: ["BREAKING CHANGE"]
}, {
transform: (commit) => commit
}))
.pipe(gulp.dest("./"));
// Streaming mode
gulp.src("CHANGELOG.md", { buffer: false })
.pipe(conventionalChangelog({
preset: "angular"
}))
.pipe(gulp.dest("./"));
// Generate complete changelog (all releases)
gulp.src("CHANGELOG.md", { read: false })
.pipe(conventionalChangelog({
preset: "angular",
releaseCount: 0
}))
.pipe(gulp.dest("./"));
// Working with a specific repository directory
gulp.src("CHANGELOG.md")
.pipe(conventionalChangelog({
preset: "angular",
cwd: "/path/to/git/repository"
}))
.pipe(gulp.dest("./"));/**
* Configuration options for changelog generation
* @typedef {Object} ChangelogOptions
* @property {string} [preset] - Conventional changelog preset (e.g., 'angular', 'atom', 'ember')
* @property {number} [releaseCount] - Number of releases to include (0 = all releases)
* @property {boolean} [append] - Whether to append new content after existing content (default: false - prepends)
* @property {boolean} [verbose] - Enable verbose logging (auto-detected from --verbose CLI flag)
* @property {Function} [debug] - Debug logging function (set to fancyLog when verbose is true)
* @property {Object} [config] - Configuration object for conventional-changelog
* @property {Function} [warn] - Warning function for logging issues
* @property {string} [cwd] - Working directory for git operations (defaults to process.cwd())
*/
/**
* Context object for changelog generation
* @typedef {Object} ChangelogContext
* @property {string} [version] - Version for changelog generation
* @property {string} [date] - Date for the changelog entry
* @property {...*} [key] - Additional context properties passed to conventional-changelog
*/
/**
* Options for git-raw-commits module
* @typedef {Object} GitRawCommitsOptions
* @property {string} [from] - Starting point for commit analysis
* @property {string} [to] - Ending point for commit analysis
* @property {string} [path] - Path to analyze commits for
* @property {...*} [key] - Additional git-raw-commits options
*/
/**
* Options for conventional-commits-parser
* @typedef {Object} ParserOptions
* @property {string[]} [noteKeywords] - Keywords that indicate breaking changes
* @property {...*} [key] - Additional parser configuration
*/
/**
* Options for conventional-changelog-writer
* @typedef {Object} WriterOptions
* @property {Function} [transform] - Transform function for commits
* @property {...*} [key] - Additional writer configuration
*/When append: false or not specified:
When append: true:
When releaseCount: 0:
The plugin provides proper Gulp error handling:
// Errors are wrapped in PluginError with plugin name
class PluginError extends Error {
plugin: "gulp-conventional-changelog";
message: string;
}Common error scenarios:
// Using built-in presets
conventionalChangelog({ preset: "angular" })
conventionalChangelog({ preset: "atom" })
conventionalChangelog({ preset: "ember" })
// Custom preset configuration
conventionalChangelog({
preset: {
name: "custom",
conventionalChangelog: customConfig
}
})// Latest release only
conventionalChangelog({ releaseCount: 1 })
// Last 3 releases
conventionalChangelog({ releaseCount: 3 })
// All releases (full regeneration)
conventionalChangelog({ releaseCount: 0 })conventionalChangelog({
preset: "angular",
cwd: "/path/to/repo" // Specify working directory
}, {}, {
from: "v1.0.0", // Start from specific tag
to: "HEAD", // End at HEAD
path: "./src" // Only commits affecting specific path
})