question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

3reactions
realvorlcommented, 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

1reaction
phetwcommented, 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 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Can Lerna bump prerelease version according to ...
It doesn't seem that Lerna 3.20. 2 is able to bump prerelease versions (e.g. 1.0. 0-alpha. 0 ) according to the Conventional Commits ......
Read more >
Monorepo using Lerna, Conventional commits, and Github ...
Conventional commits are a convention built on top of commits that consist of a set of rules to follow when writing commit messages....
Read more >
@lerna/prerelease-id-from-version | Yarn - Package Manager
All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines. 6.2.0 (2022-12-13). Bug Fixes. core: ......
Read more >
Tooling for Conventional Commits
A specification for adding human and machine readable meaning to commit messages. ... rules for projects, auto bump versions and auto changelog generation....
Read more >
Semantic Versioning(SemVer) with Conventional Commits
From now on, you can bump your version with npm run bump . And that's it. You don't need to specify what part...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found