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

Can Lerna bump prerelease version according to the Conventional Commits specification? #2536

Closed
customcommander opened this issue Apr 13, 2020 · 5 comments

Comments

@customcommander
Copy link

customcommander commented Apr 13, 2020

Hi,

Sorry for cross-posting (here and on Stack Overflow) but I just want to understand whether this is a bug or by design.


I have two Lerna-managed monorepos (both in independent mode), with three sub-packages each. One repo is in a "production" state (i.e. 1.0.0) the other is in a "prerelease" state (i.e. 1.0.0-alpha.0):

dev (or dev-prerelease)
  |-- packages
  |   |-- major
  |   |   |-- package.json (1.0.0 or 1.0.0-alpha.0)
  |   |-- minor
  |   |   |-- package.json (1.0.0 or 1.0.0-alpha.0)
  |   |-- patch
  |   |   |-- package.json (1.0.0 or 1.0.0-alpha.0)
  |-- package.json
  |-- lerna.json

I then make the following commits in both repositories: (commits follow the Conventional Commits specification)

  • A breaking change in the major package
  • A new feature in the minor package
  • A bug fix in the patch package

And run this command in both repositories:

npx lerna publish --conventional-commits --yes 2>/dev/null

Expected Behavior

In the "production" repo, I can see the following versions

Changes:
 - major: 1.0.0 => 2.0.0 (private)
 - minor: 1.0.0 => 1.1.0 (private)
 - patch: 1.0.0 => 1.0.1 (private)

In the "prerelease" repo, I can see the following versions

Changes:
 - major: 1.0.0-alpha.0 => 2.0.0-alpha.0 (private)
 - minor: 1.0.0-alpha.0 => 1.1.0-alpha.0 (private)
 - patch: 1.0.0-alpha.0 => 1.0.1-alpha.0 (private)

Current Behavior

The "production" repo is updated as expected, however in the "prerelease" repo versions are updated as follow:

Changes:
 - major: 1.0.0-alpha.0 => 1.0.0-alpha.1 (private)
 - minor: 1.0.0-alpha.0 => 1.0.0-alpha.1 (private)
 - patch: 1.0.0-alpha.0 => 1.0.0-alpha.1 (private)

Steps to Reproduce (for bugs)

I made a Minimal Reproducible Example.
I have dockerized this; you literally just need to clone the repo and follow the instructions ;)

Your Environment

The Minimal Reproducible Example mentioned above runs in a Docker container:

  • Alpine
  • Node 12
Executable Version
lerna --version 3.20.2
npm --version 6.10.0
yarn --version 1.17.3
node --version 12.7.0
customcommander added a commit to customcommander/lerna-prerelease-conventional-commits that referenced this issue Apr 13, 2020
@customcommander
Copy link
Author

@evocateur ☝;)

@realvorl
Copy link

realvorl commented May 5, 2020

It looks like a feature, I think you are supposed to use the version command to advance the MAJOR, MINOR and PATCH numbers before you prerelease again.

you have to go through the lerna versioning commands

- lerna version major
- lerna version premajor
- lerna version prerelease

now you will see that all the changes made it in your

lerna.json

@phetw
Copy link

phetw commented May 18, 2021

I found the same issue with one of my monorepo using Lerna 4.0.0. Using

lerna version --conventional-commits --conventional-prerelease

only bump patch. When I tried in newly create repository, using the same command it bumps correctly as per convention. Strange. Did you find the solution ?

@wenytang-ms-123
Copy link

wenytang-ms-123 commented Jun 20, 2021

it seems bump up prerelease according to
https://github.com/lerna/lerna/blob/main/core/conventional-commits/lib/recommend-version.js#L29
and you can tail --loglevel=silly for a better read

@JamesHenry
Copy link
Member

--conventional-bump-prerelease will be included in the next minor version of lerna thanks to @amorscher in #3362

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

No branches or pull requests

5 participants