Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named snapshot versions have semver sorting conflicts #823

Closed
mihkeleidast opened this issue May 31, 2022 · 8 comments
Closed

Named snapshot versions have semver sorting conflicts #823

mihkeleidast opened this issue May 31, 2022 · 8 comments

Comments

@mihkeleidast
Copy link

mihkeleidast commented May 31, 2022

Affected Packages

  • "@changesets/cli": "^2.22.0"

Problem

I've recently published multiple snapshot versions with different names, and tried to update from one to the other. My package manager (yarn classic) failed to install the newer transitive snapshot version, because the previous one's name was considered newer. This is probably because the named versions are ordered alphabetically.

From this example, you can see that even though the snapshot with name "semantic-colors" has the latest timestamp, it is ordered to be lower than the older "theme-provider" snapshot.
https://semvercompare.azurewebsites.net/?version=0.0.0-semantic-colors-20220527130647&version=0.0.0-theme-provider-20220526071429

Proposed solution

Reverse the order of the timestamp and snapshot name in the version. The following example has the timestamp and name switched and the versions are ordered correctly:
https://semvercompare.azurewebsites.net/?version=0.0.0-20220527130647-semantic-colors&version=0.0.0-20220526071429-theme-provider

@Andarist
Copy link
Member

I would probably accept a PR implementing this as an option.

@mihkeleidast
Copy link
Author

Why shouldn't this be the default? Isn't it bad that the snapshot versions can conflict (forcing users to think about why something is not installing correctly), while keeping the timestamp first would essentially eliminate this problem?

@Andarist
Copy link
Member

Mostly to avoid changing the default scheme within a minor release of Changesets. The current behavior was already out for a considerable amount of time and some people might rely on it.

That being said - when using snapshot versions all dependency ranges etc should be updated to fixed versions to eliminate the transitive dependency issues. If I understand your problem correctly then you might end up with the very same problem with the proposed change, just for a slightly different reason. After all the dates in the generated snapshot versions are also compared alphabetically.

@mihkeleidast
Copy link
Author

mihkeleidast commented Jun 1, 2022

Thanks, it makes more sense now.

That being said - when using snapshot versions all dependency ranges etc should be updated to fixed versions to eliminate the transitive dependency issues.

This seems like the more correct solution. Is there a way to make snapshot versioning do this, or is it the real issue that should be fixed?

@Andarist
Copy link
Member

Andarist commented Jun 1, 2022

This seems like the more correct solution. Is there a way to make snapshot versioning do this, or is it the real issue that should be fixed?

I would probably accept a PR implementing this as a default for snapshot releases 😉

@ivanbanov
Copy link

@Andarist #859
:)

@ivanbanov
Copy link

hey @Andarist about

If I understand your problem correctly then you might end up with the very same problem with the proposed change, just for a slightly different reason. After all the dates in the generated snapshot versions are also compared alphabetically.

You are right, even though it may still make sense to swap the order.
My team uses a script that wraps the changesets cli and controls the user inputs beforehand, in this case the change would save our skin since the tags are managed by the script.

I get your point about the fixed version, but since the change in order is (probably) not harmful, would it still be an option?

@mihkeleidast
Copy link
Author

This seems to be fixed by now, versions are without caret and some sort of templating is also possible, I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants