diff --git a/__tests__/tools.test.ts b/__tests__/tools.test.ts index 6c7394dd..7185c883 100644 --- a/__tests__/tools.test.ts +++ b/__tests__/tools.test.ts @@ -2,28 +2,34 @@ import * as tools from '../src/tools'; describe('Tools tests', () => { it('checking getCommand', async () => { - expect(await tools.getArchiveCommand('linux')).toBe('add_tool '); - expect(await tools.getArchiveCommand('darwin')).toBe('add_tool '); - expect(await tools.getArchiveCommand('win32')).toBe('Add-Tool '); - expect(await tools.getArchiveCommand('fedora')).toContain( + expect(await tools.getCommand('linux', 'tool')).toBe('add_tool '); + expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool '); + expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool '); + expect(await tools.getCommand('fedora', 'tool')).toContain( 'Platform fedora is not supported' ); }); it('checking getCommand', async () => { - expect(await tools.getPackageCommand('linux')).toBe('add_composer_tool '); - expect(await tools.getPackageCommand('darwin')).toBe('add_composer_tool '); - expect(await tools.getPackageCommand('win32')).toBe('Add-Composer-Tool '); - expect(await tools.getPackageCommand('fedora')).toContain( + expect(await tools.getCommand('linux', 'composertool')).toBe( + 'add_composertool ' + ); + expect(await tools.getCommand('darwin', 'composertool')).toBe( + 'add_composertool ' + ); + expect(await tools.getCommand('win32', 'composertool')).toBe( + 'Add-Composertool ' + ); + expect(await tools.getCommand('fedora', 'composertool')).toContain( 'Platform fedora is not supported' ); }); - it('checking getPECLCommand', async () => { - expect(await tools.getPECLCommand('linux')).toBe('add_pecl '); - expect(await tools.getPECLCommand('darwin')).toBe('add_pecl '); - expect(await tools.getPECLCommand('win32')).toBe('Add-PECL '); - expect(await tools.getPECLCommand('fedora')).toContain( + it('checking getCommand', async () => { + expect(await tools.getCommand('linux', 'pecl')).toBe('add_pecl '); + expect(await tools.getCommand('darwin', 'pecl')).toBe('add_pecl '); + expect(await tools.getCommand('win32', 'pecl')).toBe('Add-Pecl '); + expect(await tools.getCommand('fedora', 'pecl')).toContain( 'Platform fedora is not supported' ); }); @@ -107,22 +113,13 @@ describe('Tools tests', () => { }); it('checking getCodeceptionUriBuilder', async () => { - expect(await tools.getCodeceptionUriBuilder('3.2.1', '5.6', 'php56')).toBe( + expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php56')).toBe( 'releases/3.2.1/php56/codecept.phar' ); - expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.0', 'php54')).toBe( + expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php54')).toBe( 'releases/3.2.1/php54/codecept.phar' ); - expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.1', 'php56')).toBe( - 'releases/3.2.1/php56/codecept.phar' - ); - expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.2', 'php56')).toBe( - 'releases/3.2.1/codecept.phar' - ); - expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.3', 'php56')).toBe( - 'releases/3.2.1/codecept.phar' - ); - expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.4', 'php56')).toBe( + expect(await tools.getCodeceptionUriBuilder('3.2.1', '')).toBe( 'releases/3.2.1/codecept.phar' ); }); @@ -146,17 +143,59 @@ describe('Tools tests', () => { expect(await tools.getCodeceptionUri('latest', '7.4')).toBe( 'codecept.phar' ); - expect(await tools.getCodeceptionUri('3.2.1', '5.6')).toBe( - 'releases/3.2.1/php54/codecept.phar' + expect(await tools.getCodeceptionUri('4.0.0', '7.4')).toBe( + 'releases/4.0.0/codecept.phar' ); - expect(await tools.getCodeceptionUri('4.3.2', '5.6')).toBe( - 'releases/4.3.2/php56/codecept.phar' + expect(await tools.getCodeceptionUri('4.0.0', '5.6')).toBe( + 'releases/4.0.0/php56/codecept.phar' ); - expect(await tools.getCodeceptionUri('3.2.1', '7.4')).toBe( - 'releases/3.2.1/codecept.phar' + expect(await tools.getCodeceptionUri('4.0.0', '7.1')).toBe( + 'releases/4.0.0/php56/codecept.phar' ); - expect(await tools.getCodeceptionUri('4.3.2', '7.4')).toBe( - 'releases/4.3.2/codecept.phar' + expect(await tools.getCodeceptionUri('3.1.0', '7.4')).toBe( + 'releases/3.1.0/codecept.phar' + ); + expect(await tools.getCodeceptionUri('3.1.0', '5.6')).toBe( + 'releases/3.1.0/php54/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.5.4', '7.4')).toBe( + 'releases/2.5.4/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.5.4', '5.6')).toBe( + 'releases/2.5.4/php54/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.3.4', '7.4')).toBe( + 'releases/2.3.4/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.3.4', '5.4')).toBe( + 'releases/2.3.4/php54/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.2.4', '5.6')).toBe( + 'releases/2.2.4/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.2.4', '7.4')).toBe( + 'releases/2.2.4/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.2.4', '5.4')).toBe( + 'releases/2.2.4/php54/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.1.7', '5.6')).toBe( + 'releases/2.1.7/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.1.7', '5.4')).toBe( + 'releases/2.1.7/php54/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.1.5', '5.4')).toBe( + 'releases/2.1.5/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.1.5', '7.4')).toBe( + 'releases/2.1.5/codecept.phar' + ); + expect(await tools.getCodeceptionUri('1.6.9', '7.4')).toBe( + 'releases/1.6.9/codecept.phar' + ); + expect(await tools.getCodeceptionUri('1.5.0', '7.4')).toBe( + 'releases/1.5.0/codecept.phar' ); }); @@ -173,11 +212,11 @@ describe('Tools tests', () => { }); it('checking getPhpunitUri', async () => { - expect(await tools.getPhpunitUrl('tool', 'latest')).toBe( - 'https://phar.phpunit.de/tool.phar' + expect(await tools.getPharUrl('domain', 'tool', '', 'latest')).toBe( + 'domain/tool.phar' ); - expect(await tools.getPhpunitUrl('tool', '1.2.3')).toBe( - 'https://phar.phpunit.de/tool-1.2.3.phar' + expect(await tools.getPharUrl('domain', 'tool', 'v', '1.2.3')).toBe( + 'domain/tool-v1.2.3.phar' ); }); @@ -190,7 +229,7 @@ describe('Tools tests', () => { ); }); - it('checking getDeployerUri', async () => { + it('checking addComposer', async () => { expect(await tools.addComposer(['a', 'b'])).toStrictEqual([ 'composer', 'a', @@ -311,13 +350,13 @@ describe('Tools tests', () => { 'user/', 'linux' ); - expect(script).toContain('add_composer_tool tool tool:1.2.3 user/'); + expect(script).toContain('add_composertool tool tool:1.2.3 user/'); script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'darwin'); - expect(script).toContain('add_composer_tool tool tool:1.2.3 user/'); + expect(script).toContain('add_composertool tool tool:1.2.3 user/'); script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32'); - expect(script).toContain('Add-Composer-Tool tool tool:1.2.3 user/'); + expect(script).toContain('Add-Composertool tool tool:1.2.3 user/'); script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'fedora'); expect(script).toContain('Platform fedora is not supported'); @@ -330,7 +369,7 @@ describe('Tools tests', () => { 'linux' ); expect(script).toContain( - 'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer' + 'add_tool https://getcomposer.org/composer-stable.phar composer' ); expect(script).toContain( 'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr' @@ -351,8 +390,8 @@ describe('Tools tests', () => { 'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony' ); expect(script).toContain('add_pecl'); - expect(script).toContain('add_composer_tool phinx phinx robmorgan/'); - expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/'); + expect(script).toContain('add_composertool phinx phinx robmorgan/'); + expect(script).toContain('add_composertool phinx phinx:1.2.3 robmorgan/'); expect(script).toContain('add_devtools'); expect(script).toContain('add_log "$tick" "php-config" "Added"'); expect(script).toContain('add_log "$tick" "phpize" "Added"'); @@ -364,7 +403,7 @@ describe('Tools tests', () => { 'darwin' ); expect(script).toContain( - 'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer' + 'add_tool https://getcomposer.org/composer-stable.phar composer' ); expect(script).toContain( 'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr' @@ -384,12 +423,12 @@ describe('Tools tests', () => { expect(script).toContain( 'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm' ); - expect(script).toContain('add_composer_tool phinx phinx robmorgan/'); + expect(script).toContain('add_composertool phinx phinx robmorgan/'); expect(script).toContain( 'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive' ); expect(script).toContain( - 'add_composer_tool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-' + 'add_composertool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-' ); expect(script).toContain( 'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony' @@ -407,7 +446,7 @@ describe('Tools tests', () => { 'win32' ); expect(script).toContain( - 'Add-Tool https://github.com/composer/composer/releases/latest/download/composer.phar composer' + 'Add-Tool https://getcomposer.org/composer-stable.phar composer' ); expect(script).toContain( 'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr' @@ -415,13 +454,11 @@ describe('Tools tests', () => { expect(script).toContain( 'Add-Tool https://deployer.org/deployer.phar deployer' ); - expect(script).toContain( - 'Add-Composer-Tool prestissimo prestissimo hirak/' - ); + expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/'); expect(script).toContain( 'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd' ); - expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/'); + expect(script).toContain('Add-Composertool phinx phinx robmorgan/'); expect(script).toContain( 'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive' ); @@ -440,14 +477,12 @@ describe('Tools tests', () => { 'win32' ); expect(script).toContain( - 'Add-Tool https://github.com/composer/composer/releases/latest/download/composer.phar composer' + 'Add-Tool https://getcomposer.org/composer-stable.phar composer' ); + expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/'); + expect(script).toContain('Add-Composertool phinx phinx robmorgan/'); expect(script).toContain( - 'Add-Composer-Tool prestissimo prestissimo hirak/' - ); - expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/'); - expect(script).toContain( - 'Add-Composer-Tool composer-prefetcher composer-prefetcher narrowspark/automatic-' + 'Add-Composertool composer-prefetcher composer-prefetcher narrowspark/automatic-' ); }); }); diff --git a/action.yml b/action.yml index 75ca0f3c..dff9a81a 100644 --- a/action.yml +++ b/action.yml @@ -3,6 +3,7 @@ author: shivammathur description: 'Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer' branding: color: 'purple' + icon: 'play-circle' inputs: php-version: description: 'Setup PHP version.' diff --git a/dist/index.js b/dist/index.js index 97f8117d..1859c445 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1452,6 +1452,13 @@ exports.setFailed = setFailed; //----------------------------------------------------------------------- // Logging Commands //----------------------------------------------------------------------- +/** + * Gets whether Actions Step Debug is on or not + */ +function isDebug() { + return process.env['RUNNER_DEBUG'] === '1'; +} +exports.isDebug = isDebug; /** * Writes debug message to user log * @param message debug message @@ -1575,63 +1582,24 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const utils = __importStar(__webpack_require__(163)); /** - * Function to get command to setup tool + * Function to get command to setup tools * * @param os_version */ -function getArchiveCommand(os_version) { +function getCommand(os_version, suffix) { return __awaiter(this, void 0, void 0, function* () { switch (os_version) { case 'linux': case 'darwin': - return 'add_tool '; + return 'add_' + suffix + ' '; case 'win32': - return 'Add-Tool '; + return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' '; default: return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); } }); } -exports.getArchiveCommand = getArchiveCommand; -/** - * Function to get command to setup tools using composer - * - * @param os_version - */ -function getPackageCommand(os_version) { - return __awaiter(this, void 0, void 0, function* () { - switch (os_version) { - case 'linux': - case 'darwin': - return 'add_composer_tool '; - case 'win32': - return 'Add-Composer-Tool '; - default: - return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); - } - }); -} -exports.getPackageCommand = getPackageCommand; -/** - * - * Function to get command to setup PECL - * - * @param os_version - */ -function getPECLCommand(os_version) { - return __awaiter(this, void 0, void 0, function* () { - switch (os_version) { - case 'linux': - case 'darwin': - return 'add_pecl '; - case 'win32': - return 'Add-PECL '; - default: - return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); - } - }); -} -exports.getPECLCommand = getPECLCommand; +exports.getCommand = getCommand; /** * Function to get tool version * @@ -1703,20 +1671,13 @@ exports.getUri = getUri; * Helper function to get the codeception url * * @param version - * @param php_version * @param suffix */ -function getCodeceptionUriBuilder(version, php_version, suffix) { +function getCodeceptionUriBuilder(version, suffix) { return __awaiter(this, void 0, void 0, function* () { - switch (true) { - case /^5\.6$|^7\.[0|1]$/.test(php_version): - return ['releases', version, suffix, 'codecept.phar'] - .filter(Boolean) - .join('/'); - case /^7\.[2-4]$/.test(php_version): - default: - return ['releases', version, 'codecept.phar'].filter(Boolean).join('/'); - } + return ['releases', version, suffix, 'codecept.phar'] + .filter(Boolean) + .join('/'); }); } exports.getCodeceptionUriBuilder = getCodeceptionUriBuilder; @@ -1728,19 +1689,55 @@ exports.getCodeceptionUriBuilder = getCodeceptionUriBuilder; */ function getCodeceptionUri(version, php_version) { return __awaiter(this, void 0, void 0, function* () { + const codecept = yield getCodeceptionUriBuilder(version, ''); + const codecept54 = yield getCodeceptionUriBuilder(version, 'php54'); + const codecept56 = yield getCodeceptionUriBuilder(version, 'php56'); + // Refer to https://codeception.com/builds switch (true) { case /latest/.test(version): switch (true) { - case /^5\.6$|^7\.[0|1]$/.test(php_version): + case /5\.6|7\.[0|1]/.test(php_version): return 'php56/codecept.phar'; - case /^7\.[2-4]$/.test(php_version): + case /7\.[2-4]/.test(php_version): default: return 'codecept.phar'; } - case /([4-9]|\d{2,})\..*/.test(version): - return yield getCodeceptionUriBuilder(version, php_version, 'php56'); + case /(^[4-9]|\d{2,})\..*/.test(version): + switch (true) { + case /5\.6|7\.[0|1]/.test(php_version): + return codecept56; + case /7\.[2-4]/.test(php_version): + default: + return codecept; + } + case /(^2\.[4-5]\.\d+|^3\.[0-1]\.\d+).*/.test(version): + switch (true) { + case /5\.6/.test(php_version): + return codecept54; + case /7\.[0-4]/.test(php_version): + default: + return codecept; + } + case /^2\.3\.\d+.*/.test(version): + switch (true) { + case /5\.[4-6]/.test(php_version): + return codecept54; + case /^7\.[0-4]$/.test(php_version): + default: + return codecept; + } + case /(^2\.(1\.([6-9]|\d{2,}))|^2\.2\.\d+).*/.test(version): + switch (true) { + case /5\.[4-5]/.test(php_version): + return codecept54; + case /5.6|7\.[0-4]/.test(php_version): + default: + return codecept; + } + case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version): + return codecept; default: - return yield getCodeceptionUriBuilder(version, php_version, 'php54'); + return yield codecept; } }); } @@ -1757,10 +1754,10 @@ function addPhive(version, os_version) { return __awaiter(this, void 0, void 0, function* () { switch (version) { case 'latest': - return ((yield getArchiveCommand(os_version)) + + return ((yield getCommand(os_version, 'tool')) + 'https://phar.io/releases/phive.phar phive'); default: - return ((yield getArchiveCommand(os_version)) + + return ((yield getCommand(os_version, 'tool')) + 'https://github.com/phar-io/phive/releases/download/' + version + '/phive-' + @@ -1771,22 +1768,21 @@ function addPhive(version, os_version) { } exports.addPhive = addPhive; /** - * Function to get the PHPUnit url + * Function to get the phar url in domain/tool-version.phar format * * @param version */ -function getPhpunitUrl(tool, version) { +function getPharUrl(domain, tool, prefix, version) { return __awaiter(this, void 0, void 0, function* () { - const phpunit = 'https://phar.phpunit.de'; switch (version) { case 'latest': - return phpunit + '/' + tool + '.phar'; + return domain + '/' + tool + '.phar'; default: - return phpunit + '/' + tool + '-' + version + '.phar'; + return domain + '/' + tool + '-' + prefix + version + '.phar'; } }); } -exports.getPhpunitUrl = getPhpunitUrl; +exports.getPharUrl = getPharUrl; /** * Function to get the Deployer url * @@ -1884,7 +1880,7 @@ exports.getCleanedToolsList = getCleanedToolsList; */ function addArchive(tool, version, url, os_version) { return __awaiter(this, void 0, void 0, function* () { - return (yield getArchiveCommand(os_version)) + url + ' ' + tool; + return (yield getCommand(os_version, 'tool')) + url + ' ' + tool; }); } exports.addArchive = addArchive; @@ -1921,7 +1917,7 @@ exports.addDevTools = addDevTools; */ function addPackage(tool, release, prefix, os_version) { return __awaiter(this, void 0, void 0, function* () { - const tool_command = yield getPackageCommand(os_version); + const tool_command = yield getCommand(os_version, 'composertool'); return tool_command + tool + ' ' + release + ' ' + prefix; }); } @@ -1977,8 +1973,10 @@ function addTools(tools_csv, php_version, os_version) { script += yield addArchive(tool, version, url, os_version); break; case 'composer': - url = - github + 'composer/composer/releases/latest/download/composer.phar'; + // If RC is released as latest release, switch to getcomposer. + // Prefered source is GitHub as it is faster. + // url = github + 'composer/composer/releases/latest/download/composer.phar'; + url = 'https://getcomposer.org/composer-stable.phar'; script += yield addArchive(tool, version, url, os_version); break; case 'codeception': @@ -1989,7 +1987,7 @@ function addTools(tools_csv, php_version, os_version) { break; case 'phpcpd': case 'phpunit': - url = yield getPhpunitUrl(tool, version); + url = yield getPharUrl('https://phar.phpunit.de', tool, '', version); script += yield addArchive(tool, version, url, os_version); break; case 'deployer': @@ -2006,7 +2004,7 @@ function addTools(tools_csv, php_version, os_version) { script += yield addPackage(tool, release, 'narrowspark/automatic-', os_version); break; case 'pecl': - script += yield getPECLCommand(os_version); + script += yield getCommand(os_version, 'pecl'); break; case 'php-config': case 'phpize': diff --git a/examples/cakephp-mysql.yml b/examples/cakephp-mysql.yml index 478d6ba3..b6d8997c 100644 --- a/examples/cakephp-mysql.yml +++ b/examples/cakephp-mysql.yml @@ -34,6 +34,8 @@ jobs: # Install memcached if using ext-memcached extensions: mbstring, intl, redis, pdo_mysql coverage: pcov + - name: Start mysql service + run: sudo /etc/init.d/mysql start - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" diff --git a/examples/laravel-mysql.yml b/examples/laravel-mysql.yml index 5de24522..3f04ff3e 100644 --- a/examples/laravel-mysql.yml +++ b/examples/laravel-mysql.yml @@ -41,6 +41,8 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, mysql coverage: xdebug #optional + - name: Start mysql service + run: sudo /etc/init.d/mysql start - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" diff --git a/examples/lumen-mysql.yml b/examples/lumen-mysql.yml index d358e500..45581656 100644 --- a/examples/lumen-mysql.yml +++ b/examples/lumen-mysql.yml @@ -41,6 +41,8 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, mysql coverage: xdebug #optional + - name: Start mysql service + run: sudo /etc/init.d/mysql start - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" diff --git a/examples/phalcon-mysql.yml b/examples/phalcon-mysql.yml index 9e4ffb18..3da8bef4 100644 --- a/examples/phalcon-mysql.yml +++ b/examples/phalcon-mysql.yml @@ -41,6 +41,8 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x. coverage: xdebug #optional + - name: Start mysql service + run: sudo /etc/init.d/mysql start - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" diff --git a/examples/symfony-mysql.yml b/examples/symfony-mysql.yml index ecee71e1..1d0a73d4 100644 --- a/examples/symfony-mysql.yml +++ b/examples/symfony-mysql.yml @@ -28,6 +28,8 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql coverage: xdebug #optional + - name: Start mysql service + run: sudo /etc/init.d/mysql start - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" diff --git a/examples/yii2-mysql.yml b/examples/yii2-mysql.yml index 81e4b406..ca50d2d3 100644 --- a/examples/yii2-mysql.yml +++ b/examples/yii2-mysql.yml @@ -38,6 +38,8 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, gd, imagick, zip, dom, mysql coverage: xdebug #optional + - name: Start mysql service + run: sudo /etc/init.d/mysql start - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" diff --git a/package-lock.json b/package-lock.json index 641dda46..933851da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "setup-php", - "version": "1.8.3", + "version": "1.8.4", "lockfileVersion": 1, "requires": true, "dependencies": { "@actions/core": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.2.tgz", - "integrity": "sha512-IbCx7oefq+Gi6FWbSs2Fnw8VkEI6Y4gvjrYprY3RV//ksq/KPMlClOerJ4jRosyal6zkUIc8R9fS/cpRMlGClg==" + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.3.tgz", + "integrity": "sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w==" }, "@actions/exec": { "version": "1.0.3", @@ -32,18 +32,18 @@ } }, "@babel/core": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.8.4.tgz", - "integrity": "sha512-0LiLrB2PwrVI+a2/IEskBopDYSd8BCb3rOvH7D5tzoWd696TBEduBvuLVm4Nx6rltrLZqvI3MCalB2K2aVzQjA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.8.6.tgz", + "integrity": "sha512-Sheg7yEJD51YHAvLEV/7Uvw95AeWqYPL3Vk3zGujJKIhJ+8oLw2ALaf3hbucILhKsgSoADOvtKRJuNVdcJkOrg==", "dev": true, "requires": { "@babel/code-frame": "^7.8.3", - "@babel/generator": "^7.8.4", + "@babel/generator": "^7.8.6", "@babel/helpers": "^7.8.4", - "@babel/parser": "^7.8.4", - "@babel/template": "^7.8.3", - "@babel/traverse": "^7.8.4", - "@babel/types": "^7.8.3", + "@babel/parser": "^7.8.6", + "@babel/template": "^7.8.6", + "@babel/traverse": "^7.8.6", + "@babel/types": "^7.8.6", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.1", @@ -69,12 +69,12 @@ } }, "@babel/generator": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.4.tgz", - "integrity": "sha512-PwhclGdRpNAf3IxZb0YVuITPZmmrXz9zf6fH8lT4XbrmfQKr6ryBzhv593P5C6poJRciFCL/eHGW2NuGrgEyxA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.6.tgz", + "integrity": "sha512-4bpOR5ZBz+wWcMeVtcf7FbjcFzCp+817z2/gHNncIRcM9MmKzUhtWCYAq27RAfUrAFwb+OCG1s9WEaVxfi6cjg==", "dev": true, "requires": { - "@babel/types": "^7.8.3", + "@babel/types": "^7.8.6", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" @@ -198,9 +198,9 @@ } }, "@babel/parser": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.4.tgz", - "integrity": "sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.6.tgz", + "integrity": "sha512-trGNYSfwq5s0SgM1BMEB8hX3NDmO7EP2wsDGDexiaKMB92BaRpS+qZfpkMqUBhcsOTBwNy9B/jieo4ad/t/z2g==", "dev": true }, "@babel/plugin-syntax-bigint": { @@ -231,28 +231,28 @@ } }, "@babel/template": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.3.tgz", - "integrity": "sha512-04m87AcQgAFdvuoyiQ2kgELr2tV8B4fP/xJAVUL3Yb3bkNdMedD3d0rlSQr3PegP0cms3eHjl1F7PWlvWbU8FQ==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.6.tgz", + "integrity": "sha512-zbMsPMy/v0PWFZEhQJ66bqjhH+z0JgMoBWuikXybgG3Gkd/3t5oQ1Rw2WQhnSrsOmsKXnZOx15tkC4qON/+JPg==", "dev": true, "requires": { "@babel/code-frame": "^7.8.3", - "@babel/parser": "^7.8.3", - "@babel/types": "^7.8.3" + "@babel/parser": "^7.8.6", + "@babel/types": "^7.8.6" } }, "@babel/traverse": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.8.4.tgz", - "integrity": "sha512-NGLJPZwnVEyBPLI+bl9y9aSnxMhsKz42so7ApAv9D+b4vAFPpY013FTS9LdKxcABoIYFU52HcYga1pPlx454mg==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.8.6.tgz", + "integrity": "sha512-2B8l0db/DPi8iinITKuo7cbPznLCEk0kCxDoB9/N6gGNg/gxOXiR/IcymAFPiBwk5w6TtQ27w4wpElgp9btR9A==", "dev": true, "requires": { "@babel/code-frame": "^7.8.3", - "@babel/generator": "^7.8.4", + "@babel/generator": "^7.8.6", "@babel/helper-function-name": "^7.8.3", "@babel/helper-split-export-declaration": "^7.8.3", - "@babel/parser": "^7.8.4", - "@babel/types": "^7.8.3", + "@babel/parser": "^7.8.6", + "@babel/types": "^7.8.6", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" @@ -267,9 +267,9 @@ } }, "@babel/types": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.3.tgz", - "integrity": "sha512-jBD+G8+LWpMBBWvVcdr4QysjUE4mU/syrhN17o1u3gx0/WzJB1kwiVZAXRtWbsIPOwW8pF/YJV5+nmetPzepXg==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.6.tgz", + "integrity": "sha512-wqz7pgWMIrht3gquyEFPVXeXCti72Rm8ep9b5tQKz9Yg9LzJA3HxosF1SB3Kc81KD1A3XBkkVYtJvCKS2Z/QrA==", "dev": true, "requires": { "esutils": "^2.0.2", @@ -575,18 +575,18 @@ } }, "@sinonjs/commons": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.7.0.tgz", - "integrity": "sha512-qbk9AP+cZUsKdW1GJsBpxPKFmCJ0T8swwzVje3qFd+AkQb74Q/tiuzrdfFg8AD2g5HH/XbE/I8Uc1KYHVYWfhg==", + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.7.1.tgz", + "integrity": "sha512-Debi3Baff1Qu1Unc3mjJ96MgpbwTn43S1+9yJ0llWygPwDNu2aaWBD6yc9y/Z8XDRNhx7U+u2UDg2OGQXkclUQ==", "dev": true, "requires": { "type-detect": "4.0.8" } }, "@types/babel__core": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.4.tgz", - "integrity": "sha512-c/5MuRz5HM4aizqL5ViYfW4iEnmfPcfbH4Xa6GgLT21dMc1NGeNnuS6egHheOmP+kCJ9CAzC4pv4SDCWTnRkbg==", + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.6.tgz", + "integrity": "sha512-tTnhWszAqvXnhW7m5jQU9PomXSiKXk2sFxpahXvI20SZKu9ylPi8WtIxueZ6ehDWikPT0jeFujMj3X4ZHuf3Tg==", "dev": true, "requires": { "@babel/parser": "^7.1.0", @@ -616,9 +616,9 @@ } }, "@types/babel__traverse": { - "version": "7.0.8", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.8.tgz", - "integrity": "sha512-yGeB2dHEdvxjP0y4UbRtQaSkXJ9649fYCmIdRoul5kfAoGCwxuCbMhag0k3RPfnuh9kPGm8x89btcfDEXdVWGw==", + "version": "7.0.9", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.9.tgz", + "integrity": "sha512-jEFQ8L1tuvPjOI8lnpaf73oCJe+aoxL6ygqSy6c8LcW98zaC+4mzWuQIRCEvKeCOu+lbqdXcg4Uqmm1S8AP1tw==", "dev": true, "requires": { "@babel/types": "^7.3.0" @@ -662,9 +662,9 @@ } }, "@types/jest": { - "version": "25.1.2", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.2.tgz", - "integrity": "sha512-EsPIgEsonlXmYV7GzUqcvORsSS9Gqxw/OvkGwHfAdpjduNRxMlhsav0O5Kb0zijc/eXSO/uW6SJt9nwull8AUQ==", + "version": "25.1.3", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.3.tgz", + "integrity": "sha512-jqargqzyJWgWAJCXX96LBGR/Ei7wQcZBvRv0PLEu9ZByMfcs23keUJrKv9FMR6YZf9YCbfqDqgmY+JUBsnqhrg==", "dev": true, "requires": { "jest-diff": "^25.1.0", @@ -678,9 +678,9 @@ "dev": true }, "@types/node": { - "version": "13.7.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.1.tgz", - "integrity": "sha512-Zq8gcQGmn4txQEJeiXo/KiLpon8TzAl0kmKH4zdWctPj05nWwp1ClMdAVEloqrQKfaC48PNLdgN/aVaLqUrluA==", + "version": "13.7.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.7.tgz", + "integrity": "sha512-Uo4chgKbnPNlxQwoFmYIwctkQVkMMmsAoGGU4JKwLuvBefF0pCq4FybNSnfkfRCpC7ZW7kttcC/TrRtAJsvGtg==", "dev": true }, "@types/parse-json": { @@ -696,9 +696,9 @@ "dev": true }, "@types/yargs": { - "version": "15.0.3", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.3.tgz", - "integrity": "sha512-XCMQRK6kfpNBixHLyHUsGmXrpEmFFxzMrcnSXFMziHd8CoNJo8l16FkHyQq4x+xbM7E2XL83/O78OD8u+iZTdQ==", + "version": "15.0.4", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.4.tgz", + "integrity": "sha512-9T1auFmbPZoxHz0enUFlUuKRy3it01R+hlggyVUMtnCTQRunsQYifnSGb8hET4Xo8yiC0o0r1paW3ud5+rbURg==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -711,12 +711,12 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "2.19.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.19.2.tgz", - "integrity": "sha512-HX2qOq2GOV04HNrmKnTpSIpHjfl7iwdXe3u/Nvt+/cpmdvzYvY0NHSiTkYN257jHnq4OM/yo+OsFgati+7LqJA==", + "version": "2.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.21.0.tgz", + "integrity": "sha512-b5jjjDMxzcjh/Sbjuo7WyhrQmVJg0WipTHQgXh5Xwx10uYm6nPWqN1WGOsaNq4HR3Zh4wUx4IRQdDkCHwyewyw==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "2.19.2", + "@typescript-eslint/experimental-utils": "2.21.0", "eslint-utils": "^1.4.3", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -724,32 +724,32 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "2.19.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.19.2.tgz", - "integrity": "sha512-B88QuwT1wMJR750YvTJBNjMZwmiPpbmKYLm1yI7PCc3x0NariqPwqaPsoJRwU9DmUi0cd9dkhz1IqEnwfD+P1A==", + "version": "2.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.21.0.tgz", + "integrity": "sha512-olKw9JP/XUkav4lq0I7S1mhGgONJF9rHNhKFn9wJlpfRVjNo3PPjSvybxEldvCXnvD+WAshSzqH5cEjPp9CsBA==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.19.2", + "@typescript-eslint/typescript-estree": "2.21.0", "eslint-scope": "^5.0.0" } }, "@typescript-eslint/parser": { - "version": "2.19.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.19.2.tgz", - "integrity": "sha512-8uwnYGKqX9wWHGPGdLB9sk9+12sjcdqEEYKGgbS8A0IvYX59h01o8os5qXUHMq2na8vpDRaV0suTLM7S8wraTA==", + "version": "2.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.21.0.tgz", + "integrity": "sha512-VrmbdrrrvvI6cPPOG7uOgGUFXNYTiSbnRq8ZMyuGa4+qmXJXVLEEz78hKuqupvkpwJQNk1Ucz1TenrRP90gmBg==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.19.2", - "@typescript-eslint/typescript-estree": "2.19.2", + "@typescript-eslint/experimental-utils": "2.21.0", + "@typescript-eslint/typescript-estree": "2.21.0", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.19.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.19.2.tgz", - "integrity": "sha512-Xu/qa0MDk6upQWqE4Qy2X16Xg8Vi32tQS2PR0AvnT/ZYS4YGDvtn2MStOh5y8Zy2mg4NuL06KUHlvCh95j9C6Q==", + "version": "2.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.21.0.tgz", + "integrity": "sha512-NC/nogZNb9IK2MEFQqyDBAciOT8Lp8O3KgAfvHx2Skx6WBo+KmDqlU3R9KxHONaijfTIKtojRe3SZQyMjr3wBw==", "dev": true, "requires": { "debug": "^4.1.1", @@ -774,9 +774,9 @@ "dev": true }, "acorn": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", - "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", "dev": true }, "acorn-globals": { @@ -798,9 +798,9 @@ } }, "acorn-jsx": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz", - "integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz", + "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==", "dev": true }, "acorn-walk": { @@ -810,9 +810,9 @@ "dev": true }, "ajv": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.11.0.tgz", - "integrity": "sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA==", + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.0.tgz", + "integrity": "sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -822,12 +822,20 @@ } }, "ansi-escapes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz", - "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", + "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", "dev": true, "requires": { - "type-fest": "^0.8.1" + "type-fest": "^0.11.0" + }, + "dependencies": { + "type-fest": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", + "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==", + "dev": true + } } }, "ansi-regex": { @@ -1875,9 +1883,9 @@ } }, "eslint-plugin-jest": { - "version": "23.7.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.7.0.tgz", - "integrity": "sha512-zkiyGlvJeHNjAEz8FaIxTXNblJJ/zj3waNbYbgflK7K6uy0cpE5zJBt/JpJtOBGM/UGkC6BqsQ4n0y7kQ2HA8w==", + "version": "23.8.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.8.1.tgz", + "integrity": "sha512-OycLNqPo/2EfO6kTqnmsu1khz1gTIOxGl3ThIVwL5/oycDF4pm5uNDyvFelNLdpr4COUuM8PVi3963NEG1Efpw==", "dev": true, "requires": { "@typescript-eslint/experimental-utils": "^2.5.0" @@ -2498,9 +2506,9 @@ } }, "hosted-git-info": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", - "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", "dev": true }, "html-encoding-sniffer": { @@ -2731,74 +2739,33 @@ "dev": true }, "inquirer": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.4.tgz", - "integrity": "sha512-Bu5Td5+j11sCkqfqmUTiwv+tWisMtP0L7Q8WrqA2C/BbBhy1YTdFrvjjlrKq8oagA/tLQBski2Gcx/Sqyi2qSQ==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.5.tgz", + "integrity": "sha512-6Z5cP+LAO0rzNE7xWjWtT84jxKa5ScLEGLgegPXeO3dGeU8lNe5Ii7SlXH6KVtLGlDuaEhsvsFjrjWjw8j5lFg==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", - "chalk": "^2.4.2", + "chalk": "^3.0.0", "cli-cursor": "^3.1.0", "cli-width": "^2.0.0", "external-editor": "^3.0.3", "figures": "^3.0.0", "lodash": "^4.17.15", "mute-stream": "0.0.8", - "run-async": "^2.2.0", + "run-async": "^2.4.0", "rxjs": "^6.5.3", "string-width": "^4.1.0", - "strip-ansi": "^5.1.0", + "strip-ansi": "^6.0.0", "through": "^2.3.6" }, "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" + "ansi-regex": "^5.0.0" } } } @@ -3827,9 +3794,9 @@ } }, "make-error": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", - "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", "dev": true }, "makeerror": { @@ -4427,9 +4394,9 @@ "dev": true }, "react-is": { - "version": "16.12.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.12.0.tgz", - "integrity": "sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q==", + "version": "16.13.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.0.tgz", + "integrity": "sha512-GFMtL0vHkiBv9HluwNZTggSn/sCyEt9n02aM0dSAjGGyqyNlAyftYm4phPxdvCigG15JreC5biwxCgTAJZ7yAA==", "dev": true }, "read-pkg": { @@ -4656,9 +4623,9 @@ "dev": true }, "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.0.tgz", + "integrity": "sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg==", "dev": true, "requires": { "is-promise": "^2.1.0" @@ -5517,9 +5484,9 @@ } }, "ts-jest": { - "version": "25.2.0", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.2.0.tgz", - "integrity": "sha512-VaRdb0da46eorLfuHEFf0G3d+jeREcV+Wb/SvW71S4y9Oe8SHWU+m1WY/3RaMknrBsnvmVH0/rRjT8dkgeffNQ==", + "version": "25.2.1", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.2.1.tgz", + "integrity": "sha512-TnntkEEjuXq/Gxpw7xToarmHbAafgCaAzOpnajnFC6jI7oo1trMzAHA04eWpc3MhV6+yvhE8uUBAmN+teRJh0A==", "dev": true, "requires": { "bs-logger": "0.x", @@ -5531,36 +5498,21 @@ "mkdirp": "0.x", "resolve": "1.x", "semver": "^5.5", - "yargs-parser": "10.x" + "yargs-parser": "^16.1.0" }, "dependencies": { - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", - "dev": true - }, "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "dev": true - }, - "yargs-parser": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", - "integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==", - "dev": true, - "requires": { - "camelcase": "^4.1.0" - } } } }, "tslib": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", - "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz", + "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==", "dev": true }, "tsutils": { @@ -5618,9 +5570,9 @@ } }, "typescript": { - "version": "3.7.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz", - "integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==", + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", + "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", "dev": true }, "union-value": { @@ -5886,9 +5838,9 @@ } }, "write-file-atomic": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.1.tgz", - "integrity": "sha512-JPStrIyyVJ6oCSz/691fAjFtefZ6q+fP6tm+OS4Qw6o+TGQxNp1ziY2PgS+X/m0V8OWhZiO/m4xSj+Pr4RrZvw==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", "dev": true, "requires": { "imurmurhash": "^0.1.4", diff --git a/package.json b/package.json index d05d129f..7b99d920 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "1.8.3", + "version": "1.8.4", "private": false, "description": "Setup PHP for use with GitHub Actions", "main": "dist/index.js", @@ -24,28 +24,28 @@ "author": "shivammathur", "license": "MIT", "dependencies": { - "@actions/core": "^1.2.2", + "@actions/core": "^1.2.3", "@actions/exec": "^1.0.3", "@actions/io": "^1.0.2", "fs": "0.0.1-security" }, "devDependencies": { - "@types/jest": "^25.1.2", - "@types/node": "^13.7.1", - "@typescript-eslint/eslint-plugin": "^2.19.2", - "@typescript-eslint/parser": "^2.19.2", + "@types/jest": "^25.1.3", + "@types/node": "^13.7.7", + "@typescript-eslint/eslint-plugin": "^2.21.0", + "@typescript-eslint/parser": "^2.21.0", "@zeit/ncc": "^0.21.1", "eslint": "^6.8.0", "eslint-config-prettier": "^6.10.0", "eslint-plugin-import": "^2.20.1", - "eslint-plugin-jest": "^23.7.0", + "eslint-plugin-jest": "^23.8.1", "eslint-plugin-prettier": "^3.1.2", "husky": "^4.2.3", "jest": "^25.1.0", "jest-circus": "^25.1.0", "prettier": "^1.19.1", - "ts-jest": "^25.2.0", - "typescript": "^3.7.5" + "ts-jest": "^25.2.1", + "typescript": "^3.8.3" }, "husky": { "skipCI": true, diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index cbd4088e..c2ac455f 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -20,22 +20,14 @@ add_log() { remove_extension() { extension=$1 sudo sed -i '' "/$extension/d" "$ini_file" + sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 } -# Function to setup extensions -add_extension() { +# Function to test if extension is loaded +check_extension() { extension=$1 - install_command=$2 - prefix=$3 - if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then - echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" - elif php -m | grep -i -q -w "$extension"; then - add_log "$tick" "$extension" "Enabled" - elif ! php -m | grep -i -q -w "$extension"; then - (eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") || - add_log "$cross" "$extension" "Could not install $extension on PHP $semver" - fi + php -m | grep -i -q -w "$extension" } # Fuction to get the PECL version @@ -51,68 +43,83 @@ get_pecl_version() { echo "$pecl_version" } +# Function to install a PECL version +add_pecl_extension() { + extension=$1 + pecl_version=$2 + prefix=$3 + if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then + echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" + fi + ext_version=$(php -r "echo phpversion('$extension');") + if [ "$ext_version" = "$pecl_version" ]; then + add_log "$tick" "$extension" "Enabled" + else + remove_extension "$extension" + ( + sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 && + check_extension "$extension" && + add_log "$tick" "$extension" "Installed and enabled" + ) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver" + fi +} + +# Function to setup extensions +add_extension() { + extension=$1 + install_command=$2 + prefix=$3 + if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then + echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" + elif check_extension "$extension"; then + add_log "$tick" "$extension" "Enabled" + elif ! check_extension "$extension"; then + ( + eval "$install_command" >/dev/null 2>&1 && + check_extension "$extension" && + add_log "$tick" "$extension" "Installed and enabled" + ) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver" + fi +} + # Function to pre-release extensions using PECL add_unstable_extension() { extension=$1 stability=$2 prefix=$3 pecl_version=$(get_pecl_version "$extension" "$stability") - if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then - extension_version=$(php -d="$prefix=$extension" -r "echo phpversion('$extension');") - if [ "$extension_version" = "$pecl_version" ]; then - echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" - else - remove_extension "$extension" - add_extension "$extension" "sudo pecl install -f $extension-$pecl_version" "$prefix" - fi - elif php -m | grep -i -q -w "$extension"; then - extension_version=$(php -r "echo phpversion('$extension');") - if [ "$extension_version" = "$pecl_version" ]; then - add_log "$tick" "$extension" "Enabled" - else - remove_extension "$extension" - add_extension "$extension" "sudo pecl install -f $extension-$pecl_version" "$prefix" - fi - else - add_extension "$extension" "sudo pecl install -f $extension-$pecl_version" "$prefix" - fi + add_pecl_extension "$extension" "$pecl_version" "$prefix" } # Function to setup a remote tool add_tool() { url=$1 tool=$2 - if [ "$tool" = "composer" ]; then - brew install composer >/dev/null 2>&1 - composer -q global config process-timeout 0 + tool_path="$tool_path_dir/$tool" + if [ ! -e "$tool_path" ]; then + rm -rf "$tool_path" + fi + + status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url") + if [ "$status_code" = "200" ]; then + sudo chmod a+x "$tool_path" + if [ "$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 + add_extension xml "sudo pecl install -f xml" extension >/dev/null 2>&1 + elif [ "$tool" = "cs2pr" ]; then + sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path" + tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path" + sudo chmod a+x "$tool_path" + fi add_log "$tick" "$tool" "Added" else - tool_path=/usr/local/bin/"$tool" - if [ ! -e "$tool_path" ]; then - rm -rf "$tool_path" - fi - - status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url") - if [ "$status_code" = "200" ]; then - sudo chmod a+x "$tool_path" - if [ "$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 - add_extension xml "sudo pecl install -f xml" extension >/dev/null 2>&1 - elif [ "$tool" = "cs2pr" ]; then - sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path" - tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path" - sudo chmod a+x "$tool_path" - fi - add_log "$tick" "$tool" "Added" - else - add_log "$cross" "$tool" "Could not setup $tool" - fi + add_log "$cross" "$tool" "Could not setup $tool" fi } # Function to add a tool using composer -add_composer_tool() { +add_composertool() { tool=$1 release=$2 prefix=$3 @@ -149,6 +156,7 @@ setup_php_and_composer() { tick="✓" cross="✗" version=$1 +tool_path_dir="/usr/local/bin" existing_version=$(php-config --version | cut -c 1-3) # Setup PHP @@ -163,9 +171,10 @@ else status="Found" fi ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") -sudo chmod 777 "$ini_file" +sudo chmod 777 "$ini_file" "$tool_path_dir" echo "date.timezone=UTC" >>"$ini_file" ext_dir=$(php -i | grep -Ei "extension_dir => /(usr|opt)" | sed -e "s|.*=> s*||") +scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") sudo mkdir -p "$ext_dir" semver=$(php -v | head -n 1 | cut -f 2 -d ' ') configure_pecl diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index e75e88f5..501a8924 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -48,31 +48,17 @@ get_pecl_version() { echo "$pecl_version" } -# Function to setup extensions -add_extension() { +# Function to test if extension is loaded +check_extension() { extension=$1 - install_command=$2 - prefix=$3 - if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then - # shellcheck disable=SC2046 - $apt_install $(apt-cache depends php"$version"-"$extension" | awk '/Depends:/{print$2}') >/dev/null 2>&1 - echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" - elif php -m | grep -i -q -w "$extension"; then - add_log "$tick" "$extension" "Enabled" - elif ! php -m | grep -i -q -w "$extension"; then - (eval "$install_command" && add_log "$tick" "$extension" "Installed and enabled") || - (update_ppa && eval "$install_command" && add_log "$tick" "$extension" "Installed and enabled") || - (sudo pecl install -f "$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") || - add_log "$cross" "$extension" "Could not install $extension on PHP $semver" - fi - sudo chmod 777 "$ini_file" + php -m | grep -i -q -w "$extension" } # Function to delete extensions delete_extension() { extension=$1 sudo sed -i "/$extension/d" "$ini_file" - sudo rm -rf /etc/php/"$version"/cli/conf.d/*"$extension"* >/dev/null 2>&1 + sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 } @@ -85,13 +71,44 @@ remove_extension() { delete_extension "$extension" } +# Function to setup extensions +add_extension() { + extension=$1 + install_command=$2 + prefix=$3 + if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then + echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" + elif check_extension "$extension"; then + add_log "$tick" "$extension" "Enabled" + elif ! check_extension "$extension"; then + eval "$install_command" >/dev/null 2>&1 || + (update_ppa && eval "$install_command" >/dev/null 2>&1) || + sudo pecl install -f "$extension" >/dev/null 2>&1 + (check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled") || + add_log "$cross" "$extension" "Could not install $extension on PHP $semver" + fi + sudo chmod 777 "$ini_file" +} + # Function to install a PECL version add_pecl_extension() { extension=$1 pecl_version=$2 - (sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 && - add_log "$tick" "$extension" "Installed and enabled") || - add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver" + prefix=$3 + if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then + echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" + fi + ext_version=$(php -r "echo phpversion('$extension');") + if [ "$ext_version" = "$pecl_version" ]; then + add_log "$tick" "$extension" "Enabled" + else + delete_extension "$extension" + ( + sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 && + check_extension "$extension" && + add_log "$tick" "$extension" "Installed and enabled" + ) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver" + fi } # Function to pre-release extensions using PECL @@ -100,25 +117,7 @@ add_unstable_extension() { stability=$2 prefix=$3 pecl_version=$(get_pecl_version "$extension" "$stability") - if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then - extension_version=$(php -d="$prefix=$extension" -r "echo phpversion('$extension');") - if [ "$extension_version" = "$pecl_version" ]; then - echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" - else - delete_extension "$extension" - add_pecl_extension "$extension" "$pecl_version" - fi - elif php -m | grep -i -q -w "$extension"; then - extension_version=$(php -r "echo phpversion('$extension');") - if [ "$extension_version" = "$pecl_version" ]; then - add_log "$tick" "$extension" "Enabled" - else - delete_extension "$extension" - add_pecl_extension "$extension" "$pecl_version" - fi - else - add_pecl_extension "$extension" "$pecl_version" - fi + add_pecl_extension "$extension" "$pecl_version" "$prefix" } # Function to update extension @@ -140,7 +139,7 @@ update_extension() { add_tool() { url=$1 tool=$2 - tool_path=/usr/local/bin/"$tool" + tool_path="$tool_path_dir/$tool" if [ ! -e "$tool_path" ]; then rm -rf "$tool_path" fi @@ -152,9 +151,9 @@ add_tool() { elif [ "$tool" = "cs2pr" ]; then sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" elif [ "$tool" = "phive" ]; then - add_extension curl >/dev/null 2>&1 - add_extension mbstring >/dev/null 2>&1 - add_extension xml >/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 xml "$apt_install php$version-xml" extension >/dev/null 2>&1 fi add_log "$tick" "$tool" "Added" else @@ -163,7 +162,7 @@ add_tool() { } # Function to setup a tool using composer -add_composer_tool() { +add_composertool() { tool=$1 release=$2 prefix=$3 @@ -189,8 +188,8 @@ setup_master() { tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz install_dir=~/php/"$version" sudo mkdir -m 777 -p ~/php - $apt_install libicu-dev >/dev/null 2>&1 - curl -o "$tar_file" -L https://bintray.com/shivammathur/php/download_file?file_path="$tar_file" >/dev/null 2>&1 + update_ppa && $apt_install libicu64 libicu-dev >/dev/null 2>&1 + curl -SLO https://dl.bintray.com/shivammathur/php/"$tar_file" >/dev/null 2>&1 sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1 rm -rf "$tar_file" sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/ @@ -216,13 +215,24 @@ switch_version() { done } +# Function to get PHP version in semver format +php_semver() { + if [ ! "$version" = "8.0" ]; then + php"$version" -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-' + else + php -v | head -n 1 | cut -f 2 -d ' ' + fi +} + # Variables tick="✓" cross="✗" ppa_updated="false" pecl_config="false" version=$1 -apt_install="sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y" +debconf_fix="DEBIAN_FRONTEND=noninteractive" +apt_install="sudo $debconf_fix apt-fast install -y" +tool_path_dir="/usr/local/bin" existing_version=$(php-config --version | cut -c 1-3) # Setup PHP @@ -232,36 +242,25 @@ sudo mkdir -p /run/php if [ "$existing_version" != "$version" ]; then if [ ! -e "/usr/bin/php$version" ]; then - update_ppa if [ "$version" = "8.0" ]; then setup_master else + update_ppa $apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1 fi - status="installed" + status="Installed" else - status="switched" + status="Switched to" fi switch_version - - if [ "$version" = "8.0" ]; then - semver=$(php -v | head -n 1 | cut -f 2 -d ' ') - else - semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-') - fi - - if [ "$status" != "switched" ]; then - status="Installed PHP $semver" - else - status="Switched to PHP $semver" - fi else - semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-') - status="PHP $semver Found" + status="Found" fi +semver=$(php_semver) ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") -ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||") -sudo chmod 777 "$ini_file" -add_log "$tick" "PHP" "$status" +ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||") +scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") +sudo chmod 777 "$ini_file" "$tool_path_dir" +add_log "$tick" "PHP" "$status PHP $semver" diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 082fbe94..a3cc7175 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -124,7 +124,7 @@ Function Add-Tool() { } } -Function Add-Composer-Tool() { +Function Add-Composertool() { Param ( [Parameter(Position = 0, Mandatory = $true)] [ValidateNotNull()] @@ -152,7 +152,7 @@ Function Add-Composer-Tool() { } } -Function Add-PECL() { +Function Add-Pecl() { Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows" } @@ -194,10 +194,7 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1 } else { - $updated = Update-Php $php_dir >$null 2>&1 - if($updated -eq $False) { - $status = "Found" - } + $status = "Found" } $installed = Get-Php -Path $php_dir diff --git a/src/tools.ts b/src/tools.ts index 0b816983..b6071aee 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -1,60 +1,20 @@ import * as utils from './utils'; /** - * Function to get command to setup tool + * Function to get command to setup tools * * @param os_version */ -export async function getArchiveCommand(os_version: string): Promise { +export async function getCommand( + os_version: string, + suffix: string +): Promise { switch (os_version) { case 'linux': case 'darwin': - return 'add_tool '; + return 'add_' + suffix + ' '; case 'win32': - return 'Add-Tool '; - default: - return await utils.log( - 'Platform ' + os_version + ' is not supported', - os_version, - 'error' - ); - } -} - -/** - * Function to get command to setup tools using composer - * - * @param os_version - */ -export async function getPackageCommand(os_version: string): Promise { - switch (os_version) { - case 'linux': - case 'darwin': - return 'add_composer_tool '; - case 'win32': - return 'Add-Composer-Tool '; - default: - return await utils.log( - 'Platform ' + os_version + ' is not supported', - os_version, - 'error' - ); - } -} - -/** - * - * Function to get command to setup PECL - * - * @param os_version - */ -export async function getPECLCommand(os_version: string): Promise { - switch (os_version) { - case 'linux': - case 'darwin': - return 'add_pecl '; - case 'win32': - return 'Add-PECL '; + return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' '; default: return await utils.log( 'Platform ' + os_version + ' is not supported', @@ -138,23 +98,15 @@ export async function getUri( * Helper function to get the codeception url * * @param version - * @param php_version * @param suffix */ export async function getCodeceptionUriBuilder( version: string, - php_version: string, suffix: string ): Promise { - switch (true) { - case /^5\.6$|^7\.[0|1]$/.test(php_version): - return ['releases', version, suffix, 'codecept.phar'] - .filter(Boolean) - .join('/'); - case /^7\.[2-4]$/.test(php_version): - default: - return ['releases', version, 'codecept.phar'].filter(Boolean).join('/'); - } + return ['releases', version, suffix, 'codecept.phar'] + .filter(Boolean) + .join('/'); } /** @@ -167,19 +119,55 @@ export async function getCodeceptionUri( version: string, php_version: string ): Promise { + const codecept: string = await getCodeceptionUriBuilder(version, ''); + const codecept54: string = await getCodeceptionUriBuilder(version, 'php54'); + const codecept56: string = await getCodeceptionUriBuilder(version, 'php56'); + // Refer to https://codeception.com/builds switch (true) { case /latest/.test(version): switch (true) { - case /^5\.6$|^7\.[0|1]$/.test(php_version): + case /5\.6|7\.[0|1]/.test(php_version): return 'php56/codecept.phar'; - case /^7\.[2-4]$/.test(php_version): + case /7\.[2-4]/.test(php_version): default: return 'codecept.phar'; } - case /([4-9]|\d{2,})\..*/.test(version): - return await getCodeceptionUriBuilder(version, php_version, 'php56'); + case /(^[4-9]|\d{2,})\..*/.test(version): + switch (true) { + case /5\.6|7\.[0|1]/.test(php_version): + return codecept56; + case /7\.[2-4]/.test(php_version): + default: + return codecept; + } + case /(^2\.[4-5]\.\d+|^3\.[0-1]\.\d+).*/.test(version): + switch (true) { + case /5\.6/.test(php_version): + return codecept54; + case /7\.[0-4]/.test(php_version): + default: + return codecept; + } + case /^2\.3\.\d+.*/.test(version): + switch (true) { + case /5\.[4-6]/.test(php_version): + return codecept54; + case /^7\.[0-4]$/.test(php_version): + default: + return codecept; + } + case /(^2\.(1\.([6-9]|\d{2,}))|^2\.2\.\d+).*/.test(version): + switch (true) { + case /5\.[4-5]/.test(php_version): + return codecept54; + case /5.6|7\.[0-4]/.test(php_version): + default: + return codecept; + } + case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version): + return codecept; default: - return await getCodeceptionUriBuilder(version, php_version, 'php54'); + return await codecept; } } @@ -198,12 +186,12 @@ export async function addPhive( switch (version) { case 'latest': return ( - (await getArchiveCommand(os_version)) + + (await getCommand(os_version, 'tool')) + 'https://phar.io/releases/phive.phar phive' ); default: return ( - (await getArchiveCommand(os_version)) + + (await getCommand(os_version, 'tool')) + 'https://github.com/phar-io/phive/releases/download/' + version + '/phive-' + @@ -214,20 +202,21 @@ export async function addPhive( } /** - * Function to get the PHPUnit url + * Function to get the phar url in domain/tool-version.phar format * * @param version */ -export async function getPhpunitUrl( +export async function getPharUrl( + domain: string, tool: string, + prefix: string, version: string ): Promise { - const phpunit = 'https://phar.phpunit.de'; switch (version) { case 'latest': - return phpunit + '/' + tool + '.phar'; + return domain + '/' + tool + '.phar'; default: - return phpunit + '/' + tool + '-' + version + '.phar'; + return domain + '/' + tool + '-' + prefix + version + '.phar'; } } @@ -333,7 +322,7 @@ export async function addArchive( url: string, os_version: string ): Promise { - return (await getArchiveCommand(os_version)) + url + ' ' + tool; + return (await getCommand(os_version, 'tool')) + url + ' ' + tool; } /** @@ -385,7 +374,7 @@ export async function addPackage( prefix: string, os_version: string ): Promise { - const tool_command = await getPackageCommand(os_version); + const tool_command = await getCommand(os_version, 'composertool'); return tool_command + tool + ' ' + release + ' ' + prefix; } @@ -449,8 +438,10 @@ export async function addTools( script += await addArchive(tool, version, url, os_version); break; case 'composer': - url = - github + 'composer/composer/releases/latest/download/composer.phar'; + // If RC is released as latest release, switch to getcomposer. + // Prefered source is GitHub as it is faster. + // url = github + 'composer/composer/releases/latest/download/composer.phar'; + url = 'https://getcomposer.org/composer-stable.phar'; script += await addArchive(tool, version, url, os_version); break; case 'codeception': @@ -461,7 +452,7 @@ export async function addTools( break; case 'phpcpd': case 'phpunit': - url = await getPhpunitUrl(tool, version); + url = await getPharUrl('https://phar.phpunit.de', tool, '', version); script += await addArchive(tool, version, url, os_version); break; case 'deployer': @@ -483,7 +474,7 @@ export async function addTools( ); break; case 'pecl': - script += await getPECLCommand(os_version); + script += await getCommand(os_version, 'pecl'); break; case 'php-config': case 'phpize':