From 1d8e73a9ede97d7e8d6bbc5000f8b1b1ffd00094 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 26 Nov 2026 18:36:06 +0000 Subject: [PATCH 1/2] Include bundled command assets directories in the Phar --- features/make-phar.feature | 10 ++++++++++ utils/make-phar.php | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/features/make-phar.feature b/features/make-phar.feature index d93b1566d..ebc7ae828 100644 --- a/features/make-phar.feature +++ b/features/make-phar.feature @@ -66,3 +66,13 @@ 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 + """ diff --git a/utils/make-phar.php b/utils/make-phar.php index 2db663f2e..cf31d9c91 100644 --- a/utils/make-phar.php +++ b/utils/make-phar.php @@ -275,6 +275,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 ); } From 515c7d917bfbe2b63ca3de18e802aff66ae5f551 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 26 Nov 2026 18:36:06 +0000 Subject: [PATCH 2/2] Exclude dev-only Symfony packages from the Phar when composer/composer is absent --- features/make-phar.feature | 10 ++++++++++ utils/make-phar.php | 9 ++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/features/make-phar.feature b/features/make-phar.feature index ebc7ae828..c6eec1c81 100644 --- a/features/make-phar.feature +++ b/features/make-phar.feature @@ -76,3 +76,13 @@ Feature: Check `utils/make-phar.php` output """ 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 + """ diff --git a/utils/make-phar.php b/utils/make-phar.php index cf31d9c91..3b14de5ed 100644 --- a/utils/make-phar.php +++ b/utils/make-phar.php @@ -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\/', ]; @@ -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)\/', @@ -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' ) @@ -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' );