Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Allow semver constraints when installing packages #278

Open
Michael-F-Bryan opened this issue Sep 20, 2022 · 0 comments
Open

Allow semver constraints when installing packages #278

Michael-F-Bryan opened this issue Sep 20, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Michael-F-Bryan
Copy link
Contributor

Motivation

Sometimes, instead of installing a package's exact version, you only care about something "compatible" with that version. It'd be nice if we can run wapm install Michael-F-Bryan/hello-world@^0.2 to get a version of Michael-F-Bryan/hello-world that satisfies the semver constraint, ^0.2.0 (i.e. 0.2.5, but not 0.3.0).

For a more concrete example, on the WAPM backend @ayys and I want to be able to automatically pick up bugfixes to wit-pack as they are released while preventing breaking changes from being installed like you would get from a naive wapm install Michael-F-Bryan/hello-world.

Proposed solution

In theory, this should just be a case of updating AddedPackages::extract_name_and_version() to return a VersionReq here

fn extract_name_and_version(pair: (&'a str, &'a str)) -> Result<(&'a str, Version), Error> {
Version::parse(pair.1)
.map(|version| (pair.0, version))
.map_err(|e| Error::SemVerError(e.to_string()))
}

Then, this line would call PackageKey::new_registry_package_range(n, v) instead of PackageKey::new_registry_package(n, v).

.map(|(n, v)| PackageKey::new_registry_package(n, v))

Alternatives

One alternative would be to allow people to use a VersionReq with wapm search to find the version compatible with a particular requirement, which would then let you run wapm install package@specific_version like normal. I don't think splitting the operation into two steps would help much, though.

@Michael-F-Bryan Michael-F-Bryan added good first issue Good for newcomers enhancement New feature or request labels Sep 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant