Coder Social home page Coder Social logo

version-changelog's Introduction

Version Changelog CircleCI

Add a version & URL to your CHANGELOG.md.

Goes great with changelog-verify. Add this to your package.json:

{
  "scripts": {
    "version": "version-changelog CHANGELOG.md && changelog-verify CHANGELOG.md && git add CHANGELOG.md"
  }
}

Now whenever you execute npm version (or np), your CHANGELOG.md will be given the correct version info, checked for validity (did you forget to add changelog notes?) then added to the release commit.

Usage

Given the following ./CHANGELOG.md

# Changelog

## [Unreleased][]

- These aren’t the droids you’re looking for

## [1.0.0][] - 2016-10-11

- Reticulated the splines

And package.json

{
  "version": "2.0.0"
}

Executing the versioning script

version-changelog ./CHANGELOG.md

Will return success (0), and update CHANGELOG.md to:

# Changelog

## [Unreleased][]

## [2.0.0][] - <today's date>

- These aren’t the droids you’re looking for

## [1.0.0][] - 2016-10-11

- Reticulated the splines

[Unreleased]: <GitHub URL>/compare/v2.0.0...HEAD
[2.0.0]: <GitHub URL>/compare/v1.0.0...v2.0.0
[1.0.0]: <GitHub URL>/tree/v1.0.0

See the tests for more usage examples.

Changelog format

This tool assumes a particular format for your changelog, keeping in style with http://keepachangelog.com:

<some intro text>
## [Unreleased][]
<optional unreleased notes>
## [<version number>][]
<required release notes>

Where <version number> is the more recently previous release of this module.

Options

The cli takes two optional parameters:

  • the changelog filename
  • the remote code repository (github, gitlab, or bitbucket - used to generate URL's for versions). Default: github
version-changelog [filename] [--remote=bitbucket|gitlab|github]

filename can be a path relative to the current working directory, or an absolute path.

version-changelog's People

Contributors

alex-e-leon avatar jesstelford avatar jsaguilar avatar pmudra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

version-changelog's Issues

Support for custom tag prefixes

Just wondering if we could add support for custom tag prefixes for the generated github URLs.

The Allhomes monorepo uses .yarnrc files to prefix custom tags for each package so the harcoded v prefix means the generated URLs don't work.

I was thinking maybe adding a function like below and replace hardcoded instances of v with the value returned.

var spawn = require('cross-spawn');
var hasYarn = require('has-yarn');

function getVersionPrefix() {
  var versionPrefix = '';
  if (hasYarn()) {
    versionPrefix = spawn.sync('yarn', ['config', 'get', 'version-tag-prefix']).stdout.toString().trim();
  } else {
    versionPrefix = spawn.sync('npm', ['config', 'get', 'tag-version-prefix']).stdout.toString().trim();
  }
  if (!versionPrefix) {
    versionPrefix = 'v';
  }
  return versionPrefix;
}

Tests not running

I am trying to fix a bug with gitlab compare links. While setting up a fork I noticed that the tests wont work (on my machine?).

Steps to reproduce

git clone [email protected]:jesstelford/version-changelog.git
cd version-changelog
npm install
npm run test

Environment

  • node -v: v10.16.0
  • npm -v: 6.9.0
  • yarn -v: 1.16.0
  • uname -opvrsi: Linux 5.0.0-20-generic #21-Ubuntu SMP Mon Jun 24 09:32:09 UTC 2019 x86_64 x86_64 GNU/Linux

Output (while running npm run test)

  Versioning Changelog (prefix source: "default")
    - Handles a non-git repo correctly
    1) Correctly adds a new version
    2) Correctly updates old unreleased sections
    3) Correctly handles empty Unreleased section
    4) Correctly skips old versions for links
    gitlab
      5) Correctly adds a new gitlab version
      6) Correctly updates old unreleased sections with gitlab urls
    bitbucket
      7) Correctly adds a new bitbucket version
      8) Correctly updates old unreleased sections with bitbucket urls


  0 passing (2s)
  1 pending
  8 failing

  1) Versioning Changelog (prefix source: "default")
       Correctly adds a new version:
     AssertionError [ERR_ASSERTION]: ifError got unwanted exception: '# Changelog\n\n## [Unreleased][]\n\n## [1.0.0][] - 2019-07-17\n- Foo\n\n[Unreleased]: https://github.com/jesstelford/version... == '# Changelog\n\n## [Unreleased][]\n\n## [1.0.0][] - 2019-07-17\n- Foo\n\n[Unreleased]: https://github.com/jesstelford/version...
      at /home/philipp/Documents/js/version/test/test.js:59:16
      at versionChangelog (index.js:166:5)
      at /home/philipp/Documents/js/version/test/test.js:60:16
      at versionChangelog (index.js:163:5)
      at Context.<anonymous> (test/test.js:47:5)

[...] all error messages look the same

I am almost certain the error is due to a missing 'v' version prefix in the actual result. But I cannot figure out what's wrong.

Clean up after itself if it triggers any handled errors

I tried to run it before hooking up a repository to git, and got the [WARN]: Unable to determine origin URL for adding to changelog but it left my repo in a changed state. Would be nice if it cleaned up after itself instead.

Unnecessary '[]' after version

It seems that you add unnecessary [] characters after each version.
For example:

## [1.0.0][]

Is there a reason for there or is it a bug?
Just was curious since it doesn't adhere to keepachangelog.com.
Also wanted to say that I love this tool, thank you for creating it!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.