Closed eliot-akira closed 6 months ago
When you run wp plugin install plugin-check
, it will fetch Plugin Check
from the directory and that version does not have CLI. That is the legacy version of the plugin. You need to use from GitHub.
Wonderful! Thank you for an instant response. I'll try that to confirm, and will come back to close this issue.
Success. I suppose there are various ways to set this up. At first I tried to install plugin-check
as a Composer dependency (require-dev
) in the plugin I'm testing, but I couldn't figure out how to activate it as a plugin from inside the vendor
folder.
For now I solved it by installing it in the same folder as the plugin:
git clone --depth 1 --single-branch --branch trunk https://github.com/WordPress/plugin-check
cd plugin-check
composer install
Then updated .wp-env.json
in the plugin being tested:
{
"core": "WordPress/WordPress",
"phpVersion": "8.2",
"plugins": [".", "../plugin-check"]
}
Now wp help plugin
shows check
in the list of available commands. And wp plugin check
works.
I'll continue exploring different setups to see how to integrate plugin-check
in the automated build/lint/test workflow of the plugin.
@ernilambar Thanks very much. :)
Just to follow up, it was simple enough to install plugin-check
as a Composer dependency. In case it might be useful to others, here's how I solved it.
In composer.json
of the plugin being tested:
{
"name": "example-plugin",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/WordPress/plugin-check"
}
],
"require-dev": {
"wordpress/plugin-check": "dev-trunk"
}
}
And .wp-env.json
.
{
"core": "WordPress/WordPress",
"phpVersion": "8.2",
"plugins": [
".",
"./vendor/wordpress/plugin-check"
]
}
For convenience, I added an NPM script in package.json
. I figured it's best to run it in tests-cli
environment.
{
"scripts": {
"check": "wp-env run tests-cli wp plugin check example-plugin"
}
}
Now I can run it regularly with npm run check
. Lovely! :sparkles:
I'm having difficulty running
wp plugin check
when using it withwp-env
.In an existing project, I installed the plugin.
Running it against another installed plugin:
Listing available commands,
plugin check
is not there.It seems like a compatibility issue with
wp-env
, that something more than plugin activation is necessary to register the WP-CLI command. I'll try with an empty project, and see if I can find any clue to solve it.