feat: improve npm authentication and plugin health checks during CLI updates#3547
Open
feat: improve npm authentication and plugin health checks during CLI updates#3547
Conversation
…updates This change improves the user experience when updating the Heroku CLI by adding better handling for npm authentication and plugin installation issues. Key changes: - Add preupdate hook (check-npm-auth) that detects private plugins and prompts users to authenticate with npm before attempting the update - Add post-update hook (check-plugin-health) that verifies all plugins installed correctly and provides recovery instructions for missing plugins - Remove deprecated v6 plugin migration code from plugin-migrate hook - Add comprehensive unit tests for both new hooks The check-npm-auth hook: - Reads installed plugins from package.json - Checks which plugins are private (require authentication) - Verifies npm authentication status - Prompts user to login if needed before proceeding with update - Handles user cancellation gracefully with clear messaging The check-plugin-health hook: - Runs after plugin installation during update - Checks if all configured plugins exist in node_modules - Warns users about missing plugins with recovery instructions - Suggests both reinstall and uninstall options This resolves issues where users would get cryptic npm errors during CLI updates when logged out of npm with private plugins installed.
Refactor check-npm-auth hook to check multiple plugins concurrently instead of sequentially. This significantly reduces the time to check plugin privacy when users have many plugins installed. - Process plugins in batches of 5 using Promise.all - Maintains the same behavior and debug logging - Reduces check time from O(n) sequential to O(n/5) batches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the user experience when updating the Heroku CLI by adding better handling for npm authentication and plugin installation issues. Users previously encountered cryptic npm errors when updating while logged out of npm with private plugins installed. This change proactively detects and handles these scenarios with clear messaging and interactive prompts.
Type of Change
Feature Additions (minor semver update)
Changes
New Hooks Added
1. check-npm-auth (preupdate hook)
2. check-plugin-health (update hook)
Removed
Tests
Testing
Notes:
The hooks integrate into the existing oclif update lifecycle. The check-npm-auth hook runs before the update starts (preupdate), while check-plugin-health runs after plugin installation (update).
Steps:
heroku plugins:install @private/some-pluginnpm logoutheroku updateTo test plugin health check:
heroku updateUnit tests:
Related Issues