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

fix: update notifier to consider node version #7876

Draft
wants to merge 1 commit into
base: latest
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions lib/cli/update-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,22 @@
const parse = require('semver/functions/parse')
const { stat, writeFile } = require('node:fs/promises')
const { resolve } = require('node:path')
const { checkEngine } = require('npm-install-checks')
const semver = require('semver')

// update check frequency
const DAILY = 1000 * 60 * 60 * 24
const WEEKLY = DAILY * 7

const engineOk = (manifest, npmVersion, nodeVersion) => {
try {
checkEngine(manifest, npmVersion, nodeVersion)
return true
} catch (_) {
return false
}
}

// don't put it in the _cacache folder, just in npm's cache
const lastCheckedFile = npm =>
resolve(npm.flatOptions.cache, '../_update-notifier-last-checked')
Expand All @@ -22,19 +33,23 @@
const updateCheck = async (npm, spec, version, current) => {
const pacote = require('pacote')

const mani = await pacote.manifest(`npm@${spec}`, {
const pacu = await pacote.packument(`npm@${spec}`, {

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.9.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 22.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.17.0

pacote.packument is not a function

Check failure on line 36 in lib/cli/update-notifier.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.17.0

pacote.packument is not a function
// always prefer latest, even if doing --tag=whatever on the cmd
defaultTag: 'latest',
...npm.flatOptions,
cache: false,
}).catch(() => null)

const npmVersions = Object.keys(pacu.versions).sort(semver.rcompare)
const compatibleLatest = npmVersions.find(v => {
return engineOk(pacu.versions[v], npm.version, process.version)
})
// if pacote failed, give up
if (!mani) {
if (!compatibleLatest) {
return null
}

const latest = mani.version
const mani = pacu.versions[compatibleLatest]
const latest = compatibleLatest

// if the current version is *greater* than latest, we're on a 'next'
// and should get the updates from that release train.
Expand Down
Loading