-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: add plugins:post
* hooks
#932
Conversation
await pluginInstance.load() | ||
this.config.plugins.set(pluginInstance.name, pluginInstance) | ||
|
||
await this.config.runHook('plugins:postinstall', {}) |
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.
plugin-autocomplete needs config.plugins
with the new plugin populated for it to be included in the refreshed autocomplete files:
https://github.com/oclif/plugin-autocomplete/blob/986c6ec238ff3764c78331de7ea7b49e0670a47c/src/commands/autocomplete/create.ts#L95
|
||
for (const p of pluginNameToDelete) { | ||
this.config.plugins.delete(p) | ||
} |
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.
I know we do the same here:
https://github.com/oclif/core/blob/213e9203fd7f0f5aaffdcc9eb28d2828f7679373/src/config/config.ts#L475
but for the autocomplete refresh-hook use-case it doesn't work because the hook runs before oclif/core calls plugins.delete
:
example with some logs to show order of execution
➜ plugin-plugins git:(cd/post-hooks) ✗ sf plugins uninstall @cristiand391/sf-plugin-fzf-cmp && unfunction _sf && autoload -U _sf
› Warning: @oclif/plugin-autocomplete is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.
› Warning: @oclif/plugin-plugins is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.
@salesforce/cli: Uninstalling @cristiand391/sf-plugin-fzf-cmp... done
running plugins:postuninstall hook
› Warning: @oclif/plugin-autocomplete is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.
done plugins:postuninstall hook
called `plugins.delete` from oclif/core
maybe we can remove the plugins.delete
logic from oclif/core safely?
it was added here to avoid running postrun hooks from uninstalled plugins:
oclif/core#805
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.
Yeah I think we can safely remove that once this is merged
This PR adds 2 new hooks:
plugins:postinstall
: runs afterplugins install
plugins:postuninstall
: runs afterplugins uninstall
Added for the autocomplete refresh-cache hook:
oclif/plugin-autocomplete#753
See QA steps on the linked PR ⬆️
@W-12465784@