Skip to content

Commit 1376339

Browse files
committed
Flex recipe should always be installed first
1 parent e9a1e59 commit 1376339

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

src/Flex.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,10 @@ public function fetchRecipes(array $operations, bool $reset): array
702702
$data = $this->downloader->getRecipes($operations);
703703
$manifests = $data['manifests'] ?? [];
704704
$locks = $data['locks'] ?? [];
705-
// symfony/flex and symfony/framework-bundle recipes should always be applied first
705+
// symfony/flex recipes should always be applied first
706+
$flexRecipe = [];
707+
// symfony/framework-bundle recipe should always be applied first after the metapackages
706708
$recipes = [
707-
'symfony/flex' => null,
708709
'symfony/framework-bundle' => null,
709710
];
710711
$metaRecipes = [];
@@ -748,6 +749,8 @@ public function fetchRecipes(array $operations, bool $reset): array
748749
if (isset($manifests[$name])) {
749750
if ('metapackage' === $package->getType()) {
750751
$metaRecipes[$name] = new Recipe($package, $name, $job, $manifests[$name], $locks[$name] ?? []);
752+
} elseif ('symfony/flex' === $name) {
753+
$flexRecipe = [$name => new Recipe($package, $name, $job, $manifests[$name], $locks[$name] ?? [])];
751754
} else {
752755
$recipes[$name] = new Recipe($package, $name, $job, $manifests[$name], $locks[$name] ?? []);
753756
}
@@ -775,7 +778,7 @@ public function fetchRecipes(array $operations, bool $reset): array
775778
}
776779
}
777780

778-
return array_merge($metaRecipes, array_filter($recipes));
781+
return array_merge($flexRecipe, $metaRecipes, array_filter($recipes));
779782
}
780783

781784
public function truncatePackages(PrePoolCreateEvent $event)

tests/FlexTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,41 @@ public function getPackagesForAutoDiscovery(): array
178178
return $return;
179179
}
180180

181+
public function testFetchRecipesOrder()
182+
{
183+
$packages = [
184+
['name' => 'symfony/console', 'type' => 'library'],
185+
['name' => 'symfony/flex', 'type' => 'composer-plugin'],
186+
['name' => 'symfony/framework-bundle', 'type' => 'library'],
187+
['name' => 'symfony/webapp-meta', 'type' => 'metapackage'],
188+
];
189+
190+
$io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE);
191+
$rootPackage = $this->mockRootPackage(['symfony' => ['allow-contrib' => true]]);
192+
193+
$flex = $this->mockFlex($io, $rootPackage, null, [
194+
'manifests' => array_reduce($packages, static function (array $manifests, array $packageInfo) {
195+
$manifests[$packageInfo['name']] = ['manifest' => []];
196+
197+
return $manifests;
198+
}, []),
199+
]);
200+
201+
$recipes = $flex->fetchRecipes(array_map(static function (array $packageInfo) {
202+
$package = new Package($packageInfo['name'], '1.0.0', '1.0.0');
203+
$package->setType($packageInfo['type']);
204+
205+
return new InstallOperation($package);
206+
}, $packages), true);
207+
208+
$this->assertSame([
209+
'symfony/flex',
210+
'symfony/webapp-meta',
211+
'symfony/framework-bundle',
212+
'symfony/console',
213+
], array_keys($recipes));
214+
}
215+
181216
public static function getTestPackages(): array
182217
{
183218
return [

0 commit comments

Comments
 (0)