Skip to content

Support --conventional-commits in fixed versioning mode - #922

Merged
evocateur merged 3 commits into
lerna:masterfrom
jezzay:fixed-mode-conventional-commits
Aug 23, 2017
Merged

evocateur merged 3 commits into
lerna:masterfrom
jezzay:fixed-mode-conventional-commits

Conversation

@jezzay

@jezzay jezzay commented Jul 17, 2017 •

Copy link
Copy Markdown
Contributor

Description

This PR adds support for --conventional-commits in fixed mode. When the --conventional-commits
flag is used, the highest bump from the changed packages will be used as the new version.

Eg
package-1 1.0.0 -> feat
package-2 1.0.0 -> fix

lerna publish --conventional-commits

Results in package-1 and package-2 being updated to 1.1.0

This is accomplished by only using the "-l", pkg.name arguments (lerna mode) to conventional-recommended-bump/conventional-changelog-cli in independent mode.

The CHANGELOG.md files for each package are also created/updated on each publish.

The order of commands in src/commands/PublishCommand.js has been updated to group by option type first, then independent/fixed, which improves readability.

Motivation and Context

This PR allows lerna to be used to publish new versions in CI more easily in fixed mode when conventional commits are followed. With something like lerna publish --conventional-commits --force-publish=* it will be possible to release new versions of projects managed with lerna automatically on PR merges.

Fixes #890

How Has This Been Tested?

  • Manual testing in fixed mode
  • Unit tests have been updated to test new code paths

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@jezzay
jezzay force-pushed the fixed-mode-conventional-commits branch from 2d76b19 to f57f359 Compare July 27, 2017 12:01
@jezzay
jezzay force-pushed the fixed-mode-conventional-commits branch from 4446bd1 to 3beee9a Compare August 11, 2017 13:38
@sgwilym

sgwilym commented Aug 23, 2017

Copy link
Copy Markdown

Is this missing anything that you would accept contributions for? I'd love to help get this merged.

@jezzay

jezzay commented Aug 23, 2017

Copy link
Copy Markdown
Contributor Author

I've been using the changes in this PR in a internal fork of lerna successfully for a while now. @evocateur would you be able to review this? Thanks!

@evocateur evocateur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, apologies for the delayed response!

@@ -1,3 +1,3 @@
{
"name": "independent"
"name": "normal-exact"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, thanks!

@evocateur evocateur changed the title [Feature] Support --conventional-commits in fixed mode Support --conventional-commits in fixed versioning mode Aug 23, 2017
@evocateur
evocateur merged commit 2629cc2 into lerna:master Aug 23, 2017
@jezzay

jezzay commented Aug 24, 2017

Copy link
Copy Markdown
Contributor Author

Awesome thanks!

@KingScooty

KingScooty commented Nov 28, 2017 •

Copy link
Copy Markdown

So what do i need to do to be able to use this? What conventional commit dependencies do i need? standard-version? Or conventional-changelog and conventional-changelog-cli?

I'm just getting to grips with both lerna and conventional, so this i a bit of a learning curve i'm trying to climb. Any advice to get lerna working with conventional using --conventional-commits in fixed mode is appreciated!

I've got standard-version installed, but it doesn't seem to be filling the changelog with my commit messages.

@evocateur

Copy link
Copy Markdown
Member

@KingScooty Just lerna publish --conventional-commits. That's it. No standard-version usage required, just commits in the angular format.

@KingScooty

Copy link
Copy Markdown

Thanks @evocateur. I've been using commitizen to handle my angular format commit messages. But my changelog files don't seem to be getting populated with the commit messages.

I'll stage my commits, run commitizen to generate my angular messages, then run lerna publish --conventional-commits, but my changelogs don't reflect the changes. Am i missing something?

@evocateur

Copy link
Copy Markdown
Member

As long as those commitizen-generated messages actually get committed, that should be sufficient? That is, if you've successfully published with lerna before, and have vX.Y.Z-style git tags in the appropriate place so lerna can determine what has changed, etc.

@KingScooty

Copy link
Copy Markdown

Hmm. Well this is an example of one of my commits: style(ui-sass-settings): Tidy up whitespace. I made that commit before running lerna publish. But the changelog doesn't seem to update.

Lerna detects any package and dependency changes before publishing, so everything is working fine lerna side. --conventional-commits just doesn't seem to be doing much.

@evocateur

Copy link
Copy Markdown
Member

If you could open a new issue with your version, config, and perhaps a small repro, that would be greatly appreciated!

@jezzay

jezzay commented Nov 29, 2017

Copy link
Copy Markdown
Contributor Author

@KingScooty For your example with a commit type of style:

--conventional-commits uses the angular preset by default, which will only write entries into the change log for feat, fix or perf types OR if the commit has a breaking change. See conventional-changelog-angular

Lerna has the option to use a different preset through the --changelog-preset flag. An example usage of this flag is in the docs

@KingScooty

Copy link
Copy Markdown

Ahhh, that makes sense! Thanks @jezzay!

@soluteli

Copy link
Copy Markdown

@jezzay
In my project with lerna V^2.10.2 learn-lerna_fixed, my commit msg is in angular format.
After runninglerna publish --conventional-commits, I had get CHANGELOG files in project Root and every package root, but there is no git commit log like feat: add something show in CHANGELOG.
so, how could get this done?

related links:

Thanks~

@jezzay
jezzay deleted the fixed-mode-conventional-commits branch April 23, 2018 14:43
@lock

lock Bot commented Dec 27, 2018

Copy link
Copy Markdown

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for --conventional-commits in Fixed/Locked mode

5 participants