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

Simplify download latest release logic #560

Merged
merged 2 commits into from
Jul 23, 2018
Merged

Simplify download latest release logic #560

merged 2 commits into from
Jul 23, 2018

Conversation

36degrees
Copy link
Contributor

Within the docs we link to /prototype-admin/download-latest which looks up the latest release from GitHub and redirects to the zip download.

On the install page itself, we look up the latest release URL and then link directly to GitHub from the page.

This moves the /prototype-admin/download-latest to /docs/install so that it can live within the docs folder and unifies the two approaches so that we consistently use the /docs/download URL. This means that we are no longer blocking on a GitHub request before we can render the install page – and that we only make the request to GitHub if the user actually tries to download the kit.

Secondly, this tries to simplify the getLatestRelease function:

  • Rather than trying to extract the tag name from the zipball URL, use the value of name that we get in the response data
  • Use template literals to build the zip URL rather than multiple variables and concatenation
  • Avoid assigning things to variables that aren't used more than once (githubUrl, options) which also reduces the amount of seeking you have to do through the code
  • Remove url, zipUrl variables by assigning to releaseUrl directly and returning from every scenario

@36degrees
Copy link
Contributor Author

Thinking about it, how often is the latest release name going to differ from what's in package.json? Are they likely to be out of sync? If not, could we read it out of the package.json file instead of making a request to GitHub?

@joelanman
Copy link
Contributor

thanks, looks like a nicer approach, I'll test it out later. Just to note though that the URL is cached, so it was only ever blocking the first time it was ever called by any visit.

Copy link
Contributor

@NickColley NickColley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense 👍 would be good to get review applications on this repo

Copy link
Contributor

@NickColley NickColley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually you're right, we could avoid this request entirely.

@NickColley
Copy link
Contributor

Note if we keep the API request we could add the changelog notes into the download page: #404

Within the docs we link to `/prototype-admin/download-latest` which looks up the latest release from GitHub and redirects to the zip download.

On the install page itself, we look up the latest release URL and then link directly to GitHub from the page.

This moves the `/prototype-admin/download-latest` to `/docs/install` so that it can live within the docs folder and unifies the two approaches so that we consistently use the `/docs/download` URL. This means that we are no longer blocking on a GitHub request before we can render the install page – and that we only make the request to GitHub if the user actually tries to download the kit.
- Rather than trying to extract the tag name from the zipball URL, use the value of `name` that we get in the response data
- Use template literals to build the zip URL rather than multiple variables and concatenation
- Avoid assigning things to variables that aren't used more than once (githubUrl, options) which also reduces the amount of seeking you have to do through the code
- Remove url, zipUrl variables by assigning to releaseUrl directly and `return`ing from every scenario
@36degrees 36degrees merged commit 7be8557 into master Jul 23, 2018
@36degrees 36degrees deleted the simpler-downloads branch July 23, 2018 08:26
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