Use GitHub releases for phive's latest version

This commit is contained in:
Shivam Mathur 2021-12-13 07:47:57 +05:30
parent 1b4cc0b6fa
commit 15b20027cf
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
4 changed files with 23 additions and 27 deletions

View File

@ -227,7 +227,7 @@ describe('Tools tests', () => {
it.each` it.each`
version | php_version | os_version | script version | php_version | os_version | script
${'latest'} | ${'7.4'} | ${'linux'} | ${'add_tool https://phar.io/releases/phive.phar phive'} ${'latest'} | ${'7.4'} | ${'linux'} | ${'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive'}
${'1.2.3'} | ${'7.4'} | ${'darwin'} | ${'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'} ${'1.2.3'} | ${'7.4'} | ${'darwin'} | ${'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'}
${'1.2.3'} | ${'7.2'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.14.5/phive-0.14.5.phar phive'} ${'1.2.3'} | ${'7.2'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.14.5/phive-0.14.5.phar phive'}
${'1.2.3'} | ${'7.1'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.5/phive-0.13.5.phar phive'} ${'1.2.3'} | ${'7.1'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.5/phive-0.13.5.phar phive'}
@ -238,7 +238,6 @@ describe('Tools tests', () => {
async ({version, php_version, os_version, script}) => { async ({version, php_version, os_version, script}) => {
const data = getData({ const data = getData({
tool: 'phive', tool: 'phive',
domain: 'https://phar.io',
repository: 'phar-io/phive', repository: 'phar-io/phive',
version_parameter: 'status', version_parameter: 'status',
version: version, version: version,
@ -391,7 +390,7 @@ describe('Tools tests', () => {
'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"', 'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"',
'add_composertool phinx phinx robmorgan/', 'add_composertool phinx phinx robmorgan/',
'add_composertool phinx phinx:1.2.3 robmorgan/', 'add_composertool phinx phinx:1.2.3 robmorgan/',
'add_tool https://phar.io/releases/phive.phar phive "status"', 'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive "status"',
'add_composertool phpunit-bridge phpunit-bridge symfony/', 'add_composertool phpunit-bridge phpunit-bridge symfony/',
'add_composertool phpunit-polyfills phpunit-polyfills yoast/', 'add_composertool phpunit-polyfills phpunit-polyfills yoast/',
'add_devtools php-config', 'add_devtools php-config',

10
dist/index.js vendored
View File

@ -724,26 +724,24 @@ async function addPhive(data) {
case /5\.[3-5]/.test(data['php_version']): case /5\.[3-5]/.test(data['php_version']):
return await utils.addLog('$cross', 'phive', 'Phive is not supported on PHP ' + data['php_version'], data['os_version']); return await utils.addLog('$cross', 'phive', 'Phive is not supported on PHP ' + data['php_version'], data['os_version']);
case /5\.6|7\.0/.test(data['php_version']): case /5\.6|7\.0/.test(data['php_version']):
data['version'] = data['version'].replace('latest', '0.12.1'); data['version'] = '0.12.1';
break; break;
case /7\.1/.test(data['php_version']): case /7\.1/.test(data['php_version']):
data['version'] = data['version'].replace('latest', '0.13.5'); data['version'] = '0.13.5';
break; break;
case /7\.2/.test(data['php_version']): case /7\.2/.test(data['php_version']):
data['version'] = data['version'].replace('latest', '0.14.5'); data['version'] = '0.14.5';
break; break;
} }
if (data['version'] === 'latest') { if (data['version'] === 'latest') {
data['domain'] = data['domain'] + '/releases'; data['version'] = await getLatestVersion(data);
} }
else {
data['domain'] = [ data['domain'] = [
data['github'], data['github'],
data['repository'], data['repository'],
'releases/download', 'releases/download',
data['version'] data['version']
].join('/'); ].join('/');
}
data['url'] = await getPharUrl(data); data['url'] = await getPharUrl(data);
return await addArchive(data); return await addArchive(data);
} }

View File

@ -205,7 +205,7 @@
"phive": { "phive": {
"type": "custom-function", "type": "custom-function",
"repository": "phar-io/phive", "repository": "phar-io/phive",
"domain": "https://phar.io", "domain": "https://github.com",
"function": "phive", "function": "phive",
"version_prefix": "", "version_prefix": "",
"version_parameter": "status" "version_parameter": "status"

View File

@ -319,25 +319,24 @@ export async function addPhive(data: RS): Promise<string> {
data['os_version'] data['os_version']
); );
case /5\.6|7\.0/.test(data['php_version']): case /5\.6|7\.0/.test(data['php_version']):
data['version'] = data['version'].replace('latest', '0.12.1'); data['version'] = '0.12.1';
break; break;
case /7\.1/.test(data['php_version']): case /7\.1/.test(data['php_version']):
data['version'] = data['version'].replace('latest', '0.13.5'); data['version'] = '0.13.5';
break; break;
case /7\.2/.test(data['php_version']): case /7\.2/.test(data['php_version']):
data['version'] = data['version'].replace('latest', '0.14.5'); data['version'] = '0.14.5';
break; break;
} }
if (data['version'] === 'latest') { if (data['version'] === 'latest') {
data['domain'] = data['domain'] + '/releases'; data['version'] = await getLatestVersion(data);
} else { }
data['domain'] = [ data['domain'] = [
data['github'], data['github'],
data['repository'], data['repository'],
'releases/download', 'releases/download',
data['version'] data['version']
].join('/'); ].join('/');
}
data['url'] = await getPharUrl(data); data['url'] = await getPharUrl(data);
return await addArchive(data); return await addArchive(data);
} }