Skip to content

Unable to use --conventional-commits due to the mandatory "bump" positional #3138

@Pavel910

Description

@Pavel910

Expected Behavior

Running lerna version --conventional-commits should work, and generate the next version based on conventional commits.

Current Behavior

The positional bump is required, even though the official docs say it's not required

CleanShot 2022-05-24 at 15 03 08@2x

Possible Solution

The code in question is located here: https://github.com/lerna/lerna/blob/main/commands/version/command.js#L290.
If I pass anything, even prerelease, as a positional argument, it will hit this condition, and the conventionalCommits condition will never execute, thus skipping the desired version generation.

The changelog for 3.0.2 states: Positional bump supersedes "--conventional-commits". Ok, but how can I not specify the bump argument then?

Probably the simplest solution is to check whether the bump was sent before validating it in this block of code:
https://github.com/lerna/lerna/blob/main/commands/version/command.js#L289-L291. If the value is empty, don't validate it.

Steps to Reproduce (for bugs)

Run: lerna version --conventional-commits

{
  "packages": [
    "packages/*",
    "packages-v6/*"
  ],
  "version": "5.26.0",
  "npmClient": "yarn",
  "command": {
    "version": {
      "preid": "next",
      "ignoreChanges": [
        "scripts/**",
        ",**/__fixtures__/**",
        "**/__tests__/**",
        "**/*.md",
        "lerna.json",
        "api/**",
        "apps/**"
      ],
      "conventionalCommits": true,
      "createRelease": "github",
      "commitHooks": false,
      "message": "chore(release): publish %s :tada: :rocket:"
    },
    "publish": {
      "conventionalCommits": true
    }
  }
}

Context

I'm trying to version packages using conventional commits, and not explicit version bumps.

Executable Version
lerna --version 3.22.1
npm --version 6.14.17
yarn --version 3.1.0
node --version 14.19.3

Willing to open a PR to fix this, but want to hear from the maintainer first to be on the same page about the solution.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions