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:
| Key | Type | Obligatory | Default | Description |
|---|---|---|---|---|
extrasType: Boolean Obligatory: no Default: false | ||||
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 | Type | Description |
|---|---|---|
resType: String | ||
res | String | The string you gave in the input, just cleaned. |
versionType: String | ||
version | String | Version 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:
-
It removes bump-only changelog entries that
conventional-changeloggenerates. For example:**Note:** Version bump only for package ranges-applyThese will be deleted along with their headings.
-
If
opts.extrasenabled — 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.extrasenabled — removesh1headings 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-changelogitself leaves excessive whitespace whichprettiermight change later, causing annoying changes in git. -
Converts any unordered lists that use asterisks (
*) into dashes (-), to matchprettier. Here’s proof. -
On Sourcehut, links are generated with plural,
/commits/, for example:https://git.sr.ht/~user/project/commits/abcdefwhich lead to 404. This program replaces/commits/with/commit/if it detects a matchinggit.sr.ht/-domain URL.