-
Notifications
You must be signed in to change notification settings - Fork 20
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
Skip plugins and themes in internal Studio wp-cli commands like import export #748
Conversation
…ide a Studio site
src/site-server.ts
Outdated
if ( ! includePlugins ) { | ||
wpCliArgs.push( '--skip-plugins' ); | ||
} | ||
|
||
if ( ! includeThemes ) { | ||
wpCliArgs.push( '--skip-themes' ); | ||
} |
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'm adding some parameters in case we can include the plugins when executing some specific wp-cli command, but maybe we could avoid those parameters and directly add the arguments:
wpCliArgs.push( '--skip-plugins' );
wpCliArgs.push( '--skip-themes' );
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 also thought in adding this arguments at execute-wp-cli
level, but that way we would adding the arguments also when we execute wp-cli from the CLI.
], ${ phpVar( args ) }); |
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.
It fixes the issue with the plugin that was leaking PHP warnings to WP CLI commands output.
The only part I'm not convinced of is the default value. The executeWpCliCommand
is a general purpose command, and it may be not clear that it skips plugins or themes internally.
I think it would be clearer if we changed includePlugins
to skipPlugins
and explicitly set it in all places which need to skip plugins. It would be also aligned with the WP CLI implementation.
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 also thought in adding this arguments at execute-wp-cli level, but that way we would adding the arguments also when we execute wp-cli from the CLI.
Could you elaborate on this, @sejas?
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 think it would be clearer if we changed includePlugins to skipPlugins and explicitly set it in all places which need to skip plugins. It would be also aligned with the WP CLI implementation.
Agreed! More often than not, magical code behavior produces more headaches.
I’ve inverted the conditions and added the flag where it’s needed (export, import, etc.).
3e99a7f
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 also thought in adding this arguments at execute-wp-cli level, but that way we would adding the arguments also when we execute wp-cli from the CLI.
Could you elaborate on this, @sejas?
@fredrikekelund , my comment wants to highlight that server.executeWpCliCommand
is the right place to add this parameter. Another option would be adding the parameter down to the [execute-wp-cli.ts
](
], ${ phpVar( args ) }); |
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.
Thanks for the change @sejas , looks 100% clear now.
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.
Nice initiative 👍 I agree this makes sense as a default for our hard-coded CLI calls.
The only issue I see with this is executeWPCLiInline
(funny function name with that lowercase i
, btw). I'm not sure which commands the Assistant can potentially suggests, but since it seems much more open ended compared to our hard-coded CLI calls, I might be inclined to not skip plugins and themes in that context.
Any thoughts, @sejas?
src/site-server.ts
Outdated
includePlugins, | ||
includeThemes, |
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.
includePlugins, | |
includeThemes, | |
includePlugins = false, | |
includeThemes = false, |
Nit, but I think this clarifies intent
src/site-server.ts
Outdated
if ( ! includePlugins ) { | ||
wpCliArgs.push( '--skip-plugins' ); | ||
} | ||
|
||
if ( ! includeThemes ) { | ||
wpCliArgs.push( '--skip-themes' ); | ||
} |
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 also thought in adding this arguments at execute-wp-cli level, but that way we would adding the arguments also when we execute wp-cli from the CLI.
Could you elaborate on this, @sejas?
src/hooks/use-chat-context.tsx
Outdated
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.
Per my previous review, this is the only place I would consider not skipping plugins and themes. Do we know all the commands Assistant might suggest, and are we sure that the output of those commands couldn't be meaningfully affected by plugins or themes..?
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.
@fredrikekelund Sure!, I totally agree with you, and the assistant should execute wp-cli command without any flag. Full experience. Skipping themes and plugins was my mistake in the first place.
Now we are skipping plugins and themes for Studio internal commands by passing skipPluginsAndThemes: true
, and not including any flag for commands executed by the assistant.
I've added a skipPluginsAndThemes: false,
to be more specific, but I can remove it if you think it adds confusion.
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.
My bad for not looking closer at the code first 🙌 I see now that this code isn't for "general purpose" WP-CLI commands.
@wojtekn , @fredrikekelund , I would appreciate another review 🙏 . |
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.
LGTM and works as expected 👍
…-plugins-themes-from-wpcli
Related issues
after_wp_load
wp-cli-sqlite-command#7 (comment)Proposed Changes
Testing Instructions
npm start
wp plugin install slider-revolution-search-replace --activate
--skip-plugins
and--skip-themes
are not present--skip-plugins
and--skip-themes
are added to each wp-cli command to export, get site url, etc.Pre-merge Checklist