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 |
---|---|---|---|---|
extras Type: 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 |
---|---|---|
res Type: String | ||
res | String | The string you gave in the input, just cleaned. |
version Type: 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-changelog
generates. 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 whichprettier
might 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/abcdef
which lead to 404. This program replaces/commits/
with/commit/
if it detects a matchinggit.sr.ht/
-domain URL.