mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Improve examples and logging, and fix PCOV setup on linux
This commit is contained in:
parent
ba5306eea9
commit
17d90ace86
21
README.md
21
README.md
@ -10,8 +10,8 @@
|
|||||||
<a href="https://github.com/shivammathur/setup-php"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
|
<a href="https://github.com/shivammathur/setup-php"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
|
||||||
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
|
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
|
||||||
<a href="#tada-php-support"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
|
<a href="#tada-php-support"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
|
||||||
<a href="https://www.patreon.com/shivammathur"><img alt="Support me on Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> <a href="https://www.paypal.me/shivammathur"><img alt="Support me on Paypal" src="https://shivammathur.com/badges/paypal.svg"></a>
|
<a href="https://www.patreon.com/shivammathur"><img alt="Support me on Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> <a href="https://www.paypal.me/shivammathur"><img alt="Support me on PayPal" src="https://shivammathur.com/badges/paypal.svg"></a>
|
||||||
<a href="https://www.codementor.io/shivammathur?utm_source=github&utm_medium=button&utm_term=shivammathur&utm_campaign=github"><img alt="Get Help on codementor" src="https://cdn.codementor.io/badges/get_help_github.svg"></a>
|
<a href="https://www.codementor.io/shivammathur?utm_source=github&utm_medium=button&utm_term=shivammathur&utm_campaign=github"><img alt="Contact me on Codementor" src="https://cdn.codementor.io/badges/contact_me_github.svg"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Setup PHP with required extensions, php.ini configuration and composer in [GitHub Actions](https://github.com/features/actions). This action can be added as a step in your action workflow and it will setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage) section to see how to use this.
|
Setup PHP with required extensions, php.ini configuration and composer in [GitHub Actions](https://github.com/features/actions). This action can be added as a step in your action workflow and it will setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage) section to see how to use this.
|
||||||
@ -44,7 +44,7 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu
|
|||||||
- On `ubuntu` extensions which have the package in apt are installed.
|
- On `ubuntu` extensions which have the package in apt are installed.
|
||||||
- On `windows` and `macOS` PECL extensions are installed.
|
- On `windows` and `macOS` PECL extensions are installed.
|
||||||
- Extensions which are installed along with PHP if specified are enabled.
|
- Extensions which are installed along with PHP if specified are enabled.
|
||||||
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interruped.
|
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
|
||||||
|
|
||||||
## :signal_strength: Coverage support
|
## :signal_strength: Coverage support
|
||||||
- Specify `coverage: xdebug` to use `Xdebug`.
|
- Specify `coverage: xdebug` to use `Xdebug`.
|
||||||
@ -70,10 +70,10 @@ with:
|
|||||||
|
|
||||||
Inputs supported by this GitHub Action.
|
Inputs supported by this GitHub Action.
|
||||||
|
|
||||||
- php-version
|
- php-version `required`
|
||||||
- extension-csv (optional)
|
- extension-csv `optional`
|
||||||
- ini-values-csv (optional)
|
- ini-values-csv `optional`
|
||||||
- coverage (optional)
|
- coverage `optional`
|
||||||
|
|
||||||
See [action.yml](action.yml) for more info
|
See [action.yml](action.yml) for more info
|
||||||
|
|
||||||
@ -131,8 +131,13 @@ jobs:
|
|||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
- [Laravel](./example/laravel.yml)
|
Examples for setting up this GitHub Action with different PHP Frameworks/Packages.
|
||||||
|
|
||||||
|
**Note:** Make sure you add steps to run your tests after the setup steps given in these examples.
|
||||||
|
|
||||||
|
- [Laravel with MySQL](./example/laravel-mysql.yml)
|
||||||
|
- [Laravel with PostgreSQL](./example/laravel-postgres.yml)
|
||||||
|
- [Slim Framework](./example/slim-framework.yml)
|
||||||
|
|
||||||
## :scroll: License
|
## :scroll: License
|
||||||
|
|
||||||
|
@ -173,10 +173,10 @@ describe('Features tests', () => {
|
|||||||
expect(win32).toContain('');
|
expect(win32).toContain('');
|
||||||
|
|
||||||
win32 = await features.addCoverage('pcov', '7.0', 'win32');
|
win32 = await features.addCoverage('pcov', '7.0', 'win32');
|
||||||
expect(win32).toContain('pcov requires php 7.1 or newer');
|
expect(win32).toContain('PCOV requires PHP 7.1 or newer');
|
||||||
|
|
||||||
win32 = await features.addCoverage('pcov', '5.6', 'win32');
|
win32 = await features.addCoverage('pcov', '5.6', 'win32');
|
||||||
expect(win32).toContain('pcov requires php 7.1 or newer');
|
expect(win32).toContain('PCOV requires PHP 7.1 or newer');
|
||||||
|
|
||||||
win32 = await features.addCoverage('', '7.4', 'win32');
|
win32 = await features.addCoverage('', '7.4', 'win32');
|
||||||
expect(win32).toEqual('');
|
expect(win32).toEqual('');
|
||||||
@ -189,6 +189,7 @@ describe('Features tests', () => {
|
|||||||
linux = await features.addCoverage('pcov', '7.4', 'linux');
|
linux = await features.addCoverage('pcov', '7.4', 'linux');
|
||||||
expect(linux).toContain('./pcov.sh');
|
expect(linux).toContain('./pcov.sh');
|
||||||
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
|
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
|
||||||
|
expect(linux).toContain('sudo phpdismod xdebug');
|
||||||
|
|
||||||
linux = await features.addCoverage('', '7.4', 'linux');
|
linux = await features.addCoverage('', '7.4', 'linux');
|
||||||
expect(linux).toEqual('');
|
expect(linux).toEqual('');
|
||||||
@ -203,7 +204,6 @@ describe('Features tests', () => {
|
|||||||
|
|
||||||
darwin = await features.addCoverage('pcov', '7.4', 'darwin');
|
darwin = await features.addCoverage('pcov', '7.4', 'darwin');
|
||||||
expect(darwin).toContain('sh ./pcov.sh');
|
expect(darwin).toContain('sh ./pcov.sh');
|
||||||
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file\n');
|
|
||||||
|
|
||||||
darwin = await features.addCoverage('', '7.4', 'win32');
|
darwin = await features.addCoverage('', '7.4', 'win32');
|
||||||
expect(darwin).toEqual('');
|
expect(darwin).toEqual('');
|
||||||
|
@ -100,31 +100,53 @@ describe('Utils tests', () => {
|
|||||||
let message: string = 'Test message';
|
let message: string = 'Test message';
|
||||||
|
|
||||||
let warning_log: string = await utils.log(message, 'win32', 'warning');
|
let warning_log: string = await utils.log(message, 'win32', 'warning');
|
||||||
// expect(warning_log).toEqual(
|
expect(warning_log).toEqual(
|
||||||
// "Write-Host '" + message + "' -ForegroundColor yellow"
|
"Write-Host '" + message + "' -ForegroundColor yellow"
|
||||||
// );
|
);
|
||||||
warning_log = await utils.log(message, 'linux', 'warning');
|
warning_log = await utils.log(message, 'linux', 'warning');
|
||||||
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
||||||
warning_log = await utils.log(message, 'darwin', 'warning');
|
warning_log = await utils.log(message, 'darwin', 'warning');
|
||||||
expect(warning_log).toEqual('echo "\\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');
|
let error_log: string = await utils.log(message, 'win32', 'error');
|
||||||
// expect(error_log).toEqual(
|
expect(error_log).toEqual(
|
||||||
// "Write-Host '" + message + "' -ForegroundColor red"
|
"Write-Host '" + message + "' -ForegroundColor red"
|
||||||
// );
|
);
|
||||||
error_log = await utils.log(message, 'linux', 'error');
|
error_log = await utils.log(message, 'linux', 'error');
|
||||||
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
||||||
error_log = await utils.log(message, 'darwin', 'error');
|
error_log = await utils.log(message, 'darwin', 'error');
|
||||||
expect(error_log).toEqual('echo "\\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');
|
let success_log: string = await utils.log(message, 'win32', 'success');
|
||||||
// expect(success_log).toEqual(
|
expect(success_log).toEqual(
|
||||||
// "Write-Host '" + message + "' -ForegroundColor green"
|
"Write-Host '" + message + "' -ForegroundColor green"
|
||||||
// );
|
);
|
||||||
success_log = await utils.log(message, 'linux', 'success');
|
success_log = await utils.log(message, 'linux', 'success');
|
||||||
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
||||||
success_log = await utils.log(message, 'darwin', 'success');
|
success_log = await utils.log(message, 'darwin', 'success');
|
||||||
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
||||||
|
|
||||||
|
success_log = await utils.log(message, 'win32', 'success', 'Test win');
|
||||||
|
expect(success_log).toEqual(
|
||||||
|
"Write-Host 'Test win: " + message + "' -ForegroundColor green"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking log with prefix', async () => {
|
||||||
|
let message: string = 'Test message';
|
||||||
|
let prefix_log: string = await utils.log(
|
||||||
|
message,
|
||||||
|
'linux',
|
||||||
|
'success',
|
||||||
|
'Test Prefix'
|
||||||
|
);
|
||||||
|
expect(prefix_log).toEqual(
|
||||||
|
'echo "\\033[32;1mTest Prefix: ' + message + '\\033[0m"'
|
||||||
|
);
|
||||||
|
prefix_log = await utils.log(message, 'darwin', 'success', 'Test');
|
||||||
|
expect(prefix_log).toEqual(
|
||||||
|
'echo "\\033[32;1mTest: ' + message + '\\033[0m"'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking getExtensionPrefix', async () => {
|
it('checking getExtensionPrefix', async () => {
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
name: Laravel
|
name: Testing Laravel with MySQL
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
laravel:
|
||||||
phpunit:
|
name: Laravel (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
|
||||||
name: PHPUnit (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
DB_PASSWORD: password
|
DB_PASSWORD: password
|
||||||
@ -37,12 +34,11 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
- name: Install PHP
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extension-csv: mbstring, xdebug #optional
|
extension-csv: mbstring #optional
|
||||||
ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional
|
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
54
example/laravel-postgres.yml
Normal file
54
example/laravel-postgres.yml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
name: Testing Laravel with MySQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
laravel:
|
||||||
|
name: Laravel (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
BROADCAST_DRIVER: log
|
||||||
|
CACHE_DRIVER: redis
|
||||||
|
QUEUE_CONNECTION: redis
|
||||||
|
SESSION_DRIVER: redis
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:10.8
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
POSTGRES_DB: postgres
|
||||||
|
ports:
|
||||||
|
- 5432/tcp
|
||||||
|
options: --health-cmd pg_isready --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: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring #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:
|
||||||
|
POSTGRES_HOST: localhost
|
||||||
|
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
|
21
example/slim-framework.yml
Normal file
21
example/slim-framework.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: Testing Slim Framework
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
max-parallel: 6
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
php-versions: [7.2, 7.3]
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: 'mbstring'
|
||||||
|
coverage: 'xdebug'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
@ -18,17 +18,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const utils = __importStar(require("./utils"));
|
const utils = __importStar(require("./utils"));
|
||||||
const pecl = __importStar(require("./pecl"));
|
const pecl = __importStar(require("./pecl"));
|
||||||
function addExtension(extension_csv, version, os_version) {
|
function addExtension(extension_csv, version, os_version, log_prefix = 'Add Extension') {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return yield addExtensionWindows(extension_csv, version);
|
return yield addExtensionWindows(extension_csv, version, log_prefix);
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return yield addExtensionDarwin(extension_csv, version);
|
return yield addExtensionDarwin(extension_csv, version, log_prefix);
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return yield addExtensionLinux(extension_csv, version);
|
return yield addExtensionLinux(extension_csv, version, log_prefix);
|
||||||
default:
|
default:
|
||||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error', log_prefix);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ function addINIValues(ini_values_csv, os_version) {
|
|||||||
case 'linux':
|
case 'linux':
|
||||||
return yield addINIValuesUnix(ini_values_csv);
|
return yield addINIValuesUnix(ini_values_csv);
|
||||||
default:
|
default:
|
||||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error', 'Add Config');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -52,18 +52,18 @@ exports.addINIValues = addINIValues;
|
|||||||
*
|
*
|
||||||
* @param extension
|
* @param extension
|
||||||
*/
|
*/
|
||||||
function enableExtensionWindows(extension) {
|
function enableExtensionWindows(extension, log_prefix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return (`try {
|
return (`try {
|
||||||
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
||||||
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
||||||
Add-Content C:\\tools\\php\\php.ini "${yield utils.getExtensionPrefix(extension)}=php_${extension}.dll"\n` +
|
Add-Content C:\\tools\\php\\php.ini "${yield utils.getExtensionPrefix(extension)}=php_${extension}.dll"\n` +
|
||||||
(yield utils.log('Enabled ' + extension, 'win32', 'success')) +
|
(yield utils.log('Enabled ' + extension, 'win32', 'success', log_prefix)) +
|
||||||
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
||||||
(yield utils.log('Extension ' + extension + ' was already enabled', 'win32', 'success')) +
|
(yield utils.log(extension + ' was already enabled', 'win32', 'success', log_prefix)) +
|
||||||
` }
|
` }
|
||||||
} catch [Exception] {\n` +
|
} catch [Exception] {\n` +
|
||||||
(yield utils.log(extension + ' could not be enabled', 'win32', 'error')) +
|
(yield utils.log(extension + ' could not be enabled', 'win32', 'error', log_prefix)) +
|
||||||
` }\n`);
|
` }\n`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -74,13 +74,13 @@ exports.enableExtensionWindows = enableExtensionWindows;
|
|||||||
* @param extension
|
* @param extension
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
function enableExtensionUnix(extension, os_version) {
|
function enableExtensionUnix(extension, os_version, log_prefix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return (`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
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` +
|
echo "${yield utils.getExtensionPrefix(extension)}=${extension}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
||||||
(yield utils.log('Enabled ' + extension, os_version, 'success')) +
|
(yield utils.log('Enabled ' + extension, os_version, 'success', log_prefix)) +
|
||||||
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
||||||
(yield utils.log('Extension ' + extension + ' was already enabled', os_version, 'success')) +
|
(yield utils.log(extension + ' was already enabled', os_version, 'success', log_prefix)) +
|
||||||
`; fi\n`);
|
`; fi\n`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ exports.enableExtensionUnix = enableExtensionUnix;
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
function addExtensionDarwin(extension_csv, version) {
|
function addExtensionDarwin(extension_csv, version, log_prefix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -99,7 +99,7 @@ function addExtensionDarwin(extension_csv, version) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
// add script to enable extension is already installed along with php
|
// add script to enable extension is already installed along with php
|
||||||
script += yield enableExtensionUnix(extension, 'darwin');
|
script += yield enableExtensionUnix(extension, 'darwin', log_prefix);
|
||||||
switch (yield pecl.checkPECLExtension(extension)) {
|
switch (yield pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
@ -126,9 +126,9 @@ function addExtensionDarwin(extension_csv, version) {
|
|||||||
')" ]; then ' +
|
')" ]; then ' +
|
||||||
install_command +
|
install_command +
|
||||||
' && ' +
|
' && ' +
|
||||||
(yield utils.log('Installed and enabled ' + extension, 'darwin', 'success')) +
|
(yield utils.log('Installed and enabled ' + extension, 'darwin', 'success', log_prefix)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error')) +
|
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error', log_prefix)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
@ -137,7 +137,7 @@ function addExtensionDarwin(extension_csv, version) {
|
|||||||
'if [ ! "$(php -m | grep -i ' +
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
extension +
|
extension +
|
||||||
')" ]; then \n' +
|
')" ]; then \n' +
|
||||||
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'darwin', 'error')) +
|
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'darwin', 'error', log_prefix)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ exports.addExtensionDarwin = addExtensionDarwin;
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
function addExtensionWindows(extension_csv, version) {
|
function addExtensionWindows(extension_csv, version, log_prefix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -161,7 +161,7 @@ function addExtensionWindows(extension_csv, version) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
// add script to enable extension is already installed along with php
|
// add script to enable extension is already installed along with php
|
||||||
script += yield enableExtensionWindows(extension);
|
script += yield enableExtensionWindows(extension, log_prefix);
|
||||||
switch (yield pecl.checkPECLExtension(extension)) {
|
switch (yield pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
@ -186,9 +186,9 @@ function addExtensionWindows(extension_csv, version) {
|
|||||||
'try { ' +
|
'try { ' +
|
||||||
install_command +
|
install_command +
|
||||||
'\n' +
|
'\n' +
|
||||||
(yield utils.log('Installed and enabled ' + extension, 'win32', 'success')) +
|
(yield utils.log('Installed and enabled ' + extension, 'win32', 'success', log_prefix)) +
|
||||||
' } catch [Exception] { ' +
|
' } catch [Exception] { ' +
|
||||||
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'win32', 'error')) +
|
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'win32', 'error', log_prefix)) +
|
||||||
' } }\n';
|
' } }\n';
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
@ -197,7 +197,7 @@ function addExtensionWindows(extension_csv, version) {
|
|||||||
'if(!(php -m | findstr -i ' +
|
'if(!(php -m | findstr -i ' +
|
||||||
extension +
|
extension +
|
||||||
')) { ' +
|
')) { ' +
|
||||||
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'win32', 'error')) +
|
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'win32', 'error', log_prefix)) +
|
||||||
' } \n';
|
' } \n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ exports.addExtensionWindows = addExtensionWindows;
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
function addExtensionLinux(extension_csv, version) {
|
function addExtensionLinux(extension_csv, version, log_prefix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -221,7 +221,7 @@ function addExtensionLinux(extension_csv, version) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
// add script to enable extension is already installed along with php
|
// add script to enable extension is already installed along with php
|
||||||
script += yield enableExtensionUnix(extension, 'linux');
|
script += yield enableExtensionUnix(extension, 'linux', log_prefix);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (version + extension) {
|
switch (version + extension) {
|
||||||
case '7.4xdebug':
|
case '7.4xdebug':
|
||||||
@ -247,9 +247,9 @@ function addExtensionLinux(extension_csv, version) {
|
|||||||
')" ]; then ' +
|
')" ]; then ' +
|
||||||
install_command +
|
install_command +
|
||||||
' && ' +
|
' && ' +
|
||||||
(yield utils.log('Installed and enabled ' + extension, 'linux', 'success')) +
|
(yield utils.log('Installed and enabled ' + extension, 'linux', 'success', log_prefix)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(yield utils.log('Could not find php' + version + '-' + extension + ' on APT repository', 'linux', 'error')) +
|
(yield utils.log('Could not find php' + version + '-' + extension + ' on APT repository', 'linux', 'error', log_prefix)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -306,11 +306,15 @@ function addCoverage(coverage, version, os_version) {
|
|||||||
// if version is 7.1 or newer
|
// if version is 7.1 or newer
|
||||||
switch (version) {
|
switch (version) {
|
||||||
default:
|
default:
|
||||||
script += yield addExtension('pcov', version, os_version);
|
script += yield addExtension('pcov', version, os_version, 'Set Coverage Driver');
|
||||||
script += yield addINIValues('pcov.enabled=1', os_version);
|
script += yield addINIValues('pcov.enabled=1', os_version);
|
||||||
// add command to disable xdebug and enable pcov
|
// add command to disable xdebug and enable pcov
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
|
script +=
|
||||||
|
'if [ -e /etc/php/' +
|
||||||
|
version +
|
||||||
|
'/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n';
|
||||||
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
||||||
break;
|
break;
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
@ -322,19 +326,19 @@ function addCoverage(coverage, version, os_version) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// success
|
// success
|
||||||
script += yield utils.log('pcov enabled as coverage driver', os_version, 'success');
|
script += yield utils.log('PCOV enabled as coverage driver', os_version, 'success', 'Set Coverage Driver');
|
||||||
// version is not supported
|
// version is not supported
|
||||||
break;
|
break;
|
||||||
case '5.6':
|
case '5.6':
|
||||||
case '7.0':
|
case '7.0':
|
||||||
script += yield utils.log('pcov requires php 7.1 or newer', os_version, 'warning');
|
script += yield utils.log('PCOV requires PHP 7.1 or newer', os_version, 'warning', 'Set Coverage Driver');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//xdebug
|
//xdebug
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
script += yield addExtension('xdebug', version, os_version);
|
script += yield addExtension('xdebug', version, os_version, 'Set Coverage Driver');
|
||||||
script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success');
|
script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success', 'Set Coverage Driver');
|
||||||
break;
|
break;
|
||||||
// unknown coverage driver
|
// unknown coverage driver
|
||||||
default:
|
default:
|
||||||
|
23
lib/utils.js
23
lib/utils.js
@ -156,13 +156,21 @@ function INIArray(ini_values_csv) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.INIArray = INIArray;
|
exports.INIArray = INIArray;
|
||||||
function log(message, os_version, log_type) {
|
function log(message, os_version, log_type, prefix = '') {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const unix_color = {
|
const unix_color = {
|
||||||
error: '31',
|
error: '31',
|
||||||
success: '32',
|
success: '32',
|
||||||
warning: '33'
|
warning: '33'
|
||||||
};
|
};
|
||||||
|
switch (prefix) {
|
||||||
|
case '':
|
||||||
|
prefix = prefix;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
prefix = prefix + ': ';
|
||||||
|
break;
|
||||||
|
}
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
const color = {
|
const color = {
|
||||||
@ -170,11 +178,20 @@ function log(message, os_version, log_type) {
|
|||||||
success: 'green',
|
success: 'green',
|
||||||
warning: 'yellow'
|
warning: 'yellow'
|
||||||
};
|
};
|
||||||
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
return ("Write-Host '" +
|
||||||
|
prefix +
|
||||||
|
message +
|
||||||
|
"' -ForegroundColor " +
|
||||||
|
color[log_type]);
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
default:
|
default:
|
||||||
return ('echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
|
return ('echo "\\033[' +
|
||||||
|
unix_color[log_type] +
|
||||||
|
';1m' +
|
||||||
|
prefix +
|
||||||
|
message +
|
||||||
|
'\\033[0m"');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
119
src/features.ts
119
src/features.ts
@ -4,20 +4,22 @@ import * as pecl from './pecl';
|
|||||||
export async function addExtension(
|
export async function addExtension(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os_version: string,
|
||||||
|
log_prefix = 'Add Extension'
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return await addExtensionWindows(extension_csv, version);
|
return await addExtensionWindows(extension_csv, version, log_prefix);
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return await addExtensionDarwin(extension_csv, version);
|
return await addExtensionDarwin(extension_csv, version, log_prefix);
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return await addExtensionLinux(extension_csv, version);
|
return await addExtensionLinux(extension_csv, version, log_prefix);
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os_version + ' is not supported',
|
||||||
os_version,
|
os_version,
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,7 +35,8 @@ export async function addINIValues(ini_values_csv: string, os_version: string) {
|
|||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os_version + ' is not supported',
|
||||||
os_version,
|
os_version,
|
||||||
'error'
|
'error',
|
||||||
|
'Add Config'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,7 +46,10 @@ export async function addINIValues(ini_values_csv: string, os_version: string) {
|
|||||||
*
|
*
|
||||||
* @param extension
|
* @param extension
|
||||||
*/
|
*/
|
||||||
export async function enableExtensionWindows(extension: string) {
|
export async function enableExtensionWindows(
|
||||||
|
extension: string,
|
||||||
|
log_prefix: string
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
`try {
|
`try {
|
||||||
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
||||||
@ -51,16 +57,22 @@ export async function enableExtensionWindows(extension: string) {
|
|||||||
Add-Content C:\\tools\\php\\php.ini "${await utils.getExtensionPrefix(
|
Add-Content C:\\tools\\php\\php.ini "${await utils.getExtensionPrefix(
|
||||||
extension
|
extension
|
||||||
)}=php_${extension}.dll"\n` +
|
)}=php_${extension}.dll"\n` +
|
||||||
(await utils.log('Enabled ' + extension, 'win32', 'success')) +
|
(await utils.log('Enabled ' + extension, 'win32', 'success', log_prefix)) +
|
||||||
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Extension ' + extension + ' was already enabled',
|
extension + ' was already enabled',
|
||||||
'win32',
|
'win32',
|
||||||
'success'
|
'success',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
` }
|
` }
|
||||||
} catch [Exception] {\n` +
|
} catch [Exception] {\n` +
|
||||||
(await utils.log(extension + ' could not be enabled', 'win32', 'error')) +
|
(await utils.log(
|
||||||
|
extension + ' could not be enabled',
|
||||||
|
'win32',
|
||||||
|
'error',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
` }\n`
|
` }\n`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -73,19 +85,26 @@ export async function enableExtensionWindows(extension: string) {
|
|||||||
*/
|
*/
|
||||||
export async function enableExtensionUnix(
|
export async function enableExtensionUnix(
|
||||||
extension: string,
|
extension: string,
|
||||||
os_version: string
|
os_version: string,
|
||||||
|
log_prefix: string
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||||
echo "${await utils.getExtensionPrefix(
|
echo "${await utils.getExtensionPrefix(
|
||||||
extension
|
extension
|
||||||
)}=${extension}" >> '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')) +
|
(await utils.log(
|
||||||
|
'Enabled ' + extension,
|
||||||
|
os_version,
|
||||||
|
'success',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Extension ' + extension + ' was already enabled',
|
extension + ' was already enabled',
|
||||||
os_version,
|
os_version,
|
||||||
'success'
|
'success',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
`; fi\n`
|
`; fi\n`
|
||||||
);
|
);
|
||||||
@ -99,14 +118,15 @@ export async function enableExtensionUnix(
|
|||||||
*/
|
*/
|
||||||
export async function addExtensionDarwin(
|
export async function addExtensionDarwin(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string
|
version: string,
|
||||||
|
log_prefix: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script: string = '\n';
|
let script: string = '\n';
|
||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
// add script to enable extension is already installed along with php
|
// add script to enable extension is already installed along with php
|
||||||
script += await enableExtensionUnix(extension, 'darwin');
|
script += await enableExtensionUnix(extension, 'darwin', log_prefix);
|
||||||
switch (await pecl.checkPECLExtension(extension)) {
|
switch (await pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
let install_command: string = '';
|
let install_command: string = '';
|
||||||
@ -136,13 +156,15 @@ export async function addExtensionDarwin(
|
|||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Installed and enabled ' + extension,
|
'Installed and enabled ' + extension,
|
||||||
'darwin',
|
'darwin',
|
||||||
'success'
|
'success',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not install ' + extension + ' on PHP' + version,
|
'Could not install ' + extension + ' on PHP' + version,
|
||||||
'darwin',
|
'darwin',
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
@ -155,7 +177,8 @@ export async function addExtensionDarwin(
|
|||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
||||||
'darwin',
|
'darwin',
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
@ -172,14 +195,15 @@ export async function addExtensionDarwin(
|
|||||||
*/
|
*/
|
||||||
export async function addExtensionWindows(
|
export async function addExtensionWindows(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string
|
version: string,
|
||||||
|
log_prefix: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script: string = '\n';
|
let script: string = '\n';
|
||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
// add script to enable extension is already installed along with php
|
// add script to enable extension is already installed along with php
|
||||||
script += await enableExtensionWindows(extension);
|
script += await enableExtensionWindows(extension, log_prefix);
|
||||||
|
|
||||||
switch (await pecl.checkPECLExtension(extension)) {
|
switch (await pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
@ -209,13 +233,15 @@ export async function addExtensionWindows(
|
|||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Installed and enabled ' + extension,
|
'Installed and enabled ' + extension,
|
||||||
'win32',
|
'win32',
|
||||||
'success'
|
'success',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
' } catch [Exception] { ' +
|
' } catch [Exception] { ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not install ' + extension + ' on PHP' + version,
|
'Could not install ' + extension + ' on PHP' + version,
|
||||||
'win32',
|
'win32',
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
' } }\n';
|
' } }\n';
|
||||||
break;
|
break;
|
||||||
@ -228,7 +254,8 @@ export async function addExtensionWindows(
|
|||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
||||||
'win32',
|
'win32',
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
' } \n';
|
' } \n';
|
||||||
break;
|
break;
|
||||||
@ -245,14 +272,15 @@ export async function addExtensionWindows(
|
|||||||
*/
|
*/
|
||||||
export async function addExtensionLinux(
|
export async function addExtensionLinux(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string
|
version: string,
|
||||||
|
log_prefix: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script: string = '\n';
|
let script: string = '\n';
|
||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
// add script to enable extension is already installed along with php
|
// add script to enable extension is already installed along with php
|
||||||
script += await enableExtensionUnix(extension, 'linux');
|
script += await enableExtensionUnix(extension, 'linux', log_prefix);
|
||||||
|
|
||||||
let install_command: string = '';
|
let install_command: string = '';
|
||||||
switch (version + extension) {
|
switch (version + extension) {
|
||||||
@ -282,13 +310,15 @@ export async function addExtensionLinux(
|
|||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Installed and enabled ' + extension,
|
'Installed and enabled ' + extension,
|
||||||
'linux',
|
'linux',
|
||||||
'success'
|
'success',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not find php' + version + '-' + extension + ' on APT repository',
|
'Could not find php' + version + '-' + extension + ' on APT repository',
|
||||||
'linux',
|
'linux',
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
});
|
});
|
||||||
@ -343,12 +373,21 @@ export async function addCoverage(
|
|||||||
// if version is 7.1 or newer
|
// if version is 7.1 or newer
|
||||||
switch (version) {
|
switch (version) {
|
||||||
default:
|
default:
|
||||||
script += await addExtension('pcov', version, os_version);
|
script += await addExtension(
|
||||||
|
'pcov',
|
||||||
|
version,
|
||||||
|
os_version,
|
||||||
|
'Set Coverage Driver'
|
||||||
|
);
|
||||||
script += await addINIValues('pcov.enabled=1', os_version);
|
script += await addINIValues('pcov.enabled=1', os_version);
|
||||||
|
|
||||||
// add command to disable xdebug and enable pcov
|
// add command to disable xdebug and enable pcov
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
|
script +=
|
||||||
|
'if [ -e /etc/php/' +
|
||||||
|
version +
|
||||||
|
'/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n';
|
||||||
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
||||||
break;
|
break;
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
@ -362,29 +401,37 @@ export async function addCoverage(
|
|||||||
|
|
||||||
// success
|
// success
|
||||||
script += await utils.log(
|
script += await utils.log(
|
||||||
'pcov enabled as coverage driver',
|
'PCOV enabled as coverage driver',
|
||||||
os_version,
|
os_version,
|
||||||
'success'
|
'success',
|
||||||
|
'Set Coverage Driver'
|
||||||
);
|
);
|
||||||
// version is not supported
|
// version is not supported
|
||||||
break;
|
break;
|
||||||
case '5.6':
|
case '5.6':
|
||||||
case '7.0':
|
case '7.0':
|
||||||
script += await utils.log(
|
script += await utils.log(
|
||||||
'pcov requires php 7.1 or newer',
|
'PCOV requires PHP 7.1 or newer',
|
||||||
os_version,
|
os_version,
|
||||||
'warning'
|
'warning',
|
||||||
|
'Set Coverage Driver'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//xdebug
|
//xdebug
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
script += await addExtension('xdebug', version, os_version);
|
script += await addExtension(
|
||||||
|
'xdebug',
|
||||||
|
version,
|
||||||
|
os_version,
|
||||||
|
'Set Coverage Driver'
|
||||||
|
);
|
||||||
script += await utils.log(
|
script += await utils.log(
|
||||||
'Xdebug enabled as coverage driver',
|
'Xdebug enabled as coverage driver',
|
||||||
os_version,
|
os_version,
|
||||||
'success'
|
'success',
|
||||||
|
'Set Coverage Driver'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
// unknown coverage driver
|
// unknown coverage driver
|
||||||
|
26
src/utils.ts
26
src/utils.ts
@ -157,13 +157,22 @@ export async function INIArray(ini_values_csv: string): Promise<Array<string>> {
|
|||||||
export async function log(
|
export async function log(
|
||||||
message: string,
|
message: string,
|
||||||
os_version: string,
|
os_version: string,
|
||||||
log_type: string
|
log_type: string,
|
||||||
|
prefix = ''
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const unix_color: any = {
|
const unix_color: any = {
|
||||||
error: '31',
|
error: '31',
|
||||||
success: '32',
|
success: '32',
|
||||||
warning: '33'
|
warning: '33'
|
||||||
};
|
};
|
||||||
|
switch (prefix) {
|
||||||
|
case '':
|
||||||
|
prefix = prefix;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
prefix = prefix + ': ';
|
||||||
|
break;
|
||||||
|
}
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
const color: any = {
|
const color: any = {
|
||||||
@ -171,13 +180,24 @@ export async function log(
|
|||||||
success: 'green',
|
success: 'green',
|
||||||
warning: 'yellow'
|
warning: 'yellow'
|
||||||
};
|
};
|
||||||
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
return (
|
||||||
|
"Write-Host '" +
|
||||||
|
prefix +
|
||||||
|
message +
|
||||||
|
"' -ForegroundColor " +
|
||||||
|
color[log_type]
|
||||||
|
);
|
||||||
|
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
'echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"'
|
'echo "\\033[' +
|
||||||
|
unix_color[log_type] +
|
||||||
|
';1m' +
|
||||||
|
prefix +
|
||||||
|
message +
|
||||||
|
'\\033[0m"'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user