-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: correctly load legacy plugins #713
Conversation
private insertLegacyPlugins(plugins: IPlugin[]) { | ||
for (const plugin of plugins) { | ||
const idx = this.plugins.findIndex(p => p.name === plugin.name) | ||
if (idx !== -1) this.plugins = this.plugins.splice(idx, 1, plugin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array.splice
mutates the array and returns an array of deleted items in this case, see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice#return_value
so, this.plugins
was set to the non-compatible version of the plugin loaded here:
Line 193 in a2efc04
await this.loadPluginsAndCommands() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find, thank you!
QA Notes
modify
instead of
and then run
verified some other plugin commands
vs
couldn't find any other |
This PR fixes an issue where CLIs that includes
@oclif/plugin-legacy
and at least one old, invalid plugin would get legacy plugins as the only ones installed.left: ci-v5 plugin installed, shows as the only plugin (
--core
should show core plugins too),plugins:inspect webhooks
fails even though@heroku-cli/plugin-webhooks
is a core plugin.right: with oclif fix,
plugins:inspect
is able to find it.plugin-legacy init hook where invalid, legacy plugins are converted:
https://github.com/oclif/plugin-legacy/blob/main/src/hooks/init.ts
Repro
npm i -g heroku
heroku plugins --core
, this only returnsaddons-v5 8.1.7 (core)
because it's the first invalid plugin found.heroku plugins --core
again, should get all core plugins.[skip-validate-pr]