wp-cli / extension-command

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

Add support GitHub releases/latest on installation #386

Closed BogdanUngureanu closed 2 months ago

BogdanUngureanu commented 8 months ago

Related to https://github.com/wp-cli/extension-command/issues/91

This PR adds support for installing plugins and themes from GitHub using the release/latest URLs.

In order to get the latest release assets, I'm proposing to use the GitHub public API to extract the latest version of the plugin/theme from GH releases. If there's no asset defined, we will fall back to the source code zip file.

While the implementation works right now, I haven't added support for GitHub's API request limits. Currently, after 60 requests per hour, the user is required to use an access token in order to make an API request. However, this PR doesn't expose a way to pass that token to the request.

UPDATE: I've introduced a new environment variable called _GITHUBTOKEN.

swissspidy commented 8 months ago
  • Pass a new optional GitHub access token as a flag on the command.

I'd use an environment variable instead, e.g. getenv( 'GITHUB_TOKEN' )

BogdanUngureanu commented 8 months ago

Hey @swissspidy, that's a great idea! I've updated the PR to contain the environment variable you proposed. Thanks!

swissspidy commented 2 months ago

Closing in favor of #421