Notify users of CLI updates
npm install cli-update-notifier
# or
yarn add cli-update-notifierimport notify from "cli-update-notifier";
await notify("react", "18.2.0");import notify from "cli-update-notifier";
import pkg from "./package.json";
await notify(pkg.name, pkg.version);notify(
name: string,
currentVersion: string,
title?: string = "Update Available",
titleAlignment?: "left" | "center" | "right",
padding?: number = 1,
borderColor?: string = "green",
): Promise<void>| Name | Type | Default | Description |
|---|---|---|---|
name |
string |
— | (required) NPM package name. |
currentVersion |
string |
— | (required) Your version. |
title |
string |
"Update Available" |
Box header. |
titleAlignment |
"left" | "center" | "right" |
"center" |
Title text alignment. |
padding |
number |
1 |
Inner box padding. |
borderColor |
string |
"green" |
Boxen border color. |
- Detects package manager via
npm_config_user_agent. - Fetches
latestversion usingnpm-metadata. - Compares with
currentVersion. If identical, does nothing. - Builds a formatted message of current and latest versions + update command.
- Outputs a styled box using
boxenandchalk.
import notify from "cli-update-notifier";
import { name, version } from "./package.json";
await notify(name, version);When an update is found, users see:
Package manager is auto‑detected:
npm:npm i -g <name>yarn:yarn global add <name>pnpm:pnpm add -g <name>bun:bun add -g <name>
- Lightweight and fast
- Works with all major package managers
- Stylish, clear CLI updates
- Silent when no updates
Contributions welcome! Please:
- Fork the repo
- Create a new branch (
git checkout -b feature/...) - Add tests or docs
- Submit a PR
MIT License
