This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Allow installing old versions not listed in the package info#773
Open
alangpierce wants to merge 1 commit intoatom:masterfrom
Open
Allow installing old versions not listed in the package info#773alangpierce wants to merge 1 commit intoatom:masterfrom
alangpierce wants to merge 1 commit intoatom:masterfrom
Conversation
Fixes atom#733 Rather than relying only on the JSON returned for the package, we now fall back to the `GET /api/packages/:package_name/versions/:version_name` endpoint if necessary, and use the tarball URL from there if we find one. Since I changed the code to use `version` to mean a version JSON object, I renamed `packageVersion` to `versionName` in a few places to be more clear. I also rely on `version.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.
Author
|
See also this Slack conversation: https://atomio.slack.com/archives/C044E54H0/p1517937415000412 |
Contributor
|
Thanks for this @alangpierce! It looks pretty good at first glance and I'll dig into it on Monday 👍 |
Contributor
|
Would you mind fixing the conflicts here? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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_nameand uses theversionskey 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_nameif necessary.Since I changed the code to use
versionto mean a version JSON object, I renamedpackageVersiontoversionNamein a few places to be more clear. I also rely onversion.versioncontaining 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_nameto 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