-
Notifications
You must be signed in to change notification settings - Fork 48
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
Conversation
src/Core_Command.php
Outdated
@@ -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/' ) ); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
src/Core_Command.php
Outdated
$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'; | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
features/core-download.feature
Outdated
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 |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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.
src/Core_Command.php
Outdated
|
||
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.' ); | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
features/core-download.feature
Outdated
Given an empty directory | ||
And an empty cache | ||
|
||
When I run `wp core download --skip-content --locale=nl_NL` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
features/core-download.feature
Outdated
And an empty cache | ||
|
||
When I run `wp core download --skip-content --locale=nl_NL` | ||
Then STDOUT should contain: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
features/core-download.feature
Outdated
Given an empty directory | ||
And an empty cache | ||
|
||
When I run `wp core download --skip-content --version=4.7` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto above
There was a problem hiding this comment.
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.
features/core-download.feature
Outdated
And an empty cache | ||
|
||
When I run `wp core download --skip-content --version=4.7` | ||
Then STDOUT should contain: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto above
There was a problem hiding this comment.
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.
src/Core_Command.php
Outdated
@@ -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 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
src/Core_Command.php
Outdated
|
||
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"]; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
src/Core_Command.php
Outdated
} | ||
|
||
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/' ) ); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
Thanks for your work on this @AaronRutley ! |
--skip-content
to download WordPress without default themes/plugins (US locale only)
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.