diff --git a/README.md b/README.md index d5756c36..cc5b8fa2 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ with: These tools can be setup globally using the `tools` input. -`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-normalize`, `composer-prefetcher`, `composer-require-checker`,`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` +`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-normalize`, `composer-prefetcher`, `composer-require-checker`, `cs2pr`, `deployer`, `flex`, `infection`, `pecl`, `phan`, `phinx`, `phive`, `php-config`, `php-cs-fixer`, `phpcbf`, `phpcpd`, `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 bb6cb722..03bf1ee7 100644 --- a/__tests__/tools.test.ts +++ b/__tests__/tools.test.ts @@ -446,11 +446,38 @@ describe('Tools tests', () => { expect(script).toContain('add_log "$tick" "phpize" "Added"'); }); it('checking addTools on darwin', async () => { + const listOfTools = [ + 'blackfire', + 'blackfire-player', + 'composer-normalize', + 'composer-prefetcher:1.2.3', + 'composer-require-checker', + 'cs2pr:1.2.3', + 'flex', + 'infection', + 'phan', + 'phan:2.7.2', + 'phinx', + 'phive:1.2.3', + 'php-config', + 'phpcbf', + 'phpcpd', + 'phpcs', + 'phpize', + 'phpmd', + 'psalm', + 'symfony', + 'symfony:1.2.3', + 'vapor-cli', + 'wp-cli' + ]; + const script: string = await tools.addTools( - 'blackfire, blackfire-player, composer-normalize, composer-require-checker, 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', + listOfTools.join(', '), '7.4', 'darwin' ); + expect(script).toContain('add_blackfire'); expect(script).toContain( 'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player' @@ -513,11 +540,30 @@ describe('Tools tests', () => { expect(script).toContain('add_log "$tick" "php-config" "Added"'); }); it('checking addTools on windows', async () => { + const listOfTools = [ + 'blackfire', + 'blackfire-player:1.8.1', + 'codeception', + 'cs2pr', + 'deployer', + 'does_not_exit', + 'flex', + 'phinx', + 'phive:0.13.2', + 'php-config', + 'phpize', + 'phpmd', + 'prestissimo', + 'symfony', + 'wp-cli' + ]; + const script: string = await tools.addTools( - 'blackfire, blackfire-player:1.8.1, codeception, cs2pr, deployer, flex, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, wp-cli, does_not_exit', + listOfTools.join(', '), '7.4', 'win32' ); + expect(script).toContain('Add-Blackfire'); expect(script).toContain( 'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player' @@ -552,11 +598,18 @@ describe('Tools tests', () => { expect(script).toContain('Tool does_not_exit is not supported'); }); it('checking addTools with composer tool using user/tool as input', async () => { + const listOfTools = [ + 'hirak/prestissimo', + 'narrowspark/automatic-composer-prefetcher', + 'robmorgan/phinx' + ]; + const script: string = await tools.addTools( - 'hirak/prestissimo, narrowspark/automatic-composer-prefetcher, robmorgan/phinx', + listOfTools.join(', '), '7.4', 'win32' ); + expect(script).toContain( 'Add-Tool https://getcomposer.org/composer-stable.phar composer' ); @@ -567,11 +620,14 @@ describe('Tools tests', () => { ); }); it('checking composer setup', async () => { + const listOfTools = ['composer', 'composer:v1']; + let script: string = await tools.addTools( - 'composer, composer:v1', + listOfTools.join(', '), '7.4', 'linux' ); + expect(script).toContain( 'add_tool https://getcomposer.org/composer-1.phar composer' ); diff --git a/dist/index.js b/dist/index.js index b8a24625..b3c0786d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2296,11 +2296,24 @@ async function addTools(tools_csv, php_version, os_version) { url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); script += await addArchive(tool, version, url, os_version); break; + case 'codeception': + url = + 'https://codeception.com/' + + (await getCodeceptionUri(version, php_version)); + script += await addArchive(tool, version, url, os_version); + break; + case 'composer': + url = await getComposerUrl(version); + script += await addArchive('composer', version, url, os_version); + break; case 'composer-normalize': uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); url = github + 'ergebnis/composer-normalize/' + uri; script += await addArchive(tool, version, url, os_version); break; + case 'composer-prefetcher': + script += await addPackage(tool, release, 'narrowspark/automatic-', os_version); + break; case 'composer-require-checker': uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); url = github + 'maglnet/ComposerRequireChecker/' + uri; @@ -2311,54 +2324,6 @@ async function addTools(tools_csv, php_version, os_version) { url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri; script += await addArchive(tool, version, url, os_version); break; - case 'infection': - url = github + 'infection/infection/' + uri; - script += await addArchive(tool, version, url, os_version); - break; - case 'php-cs-fixer': - uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download'); - url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri; - script += await addArchive(tool, version, url, os_version); - break; - case 'phpcs': - case 'phpcbf': - 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; - case 'phpstan': - url = github + 'phpstan/phpstan/' + uri; - script += await addArchive(tool, version, url, os_version); - break; - case 'phpmd': - url = github + 'phpmd/phpmd/' + uri; - script += await addArchive(tool, version, url, os_version); - break; - case 'psalm': - url = github + 'vimeo/psalm/' + uri; - script += await addArchive(tool, version, url, os_version); - break; - case 'composer': - url = await getComposerUrl(version); - script += await addArchive('composer', version, url, os_version); - break; - case 'codeception': - url = - 'https://codeception.com/' + - (await getCodeceptionUri(version, php_version)); - script += await addArchive(tool, version, url, os_version); - break; - case 'phpcpd': - case 'phpunit': - url = await getPharUrl('https://phar.phpunit.de', tool, '', version); - script += await addArchive(tool, version, url, os_version); - break; case 'deployer': url = await getDeployerUrl(version); script += await addArchive(tool, version, url, os_version); @@ -2366,34 +2331,69 @@ async function addTools(tools_csv, php_version, os_version) { case 'flex': script += await addPackage(tool, release, 'symfony/', os_version); break; - case 'phinx': - script += await addPackage(tool, release, 'robmorgan/', os_version); - break; - case 'phplint': - script += await addPackage(tool, release, 'overtrue/', os_version); - break; - case 'prestissimo': - script += await addPackage(tool, release, 'hirak/', os_version); - break; - case 'vapor-cli': - script += await addPackage(tool, release, 'laravel/', os_version); - break; - case 'composer-prefetcher': - script += await addPackage(tool, release, 'narrowspark/automatic-', os_version); + case 'infection': + url = github + 'infection/infection/' + uri; + script += await addArchive(tool, version, url, os_version); break; case 'pecl': script += await getCommand(os_version, 'pecl'); break; + case 'phan': + url = github + 'phan/phan/' + uri; + script += await addArchive(tool, version, url, os_version); + break; + case 'phinx': + script += await addPackage(tool, release, 'robmorgan/', os_version); + break; + case 'phive': + script += await addPhive(version, os_version); + break; case 'php-config': case 'phpize': script += await addDevTools(tool, os_version); break; + case 'php-cs-fixer': + uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download'); + url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri; + script += await addArchive(tool, version, url, os_version); + break; + case 'phpcbf': + case 'phpcs': + url = github + 'squizlabs/PHP_CodeSniffer/' + uri; + script += await addArchive(tool, version, url, os_version); + break; + case 'phpcpd': + case 'phpunit': + url = await getPharUrl('https://phar.phpunit.de', tool, '', version); + script += await addArchive(tool, version, url, os_version); + break; + case 'phplint': + script += await addPackage(tool, release, 'overtrue/', os_version); + break; + case 'phpmd': + url = github + 'phpmd/phpmd/' + uri; + script += await addArchive(tool, version, url, os_version); + break; + case 'phpstan': + url = github + 'phpstan/phpstan/' + uri; + script += await addArchive(tool, version, url, os_version); + break; + case 'prestissimo': + script += await addPackage(tool, release, 'hirak/', os_version); + break; + case 'psalm': + url = github + 'vimeo/psalm/' + uri; + script += await addArchive(tool, version, url, os_version); + break; case 'symfony': case 'symfony-cli': uri = await getSymfonyUri(version, os_version); url = github + 'symfony/cli/' + uri; script += await addArchive('symfony', version, url, os_version); break; + case 'vapor-cli': + script += await addPackage(tool, release, 'laravel/', os_version); + break; case 'wp-cli': url = github + (await getWpCliUrl(version)); script += await addArchive(tool, version, url, os_version); diff --git a/src/tools.ts b/src/tools.ts index 9ca0bc18..184b0174 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -477,11 +477,29 @@ export async function addTools( url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); script += await addArchive(tool, version, url, os_version); break; + case 'codeception': + url = + 'https://codeception.com/' + + (await getCodeceptionUri(version, php_version)); + script += await addArchive(tool, version, url, os_version); + break; + case 'composer': + url = await getComposerUrl(version); + script += await addArchive('composer', version, url, os_version); + break; case 'composer-normalize': uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); url = github + 'ergebnis/composer-normalize/' + uri; script += await addArchive(tool, version, url, os_version); break; + case 'composer-prefetcher': + script += await addPackage( + tool, + release, + 'narrowspark/automatic-', + os_version + ); + break; case 'composer-require-checker': uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); url = github + 'maglnet/ComposerRequireChecker/' + uri; @@ -492,54 +510,6 @@ export async function addTools( url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri; script += await addArchive(tool, version, url, os_version); break; - case 'infection': - url = github + 'infection/infection/' + uri; - script += await addArchive(tool, version, url, os_version); - break; - case 'php-cs-fixer': - uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download'); - url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri; - script += await addArchive(tool, version, url, os_version); - break; - case 'phpcs': - case 'phpcbf': - 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; - case 'phpstan': - url = github + 'phpstan/phpstan/' + uri; - script += await addArchive(tool, version, url, os_version); - break; - case 'phpmd': - url = github + 'phpmd/phpmd/' + uri; - script += await addArchive(tool, version, url, os_version); - break; - case 'psalm': - url = github + 'vimeo/psalm/' + uri; - script += await addArchive(tool, version, url, os_version); - break; - case 'composer': - url = await getComposerUrl(version); - script += await addArchive('composer', version, url, os_version); - break; - case 'codeception': - url = - 'https://codeception.com/' + - (await getCodeceptionUri(version, php_version)); - script += await addArchive(tool, version, url, os_version); - break; - case 'phpcpd': - case 'phpunit': - url = await getPharUrl('https://phar.phpunit.de', tool, '', version); - script += await addArchive(tool, version, url, os_version); - break; case 'deployer': url = await getDeployerUrl(version); script += await addArchive(tool, version, url, os_version); @@ -547,39 +517,69 @@ export async function addTools( case 'flex': script += await addPackage(tool, release, 'symfony/', os_version); break; - case 'phinx': - script += await addPackage(tool, release, 'robmorgan/', os_version); - break; - case 'phplint': - script += await addPackage(tool, release, 'overtrue/', os_version); - break; - case 'prestissimo': - script += await addPackage(tool, release, 'hirak/', os_version); - break; - case 'vapor-cli': - script += await addPackage(tool, release, 'laravel/', os_version); - break; - case 'composer-prefetcher': - script += await addPackage( - tool, - release, - 'narrowspark/automatic-', - os_version - ); + case 'infection': + url = github + 'infection/infection/' + uri; + script += await addArchive(tool, version, url, os_version); break; case 'pecl': script += await getCommand(os_version, 'pecl'); break; + case 'phan': + url = github + 'phan/phan/' + uri; + script += await addArchive(tool, version, url, os_version); + break; + case 'phinx': + script += await addPackage(tool, release, 'robmorgan/', os_version); + break; + case 'phive': + script += await addPhive(version, os_version); + break; case 'php-config': case 'phpize': script += await addDevTools(tool, os_version); break; + case 'php-cs-fixer': + uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download'); + url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri; + script += await addArchive(tool, version, url, os_version); + break; + case 'phpcbf': + case 'phpcs': + url = github + 'squizlabs/PHP_CodeSniffer/' + uri; + script += await addArchive(tool, version, url, os_version); + break; + case 'phpcpd': + case 'phpunit': + url = await getPharUrl('https://phar.phpunit.de', tool, '', version); + script += await addArchive(tool, version, url, os_version); + break; + case 'phplint': + script += await addPackage(tool, release, 'overtrue/', os_version); + break; + case 'phpmd': + url = github + 'phpmd/phpmd/' + uri; + script += await addArchive(tool, version, url, os_version); + break; + case 'phpstan': + url = github + 'phpstan/phpstan/' + uri; + script += await addArchive(tool, version, url, os_version); + break; + case 'prestissimo': + script += await addPackage(tool, release, 'hirak/', os_version); + break; + case 'psalm': + url = github + 'vimeo/psalm/' + uri; + script += await addArchive(tool, version, url, os_version); + break; case 'symfony': case 'symfony-cli': uri = await getSymfonyUri(version, os_version); url = github + 'symfony/cli/' + uri; script += await addArchive('symfony', version, url, os_version); break; + case 'vapor-cli': + script += await addPackage(tool, release, 'laravel/', os_version); + break; case 'wp-cli': url = github + (await getWpCliUrl(version)); script += await addArchive(tool, version, url, os_version);