Add support for phan/phan

This commit is contained in:
Shivam Mathur 2020-05-21 03:51:28 +05:30
parent a48ff666f8
commit b1776b79c8
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
7 changed files with 26 additions and 3 deletions

View File

@ -131,7 +131,7 @@ with:
These tools can be setup globally using the `tools` input. These tools can be setup globally using the `tools` input.
`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-prefetcher`, `cs2pr`, `deployer`, `flex`, `infection`, `pecl`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`, `symfony`, `vapor-cli` `blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-prefetcher`, `cs2pr`, `deployer`, `flex`, `infection`, `pecl`, `phan`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`, `symfony`, `vapor-cli`
```yaml ```yaml
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2

View File

@ -391,7 +391,7 @@ describe('Tools tests', () => {
}); });
it('checking addTools on darwin', async () => { it('checking addTools on darwin', async () => {
const script: string = await tools.addTools( const script: string = await tools.addTools(
'blackfire, blackfire-player, flex, infection, phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, vapor-cli, phive:1.2.3, cs2pr:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3, wp-cli', 'blackfire, blackfire-player, flex, infection, phan, phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, vapor-cli, phan:2.7.2, phive:1.2.3, cs2pr:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3, wp-cli',
'7.4', '7.4',
'darwin' 'darwin'
); );
@ -408,6 +408,9 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection' 'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection'
); );
expect(script).toContain(
'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs' 'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
); );
@ -426,6 +429,9 @@ describe('Tools tests', () => {
expect(script).toContain('add_composertool vapor-cli vapor-cli laravel/'); expect(script).toContain('add_composertool vapor-cli vapor-cli laravel/');
expect(script).toContain('add_composertool flex flex symfony/'); expect(script).toContain('add_composertool flex flex symfony/');
expect(script).toContain('add_composertool phinx phinx robmorgan/'); expect(script).toContain('add_composertool phinx phinx robmorgan/');
expect(script).toContain(
'add_tool https://github.com/phan/phan/releases/download/2.7.2/phan.phar phan'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive' 'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
); );

4
dist/index.js vendored
View File

@ -1987,6 +1987,10 @@ async function addTools(tools_csv, php_version, os_version) {
url = github + 'squizlabs/PHP_CodeSniffer/' + uri; url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, version, url, os_version);
break; break;
case 'phan':
url = github + 'phan/phan/' + uri;
script += await addArchive(tool, version, url, os_version);
break;
case 'phive': case 'phive':
script += await addPhive(version, os_version); script += await addPhive(version, os_version);
break; break;

View File

@ -118,6 +118,9 @@ add_tool() {
if [ -n "$COMPOSER_TOKEN" ]; then if [ -n "$COMPOSER_TOKEN" ]; then
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN" composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
fi fi
elif [ "$tool" = "phan" ]; then
add_extension fileinfo "sudo pecl install -f fileinfo" extension >/dev/null 2>&1
add_extension ast "sudo pecl install -f ast" extension >/dev/null 2>&1
elif [ "$tool" = "phive" ]; then elif [ "$tool" = "phive" ]; then
add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1 add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1
add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1 add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1

View File

@ -219,6 +219,9 @@ add_tool() {
fi fi
elif [ "$tool" = "cs2pr" ]; then elif [ "$tool" = "cs2pr" ]; then
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
elif [ "$tool" = "phan" ]; then
add_extension fileinfo "$apt_install php$version-fileinfo" extension >/dev/null 2>&1
add_extension ast "$apt_install php-ast" extension >/dev/null 2>&1
elif [ "$tool" = "phive" ]; then elif [ "$tool" = "phive" ]; then
add_extension curl "$apt_install php$version-curl" extension >/dev/null 2>&1 add_extension curl "$apt_install php$version-curl" extension >/dev/null 2>&1
add_extension mbstring "$apt_install php$version-mbstring" extension >/dev/null 2>&1 add_extension mbstring "$apt_install php$version-mbstring" extension >/dev/null 2>&1

View File

@ -165,7 +165,10 @@ Function Add-Tool() {
Add-Content -Path $current_profile -Value "New-Alias $tool $php_dir\$tool.bat" >$null 2>&1 Add-Content -Path $current_profile -Value "New-Alias $tool $php_dir\$tool.bat" >$null 2>&1
} catch { } } catch { }
} }
if($tool -eq "phive") { if($tool -eq "phan") {
Add-Extension fileinfo >$null 2>&1
Add-Extension ast >$null 2>&1
} elseif($tool -eq "phive") {
Add-Extension xml >$null 2>&1 Add-Extension xml >$null 2>&1
} elseif($tool -eq "cs2pr") { } elseif($tool -eq "cs2pr") {
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr (Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr

View File

@ -463,6 +463,10 @@ export async function addTools(
url = github + 'squizlabs/PHP_CodeSniffer/' + uri; url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, version, url, os_version);
break; break;
case 'phan':
url = github + 'phan/phan/' + uri;
script += await addArchive(tool, version, url, os_version);
break;
case 'phive': case 'phive':
script += await addPhive(version, os_version); script += await addPhive(version, os_version);
break; break;