@shaman-apprentice/release-parrot
v1.1.1
Published
Automate changelog and package version bumps for Node.js libraries.
Maintainers
Readme
release-parrot 🦜
Automate changelog and package.json version bumps for Node.js libraries. release-parrot reads an existing changelog, promotes its unreleased section to the next semantic version and updates version of package.json accordingly.
See Behaviour details for more details. See the CHANGELOG.md of this project for an example changelog.
Usage
See options for all available options.
npx -p @shaman-apprentice/release-parrot release-parrot import { bumpRelease } from "@shaman-apprentice/release-parrot";
await bumpRelease(); // accepts same options as the cli command and returns new calculated versionVersion helper utilities
This library exposes internally used semantic version helpers. They are useful when you need to parse a version string and convert it back after making adjustments:
import { str2Version, version2Str } from "@shaman-apprentice/release-parrot";
const parsed = str2Version("2.1.3-beta.4"); // { major: 2, minor: 1, patch: 3, prerelease: "beta.4" }
const serialized = version2Str(parsed); // "2.1.3-beta.4"Configuration options
All of these flags map one-to-one to the bumpRelease options when you consume the library from JavaScript.
| Flag | Description | Default |
| --- | --- | --- |
| -h, --help | Print the CLI help and exit. | false |
| -c, --pathToChangelog <path> | Path to the changelog file that holds the ## [unreleased] section. | CHANGELOG.md |
| -p, --pathToPackageJson <path> | Path to the package.json file that should be bumped alongside the changelog. | package.json |
| --nextVersion <version> | Explicitly set the version to use instead of deriving it from the changelog entries and current version in package.json. Accepts any valid semver string. | (unused) |
| --unreleasedHeading <heading> | Override the heading text that marks the start of the unreleased section. Useful when your changelog uses different phrasing. | ## [unreleased] |
| --breakingHeading <heading> | Heading that lists breaking changes. | ### Breaking |
| --featHeading <heading> | Heading that lists new features. | ### Feat |
| --fixedHeading <heading> | Heading that lists fixes. | ### Fixed |
| --wipHeading <heading> | Heading that marks work-in-progress entries. Presence of this section aborts the release. | ### WIP |
| --releaseHeaderTemplate <template> | Template for the release header with {{previousVersion}} and {{nextVersion}} placeholders. When provided, it replaces the default ## [version] - date format. | '## [{{nextVersion}}] - YYYY-MM-DD' |
Behaviour details
- Reads the changelog and throws
CouldNotReadChangelogif the file cannot be read - Validates the unreleased-section:
- Throws
NoUnreleasedSectionif the section is missing - Throws
UnreleasedSectionIsEmptyif the section is empty - Throws
WIPIsPresentif the section still contains a WIP-subsection
- Throws
- Reads the current version from package.json
- Throws
CouldNotReadPackageJsonif the file cannot be read - Throws
InvalidCurrentVersionif the version string is not valid semver
- Throws
- Derives the next version number using semver rules:
- If
nextVersionis provided it is used verbatim - Breaking changes bump the major version
- Features bump the minor version unless the major was already bumped
- Fixes-only releases bump the patch version
- If
- Throws
InvalidPackageBumpif the derived version would be lower than the current one - Rewrites the unreleased section as the newest release entry, adding the version number and current date
- Updates package.json to the same version
- Inserts a fresh, empty
## [unreleased]section at the top of the changelog
All errors extend ReleaseParrotError and are exported from this library.
Versioning
release-parrot adheres to semver. Generated changelog entries follow Keep a Changelog. The library uses itself for promoting next releases 🦜
