-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from wp-cli/fix/add-composer-compat-for-2-3
- Loading branch information
Showing
8 changed files
with
193 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,73 @@ | ||
{ | ||
"name": "wp-cli/package-command", | ||
"type": "wp-cli-package", | ||
"description": "Lists, installs, and removes WP-CLI packages.", | ||
"homepage": "https://github.com/wp-cli/package-command", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Daniel Bachhuber", | ||
"email": "[email protected]", | ||
"homepage": "https://runcommand.io" | ||
} | ||
], | ||
"require": { | ||
"ext-json": "*", | ||
"composer/composer": "^1.10.23 || ~2.2.17", | ||
"wp-cli/wp-cli": "^2.8" | ||
}, | ||
"require-dev": { | ||
"wp-cli/scaffold-command": "^1 || ^2", | ||
"wp-cli/wp-cli-tests": "^4" | ||
}, | ||
"config": { | ||
"process-timeout": 7200, | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true, | ||
"johnpbloch/wordpress-core-installer": true | ||
} | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-main": "2.x-dev" | ||
}, | ||
"bundled": true, | ||
"commands": [ | ||
"package", | ||
"package browse", | ||
"package install", | ||
"package list", | ||
"package update", | ||
"package uninstall" | ||
] | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"src/" | ||
], | ||
"files": [ | ||
"package-command.php" | ||
] | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"scripts": { | ||
"behat": "run-behat-tests", | ||
"behat-rerun": "rerun-behat-tests", | ||
"lint": "run-linter-tests", | ||
"phpcs": "run-phpcs-tests", | ||
"phpcbf": "run-phpcbf-cleanup", | ||
"phpunit": "run-php-unit-tests", | ||
"prepare-tests": "install-package-tests", | ||
"test": [ | ||
"@lint", | ||
"@phpcs", | ||
"@phpunit", | ||
"@behat" | ||
] | ||
}, | ||
"support": { | ||
"issues": "https://github.com/wp-cli/package-command/issues" | ||
"name": "wp-cli/package-command", | ||
"type": "wp-cli-package", | ||
"description": "Lists, installs, and removes WP-CLI packages.", | ||
"homepage": "https://github.com/wp-cli/package-command", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Daniel Bachhuber", | ||
"email": "[email protected]", | ||
"homepage": "https://runcommand.io" | ||
} | ||
], | ||
"require": { | ||
"ext-json": "*", | ||
"composer/composer": "^1.10.23 || ^2.2.17", | ||
"wp-cli/wp-cli": "^2.8" | ||
}, | ||
"require-dev": { | ||
"wp-cli/scaffold-command": "^1 || ^2", | ||
"wp-cli/wp-cli-tests": "^4" | ||
}, | ||
"config": { | ||
"process-timeout": 7200, | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true, | ||
"johnpbloch/wordpress-core-installer": true | ||
} | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-main": "2.x-dev" | ||
}, | ||
"bundled": true, | ||
"commands": [ | ||
"package", | ||
"package browse", | ||
"package install", | ||
"package list", | ||
"package update", | ||
"package uninstall" | ||
] | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"src/" | ||
], | ||
"files": [ | ||
"package-command.php" | ||
] | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"scripts": { | ||
"behat": "run-behat-tests", | ||
"behat-rerun": "rerun-behat-tests", | ||
"lint": "run-linter-tests", | ||
"phpcs": "run-phpcs-tests", | ||
"phpcbf": "run-phpcbf-cleanup", | ||
"phpunit": "run-php-unit-tests", | ||
"prepare-tests": "install-package-tests", | ||
"test": [ | ||
"@lint", | ||
"@phpcs", | ||
"@phpunit", | ||
"@behat" | ||
] | ||
}, | ||
"support": { | ||
"issues": "https://github.com/wp-cli/package-command/issues" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/WP_CLI/Package/Compat/Min_Composer_1_10/NullIOMethodsTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace WP_CLI\Package\Compat\Min_Composer_1_10; | ||
|
||
use WP_CLI; | ||
|
||
trait NullIOMethodsTrait { | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function isVerbose() { | ||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function write( $messages, $newline = true, $verbosity = self::NORMAL ) { | ||
self::output_clean_message( $messages ); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function writeError( $messages, $newline = true, $verbosity = self::NORMAL ) { | ||
self::output_clean_message( $messages ); | ||
} | ||
|
||
private static function output_clean_message( $messages ) { | ||
$messages = (array) preg_replace( '#<(https?)([^>]+)>#', '$1$2', $messages ); | ||
foreach ( $messages as $message ) { | ||
// phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | ||
WP_CLI::log( strip_tags( trim( $message ) ) ); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/WP_CLI/Package/Compat/Min_Composer_2_3/NullIOMethodsTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace WP_CLI\Package\Compat\Min_Composer_2_3; | ||
|
||
use WP_CLI; | ||
|
||
trait NullIOMethodsTrait { | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function isVerbose(): bool { | ||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function write( $messages, bool $newline = true, int $verbosity = self::NORMAL ): void { | ||
self::output_clean_message( $messages ); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function writeError( $messages, bool $newline = true, int $verbosity = self::NORMAL ): void { | ||
self::output_clean_message( $messages ); | ||
} | ||
|
||
private static function output_clean_message( $messages ) { | ||
$messages = (array) preg_replace( '#<(https?)([^>]+)>#', '$1$2', $messages ); | ||
foreach ( $messages as $message ) { | ||
// phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | ||
WP_CLI::log( strip_tags( trim( $message ) ) ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace WP_CLI\Package\Compat; | ||
|
||
use Composer\InstalledVersions; | ||
use Composer\Semver\VersionParser; | ||
|
||
// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound,Generic.Classes.DuplicateClassName.Found | ||
|
||
if ( | ||
class_exists( InstalledVersions::class ) | ||
&& InstalledVersions::satisfies( new VersionParser(), 'composer/composer', '^2.3' ) | ||
) { | ||
require_once __DIR__ . '/Min_Composer_2_3/NullIOMethodsTrait.php'; | ||
|
||
trait NullIOMethodsTrait { | ||
|
||
use Min_Composer_2_3\NullIOMethodsTrait; | ||
} | ||
|
||
return; | ||
} | ||
|
||
require_once __DIR__ . '/Min_Composer_1_10/NullIOMethodsTrait.php'; | ||
|
||
trait NullIOMethodsTrait { | ||
|
||
use Min_Composer_1_10\NullIOMethodsTrait; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* A Composer IO class so we can provide some level of interactivity from WP-CLI. | ||
* | ||
* Due to PHP 5.6 compatibility, we have two different implementations of this class. | ||
* This is implemented via traits to make static analysis easier. | ||
* | ||
* See https://github.com/wp-cli/package-command/issues/172. | ||
*/ | ||
|
||
namespace WP_CLI\Package; | ||
|
||
use Composer\IO\NullIO; | ||
use WP_CLI\Package\Compat\NullIOMethodsTrait; | ||
|
||
class ComposerIO extends NullIO { | ||
use NullIOMethodsTrait; | ||
} |