From e019ad4810418590ca02edf699209cc42d735a2f Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 10:17:08 +0000 Subject: [PATCH 01/12] add update_version as default field --- features/plugin.feature | 15 +++++++++------ src/Plugin_Command.php | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/features/plugin.feature b/features/plugin.feature index 26d923c3..8dcb1fc3 100644 --- a/features/plugin.feature +++ b/features/plugin.feature @@ -63,8 +63,8 @@ Feature: Manage WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | Zombieland | active | none | 0.1.0 | + | name | status | update | version | update_version | + | Zombieland | active | none | 0.1.0 | | When I try `wp plugin uninstall Zombieland` Then STDERR should be: @@ -131,8 +131,8 @@ Feature: Manage WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | wordpress-importer | active | available | 0.5 | + | name | status | update | version | update_version | + | wordpress-importer | active | available | 0.5 | {UPDATE_VERSION} | When I try `wp plugin update` Then STDERR should be: @@ -648,11 +648,14 @@ Feature: Manage WordPress plugins When I run `wp plugin list --name=hello-dolly --field=version` And save STDOUT as {PLUGIN_VERSION} + + When I run `wp plugin list --name=hello-dolly --field=update_version` + And save STDOUT as {UPDATE_VERSION} When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | hello-dolly | inactive | version higher than expected | {PLUGIN_VERSION} | + | name | status | update | version | update_version | + | hello-dolly | inactive | version higher than expected | {PLUGIN_VERSION} | {UPDATE_VERSION} | When I try `wp plugin update --all` Then STDERR should be: diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 7461b1fb..b108c151 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -52,6 +52,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade { 'status', 'update', 'version', + 'update_version', ); /** From 15b501c95d45ab8473178a683122f23b49649f39 Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 10:22:25 +0000 Subject: [PATCH 02/12] update plugin-update.feature tests --- features/plugin-update.feature | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/features/plugin-update.feature b/features/plugin-update.feature index 398629bb..09403fe3 100644 --- a/features/plugin-update.feature +++ b/features/plugin-update.feature @@ -13,8 +13,8 @@ Feature: Update WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | wordpress-importer | inactive | available | 0.5 | + | name | status | update | version | update_version | + | wordpress-importer | inactive | available | 0.5 | {UPDATE_VERSION} | When I try `wp plugin update akismet --version=0.5.3` Then STDERR should be: @@ -25,16 +25,16 @@ Feature: Update WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | wordpress-importer | inactive | available | 0.5 | + | name | status | update | version | update_version | + | wordpress-importer | inactive | available | 0.5 | {UPDATE_VERSION} | When I run `wp plugin update wordpress-importer` Then STDOUT should not be empty When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | wordpress-importer | inactive | none | {UPDATE_VERSION} | + | name | status | update | version | update_version | + | wordpress-importer | inactive | none | {UPDATE_VERSION} | | Scenario: Error when both --minor and --patch are provided Given a WP install From 253caf9f3c2e9170a7b1da9df65d71268bc8065e Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 10:50:30 +0000 Subject: [PATCH 03/12] fix upgradables.feature test for plugin command --- features/upgradables.feature | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/features/upgradables.feature b/features/upgradables.feature index d4445d47..8b8cede3 100644 --- a/features/upgradables.feature +++ b/features/upgradables.feature @@ -51,10 +51,14 @@ Feature: Manage WordPress themes and plugins "" """ + When I run `wp list --name= --field=update_version` + Then STDOUT should not be empty + And save STDOUT as {UPDATE_VERSION} + When I run `wp list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | | inactive | available | | + | name | status | update | version | update_version | + | | inactive | available | | {UPDATE_VERSION} | When I run `wp list --field=name` Then STDOUT should contain: From 364b768a053a651fc7a06d4677ded2460b536159 Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 10:55:45 +0000 Subject: [PATCH 04/12] add update_version field to theme command --- src/Theme_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Theme_Command.php b/src/Theme_Command.php index 225656b6..a1edeebf 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -49,7 +49,7 @@ class Theme_Command extends CommandWithUpgrade { protected $upgrade_refresh = 'wp_update_themes'; protected $upgrade_transient = 'update_themes'; - protected $obj_fields = [ 'name', 'status', 'update', 'version' ]; + protected $obj_fields = [ 'name', 'status', 'update', 'version', 'update_version' ]; public function __construct() { if ( is_multisite() ) { From d1f03b18f42033b7f4ba78b60b7cfbd87fbe3c97 Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 10:56:11 +0000 Subject: [PATCH 05/12] fix theme.feature tests to include the new field --- features/theme.feature | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/features/theme.feature b/features/theme.feature index 0c9235b9..ce6a0b1d 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -77,10 +77,14 @@ Feature: Manage WordPress themes When I run `wp theme install p2 --version=1.4.2` Then STDOUT should not be empty + When I run `wp theme list --name=p2 --field=update_version` + Then STDOUT should not be empty + And save STDOUT as {UPDATE_VERSION} + When I run `wp theme list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | p2 | inactive | available | 1.4.2 | + | name | status | update | version | update_version | + | p2 | inactive | available | 1.4.2 | {UPDATE_VERSION} | When I run `wp theme activate p2` Then STDOUT should not be empty @@ -97,8 +101,8 @@ Feature: Manage WordPress themes When I run `wp theme list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | p2 | active | available | 1.4.1 | + | name | status | update | version | update_version | + | p2 | inactive | available | 1.4.1 | {UPDATE_VERSION} | When I try `wp theme update` Then STDERR should be: From ad0b22fdb6896ebcdf43c53d6789cd80399d3f6b Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 11:04:58 +0000 Subject: [PATCH 06/12] fix theme test active state --- features/theme.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/theme.feature b/features/theme.feature index ce6a0b1d..4c48785f 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -84,7 +84,7 @@ Feature: Manage WordPress themes When I run `wp theme list` Then STDOUT should be a table containing rows: | name | status | update | version | update_version | - | p2 | inactive | available | 1.4.2 | {UPDATE_VERSION} | + | p2 | active | available | 1.4.2 | {UPDATE_VERSION} | When I run `wp theme activate p2` Then STDOUT should not be empty From bdf4cfa9f3ddb3bb506c9f07e55604cf6c9e1795 Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 11:06:53 +0000 Subject: [PATCH 07/12] fix theme test active state --- features/theme.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/theme.feature b/features/theme.feature index 4c48785f..7f9561f9 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -84,7 +84,7 @@ Feature: Manage WordPress themes When I run `wp theme list` Then STDOUT should be a table containing rows: | name | status | update | version | update_version | - | p2 | active | available | 1.4.2 | {UPDATE_VERSION} | + | p2 | inactive | available | 1.4.2 | {UPDATE_VERSION} | When I run `wp theme activate p2` Then STDOUT should not be empty @@ -102,7 +102,7 @@ Feature: Manage WordPress themes When I run `wp theme list` Then STDOUT should be a table containing rows: | name | status | update | version | update_version | - | p2 | inactive | available | 1.4.1 | {UPDATE_VERSION} | + | p2 | active | available | 1.4.1 | {UPDATE_VERSION} | When I try `wp theme update` Then STDERR should be: From 7fb9b9bdec5a4eb2eab98bfc73cc5d74028b93e6 Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 11:19:40 +0000 Subject: [PATCH 08/12] update docblock comments for each function --- src/Plugin_Command.php | 28 ++++++++++++++-------------- src/Theme_Command.php | 8 ++++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index b108c151..dac195b3 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -1176,10 +1176,10 @@ public function delete( $args, $assoc_args = array() ) { * * status * * update * * version + * * update_version * * These fields are optionally available: * - * * update_version * * update_package * * update_id * * title @@ -1192,22 +1192,22 @@ public function delete( $args, $assoc_args = array() ) { * * # List active plugins on the site. * $ wp plugin list --status=active --format=json - * [{"name":"dynamic-hostname","status":"active","update":"none","version":"0.4.2"},{"name":"tinymce-templates","status":"active","update":"none","version":"4.4.3"},{"name":"wp-multibyte-patch","status":"active","update":"none","version":"2.4"},{"name":"wp-total-hacks","status":"active","update":"none","version":"2.0.1"}] + * [{"name":"dynamic-hostname","status":"active","update":"none","version":"0.4.2","update_version": null},{"name":"tinymce-templates","status":"active","update":"none","version":"4.4.3","update_version": null},{"name":"wp-multibyte-patch","status":"active","update":"none","version":"2.4","update_version": null},{"name":"wp-total-hacks","status":"active","update":"none","version":"2.0.1","update_version": null}] * * # List plugins on each site in a network. * $ wp site list --field=url | xargs -I % wp plugin list --url=% - * +---------+----------------+--------+---------+ - * | name | status | update | version | - * +---------+----------------+--------+---------+ - * | akismet | active-network | none | 3.1.11 | - * | hello | inactive | none | 1.6 | - * +---------+----------------+--------+---------+ - * +---------+----------------+--------+---------+ - * | name | status | update | version | - * +---------+----------------+--------+---------+ - * | akismet | active-network | none | 3.1.11 | - * | hello | inactive | none | 1.6 | - * +---------+----------------+--------+---------+ + * +---------+----------------+--------+---------+----------------+ + * | name | status | update | version | update_version | + * +---------+----------------+--------+---------+----------------+ + * | akismet | active-network | none | 3.1.11 | | + * | hello | inactive | none | 1.6 | 1.7.2 | + * +---------+----------------+--------+---------+----------------+ + * +---------+----------------+--------+---------+----------------+ + * | name | status | update | version | update_version | + * +---------+----------------+--------+---------+----------------+ + * | akismet | active-network | none | 3.1.11 | | + * | hello | inactive | none | 1.6 | 1.7.2 | + * +---------+----------------+--------+---------+----------------+ * * @subcommand list */ diff --git a/src/Theme_Command.php b/src/Theme_Command.php index a1edeebf..4eb90e70 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -846,10 +846,10 @@ public function delete( $args, $assoc_args ) { * * status * * update * * version + * * update_version * * These fields are optionally available: * - * * update_version * * update_package * * update_id * * title @@ -860,9 +860,9 @@ public function delete( $args, $assoc_args ) { * * # List themes * $ wp theme list --status=inactive --format=csv - * name,status,update,version - * twentyfourteen,inactive,none,1.7 - * twentysixteen,inactive,available,1.1 + * name,status,update,version,update_version + * twentyfourteen,inactive,none,1.7, + * twentysixteen,inactive,available,1.1, * * @subcommand list */ From 1335956354f1658595e568ed2335e5f0517d01a4 Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 11:26:14 +0000 Subject: [PATCH 09/12] fix formatting --- features/plugin.feature | 4 ++-- features/theme.feature | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/plugin.feature b/features/plugin.feature index 8dcb1fc3..ff4d45c6 100644 --- a/features/plugin.feature +++ b/features/plugin.feature @@ -131,8 +131,8 @@ Feature: Manage WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | update_version | - | wordpress-importer | active | available | 0.5 | {UPDATE_VERSION} | + | name | status | update | version | update_version | + | wordpress-importer | active | available | 0.5 | {UPDATE_VERSION} | When I try `wp plugin update` Then STDERR should be: diff --git a/features/theme.feature b/features/theme.feature index 7f9561f9..f11c2d8e 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -101,8 +101,8 @@ Feature: Manage WordPress themes When I run `wp theme list` Then STDOUT should be a table containing rows: - | name | status | update | version | update_version | - | p2 | active | available | 1.4.1 | {UPDATE_VERSION} | + | name | status | update | version | update_version | + | p2 | active | available | 1.4.1 | {UPDATE_VERSION} | When I try `wp theme update` Then STDERR should be: From a03a8fe835c6cf9b28b74bdbca83011a79cd56f4 Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 11:36:54 +0000 Subject: [PATCH 10/12] remove new empty spaces fomatting on tests --- features/plugin-update.feature | 4 ++-- features/plugin.feature | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/plugin-update.feature b/features/plugin-update.feature index 09403fe3..071d0686 100644 --- a/features/plugin-update.feature +++ b/features/plugin-update.feature @@ -33,8 +33,8 @@ Feature: Update WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | update_version | - | wordpress-importer | inactive | none | {UPDATE_VERSION} | | + | name | status | update | version | update_version | + | wordpress-importer | inactive | none | {UPDATE_VERSION} | | Scenario: Error when both --minor and --patch are provided Given a WP install diff --git a/features/plugin.feature b/features/plugin.feature index ff4d45c6..63e98c48 100644 --- a/features/plugin.feature +++ b/features/plugin.feature @@ -131,8 +131,8 @@ Feature: Manage WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | update_version | - | wordpress-importer | active | available | 0.5 | {UPDATE_VERSION} | + | name | status | update | version | update_version | + | wordpress-importer | active | available | 0.5 | {UPDATE_VERSION} | When I try `wp plugin update` Then STDERR should be: From 9749bd2a293c12609ef4df95741453438e9029d1 Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 11:52:00 +0000 Subject: [PATCH 11/12] set update_version empty string instead of null --- src/WP_CLI/CommandWithUpgrade.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index d345a1e7..53c45df7 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -511,6 +511,10 @@ protected function _list( $_, $assoc_args ) { $item['version'] = ''; } + if ( empty( $item['update_version'] ) ) { + $item['update_version'] = ''; + } + foreach ( $item as $field => &$value ) { if ( 'update' === $field ) { if ( true === $value ) { From e12aac390d38e27470a769dcbe82020f980e74ba Mon Sep 17 00:00:00 2001 From: sejas Date: Fri, 10 Nov 2023 11:54:22 +0000 Subject: [PATCH 12/12] fix example of update_version json format --- src/Plugin_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 52bb544d..00233cc3 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -1193,7 +1193,7 @@ public function delete( $args, $assoc_args = array() ) { * * # List active plugins on the site. * $ wp plugin list --status=active --format=json - * [{"name":"dynamic-hostname","status":"active","update":"none","version":"0.4.2","update_version": null},{"name":"tinymce-templates","status":"active","update":"none","version":"4.4.3","update_version": null},{"name":"wp-multibyte-patch","status":"active","update":"none","version":"2.4","update_version": null},{"name":"wp-total-hacks","status":"active","update":"none","version":"2.0.1","update_version": null}] + * [{"name":"dynamic-hostname","status":"active","update":"none","version":"0.4.2","update_version": ""},{"name":"tinymce-templates","status":"active","update":"none","version":"4.4.3","update_version": ""},{"name":"wp-multibyte-patch","status":"active","update":"none","version":"2.4","update_version": ""},{"name":"wp-total-hacks","status":"active","update":"none","version":"2.0.1","update_version": ""}] * * # List plugins on each site in a network. * $ wp site list --field=url | xargs -I % wp plugin list --url=%