Installation
Quick Take
Purpose
This program removes the frivolous changelog file entries generated by commitizen:

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:
options object's key | Type | Obligatory? | Default | Description |
---|---|---|---|---|
extras | Boolean | no | false | Extras: 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 name | Key value's type | Description |
---|---|---|
version | String | Version as present currently in package.json . For example, 1.0.0 |
res | String | The string you gave in the input, just cleaned. |
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:
-
It removes bump-only changelog entries that
conventional-changelog
generates. There can be many reasons For example:**Note:** Version bump only for package ranges-apply
These will be deleted along with their headings.
-
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.
-
If
opts.extras
enabled — removesh1
headings and turns them intoh2
, with the exception of the first, main heading of the changelog.For exampe, 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)
-
Replaces two or more empty lines into one line.
conventional-changelog
itself leaves excessive whitespace. As a bonus, if line only contains whitespace characters (spaces, tabs etc.) those whitespace characters are removed. They're hard to spot but useless. -
If existing, pre-lerna changelog entries use dashes to note list items, those dashes are updated to match
conventional-changelog
notation using asterisks. -
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 matchinggit.sr.ht/
-domain URL.