Gathering detailed insights and metrics for @slavkojos/keep-a-changelog
Gathering detailed insights and metrics for @slavkojos/keep-a-changelog
Gathering detailed insights and metrics for @slavkojos/keep-a-changelog
Gathering detailed insights and metrics for @slavkojos/keep-a-changelog
Node & Deno package to parse and generate changelogs
npm install @slavkojos/keep-a-changelog
Typescript
Module System
Node Version
NPM Version
73.4
Supply Chain
81.1
Quality
76
Maintenance
100
Vulnerability
99.6
License
TypeScript (100%)
Total Downloads
2,086
Last Day
1
Last Week
6
Last Month
31
Last Year
398
MIT License
140 Commits
1 Branches
1 Contributors
Updated on Mar 28, 2023
Minified
Minified + Gzipped
Latest Version
1.1.2
Package Id
@slavkojos/keep-a-changelog@1.1.2
Unpacked Size
103.01 kB
Size
32.55 kB
File Count
29
NPM Version
8.19.2
Node Version
16.18.0
Published on
Mar 28, 2023
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
20%
6
Compared to previous week
Last Month
-48.3%
31
Compared to previous month
Last Year
-41.1%
398
Compared to previous year
4
Keep a Changelog library for Node & Deno
Deno package to parse and generate changelogs following the keepachangelog format.
1import { parser } from "keep-a-changelog"; 2import fs from "fs"; 3 4//Parse a changelog file 5const changelog = parser(fs.readFileSync("CHANGELOG.md", "UTF-8")); 6 7//Generate the new changelog string 8console.log(changelog.toString());
1import { parser } from "https://deno.land/x/changelog@v2.0.0/mod.ts"; 2 3//Parse a changelog file 4const changelog = parser(await Deno.readTextFile("CHANGELOG.md")); 5 6//Generate the new changelog string 7console.log(changelog.toString());
1import { 2 Changelog, 3 Release, 4} from "https://deno.land/x/changelog@v2.0.0/mod.ts"; 5 6const changelog = new Changelog("My project") 7 .addRelease( 8 new Release("0.1.0", "2017-12-06") 9 .added("New awesome feature") 10 .added("New other awesome feature") 11 .fixed("Bug #3") 12 .removed("Drop support for X"), 13 ) 14 .addRelease( 15 new Release("0.2.0", "2017-12-09") 16 .security("Fixed security vulnerability") 17 .deprecated("Feature X is deprecated"), 18 ); 19 20console.log(changelog.toString());
By default, the output format of the markdown is "compact", that removes the
space after the headings. You can change it to follow the
markdownlint
rules:
1const changelog = new Changelog(); 2changelog.format = "markdownlint";
By default, the tag names are v
+ version number. For example, the tag for the
version 2.4.9
is v2.4.9
. To change this behavior, set a new
tagNameBuilder
:
1const changelog = new Changelog(); 2changelog.tagNameBuilder = (release) => `version-${release.version}`;
By default and according to the
keepachangelog format, the change types
are Added
, Changed
, Deprecated
, Removed
, Fixed
, and Security
.
In case you'd like add another type, you need to extend the Release
class to
support new types. Additionally, you have to tell the parser
that it should
create instances of your new extended Release
in order to parse your changelog
correctly.
For example, we would like to add a type Maintenance
. Extend the provided
Release
class:
1class CustomRelease extends Release { 2 constructor(version, date, description) { 3 super(version, date, description); 4 // add whatever types you want - in lowercase 5 const newChangeTypes = [ 6 ["maintenance", []], 7 ]; 8 9 this.changes = new Map([...this.changes, ...newChangeTypes]); 10 } 11 // for convenience, add a new method to add change of type 'maintanance' 12 maintenance(change) { 13 return this.addChange("maintenance", change); 14 } 15}
And once you want to use the parser:
1const releaseCreator = (ver, date, desc) => new CustomRelease(ver, date, desc);
2const changelog = parser(changelogTextContent, { releaseCreator });
This library provides the changelog
command to normalize the changelog format.
It reads the CHANGELOG.md file and override it with the new format:
Deno:
1deno install --allow-read --allow-write --name changelog https://deno.land/x/changelog/bin.ts
Node:
1npm install keep-a-changelog -g
Run the script:
1changelog
To use other file name:
1changelog --file=History.md
To generate an empty new CHANGELOG.md file:
1changelog --init
You can release automatically the latest "Unreleased" version:
1changelog --release
And return the latest released version:
1changelog --latest-release 2> 0.3.1
Available options:
Option | Description |
---|---|
--format | The output format for the generated markdown. It can be markdownlint or compact . The default value is compact . |
--file | The markdown file of the changelog. The default value is CHANGELOG.md . |
--url | The base url used to build the diff urls of the different releases. It is taken from the existing diff urls in the markdown. If no urls are found, try to catch it using the url of the git remote repository. |
--https | Set to false to use http instead https in the url (--https=false ). |
--init | Init a new empty changelog file. |
--latest-release | Print the latest release version. |
--release | Updated the latest unreleased version with the current date. |
--quiet | Do not output error messages |
No vulnerabilities found.
No security vulnerabilities found.