Skip to content

Comments

Add WP-CLI support#277

Merged
costdev merged 10 commits intofairpm:mainfrom
costdev:add_wp_cli_support
Oct 4, 2025
Merged

Add WP-CLI support#277
costdev merged 10 commits intofairpm:mainfrom
costdev:add_wp_cli_support

Conversation

@costdev
Copy link
Member

@costdev costdev commented Sep 29, 2025

This PR adds support for the following wp plugin <subcommand> <did> commands.

Currently supported commands

The following commands are supported:

wp plugin activate <did>
wp plugin deactivate <did>
wp plugin delete <did>
wp plugin get <did>
wp plugin install <did>
wp plugin is-active <did>
wp plugin path <did>
wp plugin search <did>
wp plugin status <did>
wp plugin toggle <did>
wp plugin uninstall <did>
wp plugin update <did>

For those commands which support multiple values, a mixture of DIDs and slugs (for non-FAIR plugins) is also supported by this PR.

Currently NOT supported commands

The following commands are not currently supported:

wp plugin verify-checksums <did>

This relies on the wordpress.org API, and each file in a package has its own checksum which isn't part of the FAIR protocol.

Additional changes

The PR also includes refactoring some of the plugin to facilitate WP-CLI support:

  • How a DID for install is cached: Previously, the DID was cached in the AJAX installation handler. This meant that only one DID could be cached, even during a bulk install (such as via WP-CLI). Now, the DID is cached when its artifact's URL matches the package currently being passed for installation. Additionally, the cached DID is cleared after the package has been installed to prevent contamination.
  • Signature verification functions: Previously, signature verification was only applied in the Updater class, whose setup is somewhat tightly coupled to installing in an admin context. Now, signature verification has been moved to general functions so that it can be used in various contexts.
  • Search by DID: This has been moved from the Packages\Admin namespace to the Packages namespace, as this is now used in more than just the admin context.

Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Previously, the DID was cached in the AJAX installation handler. This meant that only one DID could be cached, even during a bulk install (such as via WP-CLI).

Now, the DID is cached when its artifact's URL matches the package currently being passed for installation. Additionally, the cached DID is cleared after the package has been installed to prevent contamination.

Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Previously, signature verification was only applied in the Updater class, whose setup is somewhat tightly coupled to installing in an admin context.

Now, signature verification has been moved to general functions so that it can be used in various contexts.

Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
This excludes `verify-checksums` because:
1. This currently depends on the WordPress.org API.
2. Each file in a plugin or theme has its own checksum, which is not part of the FAIR protocol.

Future support remains uncertain.

Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Repeated testing showed failures to rename the downloaded package correctly. This occurred at times for a package whether it used a release asset or not. While the exact cause hasn't been determined yet, bumping the priority resolved the issue.

Re-testing with the previous priority of 10, and possible investigation to find the cause, is welcome.

Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
@costdev
Copy link
Member Author

costdev commented Sep 29, 2025

Some DIDs to test with:

  • Git Updater: did:plc:afjf7gsjzsqmgc7dlhb553mv
  • Handbook Callout Blocks: did:plc:deoui6ztyx6paqajconl67rz
  • Pods: did:plc:e3rm6t7cspgpzaf47kn3nnsl

Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
@costdev costdev merged commit abd2cee into fairpm:main Oct 4, 2025
46 checks passed
@costdev costdev deleted the add_wp_cli_support branch October 4, 2025 20:20
@costdev costdev linked an issue Oct 6, 2025 that may be closed by this pull request
@Ipstenu Ipstenu added this to the 1.1 milestone Oct 27, 2025
@swissspidy
Copy link

@costdev If there's anything we could improve on the WP-CLI side to make this more seamless, please let me know :-)

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.

Plugin installation via WP-CLI using DID

4 participants