fix: use internal npm for pkg checks #595
Merged
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.
When installing a plugin using an "unfriendly" plugin name,
plugins install
needs to call npm to verify that the pkg exists in the registry. Until now it's been doing that by executingnpm show <pkg-name> dist-tags
, which works fine unless you don't havenpm
installed globally on your system.This PR updates this check to use the
npm
version pinned in and shipped withplugin-plugins
, this way the user doesn't need to install npm and also helps avoid weird issues if a user has an old npm version or a new breaking change is released.Testing notes:
plugins link .
)Suggestion
set
DEBUG='@oclif/plugins'
when testing to see additional debug output.Possible scenarios
Install CLI via mac/win installer or tarballs
Installers/tarballs include a node executable and
plugins install <unfriendly-name
will perform the call to the pinned npm version inplugin-plugins/package.json
using the include node binary.Install CLI via npm (so user has node installed)
plugins install <unfriendly-name>
will use the global node binary to call the pinned npm version inplugin-plugins/package.json
It doesn't matter if the user has
npm
installed globally,plugin-plugins
should always use the pinned version included by the plugin.What's an "unfriendly" pkg name?
If you define an npm pkg scope in your CLI (
pjson.oclif.scope
), you can use a shorter name when installing plugins published under that scope.https://github.com/oclif/plugin-plugins/blob/main/src/plugins.ts#L258
Example:
The Salesforce CLI defines
salesforce
as an npm scope here:https://github.com/salesforcecli/sfdx-cli/blob/main/package.json#L27
To install
@salesforce/plugin-data
you can run:sfdx plugins install data
and plugin-plugins resolves the plugin name.@W-13018874@