melos icon indicating copy to clipboard operation
melos copied to clipboard

fix: preid parameter not properly propagated in some cases

Open michte opened this issue 2 years ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Version

2.3.1

Description

By convention, our team suffixes prereleases with the term beta. Using the preid flag available in the version command, we get an inconsistent behaviour depending on the scope of packages involved by the versioning process.

Steps to reproduce

  1. Commit a fix on a package with another package depending on it
  2. Launch the melos version command with a custom preid (beta)
  3. The custom preid is only applied on the package directly impacted by the commit, the other package is also updated but with the default preid suffix (dev)

Expected behavior

The custom preid should be applied to all packages involved in the versioning process.

Screenshots

No response

Additional context and comments

Our test repository has 2 packages in a single packages directory:

  • Parent
  • Child (using the Parent package as a dependency)

If I commit a fix on the Parent package and launch the following version command:

melos version --prerelease --preid=beta --yes

I get the following output:

melos version
   â””> D:\repo\git\flutter\_indus\flutter_multi

The following 2 packages will be updated:

Package Name                     Current Version   Updated Version   Update Reason
flutter_multi_parent   1.0.0             1.0.1-beta.0      updated with patch changes
flutter_multi_child    1.0.0             1.0.1-dev.0       dependency was updated
Versioning successful. Ensure you push your git changes and tags (if applicable) via git push --follow-tags

As you can see, the beta suffix is properly set on the Parent package directly affected by the commit, but the Child one is updated with the default dev suffix.

However, if I commit a fix impacting both packages and then launch the same command, I get the following output:

melos version
   â””> D:\repo\git\flutter\_indus\flutter_multi

The following 2 packages will be updated:

Package Name                     Current Version   Updated Version   Update Reason
flutter_multi_child    1.0.1-dev.0       1.0.1-beta.0      updated with patch changes
flutter_multi_parent   1.0.1-beta.0      1.0.1-beta.1      updated with patch changes
Versioning successful. Ensure you push your git changes and tags (if applicable) via git push --follow-tags

This time, both packages' versions are properly updated with the provided beta suffix.

Unless I'm mistaken, the preid parameter should apply to directly and indirectly involved packages during the versioning process or am I missing something ?

michte avatar May 31 '22 15:05 michte

I think the requested behavior makes sense. The docs for the --prerelease flag say Version any packages with changes as a prerelease.. It would probably be a mistake to use a prerelease dependency in a stable version.

WDYT @Salakar?

blaugold avatar May 31 '22 18:05 blaugold

One would argue that a dependency change in a package would be considered a change 😃

But nothing major on our side, I just wanted to make sure this was the intended behavior.

michte avatar Jun 01 '22 07:06 michte