feat(version): add --premajor-version-bump option to force patch bumps for non-breaking changes in premajor packages#3876
Conversation
|
Hi @jchiem , thank you for your work on this. It is looking good. A few things:
Once again, thank you for your work on this feature. Hopefully we can get it in soon! |
|
As for the naming for the option and the values, that's a tricky one. I think it'd be clearer to have the option values be I'm open to suggestions and feedback but I'm leaning towards this over 'semver'/'node-semver'. |
ef14b22 to
9754d2c
Compare
Another option for the naming could be: I've rebased and updated the PR based on your suggestions for the comments that I have resolved, for now I've gone with I have not yet added a |
…r prerelease-independent and independent.
9754d2c to
6acf913
Compare
… to be called with preMajorVersionBump default
6acf913 to
bef0eb0
Compare
A few things you can try:
|
I've tried your suggestions out, I managed to change the port for which When I had verdaccio running on port 4872 through It seems to complain about the Sorry for all the questions but I can't seem to get the e2e tests to work following the current info from the CONTIRBUTING.md nor the steps you have suggested. |
|
Hmm, I would suggest resetting any local changes, like if your lerna.json file differs from the one that already exists in git. A pnpm-lock file shouldn't be needed in the lerna repo itself. You can run If you're on a completely clean working tree, with no prior processes running on port 4872, you should be able to run |
Edit: the error i previously had for Following these steps, I cloned the repository from scratch and ran the steps in I'm getting an error with
|
|
I've added 2 new e2e tests for There was a comment stating: If you have an easy way to adjust the "first version" of packages in e2e independent mode I can add additional tests. |
|
Thank you very much for your hard work on this @jchiem ! |


Description
premajorVersionBump(--premajor-version-bump) option forlerna version --conventional-commits, can be configured with either"semver"or"node-semver"--conventional-commitswithlerna version."semver"is the default and bumps premajor version packages asminorforfeat/fixand is aligned with how lerna handles bumps for premajor version packages today."node-semver"bumpsfeat/fixupdates aspatch.Motivation and Context
Short summary
Add an option to control version bumps for
premajorversion whenlerna version --conventional-commitsis used sincenode-semverdocuments it as common to handle minor version bumps as breaking changes andnpmis configured to not automatically bumppremajorversion releases tominorwhen using^inpackage.json. The recommendation fromsemveris to try to bump the package to1.0.0as fast as possible but there does not appear to be a strict guideline that states that you must do this to be compliant with semver.This PR is based on the feature request I made in #3863 which @fahslaj suggested I make a PR for so long as it remains backwards compatible.
Original proposal from feature request 3863
Any premajor version package with "feature" (according to conventional commits) should be possible to bump with `patch` but there's code in recommend-version.ts (L76-L94)This states in the comment that this is in accordance to semver, but the only information I found about this in semver is the FAQ suggesting "the easiest way to handle versions for premajor versions", but it does not explicitly state that all version updates should be done as minor version releases.
node-semverdocumentation states that "Many authors treat a 0.x version as if the x were the major "breaking-change" indicator." . By default npm install results in"^"denoted versions inpackage.json. The way lerna always bumps all premajor version packages as "minor" forces users reliant on premajor version packages to manually bump packages as minor if the package is in initial release state but no breaking changes were added.In my team, we have interpreted the
semverdocumentation in the waynode-semverhandles this, which means that you should be able to providefeatureupdates throughpatchreleases on premajor version packages, since any version bump forminorfor premajor version packages are considered as potentially containing breaking and can't automatically be bumped bynpmif^is used.lerna/libs/core/src/lib/conventional-commits/recommend-version.ts
Lines 76 to 94 in 914dd96
How Has This Been Tested?
independentandindependent-prereleasefixtures to include an additional package with "0.1.0" version to ensure that there's coverage of premajor version package bumps in the current state before adding my feature.preMajorVersionBumpoption that I added inindependentandfixedmode.version-conventional-commits.spec.tsto validate the new feature as well as backwards compatibility. (Not 100% sure if the 2nd test with"--premajor-version-bump semver"being explicitly set is needed though)Note: I had to update existing tests to support the additional packages with the additional premajor version package in the fixtures. Tests were also updated ensure the default
premajorVersionBumpargument passed torecommendVersionis accounted for as part of theexpect(recommendVersion).toHaveBeenCalledWithtest to continue to work since I've added the feature by passing the option to this function.Types of changes
Checklist:
Additional information
I have so far not done E2E testing nor Local CLI testing, let me know if these must be done in order to approve the PR, it was not super clear if they must be done for the PR to be approved.
Also I'm not entirely sure about the option name (
premajorVersionBump) or the values ("semver"/"node-semver") for the option, if you have any suggestions on better names for this then let me know.