wp-cli / extension-command

Manages plugins and themes, including installs, activations, and updates.
MIT License
87 stars 82 forks source link

Possibility to check-updates for plugins, themes and languages #384

Open MoBlockbuster opened 8 months ago

MoBlockbuster commented 8 months ago

I think it would be very helpful if there is a possibility to check if updates exist. Thes feature is already implemented for the wp core:

https://developer.wordpress.org/cli/commands/core/check-update/

But there is no such a feature for plugins, themes and languagepacks.

Plugin parameter overview:

https://developer.wordpress.org/cli/commands/plugin/

Theme parameter overview:

https://developer.wordpress.org/cli/commands/theme/

Langauge parameter overview:

https://developer.wordpress.org/cli/commands/language/core/ https://developer.wordpress.org/cli/commands/language/plugin/ https://developer.wordpress.org/cli/commands/language/theme/

It would be also nice, if the check-update parameter provide returncodes. Example:

wp plugin check-update -> no updates -> returncode = 0

wp core check-update -> update available -> returncode = 1

wp theme check-update -> unknown error -> returncode = 2

Thanks and Cheers

danielbachhuber commented 8 months ago

Thanks for the suggestion, @MoBlockbuster !

I'm amenable to creating parity with wp core check-update. We'll want to follow its behavior, though:

$ wp core check-update
Success: WordPress is at the latest version.
$ echo $?
0
$ wp core check-update
+---------+-------------+-----------------------------------------------------------------------+
| version | update_type | package_url                                                           |
+---------+-------------+-----------------------------------------------------------------------+
| 6.1.4   | minor       | https://downloads.wordpress.org/release/wordpress-6.1.4-partial-0.zip |
| 6.4.1   | major       | https://downloads.wordpress.org/release/wordpress-6.4.1.zip           |
+---------+-------------+-----------------------------------------------------------------------+
$ echo $?
0

Notably, the return code is always 0, even when there are updates available.

MoBlockbuster commented 8 months ago

Hi @danielbachhuber, I assume the check-update parameter is a huge advance for the wp-cli community.

The returncodes are helpful for the check-condition to check if there is an update befor a real update run. But I think we can parse the wp-cli output and define if an update is found or not.

Thanks for your support

mrsdizzie commented 8 months ago

If you want to se if there are any plugin or theme updates (as in your example) this currently works and provides sort of similar information:

wp plugin list --update=available
wp theme list --update=available

I'm not familiar with languages but I think it works similarly: wp language plugin list --all --update=available

I don't know if plugins can provide details on if something is a patch or major update since they all probably use different versioning.