mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-26 13:23:05 +07:00
Fix xdebug version
This commit is contained in:
parent
dcd432d918
commit
eaf140ca8b
@ -22,11 +22,9 @@ describe('Features tests', () => {
|
|||||||
);
|
);
|
||||||
win32 = await features.addExtension('xdebug, pcov', '7.4', 'win32');
|
win32 = await features.addExtension('xdebug, pcov', '7.4', 'win32');
|
||||||
expect(win32).toContain(
|
expect(win32).toContain(
|
||||||
'Install-PhpExtension xdebug -MinimumStability alpha'
|
'Install-PhpExtension xdebug -Version 2.8 -MinimumStability beta'
|
||||||
);
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Install-PhpExtension pcov -MinimumStability alpha'
|
|
||||||
);
|
);
|
||||||
|
expect(win32).toContain('Install-PhpExtension pcov -MinimumStability beta');
|
||||||
|
|
||||||
win32 = await features.addExtension('does_not_exist', '7.2', 'win32');
|
win32 = await features.addExtension('does_not_exist', '7.2', 'win32');
|
||||||
expect(win32).toContain('Could not find does_not_exist for PHP7.2 on PECL');
|
expect(win32).toContain('Could not find does_not_exist for PHP7.2 on PECL');
|
||||||
@ -61,9 +59,18 @@ describe('Features tests', () => {
|
|||||||
expect(darwin).toContain('sudo pecl install xdebug');
|
expect(darwin).toContain('sudo pecl install xdebug');
|
||||||
expect(darwin).toContain('sudo pecl install pcov');
|
expect(darwin).toContain('sudo pecl install pcov');
|
||||||
|
|
||||||
|
darwin = await features.addExtension('pcov', '5.6', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install pcov');
|
||||||
|
|
||||||
|
darwin = await features.addExtension('pcov', '7.2', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install pcov');
|
||||||
|
|
||||||
darwin = await features.addExtension('xdebug', '5.6', 'darwin');
|
darwin = await features.addExtension('xdebug', '5.6', 'darwin');
|
||||||
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
||||||
|
|
||||||
|
darwin = await features.addExtension('xdebug', '7.2', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install xdebug');
|
||||||
|
|
||||||
darwin = await features.addExtension('does_not_exist', '7.2', 'darwin');
|
darwin = await features.addExtension('does_not_exist', '7.2', 'darwin');
|
||||||
expect(darwin).toContain(
|
expect(darwin).toContain(
|
||||||
'Could not find does_not_exist for PHP7.2 on PECL'
|
'Could not find does_not_exist for PHP7.2 on PECL'
|
||||||
@ -130,7 +137,7 @@ describe('Features tests', () => {
|
|||||||
it('checking addCoverage on windows', async () => {
|
it('checking addCoverage on windows', async () => {
|
||||||
let win32: string = await features.addCoverage('xdebug', '7.4', 'win32');
|
let win32: string = await features.addCoverage('xdebug', '7.4', 'win32');
|
||||||
expect(win32).toContain(
|
expect(win32).toContain(
|
||||||
'Install-PhpExtension xdebug -MinimumStability alpha'
|
'Install-PhpExtension xdebug -Version 2.8 -MinimumStability beta'
|
||||||
);
|
);
|
||||||
|
|
||||||
win32 = await features.addCoverage('xdebug', '7.3', 'win32');
|
win32 = await features.addCoverage('xdebug', '7.3', 'win32');
|
||||||
@ -139,9 +146,7 @@ describe('Features tests', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
win32 = await features.addCoverage('pcov', '7.4', 'win32');
|
win32 = await features.addCoverage('pcov', '7.4', 'win32');
|
||||||
expect(win32).toContain(
|
expect(win32).toContain('Install-PhpExtension pcov -MinimumStability beta');
|
||||||
'Install-PhpExtension pcov -MinimumStability alpha'
|
|
||||||
);
|
|
||||||
expect(win32).toContain(
|
expect(win32).toContain(
|
||||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
|
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
|
||||||
);
|
);
|
||||||
|
@ -129,6 +129,16 @@ describe('Utils tests', () => {
|
|||||||
expect(success_log).toEqual('echo -e "\\033[32;1m' + message + '\\033[0m"');
|
expect(success_log).toEqual('echo -e "\\033[32;1m' + message + '\\033[0m"');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checking getExtensionPrefix', async () => {
|
||||||
|
expect(await utils.getExtensionPrefix('extensionDoesNotExist')).toEqual(
|
||||||
|
'extension'
|
||||||
|
);
|
||||||
|
expect(await utils.getExtensionPrefix('xsl')).toEqual('extension');
|
||||||
|
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
|
||||||
|
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('pecl tests', () => {
|
||||||
it('checking checkPECLExtension', async () => {
|
it('checking checkPECLExtension', async () => {
|
||||||
expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false);
|
expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false);
|
||||||
expect(await pecl.checkPECLExtension('xdebug')).toBe(true);
|
expect(await pecl.checkPECLExtension('xdebug')).toBe(true);
|
||||||
|
@ -57,7 +57,7 @@ function enableExtensionWindows(extension) {
|
|||||||
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 "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')) +
|
||||||
` } 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 ' + extension + ' was already enabled', 'win32', 'success')) +
|
||||||
@ -76,8 +76,8 @@ exports.enableExtensionWindows = enableExtensionWindows;
|
|||||||
*/
|
*/
|
||||||
function enableExtensionUnix(extension, os_version) {
|
function enableExtensionUnix(extension, os_version) {
|
||||||
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/php_${extension}.so" ]; then
|
||||||
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
echo "${yield utils.getExtensionPrefix(extension)}=php_${extension}.so" >> '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')) +
|
||||||
`;\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 ' + extension + ' was already enabled', os_version, 'success')) +
|
||||||
@ -102,15 +102,25 @@ function addExtensionDarwin(extension_csv, version) {
|
|||||||
script += yield enableExtensionUnix(extension, 'darwin');
|
script += yield enableExtensionUnix(extension, 'darwin');
|
||||||
switch (yield pecl.checkPECLExtension(extension)) {
|
switch (yield pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
let extension_version = version === '5.6' && extension === 'xdebug'
|
let extension_version = extension;
|
||||||
? 'xdebug-2.5.5'
|
switch (version + extension) {
|
||||||
: extension;
|
case '5.6xdebug':
|
||||||
|
extension_version = 'xdebug-2.5.5';
|
||||||
|
break;
|
||||||
|
case '7.4xdebug':
|
||||||
|
extension_version = 'xdebug-2.8.0beta2';
|
||||||
|
break;
|
||||||
|
case '7.2xdebug':
|
||||||
|
default:
|
||||||
|
extension_version = extension;
|
||||||
|
break;
|
||||||
|
}
|
||||||
script +=
|
script +=
|
||||||
'if [ ! "$(php -m | grep -i ' +
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
extension +
|
extension +
|
||||||
')" ]; then sudo pecl install ' +
|
')" ]; then sudo pecl install ' +
|
||||||
extension_version +
|
extension_version +
|
||||||
' >/dev/null 2>&1 && ' +
|
' >/dev/null 2>&1 && ' +
|
||||||
(yield utils.log('Installed and enabled ' + extension, 'darwin', 'success')) +
|
(yield utils.log('Installed and enabled ' + extension, 'darwin', 'success')) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error')) +
|
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error')) +
|
||||||
@ -147,26 +157,36 @@ function addExtensionWindows(extension_csv, version) {
|
|||||||
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);
|
||||||
let extension_version = '';
|
let extension_stability = '';
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
extension_version = 'alpha';
|
extension_stability = 'beta';
|
||||||
break;
|
break;
|
||||||
case '7.2':
|
case '7.2':
|
||||||
default:
|
default:
|
||||||
extension_version = 'stable';
|
extension_stability = 'stable';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (yield pecl.checkPECLExtension(extension)) {
|
switch (yield pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
|
let extension_version = extension;
|
||||||
|
switch (version + extension) {
|
||||||
|
case '7.4xdebug':
|
||||||
|
extension_version = 'xdebug -Version 2.8';
|
||||||
|
break;
|
||||||
|
case '7.2xdebug':
|
||||||
|
default:
|
||||||
|
extension_version = extension;
|
||||||
|
break;
|
||||||
|
}
|
||||||
script +=
|
script +=
|
||||||
'if(!(php -m | findstr -i ' +
|
'if(!(php -m | findstr -i ' +
|
||||||
extension +
|
extension +
|
||||||
')) { ' +
|
')) { ' +
|
||||||
'try { Install-PhpExtension ' +
|
'try { Install-PhpExtension ' +
|
||||||
extension +
|
|
||||||
' -MinimumStability ' +
|
|
||||||
extension_version +
|
extension_version +
|
||||||
|
' -MinimumStability ' +
|
||||||
|
extension_stability +
|
||||||
'\n' +
|
'\n' +
|
||||||
(yield utils.log('Installed and enabled ' + extension, 'win32', 'success')) +
|
(yield utils.log('Installed and enabled ' + extension, 'win32', 'success')) +
|
||||||
' } catch [Exception] { ' +
|
' } catch [Exception] { ' +
|
||||||
@ -211,10 +231,18 @@ function addExtensionLinux(extension_csv, version) {
|
|||||||
version +
|
version +
|
||||||
'-' +
|
'-' +
|
||||||
extension +
|
extension +
|
||||||
|
' >/dev/null 2>&1 || sudo DEBIAN_FRONTEND=noninteractive apt install -y php-' +
|
||||||
|
extension +
|
||||||
' >/dev/null 2>&1 && ' +
|
' >/dev/null 2>&1 && ' +
|
||||||
(yield utils.log('Installed and enabled ' + extension, 'linux', 'success')) +
|
(yield utils.log('Installed and enabled ' + extension, 'linux', 'success')) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(yield utils.log('Could not find php' + version + '-' + extension + ' on APT repository', 'linux', 'error')) +
|
(yield utils.log('Could not find php-' +
|
||||||
|
extension +
|
||||||
|
' or php' +
|
||||||
|
version +
|
||||||
|
'-' +
|
||||||
|
extension +
|
||||||
|
' on APT repository', 'linux', 'error')) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
14
lib/utils.js
14
lib/utils.js
@ -141,3 +141,17 @@ function log(message, os_version, log_type) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.log = log;
|
exports.log = log;
|
||||||
|
function getExtensionPrefix(extension) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let zend = ['xdebug', 'opcache'];
|
||||||
|
switch (zend.indexOf(extension)) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
return 'zend_extension';
|
||||||
|
case -1:
|
||||||
|
default:
|
||||||
|
return 'extension';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getExtensionPrefix = getExtensionPrefix;
|
||||||
|
@ -48,7 +48,9 @@ export async function enableExtensionWindows(extension: string) {
|
|||||||
`try {
|
`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 "extension=php_${extension}.dll"\n` +
|
Add-Content C:\\tools\\php\\php.ini "${await utils.getExtensionPrefix(
|
||||||
|
extension
|
||||||
|
)}=php_${extension}.dll"\n` +
|
||||||
(await utils.log('Enabled ' + extension, 'win32', 'success')) +
|
(await utils.log('Enabled ' + extension, 'win32', 'success')) +
|
||||||
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
@ -74,8 +76,10 @@ export async function enableExtensionUnix(
|
|||||||
os_version: string
|
os_version: string
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/php_${extension}.so" ]; then
|
||||||
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
echo "${await utils.getExtensionPrefix(
|
||||||
|
extension
|
||||||
|
)}=php_${extension}.so" >> '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')) +
|
||||||
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
@ -105,16 +109,25 @@ export async function addExtensionDarwin(
|
|||||||
script += await enableExtensionUnix(extension, 'darwin');
|
script += await enableExtensionUnix(extension, 'darwin');
|
||||||
switch (await pecl.checkPECLExtension(extension)) {
|
switch (await pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
let extension_version: string =
|
let extension_version: string = extension;
|
||||||
version === '5.6' && extension === 'xdebug'
|
switch (version + extension) {
|
||||||
? 'xdebug-2.5.5'
|
case '5.6xdebug':
|
||||||
: extension;
|
extension_version = 'xdebug-2.5.5';
|
||||||
|
break;
|
||||||
|
case '7.4xdebug':
|
||||||
|
extension_version = 'xdebug-2.8.0beta2';
|
||||||
|
break;
|
||||||
|
case '7.2xdebug':
|
||||||
|
default:
|
||||||
|
extension_version = extension;
|
||||||
|
break;
|
||||||
|
}
|
||||||
script +=
|
script +=
|
||||||
'if [ ! "$(php -m | grep -i ' +
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
extension +
|
extension +
|
||||||
')" ]; then sudo pecl install ' +
|
')" ]; then sudo pecl install ' +
|
||||||
extension_version +
|
extension_version +
|
||||||
' >/dev/null 2>&1 && ' +
|
' >/dev/null 2>&1 && ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Installed and enabled ' + extension,
|
'Installed and enabled ' + extension,
|
||||||
'darwin',
|
'darwin',
|
||||||
@ -162,27 +175,37 @@ export async function addExtensionWindows(
|
|||||||
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);
|
||||||
let extension_version: string = '';
|
let extension_stability: string = '';
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
extension_version = 'alpha';
|
extension_stability = 'beta';
|
||||||
break;
|
break;
|
||||||
case '7.2':
|
case '7.2':
|
||||||
default:
|
default:
|
||||||
extension_version = 'stable';
|
extension_stability = 'stable';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (await pecl.checkPECLExtension(extension)) {
|
switch (await pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
|
let extension_version: string = extension;
|
||||||
|
switch (version + extension) {
|
||||||
|
case '7.4xdebug':
|
||||||
|
extension_version = 'xdebug -Version 2.8';
|
||||||
|
break;
|
||||||
|
case '7.2xdebug':
|
||||||
|
default:
|
||||||
|
extension_version = extension;
|
||||||
|
break;
|
||||||
|
}
|
||||||
script +=
|
script +=
|
||||||
'if(!(php -m | findstr -i ' +
|
'if(!(php -m | findstr -i ' +
|
||||||
extension +
|
extension +
|
||||||
')) { ' +
|
')) { ' +
|
||||||
'try { Install-PhpExtension ' +
|
'try { Install-PhpExtension ' +
|
||||||
extension +
|
|
||||||
' -MinimumStability ' +
|
|
||||||
extension_version +
|
extension_version +
|
||||||
|
' -MinimumStability ' +
|
||||||
|
extension_stability +
|
||||||
'\n' +
|
'\n' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Installed and enabled ' + extension,
|
'Installed and enabled ' + extension,
|
||||||
@ -238,6 +261,8 @@ export async function addExtensionLinux(
|
|||||||
version +
|
version +
|
||||||
'-' +
|
'-' +
|
||||||
extension +
|
extension +
|
||||||
|
' >/dev/null 2>&1 || sudo DEBIAN_FRONTEND=noninteractive apt install -y php-' +
|
||||||
|
extension +
|
||||||
' >/dev/null 2>&1 && ' +
|
' >/dev/null 2>&1 && ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Installed and enabled ' + extension,
|
'Installed and enabled ' + extension,
|
||||||
@ -246,7 +271,13 @@ export async function addExtensionLinux(
|
|||||||
)) +
|
)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not find php' + version + '-' + extension + ' on APT repository',
|
'Could not find php-' +
|
||||||
|
extension +
|
||||||
|
' or php' +
|
||||||
|
version +
|
||||||
|
'-' +
|
||||||
|
extension +
|
||||||
|
' on APT repository',
|
||||||
'linux',
|
'linux',
|
||||||
'error'
|
'error'
|
||||||
)) +
|
)) +
|
||||||
|
@ -28,7 +28,7 @@ fi
|
|||||||
|
|
||||||
composer global require hirak/prestissimo >/dev/null 2>&1
|
composer global require hirak/prestissimo >/dev/null 2>&1
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
ext_dir=$(/usr/bin/php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
sudo chmod 777 "$ini_file"
|
sudo chmod 777 "$ini_file"
|
||||||
sudo mkdir -p /run/php
|
sudo mkdir -p /run/php
|
||||||
php -v
|
php -v
|
||||||
|
12
src/utils.ts
12
src/utils.ts
@ -146,3 +146,15 @@ export async function log(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getExtensionPrefix(extension: string): Promise<string> {
|
||||||
|
let zend: Array<string> = ['xdebug', 'opcache'];
|
||||||
|
switch (zend.indexOf(extension)) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
return 'zend_extension';
|
||||||
|
case -1:
|
||||||
|
default:
|
||||||
|
return 'extension';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user