Gathering detailed insights and metrics for update-notifier
Gathering detailed insights and metrics for update-notifier
Gathering detailed insights and metrics for update-notifier
Gathering detailed insights and metrics for update-notifier
simple-update-notifier
Simple update notifier to check for npm updates for cli applications
@types/update-notifier
TypeScript definitions for update-notifier
tiny-updater
A small update notifier for NPM packages, useful for CLI apps.
oclif-plugin-update-notifier
update-notifier for oclif plugins
Update notifications for your CLI app
npm install update-notifier
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,763 Stars
221 Commits
132 Forks
21 Watching
1 Branches
58 Contributors
Updated on 30 Oct 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-1.9%
1,461,782
Compared to previous day
Last week
4.2%
7,925,251
Compared to previous week
Last month
21.4%
30,774,353
Compared to previous month
Last year
-14.9%
311,032,260
Compared to previous year
Update notifications for your CLI app
Inform users of updates for your package in a non-intrusive way.
1npm install update-notifier
1import updateNotifier from 'update-notifier'; 2import packageJson from './package.json' assert {type: 'json'}; 3 4updateNotifier({pkg: packageJson}).notify();
1import updateNotifier from 'update-notifier'; 2import packageJson from './package.json' assert {type: 'json'}; 3 4// Checks for available update and returns an instance 5const notifier = updateNotifier({pkg: packageJson}); 6 7// Notify using the built-in convenience method 8notifier.notify(); 9 10// `notifier.update` contains some useful info about the update 11console.log(notifier.update); 12/* 13{ 14 latest: '1.0.1', 15 current: '1.0.0', 16 type: 'patch', // Possible values: latest, major, minor, patch, prerelease, build 17 name: 'pageres' 18} 19*/
1const notifier = updateNotifier({ 2 pkg, 3 updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week 4}); 5 6if (notifier.update) { 7 console.log(`Update available: ${notifier.update.latest}`); 8}
Whenever you initiate the update notifier and it's not within the interval threshold, it will asynchronously check with npm in the background for available updates, then persist the result. The next time the notifier is initiated, the result will be loaded into the .update
property. This prevents any impact on your package startup performance.
The update check is done in an unref'ed child process. This means that if you call process.exit
, the check will still be performed in its own process.
The first time the user runs your app, it will check for an update, and even if an update is available, it will wait the specified updateCheckInterval
before notifying the user. This is done to not be annoying to the user, but might surprise you as an implementer if you're testing whether it works. Check out example.js
to quickly test out update-notifier
and see how you can test that it works in your app.
Checks if there is an available update. Accepts options defined below. Returns an instance with an .update
property if there is an available update, otherwise undefined
.
Type: object
Type: object
Required
Type: string
Required
Type: string
Type: number
Default: 1000 * 60 * 60 * 24
(1 day)
How often to check for updates.
Type: boolean
Default: false
Allows notification to be shown when running as an npm script.
Type: string
Default: 'latest'
Which dist-tag to use to find the latest version.
Check update information.
Returns an object
with:
latest
(string) - Latest version.current
(string) - Current version.type
(string) - Type of the current update. Possible values: latest
, major
, minor
, patch
, prerelease
, build
.name
(string) - Package name.Convenience method to display a notification message. (See screenshot)
Only notifies if there is an update and the process is TTY.
Type: object
Type: boolean
Default: true
Defer showing the notification until after the process has exited.
Type: string
Default: See above screenshot
Message that will be shown when an update is available.
Available placeholders:
{packageName}
- Package name.{currentVersion}
- Current version.{latestVersion}
- Latest version.{updateCommand}
- Update command.1notifier.notify({message: 'Run `{updateCommand}` to update.'}); 2 3// Output: 4// Run `npm install update-notifier-tester@1.0.0` to update.
Type: boolean
Default: Auto-detect
Include the -g
argument in the default message's npm i
recommendation. You may want to change this if your CLI package can be installed as a dependency of another project, and don't want to recommend a global installation. This option is ignored if you supply your own message
(see above).
Type: object
Default: {padding: 1, margin: 1, textAlignment: 'center', borderColor: 'yellow', borderStyle: 'round'}
(See screenshot)
Options object that will be passed to boxen
.
Users of your module have the ability to opt-out of the update notifier by changing the optOut
property to true
in ~/.config/configstore/update-notifier-[your-module-name].json
. The path is available in notifier.config.path
.
Users can also opt-out by setting the environment variable NO_UPDATE_NOTIFIER
with any value or by using the --no-update-notifier
flag on a per run basis.
The check is also skipped automatically:
NODE_ENV
environment variable is test
)The idea for this module came from the desire to apply the browser update strategy to CLI tools, where everyone is always on the latest version. We first tried automatic updating, which we discovered wasn't popular. This is the second iteration of that idea, but limited to just update notifications.
There are a bunch of projects using it:
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4
Reason
Found 6/30 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More