Convert Figma logo to code with AI

conventional-changelog logostandard-version

:trophy: Automate versioning and CHANGELOG generation, with semver.org and conventionalcommits.org

7,675
792
7,675
309

Top Related Projects

:package::rocket: Fully automated version management and package publishing

🚀 Automate versioning and package publishing

Generate changelogs and release notes from a project's commit messages and metadata.

35,695

:dragon: Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.

16,798

The commitizen command line utility. #BlackLivesMatter

32,324

Git hooks made easy 🐶 woof!

Quick Overview

Standard-version is a utility for versioning using semver and CHANGELOG generation. It automates the process of bumping version numbers, generating changelogs, and creating git tags, following the Conventional Commits specification.

Pros

  • Automates version management and changelog generation
  • Follows the Conventional Commits specification for consistent commit messages
  • Integrates well with npm and other package managers
  • Customizable through configuration options

Cons

  • Requires team adoption of Conventional Commits for full effectiveness
  • May not be suitable for projects with complex versioning needs
  • Learning curve for teams new to semantic versioning and conventional commits
  • Limited flexibility in changelog formatting

Code Examples

  1. Basic usage:
// Run standard-version
npx standard-version
  1. Specifying a release type:
// Create a patch release
npx standard-version --release-as patch
  1. Custom configuration:
// .versionrc
{
  "types": [
    {"type": "feat", "section": "Features"},
    {"type": "fix", "section": "Bug Fixes"},
    {"type": "chore", "hidden": true},
    {"type": "docs", "hidden": true},
    {"type": "style", "hidden": true},
    {"type": "refactor", "hidden": true},
    {"type": "perf", "hidden": true},
    {"type": "test", "hidden": true}
  ]
}

Getting Started

  1. Install standard-version:
npm install --save-dev standard-version
  1. Add a script to your package.json:
{
  "scripts": {
    "release": "standard-version"
  }
}
  1. Run the release script:
npm run release

This will bump the version, update the CHANGELOG.md file, create a new commit, and tag the release.

Competitor Comparisons

:package::rocket: Fully automated version management and package publishing

Pros of semantic-release

  • Fully automated release process, including version bumping and changelog generation
  • Integrates well with CI/CD pipelines for continuous delivery
  • Supports multiple package managers and release platforms out of the box

Cons of semantic-release

  • Steeper learning curve due to more complex configuration
  • Requires strict adherence to commit message conventions
  • Less flexibility in customizing the release process

Code Comparison

semantic-release configuration:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "@semantic-release/npm",
    "@semantic-release/github"
  ]
}

standard-version usage:

npx standard-version

Key Differences

  • semantic-release is designed for fully automated releases, while standard-version allows for more manual control
  • semantic-release has a plugin-based architecture, offering more extensibility
  • standard-version is simpler to set up and use for smaller projects
  • semantic-release integrates better with CI/CD workflows
  • standard-version provides more flexibility in commit message formats

Both tools aim to streamline the release process and maintain consistent versioning, but they cater to different project needs and team preferences. Choose based on your project's size, complexity, and desired level of automation.

🚀 Automate versioning and package publishing

Pros of release-it

  • More flexible and customizable with extensive configuration options
  • Supports a wider range of version control systems (Git, SVN, Mercurial)
  • Includes built-in CI/CD integration and hooks for automation

Cons of release-it

  • Steeper learning curve due to more complex configuration
  • May require more setup time for simpler projects
  • Larger package size and more dependencies

Code Comparison

release-it configuration example:

{
  "git": {
    "commitMessage": "chore: release v${version}",
    "tagName": "v${version}"
  },
  "npm": {
    "publish": true
  },
  "hooks": {
    "after:bump": "npm run build"
  }
}

standard-version configuration example:

{
  "types": [
    {"type": "feat", "section": "Features"},
    {"type": "fix", "section": "Bug Fixes"},
    {"type": "chore", "hidden": true}
  ],
  "commitUrlFormat": "https://github.com/myorg/myrepo/commit/{{hash}}"
}

Both tools aim to streamline the release process, but release-it offers more flexibility and features at the cost of complexity. standard-version focuses on simplicity and adheres strictly to the Conventional Commits specification. Choose release-it for more control and customization, or standard-version for a straightforward, opinionated approach to versioning and changelogs.

Generate changelogs and release notes from a project's commit messages and metadata.

Pros of conventional-changelog

  • More flexible and customizable, allowing for greater control over changelog generation
  • Supports a wider range of commit message formats and conventions
  • Can be integrated into various build processes and workflows

Cons of conventional-changelog

  • Requires more setup and configuration to get started
  • Less opinionated, which may lead to inconsistencies across projects
  • Doesn't include built-in version bumping or release management features

Code comparison

conventional-changelog:

const conventionalChangelog = require('conventional-changelog');

conventionalChangelog({
  preset: 'angular',
  releaseCount: 0
})
  .pipe(process.stdout);

standard-version:

const standardVersion = require('standard-version');

standardVersion({
  noVerify: true,
  infile: 'CHANGELOG.md',
  silent: true
}).then(() => {
  console.log('CHANGELOG.md updated');
});

Key differences

  1. Purpose: conventional-changelog focuses solely on generating changelogs, while standard-version provides a complete release management solution.
  2. Ease of use: standard-version offers a more streamlined, opinionated approach, making it easier to get started quickly.
  3. Flexibility: conventional-changelog provides more options for customization and integration with various workflows.
  4. Features: standard-version includes version bumping and git tagging, which are not part of conventional-changelog's core functionality.
  5. Learning curve: conventional-changelog may require more time to master due to its extensive configuration options, while standard-version has a gentler learning curve for basic usage.
35,695

:dragon: Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.

Pros of Lerna

  • Designed for managing monorepos and multiple packages
  • Provides tools for versioning, publishing, and dependency management
  • Offers flexible configuration options for different project structures

Cons of Lerna

  • Steeper learning curve due to more complex features
  • Can be overkill for single-package projects
  • Requires more setup and configuration

Code Comparison

Standard-version:

{
  "scripts": {
    "release": "standard-version"
  }
}

Lerna:

{
  "scripts": {
    "version": "lerna version",
    "publish": "lerna publish"
  }
}

Key Differences

  • Standard-version focuses on changelog generation and versioning for single packages
  • Lerna is built for managing multiple packages in a monorepo
  • Standard-version follows the Conventional Commits specification more strictly
  • Lerna offers more advanced features for package management and interdependencies

Use Cases

Standard-version:

  • Single-package projects
  • Projects requiring strict adherence to Conventional Commits

Lerna:

  • Monorepos with multiple packages
  • Projects needing advanced package management and publishing workflows

Community and Maintenance

  • Both projects have active communities and are well-maintained
  • Lerna has a larger user base due to its popularity in the JavaScript ecosystem
  • Standard-version is more focused and has fewer dependencies
16,798

The commitizen command line utility. #BlackLivesMatter

Pros of cz-cli

  • Interactive CLI prompts for structured commit messages
  • Customizable commit types and scopes
  • Supports multiple languages and integrations

Cons of cz-cli

  • Requires additional setup and configuration
  • May slow down the commit process for some developers
  • Limited built-in versioning and changelog generation features

Code Comparison

cz-cli:

commitizen.prompt({
  type: 'list',
  name: 'type',
  message: 'Select the type of change:',
  choices: ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']
}, (answers) => {
  // Handle commit message creation
});

standard-version:

standardVersion({
  infile: 'CHANGELOG.md',
  firstRelease: true,
  types: [
    {type: 'feat', section: 'Features'},
    {type: 'fix', section: 'Bug Fixes'},
    {type: 'chore', hidden: true}
  ]
});

Key Differences

  • cz-cli focuses on commit message creation, while standard-version emphasizes versioning and changelog generation
  • cz-cli provides an interactive interface, whereas standard-version is more automated
  • standard-version offers built-in release management features, which cz-cli lacks
  • cz-cli is more flexible for customizing commit types and formats, while standard-version follows a more standardized approach

Use Cases

  • Choose cz-cli for teams that prioritize consistent commit messages and want an interactive commit process
  • Opt for standard-version when automated versioning and changelog generation are the primary concerns
32,324

Git hooks made easy 🐶 woof!

Pros of husky

  • Focuses on Git hooks, allowing for more granular control over the development workflow
  • Easier to set up and configure for specific project needs
  • Supports a wider range of Git hooks, not just commit-related ones

Cons of husky

  • Doesn't provide automatic versioning or changelog generation
  • Requires more manual setup for commit message formatting and validation
  • May need additional tools or scripts to achieve similar functionality to standard-version

Code comparison

husky configuration (in package.json):

{
  "husky": {
    "hooks": {
      "pre-commit": "npm test",
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  }
}

standard-version usage:

npx standard-version

Summary

husky is a versatile tool for managing Git hooks, offering fine-grained control over various stages of the development process. It's highly customizable but requires more manual setup for specific tasks. standard-version, on the other hand, focuses on automating versioning and changelog generation based on conventional commits. While husky provides more flexibility, standard-version offers a more streamlined approach to version management and release documentation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Standard Version

standard-version is deprecated. If you're a GitHub user, I recommend release-please as an alternative. If you're unable to use GitHub Actions, or if you need to stick with standard-version for some other reason, you can use the commit-and-tag-version fork of standard-version.

A utility for versioning using semver and CHANGELOG generation powered by Conventional Commits.

ci NPM version codecov Conventional Commits Community slack

Having problems? Want to contribute? Join us on the node-tooling community Slack.

How It Works:

  1. Follow the Conventional Commits Specification in your repository.
  2. When you're ready to release, run standard-version.

standard-version will then do the following:

  1. Retrieve the current version of your repository by looking at packageFiles[1], falling back to the last git tag.
  2. bump the version in bumpFiles[1] based on your commits.
  3. Generates a changelog based on your commits (uses conventional-changelog under the hood).
  4. Creates a new commit including your bumpFiles[1] and updated CHANGELOG.
  5. Creates a new tag with the new version number.

bumpFiles, packageFiles and updaters

standard-version uses a few key concepts for handling version bumping in your project.

  • packageFiles – User-defined files where versions can be read from and be "bumped".
    • Examples: package.json, manifest.json
    • In most cases (including the default), packageFiles are a subset of bumpFiles.
  • bumpFiles – User-defined files where versions should be "bumped", but not explicitly read from.
    • Examples: package-lock.json, npm-shrinkwrap.json
  • updaters – Simple modules used for reading packageFiles and writing to bumpFiles.

By default, standard-version assumes you're working in a NodeJS based project... because of this, for the majority of projects you might never need to interact with these options.

That said, if you find your self asking How can I use standard-version for additional metadata files, languages or version files? – these configuration options will help!

Installing standard-version

As a local npm run script

Install and add to devDependencies:

npm i --save-dev standard-version

Add an npm run script to your package.json:

{
  "scripts": {
    "release": "standard-version"
  }
}

Now you can use npm run release in place of npm version.

This has the benefit of making your repo/package more portable, so that other developers can cut releases without having to globally install standard-version on their machine.

As global bin

Install globally (add to your PATH):

npm i -g standard-version

Now you can use standard-version in place of npm version.

This has the benefit of allowing you to use standard-version on any repo/package without adding a dev dependency to each one.

Using npx

As of npm@5.2.0, npx is installed alongside npm. Using npx you can use standard-version without having to keep a package.json file by running: npx standard-version.

This method is especially useful when using standard-version in non-JavaScript projects.

Configuration

You can configure standard-version either by:

  1. Placing a standard-version stanza in your package.json (assuming your project is JavaScript).
  2. Creating a .versionrc, .versionrc.json or .versionrc.js.
  • If you are using a .versionrc.js your default export must be a configuration object, or a function returning a configuration object.

Any of the command line parameters accepted by standard-version can instead be provided via configuration. Please refer to the conventional-changelog-config-spec for details on available configuration options.

Customizing CHANGELOG Generation

By default (as of 6.0.0), standard-version uses the conventionalcommits preset.

This preset:

  • Adheres closely to the conventionalcommits.org specification.
  • Is highly configurable, following the configuration specification maintained here.
    • We've documented these config settings as a recommendation to other tooling makers.

There are a variety of dials and knobs you can turn related to CHANGELOG generation.

As an example, suppose you're using GitLab, rather than GitHub, you might modify the following variables:

  • commitUrlFormat: the URL format of commit SHAs detected in commit messages.
  • compareUrlFormat: the URL format used to compare two tags.
  • issueUrlFormat: the URL format used to link to issues.

Making these URLs match GitLab's format, rather than GitHub's.

CLI Usage

NOTE: To pass nested configurations to the CLI without defining them in the package.json use dot notation as the parameters e.g. --skip.changelog.

First Release

To generate your changelog for your first release, simply do:

# npm run script
npm run release -- --first-release
# global bin
standard-version --first-release
# npx
npx standard-version --first-release

This will tag a release without bumping the version bumpFiles1.

When you are ready, push the git tag and npm publish your first release. \o/

Cutting Releases

If you typically use npm version to cut a new release, do this instead:

# npm run script
npm run release
# or global bin
standard-version

As long as your git commit messages are conventional and accurate, you no longer need to specify the semver type - and you get CHANGELOG generation for free! \o/

After you cut a release, you can push the new git tag and npm publish (or npm publish --tag next) when you're ready.

Release as a Pre-Release

Use the flag --prerelease to generate pre-releases:

Suppose the last version of your code is 1.0.0, and your code to be committed has patched changes. Run:

# npm run script
npm run release -- --prerelease

This will tag your version as: 1.0.1-0.

If you want to name the pre-release, you specify the name via --prerelease <name>.

For example, suppose your pre-release should contain the alpha prefix:

# npm run script
npm run release -- --prerelease alpha

This will tag the version as: 1.0.1-alpha.0

Release as a Target Type Imperatively (npm version-like)

To forgo the automated version bump use --release-as with the argument major, minor or patch.

Suppose the last version of your code is 1.0.0, you've only landed fix: commits, but you would like your next release to be a minor. Simply run the following:

# npm run script
npm run release -- --release-as minor
# Or
npm run release -- --release-as 1.1.0

You will get version 1.1.0 rather than what would be the auto-generated version 1.0.1.

NOTE: you can combine --release-as and --prerelease to generate a release. This is useful when publishing experimental feature(s).

Prevent Git Hooks

If you use git hooks, like pre-commit, to test your code before committing, you can prevent hooks from being verified during the commit step by passing the --no-verify option:

# npm run script
npm run release -- --no-verify
# or global bin
standard-version --no-verify

Signing Commits and Tags

If you have your GPG key set up, add the --sign or -s flag to your standard-version command.

Lifecycle Scripts

standard-version supports lifecycle scripts. These allow you to execute your own supplementary commands during the release. The following hooks are available and execute in the order documented:

  • prerelease: executed before anything happens. If the prerelease script returns a non-zero exit code, versioning will be aborted, but it has no other effect on the process.
  • prebump/postbump: executed before and after the version is bumped. If the prebump script returns a version #, it will be used rather than the version calculated by standard-version.
  • prechangelog/postchangelog: executes before and after the CHANGELOG is generated.
  • precommit/postcommit: called before and after the commit step.
  • pretag/posttag: called before and after the tagging step.

Simply add the following to your package.json to configure lifecycle scripts:

{
  "standard-version": {
    "scripts": {
      "prebump": "echo 9.9.9"
    }
  }
}

As an example to change from using GitHub to track your items to using your projects Jira use a postchangelog script to replace the url fragment containing 'https://github.com/`myproject`/issues/' with a link to your Jira - assuming you have already installed replace

{
  "standard-version": {
    "scripts": {
      "postchangelog": "replace 'https://github.com/myproject/issues/' 'https://myjira/browse/' CHANGELOG.md"
    }
  }
}

Skipping Lifecycle Steps

You can skip any of the lifecycle steps (bump, changelog, commit, tag), by adding the following to your package.json:

{
  "standard-version": {
    "skip": {
      "changelog": true
    }
  }
}

Committing Generated Artifacts in the Release Commit

If you want to commit generated artifacts in the release commit, you can use the --commit-all or -a flag. You will need to stage the artifacts you want to commit, so your release command could look like this:

{
  "standard-version": {
    "scripts": {
      "prerelease": "webpack -p --bail && git add <file(s) to commit>"
    }
  }
}
{
  "scripts": {
    "release": "standard-version -a"
  }
}

Dry Run Mode

running standard-version with the flag --dry-run allows you to see what commands would be run, without committing to git or updating files.

# npm run script
npm run release -- --dry-run
# or global bin
standard-version --dry-run

Prefix Tags

Tags are prefixed with v by default. If you would like to prefix your tags with something else, you can do so with the -t flag.

standard-version -t @scope/package\@

This will prefix your tags to look something like @scope/package@2.0.0

If you do not want to have any tag prefix you can use the -t flag and provide it with an empty string as value.

Note: simply -t or --tag-prefix without any value will fallback to the default 'v'

CLI Help

# npm run script
npm run release -- --help
# or global bin
standard-version --help

Code Usage

const standardVersion = require('standard-version')

// Options are the same as command line, except camelCase
// standardVersion returns a Promise
standardVersion({
  noVerify: true,
  infile: 'docs/CHANGELOG.md',
  silent: true
}).then(() => {
  // standard-version is done
}).catch(err => {
    console.error(`standard-version failed with message: ${err.message}`)
})

TIP: Use the silent option to prevent standard-version from printing to the console.

FAQ

How is standard-version different from semantic-release?

semantic-release is described as:

semantic-release automates the whole package release workflow including: determining the next version number, generating the release notes and publishing the package.

While both are based on the same foundation of structured commit messages, standard-version takes a different approach by handling versioning, changelog generation, and git tagging for you without automatic pushing (to GitHub) or publishing (to an npm registry). Use of standard-version only affects your local git repo - it doesn't affect remote resources at all. After you run standard-version, you can review your release state, correct mistakes and follow the release strategy that makes the most sense for your codebase.

We think they are both fantastic tools, and we encourage folks to use semantic-release instead of standard-version if it makes sense for their use-case.

Should I always squash commits when merging PRs?

The instructions to squash commits when merging pull requests assumes that one PR equals, at most, one feature or fix.

If you have multiple features or fixes landing in a single PR and each commit uses a structured message, then you can do a standard merge when accepting the PR. This will preserve the commit history from your branch after the merge.

Although this will allow each commit to be included as separate entries in your CHANGELOG, the entries will not be able to reference the PR that pulled the changes in because the preserved commit messages do not include the PR number.

For this reason, we recommend keeping the scope of each PR to one general feature or fix. In practice, this allows you to use unstructured commit messages when committing each little change and then squash them into a single commit with a structured message (referencing the PR number) once they have been reviewed and accepted.

Can I use standard-version for additional metadata files, languages or version files?

As of version 7.1.0 you can configure multiple bumpFiles and packageFiles.

  1. Specify a custom bumpFile "filename", this is the path to the file you want to "bump"
  2. Specify the bumpFile "updater", this is how the file will be bumped. a. If you're using a common type, you can use one of standard-version's built-in updaters by specifying a type. b. If your using an less-common version file, you can create your own updater.
// .versionrc
{
  "bumpFiles": [
    {
      "filename": "MY_VERSION_TRACKER.txt",
      // The `plain-text` updater assumes the file contents represents the version.
      "type": "plain-text"
    },
    {
      "filename": "a/deep/package/dot/json/file/package.json",
      // The `json` updater assumes the version is available under a `version` key in the provided JSON document.
      "type": "json"
    },
    {
      "filename": "VERSION_TRACKER.json",
      //  See "Custom `updater`s" for more details.
      "updater": "standard-version-updater.js"
    }
  ]
}

If using .versionrc.js as your configuration file, the updater may also be set as an object, rather than a path:

// .versionrc.js
const tracker = {
  filename: 'VERSION_TRACKER.json',
  updater: require('./path/to/custom-version-updater')
}

module.exports = {
  bumpFiles: [tracker],
  packageFiles: [tracker]
}

Custom updaters

An updater is expected to be a Javascript module with atleast two methods exposed: readVersion and writeVersion.

readVersion(contents = string): string

This method is used to read the version from the provided file contents.

The return value is expected to be a semantic version string.

writeVersion(contents = string, version: string): string

This method is used to write the version to the provided contents.

The return value will be written directly (overwrite) to the provided file.


Let's assume our VERSION_TRACKER.json has the following contents:

{
  "tracker": {
    "package": {
      "version": "1.0.0"
    }
  }
}

An acceptable standard-version-updater.js would be:

// standard-version-updater.js
const stringifyPackage = require('stringify-package')
const detectIndent = require('detect-indent')
const detectNewline = require('detect-newline')

module.exports.readVersion = function (contents) {
  return JSON.parse(contents).tracker.package.version;
}

module.exports.writeVersion = function (contents, version) {
  const json = JSON.parse(contents)
  let indent = detectIndent(contents).indent
  let newline = detectNewline(contents)
  json.tracker.package.version = version
  return stringifyPackage(json, indent, newline)
}

License

ISC

NPM DownloadsLast 30 Days