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

Automatically narrow down dependencies given as "any" #675

Merged
merged 6 commits into from
Feb 3, 2021

Conversation

mosteo
Copy link
Member

@mosteo mosteo commented Jan 29, 2021

I think npm also works like this. When a user adds a dependency without giving a version range, after this PR we use the solved version to narrow down the dependency to be added to what the user probably intends. E.g.: alr with foo previously resulted in foo* being added; now it will result in either foo~0.x or foo^x.y, etc being presented as the requested dependency.

A * dependency can still be added by requesting it explicitly with alr with 'foo>=0' (or manually editing, of course).

This may merit a config option to disable this behavior.

@mosteo mosteo marked this pull request as ready for review February 1, 2021 09:59
@onox
Copy link
Contributor

onox commented Feb 1, 2021

I think npm also works like this.

npm (and yarn) will look up the latest tag of the crate and then return the resolved version (seems to be x.y.z) with the ^ prefix. So they implicitly use foo@latest when you write foo.

Yarn will use ~ prefix if --tilde is used and if --peer is used, the default range is * and no resolving is done. (A peer dependency is used for crates that are plug-ins which are only known to work for specific x.y version of their host crate)

@mosteo
Copy link
Member Author

mosteo commented Feb 1, 2021

Thanks for the precision, @onox. I think the end result is similar (at least for regular crates... The idea of peer/host crates is new to me).

Instead of adding just a foo* dependency, check how it was solved and use that
version to add a more precise (and usually wanted) dependency; e.g., foo^1.2,
foo~0.1
Many tests explicitly check the added dependencies, so this is extra assurance
about this change.
@mosteo mosteo merged commit a689ee3 into alire-project:master Feb 3, 2021
@mosteo mosteo deleted the feat/narrowdep branch February 3, 2021 10:55
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 this pull request may close these issues.

3 participants