Skip to content

Commit 98e9cd6

Browse files
committed
Tweaks thanks to @smnandre
1 parent 2cea0f8 commit 98e9cd6

File tree

5 files changed

+11
-19
lines changed

5 files changed

+11
-19
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,12 @@
177177
->set('asset_mapper.importmap.auditor', ImportMapAuditor::class)
178178
->args([
179179
service('asset_mapper.importmap.config_reader'),
180-
service('asset_mapper.importmap.resolver'),
181180
service('http_client'),
182181
])
183182

184183
->set('asset_mapper.importmap.command.require', ImportMapRequireCommand::class)
185184
->args([
186185
service('asset_mapper.importmap.manager'),
187-
service('asset_mapper'),
188186
param('kernel.project_dir'),
189187
])
190188
->tag('console.command')

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\AssetMapper\Command;
1313

14-
use Symfony\Component\AssetMapper\AssetMapperInterface;
1514
use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry;
1615
use Symfony\Component\AssetMapper\ImportMap\ImportMapManager;
1716
use Symfony\Component\AssetMapper\ImportMap\PackageRequireOptions;
@@ -31,7 +30,6 @@ final class ImportMapRequireCommand extends Command
3130
{
3231
public function __construct(
3332
private readonly ImportMapManager $importMapManager,
34-
private readonly AssetMapperInterface $assetMapper,
3533
private readonly string $projectDir,
3634
) {
3735
parent::__construct();

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\AssetMapper\ImportMap;
1313

1414
use Symfony\Component\AssetMapper\Exception\RuntimeException;
15-
use Symfony\Component\AssetMapper\ImportMap\Resolver\PackageResolverInterface;
1615
use Symfony\Component\HttpClient\HttpClient;
1716
use Symfony\Contracts\HttpClient\HttpClientInterface;
1817

@@ -24,7 +23,6 @@ class ImportMapAuditor
2423

2524
public function __construct(
2625
private readonly ImportMapConfigReader $configReader,
27-
private readonly PackageResolverInterface $packageResolver,
2826
HttpClientInterface $httpClient = null,
2927
) {
3028
$this->httpClient = $httpClient ?? HttpClient::create();

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,23 @@ public function downloadPackages(callable $progressCallback = null): array
6666

6767
$contents = $this->packageResolver->downloadPackages($remoteEntriesToDownload, $progressCallback);
6868
$downloadedPackages = [];
69-
foreach ($contents as $package => $content) {
70-
if (!isset($remoteEntriesToDownload[$package])) {
71-
throw new \LogicException(sprintf('The package "%s" was not in the requested packages.', $package));
69+
foreach ($remoteEntriesToDownload as $package => $entry) {
70+
if (!isset($contents[$package])) {
71+
throw new \LogicException(sprintf('The package "%s" was not downloaded.', $package));
7272
}
7373

74-
$filename = $this->savePackage($package, $content, $remoteEntriesToDownload[$package]->type);
74+
$filename = $this->savePackage($package, $contents[$package], $entry->type);
7575
$newInstalled[$package] = [
7676
'path' => $filename,
77-
'version' => $remoteEntriesToDownload[$package]->version,
77+
'version' => $entry->version,
7878
];
7979

8080
$downloadedPackages[] = $package;
81+
unset($contents[$package]);
82+
}
83+
84+
if ($contents) {
85+
throw new \LogicException(sprintf('The following packages were unexpectedly downloaded: "%s".', implode('", "', array_keys($contents))));
8186
}
8287

8388
$this->saveInstalled($newInstalled);
@@ -124,10 +129,6 @@ private function loadInstalled(): array
124129
}
125130

126131
$installedPath = $this->vendorDir.'/installed.php';
127-
if (!is_file($installedPath)) {
128-
return [];
129-
}
130-
131132
$installed = is_file($installedPath) ? (static fn () => include $installedPath)() : [];
132133

133134
foreach ($installed as $package => $data) {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,21 @@
1919
use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry;
2020
use Symfony\Component\AssetMapper\ImportMap\ImportMapPackageAudit;
2121
use Symfony\Component\AssetMapper\ImportMap\ImportMapPackageAuditVulnerability;
22-
use Symfony\Component\AssetMapper\ImportMap\Resolver\PackageResolverInterface;
2322
use Symfony\Component\HttpClient\MockHttpClient;
2423
use Symfony\Component\HttpClient\Response\MockResponse;
2524
use Symfony\Contracts\HttpClient\HttpClientInterface;
2625

2726
class ImportMapAuditorTest extends TestCase
2827
{
2928
private ImportMapConfigReader $importMapConfigReader;
30-
private PackageResolverInterface $packageResolver;
3129
private HttpClientInterface $httpClient;
3230
private ImportMapAuditor $importMapAuditor;
3331

3432
protected function setUp(): void
3533
{
3634
$this->importMapConfigReader = $this->createMock(ImportMapConfigReader::class);
37-
$this->packageResolver = $this->createMock(PackageResolverInterface::class);
3835
$this->httpClient = new MockHttpClient();
39-
$this->importMapAuditor = new ImportMapAuditor($this->importMapConfigReader, $this->packageResolver, $this->httpClient);
36+
$this->importMapAuditor = new ImportMapAuditor($this->importMapConfigReader, $this->httpClient);
4037
}
4138

4239
public function testAudit()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy