1
0
Fork 0

Suggest running 'require' not 'update' if a root req fails to update (#11691)

pull/11699/head
Dan Wallis 2023-10-26 10:08:03 +01:00 committed by GitHub
parent 03085c8181
commit 81b662d388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

View File

@ -152,7 +152,23 @@ abstract class BaseDependencyCommand extends BaseCommand
} }
if ($inverted && $input->hasArgument(self::ARGUMENT_CONSTRAINT)) { if ($inverted && $input->hasArgument(self::ARGUMENT_CONSTRAINT)) {
$this->getIO()->writeError('Not finding what you were looking for? Try calling `composer update "'.$input->getArgument(self::ARGUMENT_PACKAGE).':'.$input->getArgument(self::ARGUMENT_CONSTRAINT).'" --dry-run` to get another view on the problem.'); $composerCommand = 'update';
foreach ($composer->getPackage()->getRequires() as $rootRequirement) {
if ($rootRequirement->getTarget() === $needle) {
$composerCommand = 'require';
break;
}
}
foreach ($composer->getPackage()->getDevRequires() as $rootRequirement) {
if ($rootRequirement->getTarget() === $needle) {
$composerCommand = 'require --dev';
break;
}
}
$this->getIO()->writeError('Not finding what you were looking for? Try calling `composer '.$composerCommand.' "'.$needle.':'.$textConstraint.'" --dry-run` to get another view on the problem.');
} }
return 0; return 0;

View File

@ -425,7 +425,7 @@ OUTPUT
<<<OUTPUT <<<OUTPUT
Package "vendor1/package1" could not be found with constraint "3.*", results below will most likely be incomplete. Package "vendor1/package1" could not be found with constraint "3.*", results below will most likely be incomplete.
__root__ - requires vendor1/package1 (1.*) __root__ - requires vendor1/package1 (1.*)
Not finding what you were looking for? Try calling `composer update "vendor1/package1:3.*" --dry-run` to get another view on the problem. Not finding what you were looking for? Try calling `composer require "vendor1/package1:3.*" --dry-run` to get another view on the problem.
OUTPUT OUTPUT
]; ];
@ -434,7 +434,7 @@ OUTPUT
<<<OUTPUT <<<OUTPUT
Package "vendor1/package1" could not be found with constraint "^1.4", results below will most likely be incomplete. Package "vendor1/package1" could not be found with constraint "^1.4", results below will most likely be incomplete.
There is no installed package depending on "vendor1/package1" in versions not matching ^1.4 There is no installed package depending on "vendor1/package1" in versions not matching ^1.4
Not finding what you were looking for? Try calling `composer update "vendor1/package1:^1.4" --dry-run` to get another view on the problem. Not finding what you were looking for? Try calling `composer require "vendor1/package1:^1.4" --dry-run` to get another view on the problem.
OUTPUT OUTPUT
]; ];
@ -442,7 +442,7 @@ OUTPUT
['package' => 'vendor1/package1', 'version' => '^1.3'], ['package' => 'vendor1/package1', 'version' => '^1.3'],
<<<OUTPUT <<<OUTPUT
There is no installed package depending on "vendor1/package1" in versions not matching ^1.3 There is no installed package depending on "vendor1/package1" in versions not matching ^1.3
Not finding what you were looking for? Try calling `composer update "vendor1/package1:^1.3" --dry-run` to get another view on the problem. Not finding what you were looking for? Try calling `composer require "vendor1/package1:^1.3" --dry-run` to get another view on the problem.
OUTPUT OUTPUT
]; ];