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

new npm-specific update-notifier implementation #1632

Closed
wants to merge 2 commits into from

Conversation

isaacs
Copy link
Contributor

@isaacs isaacs commented Aug 6, 2020

This drops our usage of the update-notifier module, in favor of checking
ourselves, using the modules and UX patterns that npm already has in
place.

  • While on a prerelease version, updates are checked for every day,
    instead of every week, and always checks for a new beta in the current
    release family. Ie, ^7.0.0-beta.2 instead of latest.
  • Latest version is suggested if newer than current.
  • If current version is newer than latest, then we check again for an
    update in the current version family. Ie, ^7.0.0 instead of latest,
    if current is 7.0.0 and latest is 6.x.
  • Output is printed using log.notice, at the end of all other log
    output, so that it's both less visually disruptive, and less likely to
    be missed among other warnings and notices.

This has the side effect of requiring that we set npm.flatOptions as
soon as config is loaded, rather than waiting for a command to be run.
Since the cli runs a command immediately after loading anyway, this is
not a relevant change for our purposes, but worth mentioning here.

@isaacs isaacs requested a review from a team as a code owner August 6, 2020 21:26
isaacs added 2 commits August 6, 2020 14:28
This drops our usage of the update-notifier module, in favor of checking
ourselves, using the modules and UX patterns that npm already has in
place.

- While on a prerelease version, updates are checked for every day,
  instead of every week, and always checks for a new beta in the current
  release family.  Ie, ^7.0.0-beta.2 instead of latest.
- Latest version is suggested if newer than current.
- If current version is newer than latest, then we check again for an
  update in the current version family.  Ie, ^7.0.0 instead of latest,
  if current is 7.0.0 and latest is 6.x.
- Output is printed using log.notice, at the end of all other log
  output, so that it's both less visually disruptive, and less likely to
  be missed among other warnings and notices.

This has the side effect of requiring that we set npm.flatOptions as
soon as config is loaded, rather than waiting for a command to be run.
Since the cli runs a command immediately after loading anyway, this is
not a relevant change for our purposes, but worth mentioning here.
@isaacs isaacs force-pushed the isaacs/new-terse-update-notifier branch from d94ed8c to 655964d Compare August 6, 2020 21:29
@isaacs
Copy link
Contributor Author

isaacs commented Aug 6, 2020

New styling:
Screen Shot 2020-08-06 at 14 30 04

if (!er && !this[_flatOptions]) {
this[_flatOptions] = require('./config/flat-options.js')(this)
require('./config/set-envs.js')(this)
}
Copy link
Contributor

@ruyadorno ruyadorno Aug 7, 2020

Choose a reason for hiding this comment

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

will this also allow us to move even more configs to flatOptions in the future ?

if (er) return errorHandler(er)

updateNotifier(npm)
npm.updateNotification = await updateNotifier(npm)
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm this got me thinking... is there a possibility we could move this to a threaded api (workers/child_process/etc) so the cli never has to wait on it? Simply saying: print it if you had the time, don't bother blocking cli exit in case pacote isn't done fetching the packument yet.

Or is it already the case and I'm missing how something about how it works?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm. Yeah, we could do something like:

updateNotifier(npm).then(message => { npm.updateNotification = message })

and then it'll just get killed when the process exits if it doesn't finish in time.

But it means you won't ever get notified if you're running npm ls. Maybe that's good? Have to make sure the timer file doesn't get touched before pacote finishes though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, the updateTimeout method would have to be split into two functions, one to check the timer and another to reset it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe that's good?

I do think so! but we can def revisit it later 😊 def not a blocker so I ended up merging the PR 😁

ruyadorno pushed a commit that referenced this pull request Aug 7, 2020
PR-URL: #1632
Credit: @isaacs
Close: #1632
Reviewed-by: @ruyadorno
@ruyadorno ruyadorno closed this Aug 7, 2020
@isaacs isaacs deleted the isaacs/new-terse-update-notifier branch October 2, 2020 21:41
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.

2 participants