Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Version] Using a custom tagVersionPrefix with conventionalCommits, lerna version incorrectly computes root CHANGELOG. #2197

Closed
darkobits opened this issue Jul 23, 2019 · 1 comment · May be fixed by adamlaska/scatter-js#3

Comments

@darkobits
Copy link

Expected Behavior

When running lerna version using the conventionalCommits option/flag, Lerna should produce accurate root and package-level change logs.

Current Behavior

Lerna produces accurate package-level change logs, but the root-level change log contains a very verbose change set spanning several releases.

Possible Solution

When generating root-level changelogs, this code path is taken in update-changelog.js. Notice that in the else branch on L44 for non-root packages, tagPrefix is being assigned to options, but this does not happen on the root-level code path. I believe this is sufficient to explain why package-level change logs are produced correctly, but root-level change logs are not.

I have tested this flow locally by adding the following line just below L34 in update-changelog.js, and it resulted in root-level change logs that were accurate:

options.tagPrefix = tagPrefix;

However, I am not aware of the context around why this wasn't being set in the first place, and as such, this solution may have other undesired effects for other use cases that I'm not aware of.

Steps to Reproduce (for bugs)

  1. Set the same tagVersionPrefix option for the version and publish commands in lerna.json or use the same --tag-version-prefix flag when executing lerna version and lerna publish below.
  2. With 1 or more commits representing changes to at least 1 package, run lerna version.
lerna.json

{
  "version": "1.2.3",
  "packages": [
    "packages/*"
  ],
  "command": {
    "bootstrap": {
      "ci": false,
      "hoist": true
    },
    "version": {
      "message": "chore(release): %v",
      "conventionalCommits": true,
      "gitTagVersion": true,
      "push": false,
      "tagVersionPrefix": "foo/v"
    },
    "publish": {
      "verifyAccess": false,
      "gitTagVersion": false,
      "push": false,
      "tagVersionPrefix": "foo/v"
    }
  }
}

Context

When using lerna version with a custom tagVersionPrefix and conventionalCommits, it is necessary to manually remove all extraneous information from the root-level change log that Lerna produces.

Your Environment

Executable Version
lerna --version 3.16.3
npm --version 6.10.1
node --version 10.16.0
OS Version
NAME VERSION
macOS Sierra 10.14.5
@evocateur
Copy link
Member

It's amazing what happens when folks actually use a feature :D

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants