Skip to content

[lockfile-explorer] Replace update-notifier with a built-in solution#5786

Open
iclanton wants to merge 5 commits intomicrosoft:mainfrom
iclanton:update-notifier
Open

[lockfile-explorer] Replace update-notifier with a built-in solution#5786
iclanton wants to merge 5 commits intomicrosoft:mainfrom
iclanton:update-notifier

Conversation

@iclanton
Copy link
Copy Markdown
Member

Summary

Removes the update-notifier npm dependency from @rushstack/lockfile-explorer and replaces it with a small built-in PackageUpdateChecker class.

The new implementation:

  • Fetches the latest version from the npm registry using the global fetch API (Node 18+), with a 5-second abort timeout so it never hangs startup
  • Caches results in ~/.rushstack/update-checks/<package>.json (consistent with the ~/.rushstack convention used by @rushstack/debug-certificate-manager)
  • Starts the check concurrently with server setup and displays the notification inside app.listen, so it never blocks the server from starting
  • Skips silently on network errors or cache write failures

Details

  • apps/lockfile-explorer/src/utils/PackageUpdateChecker.ts — new self-contained utility (no new dependencies)
  • apps/lockfile-explorer/src/utils/constants.ts — extracts LFX_PACKAGE_NAME / LFX_VERSION constants shared across the CLI entry points
  • ExplorerCommandLineParser.ts — fires updateCheckPromise before server setup, awaits it in app.listen callback via printUpdateNotification()
  • Removes update-notifier and @types/update-notifier from package.json
  • Removes update-notifier from nonbrowser-approved-packages.json

Also includes: CLI help snapshot test and minor terminal/action cleanup.

How it was tested

Unit tests added for PackageUpdateChecker covering: fresh cache hit, stale cache re-fetch, missing cache, forceCheck, network error, non-ok HTTP response, isOutdated logic, wrong cacheVersion, custom cacheExpiryMs, and scoped package name sanitization.

iclanton and others added 5 commits April 18, 2026 14:52
…te-notifier

- Add `PackageUpdateChecker` class to `rush-lib` as an `@internal` utility:
  caches latest-version results in `~/.rushstack/update-checks/`, uses
  global `fetch` with a 5s timeout, and supports `forceCheck`/`skip` options
- Export as `_PackageUpdateChecker` from `@microsoft/rush-lib`
- Replace `update-notifier` in `lockfile-explorer` with `PackageUpdateChecker`;
  fire the check concurrently with server setup and display the result inside
  `app.listen` via a standalone `printUpdateNotification` helper
- Remove `update-notifier` and `@types/update-notifier` from dependencies
- Remove `update-notifier` from nonbrowser-approved-packages.json
- Add unit tests for `PackageUpdateChecker` (mocking `fetch` and `JsonFile`)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

1 participant