Skip to content

Add update notifier to CLI#3096

Merged
youknowriad merged 7 commits intotrunkfrom
cli-update-changelog
Apr 15, 2026
Merged

Add update notifier to CLI#3096
youknowriad merged 7 commits intotrunkfrom
cli-update-changelog

Conversation

@youknowriad
Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Claude authored the implementation and tests based on design decisions made collaboratively. All code was reviewed and tested manually.

Proposed Changes

  • Add an update notifier that checks the npm registry for newer versions of wp-studio and displays a banner at the top of CLI output
  • The banner includes the current/latest version, the npm update command, and a link to the changelog at https://developer.wordpress.com/docs/developer-tools/studio/changelog/
  • Results are cached locally for 24 hours to avoid repeated network calls
  • The banner is suppressed in IPC mode (when CLI is spawned by the desktop app) and when --json flag is used

Testing Instructions

  • Build the CLI: npm run cli:build
  • Temporarily set the version in apps/cli/package.json to an old version (e.g., 1.0.0), rebuild, then run any command twice:
    • First run populates the cache
    • Second run displays the update banner at the top of output
  • Verify the banner shows for --version, site list, and other commands
  • Verify the banner does NOT show when using --json flag
  • Restore the version back to the original value after testing

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

Show a banner at the top of CLI output when a newer version of wp-studio
is available on npm. Includes a changelog link to the Studio docs page.
The check is cached for 24 hours and suppressed in IPC mode or with --json.

Fixes STU-1449

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@youknowriad youknowriad self-assigned this Apr 15, 2026
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Apr 15, 2026

📊 Performance Test Results

Comparing 0eebd17 vs trunk

app-size

Metric trunk 0eebd17 Diff Change
App Size (Mac) 1282.03 MB 1282.03 MB 0.00 MB ⚪ 0.0%

site-editor

Metric trunk 0eebd17 Diff Change
load 1959 ms 1987 ms +28 ms ⚪ 0.0%

site-startup

Metric trunk 0eebd17 Diff Change
siteCreation 9095 ms 9124 ms +29 ms ⚪ 0.0%
siteStartup 4319 ms 4954 ms +635 ms 🔴 14.7%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Copy link
Copy Markdown
Contributor

@fredrikekelund fredrikekelund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fundamental strategy looks good to me, and this works as expected in testing 👍

I left a couple of implementation-focused comments that we should address before landing, but I'll still approve straight away to unblock you, @youknowriad

Comment thread apps/cli/lib/update-notifier.ts Outdated
Comment thread apps/cli/lib/update-notifier.ts Outdated
Comment thread apps/cli/lib/update-notifier.ts
Comment thread apps/cli/lib/update-notifier.ts
youknowriad and others added 4 commits April 15, 2026 11:43
- Use zod schemas to validate cache file and npm registry response
- Use atomically library for cache writes to avoid concurrent conflicts
- Reduce fetch timeout from 5s to 3s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move lastChecked/latestVersion into the existing cli.json config file
as an optional updateCheck field. Writes use updateCliConfigWithPartial
(with locking), reads use a direct sync fs.readFileSync for the banner.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make setupUpdateNotifier async and await it so the fetch completes
before the process exits. This ensures the cache is written and the
banner shows even for quick commands like --version.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it with site list, code and code --json

Image Image Image

I also tested it using latest version, and I confirm the notice doesn't appear in that case:

Image

I left a minor suggestion.

Comment thread apps/cli/lib/update-notifier.ts Outdated
Copy link
Copy Markdown
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried with a -beta1 👍

1.7.8-beta1 1.7.9-beta1
Image Image

youknowriad and others added 2 commits April 15, 2026 13:02
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Skip the update notifier when __IS_PACKAGED_FOR_NPM__ is false, since
bundled CLI users should update via the desktop app instead of npm.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@youknowriad youknowriad merged commit 7392c2b into trunk Apr 15, 2026
10 checks passed
@youknowriad youknowriad deleted the cli-update-changelog branch April 15, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants