Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alangpierce
Copy link

@alangpierce alangpierce commented Feb 10, 2018

Description of the Change

As described in #733, installation currently makes a request to GET /api/packages/:package_name and uses the versions 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 to GET /api/packages/:package_name/versions/:version_name if necessary.

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.

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 Reviewable

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.
@alangpierce
Copy link
Author

See also this Slack conversation: https://atomio.slack.com/archives/C044E54H0/p1517937415000412
cc @lee-dohm

@lee-dohm
Copy link
Contributor

Thanks for this @alangpierce! It looks pretty good at first glance and I'll dig into it on Monday 👍

@lee-dohm
Copy link
Contributor

Would you mind fixing the conflicts here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

apm can't install a version that is more than [pagination limit] behind the latest
2 participants