diff --git a/src/Tasks/UpdatePackageInfoTask.php b/src/Tasks/UpdatePackageInfoTask.php index a0230d2..33cea9f 100644 --- a/src/Tasks/UpdatePackageInfoTask.php +++ b/src/Tasks/UpdatePackageInfoTask.php @@ -217,8 +217,8 @@ public function getPackageInfo($packageList) } /** - * Return an array of supported modules as fetched from silverstripe/supported-modules. Outputs a message and returns null - * if an error occurs + * Return an array of supported modules as fetched from silverstripe/supported-modules. + * Outputs a message and returns null if an error occurs * * @return null|array */ @@ -234,8 +234,8 @@ public function getSupportedPackages() } /** - * Return an array of module health information as fetched from addons.silverstripe.org. Outputs a message and - * returns null if an error occurs + * Return an array of module health information as fetched from addons.silverstripe.org. + * Outputs a message and returns null if an error occurs * * @param string[] $moduleNames * @return null|array diff --git a/src/Util/ApiLoader.php b/src/Util/ApiLoader.php index 17c391a..fda231a 100644 --- a/src/Util/ApiLoader.php +++ b/src/Util/ApiLoader.php @@ -75,7 +75,11 @@ public function doRequest($endpoint, callable $callback) $responseJson = $this->parseResponseContents($response->getBody()->getContents(), $failureMessage); if (str_contains($endpoint, 'addons.silverstripe.org')) { - Deprecation::notice('3.2.0', 'addons.silverstripe.org is no longer operational. Use packagist instead.', Deprecation::SCOPE_GLOBAL); + Deprecation::notice( + '3.2.0', + 'addons.silverstripe.org is no longer operational. Use packagist instead.', + Deprecation::SCOPE_GLOBAL + ); if (!isset($responseJson['success']) || !$responseJson['success']) { throw new RuntimeException($failureMessage . 'Response returned unsuccessfully'); } diff --git a/src/Util/SupportedAddonsLoader.php b/src/Util/SupportedAddonsLoader.php index 7ade8cd..a3d11f3 100644 --- a/src/Util/SupportedAddonsLoader.php +++ b/src/Util/SupportedAddonsLoader.php @@ -14,9 +14,12 @@ class SupportedAddonsLoader extends ApiLoader */ public function getAddonNames() { - $endpoint = 'https://raw.githubusercontent.com/silverstripe/supported-modules/5/modules.json'; + $endpoint = 'https://raw.githubusercontent.com/silverstripe/supported-modules/main/repositories.json'; return $this->doRequest($endpoint, function ($responseJson) { - return array_map(fn(array $item) => $item['composer'], $responseJson); + return array_filter(array_map( + fn(array $item) => isset($item['majorVersionMapping'][5]) ? $item['packagist'] : null, + $responseJson['supportedModules'] + )); }); } diff --git a/tests/Util/SupportedAddonsLoaderTest.php b/tests/Util/SupportedAddonsLoaderTest.php index 084d53a..413544f 100644 --- a/tests/Util/SupportedAddonsLoaderTest.php +++ b/tests/Util/SupportedAddonsLoaderTest.php @@ -23,7 +23,7 @@ protected function setUp(): void public function testCallsSupportedAddonsEndpoint() { - $endpoint = 'https://raw.githubusercontent.com/silverstripe/supported-modules/5/modules.json'; + $endpoint = 'https://raw.githubusercontent.com/silverstripe/supported-modules/main/repositories.json'; $this->loader->expects($this->once()) ->method('doRequest') ->with($endpoint, function () { @@ -42,11 +42,57 @@ public function testCallbackReturnsAddonsFromBody() $result = $this->loader->getAddonNames(); $mockResponse = [ - [ - 'composer' => 'foo/bar' + 'supportedModules' => [ + [ + 'github' => 'some/repo1', + 'packagist' => 'foo/bar', + 'majorVersionMapping' => [ + 4 => [4], + 5 => [5], + ], + ], + [ + 'github' => 'some/repo2', + 'packagist' => 'bin/baz', + 'majorVersionMapping' => [ + 5 => [5, 6], + ], + ], + [ + 'github' => 'some/repo3', + 'packagist' => 'bin/baz2', + 'majorVersionMapping' => [ + 4 => [4], + ], + ], ], - [ - 'composer' => 'bin/baz' + 'workflow' => [ + [ + 'github' => 'some/repo4', + 'packagist' => 'bin/baz1', + 'majorVersionMapping' => [ + 4 => [4], + 5 => [5], + ], + ], + ], + 'tooling' => [ + [ + 'github' => 'some/repo5', + 'packagist' => 'bin/baz2', + 'majorVersionMapping' => [ + 5 => [5, 6], + ], + ], + ], + 'misc' => [ + [ + 'github' => 'some/repo6', + 'packagist' => 'bin/baz3', + 'majorVersionMapping' => [ + 4 => [4], + ], + ], ], ];