mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-01 12:43:17 +07:00
Compare commits
28 Commits
releases/v
...
1.8.8
Author | SHA1 | Date | |
---|---|---|---|
062567eeb1 | |||
00b0d694d0 | |||
54afb29ef6 | |||
41329810ef | |||
90a6d88c24 | |||
8e6968c49e | |||
4ce413f558 | |||
533e0949a8 | |||
0ffe535b8e | |||
55fe8db60d | |||
5af5f992ec | |||
e9e024e600 | |||
a7ea0636d7 | |||
c471c0a458 | |||
277239149a | |||
9385896f2a | |||
9cabd8564d | |||
fdfa901941 | |||
527cd148c8 | |||
59b6e2b54a | |||
5ad0888329 | |||
3cfc409e14 | |||
ebc671081f | |||
efae663c0f | |||
fa8a671e6f | |||
6a4159ba98 | |||
0da52b1327 | |||
3579c7ef28 |
@ -17,7 +17,6 @@
|
||||
"camelcase": "off",
|
||||
"require-atomic-updates": "off",
|
||||
"@typescript-eslint/ban-ts-ignore": "off",
|
||||
"@typescript-eslint/camelcase": "off",
|
||||
"@typescript-eslint/no-unused-vars": "off"
|
||||
"@typescript-eslint/camelcase": "off"
|
||||
}
|
||||
}
|
10
.github/workflows/experimental-workflow.yml
vendored
10
.github/workflows/experimental-workflow.yml
vendored
@ -2,19 +2,13 @@ name: Experimental workflow
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- nightly
|
||||
- master
|
||||
- develop
|
||||
- verbose
|
||||
- releases/v1
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'examples/**'
|
||||
push:
|
||||
branches:
|
||||
- nightly
|
||||
- master
|
||||
- develop
|
||||
- verbose
|
||||
- releases/v1
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'examples/**'
|
||||
|
8
.github/workflows/workflow.yml
vendored
8
.github/workflows/workflow.yml
vendored
@ -2,17 +2,13 @@ name: Main workflow
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- verbose
|
||||
- releases/v1
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'examples/**'
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- verbose
|
||||
- releases/v1
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'examples/**'
|
||||
|
@ -1,11 +1,12 @@
|
||||
{
|
||||
"arrowParens": "avoid",
|
||||
"bracketSpacing": false,
|
||||
"endOfLine": "auto",
|
||||
"parser": "typescript",
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": false,
|
||||
"arrowParens": "avoid",
|
||||
"parser": "typescript"
|
||||
}
|
||||
"useTabs": false
|
||||
}
|
18
README.md
18
README.md
@ -31,6 +31,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
||||
- [Experimental Setup](#experimental-setup)
|
||||
- [Thread Safe Setup](#thread-safe-setup)
|
||||
- [Cache dependencies](#cache-dependencies)
|
||||
- [Composer GitHub OAuth](#composer-github-oauth)
|
||||
- [Problem Matchers](#problem-matchers)
|
||||
- [Examples](#examples)
|
||||
- [License](#scroll-license)
|
||||
@ -60,7 +61,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
||||
|Windows Server 2019|`windows-latest` or `windows-2019`|
|
||||
|Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`|
|
||||
|Ubuntu 16.04|`ubuntu-16.04`|
|
||||
|macOS X Catalina 10.15|`macos-latest` or `macOS-10.15`|
|
||||
|macOS X Catalina 10.15|`macos-latest` or `macos-10.15`|
|
||||
|
||||
## :heavy_plus_sign: PHP Extension Support
|
||||
- On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl` in the tools input.
|
||||
@ -277,7 +278,20 @@ In the above example, if you support a range of `composer` dependencies and do n
|
||||
|
||||
```yaml
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
```
|
||||
```
|
||||
|
||||
### Composer GitHub OAuth
|
||||
|
||||
If you have a number of workflows which setup multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. To avoid that you can add a `OAuth` token to the composer's config by setting `COMPOSER_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
|
||||
|
||||
```yaml
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.4'
|
||||
env:
|
||||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### Problem Matchers
|
||||
|
||||
|
@ -3,15 +3,29 @@ import * as extensions from '../src/extensions';
|
||||
describe('Extension tests', () => {
|
||||
it('checking addExtensionOnWindows', async () => {
|
||||
let win32: string = await extensions.addExtension(
|
||||
'xdebug, pcov, phalcon4, ast-beta',
|
||||
'Xdebug, pcov, sqlite, phalcon4, ast-beta',
|
||||
'7.4',
|
||||
'win32'
|
||||
);
|
||||
expect(win32).toContain('Add-Extension xdebug');
|
||||
expect(win32).toContain('Add-Extension pcov');
|
||||
expect(win32).toContain('Add-Extension sqlite3');
|
||||
expect(win32).toContain('phalcon.ps1 phalcon4');
|
||||
expect(win32).toContain('Add-Extension ast beta');
|
||||
|
||||
win32 = await extensions.addExtension('mysql', '7.4', 'win32');
|
||||
expect(win32).toContain('Add-Extension mysqli');
|
||||
expect(win32).toContain('Add-Extension mysqlnd');
|
||||
|
||||
win32 = await extensions.addExtension('mysql', '8.0', 'win32');
|
||||
expect(win32).toContain('Add-Extension mysqli');
|
||||
expect(win32).toContain('Add-Extension mysqlnd');
|
||||
|
||||
win32 = await extensions.addExtension('mysql', '5.6', 'win32');
|
||||
expect(win32).toContain('Add-Extension mysql');
|
||||
expect(win32).toContain('Add-Extension mysqli');
|
||||
expect(win32).toContain('Add-Extension mysqlnd');
|
||||
|
||||
win32 = await extensions.addExtension(
|
||||
'phalcon3, does_not_exist',
|
||||
'7.2',
|
||||
@ -27,13 +41,14 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnLinux', async () => {
|
||||
let linux: string = await extensions.addExtension(
|
||||
'xdebug, pcov, ast-beta, xdebug-alpha',
|
||||
'Xdebug, pcov, sqlite, ast-beta, xdebug-alpha',
|
||||
'7.4',
|
||||
'linux'
|
||||
);
|
||||
expect(linux).toContain('update_extension xdebug 2.9.0');
|
||||
expect(linux).toContain('update_extension xdebug 2.9.2');
|
||||
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
|
||||
expect(linux).toContain(
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
|
||||
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
|
||||
);
|
||||
expect(linux).toContain('add_unstable_extension ast beta extension');
|
||||
expect(linux).toContain(
|
||||
@ -64,12 +79,13 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnDarwin', async () => {
|
||||
let darwin: string = await extensions.addExtension(
|
||||
'xdebug, pcov, ast-beta',
|
||||
'Xdebug, pcov, sqlite, ast-beta',
|
||||
'7.2',
|
||||
'darwin'
|
||||
);
|
||||
expect(darwin).toContain('sudo pecl install -f xdebug');
|
||||
expect(darwin).toContain('sudo pecl install -f pcov');
|
||||
expect(darwin).toContain('sudo pecl install -f sqlite3');
|
||||
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
||||
|
||||
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
|
||||
|
@ -69,6 +69,8 @@ jest.mock('../src/install', () => ({
|
||||
* @param extension_csv
|
||||
* @param ini_values_csv
|
||||
* @param coverage_driver
|
||||
* @param tools
|
||||
* @param pecl
|
||||
*/
|
||||
function setEnv(
|
||||
version: string | number,
|
||||
|
@ -1,16 +1,6 @@
|
||||
import * as io from '@actions/io';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as matchers from '../src/matchers';
|
||||
|
||||
async function cleanup(path: string): Promise<void> {
|
||||
fs.unlink(path, error => {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
jest.mock('@actions/io');
|
||||
|
||||
describe('Matchers', () => {
|
||||
|
@ -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-'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -29,7 +29,9 @@ describe('Utils tests', () => {
|
||||
it('checking asyncForEach', async () => {
|
||||
const array: Array<string> = ['a', 'b', 'c'];
|
||||
let concat = '';
|
||||
await utils.asyncForEach(array, async function(str: string): Promise<void> {
|
||||
await utils.asyncForEach(array, async function (
|
||||
str: string
|
||||
): Promise<void> {
|
||||
concat += str;
|
||||
});
|
||||
expect(concat).toBe('abc');
|
||||
@ -55,12 +57,12 @@ describe('Utils tests', () => {
|
||||
path.join(__dirname, '../src/scripts/win32.ps1'),
|
||||
'utf8'
|
||||
);
|
||||
expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(darwin);
|
||||
expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
|
||||
expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
|
||||
expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux);
|
||||
expect(await utils.readScript('win32.ps1', '7.4', 'win32')).toBe(win32);
|
||||
expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
|
||||
expect(await utils.readScript('darwin.sh')).toBe(darwin);
|
||||
expect(await utils.readScript('darwin.sh')).toBe(darwin);
|
||||
expect(await utils.readScript('linux.sh')).toBe(linux);
|
||||
expect(await utils.readScript('linux.sh')).toBe(linux);
|
||||
expect(await utils.readScript('win32.ps1')).toBe(win32);
|
||||
expect(await utils.readScript('win32.ps1')).toBe(win32);
|
||||
});
|
||||
|
||||
it('checking writeScripts', async () => {
|
||||
@ -68,7 +70,10 @@ describe('Utils tests', () => {
|
||||
const runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || '';
|
||||
const script_path: string = path.join(runner_dir, 'test.sh');
|
||||
await utils.writeScript('test.sh', testString);
|
||||
await fs.readFile(script_path, function(error: Error | null, data: Buffer) {
|
||||
await fs.readFile(script_path, function (
|
||||
error: Error | null,
|
||||
data: Buffer
|
||||
) {
|
||||
expect(testString).toBe(data.toString());
|
||||
});
|
||||
await cleanup(script_path);
|
||||
|
@ -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.'
|
||||
@ -20,18 +21,17 @@ inputs:
|
||||
tools:
|
||||
description: 'Setup popular tools globally.'
|
||||
required: false
|
||||
# Deprecated options, do not use. Will not be supported in v2 which will be released around February 1, 2020.
|
||||
extension-csv:
|
||||
description: 'Deprecated! Use extensions instead.'
|
||||
deprecationMessage: 'The extension-csv property will not be supported in v2. Use extensions instead.'
|
||||
deprecationMessage: 'The extension-csv property is deprecated. Use extensions instead.'
|
||||
required: false
|
||||
ini-values-csv:
|
||||
description: 'Deprecated! Use ini-values instead.'
|
||||
deprecationMessage: 'The ini-values-csv property will not be supported in v2. Use ini-values instead.'
|
||||
deprecationMessage: 'The ini-values-csv property is deprecated. Use ini-values instead.'
|
||||
required: false
|
||||
pecl:
|
||||
description: 'Deprecated! Use tools instead to setup PECL.'
|
||||
deprecationMessage: 'The pecl property will not be supported in v2. Specify pecl in tools instead.'
|
||||
deprecationMessage: 'The pecl property is deprecated. Specify pecl in tools instead.'
|
||||
required: false
|
||||
runs:
|
||||
using: 'node12'
|
||||
|
1879
dist/index.js
vendored
1879
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -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)"
|
||||
|
@ -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)"
|
||||
|
@ -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)"
|
||||
|
@ -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)"
|
||||
|
@ -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)"
|
||||
|
@ -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)"
|
||||
|
@ -9,4 +9,4 @@ module.exports = {
|
||||
},
|
||||
verbose: true,
|
||||
collectCoverage: true
|
||||
};
|
||||
};
|
||||
|
3567
package-lock.json
generated
3567
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-php",
|
||||
"version": "1.8.2",
|
||||
"version": "1.8.8",
|
||||
"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/exec": "^1.0.3",
|
||||
"@actions/core": "^1.2.4",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/io": "^1.0.2",
|
||||
"fs": "0.0.1-security"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^25.1.1",
|
||||
"@types/node": "^13.7.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.18.0",
|
||||
"@typescript-eslint/parser": "^2.18.0",
|
||||
"@zeit/ncc": "^0.21.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.10.0",
|
||||
"eslint-plugin-import": "^2.20.1",
|
||||
"eslint-plugin-jest": "^23.6.0",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"husky": "^4.2.1",
|
||||
"jest": "^25.1.0",
|
||||
"jest-circus": "^25.1.0",
|
||||
"prettier": "^1.19.1",
|
||||
"ts-jest": "^25.1.0",
|
||||
"typescript": "^3.7.5"
|
||||
"@types/jest": "^25.2.1",
|
||||
"@types/node": "^14.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^2.33.0",
|
||||
"@typescript-eslint/parser": "^2.33.0",
|
||||
"@zeit/ncc": "^0.22.1",
|
||||
"eslint": "^7.0.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint-plugin-jest": "^23.11.0",
|
||||
"eslint-plugin-prettier": "^3.1.3",
|
||||
"husky": "^4.2.5",
|
||||
"jest": "^26.0.1",
|
||||
"jest-circus": "^26.0.1",
|
||||
"prettier": "^2.0.5",
|
||||
"ts-jest": "^25.5.1",
|
||||
"typescript": "^3.9.2"
|
||||
},
|
||||
"husky": {
|
||||
"skipCI": true,
|
||||
|
BIN
src/bin/php_nts_pcov.dll
Normal file
BIN
src/bin/php_nts_pcov.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,7 +10,7 @@ export async function addINIValuesUnix(
|
||||
): Promise<string> {
|
||||
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
||||
let script = '\n';
|
||||
await utils.asyncForEach(ini_values, async function(line: string) {
|
||||
await utils.asyncForEach(ini_values, async function (line: string) {
|
||||
script +=
|
||||
(await utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
|
||||
});
|
||||
@ -27,7 +27,7 @@ export async function addINIValuesWindows(
|
||||
): Promise<string> {
|
||||
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
||||
let script = '\n';
|
||||
await utils.asyncForEach(ini_values, async function(line: string) {
|
||||
await utils.asyncForEach(ini_values, async function (line: string) {
|
||||
script +=
|
||||
(await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n';
|
||||
});
|
||||
@ -44,6 +44,7 @@ export async function addINIValuesWindows(
|
||||
*
|
||||
* @param ini_values_csv
|
||||
* @param os_version
|
||||
* @param no_step
|
||||
*/
|
||||
export async function addINIValues(
|
||||
ini_values_csv: string,
|
||||
|
@ -15,12 +15,12 @@ export async function addExtensionDarwin(
|
||||
): Promise<string> {
|
||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||
let script = '\n';
|
||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||
extension = extension.toLowerCase();
|
||||
await utils.asyncForEach(extensions, async function (extension: string) {
|
||||
const version_extension: string = version + extension;
|
||||
const [extension_name, stability]: string[] = extension.split('-');
|
||||
const prefix = await utils.getExtensionPrefix(extension_name);
|
||||
let install_command = '';
|
||||
const ext_prefix = await utils.getExtensionPrefix(extension_name);
|
||||
const command_prefix = 'sudo pecl install -f ';
|
||||
let command = '';
|
||||
switch (true) {
|
||||
// match pre-release versions
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
@ -30,43 +30,54 @@ export async function addExtensionDarwin(
|
||||
' ' +
|
||||
stability +
|
||||
' ' +
|
||||
prefix;
|
||||
ext_prefix;
|
||||
return;
|
||||
// match 5.6xdebug
|
||||
case /5\.6xdebug/.test(version_extension):
|
||||
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
||||
command = command_prefix + 'xdebug-2.5.5' + pipe;
|
||||
break;
|
||||
// match 7.0xdebug
|
||||
case /7\.0xdebug/.test(version_extension):
|
||||
install_command = 'sudo pecl install -f xdebug-2.9.0' + pipe;
|
||||
command = command_prefix + 'xdebug-2.9.0' + pipe;
|
||||
break;
|
||||
// match 5.6redis
|
||||
case /5\.6redis/.test(version_extension):
|
||||
install_command = 'sudo pecl install -f redis-2.2.8' + pipe;
|
||||
command = command_prefix + 'redis-2.2.8' + pipe;
|
||||
break;
|
||||
case /[5-9]\.\dimagick/.test(version_extension):
|
||||
install_command =
|
||||
// match imagick
|
||||
case /^imagick$/.test(extension):
|
||||
command =
|
||||
'brew install pkg-config imagemagick' +
|
||||
pipe +
|
||||
' && sudo pecl install -f imagick' +
|
||||
' && ' +
|
||||
command_prefix +
|
||||
'imagick' +
|
||||
pipe;
|
||||
break;
|
||||
// match sqlite
|
||||
case /^sqlite$/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
command = command_prefix + extension + pipe;
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
install_command =
|
||||
'sh ' +
|
||||
script +=
|
||||
'\nbash ' +
|
||||
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
|
||||
' ' +
|
||||
extension +
|
||||
' ' +
|
||||
version +
|
||||
pipe;
|
||||
break;
|
||||
version;
|
||||
return;
|
||||
default:
|
||||
install_command = 'sudo pecl install -f ' + extension + pipe;
|
||||
command = command_prefix + extension + pipe;
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'\nadd_extension ' +
|
||||
extension +
|
||||
' "' +
|
||||
install_command +
|
||||
command +
|
||||
'" ' +
|
||||
(await utils.getExtensionPrefix(extension));
|
||||
});
|
||||
@ -78,17 +89,14 @@ export async function addExtensionDarwin(
|
||||
*
|
||||
* @param extension_csv
|
||||
* @param version
|
||||
* @param pipe
|
||||
*/
|
||||
export async function addExtensionWindows(
|
||||
extension_csv: string,
|
||||
version: string,
|
||||
pipe: string
|
||||
version: string
|
||||
): Promise<string> {
|
||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||
let script = '\n';
|
||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||
extension = extension.toLowerCase();
|
||||
await utils.asyncForEach(extensions, async function (extension: string) {
|
||||
const [extension_name, stability]: string[] = extension.split('-');
|
||||
const version_extension: string = version + extension;
|
||||
switch (true) {
|
||||
@ -96,6 +104,22 @@ export async function addExtensionWindows(
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
script += '\nAdd-Extension ' + extension_name + ' ' + stability;
|
||||
break;
|
||||
// match 5.6mysql, 5.6mysqli, 5.6mysqlnd
|
||||
case /^5\.6(mysql|mysqli|mysqlnd)$/.test(version_extension):
|
||||
script +=
|
||||
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
|
||||
break;
|
||||
// match 7.0mysql..8.0mysql
|
||||
// match 7.0mysqli..8.0mysqli
|
||||
// match 7.0mysqlnd..8.0mysqlnd
|
||||
case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
|
||||
script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
|
||||
break;
|
||||
// match sqlite
|
||||
case /^sqlite$/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
script += '\nAdd-Extension ' + extension;
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
script +=
|
||||
@ -129,12 +153,12 @@ export async function addExtensionLinux(
|
||||
): Promise<string> {
|
||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||
let script = '\n';
|
||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||
extension = extension.toLowerCase();
|
||||
await utils.asyncForEach(extensions, async function (extension: string) {
|
||||
const version_extension: string = version + extension;
|
||||
const [extension_name, stability]: string[] = extension.split('-');
|
||||
const prefix = await utils.getExtensionPrefix(extension_name);
|
||||
let install_command = '';
|
||||
const ext_prefix = await utils.getExtensionPrefix(extension_name);
|
||||
const command_prefix = 'sudo $debconf_fix apt-get install -y php';
|
||||
let command = '';
|
||||
switch (true) {
|
||||
// match pre-release versions
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
@ -144,12 +168,12 @@ export async function addExtensionLinux(
|
||||
' ' +
|
||||
stability +
|
||||
' ' +
|
||||
prefix;
|
||||
ext_prefix;
|
||||
return;
|
||||
// match 5.6gearman..7.4gearman
|
||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||
install_command =
|
||||
'sh ' +
|
||||
command =
|
||||
'\nbash ' +
|
||||
path.join(__dirname, '../src/scripts/ext/gearman.sh') +
|
||||
' ' +
|
||||
version +
|
||||
@ -158,7 +182,7 @@ export async function addExtensionLinux(
|
||||
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
script +=
|
||||
'\nsh ' +
|
||||
'\nbash ' +
|
||||
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
|
||||
' ' +
|
||||
extension +
|
||||
@ -168,14 +192,19 @@ export async function addExtensionLinux(
|
||||
// match 7.0xdebug..7.4xdebug
|
||||
case /^7\.[0-4]xdebug$/.test(version_extension):
|
||||
script +=
|
||||
'\nupdate_extension xdebug 2.9.0' +
|
||||
'\nupdate_extension xdebug 2.9.2' +
|
||||
pipe +
|
||||
'\n' +
|
||||
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||
return;
|
||||
// match sqlite
|
||||
case /^sqlite$/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
command = command_prefix + version + '-' + extension + pipe;
|
||||
break;
|
||||
default:
|
||||
install_command =
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +
|
||||
command =
|
||||
command_prefix +
|
||||
version +
|
||||
'-' +
|
||||
extension.replace('pdo_', '').replace('pdo-', '') +
|
||||
@ -183,7 +212,7 @@ export async function addExtensionLinux(
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'\nadd_extension ' + extension + ' "' + install_command + '" ' + prefix;
|
||||
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
|
||||
});
|
||||
return script;
|
||||
}
|
||||
@ -194,7 +223,7 @@ export async function addExtensionLinux(
|
||||
* @param extension_csv
|
||||
* @param version
|
||||
* @param os_version
|
||||
* @param log_prefix
|
||||
* @param no_step
|
||||
*/
|
||||
export async function addExtension(
|
||||
extension_csv: string,
|
||||
@ -216,7 +245,7 @@ export async function addExtension(
|
||||
|
||||
switch (os_version) {
|
||||
case 'win32':
|
||||
return script + (await addExtensionWindows(extension_csv, version, pipe));
|
||||
return script + (await addExtensionWindows(extension_csv, version));
|
||||
case 'darwin':
|
||||
return script + (await addExtensionDarwin(extension_csv, version, pipe));
|
||||
case 'linux':
|
||||
|
@ -37,7 +37,7 @@ export async function build(
|
||||
tools_csv = 'pecl, ' + tools_csv;
|
||||
}
|
||||
|
||||
let script: string = await utils.readScript(filename, version, os_version);
|
||||
let script: string = await utils.readScript(filename);
|
||||
script += await tools.addTools(tools_csv, version, os_version);
|
||||
|
||||
if (extension_csv) {
|
||||
|
@ -20,21 +20,17 @@ 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"
|
||||
if [ "$extension" != "mysql" ]; then
|
||||
php -m | grep -i -q -w "$extension"
|
||||
else
|
||||
php -m | grep -i -q "$extension"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -51,73 +47,94 @@ 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" = "composer" ]; then
|
||||
composer -q global config process-timeout 0
|
||||
echo "::add-path::/Users/$USER/.composer/vendor/bin"
|
||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
||||
fi
|
||||
elif [ "$tool" = "phive" ]; then
|
||||
add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1
|
||||
add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1
|
||||
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 >/dev/null 2>&1
|
||||
add_extension mbstring >/dev/null 2>&1
|
||||
add_extension xml >/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" >/dev/null 2>&1
|
||||
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
|
||||
(
|
||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" &&
|
||||
add_log "$tick" "$tool" "Added"
|
||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||
}
|
||||
@ -136,27 +153,48 @@ add_pecl() {
|
||||
add_log "$tick" "PECL" "Added"
|
||||
}
|
||||
|
||||
# Function to fetch updated formulas
|
||||
update_formulae() {
|
||||
brew_dir=$(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
|
||||
for formula in httpd pkg-config apr apr-util argon2 aspell autoconf bison curl-openssl freetds freetype gettext glib gmp icu4c jpeg krb5 libffi libpng libpq libsodium libzip oniguruma openldap openssl@1.1 re2c sqlite tidyp unixodbc webp; do
|
||||
sudo curl -o "$brew_dir"/"$formula".rb -sSL https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/"$formula".rb &
|
||||
to_wait+=( $! )
|
||||
done
|
||||
wait "${to_wait[@]}"
|
||||
}
|
||||
|
||||
# Function to setup PHP and composer
|
||||
setup_php_and_composer() {
|
||||
setup_php() {
|
||||
if [ "$version" = "8.0" ]; then
|
||||
update_formulae
|
||||
fi
|
||||
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
||||
brew tap shivammathur/homebrew-php >/dev/null 2>&1
|
||||
brew install shivammathur/php/php@"$version" >/dev/null 2>&1
|
||||
brew link --force --overwrite php@"$version" >/dev/null 2>&1
|
||||
brew tap shivammathur/homebrew-php
|
||||
brew install shivammathur/php/php@"$version"
|
||||
brew link --force --overwrite php@"$version"
|
||||
}
|
||||
|
||||
# Variables
|
||||
tick="✓"
|
||||
cross="✗"
|
||||
version=$1
|
||||
tool_path_dir="/usr/local/bin"
|
||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||
|
||||
# Setup PHP and composer
|
||||
# Setup PHP
|
||||
step_log "Setup PHP"
|
||||
setup_php_and_composer
|
||||
if [ "$existing_version" != "$version" ]; then
|
||||
setup_php >/dev/null 2>&1
|
||||
status="Installed"
|
||||
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" "$tool_path_dir"
|
||||
echo "date.timezone=UTC" >>"$ini_file"
|
||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||
sudo chmod 777 "$ini_file"
|
||||
mkdir -p "$(pecl config-get ext_dir)"
|
||||
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 ' ')
|
||||
add_log "$tick" "PHP" "Installed PHP $semver"
|
||||
configure_pecl
|
||||
add_log "$tick" "PHP" "$status PHP $semver"
|
||||
|
@ -1,15 +0,0 @@
|
||||
php_h="https://raw.githubusercontent.com/php/php-src/PHP-$2/main/php.h"
|
||||
os=$(uname -s)
|
||||
if [ "$os" = "Linux" ]; then
|
||||
apiv=$(curl -sSL --retry 5 "$php_h" | grep "PHP_API_VERSION" | cut -d' ' -f 3)
|
||||
dir="/usr/lib/php/$apiv"
|
||||
sudo mkdir -p "$dir" && sudo chown -R "$USER":"$(id -g -n)" /usr/lib/php
|
||||
elif [ "$os" = "Darwin" ]; then
|
||||
apiv=$(curl -sSL --retry 5 "$php_h" | grep "PHP_API_VERSION" | cut -d' ' -f 3)
|
||||
dir="/usr/local/lib/php/pecl/$apiv"
|
||||
else
|
||||
dir='C:\\tools\\php\\ext'
|
||||
fi
|
||||
hash=$(echo -n "$1" | openssl dgst -sha256 | cut -d ' ' -f 2)
|
||||
echo "::set-output name=ext_dir::$dir"
|
||||
echo "::set-output name=ext_hash::$hash"
|
@ -22,7 +22,6 @@ update_ppa() {
|
||||
install_phalcon() {
|
||||
extension=$1
|
||||
version=$2
|
||||
(sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||
(update_ppa && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||
}
|
||||
@ -36,7 +35,7 @@ tick="✓"
|
||||
cross="✗"
|
||||
|
||||
if [ "$extension_major_version" = "4" ]; then
|
||||
if [ -e "$ext_dir/psr.so" ]; then
|
||||
if [ -e "$ext_dir/psr.so" ] && ! php -m | grep -i -q -w psr; then
|
||||
echo "extension=psr.so" | sudo tee -a "$ini_file" >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
@ -69,4 +68,4 @@ if [ "$extension_major_version" = "3" ]; then
|
||||
else
|
||||
install_phalcon "$1" "$2"
|
||||
fi
|
||||
fi
|
||||
fi
|
@ -1,17 +1,47 @@
|
||||
# Function to log result of a operation
|
||||
add_log() {
|
||||
mark=$1
|
||||
subject=$2
|
||||
message=$3
|
||||
if [ "$mark" = "$tick" ]; then
|
||||
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||
else
|
||||
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to install phalcon
|
||||
install_phalcon() {
|
||||
(
|
||||
sed -i '' '/extension.*psr/d' "$ini_file"
|
||||
brew tap shivammathur/homebrew-phalcon >/dev/null 2>&1
|
||||
brew install phalcon@"$php_version"_"$extension_major" >/dev/null 2>&1
|
||||
sudo cp /usr/local/opt/psr@"$php_version"/psr.so "$ext_dir" >/dev/null 2>&1
|
||||
sudo cp /usr/local/opt/phalcon@"$php_version"_"$extension_major"/phalcon.so "$ext_dir" >/dev/null 2>&1
|
||||
add_log "$tick" "$extension" "Installed and enabled"
|
||||
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||
}
|
||||
|
||||
tick="✓"
|
||||
cross="✗"
|
||||
extension=$1
|
||||
extension_major=${extension: -1}
|
||||
php_version=$2
|
||||
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||
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*||")
|
||||
if [ -e "$ext_dir/psr.so" ] && [ -e "$ext_dir/phalcon.so" ]; then
|
||||
echo "extension=psr" >>"$ini_file"
|
||||
echo "extension=phalcon" >>"$ini_file"
|
||||
phalcon_version=$(php -d="extension=phalcon" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
||||
phalcon_version=$(php -d="extension=psr.so" -d="extension=phalcon.so" -r "echo phpversion('phalcon');" 2>/dev/null | cut -d'.' -f 1)
|
||||
if php -m | grep -i -q -w psr; then
|
||||
phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" 2>/dev/null | cut -d'.' -f 1)
|
||||
fi
|
||||
if [ "$phalcon_version" != "$extension_major" ]; then
|
||||
brew tap shivammathur/homebrew-phalcon
|
||||
brew install phalcon@"$php_version"_"$extension_major"
|
||||
install_phalcon
|
||||
else
|
||||
if ! php -m | grep -i -q -w psr; then echo "extension=psr.so" >>"$ini_file"; fi
|
||||
echo "extension=phalcon.so" >>"$ini_file"
|
||||
add_log "$tick" "$extension" "Enabled"
|
||||
fi
|
||||
else
|
||||
brew tap shivammathur/homebrew-phalcon
|
||||
brew install phalcon@"$php_version"_"$extension_major"
|
||||
install_phalcon
|
||||
fi
|
@ -19,15 +19,15 @@ add_log() {
|
||||
# Function to update php ppa
|
||||
update_ppa() {
|
||||
if [ "$ppa_updated" = "false" ]; then
|
||||
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
||||
ppa_updated="true"
|
||||
sudo "$debconf_fix" apt-get update >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to configure PECL
|
||||
configure_pecl() {
|
||||
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
|
||||
for tool in pear pecl; do
|
||||
sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
|
||||
sudo "$tool" config-set php_ini "$pecl_file" >/dev/null 2>&1
|
||||
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
||||
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
|
||||
done
|
||||
@ -48,31 +48,22 @@ 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"
|
||||
if [ "$extension" != "mysql" ]; then
|
||||
php -m | grep -i -q -w "$extension"
|
||||
else
|
||||
php -m | grep -i -q "$extension"
|
||||
fi
|
||||
sudo chmod 777 "$ini_file"
|
||||
}
|
||||
|
||||
# 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 sed -i "/$extension/d" "$pecl_file"
|
||||
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
||||
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||
}
|
||||
|
||||
@ -85,13 +76,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" >>"$pecl_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 +122,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 +144,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
|
||||
@ -149,12 +153,16 @@ add_tool() {
|
||||
sudo chmod a+x "$tool_path"
|
||||
if [ "$tool" = "composer" ]; then
|
||||
composer -q global config process-timeout 0
|
||||
echo "::add-path::/home/$USER/.composer/vendor/bin"
|
||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
||||
fi
|
||||
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,13 +171,12 @@ add_tool() {
|
||||
}
|
||||
|
||||
# Function to setup a tool using composer
|
||||
add_composer_tool() {
|
||||
add_composertool() {
|
||||
tool=$1
|
||||
release=$2
|
||||
prefix=$3
|
||||
(
|
||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" &&
|
||||
add_log "$tick" "$tool" "Added"
|
||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||
}
|
||||
@ -177,7 +184,7 @@ add_composer_tool() {
|
||||
# Function to setup phpize and php-config
|
||||
add_devtools() {
|
||||
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then
|
||||
$apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
|
||||
update_ppa && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
|
||||
fi
|
||||
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
|
||||
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
|
||||
@ -186,14 +193,18 @@ add_devtools() {
|
||||
|
||||
# Function to setup the nightly build from master branch
|
||||
setup_master() {
|
||||
update_ppa && $apt_install libzip-dev libwebp-dev >/dev/null 2>&1
|
||||
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz
|
||||
install_dir=~/php/"$version"
|
||||
bintray_url=https://dl.bintray.com/shivammathur/php/"$tar_file"
|
||||
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
|
||||
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/
|
||||
curl -o /tmp/"$tar_file" -sSL "$bintray_url"
|
||||
sudo tar xf /tmp/"$tar_file" -C ~/php
|
||||
for tool_path in "$install_dir"/bin/*; do
|
||||
tool=$(basename "$tool_path")
|
||||
sudo cp "$tool_path" /usr/bin/"$tool$version"
|
||||
sudo update-alternatives --install /usr/bin/"$tool" "$tool" /usr/bin/"$tool$version" 50 >/dev/null 2>&1
|
||||
done
|
||||
sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
|
||||
}
|
||||
|
||||
@ -216,52 +227,53 @@ 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"
|
||||
existing_version=$(php-config --version | cut -c 1-3)
|
||||
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 2>/dev/null | cut -c 1-3)
|
||||
|
||||
# Setup PHP
|
||||
step_log "Setup PHP"
|
||||
sudo mkdir -p /var/run
|
||||
sudo mkdir -p /run/php
|
||||
sudo mkdir -p /var/run /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)
|
||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||
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*||")
|
||||
pecl_file="$scan_dir"/99-pecl.ini
|
||||
sudo touch "$pecl_file" >/dev/null 2>&1
|
||||
sudo chmod 777 "$ini_file" "$tool_path_dir" "$pecl_file"
|
||||
add_log "$tick" "PHP" "$status PHP $semver"
|
||||
|
@ -20,6 +20,18 @@ Function Add-Log($mark, $subject, $message) {
|
||||
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
|
||||
}
|
||||
|
||||
Function Install-PhpManager() {
|
||||
$repo = "mlocati/powershell-phpmanager"
|
||||
$zip_file = "$php_dir\PhpManager.zip"
|
||||
$tags = Invoke-WebRequest https://api.github.com/repos/$repo/tags | ConvertFrom-Json
|
||||
$tag = $tags[0].Name
|
||||
$module_path = "$php_dir\PhpManager\powershell-phpmanager-$tag\PhpManager"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri https://github.com/$repo/archive/$tag.zip -OutFile $zip_file
|
||||
Expand-Archive -Path $zip_file -DestinationPath $php_dir\PhpManager
|
||||
Import-Module $module_path
|
||||
Add-Content -Path $PsHome\profile.ps1 -Value "Import-Module $module_path"
|
||||
}
|
||||
|
||||
Function Add-Extension {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
@ -91,10 +103,7 @@ Function Add-Tool() {
|
||||
if (Test-Path $php_dir\$tool) {
|
||||
Remove-Item $php_dir\$tool
|
||||
}
|
||||
if ($tool -eq "composer") {
|
||||
Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir
|
||||
composer -q global config process-timeout 0
|
||||
} elseif ($tool -eq "symfony") {
|
||||
if ($tool -eq "symfony") {
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe
|
||||
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.exe" > $null 2>&1
|
||||
} else {
|
||||
@ -113,10 +122,16 @@ Function Add-Tool() {
|
||||
Add-Extension curl >$null 2>&1
|
||||
Add-Extension mbstring >$null 2>&1
|
||||
Add-Extension xml >$null 2>&1
|
||||
}
|
||||
if($tool -eq "cs2pr") {
|
||||
} elseif($tool -eq "cs2pr") {
|
||||
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
||||
} elseif($tool -eq "composer") {
|
||||
composer -q global config process-timeout 0
|
||||
Write-Output "::add-path::$env:APPDATA\Composer\vendor\bin"
|
||||
if (Test-Path env:COMPOSER_TOKEN) {
|
||||
composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN
|
||||
}
|
||||
}
|
||||
|
||||
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
||||
Add-Log $tick $tool "Added"
|
||||
} else {
|
||||
@ -124,7 +139,7 @@ Function Add-Tool() {
|
||||
}
|
||||
}
|
||||
|
||||
Function Add-Composer-Tool() {
|
||||
Function Add-Composertool() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
@ -144,15 +159,13 @@ Function Add-Composer-Tool() {
|
||||
)
|
||||
composer -q global require $prefix$release 2>&1 | out-null
|
||||
if($?) {
|
||||
$composer_dir = composer -q global config home | ForEach-Object { $_ -replace "/", "\" }
|
||||
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $composer_dir\vendor\bin\$tool.bat"
|
||||
Add-Log $tick $tool "Added"
|
||||
} else {
|
||||
Add-Log $cross $tool "Could not setup $tool"
|
||||
}
|
||||
}
|
||||
|
||||
Function Add-PECL() {
|
||||
Function Add-Pecl() {
|
||||
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
||||
}
|
||||
|
||||
@ -160,28 +173,26 @@ Function Add-PECL() {
|
||||
$tick = ([char]8730)
|
||||
$cross = ([char]10007)
|
||||
$php_dir = 'C:\tools\php'
|
||||
$ext_dir = $php_dir + '\ext'
|
||||
$ext_dir = "$php_dir\ext"
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$master_version = '8.0'
|
||||
$arch = 'x64'
|
||||
$ts = $false
|
||||
if((Test-Path env:PHPTS) -and $env:PHPTS -eq 'ts') {
|
||||
$ts = $true
|
||||
$ts = $env:PHPTS -eq 'ts'
|
||||
if($env:PHPTS -ne 'ts') {
|
||||
$env:PHPTS = 'nts'
|
||||
}
|
||||
|
||||
Step-Log "Setup PhpManager"
|
||||
Install-Module -Name PhpManager -Force -Scope CurrentUser
|
||||
Install-PhpManager >$null 2>&1
|
||||
Add-Log $tick "PhpManager" "Installed"
|
||||
|
||||
Step-Log "Setup PHP"
|
||||
$installed = $null
|
||||
if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
||||
try {
|
||||
$installed = Get-Php -Path $php_dir
|
||||
}
|
||||
catch {
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
Step-Log "Setup PHP"
|
||||
$status = "Installed"
|
||||
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
||||
if ($version -lt '7.0') {
|
||||
@ -194,22 +205,15 @@ 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
|
||||
Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
|
||||
Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir
|
||||
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir
|
||||
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
|
||||
if ($version -eq 'master') {
|
||||
if($installed.ThreadSafe) {
|
||||
Copy-Item $dir"\..\src\bin\php_ts_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
|
||||
} else {
|
||||
Copy-Item $dir"\..\src\bin\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
|
||||
}
|
||||
Copy-Item $dir"\..\src\bin\php_$env:PHPTS`_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
|
||||
Set-PhpIniKey -Key 'opcache.jit_buffer_size' -Value '256M' -Path $php_dir
|
||||
Set-PhpIniKey -Key 'opcache.jit' -Value '1235' -Path $php_dir
|
||||
}
|
||||
|
160
src/tools.ts
160
src/tools.ts
@ -1,60 +1,21 @@
|
||||
import * as utils from './utils';
|
||||
|
||||
/**
|
||||
* Function to get command to setup tool
|
||||
* Function to get command to setup tools
|
||||
*
|
||||
* @param os_version
|
||||
* @param suffix
|
||||
*/
|
||||
export async function getArchiveCommand(os_version: string): Promise<string> {
|
||||
export async function getCommand(
|
||||
os_version: string,
|
||||
suffix: string
|
||||
): Promise<string> {
|
||||
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<string> {
|
||||
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<string> {
|
||||
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',
|
||||
@ -109,6 +70,8 @@ export async function parseTool(
|
||||
/**
|
||||
* Function to get the url of tool with the given version
|
||||
*
|
||||
* @param tool
|
||||
* @param extension
|
||||
* @param version
|
||||
* @param prefix
|
||||
* @param version_prefix
|
||||
@ -138,23 +101,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<string> {
|
||||
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,28 +122,62 @@ export async function getCodeceptionUri(
|
||||
version: string,
|
||||
php_version: string
|
||||
): Promise<string> {
|
||||
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 codecept;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get script to setup phive
|
||||
*
|
||||
* @param tool
|
||||
* @param version
|
||||
* @param url
|
||||
* @param os_version
|
||||
*/
|
||||
export async function addPhive(
|
||||
@ -198,12 +187,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 +203,24 @@ export async function addPhive(
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the PHPUnit url
|
||||
* Function to get the phar url in domain/tool-version.phar format
|
||||
*
|
||||
* @param domain
|
||||
* @param tool
|
||||
* @param prefix
|
||||
* @param version
|
||||
*/
|
||||
export async function getPhpunitUrl(
|
||||
export async function getPharUrl(
|
||||
domain: string,
|
||||
tool: string,
|
||||
prefix: string,
|
||||
version: string
|
||||
): Promise<string> {
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,7 +276,7 @@ export async function getSymfonyUri(
|
||||
/**
|
||||
* Function to add/move composer in the tools list
|
||||
*
|
||||
* @param tools
|
||||
* @param tools_list
|
||||
*/
|
||||
export async function addComposer(tools_list: string[]): Promise<string[]> {
|
||||
const regex = /^composer($|:.*)/;
|
||||
@ -310,7 +303,7 @@ export async function getCleanedToolsList(
|
||||
let tools_list: string[] = await utils.CSVArray(tools_csv);
|
||||
tools_list = await addComposer(tools_list);
|
||||
tools_list = tools_list
|
||||
.map(function(extension: string) {
|
||||
.map(function (extension: string) {
|
||||
return extension
|
||||
.trim()
|
||||
.replace(/robmorgan\/|hirak\/|narrowspark\/automatic-/, '');
|
||||
@ -333,7 +326,7 @@ export async function addArchive(
|
||||
url: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
return (await getArchiveCommand(os_version)) + url + ' ' + tool;
|
||||
return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -385,14 +378,15 @@ export async function addPackage(
|
||||
prefix: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
const tool_command = await getPackageCommand(os_version);
|
||||
const tool_command = await getCommand(os_version, 'composertool');
|
||||
return tool_command + tool + ' ' + release + ' ' + prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup tools
|
||||
*
|
||||
* @param tool_csv
|
||||
* @param tools_csv
|
||||
* @param php_version
|
||||
* @param os_version
|
||||
*/
|
||||
export async function addTools(
|
||||
@ -402,7 +396,7 @@ export async function addTools(
|
||||
): Promise<string> {
|
||||
let script = '\n' + (await utils.stepLog('Setup Tools', os_version));
|
||||
const tools_list: Array<string> = await getCleanedToolsList(tools_csv);
|
||||
await utils.asyncForEach(tools_list, async function(release: string) {
|
||||
await utils.asyncForEach(tools_list, async function (release: string) {
|
||||
const tool_data: {name: string; version: string} = await parseTool(release);
|
||||
const tool: string = tool_data.name;
|
||||
const version: string = tool_data.version;
|
||||
@ -449,8 +443,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.
|
||||
// Preferred 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 +457,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 +479,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':
|
||||
|
16
src/utils.ts
16
src/utils.ts
@ -65,7 +65,6 @@ export async function color(type: string): Promise<string> {
|
||||
* @param message
|
||||
* @param os_version
|
||||
* @param log_type
|
||||
* @param prefix
|
||||
*/
|
||||
export async function log(
|
||||
message: string,
|
||||
@ -121,6 +120,7 @@ export async function stepLog(
|
||||
* @param mark
|
||||
* @param subject
|
||||
* @param message
|
||||
* @param os_version
|
||||
*/
|
||||
export async function addLog(
|
||||
mark: string,
|
||||
@ -147,14 +147,8 @@ export async function addLog(
|
||||
* Read the scripts
|
||||
*
|
||||
* @param filename
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
export async function readScript(
|
||||
filename: string,
|
||||
version: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
export async function readScript(filename: string): Promise<string> {
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../src/scripts/' + filename),
|
||||
'utf8'
|
||||
@ -165,7 +159,6 @@ export async function readScript(
|
||||
* Write final script which runs
|
||||
*
|
||||
* @param filename
|
||||
* @param version
|
||||
* @param script
|
||||
*/
|
||||
export async function writeScript(
|
||||
@ -193,9 +186,10 @@ export async function extensionArray(
|
||||
default:
|
||||
return extension_csv
|
||||
.split(',')
|
||||
.map(function(extension: string) {
|
||||
.map(function (extension: string) {
|
||||
return extension
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace('php-', '')
|
||||
.replace('php_', '');
|
||||
})
|
||||
@ -217,7 +211,7 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
|
||||
default:
|
||||
return values_csv
|
||||
.split(',')
|
||||
.map(function(value: string) {
|
||||
.map(function (value: string) {
|
||||
return value.trim();
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
|
BIN
update.zip
BIN
update.zip
Binary file not shown.
Reference in New Issue
Block a user