mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-09-08 05:44:07 +07:00
Add fallback for the manifest URL
This commit is contained in:
17
src/utils.ts
17
src/utils.ts
@ -48,8 +48,11 @@ export async function getInput(
|
||||
/**
|
||||
* Function to get manifest URL
|
||||
*/
|
||||
export async function getManifestURL(): Promise<string> {
|
||||
return 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/php-versions.json';
|
||||
export async function getManifestURLS(): Promise<string[]> {
|
||||
return [
|
||||
'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/php-versions.json',
|
||||
'https://setup-php.com/php-versions.json'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,9 +63,13 @@ export async function getManifestURL(): Promise<string> {
|
||||
export async function parseVersion(version: string): Promise<string> {
|
||||
switch (true) {
|
||||
case /^(latest|lowest|highest|nightly|\d+\.x)$/.test(version):
|
||||
return JSON.parse((await fetch.fetch(await getManifestURL()))['data'])[
|
||||
version
|
||||
];
|
||||
for (const manifestURL of await getManifestURLS()) {
|
||||
const fetchResult = await fetch.fetch(manifestURL);
|
||||
if (fetchResult['data'] ?? false) {
|
||||
return JSON.parse(fetchResult['data'])[version];
|
||||
}
|
||||
}
|
||||
throw new Error(`Could not fetch the PHP version manifest.`);
|
||||
default:
|
||||
switch (true) {
|
||||
case version.length > 1:
|
||||
|
Reference in New Issue
Block a user