|
9 | 9 | use Symfony\Component\Finder\Finder;
|
10 | 10 |
|
11 | 11 | $finder = (new Finder())
|
12 |
| - ->in([__DIR__.'/../src/*/', __DIR__.'/../src/*/src/Bridge/*/']) |
| 12 | + ->in([__DIR__.'/../src/*/', __DIR__.'/../src/*/src/Bridge/*/', __DIR__.'/../ux.symfony.com/']) |
13 | 13 | ->depth(0)
|
14 | 14 | ->name('composer.json')
|
15 | 15 | ;
|
16 | 16 |
|
| 17 | +// 1. Find all UX packages |
| 18 | +$uxPackages = []; |
17 | 19 | foreach ($finder as $composerFile) {
|
18 | 20 | $json = file_get_contents($composerFile->getPathname());
|
19 | 21 | if (null === $packageData = json_decode($json, true)) {
|
20 | 22 | passthru(sprintf('composer validate %s', $composerFile->getPathname()));
|
21 | 23 | exit(1);
|
22 | 24 | }
|
23 | 25 |
|
24 |
| - $repositories = []; |
| 26 | + if (str_starts_with($composerFile->getPathname(), __DIR__ . '/../src/')) { |
| 27 | + $packageName = $packageData['name']; |
25 | 28 |
|
26 |
| - if (isset($packageData['require']['symfony/ux-twig-component']) |
27 |
| - || isset($packageData['require-dev']['symfony/ux-twig-component']) |
28 |
| - ) { |
29 |
| - $repositories[] = [ |
30 |
| - 'type' => 'path', |
31 |
| - 'url' => '../TwigComponent', |
| 29 | + $uxPackages[$packageName] = [ |
| 30 | + 'path' => realpath($composerFile->getPath()), |
32 | 31 | ];
|
33 |
| - $key = isset($packageData['require']['symfony/ux-twig-component']) ? 'require' : 'require-dev'; |
34 |
| - $packageData[$key]['symfony/ux-twig-component'] = '@dev'; |
35 | 32 | }
|
| 33 | +} |
36 | 34 |
|
37 |
| - if (isset($packageData['require']['symfony/stimulus-bundle']) |
38 |
| - || isset($packageData['require-dev']['symfony/stimulus-bundle']) |
39 |
| - ) { |
40 |
| - $repositories[] = [ |
41 |
| - 'type' => 'path', |
42 |
| - 'url' => '../StimulusBundle', |
43 |
| - ]; |
44 |
| - $key = isset($packageData['require']['symfony/stimulus-bundle']) ? 'require' : 'require-dev'; |
45 |
| - $packageData[$key]['symfony/stimulus-bundle'] = '@dev'; |
| 35 | +// 2. Update all composer.json files from the repository, to use the local version of the UX packages |
| 36 | +foreach ($finder as $composerFile) { |
| 37 | + $json = file_get_contents($composerFile->getPathname()); |
| 38 | + if (null === $packageData = json_decode($json, true)) { |
| 39 | + passthru(sprintf('composer validate %s', $composerFile->getPathname())); |
| 40 | + exit(1); |
46 | 41 | }
|
47 |
| - |
48 |
| - if (isset($packageData['require']['symfony/ux-map']) |
49 |
| - || isset($packageData['require-dev']['symfony/ux-map']) |
50 |
| - ) { |
51 |
| - $repositories[] = [ |
52 |
| - 'type' => 'path', |
53 |
| - 'url' => '../../../', |
54 |
| - ]; |
55 |
| - $key = isset($packageData['require']['symfony/ux-map']) ? 'require' : 'require-dev'; |
56 |
| - $packageData[$key]['symfony/ux-map'] = '@dev'; |
| 42 | + |
| 43 | + $repositories = $packageData['repositories'] ?? []; |
| 44 | + |
| 45 | + foreach ($uxPackages as $packageName => $packageInfo) { |
| 46 | + if (isset($packageData['require'][$packageName]) |
| 47 | + || isset($packageData['require-dev'][$packageName]) |
| 48 | + ) { |
| 49 | + $repositories[] = [ |
| 50 | + 'type' => 'path', |
| 51 | + 'url' => $packageInfo['path'], |
| 52 | + ]; |
| 53 | + $key = isset($packageData['require'][$packageName]) ? 'require' : 'require-dev'; |
| 54 | + $packageData[$key][$packageName] = '@dev'; |
| 55 | + } |
57 | 56 | }
|
58 | 57 |
|
59 | 58 | if ($repositories) {
|
|
0 commit comments