salsify / ember-cli-dependency-lint

Lint your app's addon dependencies, making sure you only have one version of each.
MIT License
83 stars 8 forks source link

Not correctly interpreting version ranges #7

Closed mydea closed 6 years ago

mydea commented 6 years ago

I just started using ember-cli-dependency-lint, and I really like the idea (as it has happend to me before that my app broke due to differing dependency versions).

However, it seems to not correctly handle version ranges for me.

E.g. my app has the following dependency:

"ember-tether": "~0.4.1"

while another dependency had

"ember-tether": "^0.3.1"

specified. This resulted in an error. Shouldn't that be allowed?

dfreeman commented 6 years ago

Node/npm/yarn/etc. treat version numbers with leading zeroes (e.g. 0.x.y or 0.0.z) in a special way when dealing with ^ and ~ version ranges. Basically, incrementing the first nonzero segment indicates a potentially breaking change in a library. In ember-tether, for example, they dropped support for all versions of Ember before 2.4 when they released version 0.4.0.

This means ~0.4.1 is equivalent to >=0.4.1 <0.5.0, and ^0.3.1 is equivalent to >=0.3.1 <0.4.0, so there's no version of ember-tether that can satisfy both. You're winding up with two different versions in your dependency tree, and dependency-lint is letting you know that that happened. If you test your app and you're comfortable with the conflict, you can tell dependency-lint to ignore it.

You can check out the node-semver documentation and this interactive semver calculator for more details on how version ranges work. 🙂

mydea commented 6 years ago

Ah, got it. Good to know - I wasn't aware of that. Thanks for the quick answer and the great work on this addon :)