Skip to content

Commit 8819ea9

Browse files
committed
minor #60601 switch to Composer 2 metadata (xabbuh)
This PR was merged into the 6.4 branch. Discussion ---------- switch to Composer 2 metadata | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The Composer 1 metadata are no longer up-to-date and the legacy API will be turned off in August anyway: https://blog.packagist.com/shutting-down-packagist-org-support-for-composer-1-x/ Commits ------- 43a549b switch to Composer 2 metadata
2 parents 15145c7 + 43a549b commit 8819ea9

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

.github/build-packages.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
require __DIR__.'/vendor/autoload.php';
4+
5+
use Composer\MetadataMinifier\MetadataMinifier;
6+
37
if (3 > $_SERVER['argc']) {
48
echo "Usage: branch version dir1 dir2 ... dirN\n";
59
exit(1);
@@ -52,11 +56,23 @@
5256

5357
$packages[$package->name][$package->version] = $package;
5458

55-
$versions = @file_get_contents('https://repo.packagist.org/p/'.$package->name.'.json') ?: sprintf('{"packages":{"%s":{"%s":%s}}}', $package->name, $package->version, file_get_contents($dir.'/composer.json'));
56-
$versions = json_decode($versions)->packages->{$package->name};
59+
if (false !== $taggedReleases = @file_get_contents('https://repo.packagist.org/p2/'.$package->name.'.json')) {
60+
$versions = MetadataMinifier::expand(json_decode($taggedReleases, true)['packages'][$package->name]);
61+
62+
foreach ($versions as $v => $p) {
63+
$packages[$package->name] += [$v => $p];
64+
}
65+
}
66+
67+
if (false !== $devReleases = @file_get_contents('https://repo.packagist.org/p2/'.$package->name.'~dev.json')) {
68+
$versions = MetadataMinifier::expand(json_decode($taggedReleases, true)['packages'][$package->name]);
69+
} else {
70+
$versions = sprintf('{"packages":{"%s":{"%s":%s}}}', $package->name, $package->version, file_get_contents($dir.'/composer.json'));
71+
$versions = json_decode($versions, true)['packages'][$package->name];
72+
}
5773

58-
foreach ($versions as $v => $package) {
59-
$packages[$package->name] += [$v => $package];
74+
foreach ($versions as $v => $p) {
75+
$packages[$package->name] += [$v => $p];
6076
}
6177
}
6278

.github/composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"composer/metadata-minifier": "^1.0"
4+
}
5+
}

.github/workflows/unit-tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,18 @@ jobs:
9292
9393
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
9494
if [[ ! "${{ matrix.mode }}" = *-deps ]]; then
95-
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
95+
cd .github
96+
composer install
97+
php ./build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
98+
cd ..
9699
else
97100
echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV
98101
cp composer.json composer.json.orig
99102
echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json
100-
php .github/build-packages.php HEAD^ $SYMFONY_VERSION $(find src/Symfony -mindepth 2 -type f -name composer.json -printf '%h\n' | grep -v src/Symfony/Component/Intl/Resources/emoji)
103+
cd .github
104+
composer install
105+
php ./build-packages.php HEAD^ $SYMFONY_VERSION $(find src/Symfony -mindepth 2 -type f -name composer.json -printf '%h\n' | grep -v src/Symfony/Component/Intl/Resources/emoji)
106+
cd ..
101107
mv composer.json composer.json.phpunit
102108
mv composer.json.orig composer.json
103109
fi

0 commit comments

Comments
 (0)