8000 Sending a warning if we can't find the dependent package · symfony/symfony@8d7c806 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d7c806

Browse files
committed
Sending a warning if we can't find the dependent package
1 parent d95d406 commit 8d7c806

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

src/Symfony/Component/AssetMapper/Command/VersionProblemCommandTrait.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ private function renderVersionProblems(ImportMapVersionChecker $importMapVersion
2525
foreach ($problems as $problem) {
2626
if (null === $problem->installedVersion) {
2727
$output->writeln(sprintf('[warning] <info>%s</info> requires <info>%s</info> but it is not in the importmap.php. You may need to run "php bin/console importmap:require %s".', $problem->packageName, $problem->dependencyPackageName, $problem->dependencyPackageName));
28-
} else {
29-
$output->writeln(sprintf('[warning] <info>%s</info> requires <info>%s</info>@<comment>%s</comment> but version <comment>%s</comment> is installed.', $problem->packageName, $problem->dependencyPackageName, $problem->requiredVersionConstraint, $problem->installedVersion));
28+
29+
continue;
3030
}
31+
32+
if (null === $problem->requiredVersionConstraint) {
33+
$output->writeln(sprintf('[warning] <info>%s</info> appears to import <info>%s</info> but this is not listed as a dependency of <info>%s</info>. This is odd and could be a misconfiguration of that package.', $problem->packageName, $problem->dependencyPackageName, $problem->packageName));
34+
35+
continue;
36+
}
37+
38+
$output->writeln(sprintf('[warning] <info>%s</info> requires <info>%s</info>@<comment>%s</comment> but version <comment>%s</comment> is installed.', $problem->packageName, $problem->dependencyPackageName, $problem->requiredVersionConstraint, $problem->installedVersion));
3139
}
3240
}
3341
}

src/Symfony/Component/AssetMapper/ImportMap/ImportMapVersionChecker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public function checkVersions(): array
8888
}
8989

9090
if (null === $dependencyVersionConstraint) {
91-
// local file imports this, but the package doesn't have it as a dependency
92-
// odd, but not technically a problem
91+
$problems[] = new PackageVersionProblem($packageName, $dependencyName, $dependencyVersionConstraint, $entries->get($dependencyName)->version);
92+
9393
continue;
9494
}
9595

src/Symfony/Component/AssetMapper/ImportMap/PackageVersionProblem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class PackageVersionProblem
1616
public function __construct(
1717
public readonly string $packageName,
1818
public readonly string $dependencyPackageName,
19-
public readonly string $requiredVersionConstraint,
19+
public readonly ?string $requiredVersionConstraint,
2020
public readonly ?string $installedVersion
2121
) {
2222
}

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,5 +196,27 @@ public static function getCheckVersionsTests()
196196
new PackageVersionProblem('foo', 'bar', '^2.0.0', '1.5.0'),
197197
],
198198
];
199+
200+
yield 'single that imports something that is not required by the package' => [
201+
[
202+
new ImportMapEntry('foo', version: '1.0.0'),
203+
new ImportMapEntry('bar', version: '1.5.0'),
204+
],
205+
[
206+
'foo' => ['bar'],
207+
'bar' => [],
208+
],
209+
[
210+
[
211+
'url' => '/foo/1.0.0',
212+
'response' => [
213+
'dependencies' => [],
214+
],
215+
],
216+
],
217+
[
218+
new PackageVersionProblem('foo', 'bar', null, '1.5.0'),
219+
],
220+
];
199221
}
200222
}

0 commit comments

Comments
 (0)
0