This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Allow installing old versions not listed in the package info #773
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
As described in #733, installation currently makes a request to
GET /api/packages/:package_name
and uses theversions
key to get the tarball URL. This only works with recent versions because the API only returns the 30 most recent versions here. To allow installing older versions, this change makes it so we first check the package information, then make another request toGET /api/packages/:package_name/versions/:version_name
if necessary.Since I changed the code to use
version
to mean a version JSON object, I renamedpackageVersion
toversionName
in a few places to be more clear. I also rely onversion.version
containing the version name, which required updating some test fixtures.This also adds tests for installing old versions in general and producing the expected error message if a version isn't found.
Alternate Designs
Another approach would be to modify the
GET /api/packages/:package_name
to either support pagination or return all versions. The current approach is nice because it's just a change to the client and does not have the risk of a performance regression in the common case. It's also simpler than trying to use a paginated endpoint.Yet another approach would be to derive the tarball URL directly rather than getting it from the API, since it seems to follow a standard format. This would simplify the code, but would be less HATEOAS-friendly and make it harder to change tarball URLs in the future.
Benefits
This change makes it possible to install old versions of packages. In particular, I'm getting a build failure in the decaffeinate test suite because I'm trying to build Atom from last September.
Possible Drawbacks
Installing a nonexistent version will now be slightly slower because it will do another API request.
Applicable Issues
Fixes #733
This change is