lerna-clean-changelogs2.1.0

Removes frivolous entries from commitizen generated changelogs

Quick Take

import { strict as assert } from "assert";
import { cleanChangelogs } from "lerna-clean-changelogs";

// are all values equal to null:
assert.equal(
  cleanChangelogs(`# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2.9.2 (2018-12-27)







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



## [2.9.1](https://gitlab.com/codsen/codsen/tree/master/packages/ranges-apply/compare/ranges-apply@2.9.0...ranges-apply@2.9.1) (2018-12-27)

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

## 2.9.0 (2018-12-26)

### Bug Fixes

* aaa

### Features

* bbb

`).res,
  //
  //
  //
  // output:
  `# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2.9.0 (2018-12-26)

### Bug Fixes

- aaa

### Features

- bbb
`
);

Purpose

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

cleaning

It is used in a Lerna monorepos environment.

API

cleanChangelogs(str)

In other words, a function takes one, obligatory argument, a string.

This library is deliberately decoupled from the file read/write operations because of separation of concerns opens in a new tab.

API - Output

A plain object is returned and it contains 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",
}

Algorithm

This package performs the following cleaning steps:

  1. 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.

  2. It 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. Remove h1 headings and turn them into h2, 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)

  4. 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.

  5. If existing, pre-lerna changelog entries use dashes to note list items, those dashes are updated to match conventional-changelog notation using asterisks.

  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

See it in the monorepo opens in a new tab, on GitHub.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub opens in a new tab.

Any code contributions welcome! All Pull Requests will be dealt promptly.

Licence

MIT opens in a new tab

Copyright © 2010–2021 Roy Revelt and other contributors

Related packages:

📦 lerna-clean-changelogs-cli 1.5.0
CLI application to cleanse the lerna/commitizen-generated changelogs
📦 lerna-link-dep 1.4.0
Like lerna add but does just the symlinking, works on CLI bins too