Implement wp cli update#1535
Conversation
php/commands/cli.php
Outdated
There was a problem hiding this comment.
Let's call this update, instead of self-update, to follow the established pattern for wp core and wp plugin.
What do you think is the best way to do this?
Yeah, that's #1493 |
Changes to WP_CLI::error(): - can now take an array of lines, which will be printed in a red box, similar to Composer's exceptions - new boolean $exit param - if false will not exit(1); defaults to old behaviour Both loggers get a new error_box( $message_lines ) function `wp cli self-update` is now `wp cli update`
We could have Do you want me to open another PR for #680? I'll create an issue with a task list for everything update-related. |
- Implements wp-cli#680 - It is now possibile to set the version at build time (required for wp-cli#1535): --version=x.y.z - Keywords for incrementing the version number by one: --version=[patch|minor|major] - When no arguments are passed, the old behaviour is preverved - utils/update-phar takes an option argument: `update-phar [same|patch|minor|major|x.y.z]`
php/class-wp-cli.php
Outdated
There was a problem hiding this comment.
I don't want to make WP_CLI::error() a magical method that does different things based on what you pass to it. Let's keep the scope of the pull request to wp cli update
There was a problem hiding this comment.
Would you rather have a WP_CLI::error_box() or remove this entirely?
Also, what the $exit param?
There was a problem hiding this comment.
Would you rather have a WP_CLI::error_box() or remove this entirely?
I'm open to it. _box() doesn't strike me as very semantic though. How about error_multi_line()?
Also, what the $exit param?
I'd prefer not to change the behavior unless there's a good reason to do so. The one use you have in this pull request doesn't justify, in my opinion.
There was a problem hiding this comment.
WP_CLI::error_multi_line() is now in nyordanov@6fd93c2
Given that each build runs the full suite of tests, I'm not sure how I feel about setting Instead, we probably should set it at runtime. How do you feel about this? I like #1539 generally though, so I think we can keep that once you address the modifications I've proposed. |
Such test will need an entirely different build anyway. After performing
How can we expose this to the tests but not to regular users? |
Good point. Ignore my runtime suggestion then. I think we'll just need to have a bespoke Travis build for testing the update process, outside of the standard matrix. |
- change description of --patch and --minor - introduce --ignore-patch and --ignore-minor
features/cli.feature: - wp cli check-updates should return at least one update after version 0.0.0 - wp cli update should perform a successful update of version 0.0.0
- make-phar.php gains a new optional flag --store-version which defaults to false. The script will change the contents of VERSION only if this is true. This is false when building temporary Phars with custom versions for tests. - Because of that there is a new function set_file_contents() in make-phar.php This is similar to add_file(), but the contents of the new file are passed as an argument, instead of reading them via file_get_contents() - Behat test for building a temporary Phar with a fake version Also ensure that VERSION is not modified
|
I've added a new
Also:
|
php/commands/cli.php
Outdated
There was a problem hiding this comment.
s/list/perform
Also, I think we can skip --ignore-* by using our magic --no- prefix.
|
This is looking solid. A few minor comments to address. I'll set aside some time next week to check the branch out and test throughly. |
- from 0.14.0 with --patch - from 0.14.0 with --no-patch
|
This is my very-short and solid install/update script: WPCLI_URL="https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar"
wget -O /usr/local/bin/wp "$WPCLI_URL" && chmod +x /usr/local/bin/wp
WPCLI_COMPLETION_URL="https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash"
wget -O- "$WPCLI_COMPLETION_URL"|sed 's/wp cli completions/wp --allow-root cli completions/' > /etc/bash_completion.d/wp-clihttps://github.com/szepeviktor/debian-server-tools/blob/master/debian-setup.sh#L342-L348 Maybe you shouldn't update at the time of a new release. Wait for the bugs! |
|
👍 Thanks for your work on this! |
Implement `wp cli self-update`
There was a problem hiding this comment.
What is the purpose of adding ! $assoc_args['patch']?
There was a problem hiding this comment.
Takes care of --no-patch. This will behave in the exact same way as --minor until 1.0.0 is released.
This implements
wp cli self-update, originally proposed in #522I've reused the code for getting the url of the latest phar from
wp cli check-update. A newprivate function get_updates( $assoc_args )is introduced which is used by bothcheck_updateandself_update.An update is performed if all of these criteria are met:
php /path/to/downloaded/update --versionshould be 0)I haven't added any tests. However, in order to create a test for this command, it should be possible to set
WP_CLI_VERSIONat build time.A manual test can be performed by decreasing
WP_CLI_VERSIONin php/wp-cli.php and running this in a shell: