Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions features/core.feature
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ Feature: Manage WordPress installation
When I run `wp core check-update`
Then STDOUT should be a table containing rows:
| version | update_type | package_url |
| 4.0 | major | https://wordpress.org/wordpress-4.0.zip |
| 3.9.2 | major | https://wordpress.org/wordpress-3.9.2.zip |
| 3.8.4 | minor | https://wordpress.org/wordpress-3.8.4.zip |
| 4.0.1 | major | https://wordpress.org/wordpress-4.0.1.zip |
| 3.9.3 | major | https://wordpress.org/wordpress-3.9.3.zip |
| 3.8.5 | minor | https://wordpress.org/wordpress-3.8.5.zip |

When I run `wp core check-update --field=version | wc -l`
Then STDOUT should be:
Expand All @@ -283,8 +283,8 @@ Feature: Manage WordPress installation
When I run `wp core check-update --major`
Then STDOUT should be a table containing rows:
| version | update_type | package_url |
| 4.0 | major | https://wordpress.org/wordpress-4.0.zip |
| 3.9.2 | major | https://wordpress.org/wordpress-3.9.2.zip |
| 4.0.1 | major | https://wordpress.org/wordpress-4.0.1.zip |
| 3.9.3 | major | https://wordpress.org/wordpress-3.9.3.zip |

When I run `wp core check-update --major --field=version | wc -l`
Then STDOUT should be:
Expand All @@ -295,7 +295,7 @@ Feature: Manage WordPress installation
When I run `wp core check-update --minor`
Then STDOUT should be a table containing rows:
| version | update_type | package_url |
| 3.8.4 | minor | https://wordpress.org/wordpress-3.8.4.zip |
| 3.8.5 | minor | https://wordpress.org/wordpress-3.8.5.zip |

When I run `wp core check-update --minor --field=version | wc -l`
Then STDOUT should be:
Expand Down
13 changes: 13 additions & 0 deletions features/plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,16 @@ Feature: Manage WordPress plugins
| handbook/handbook | inactive |
| handbook/functionality-for-pages | active |

Scenario: Install a plugin, then update to a specific version of that plugin
Given a WP install

When I run `wp plugin install akismet --version=2.5.7 --force`
Then STDOUT should not be empty

When I run `wp plugin update akismet --version=2.6.0`
Then STDOUT should not be empty

When I run `wp plugin list --fields=name,version`
Then STDOUT should be a table containing rows:
| name | version |
| akismet | 2.6.0 |
14 changes: 14 additions & 0 deletions features/theme.feature
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,17 @@ Feature: Manage WordPress themes
"""
Error: This is not a multisite install.
"""

Scenario: Install a theme, then update to a specific version of that theme
Given a WP install

When I run `wp theme install p2 --version=1.4.1`
Then STDOUT should not be empty

When I run `wp theme update p2 --version=1.4.2`
Then STDOUT should not be empty

When I run `wp theme list --fields=name,version`
Then STDOUT should be a table containing rows:
| name | version |
| p2 | 1.4.2 |
3 changes: 2 additions & 1 deletion php/commands/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function check_update( $_, $assoc_args ) {
$release_data = json_decode( $response->body );
$release_versions = array_keys( (array) $release_data );
usort( $release_versions, function( $a, $b ){
return ! version_compare( $a, $b );
return 1 === version_compare( $a, $b );
});

$locale = get_locale();
Expand Down Expand Up @@ -86,6 +86,7 @@ function check_update( $_, $assoc_args ) {
}

if ( $updates ) {
$updates = array_reverse( $updates );
$formatter = new \WP_CLI\Formatter(
$assoc_args,
array( 'version', 'update_type', 'package_url' )
Expand Down
7 changes: 4 additions & 3 deletions php/commands/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ protected function install_from_repo( $slug, $assoc_args ) {
* : If set, all plugins that have updates will be updated.
*
* [--version=<version>]
* : If set, the plugin will be updated to the latest development version,
* regardless of what version is currently installed.
* : If set, the plugin will be updated to the specified version.
*
* [--dry-run]
* : Preview which plugins would be updated.
Expand All @@ -311,9 +310,11 @@ protected function install_from_repo( $slug, $assoc_args ) {
* wp plugin update --all
*/
function update( $args, $assoc_args ) {
if ( isset( $assoc_args['version'] ) && 'dev' == $assoc_args['version'] ) {
if ( isset( $assoc_args['version'] ) ) {
foreach ( $this->fetcher->get_many( $args ) as $plugin ) {
$this->_delete( $plugin );

$assoc_args['force'] = 1;
$this->install( array( $plugin->name ), $assoc_args );
}
} else {
Expand Down
3 changes: 1 addition & 2 deletions php/commands/scaffold.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ function plugin_tests( $args, $assoc_args ) {
foreach ( $to_copy as $file => $dir ) {
$wp_filesystem->copy( WP_CLI_ROOT . "/templates/$file", "$dir/$file", true );
if ( 'install-wp-tests.sh' === $file ) {
if ( ! $wp_filesystem->chmod( "$dir/$file", '0755' ) ) {
if ( ! $wp_filesystem->chmod( "$dir/$file", 0755 ) ) {
WP_CLI::warning( "Couldn't mark install-wp-tests.sh as executable." );
}
}
Expand Down Expand Up @@ -632,4 +632,3 @@ private function init_wp_filesystem() {
}

WP_CLI::add_command( 'scaffold', 'Scaffold_Command' );

17 changes: 14 additions & 3 deletions php/commands/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,7 @@ public function get( $args, $assoc_args ) {
* : If set, all themes that have updates will be updated.
*
* [--version=<version>]
* : If set, the theme will be updated to the latest development version,
* regardless of what version is currently installed.
* : If set, the plugin will be updated to the specified version.
*
* [--dry-run]
* : Preview which themes would be updated.
Expand All @@ -453,7 +452,19 @@ public function get( $args, $assoc_args ) {
* wp theme update --all
*/
function update( $args, $assoc_args ) {
parent::update_many( $args, $assoc_args );
if ( isset( $assoc_args['version'] ) ) {
foreach ( $this->fetcher->get_many( $args ) as $theme ) {
$r = delete_theme( $theme->stylesheet );
if ( is_wp_error( $r ) ) {
WP_CLI::warning( $r );
} else {
$assoc_args['force'] = 1;
$this->install( array( $theme->stylesheet ), $assoc_args );
}
}
} else {
parent::update_many( $args, $assoc_args );
}
}

/**
Expand Down
83 changes: 83 additions & 0 deletions utils/wp-cli-updatedeb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
#
# Package wp-cli to be installed in Debian-compatible systems.
# Only the phar file is included.
#
# VERSION :0.2
# DATE :2014-11-19
# AUTHOR :Viktor Szépe <viktor@szepe.net>
# LICENSE :The MIT License (MIT)
# URL :https://github.com/wp-cli/wp-cli/tree/master/utils
# BASH-VERSION :4.2+

# packages source path
DIR="php-wpcli"
# phar URL
PHAR="https://github.com/wp-cli/builds/raw/gh-pages/phar/wp-cli.phar"

die() {
local RET="$1"
shift

echo -e "$@" >&2
exit "$RET"
}

dump_control() {
cat > DEBIAN/control <<CTRL
Package: php-wpcli
Version: 0.0.0
Architecture: all
Maintainer: Daniel Bachhuber <daniel@handbuilt.co>
Section: php
Priority: optional
Depends: php5-cli, php5-mysql | php5-mysqlnd, mysql-client
Homepage: http://wp-cli.org/
Description: wp-cli is a set of command-line tools for managing
WordPress installations. You can update plugins, set up multisite
installs and much more, without using a web browser.

CTRL
}

# deb's dir
if ! [ -d "$DIR" ]; then
mkdir "$DIR" || die 1 "Cannot create directory here: ${PWD}"
fi

pushd "$DIR"

# control file
if ! [ -r DEBIAN/control ]; then
mkdir DEBIAN
dump_control
fi

# content dirs
[ -d usr/bin ] || mkdir -p usr/bin

# download current version
wget -nv -O usr/bin/wp "$PHAR" || die 3 "Phar download failure"
chmod +x usr/bin/wp || die 4 "chmod failure"

# get version
WPCLI_VER="$(grep -ao "define.*WP_CLI_VERSION.*;" usr/bin/wp | cut -d"'" -f4)"
[ -z "$WPCLI_VER" ] && die 5 "Cannot get wp-cli version"
echo "Current version: ${WPCLI_VER}"

# update version
sed -i "s/^Version: .*$/Version: ${WPCLI_VER}/" DEBIAN/control || die 6 "Version update failure"

# update MD5-s
find usr -type f -exec md5sum \{\} \; > DEBIAN/md5sums || die 7 "md5sum creation failure"

popd

# build package in the current diretory
WPCLI_PKG="${PWD}/php-wpcli_${WPCLI_VER}_all.deb"
fakeroot dpkg-deb --build "$DIR" "$WPCLI_PKG" || die 8 "Packaging failed"

# optional steps
echo "sign it: dpkg-sig -k <YOUR-KEY> -s builder \"$WPCLI_PKG\""
echo "include in your repo: pushd /var/www/<REPO-DIR>"
echo "reprepro includedeb wheezy \"$WPCLI_PKG\" && popd"