diff --git a/README.md b/README.md index a1266843..ff21388d 100644 --- a/README.md +++ b/README.md @@ -669,4 +669,4 @@ If this action helped you. - [About GitHub Actions](https://github.com/features/actions "GitHub Actions") - [GitHub Actions Syntax](https://help.github.com/en/articles/workflow-syntax-for-github-actions "GitHub Actions Syntax") -- [Other Awesome Actions](https://github.com/sdras/awesome-actions "List of Awesome GitHub Actions") +- [Other Awesome Actions](https://github.com/sdras/awesome-actions "List of Awesome GitHub Actions") \ No newline at end of file diff --git a/__tests__/tools.test.ts b/__tests__/tools.test.ts index aa261a46..c27b00d3 100644 --- a/__tests__/tools.test.ts +++ b/__tests__/tools.test.ts @@ -446,11 +446,39 @@ 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', + 'composer-unused', + '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, composer-unused, 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' @@ -516,11 +544,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' @@ -555,11 +602,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' ); @@ -570,11 +624,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 e1f020ce..d11cf2a2 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; @@ -2316,54 +2329,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); @@ -2371,34 +2336,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 53670269..c5ed8a56 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; @@ -497,54 +515,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); @@ -552,39 +522,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);