Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

prevOpen Source→lerna-clean-changelogsnext

lerna-clean-changelogs5.2.1

Removes frivolous entries from commitizen generated changelogs

Downloads per monthChangelogMIT Licenselibera manifesto
  • the top
  • Installation
  • Quick Take
  • Examples
  • PURPOSE
  • API — CLEANCHANGEL…
  • API — DEFAULTS
  • API — VERSION
  • ALGORITHM
  • Changelog

Installation

Quick Take

Examples

  • Fix SourceHut commit links
  • Preserve CRLF line endings
  • Remove WIP entries and tidy the headings

Purpose

This program removes the frivolous changelog file entries generated by commitizenopens in a new tab:

cleaning
cleaning

It is used in a Lerna monorepos environment.

API — cleanChangelogs()

The main function cleanChangelogs() is imported like this:

It’s a function which takes two input arguments:

The optional options object has the following shape:

KeyTypeObligatoryDefaultDescription
extras
Type: Boolean
Obligatory: no
Default: false
extrasBooleannofalseExtras: 1. removes diff links from headers; 2. turns h1 into h2

Here are all defaults in one place for copying:

Function returns a plain object with the following keys:

Key’s nameTypeDescription
res
Type: String
resStringThe string you gave in the input, just cleaned.
version
Type: String
versionStringVersion as present currently in package.json. For example, 1.0.0

for example,

{
  res: "some text",
  version: "1.3.56",
}

API — defaults

You can import defaults:

It's a plain object:

The main function calculates the options to be used by merging the options you passed with these defaults.

API — version

You can import version:

Algorithm

This package performs the following cleaning steps:

  1. It removes bump-only changelog entries that conventional-changelog generates. For example:

    **Note:** Version bump only for package ranges-apply
    

    These will be deleted along with their headings.

  2. If opts.extras enabled — removes diff links from headings. Change the following:

    ## [2.9.1](/os/ranges-apply/compare/ranges-apply@2.9.0...ranges-apply@2.9.1) (2018-12-27)
    

    into:

    ## 2.9.1 (2018-12-27)
    

    We need to do that because those links don’t work on BitBucket and, generally, are a noise.

  3. If opts.extras enabled — removes h1 headings and turns them into h2, with the exception of the first, main heading of the changelog.

    For example, change the following:

    # [2.0.0](/os/ranges-apply/compare/ranges-apply@2.0.0...ranges-apply@1.9.1) (2018-12-27)
    

    into:

    ## 2.0.0 (2018-12-27)
    

    (notice how a second hash character added, beside link being removed)

  4. Replaces two or more empty lines into one line. conventional-changelog itself leaves excessive whitespace which prettier might change later, causing annoying changes in git.

  5. Converts any unordered lists that use asterisks (*) into dashes (-), to match prettier. Here’s proofopens in a new tab.

  6. On Sourcehut, links are generated with plural, /commits/, for example: https://git.sr.ht/~user/project/commits/abcdef which lead to 404. This program replaces /commits/ with /commit/ if it detects a matching git.sr.ht/-domain URL.

Changelog

Open Changelog
↑ back to top
prev next

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab