Skip to content

Conversation

@vishalkakadiya
Copy link

Add Plugin_Check_Command class

Closes #30

@vishalkakadiya vishalkakadiya marked this pull request as draft February 7, 2023 10:40
@vishalkakadiya vishalkakadiya changed the title Add Plugin_Check_Command class WIP: Add Plugin_Check_Command class Feb 7, 2023
@vishalkakadiya vishalkakadiya marked this pull request as ready for review February 24, 2023 13:03
@vishalkakadiya
Copy link
Author

@felixarntz @jjgrainger The unit tests are not yet completed, but the command's class is a bit large, so that you can review the CLI command code. I will complete the unit test for this soon. Thank you! 🙂

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vishalkakadiya Left some feedback. Overall this looks solid.

There are a few things that we need to reconsider and discuss outside of this PR, e.g. how to better handle setup of the runner classes. But we can address that in a separate follow up PR later once we have figured out the approach.

@vishalkakadiya vishalkakadiya changed the title WIP: Add Plugin_Check_Command class Add Plugin_Check_Command class Feb 26, 2023
Copy link
Contributor

@jjgrainger jjgrainger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vishalkakadiya a couple of small changes here but there is 1 part of this work I want to discuss with @felixarntz on next steps too.

Copy link
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion, otherwise this is looking pretty good.

@vishalkakadiya
Copy link
Author

@joemcgill I have addressed your feedback on this PR and left one comment. You can review it now, thanks!

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjgrainger This is almost good to go, there are just a few critical things missing around the runner setup, which we recently prepared for via #95.

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jjgrainger, I left some minor update feedback, one of which related to the option in the command not working.

/**
* Run plugin check.
*
* ## OPTIONS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjgrainger Is the options argument working for you? or will it be in an upcoming PR?

npm run wp-env run cli wp plugin check akismet --format=json it give me an error Error: Too many positional arguments: json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mukeshpanchal27 I experienced the same issue here but am uncertain what the cause is. I noticed that the docblock comment for the command wasn't correct for these options, however updating these has not resolved the issue. I'll keep looking into this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're invoking WP-CLI in the container, I think you're missing an extra --. You need to use npm run wp-env run cli -- wp plugin check akismet --format=json

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjgrainger One more thing here, and one nit-pick, but should be quick to address. I'll give this my approval already since the tweaks should be trivial. Excited to see this shape!

Comment on lines 111 to 112
$runner->set_plugin( $plugin );
$runner->set_check_slugs( $checks );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These calls need to happen unconditionally, even if you're using the runner returned by Plugin_Request_Utility::get_runner. That is the entire reason why we implemented the validation in Abstract_Check_Runner.

$checks = wp_parse_list( $options['checks'] );

// Get the CLI Runner.
$runner = Plugin_Request_Utility::get_runner();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit-pick: Not sure if this can realistically ever happen, but we should probably cater for it just in case: If this returns any object that is not a CLI_Runner, we should error out. For example, imagine something goes wrong in the object-cache.php invoked logic and then somehow this returns an AJAX_Runner here. Extremely unlikely, but possible based on the method implementation, so we may want to cater for that.

Copy link
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with the current iteration once @felixarntz's comments have been addressed.

@jjgrainger
Copy link
Contributor

Thanks all, I've updated the PR based on the latest feedback. Will merge this now

@jjgrainger jjgrainger merged commit 11307cf into trunk Mar 13, 2023
@jjgrainger jjgrainger deleted the feature/add-wp-plugin-check-command branch March 13, 2023 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create the WP-CLI subcommand wp plugin check

7 participants