wp-cli / extension-command

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

Add `update_version` to the default fields for `plugin` and `theme` commands #380

Closed sejas closed 8 months ago

sejas commented 8 months ago

Description

I'm adding the field update_version as a default field for plugin and theme commands. If no update_version is available we return an empty string following the same pattern as version itself.

Now wp plugin list and wp theme list display a table similar to:

+------------+----------+--------+---------+----------------+-------------+
| name       | status   | update | version | update_version | auto_update |
+------------+----------+--------+---------+----------------+-------------+
| akismet    | inactive | none   | 5.3     |                | off         |
| hello      | inactive | none   | 1.7.2   |                | off         |
| Zombieland | inactive | none   | 0.1.0   |                | off         |
| no-mail    | must-use | none   |         |                | off         |
| polyfills  | must-use | none   |         |                | off         |
+------------+----------+--------+---------+----------------+-------------+
+-------------------+----------+--------+---------+----------------+-------------+
| name              | status   | update | version | update_version | auto_update |
+-------------------+----------+--------+---------+----------------+-------------+
| twentytwentyfour  | active   | none   | 1.0     |                | off         |
| twentytwentythree | inactive | none   | 1.3     |                | off         |
| twentytwentytwo   | inactive | none   | 1.6     |                | off         |
+-------------------+----------+--------+---------+----------------+-------------+

Testing instructions

  1. Run composer behat -- features/plugin-update.feature
  2. Run composer behat -- features/plugin.feature
  3. Run composer behat -- features/upgradables.feature
  4. Run composer behat -- features/theme.feature
  5. Observe the tests pass
sejas commented 8 months ago

Thanks for the quick review! I fixed the alignment issues (https://github.com/wp-cli/extension-command/pull/380/commits/1335956354f1658595e568ed2335e5f0517d01a4). I also updated some comments on the functions. (https://github.com/wp-cli/extension-command/pull/380/commits/7fb9b9bdec5a4eb2eab98bfc73cc5d74028b93e6)

And I realized that the json format is returning null instead of an empty string. Is that something I need to change? I would appreciate where that part of the code lives.

wp plugin list --format=json

[
    {"name":"akismet","status":"active","update":"none","version":"5.3","update_version":null}
    ,{"name":"hello","status":"inactive","update":"none","version":"1.7.2","update_version":null}
    ,{"name":"Zombieland","status":"inactive","update":"none","version":"0.1.0","update_version":null}
    ,{"name":"no-mail","status":"must-use","update":"none","version":"","update_version":null}
    ,{"name":"polyfills","status":"must-use","update":"none","version":"","update_version":null}
]

The table, and csv format are working correctly returning an empty string.

I'll also solve the merging conflicts.

sejas commented 8 months ago

And I realized that the json format is returning null instead of an empty string. Is that something I need to change? I would appreciate where that part of the code lives.

I found it: https://github.com/wp-cli/extension-command/pull/380/commits/9749bd2a293c12609ef4df95741453438e9029d1