lerna-clean-changelogs1.3.60

Removes frivolous changelog 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.deepEqual(
  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/[email protected]@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

`),
  //
  //
  //
  // output:
  {
    version: "1.3.59",
    res: `# 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. It's also an API for lerna-clean-changelogs-cli.

§ 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 we might want to put it on the web or to drive a CLI application using it or whatever. API as string-in, string-out^ is the most universal.

§ API - Output

A plain object is returned and it contains the following keys:

Key's nameKey value's typeDescription
versionStringVersion as present currently in package.json. For example, 1.0.0
resStringThe 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/[email protected]@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/[email protected]@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.

§ Licence

MIT opens in a new tab

Copyright © 2010–2020 Roy Revelt and other contributors

Related packages:

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