From b1776b79c874044f527f3adbf48946ced8eec840 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Thu, 21 May 2020 03:51:28 +0530 Subject: [PATCH] Add support for phan/phan --- README.md | 2 +- __tests__/tools.test.ts | 8 +++++++- dist/index.js | 4 ++++ src/scripts/darwin.sh | 3 +++ src/scripts/linux.sh | 3 +++ src/scripts/win32.ps1 | 5 ++++- src/tools.ts | 4 ++++ 7 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4bad5564..9e131d46 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ with: 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 uses: shivammathur/setup-php@v2 diff --git a/__tests__/tools.test.ts b/__tests__/tools.test.ts index 8a16d45c..07c2394e 100644 --- a/__tests__/tools.test.ts +++ b/__tests__/tools.test.ts @@ -391,7 +391,7 @@ describe('Tools tests', () => { }); it('checking addTools on darwin', async () => { 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', 'darwin' ); @@ -408,6 +408,9 @@ describe('Tools tests', () => { expect(script).toContain( '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( '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 flex flex symfony/'); 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( 'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive' ); diff --git a/dist/index.js b/dist/index.js index 012c0eeb..b9525f03 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1987,6 +1987,10 @@ async function addTools(tools_csv, php_version, os_version) { url = github + 'squizlabs/PHP_CodeSniffer/' + uri; script += await addArchive(tool, version, url, os_version); break; + case 'phan': + url = github + 'phan/phan/' + uri; + script += await addArchive(tool, version, url, os_version); + break; case 'phive': script += await addPhive(version, os_version); break; diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 451ba1b6..3cae05a0 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -118,6 +118,9 @@ add_tool() { if [ -n "$COMPOSER_TOKEN" ]; then composer -q global config github-oauth.github.com "$COMPOSER_TOKEN" 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 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 diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index bcc8dfe7..af177f2d 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -219,6 +219,9 @@ add_tool() { fi elif [ "$tool" = "cs2pr" ]; then 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 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 diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 18791125..1964589a 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -165,7 +165,10 @@ Function Add-Tool() { Add-Content -Path $current_profile -Value "New-Alias $tool $php_dir\$tool.bat" >$null 2>&1 } 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 } elseif($tool -eq "cs2pr") { (Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr diff --git a/src/tools.ts b/src/tools.ts index 65a2c311..828f85cc 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -463,6 +463,10 @@ export async function addTools( url = github + 'squizlabs/PHP_CodeSniffer/' + uri; script += await addArchive(tool, version, url, os_version); break; + case 'phan': + url = github + 'phan/phan/' + uri; + script += await addArchive(tool, version, url, os_version); + break; case 'phive': script += await addPhive(version, os_version); break;