Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use `--skip-content` to download WordPress without default themes/plugins (US locale only) #37

Merged
merged 14 commits into from Oct 1, 2017

Conversation

@AaronRutley
Copy link

commented Sep 27, 2017

Allow users to install WordPress without content eg: wp core download --skip-content
See these issues for context #36 & wp-cli/ideas#59

This is my first pass, please let me know what needs improvement.

@@ -158,6 +161,12 @@ public function download( $args, $assoc_args ) {
$download_url = str_replace( '.zip', '.tar.gz', $offer['download'] );
}
if ( true === \WP_CLI\Utils\get_flag_value( $assoc_args, 'skip-content' ) ) {
$offer = unserialize( self::_read( 'https://api.wordpress.org/core/version-check/1.6/' ) );

This comment has been minimized.

Copy link
@ocean90

ocean90 Sep 27, 2017

Contributor

Any reason for not using https://api.wordpress.org/core/version-check/1.7/ which provides JSON data?

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 27, 2017

Author

Hey @ocean90, I opted for /1.6/ as it's used is for this command here

I'm happy to swap it for /1.7/ if needed!

This comment has been minimized.

Copy link
@ocean90

ocean90 Sep 27, 2017

Contributor

Gotcha, maybe there's a reason... cc @danielbachhuber

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 27, 2017

Member

Here's the original commit: wp-cli/wp-cli@3fbef8b

My assumption is that 1.7 wasn't available.

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 28, 2017

Author

Thanks @danielbachhuber,
Would you like to continue using 1.6 or should we change to 1.7?

$offer = unserialize( self::_read( 'https://api.wordpress.org/core/version-check/1.6/' ) );
$download_url = $offer['offers'][0]["packages"]["no_content"];
$version = $offer['offers'][0]["current"].' without content';
}

This comment has been minimized.

Copy link
@ocean90

ocean90 Sep 27, 2017

Contributor

Since there's a Nightly builds are only available for the en_US locale. error, packages with no content are also only available for the en_US locale.

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 27, 2017

Author

Thanks @ocean90, I've just added this AaronRutley@dd9a40c

When I run `wp core download --skip-content`
And save STDOUT 'Downloading WordPress ([\d\.]+)' as {VERSION}
Then the wp-settings.php file should exist
And the {SUITE_CACHE_DIR}/core/wordpress-{WP_VERSION-latest}-without-content-en_US.zip file should exist

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 27, 2017

Member

Can you create a new Scenario for this behavior please (instead of repurposing an existing one)?

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 27, 2017

Member

We'll also need to make sure there are tests for:

  • Non US locales
  • Use of --version=<version>

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 28, 2017

Author

Thanks @danielbachhuber, I've just created 3 new scenarios.

if ( true === \WP_CLI\Utils\get_flag_value( $assoc_args, 'skip-content' ) && 'en_US' !== $locale ) {
WP_CLI::error( 'The skip content build is only available for the en_US locale.' );
}

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 27, 2017

Member

I think it would make sense to render this error earlier on, to avoid an unnecessary HTTP request when the error will render.

Also, did you confirm this is the case? That --skip-content is available for the en_US locale?

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 28, 2017

Author

Thanks @danielbachhuber, I've moved this check to earlier on.
Yes, as I understand, --skip-content is only available for the en_US locale.

Given an empty directory
And an empty cache

When I run `wp core download --skip-content --locale=nl_NL`

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 28, 2017

Member

This should be When I try, because the expected result is an error.

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 29, 2017

Author

Thanks, I've just fixed.

And an empty cache

When I run `wp core download --skip-content --locale=nl_NL`
Then STDOUT should contain:

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 28, 2017

Member

This should be Then STDERR should contain

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 29, 2017

Author

Thanks, I've just fixed.

Given an empty directory
And an empty cache

When I run `wp core download --skip-content --version=4.7`

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 28, 2017

Member

Ditto above

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 29, 2017

Author

Thanks, I've just fixed.

And an empty cache

When I run `wp core download --skip-content --version=4.7`
Then STDOUT should contain:

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 28, 2017

Member

Ditto above

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 29, 2017

Author

Thanks, I've just fixed.

@@ -108,6 +108,9 @@ function check_update( $_, $assoc_args ) {
* [--force]
* : Overwrites existing files, if present.
*
* [--skip-content]
* : Download the latest version of WP without the default themes and plugins

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 28, 2017

Member

Can we include some mention that this only works when locale is en_US?

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 29, 2017

Author

For sure, I've just updated.

if ( true === \WP_CLI\Utils\get_flag_value( $assoc_args, 'skip-content' ) ) {
$offer = unserialize( self::_read( 'https://api.wordpress.org/core/version-check/1.6/' ) );
$download_url = $offer['offers'][0]["packages"]["no_content"];

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 28, 2017

Member

We need to check that $offer['offers'][0]["packages"]["no_content"]; is set, and error if it's not.

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 29, 2017

Author

Thanks for your feedback, I've just addressed this!

}
if ( true === \WP_CLI\Utils\get_flag_value( $assoc_args, 'skip-content' ) ) {
$offer = unserialize( self::_read( 'https://api.wordpress.org/core/version-check/1.6/' ) );

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Sep 28, 2017

Member

Let's switch this to the v1.7 API

This comment has been minimized.

Copy link
@AaronRutley

AaronRutley Sep 29, 2017

Author

Thanks for your feedback, I've just addressed this!

@danielbachhuber danielbachhuber merged commit aa301bd into wp-cli:master Oct 1, 2017
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@danielbachhuber

This comment has been minimized.

Copy link
Member

commented Oct 1, 2017

Thanks for your work on this @AaronRutley !

@danielbachhuber danielbachhuber changed the title Add skip content flag feature Use `--skip-content` to download WordPress without default themes/plugins (US locale only) Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.