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

Add yarn version check on startup #1138

Closed
Daniel15 opened this issue Oct 17, 2016 · 14 comments
Closed

Add yarn version check on startup #1138

Daniel15 opened this issue Oct 17, 2016 · 14 comments

Comments

@Daniel15
Copy link
Member

Daniel15 commented Oct 17, 2016

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
Yarn does not notify the user that a new version of Yarn is available

What is the expected behavior?
Yarn should periodically check for new version on startup. Maybe once per day. You can get the latest version number by hitting https://yarnpkg.com/latest-version.

If the latest version is newer than the current version, display a message with the new version number, and instructions on how to update. Optionally, if the user is using a TTY (ie. they're not piping the output elsewhere or running Yarn from a script), we could prompt if they want to upgrade right away:

Yarn 0.16.0 is available! (you're using 0.15.0)
Do you want to upgrade now (Y/N)? __

This would use yarn update-self once it's updated to use the same installation method originally used (#1139).

For an initial version, we could just show instructions on how to update. Important: These instructions should correspond to the installation method the user used to install Yarn.

For example, on Debian or Ubuntu:

Yarn 0.16.0 is available! (you're using 0.15.0)
To upgrade, run "sudo apt-get install yarn"

On Windows when using the Windows installer:

Yarn 0.16.0 is available! (you're using 0.15.0)
To upgrade, download the latest installer from https://yarnpkg.com/latest.msi

On Mac OS:

Yarn 0.16.0 is available! (you're using 0.15.0)
To upgrade, run "brew upgrade yarn"

When installed via npm:

Yarn 0.16.0 is available! (you're using 0.15.0)
To upgrade, run "npm upgrade --global yarn"

Currently we don't actually record the installation method anywhere, so I think we'll just have to guess it based on the environment (eg. if /usr/share/lintian/overrides/yarn exists, the Ubuntu/Debian package was used) unless we update all the installation methods to write a config file specifying the installation method.

If we can't tell which installation method was used, just print the new version number without the upgrade instructions.

@dlong500
Copy link

I love this, but I'd prefer not to have a prompt to upgrade (or at least a config flag to turn that behavior off). The yarn self-update command working as you just mentioned in #1139 would make things very easy to keep things up to date especially on a vanilla Windows platform without any OS package manager.

Thanks for the great work!

@jamiebuilds
Copy link
Contributor

Big fan of this idea

@addyosmani
Copy link
Member

Love this idea. In case it offers any inspiration, we use https://github.com/yeoman/update-notifier for start-up based update notifications in a few different CLI projects.

I think you might be trying to do something a little more custom in each case given you would like to stick closely to the installation method originally used to install yarn.

@Daniel15
Copy link
Member Author

@addyosmani - Yeah, I saw that (someone linked to it in another issue somewhere) but it looks tightly-coupled to npm. I wonder if we could use the UI of it while customising the backend.

In our case, we have an endpoint https://yarnpkg.com/latest-version that returns the version number, so a lot of the complexity (ie. checking version number from npm) doesn't exist for us. It should be fairly straightforward 😄

@cpojer
Copy link
Contributor

cpojer commented Oct 17, 2016

@Daniel15 please make a PR for this.

Can we somehow add a token to every build indicating the install method? I think that's way better than any sort of inference we might do.

@addyosmani
Copy link
Member

Sgtm @Daniel15 :)

I'll loop in @sindresorhus just in case he's interested in generalizing update-notifier (or similar) to work better with yarn (even if it may not get used here).

@Daniel15
Copy link
Member Author

please make a PR for this

I'll try to do that when I get some time to work on it (perhaps a week or two from now), I just thought I'd post the idea while it's still fresh in my mind. If anyone else wants to work on this and it's unassigned on Github, feel free to pick it up (I'll assign it to me if I start working on it) 😄

@Daniel15
Copy link
Member Author

Can we somehow add a token to every build indicating the install method?

Yeah, that sounds like the best idea. It'd help with #942 (if we want to implement that) too.

@sindresorhus
Copy link

sindresorhus commented Oct 17, 2016

I don't think update-notifier is a good fit here as-is, but could definitely be a good inspiration, and you could reuse many of its building blocks. The best thing about it is how non-intrusive it is. It only shows the update notification after running the CLI tool and only if the terminal is interactive, so it's never in the way of what the user want to do. It should not show the notification very often; Maximum once a day, but preferably once a week. It's also important to have an easy opt-out for people not wanting update notifications.

I'm thinking the output text could be:

Yarn 0.16.0 is available!
To upgrade from 0.15.0, run:
brew upgrade yarn

Having the command on a separate line makes it easier to copy-paste for users.

Yeah, I saw that (someone linked to it in another issue somewhere) but it looks tightly-coupled to npm. I wonder if we could use the UI of it while customising the backend.

The update-notifier UI is just boxen for the box and chalk for styling the text.

@Daniel15
Copy link
Member Author

Thanks for your insight, @sindresorhus!

It only shows the update notification after running the CLI tool and only if the terminal is interactive

This is a great idea, better than showing the notification / asking about it before running the tool.

sebmck pushed a commit that referenced this issue Oct 25, 2016
@sebmck
Copy link
Contributor

sebmck commented Oct 25, 2016

Created #1429 to fix this, pending approval.

@sebmck sebmck closed this as completed Oct 25, 2016
sebmck pushed a commit that referenced this issue Oct 25, 2016
Daniel15 added a commit to Daniel15/yarn that referenced this issue Oct 30, 2016
Daniel15 added a commit to Daniel15/yarn that referenced this issue Oct 30, 2016
sebmck pushed a commit that referenced this issue Nov 1, 2016
* Add installationMethod property to package.json

References #1139, #942, #1429, #1138

* Make set-installation-method.js executable
bestander pushed a commit that referenced this issue Nov 14, 2016
… version available (#1429)

* Add automatic check for updates that nags the user when there's a new version available - fixes #1138

* remove self-update

* add support for updating yarn to tarball installer

* use new installationMethod package.json value to output update command

* address comments from @Daniel15

* remove self update tests
@AlexWayfer
Copy link

Where is it?…

$ yarn
yarn install v1.3.2
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.49s.

But 1.5.1 at https://yarnpkg.com/latest-version 🙁

@Daniel15
Copy link
Member Author

Daniel15 commented Mar 4, 2018

The check only runs once per day, so it might not have ran yet.

@AlexWayfer
Copy link

The check only runs once per day, so it might not have ran yet.

Still no:

$ yarn
yarn install v1.3.2
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.33s.

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

No branches or pull requests

8 participants