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

@AaronRutley AaronRutley 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/' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

@AaronRutley AaronRutley Sep 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

My assumption is that 1.7 wasn't available.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.' );
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've just fixed.

And an empty cache

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Then STDERR should contain

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've just fixed.

Given an empty directory
And an empty cache

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've just fixed.

And an empty cache

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/' ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's switch this to the v1.7 API

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@danielbachhuber danielbachhuber merged commit aa301bd into wp-cli:master Oct 1, 2017
@danielbachhuber
Copy link
Member

Thanks for your work on this @AaronRutley !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants