From d953dd89e82962acb97c1a7ceab3ed7aaf6ef7b3 Mon Sep 17 00:00:00 2001 From: Yadd Date: Thu, 16 Feb 2023 14:46:17 +0800 Subject: [PATCH] don't check for last version Forwarded: not-needed Last-Update: 2021-12-13 Gbp-Pq: Name dont-check-for-last-version.patch --- lib/utils/update-notifier.js | 81 +----------------------------------- 1 file changed, 2 insertions(+), 79 deletions(-) diff --git a/lib/utils/update-notifier.js b/lib/utils/update-notifier.js index 44b6a54..0464561 100644 --- a/lib/utils/update-notifier.js +++ b/lib/utils/update-notifier.js @@ -35,85 +35,8 @@ const checkTimeout = async (npm, duration) => { } const updateNotifier = async (npm, spec = 'latest') => { - // never check for updates in CI, when updating npm already, or opted out - if (!npm.config.get('update-notifier') || - isGlobalNpmUpdate(npm) || - ciDetect()) { - return null - } - - // if we're on a prerelease train, then updates are coming fast - // check for a new one daily. otherwise, weekly. - const { version } = npm - const current = semver.parse(version) - - // if we're on a beta train, always get the next beta - if (current.prerelease.length) { - spec = `^${version}` - } - - // while on a beta train, get updates daily - const duration = spec !== 'latest' ? DAILY : WEEKLY - - // if we've already checked within the specified duration, don't check again - if (!(await checkTimeout(npm, duration))) { - return null - } - - // if they're currently using a prerelease, nudge to the next prerelease - // otherwise, nudge to latest. - const useColor = log.useColor() - - const mani = await pacote.manifest(`npm@${spec}`, { - // always prefer latest, even if doing --tag=whatever on the cmd - defaultTag: 'latest', - ...npm.flatOptions, - }).catch(() => null) - - // if pacote failed, give up - if (!mani) { - return null - } - - const latest = mani.version - - // if the current version is *greater* than latest, we're on a 'next' - // and should get the updates from that release train. - // Note that this isn't another http request over the network, because - // the packument will be cached by pacote from previous request. - if (semver.gt(version, latest) && spec === 'latest') { - return updateNotifier(npm, `^${version}`) - } - - // if we already have something >= the desired spec, then we're done - if (semver.gte(version, latest)) { - return null - } - - // ok! notify the user about this update they should get. - // The message is saved for printing at process exit so it will not get - // lost in any other messages being printed as part of the command. - const update = semver.parse(mani.version) - const type = update.major !== current.major ? 'major' - : update.minor !== current.minor ? 'minor' - : update.patch !== current.patch ? 'patch' - : 'prerelease' - const typec = !useColor ? type - : type === 'major' ? chalk.red(type) - : type === 'minor' ? chalk.yellow(type) - : chalk.green(type) - const oldc = !useColor ? current : chalk.red(current) - const latestc = !useColor ? latest : chalk.green(latest) - const changelog = `https://github.com/npm/cli/releases/tag/v${latest}` - const changelogc = !useColor ? `<${changelog}>` : chalk.cyan(changelog) - const cmd = `npm install -g npm@${latest}` - const cmdc = !useColor ? `\`${cmd}\`` : chalk.green(cmd) - const message = `\nNew ${typec} version of npm available! ` + - `${oldc} -> ${latestc}\n` + - `Changelog: ${changelogc}\n` + - `Run ${cmdc} to update!\n` - - return message + // Maintained by Debian JS Team + return null } // only update the notification timeout if we actually finished checking