npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

releaselog

v5.0.1

Published

Gets the contents of a specific release from a changelog

Downloads

234

Readme

Releaselog

Releaselog extracts the title and notes for a specific release from a CHANGELOG. For details on why to keep a CHANGELOG, CHANGELOG best practices, etc see https://keepachangelog.com/.

Installation

npm install releaselog

Command Line Usage

The releaselog command line interface is run as follows:

Usage: releaselog [options] <version>

Options:
  -c, --changelog <file>  the path to the CHANGELOG (directory or file) (default: "./")
  -f, --format <value>    the output format ("json", "title", or "notes") (default: "json")
  -h, --help              output usage information

The version to extract from the CHANGELOG must be provided. For example, to output the details for version 1.0.0 from a CHANGELOG in the current directory to a JSON file (assuming installed globally):

> releaselog 1.0.0 > release.json

# release.json:
# {"title":"Version 1.0.0","notes":"Initial release"}

The format option can be used to extract a subset of the release details (title or notes). From the previous example, to output only the release notes for version 1.0.0 to a file:

> releaselog --format=notes 1.0.0 > release_notes.txt

# release_notes.txt:
# Initial release

The optional changelog parameter can be used to provide the path to either a file or directory. If not provided, the current working directory is used. If any directory is specified, the findChangelog function is used to find the CHANGELOG file. See below for details on how the CHANGELOG file is selected.

Module usage

The releaselog module includes two functions: getReleaseDetails and findChangelog.

getReleaseDetails returns an object with the title and notes for the given version if found in the specified CHANGELOG.

const releaselog = require('releaselog');
const { title, notes } = releaselog.getReleaseDetails(
  './CHANGELOG.md',
  '1.0.0'
);

See below for CHANGELOG requirements for use with releaselog.

If not know, findChangelog can be used to return the full path of the CHANGELOG in the specified directory.

const releaselog = require('releaselog');
const changelog = releaselog.findChangelog('./');
const { title, notes } = releaselog.getReleaseDetails(changelog, '1.0.0');

This finds the "primary" CHANGELOG in the specified location. The CHANGELOG name must contain "changelog" (case-insensitive). for example CHANGELOG, changelog.md, CHANGELOG-EE.md. If multiple CHANGELOGs are found in that directory, changelog.md (case-insensitive) is assumed to be primary. Otherwise, the first CHANGELOG in the directory listing is used.

Changelog requirements

Releaselog is designed to support whatever versioning scheme is used - SemVer, CalVer, etc. It also allows flexibility in the CHANGELOG format, but it must conform to the following requirements:

  • The file format must be markdown
  • Version titles must use markdown headers. The header can be any level ## through ##### (not #), but the same header type must be used for all titles.
  • The text of the version must be included in the version title line. If the version starts with "v" (for example "v1.1.0"), it is stripped and the remaining text is used (for example "1.1.0").

Once the current version is found, the header format for that line is assumed for all versions, and the next occurrence in the CHANGELOG signals the end of the release content. All text between those lines is included in the release notes, allowing flexibility in the release note content.

As an example, searching the following CHANGELOG for version "v1.1.0" (note the "v" is stripped before searching the CHANGELOG):

# Changelog

## Version 1.1.0 (2019-02-03)

### Added

- Add new feature 1
- Add another new feature

### Fixed

- Update `foo` to fix `bar`

## Version 1.0.0 (2019-01-26)

- Initial release

Results in a release with the title Version 1.1.0 (2019-02-03) and the following notes:

### Added

- Add new feature 1
- Add another new feature

### Fixed

- Update `foo` to fix `bar`