npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

upgrade-self

v0.2.0

Published

Reusable upgrade core for Node.js CLIs that checks npm versions, plans installs, and schedules detached self-upgrades.

Readme

upgrade-self

npm npm downloads license

github build coverage

upgrade-self is a shared upgrade core for Node.js CLIs. It checks npm for the latest version, builds an upgrade plan, writes a detached runner payload, and performs the global upgrade after the parent process exits.

The current implementation focuses on npm as the installer, while the public types and service layer keep room for additional package manager adapters.

Capabilities

  • Query the remote version with npm info <package> version --json
  • Compare versions with semver, including prerelease semantics
  • Share the same UpgradePlan and state machine between automatic and manual upgrade flows
  • Persist upgrade state, runner context, and logs under an isolated storageDir
  • Use a detached Node runner to avoid Windows file-lock conflicts while the CLI is still running

Install

npm install upgrade-self

Public API

import {
  buildNpmInstallCommand,
  checkForNpmUpdate,
  compareVersions,
  createAutoUpgradeService,
  readUpgradeState,
  resolveUpgradePaths,
  shouldCheckForUpdates,
} from 'upgrade-self'

Integration Example

The service is designed to be wired into a CLI at startup. A consumer can call the automatic path before dispatching commands, then reuse the same service for a manual upgrade command.

import os from 'node:os'
import { createRequire } from 'node:module'
import path from 'node:path'

import { NodeCommandRunner, createAutoUpgradeService } from 'upgrade-self'

const require = createRequire(import.meta.url)
const packageJson = require('./package.json') as { name: string; version: string }

const service = createAutoUpgradeService({
  packageName: packageJson.name,
  currentVersion: packageJson.version,
  storageDir: path.join(os.homedir(), '.my-cli', 'upgrade'),
  registry: process.env.npm_config_registry,
  argv: process.argv.slice(2),
  env: process.env,
  isInteractive: process.stdout.isTTY && process.stderr.isTTY,
  commandRunner: new NodeCommandRunner(),
})

await service.runAutomaticUpgrade()

// Inside a dedicated `upgrade` command:
// const status = await service.getStatus()
// const result = await service.runManualUpgrade({ checkOnly: true })

Design Boundaries

  • This package is a shared upgrade core, not a CLI command parser or text output layer.
  • This package targets Node.js only, so it does not produce browser UMD/CDN artifacts.
  • The first release ships with npm-only execution, but the type surface is ready for additional package managers.
  • The detached runner uses its own storageDir and does not depend on a consumer-specific config schema.

Local Development

npm install
npm run lint
npm run build
npm run test:unit
npm run test:e2e
npm test

Version requirements:

  • Published runtime: Node.js 14.18.0 or higher
  • Test runtime: Node.js 18.0.0 or higher
  • Build environment: Node.js 22.18.0 or higher because tsdown requires it

The end-to-end suite stays offline: tests/e2e prepends a local stub npm or npm.cmd, then exercises the real detached runner without contacting the public registry.