diff --git a/composer.json b/composer.json index 38ce813d9..6b133a4f2 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ "wp-cli/wp-cli": "dev-main" }, "require-dev": { + "symfony/finder": "^5.4", "wp-cli/package-command": "^3", "wp-cli/wp-cli-tests": "^5.4.0" }, diff --git a/composer.lock b/composer.lock index 4dbed7b92..8318349b4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7b14f7d16361ad6655125b383a90eb11", + "content-hash": "326eb7382ec92dcc6dc2ba80d1cdcb3c", "packages": [ { "name": "composer/semver", diff --git a/utils/make-phar.php b/utils/make-phar.php index 2bfca7904..17834153c 100644 --- a/utils/make-phar.php +++ b/utils/make-phar.php @@ -224,7 +224,6 @@ function get_composer_versions( $current_version ) { $finder ->in( WP_CLI_VENDOR_DIR . '/wp-cli/mustangostang-spyc' ) ->in( WP_CLI_VENDOR_DIR . '/wp-cli/php-cli-tools' ) - ->in( WP_CLI_VENDOR_DIR . '/seld/cli-prompt' ) ->exclude( 'console' ) ->exclude( 'filesystem' ) ->exclude( 'composer/ca-bundle' ) @@ -235,9 +234,6 @@ function get_composer_versions( $current_version ) { $finder ->in( WP_CLI_VENDOR_DIR . '/wp-cli' ) ->in( WP_CLI_VENDOR_DIR . '/nb/oxymel' ) - ->in( WP_CLI_VENDOR_DIR . '/psr' ) - ->in( WP_CLI_VENDOR_DIR . '/seld' ) - ->in( WP_CLI_VENDOR_DIR . '/justinrainbow/json-schema' ) ->in( WP_CLI_VENDOR_DIR . '/gettext' ) ->in( WP_CLI_VENDOR_DIR . '/mck89' ) ->exclude( 'demo' ) @@ -253,10 +249,16 @@ function get_composer_versions( $current_version ) { ->exclude( 'composer/composer/src/Composer/Question' ) ->exclude( 'composer/composer/src/Composer/Repository/Pear' ) ->exclude( 'composer/composer/src/Composer/SelfUpdate' ); +} - // required by justinrainbow/json-schema v6+. - if ( is_dir( WP_CLI_VENDOR_DIR . '/marc-mabe/php-enum' ) ) { - $finder->in( WP_CLI_VENDOR_DIR . '/marc-mabe/php-enum' ); +// These only exist when a bundled package pulls them in, e.g. composer/composer +// for older versions of wp-cli/package-command. Finder errors out on missing directories. +$optional_dirs = 'cli' === BUILD + ? [ 'seld/cli-prompt' ] + : [ 'psr', 'seld', 'justinrainbow/json-schema', 'marc-mabe/php-enum' ]; +foreach ( $optional_dirs as $optional_dir ) { + if ( is_dir( WP_CLI_VENDOR_DIR . '/' . $optional_dir ) ) { + $finder->in( WP_CLI_VENDOR_DIR . '/' . $optional_dir ); } } @@ -304,7 +306,7 @@ function get_composer_versions( $current_version ) { } add_file( $phar, WP_CLI_VENDOR_DIR . '/autoload.php' ); -if ( 'cli' !== BUILD ) { +if ( 'cli' !== BUILD && is_dir( WP_CLI_VENDOR_DIR . '/composer/composer' ) ) { add_file( $phar, WP_CLI_VENDOR_DIR . '/composer/composer/LICENSE' ); add_file( $phar, WP_CLI_VENDOR_DIR . '/composer/composer/res/composer-schema.json' ); }