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
20 changes: 20 additions & 0 deletions features/make-phar.feature
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,23 @@ Feature: Check `utils/make-phar.php` output
"""
SHA-512
"""

Scenario: Bundled command assets are included in the Phar
Given an empty directory
And a new Phar with the same version

When I run `php -r '$phar = new Phar( "{PHAR_PATH}" ); echo isset( $phar["vendor/wp-cli/i18n-command/assets/block-i18n.json"] ) && isset( $phar["vendor/wp-cli/i18n-command/assets/theme-i18n.json"] ) ? "present" : "missing";'`
Then STDOUT should be:
"""
present
"""

Scenario: Dev-only Symfony packages are excluded from the Phar
Given an empty directory
And a new Phar with the same version

When I run `php -r '$phar = new Phar( "{PHAR_PATH}" ); $found = 0; foreach ( new RecursiveIteratorIterator( $phar ) as $file ) { if ( false !== strpos( $file->getPathname(), "/vendor/symfony/" ) ) { ++$found; } } echo $found;'`
Then STDOUT should be:
"""
0
"""
16 changes: 13 additions & 3 deletions utils/make-phar.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function add_file( $phar, $path ) {
'\/nb\/oxymel\/',
'-command\/src\/',
'\/wp-cli\/[^\n]+?-command\/',
'\/symfony\/(?:config|console|debug|dependency-injection|event-dispatcher|filesystem|translation|yaml)',
is_dir( WP_CLI_VENDOR_DIR . '/composer/composer' ) ? '\/symfony\/(?:config|console|debug|dependency-injection|event-dispatcher|filesystem|translation|yaml)' : '\/symfony\/',
'\/(?:dealerdirect|myclabs|squizlabs|wimg)\/',
'\/yoast\/',
];
Expand All @@ -91,7 +91,7 @@ function add_file( $phar, $path ) {
'\/phpspec\/',
'\/sebastian\/',
'\/php-parallel-lint\/',
'\/symfony\/(?:config|debug|dependency-injection|event-dispatcher|translation|yaml)',
is_dir( WP_CLI_VENDOR_DIR . '/composer/composer' ) ? '\/symfony\/(?:config|debug|dependency-injection|event-dispatcher|translation|yaml)' : '\/symfony\/',
'\/composer\/spdx-licenses\/',
'\/Composer\/(?:Command\/|Compiler\.php|Console\/|Downloader\/Pear|Installer\/Pear|Question\/|Repository\/Pear|SelfUpdate\/)',
'\/(?:dealerdirect|myclabs|squizlabs|wimg)\/',
Expand Down Expand Up @@ -201,7 +201,6 @@ function get_composer_versions( $current_version ) {
->in( WP_CLI_VENDOR_DIR . '/eftec/bladeone' )
->in( WP_CLI_ROOT . '/bundle/rmccue/requests' )
->in( WP_CLI_VENDOR_DIR . '/composer' )
->in( WP_CLI_VENDOR_DIR . '/symfony' )
->notName( 'behat-tags.php' )
->notPath( '#(?:[^/]+-command|php-cli-tools)/vendor/#' ) // For running locally, in case have composer installed or symlinked them.
->exclude( 'config' )
Expand All @@ -216,6 +215,10 @@ function get_composer_versions( $current_version ) {
->exclude( 'tests' )
->exclude( 'Test' )
->exclude( 'Tests' );
if ( is_dir( WP_CLI_VENDOR_DIR . '/composer/composer' ) && is_dir( WP_CLI_VENDOR_DIR . '/symfony' ) ) {
$finder
->in( WP_CLI_VENDOR_DIR . '/symfony' );
}
if ( is_dir( WP_CLI_VENDOR_DIR . '/react' ) ) {
$finder
->in( WP_CLI_VENDOR_DIR . '/react' );
Expand Down Expand Up @@ -275,6 +278,13 @@ function get_composer_versions( $current_version ) {
->in( WP_CLI_ROOT . '/templates' )
->in( WP_CLI_VENDOR_DIR . '/wp-cli/*-command/templates' );

if ( 'cli' !== BUILD ) {
$asset_dirs = glob( WP_CLI_VENDOR_DIR . '/wp-cli/*-command/assets', GLOB_ONLYDIR );
if ( ! empty( $asset_dirs ) ) {
$finder->in( $asset_dirs );
}
}

foreach ( $finder as $file ) {
add_file( $phar, $file );
}
Expand Down