mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Merge pull request #48 from shivammathur/develop
1.3.7 - restructure code, fix extensions on 7.4 and add example
This commit is contained in:
commit
06929bdf4c
@ -129,6 +129,11 @@ jobs:
|
||||
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
- [Laravel](./example/laravel.yml)
|
||||
|
||||
|
||||
## :scroll: License
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE). This project has multiple [dependencies](https://github.com/shivammathur/setup-php/network/dependencies) and their licenses can be found in their respective repositories.
|
||||
|
@ -14,17 +14,17 @@ describe('Features tests', () => {
|
||||
'7.2',
|
||||
'win32'
|
||||
);
|
||||
expect(win32).toContain(
|
||||
'Install-PhpExtension xdebug -MinimumStability stable'
|
||||
);
|
||||
expect(win32).toContain(
|
||||
'Install-PhpExtension pcov -MinimumStability stable'
|
||||
);
|
||||
expect(win32).toContain('Install-PhpExtension xdebug');
|
||||
expect(win32).toContain('Install-PhpExtension pcov');
|
||||
win32 = await features.addExtension('xdebug, pcov', '7.4', 'win32');
|
||||
const extension_url: string =
|
||||
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
||||
expect(win32).toContain(
|
||||
'Install-PhpExtension xdebug -Version 2.8 -MinimumStability beta'
|
||||
'Invoke-WebRequest -Uri ' +
|
||||
extension_url +
|
||||
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
|
||||
);
|
||||
expect(win32).toContain('Install-PhpExtension pcov -MinimumStability beta');
|
||||
expect(win32).toContain('Install-PhpExtension pcov');
|
||||
|
||||
win32 = await features.addExtension('does_not_exist', '7.2', 'win32');
|
||||
expect(win32).toContain('Could not find does_not_exist for PHP7.2 on PECL');
|
||||
@ -46,6 +46,10 @@ describe('Features tests', () => {
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-pcov'
|
||||
);
|
||||
|
||||
linux = await features.addExtension('xdebug, pcov', '7.4', 'linux');
|
||||
expect(linux).toContain('./xdebug.sh');
|
||||
expect(linux).toContain('./pcov.sh');
|
||||
|
||||
linux = await features.addExtension('xdebug', '7.2', 'fedora');
|
||||
expect(linux).toContain('Platform fedora is not supported');
|
||||
});
|
||||
@ -68,6 +72,12 @@ describe('Features tests', () => {
|
||||
darwin = await features.addExtension('xdebug', '5.6', 'darwin');
|
||||
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
||||
|
||||
darwin = await features.addExtension('xdebug', '7.4', 'darwin');
|
||||
expect(darwin).toContain('sh ./xdebug_darwin.sh');
|
||||
|
||||
darwin = await features.addExtension('pcov', '7.4', 'darwin');
|
||||
expect(darwin).toContain('sh ./pcov.sh');
|
||||
|
||||
darwin = await features.addExtension('xdebug', '7.2', 'darwin');
|
||||
expect(darwin).toContain('sudo pecl install xdebug');
|
||||
|
||||
@ -136,25 +146,25 @@ describe('Features tests', () => {
|
||||
|
||||
it('checking addCoverage on windows', async () => {
|
||||
let win32: string = await features.addCoverage('xdebug', '7.4', 'win32');
|
||||
const extension_url: string =
|
||||
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
||||
expect(win32).toContain(
|
||||
'Install-PhpExtension xdebug -Version 2.8 -MinimumStability beta'
|
||||
'Invoke-WebRequest -Uri ' +
|
||||
extension_url +
|
||||
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
|
||||
);
|
||||
|
||||
win32 = await features.addCoverage('xdebug', '7.3', 'win32');
|
||||
expect(win32).toContain(
|
||||
'Install-PhpExtension xdebug -MinimumStability stable'
|
||||
);
|
||||
expect(win32).toContain('Install-PhpExtension xdebug');
|
||||
|
||||
win32 = await features.addCoverage('pcov', '7.4', 'win32');
|
||||
expect(win32).toContain('Install-PhpExtension pcov -MinimumStability beta');
|
||||
expect(win32).toContain('Install-PhpExtension pcov');
|
||||
expect(win32).toContain(
|
||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
|
||||
);
|
||||
|
||||
win32 = await features.addCoverage('pcov', '7.3', 'win32');
|
||||
expect(win32).toContain(
|
||||
'Install-PhpExtension pcov -MinimumStability stable'
|
||||
);
|
||||
expect(win32).toContain('Install-PhpExtension pcov');
|
||||
expect(win32).toContain(
|
||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
|
||||
);
|
||||
@ -174,18 +184,11 @@ describe('Features tests', () => {
|
||||
|
||||
it('checking addCoverage on linux', async () => {
|
||||
let linux: string = await features.addCoverage('xdebug', '7.4', 'linux');
|
||||
expect(linux).toContain(
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.4-xdebug'
|
||||
);
|
||||
expect(linux).toContain('./xdebug.sh');
|
||||
|
||||
linux = await features.addCoverage('pcov', '7.4', 'linux');
|
||||
expect(linux).toContain(
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.4-pcov'
|
||||
);
|
||||
expect(linux).toContain(
|
||||
"sudo phpdismod xdebug || echo 'xdebug not installed'"
|
||||
);
|
||||
expect(linux).toContain("sudo phpenmod pcov || echo 'pcov not installed'");
|
||||
expect(linux).toContain('./pcov.sh');
|
||||
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
|
||||
|
||||
linux = await features.addCoverage('', '7.4', 'linux');
|
||||
expect(linux).toEqual('');
|
||||
@ -193,13 +196,13 @@ describe('Features tests', () => {
|
||||
|
||||
it('checking addCoverage on darwin', async () => {
|
||||
let darwin: string = await features.addCoverage('xdebug', '7.4', 'darwin');
|
||||
expect(darwin).toContain('sudo pecl install xdebug');
|
||||
expect(darwin).toContain('sh ./xdebug_darwin.sh');
|
||||
|
||||
darwin = await features.addCoverage('xdebug', '5.6', 'darwin');
|
||||
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
||||
|
||||
darwin = await features.addCoverage('pcov', '7.4', 'darwin');
|
||||
expect(darwin).toContain('sudo pecl install pcov');
|
||||
expect(darwin).toContain('sh ./pcov.sh');
|
||||
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file\n');
|
||||
|
||||
darwin = await features.addCoverage('', '7.4', 'win32');
|
||||
|
15
__tests__/pecl.test.ts
Normal file
15
__tests__/pecl.test.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import * as pecl from '../src/pecl';
|
||||
|
||||
let valid_extensions = ['xdebug', 'pcov'];
|
||||
jest.mock('../src/pecl', () => ({
|
||||
checkPECLExtension: jest.fn().mockImplementation(extension => {
|
||||
return valid_extensions.indexOf(extension) !== -1;
|
||||
})
|
||||
}));
|
||||
|
||||
describe('pecl tests', () => {
|
||||
it('checking checkPECLExtension', async () => {
|
||||
expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false);
|
||||
expect(await pecl.checkPECLExtension('xdebug')).toBe(true);
|
||||
});
|
||||
});
|
@ -1,14 +1,6 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as utils from '../src/utils';
|
||||
import * as pecl from '../src/pecl';
|
||||
|
||||
let valid_extensions = ['xdebug', 'pcov'];
|
||||
jest.mock('../src/pecl', () => ({
|
||||
checkPECLExtension: jest.fn().mockImplementation(extension => {
|
||||
return valid_extensions.indexOf(extension) !== -1;
|
||||
})
|
||||
}));
|
||||
|
||||
jest.mock('@actions/core', () => ({
|
||||
getInput: jest.fn().mockImplementation(key => {
|
||||
@ -45,24 +37,25 @@ describe('Utils tests', () => {
|
||||
|
||||
it('checking readScripts', async () => {
|
||||
let rc: string = fs.readFileSync(
|
||||
path.join(__dirname, '../src/7.4.sh'),
|
||||
path.join(__dirname, '../src/scripts/7.4.sh'),
|
||||
'utf8'
|
||||
);
|
||||
let darwin: string = fs.readFileSync(
|
||||
path.join(__dirname, '../src/darwin.sh'),
|
||||
path.join(__dirname, '../src/scripts/darwin.sh'),
|
||||
'utf8'
|
||||
);
|
||||
let linux: string = fs.readFileSync(
|
||||
path.join(__dirname, '../src/linux.sh'),
|
||||
path.join(__dirname, '../src/scripts/linux.sh'),
|
||||
'utf8'
|
||||
);
|
||||
let win32: string = fs.readFileSync(
|
||||
path.join(__dirname, '../src/win32.ps1'),
|
||||
path.join(__dirname, '../src/scripts/win32.ps1'),
|
||||
'utf8'
|
||||
);
|
||||
expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(rc);
|
||||
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.3', 'win32')).toBe(win32);
|
||||
expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain(
|
||||
'Platform fedora is not supported'
|
||||
@ -88,6 +81,8 @@ describe('Utils tests', () => {
|
||||
'c',
|
||||
'd'
|
||||
]);
|
||||
expect(await utils.extensionArray('')).toEqual([]);
|
||||
expect(await utils.extensionArray(' ')).toEqual([]);
|
||||
});
|
||||
|
||||
it('checking INIArray', async () => {
|
||||
@ -96,6 +91,8 @@ describe('Utils tests', () => {
|
||||
'b=2',
|
||||
'c=3'
|
||||
]);
|
||||
expect(await utils.INIArray('')).toEqual([]);
|
||||
expect(await utils.INIArray(' ')).toEqual([]);
|
||||
});
|
||||
|
||||
it('checking log', async () => {
|
||||
@ -108,7 +105,7 @@ describe('Utils tests', () => {
|
||||
warning_log = await utils.log(message, 'linux', 'warning');
|
||||
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
||||
warning_log = await utils.log(message, 'darwin', 'warning');
|
||||
expect(warning_log).toEqual('echo -e "\\033[33;1m' + message + '\\033[0m"');
|
||||
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
||||
|
||||
let error_log: string = await utils.log(message, 'win32', 'error');
|
||||
// expect(error_log).toEqual(
|
||||
@ -117,7 +114,7 @@ describe('Utils tests', () => {
|
||||
error_log = await utils.log(message, 'linux', 'error');
|
||||
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
||||
error_log = await utils.log(message, 'darwin', 'error');
|
||||
expect(error_log).toEqual('echo -e "\\033[31;1m' + message + '\\033[0m"');
|
||||
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
||||
|
||||
let success_log: string = await utils.log(message, 'win32', 'success');
|
||||
// expect(success_log).toEqual(
|
||||
@ -126,7 +123,7 @@ describe('Utils tests', () => {
|
||||
success_log = await utils.log(message, 'linux', 'success');
|
||||
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
||||
success_log = await utils.log(message, 'darwin', 'success');
|
||||
expect(success_log).toEqual('echo -e "\\033[32;1m' + message + '\\033[0m"');
|
||||
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
||||
});
|
||||
|
||||
it('checking getExtensionPrefix', async () => {
|
||||
@ -138,9 +135,3 @@ describe('Utils tests', () => {
|
||||
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
|
||||
});
|
||||
});
|
||||
describe('pecl tests', () => {
|
||||
it('checking checkPECLExtension', async () => {
|
||||
expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false);
|
||||
expect(await pecl.checkPECLExtension('xdebug')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
58
example/laravel.yml
Normal file
58
example/laravel.yml
Normal file
@ -0,0 +1,58 @@
|
||||
name: Laravel
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
|
||||
phpunit:
|
||||
name: PHPUnit (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DB_PASSWORD: password
|
||||
BROADCAST_DRIVER: log
|
||||
CACHE_DRIVER: redis
|
||||
QUEUE_CONNECTION: redis
|
||||
SESSION_DRIVER: redis
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
env:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: false
|
||||
MYSQL_ROOT_PASSWORD: password
|
||||
MYSQL_DATABASE: laravel
|
||||
ports:
|
||||
- 3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- 6379/tcp
|
||||
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 15
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
php-versions: ['7.2', '7.3']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extension-csv: mbstring, xdebug #optional
|
||||
ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional
|
||||
coverage: xdebug #optional
|
||||
- name: Install Composer dependencies
|
||||
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||
- name: Prepare the application
|
||||
run: |
|
||||
cp .env.example .env
|
||||
php artisan key:generate
|
||||
- name: Clear Config
|
||||
run: php artisan config:clear
|
||||
- name: Run Migration
|
||||
run: php artisan migrate -v
|
||||
env:
|
||||
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
101
lib/features.js
101
lib/features.js
@ -76,8 +76,8 @@ exports.enableExtensionWindows = enableExtensionWindows;
|
||||
*/
|
||||
function enableExtensionUnix(extension, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return (`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/php_${extension}.so" ]; then
|
||||
echo "${yield utils.getExtensionPrefix(extension)}=php_${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
||||
return (`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||
echo "${yield utils.getExtensionPrefix(extension)}=${extension}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
||||
(yield utils.log('Enabled ' + extension, os_version, 'success')) +
|
||||
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
||||
(yield utils.log('Extension ' + extension + ' was already enabled', os_version, 'success')) +
|
||||
@ -102,25 +102,30 @@ function addExtensionDarwin(extension_csv, version) {
|
||||
script += yield enableExtensionUnix(extension, 'darwin');
|
||||
switch (yield pecl.checkPECLExtension(extension)) {
|
||||
case true:
|
||||
let extension_version = extension;
|
||||
let install_command = '';
|
||||
switch (version + extension) {
|
||||
case '5.6xdebug':
|
||||
extension_version = 'xdebug-2.5.5';
|
||||
break;
|
||||
case '7.4xdebug':
|
||||
extension_version = 'xdebug-2.8.0beta2';
|
||||
install_command =
|
||||
'sh ./xdebug_darwin.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||
break;
|
||||
case '7.4pcov':
|
||||
install_command =
|
||||
'sh ./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||
break;
|
||||
case '5.6xdebug':
|
||||
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1';
|
||||
break;
|
||||
case '7.2xdebug':
|
||||
default:
|
||||
extension_version = extension;
|
||||
install_command =
|
||||
'sudo pecl install ' + extension + ' >/dev/null 2>&1';
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'if [ ! "$(php -m | grep -i ' +
|
||||
extension +
|
||||
')" ]; then sudo pecl install ' +
|
||||
extension_version +
|
||||
' >/dev/null 2>&1 && ' +
|
||||
')" ]; then ' +
|
||||
install_command +
|
||||
' && ' +
|
||||
(yield utils.log('Installed and enabled ' + extension, 'darwin', 'success')) +
|
||||
' || ' +
|
||||
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error')) +
|
||||
@ -157,36 +162,29 @@ function addExtensionWindows(extension_csv, version) {
|
||||
extension = extension.toLowerCase();
|
||||
// add script to enable extension is already installed along with php
|
||||
script += yield enableExtensionWindows(extension);
|
||||
let extension_stability = '';
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
extension_stability = 'beta';
|
||||
break;
|
||||
case '7.2':
|
||||
default:
|
||||
extension_stability = 'stable';
|
||||
break;
|
||||
}
|
||||
switch (yield pecl.checkPECLExtension(extension)) {
|
||||
case true:
|
||||
let extension_version = extension;
|
||||
let install_command = '';
|
||||
switch (version + extension) {
|
||||
case '7.4xdebug':
|
||||
extension_version = 'xdebug -Version 2.8';
|
||||
const extension_url = 'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
||||
install_command =
|
||||
'Invoke-WebRequest -Uri ' +
|
||||
extension_url +
|
||||
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll\n';
|
||||
install_command += 'Enable-PhpExtension xdebug';
|
||||
break;
|
||||
case '7.2xdebug':
|
||||
default:
|
||||
extension_version = extension;
|
||||
install_command = 'Install-PhpExtension ' + extension;
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'if(!(php -m | findstr -i ' +
|
||||
extension +
|
||||
')) { ' +
|
||||
'try { Install-PhpExtension ' +
|
||||
extension_version +
|
||||
' -MinimumStability ' +
|
||||
extension_stability +
|
||||
'try { ' +
|
||||
install_command +
|
||||
'\n' +
|
||||
(yield utils.log('Installed and enabled ' + extension, 'win32', 'success')) +
|
||||
' } catch [Exception] { ' +
|
||||
@ -224,25 +222,34 @@ function addExtensionLinux(extension_csv, version) {
|
||||
extension = extension.toLowerCase();
|
||||
// add script to enable extension is already installed along with php
|
||||
script += yield enableExtensionUnix(extension, 'linux');
|
||||
let install_command = '';
|
||||
switch (version + extension) {
|
||||
case '7.4xdebug':
|
||||
install_command =
|
||||
'./xdebug.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||
break;
|
||||
case '7.4pcov':
|
||||
install_command =
|
||||
'./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||
break;
|
||||
default:
|
||||
install_command =
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||
version +
|
||||
'-' +
|
||||
extension +
|
||||
' >/dev/null 2>&1';
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'if [ ! "$(php -m | grep -i ' +
|
||||
extension +
|
||||
')" ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||
version +
|
||||
'-' +
|
||||
extension +
|
||||
' >/dev/null 2>&1 || sudo DEBIAN_FRONTEND=noninteractive apt install -y php-' +
|
||||
extension +
|
||||
' >/dev/null 2>&1 && ' +
|
||||
')" ]; then ' +
|
||||
install_command +
|
||||
' && ' +
|
||||
(yield utils.log('Installed and enabled ' + extension, 'linux', 'success')) +
|
||||
' || ' +
|
||||
(yield utils.log('Could not find php-' +
|
||||
extension +
|
||||
' or php' +
|
||||
version +
|
||||
'-' +
|
||||
extension +
|
||||
' on APT repository', 'linux', 'error')) +
|
||||
(yield utils.log('Could not find php' + version + '-' + extension + ' on APT repository', 'linux', 'error')) +
|
||||
'; fi\n';
|
||||
});
|
||||
});
|
||||
@ -299,14 +306,12 @@ function addCoverage(coverage, version, os_version) {
|
||||
// if version is 7.1 or newer
|
||||
switch (version) {
|
||||
default:
|
||||
script += yield addExtension(coverage, version, os_version);
|
||||
script += yield addExtension('pcov', version, os_version);
|
||||
script += yield addINIValues('pcov.enabled=1', os_version);
|
||||
// add command to disable xdebug and enable pcov
|
||||
switch (os_version) {
|
||||
case 'linux':
|
||||
script +=
|
||||
"sudo phpdismod xdebug || echo 'xdebug not installed'\n";
|
||||
script += "sudo phpenmod pcov || echo 'pcov not installed'\n";
|
||||
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
||||
break;
|
||||
case 'darwin':
|
||||
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
||||
@ -328,7 +333,7 @@ function addCoverage(coverage, version, os_version) {
|
||||
break;
|
||||
//xdebug
|
||||
case 'xdebug':
|
||||
script += yield addExtension(coverage, version, os_version);
|
||||
script += yield addExtension('xdebug', version, os_version);
|
||||
script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success');
|
||||
break;
|
||||
// unknown coverage driver
|
||||
|
@ -39,7 +39,7 @@ function run() {
|
||||
darwin += yield features.addINIValues(ini_values_csv, os_version);
|
||||
darwin += yield features.addCoverage(coverage, version, os_version);
|
||||
yield utils.writeScript('darwin.sh', version, darwin);
|
||||
yield exec_1.exec('sh -x ./' + version + 'darwin.sh ' + version);
|
||||
yield exec_1.exec('sh ./' + version + 'darwin.sh ' + version);
|
||||
}
|
||||
else if (os_version == 'win32') {
|
||||
let windows = yield utils.readScript('win32.ps1', version, os_version);
|
||||
|
50
lib/utils.js
50
lib/utils.js
@ -47,6 +47,19 @@ function asyncForEach(array, callback) {
|
||||
});
|
||||
}
|
||||
exports.asyncForEach = asyncForEach;
|
||||
/**
|
||||
* Copy config
|
||||
*
|
||||
* @param files
|
||||
*/
|
||||
function readFiles74(files) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield asyncForEach(files, function (filename) {
|
||||
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(fs.createWriteStream(filename.split('/')[1], { mode: 0o755 }));
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.readFiles74 = readFiles74;
|
||||
/**
|
||||
* Read the scripts
|
||||
*
|
||||
@ -60,15 +73,27 @@ function readScript(filename, version, os_version) {
|
||||
case 'darwin':
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
fs.createReadStream(path.join(__dirname, '../src/config.yaml')).pipe(fs.createWriteStream('config.yaml'));
|
||||
return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
|
||||
yield readFiles74([
|
||||
'configs/config.yaml',
|
||||
'scripts/xdebug_darwin.sh',
|
||||
'scripts/pcov.sh'
|
||||
]);
|
||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8');
|
||||
case '7.3':
|
||||
default:
|
||||
return fs.readFileSync(path.join(__dirname, '../src/' + filename), 'utf8');
|
||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
||||
}
|
||||
case 'linux':
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
yield readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
||||
case '7.3':
|
||||
default:
|
||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
||||
}
|
||||
case 'win32':
|
||||
case 'linux':
|
||||
return fs.readFileSync(path.join(__dirname, '../src/' + filename), 'utf8');
|
||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
||||
default:
|
||||
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||
}
|
||||
@ -94,12 +119,18 @@ exports.writeScript = writeScript;
|
||||
*/
|
||||
function extensionArray(extension_csv) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
switch (extension_csv) {
|
||||
case '':
|
||||
case ' ':
|
||||
return [];
|
||||
default:
|
||||
return extension_csv.split(',').map(function (extension) {
|
||||
return extension
|
||||
.trim()
|
||||
.replace('php-', '')
|
||||
.replace('php_', '');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.extensionArray = extensionArray;
|
||||
@ -111,9 +142,15 @@ exports.extensionArray = extensionArray;
|
||||
*/
|
||||
function INIArray(ini_values_csv) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
switch (ini_values_csv) {
|
||||
case '':
|
||||
case ' ':
|
||||
return [];
|
||||
default:
|
||||
return ini_values_csv.split(',').map(function (ini_value) {
|
||||
return ini_value.trim();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.INIArray = INIArray;
|
||||
@ -133,10 +170,9 @@ function log(message, os_version, log_type) {
|
||||
};
|
||||
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
||||
case 'linux':
|
||||
return ('echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
|
||||
case 'darwin':
|
||||
default:
|
||||
return ('echo -e "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
|
||||
return ('echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-php",
|
||||
"version": "1.3.6",
|
||||
"version": "1.3.7",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-php",
|
||||
"version": "1.3.6",
|
||||
"version": "1.3.7",
|
||||
"private": false,
|
||||
"description": "Setup php action",
|
||||
"main": "lib/setup-php.js",
|
||||
|
@ -1,60 +0,0 @@
|
||||
variants:
|
||||
dev:
|
||||
bcmath:
|
||||
calendar:
|
||||
cli:
|
||||
ctype:
|
||||
dom:
|
||||
fileinfo:
|
||||
filter:
|
||||
ipc:
|
||||
iconv:
|
||||
json:
|
||||
mbregex:
|
||||
mbstring:
|
||||
mhash:
|
||||
mcrypt:
|
||||
pcntl:
|
||||
pcre:
|
||||
pdo:
|
||||
phar:
|
||||
posix:
|
||||
sockets:
|
||||
tokenizer:
|
||||
xml:
|
||||
curl:
|
||||
openssl:
|
||||
zip:
|
||||
gd:
|
||||
- --with-freetype
|
||||
- --with-pdo-mysql=mysqlnd
|
||||
- --with-mysqli=mysqlnd
|
||||
- --with-pgsql
|
||||
- --with-pdo-pgsql
|
||||
- --with-gmp=/usr/local/opt/gmp
|
||||
- --with-openssl
|
||||
- --with-pear
|
||||
- --with-zip
|
||||
- --with-zlib-dir=/usr/local/opt/zlib
|
||||
- --with-libxml
|
||||
- --with-kerberos
|
||||
- --with-gd
|
||||
- --with-ffi
|
||||
- --with-bz2=/usr/local/opt/bzip2
|
||||
- --with-readline=/usr/local/opt/readline
|
||||
- --with-iconv=/usr/local/opt/libiconv
|
||||
- --with-icu-dir=/usr/local/opt/icu4c
|
||||
- --enable-intl
|
||||
- --enable-xml
|
||||
- --enable-sysvsem
|
||||
- --enable-sysvshm
|
||||
- --enable-sysvmsg
|
||||
- --enable-phpdbg
|
||||
- --enable-exif
|
||||
- --enable-gd
|
||||
- --enable-soap
|
||||
- --enable-xmlreader
|
||||
- --enable-zend-test=shared
|
||||
extensions:
|
||||
dev:
|
||||
xdebug: stable
|
@ -35,15 +35,16 @@ variants:
|
||||
- --with-openssl
|
||||
- --with-pear
|
||||
- --with-zip
|
||||
- --with-zlib-dir=/usr/local/opt/zlib
|
||||
- --with-libxml
|
||||
- --with-kerberos
|
||||
- --with-gd
|
||||
- --with-ffi
|
||||
- --with-bz2=/usr/local/opt/bzip2
|
||||
- --with-curl
|
||||
- --with-mhash
|
||||
- --with-readline=/usr/local/opt/readline
|
||||
- --with-iconv=/usr/local/opt/libiconv
|
||||
- --with-icu-dir=/usr/local/opt/icu4c
|
||||
- --with-config-file-path=/etc
|
||||
- --enable-intl
|
||||
- --enable-xml
|
||||
- --enable-sysvsem
|
||||
@ -55,6 +56,3 @@ variants:
|
||||
- --enable-soap
|
||||
- --enable-xmlreader
|
||||
- --enable-zend-test=shared
|
||||
extensions:
|
||||
dev:
|
||||
xdebug: stable
|
101
src/features.ts
101
src/features.ts
@ -76,10 +76,10 @@ export async function enableExtensionUnix(
|
||||
os_version: string
|
||||
) {
|
||||
return (
|
||||
`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/php_${extension}.so" ]; then
|
||||
`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||
echo "${await utils.getExtensionPrefix(
|
||||
extension
|
||||
)}=php_${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
||||
)}=${extension}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
||||
(await utils.log('Enabled ' + extension, os_version, 'success')) +
|
||||
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
||||
(await utils.log(
|
||||
@ -109,25 +109,30 @@ export async function addExtensionDarwin(
|
||||
script += await enableExtensionUnix(extension, 'darwin');
|
||||
switch (await pecl.checkPECLExtension(extension)) {
|
||||
case true:
|
||||
let extension_version: string = extension;
|
||||
let install_command: string = '';
|
||||
switch (version + extension) {
|
||||
case '5.6xdebug':
|
||||
extension_version = 'xdebug-2.5.5';
|
||||
break;
|
||||
case '7.4xdebug':
|
||||
extension_version = 'xdebug-2.8.0beta2';
|
||||
install_command =
|
||||
'sh ./xdebug_darwin.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||
break;
|
||||
case '7.4pcov':
|
||||
install_command =
|
||||
'sh ./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||
break;
|
||||
case '5.6xdebug':
|
||||
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1';
|
||||
break;
|
||||
case '7.2xdebug':
|
||||
default:
|
||||
extension_version = extension;
|
||||
install_command =
|
||||
'sudo pecl install ' + extension + ' >/dev/null 2>&1';
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'if [ ! "$(php -m | grep -i ' +
|
||||
extension +
|
||||
')" ]; then sudo pecl install ' +
|
||||
extension_version +
|
||||
' >/dev/null 2>&1 && ' +
|
||||
')" ]; then ' +
|
||||
install_command +
|
||||
' && ' +
|
||||
(await utils.log(
|
||||
'Installed and enabled ' + extension,
|
||||
'darwin',
|
||||
@ -175,37 +180,31 @@ export async function addExtensionWindows(
|
||||
extension = extension.toLowerCase();
|
||||
// add script to enable extension is already installed along with php
|
||||
script += await enableExtensionWindows(extension);
|
||||
let extension_stability: string = '';
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
extension_stability = 'beta';
|
||||
break;
|
||||
case '7.2':
|
||||
default:
|
||||
extension_stability = 'stable';
|
||||
break;
|
||||
}
|
||||
|
||||
switch (await pecl.checkPECLExtension(extension)) {
|
||||
case true:
|
||||
let extension_version: string = extension;
|
||||
let install_command: string = '';
|
||||
switch (version + extension) {
|
||||
case '7.4xdebug':
|
||||
extension_version = 'xdebug -Version 2.8';
|
||||
const extension_url: string =
|
||||
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
||||
install_command =
|
||||
'Invoke-WebRequest -Uri ' +
|
||||
extension_url +
|
||||
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll\n';
|
||||
install_command += 'Enable-PhpExtension xdebug';
|
||||
break;
|
||||
case '7.2xdebug':
|
||||
default:
|
||||
extension_version = extension;
|
||||
install_command = 'Install-PhpExtension ' + extension;
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'if(!(php -m | findstr -i ' +
|
||||
extension +
|
||||
')) { ' +
|
||||
'try { Install-PhpExtension ' +
|
||||
extension_version +
|
||||
' -MinimumStability ' +
|
||||
extension_stability +
|
||||
'try { ' +
|
||||
install_command +
|
||||
'\n' +
|
||||
(await utils.log(
|
||||
'Installed and enabled ' + extension,
|
||||
@ -254,16 +253,32 @@ export async function addExtensionLinux(
|
||||
extension = extension.toLowerCase();
|
||||
// add script to enable extension is already installed along with php
|
||||
script += await enableExtensionUnix(extension, 'linux');
|
||||
script +=
|
||||
'if [ ! "$(php -m | grep -i ' +
|
||||
extension +
|
||||
')" ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||
|
||||
let install_command: string = '';
|
||||
switch (version + extension) {
|
||||
case '7.4xdebug':
|
||||
install_command =
|
||||
'./xdebug.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||
break;
|
||||
case '7.4pcov':
|
||||
install_command =
|
||||
'./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||
break;
|
||||
default:
|
||||
install_command =
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||
version +
|
||||
'-' +
|
||||
extension +
|
||||
' >/dev/null 2>&1 || sudo DEBIAN_FRONTEND=noninteractive apt install -y php-' +
|
||||
' >/dev/null 2>&1';
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'if [ ! "$(php -m | grep -i ' +
|
||||
extension +
|
||||
' >/dev/null 2>&1 && ' +
|
||||
')" ]; then ' +
|
||||
install_command +
|
||||
' && ' +
|
||||
(await utils.log(
|
||||
'Installed and enabled ' + extension,
|
||||
'linux',
|
||||
@ -271,13 +286,7 @@ export async function addExtensionLinux(
|
||||
)) +
|
||||
' || ' +
|
||||
(await utils.log(
|
||||
'Could not find php-' +
|
||||
extension +
|
||||
' or php' +
|
||||
version +
|
||||
'-' +
|
||||
extension +
|
||||
' on APT repository',
|
||||
'Could not find php' + version + '-' + extension + ' on APT repository',
|
||||
'linux',
|
||||
'error'
|
||||
)) +
|
||||
@ -334,15 +343,13 @@ export async function addCoverage(
|
||||
// if version is 7.1 or newer
|
||||
switch (version) {
|
||||
default:
|
||||
script += await addExtension(coverage, version, os_version);
|
||||
script += await addExtension('pcov', version, os_version);
|
||||
script += await addINIValues('pcov.enabled=1', os_version);
|
||||
|
||||
// add command to disable xdebug and enable pcov
|
||||
switch (os_version) {
|
||||
case 'linux':
|
||||
script +=
|
||||
"sudo phpdismod xdebug || echo 'xdebug not installed'\n";
|
||||
script += "sudo phpenmod pcov || echo 'pcov not installed'\n";
|
||||
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
||||
break;
|
||||
case 'darwin':
|
||||
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
||||
@ -373,7 +380,7 @@ export async function addCoverage(
|
||||
break;
|
||||
//xdebug
|
||||
case 'xdebug':
|
||||
script += await addExtension(coverage, version, os_version);
|
||||
script += await addExtension('xdebug', version, os_version);
|
||||
script += await utils.log(
|
||||
'Xdebug enabled as coverage driver',
|
||||
os_version,
|
||||
|
@ -27,7 +27,7 @@ async function run() {
|
||||
darwin += await features.addINIValues(ini_values_csv, os_version);
|
||||
darwin += await features.addCoverage(coverage, version, os_version);
|
||||
await utils.writeScript('darwin.sh', version, darwin);
|
||||
await exec('sh -x ./' + version + 'darwin.sh ' + version);
|
||||
await exec('sh ./' + version + 'darwin.sh ' + version);
|
||||
} else if (os_version == 'win32') {
|
||||
let windows: string = await utils.readScript(
|
||||
'win32.ps1',
|
||||
|
@ -1,7 +1,7 @@
|
||||
brew install pkg-config autoconf bison re2c openssl krb5 bzip2 enchant libffi libpng webp freetype intltool icu4c libiconv zlib t1lib gd libzip gmp tidyp libxml2 libxslt postgresql >/dev/null 2>&1
|
||||
brew install pkg-config autoconf bison re2c openssl@1.1 krb5 enchant libffi freetype intltool icu4c libiconv t1lib gd libzip gmp tidyp libxml2 libxslt postgresql curl >/dev/null 2>&1
|
||||
brew link icu4c gettext --force >/dev/null 2>&1
|
||||
|
||||
for package in gettext gmp bzip2 krb5 icu4c bison openssl libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype;
|
||||
for package in gettext gmp krb5 icu4c bison openssl@1.1 libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype;
|
||||
do
|
||||
caps_package=$(echo "$package" | tr '[:lower:]' '[:upper:]')
|
||||
{
|
||||
@ -18,17 +18,16 @@ echo 'export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib"'
|
||||
echo 'export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include"'
|
||||
echo 'export ICU_LIBS="-L/usr/local/opt/icu4c/lib"'
|
||||
echo 'export ICU_CFLAGS="-I/usr/local/opt/icu4c/include"'
|
||||
echo 'export OPENSSL_LIBS="-L/usr/local/Cellar/openssl/1.0.2s/lib -lcrypto"'
|
||||
echo 'export OPENSSL_CFLAGS="-I/usr/local/Cellar/openssl/1.0.2s/include"'
|
||||
echo 'export OPENSSL_ROOT_DIR="/usr/local/opt/openssl"'
|
||||
echo 'export OPENSSL_LIB_DIR="/usr/local/opt/openssl/lib"'
|
||||
echo 'export OPENSSL_INCLUDE_DIR="/usr/local/opt/openssl/include"'
|
||||
echo 'export PKG_CONFIG_PATH="/usr/local/Cellar/openssl/1.0.2s/lib/pkgconfig:$PKG_CONFIG_PATH"'
|
||||
echo 'export OPENSSL_LIBS="-L/usr/local/opt/openssl@1.1/lib -lcrypto"'
|
||||
echo 'export OPENSSL_CFLAGS="-I/usr/local/opt/openssl@1.1/include"'
|
||||
echo 'export OPENSSL_ROOT_DIR="/usr/local/opt/openssl@1.1/"'
|
||||
echo 'export OPENSSL_LIB_DIR="/usr/local/opt/openssl@1.1/lib"'
|
||||
echo 'export OPENSSL_INCLUDE_DIR="/usr/local/opt/openssl@1.1/include"'
|
||||
echo 'export PKG_CONFIG="/usr/local/opt/pkgconfig/bin/pkg-config"'
|
||||
echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib
|
||||
/usr/local/opt/readline/lib/libreadline.dylib
|
||||
/usr/local/opt/openssl/lib/libssl.dylib
|
||||
/usr/local/opt/openssl/lib/libcrypto.dylib
|
||||
/usr/local/opt/openssl@1.1/lib/libssl.dylib
|
||||
/usr/local/opt/openssl@1.1/lib/libcrypto.dylib
|
||||
/usr/local/opt/icu4c/lib/libicudata.dylib
|
||||
/usr/local/opt/icu4c/lib/libicui18n.dylib
|
||||
/usr/local/opt/icu4c/lib/libicuio.dylib
|
||||
@ -36,25 +35,25 @@ echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib
|
||||
/usr/local/opt/icu4c/lib/libicuuc.dylib"'
|
||||
} >> ~/.bash_profile
|
||||
config_file=$(pwd)/config.yaml
|
||||
cd ~ || echo "could not move to ~"
|
||||
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1
|
||||
chmod +x ./phpbrew
|
||||
sudo mv phpbrew /usr/local/bin/phpbrew
|
||||
sudo mkdir -p /opt/phpbrew
|
||||
sudo mkdir -p /usr/local/lib
|
||||
sudo mkdir -p /usr/local/bin
|
||||
sudo phpbrew init --root=/opt/phpbrew --config="$config_file" >/dev/null 2>&1
|
||||
sudo chmod -R 777 /opt/phpbrew
|
||||
export PHPBREW_ROOT=/opt/phpbrew
|
||||
export PHPBREW_HOME=/opt/phpbrew
|
||||
echo "[[ -e ~/.phpbrew/bash_profile ]] && source ~/.phpbrew/bash_profile" >> ~/.bash_profile
|
||||
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
|
||||
source ~/.bash_profile >/dev/null 2>&1
|
||||
sudo mkdir -p /usr/local/lib
|
||||
phpbrew install -j 4 7.4.0RC2 +dev
|
||||
phpbrew switch php-7.4.0RC2
|
||||
phpbrew ext install +dev >/dev/null 2>&1
|
||||
sudo mkdir -p /usr/local/bin
|
||||
sudo ln -sf /opt/phpbrew/php/php-7.4.0RC2/bin/* /usr/local/bin/
|
||||
source ~/.bashrc >/dev/null 2>&1
|
||||
phpbrew install -j 6 7.4.0RC3 +dev >/dev/null 2>&1
|
||||
phpbrew switch 7.4.0RC3
|
||||
sudo ln -sf /opt/phpbrew/php/php-7.4.0RC3/bin/* /usr/local/bin/
|
||||
sudo ln -sf /opt/phpbrew/php/php-7.4.0RC3/etc/php.ini /etc/php.ini
|
||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||
pecl config-set php_ini $ini_file
|
||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||
ext_dir=$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")
|
||||
pecl config-set php_ini "$ini_file"
|
||||
sudo chmod 777 "$ini_file"
|
||||
brew install composer
|
@ -4,6 +4,11 @@ if [ "$version" != "$1" ]; then
|
||||
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y >/dev/null 2>&1
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt update -y >/dev/null 2>&1
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
|
||||
if [ "$1" != "7.4" ]; then
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
|
||||
else
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" php"$1"-dev curl php"$1"-curl >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
for tool in php phar phar.phar php-cgi php-config phpize; do
|
||||
if [ -e "/usr/bin/$tool$1" ]; then
|
7
src/scripts/pcov.sh
Normal file
7
src/scripts/pcov.sh
Normal file
@ -0,0 +1,7 @@
|
||||
git clone --depth=1 https://github.com/krakjoe/pcov.git
|
||||
(
|
||||
cd pcov && phpize
|
||||
./configure --enable-pcov
|
||||
make
|
||||
sudo make install
|
||||
)
|
5
src/scripts/xdebug.sh
Normal file
5
src/scripts/xdebug.sh
Normal file
@ -0,0 +1,5 @@
|
||||
git clone --depth=1 https://github.com/xdebug/xdebug.git
|
||||
(
|
||||
cd xdebug || echo "cd failed"
|
||||
sudo ./rebuild.sh
|
||||
)
|
8
src/scripts/xdebug_darwin.sh
Normal file
8
src/scripts/xdebug_darwin.sh
Normal file
@ -0,0 +1,8 @@
|
||||
git clone --depth=1 https://github.com/xdebug/xdebug.git
|
||||
(
|
||||
cd xdebug || echo "cd failed"
|
||||
sudo phpize
|
||||
sudo ./configure
|
||||
sudo make
|
||||
sudo cp modules/xdebug.so "$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")"
|
||||
)
|
61
src/utils.ts
61
src/utils.ts
@ -32,6 +32,19 @@ export async function asyncForEach(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy config
|
||||
*
|
||||
* @param files
|
||||
*/
|
||||
export async function readFiles74(files: Array<string>) {
|
||||
await asyncForEach(files, function(filename: string) {
|
||||
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(
|
||||
fs.createWriteStream(filename.split('/')[1], {mode: 0o755})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the scripts
|
||||
*
|
||||
@ -48,21 +61,40 @@ export async function readScript(
|
||||
case 'darwin':
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
fs.createReadStream(path.join(__dirname, '../src/config.yaml')).pipe(
|
||||
fs.createWriteStream('config.yaml')
|
||||
await readFiles74([
|
||||
'configs/config.yaml',
|
||||
'scripts/xdebug_darwin.sh',
|
||||
'scripts/pcov.sh'
|
||||
]);
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../src/scripts/7.4.sh'),
|
||||
'utf8'
|
||||
);
|
||||
return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
|
||||
case '7.3':
|
||||
default:
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../src/' + filename),
|
||||
path.join(__dirname, '../src/scripts/' + filename),
|
||||
'utf8'
|
||||
);
|
||||
}
|
||||
case 'linux':
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
await readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../src/scripts/' + filename),
|
||||
'utf8'
|
||||
);
|
||||
case '7.3':
|
||||
default:
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../src/scripts/' + filename),
|
||||
'utf8'
|
||||
);
|
||||
}
|
||||
case 'win32':
|
||||
case 'linux':
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../src/' + filename),
|
||||
path.join(__dirname, '../src/scripts/' + filename),
|
||||
'utf8'
|
||||
);
|
||||
default:
|
||||
@ -96,6 +128,11 @@ export async function writeScript(
|
||||
export async function extensionArray(
|
||||
extension_csv: string
|
||||
): Promise<Array<string>> {
|
||||
switch (extension_csv) {
|
||||
case '':
|
||||
case ' ':
|
||||
return [];
|
||||
default:
|
||||
return extension_csv.split(',').map(function(extension: string) {
|
||||
return extension
|
||||
.trim()
|
||||
@ -103,6 +140,7 @@ export async function extensionArray(
|
||||
.replace('php_', '');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to break ini values csv into an array
|
||||
@ -111,10 +149,16 @@ export async function extensionArray(
|
||||
* @constructor
|
||||
*/
|
||||
export async function INIArray(ini_values_csv: string): Promise<Array<string>> {
|
||||
switch (ini_values_csv) {
|
||||
case '':
|
||||
case ' ':
|
||||
return [];
|
||||
default:
|
||||
return ini_values_csv.split(',').map(function(ini_value: string) {
|
||||
return ini_value.trim();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function log(
|
||||
message: string,
|
||||
@ -136,13 +180,10 @@ export async function log(
|
||||
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
||||
|
||||
case 'linux':
|
||||
return (
|
||||
'echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"'
|
||||
);
|
||||
case 'darwin':
|
||||
default:
|
||||
return (
|
||||
'echo -e "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"'
|
||||
'echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user