Could you add new commands to wp-cli for install remote plugins and themes?
https://github.com/wp-cli/wp-cli/wiki/Commands-Cookbook
https://github.com/wp-cli/wp-cli/wiki/List-of-community-commands
https://github.com/wp-plugins/ewww-image-optimizer/blob/master/iocli.php
I've never used WP-CLI, thanks for the references. I will definitely consider this a feature request.
Do you know EasyEngine? ;-)
I didn't until now. :wink:
@JosefJezek please remember I'm really just a trauma surgeon. I am primarily self taught and honestly adding CLI support seems a bit daunting for me at the moment. A PR would be most appreciated. If it could be rolled into it's own class that would probably be easiest for me to understand.
That said, I think it's a great idea and certainly one that deserves inclusion.
adding CLI support seems a bit
May I help? I'm a wp-cli contributor.
What should the new command exactly do?
It possible now to
wp theme install http://s3.amazonaws.com/bucketname/my-theme.zip
@szepeviktor I would greatly appreciate it.
Could you describe what is the goal here?
Could you add new commands to wp-cli for install remote plugins and themes?
These are already covered, see my comment above.
Add support for install themes and plugins from private repo. I have private repo on GitLab.com
@szepeviktor When trying to upgrade plugins through wp plugin upgrade --all, GitHub plugins are not upgraded.
Strange, wp-cli uses upgrader class from core.
@afragen Could you look at these three files?
https://github.com/wp-cli/wp-cli/search?utf8=%E2%9C%93&q=CoreUpgrader
@sheabunge What wp plugin update PLUGINNAME outputs?
Actually upgrade is really update, but that causes no problems.
Unfortunately I have no experience with wp-cli and while I'm open to a PR, I'm not sure I can add this feature on my own.
@afragen OK.
@sheabunge Please also share wp plugin list before the update attempt.
@afragen Maybe this hardcoded JSON request fails towards GitHub.
https://github.com/wp-cli/wp-cli/blob/b2a39f33648c4aa32b96afea01f76fdadad14a6f/php/WP_CLI/CoreUpgrader.php#L54-L62
This is the original core function:
https://github.com/WordPress/WordPress/blob/092478579acbfce748f2c50277b4a0b9ec6f999b/wp-admin/includes/class-wp-upgrader.php#L213-L254
We don't hook into download_package So I'm sure what to do here.
_site_transient_update_plugins when on WP admin
http://www.unserialize.com/s/5f8ea0b2-e7b6-87a9-b2ba-000069c52602
after wp plugin list
http://www.unserialize.com/s/5d1d21fe-5103-d1c8-4b1f-00004afb0094
I can confirm that forced_meta_update_plugins does not get called in wp plugin list but does on WP admin.
Using this plugin, github-updater:
Running wp plugin update --all updates other plugins, but ignores github-updater.
Running wp plugin update github-updater returns Success: Updated 0/0 plugins.
Running wp plugin list returns | github-updater | active | none | 5.1.2.4 |
among the results.
I can confirm that forced_meta_update_plugins does not get called in
wp plugin listbut does on WP admin.
If there's a solution, a PR would be great.
What's the latest on this one?
I was really hoping to get a PR for this. I don't use WP-CLI so not the easiest thing for me to implement without help.
Really love to see these two awesome projects get along with each other.
I don't exactly know how Github-Updater manages it's plugins/themes internally but I think WP-CLI is mostly using standard WordPress practices. So we have to find out why it isn't noticing the remote plugins. Does anyone have a idea?
I think WP-CLI is mostly using standard WordPress practices
I would say always
GitHub Updater also uses standard WordPress core practices. I just had an idea and in the next few days hopefully I'll be able to see if it works. As I've previously said, I really haven't used WP-CLI so I have some learning to do.
OK, finally figured some stuff out. Everything in branch wp-cli.
To use wp github-updater plugin and then use any wp plugin command.
Also, wp github-updater theme and then use any wp theme command.
Both commands really need docBlocks and such. The next thing to work on would be plugin and theme installation.
Feedback and PRs appreciated.
So, I think I've actually gotten everything working.
Install is wp github-updater install $type $uri where $type is 'plugin' or 'theme' and $uri is the full URL to the repo.
I could use some help with the docBlocks for WP-CLI compatibility so the proper info shows up.
I think I figured out the docBlocks. Please test and let me know what you think.
Please refer to wp help github-updater init and wp help github-updater install for proper syntax.
I've switched the wp github-updater plugin and wp github-updater theme commands to
wp github-updater init <type>
<type> is plugins or themes.
Thanks for your work Andy! I'll be happy to test it next week.
Make sure you reinstall the branch if you have already switched as I fix some bugs where GHU options were wiped during an wp-cli install.
As a wp-cli contributor, please take a look at wp-cli commands and subcommand.
wp github-updater init <type> could be wp theme install-ghu <theme name> and wp plugin install-ghu <plugin name> to conform built-in commands.
Thank you.
and wp theme init-ghu and wp plugin init-ghu
How do I add a subcommand to a standard wp-cli command?
public function __invoke( $_, $assoc_args ) {
}
WP_CLI::add_command( 'cli check-update', 'WP_CLI_Check_Update' );
See https://github.com/szepeviktor/wp-cli-check-update/blob/master/wp-cli-check-update.php
@szepeviktor how do I send parameters to WP_CLI::add_command
I would like to send the $type as array( 'plugin' ) have the $uri as an option.
WP_CLI::add_command( 'plugin install-github-updater', array( $ghu_cli, 'install') );
so I don't need to split this up into 2 functions.
so I don't need to split this up into 2 functions.
Two wrapper functions are the preferred way.
WP-CLI supports two ways of registering optional arguments for your command: through the callable鈥檚 PHPDoc, or passed as a third $args parameter to WP_CLI::add_command().
Please choose the PHPDoc way. It is much cleaner.
Can you provide a code example for passing a single $args parameter to a function in WP_CLI::add_command() along with passing an option?
http://wp-cli.org/docs/commands-cookbook/#wpcliaddcommands-third-args-parameter
Oh I see!
You would like to mix GHU functions with wp-cli functions.
Please consider writing tiny wrapper functions for wp-cli.
Please consider tiny wrapper functions for wp-cli.
Not sure I understand what you mean here.
I think you would like to call an existing GHU function without writing a wrapper for each wp-cli command
I just split the function in two. Simpler.
What do you think about subcommand names init-github-updater and install-github-updater or should we do github-updater-init and github-updater-install. The benefit of the second is that the subcommands sort adjacently when looking at wp help plugin.
github-updater-* has that benefit.
So here's the current state.
wp plugin github-updater-init
wp plugin github-updater-install <uri> [--field=<access_token>] [--bitbucket_private=<private>]
wp theme github-updater-init
wp theme github-updater-install <uri> [--field=<access_token>] [--bitbucket_private=<private>]
When testing please make sure the wp help ... is correct.
wp help plugin github-updater-init
wp help plugin github-updater-install
wp help theme github-updater-init
wp help theme github-updater-install
There are optional parameters for installing private repos. Please see help for syntax.
This is now merged into develop. Please test from there.
Added better error messaging.
Any feedback?
Sorry Andy, couldn't find any time yet. I'll definitely let you know my findings when I do some testing.
I just added the github-updater-init code into a constructor so that wp plugin list should always be correct. Initially it may take some time if the transients need to be updated.
So only commands are
wp plugin github-updater-install and wp theme github-updater-install
All other wp plugin update <slug> commands should just work.
I split out the wp-cli commands for integrating with wp plugin and wp theme into it's own class and added a class to interact with GitHub Updater. So far there are commands to delete the cache and reset the REST API key.
Anything else worthwhile to add for interacting with the actual plugin? Most of the other stuff really doesn't interact with wp-cli.
This also means some of the command syntax has changed. Always refer to the wiki for current info.
@szepeviktor any more feedback?
No. Your implementation seems complete.
I have to admit again, I am not a GHU user. I do wp plugin install https://github.com......
@szepeviktor when you do wp plugin install https://github.com... isn't the directory named as <user>-<slug>-<hash|branch>?
If you use wp plugin github-updater-install https://github.com... the directory should be renamed correctly.
isn't the directory named as
- - ?
$ wp plugin install https://github.com/afragen/github-updater/archive/develop.zip
...
Renamed Github-based project from 'github-updater-develop' to 'github-updater'.
...
It is a WP-CLI feature.
It is a WP-CLI feature.
I was proposing it.
So it works for GitHub?
How about Bitbucket and GitLab?
What about private repos?
Is there an issue for your proposal?
Is there an issue for your proposal?
As you may see from the above output it is implemented in WP-CLI.
This functionality is enough for me.
I found the merge https://github.com/wp-cli/wp-cli/pull/3314
This functionality is enough for me.
Actually I disable WP core's auto update functionality. I am a wp-cli user. I update plugins using a command line tool.
See my Mu plugin https://github.com/szepeviktor/wordpress-plugin-construction/blob/master/mu-disable-updates/disable-updates.php
Thanks @szepeviktor. I'll have to add GHU to the community plugins page.
This functionality is enough for me.
Actually I disable WP core's update functionality. I am a wp-cli user. I update plugins using a command line tool.
In that case, adding GHU should seamlessly update those plugins/themes using the same commands you're used to using. 馃槈
OK-OK!
I would use such a solution if
Maybe I am wrong but I think GHU's features could be deeply integrated into core's hooks. Please don't take it as an offense.
Maybe I should have written that. I am no-click&type guy. git pull is a lean way of updating a repo.
No offense taken. I'd like as many people as possible to utilize GHU's feature-set.
GHU's WP-CLI implementation certainly installs plugins/themes from GitHub, Bitbucket, and GitLab (public and private repos).
GHU is very modularized but would still require all the API classes, etc for full functionality. The code displaying the Settings page is essentially skipped when using WP-CLI.
Optimization is one part and I believe that GHU is highly optimized, but why the size limitation?
Mayba I should have written that. I am no-click&type guy. git pull is a lean way of updating a repo.
But git pull is just a reinstall essentially, like GHU's branch switcher.
With GHU installed you will see updates inside of wp plugin list and be able to update from there.
Maybe I am wrong but I think GHU's features could be deeply integrated into core's hooks. Please don't take it as an offense.
Core WP or core WP-CLI?
you will see updates inside of wp plugin list
One can develop a git command based plugin updater in a few kilobytes.
Core WP or core WP-CLI?
Core WP. That would make GHU much smaller and easier to maintain.
you will see updates inside of wp plugin list
One can develop a git command based plugin updater in a few kilobytes.
But would it likely wouldn't take into account private repos?
But would it likely wouldn't take into account private repos?
Of course one should use SSH based authentication.
Core WP. Thank would make GHU much smaller and easier to maintain.
Certainly, but I don't think it's likely to happen. It would certainly be interesting as a feature plugin.
It is an interesting project to write GHU-mini that takes input only from the command line, and uses the git command to communicate with the repository.
That wouldn't work on WordPress admin as executing binaries in a web application (exec()) is highly discouraged. But of course would work on cli.
Looky-looky!! https://github.com/boonebgorges/wp-cli-git-helper
:( False alarm is only keeps track of thing happening in a local git repo.
It certainly could be possible to build a GHU-mini, I might be able to just skip certain wp_remote_get parts when using WP-CLI. That should effectively create a GHU-mini.
It certainly could be possible to build a GHU-mini, I might be able to just skip certain wp_remote_get parts when using WP-CLI. That should effectively create a GHU-mini.
Similar to using hook github_updater_run_at_scale.
https://github.com/afragen/github-updater/wiki/Developer-Hooks
https://github.com/afragen/github-updater/blob/develop/src/GitHub_Updater/Base.php#L469-L476
I could easily solve that :) Shortcircuit core's plugin update when running on a webserver if the plugin is a git-based one.
I would only support git-based operations on cli. And of course no GUI, no readme etc.
OK, I think I've changed the subcommand for the final time.
I decided something more generic to install a repo would be easier to remember so instead of github-updater-install it's now install-git.
DocBlock instructions and wiki page have been updated.
I also added an option to install a specific branch, [--branch=<branch_name>]. The default is master.
Has anyone other than me been able to test this feature? I'd like at least one or two others to test and see if I made any glaring errors before a merge. Thanks.
Set to be merged in next release.