mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-08-18 03:24:41 +07:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
eaf140ca8b | |||
dcd432d918 | |||
91a03a2865 | |||
ca33947c62 | |||
932b66f3fc | |||
651d2619bb | |||
16f13a69eb |
@ -22,14 +22,12 @@ 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 extension: does_not_exist');
|
expect(win32).toContain('Could not find does_not_exist for PHP7.2 on PECL');
|
||||||
|
|
||||||
win32 = await features.addExtension('xdebug', '7.2', 'fedora');
|
win32 = await features.addExtension('xdebug', '7.2', 'fedora');
|
||||||
expect(win32).toContain('Platform fedora is not supported');
|
expect(win32).toContain('Platform fedora is not supported');
|
||||||
@ -61,11 +59,22 @@ 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('Could not find extension: does_not_exist');
|
expect(darwin).toContain(
|
||||||
|
'Could not find does_not_exist for PHP7.2 on PECL'
|
||||||
|
);
|
||||||
|
|
||||||
darwin = await features.addExtension('xdebug', '7.2', 'fedora');
|
darwin = await features.addExtension('xdebug', '7.2', 'fedora');
|
||||||
expect(darwin).toContain('Platform fedora is not supported');
|
expect(darwin).toContain('Platform fedora is not supported');
|
||||||
@ -128,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');
|
||||||
@ -137,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'
|
||||||
);
|
);
|
||||||
|
@ -106,7 +106,7 @@ describe('Utils tests', () => {
|
|||||||
// "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 -e "\\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 -e "\\033[33;1m' + message + '\\033[0m"');
|
expect(warning_log).toEqual('echo -e "\\033[33;1m' + message + '\\033[0m"');
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ describe('Utils tests', () => {
|
|||||||
// "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 -e "\\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 -e "\\033[31;1m' + message + '\\033[0m"');
|
expect(error_log).toEqual('echo -e "\\033[31;1m' + message + '\\033[0m"');
|
||||||
|
|
||||||
@ -124,11 +124,21 @@ describe('Utils tests', () => {
|
|||||||
// "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 -e "\\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 -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);
|
||||||
|
60
config.yaml
Normal file
60
config.yaml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
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
|
100
lib/features.js
100
lib/features.js
@ -57,11 +57,13 @@ 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) {
|
||||||
Enable-PhpExtension ${extension} C:\\tools\\php\n` +
|
Add-Content C:\\tools\\php\\php.ini "${yield utils.getExtensionPrefix(extension)}=php_${extension}.dll"\n` +
|
||||||
(yield utils.log(extension + ' enabled', 'win32', 'success')) +
|
(yield utils.log('Enabled ' + extension, 'win32', 'success')) +
|
||||||
`}
|
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
||||||
|
(yield utils.log('Extension ' + extension + ' was already enabled', 'win32', 'success')) +
|
||||||
|
` }
|
||||||
} catch [Exception] {\n` +
|
} catch [Exception] {\n` +
|
||||||
(yield utils.log(extension + ' could not be installed', 'win32', 'error')) +
|
(yield utils.log(extension + ' could not be enabled', 'win32', 'error')) +
|
||||||
` }\n`);
|
` }\n`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -70,12 +72,15 @@ exports.enableExtensionWindows = enableExtensionWindows;
|
|||||||
* Enable extensions which are installed but not enabled on unix
|
* Enable extensions which are installed but not enabled on unix
|
||||||
*
|
*
|
||||||
* @param extension
|
* @param extension
|
||||||
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
function enableExtensionUnix(extension) {
|
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 ${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(extension + ' enabled', 'unix', 'success')) +
|
(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')) +
|
||||||
`; fi\n`);
|
`; fi\n`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -94,26 +99,41 @@ 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);
|
script += yield enableExtensionUnix(extension, 'darwin');
|
||||||
switch (yield pecl.checkPECLExtension(extension)) {
|
switch (yield pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
extension =
|
let extension_version = 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 ' +
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
extension +
|
extension +
|
||||||
')" ]; then sudo pecl install ' +
|
')" ]; then sudo pecl install ' +
|
||||||
extension +
|
extension_version +
|
||||||
|
' >/dev/null 2>&1 && ' +
|
||||||
|
(yield utils.log('Installed and enabled ' + extension, 'darwin', 'success')) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(yield utils.log("Couldn't install extension: " + extension, 'darwin', 'error')) +
|
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error')) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script +=
|
script +=
|
||||||
(yield utils.log('Could not find extension: ' + extension, 'darwin', 'error')) + '\n';
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
|
extension +
|
||||||
|
')" ]; then \n' +
|
||||||
|
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'darwin', 'error')) +
|
||||||
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -137,34 +157,50 @@ 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' +
|
||||||
|
(yield utils.log('Installed and enabled ' + extension, 'win32', 'success')) +
|
||||||
' } catch [Exception] { ' +
|
' } catch [Exception] { ' +
|
||||||
(yield utils.log('Could not install extension: ' + extension, 'win32', 'error')) +
|
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'win32', 'error')) +
|
||||||
' } }\n';
|
' } }\n';
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script +=
|
script +=
|
||||||
(yield utils.log('Could not find extension: ' + extension, 'win32', 'error')) + '\n';
|
'if(!(php -m | findstr -i ' +
|
||||||
|
extension +
|
||||||
|
')) { ' +
|
||||||
|
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'win32', 'error')) +
|
||||||
|
' } \n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -187,16 +223,26 @@ 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);
|
script += yield enableExtensionUnix(extension, 'linux');
|
||||||
script +=
|
script +=
|
||||||
'if [ ! "$(php -m | grep ' +
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
extension +
|
extension +
|
||||||
')" ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
')" ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||||
version +
|
version +
|
||||||
'-' +
|
'-' +
|
||||||
extension +
|
extension +
|
||||||
|
' >/dev/null 2>&1 || sudo DEBIAN_FRONTEND=noninteractive apt install -y php-' +
|
||||||
|
extension +
|
||||||
|
' >/dev/null 2>&1 && ' +
|
||||||
|
(yield utils.log('Installed and enabled ' + extension, 'linux', 'success')) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(yield utils.log("Couldn't find extension php" + version + '-' + extension, 'linux', 'error')) +
|
(yield utils.log('Could not find php-' +
|
||||||
|
extension +
|
||||||
|
' or php' +
|
||||||
|
version +
|
||||||
|
'-' +
|
||||||
|
extension +
|
||||||
|
' on APT repository', 'linux', 'error')) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
26
lib/utils.js
26
lib/utils.js
@ -60,6 +60,7 @@ function readScript(filename, version, os_version) {
|
|||||||
case 'darwin':
|
case 'darwin':
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
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');
|
return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
|
||||||
case '7.3':
|
case '7.3':
|
||||||
default:
|
default:
|
||||||
@ -118,6 +119,11 @@ 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) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const unix_color = {
|
||||||
|
error: '31',
|
||||||
|
success: '32',
|
||||||
|
warning: '33'
|
||||||
|
};
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
const color = {
|
const color = {
|
||||||
@ -127,15 +133,25 @@ function log(message, os_version, log_type) {
|
|||||||
};
|
};
|
||||||
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
||||||
case 'linux':
|
case 'linux':
|
||||||
|
return ('echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
default:
|
default:
|
||||||
const unix_color = {
|
|
||||||
error: '31',
|
|
||||||
success: '32',
|
|
||||||
warning: '33'
|
|
||||||
};
|
|
||||||
return ('echo -e "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
|
return ('echo -e "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.3.5",
|
"version": "1.3.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.3.5",
|
"version": "1.3.6",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup php action",
|
"description": "Setup php action",
|
||||||
"main": "lib/setup-php.js",
|
"main": "lib/setup-php.js",
|
||||||
|
94
src/7.4.sh
94
src/7.4.sh
@ -1,50 +1,60 @@
|
|||||||
brew fetch autoconf& brew fetch automake& brew fetch pcre& brew fetch libtool& brew fetch libpng& brew fetch webp& brew fetch jpeg& brew fetch freetype& brew fetch libxml2& brew fetch pkg-config& brew fetch krb5& brew fetch icu4c& brew fetch re2c& brew fetch bison& brew fetch libzip& brew fetch mcrypt& brew fetch zlib& brew fetch bzip2& brew fetch enchant
|
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 autoconf automake pcre libtool libpng webp jpeg freetype libxml2 pkg-config krb5 icu4c re2c bison libzip mcrypt zlib bzip2 enchant > /dev/null 2>&1
|
brew link icu4c gettext --force >/dev/null 2>&1
|
||||||
brew link --force gettext
|
|
||||||
brew link --force bison
|
for package in gettext gmp bzip2 krb5 icu4c bison openssl libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype;
|
||||||
brew link --force openssl
|
do
|
||||||
brew link --force libxml2
|
caps_package=$(echo "$package" | tr '[:lower:]' '[:upper:]')
|
||||||
brew link --force bzip2
|
{
|
||||||
echo 'export PATH="/usr/local/opt/bzip2/bin:$PATH"' >> ~/.bash_profile
|
echo 'export PATH="/usr/local/opt/'"$package"'/bin:$PATH"'
|
||||||
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
|
echo 'export PKG_CONFIG_PATH="/usr/local/opt/'$package'/lib/pkgconfig:$PKG_CONFIG_PATH"'
|
||||||
echo 'export PATH="/usr/local/opt/krb5/bin:$PATH"' >> ~/.bash_profile
|
echo 'export '"$caps_package"'_LIBS="-L/usr/local/opt/'$package'/lib"'
|
||||||
echo 'export PATH="/usr/local/opt/krb5/sbin:$PATH"' >> ~/.bash_profile
|
echo 'export '"$caps_package"'_CFLAGS="-I/usr/local/opt/'$package'/include"'
|
||||||
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
|
} >> ~/.bash_profile;
|
||||||
echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile
|
done
|
||||||
echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
|
{
|
||||||
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile
|
echo 'export ICONV_LIBS="-L/usr/local/opt/libiconv/lib"'
|
||||||
echo 'export PATH="/Users/runner/.phpbrew/php/php-7.4.0RC1/bin:$PATH"' >> ~/.bash_profile
|
echo 'export ICONV_CFLAGS="-I/usr/local/opt/libiconv/include"'
|
||||||
source ~/.bash_profile > /dev/null 2>&1
|
echo 'export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib"'
|
||||||
export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib"
|
echo 'export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include"'
|
||||||
export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include"
|
echo 'export ICU_LIBS="-L/usr/local/opt/icu4c/lib"'
|
||||||
export ENCHANT_LIBS="-L/usr/local/opt/enchant/lib"
|
echo 'export ICU_CFLAGS="-I/usr/local/opt/icu4c/include"'
|
||||||
export ENCHANT_CFLAGS="-I/usr/local/opt/enchant/include"
|
echo 'export OPENSSL_LIBS="-L/usr/local/Cellar/openssl/1.0.2s/lib -lcrypto"'
|
||||||
export FFI_LIBS="-L/usr/local/opt/libffi/lib"
|
echo 'export OPENSSL_CFLAGS="-I/usr/local/Cellar/openssl/1.0.2s/include"'
|
||||||
export FFI_CFLAGS="-I/usr/local/opt/libffi/include"
|
echo 'export OPENSSL_ROOT_DIR="/usr/local/opt/openssl"'
|
||||||
export ICU_LIBS="-L/usr/local/opt/icu4c/lib"
|
echo 'export OPENSSL_LIB_DIR="/usr/local/opt/openssl/lib"'
|
||||||
export ICU_CFLAGS="-I/usr/local/opt/icu4c/include"
|
echo 'export OPENSSL_INCLUDE_DIR="/usr/local/opt/openssl/include"'
|
||||||
export KERBEROS_LIBS="-L/usr/local/opt/krb5/lib"
|
echo 'export PKG_CONFIG_PATH="/usr/local/Cellar/openssl/1.0.2s/lib/pkgconfig:$PKG_CONFIG_PATH"'
|
||||||
export KERBEROS_CFLAGS="-I/usr/local/opt/krb5/include"
|
echo 'export PKG_CONFIG="/usr/local/opt/pkgconfig/bin/pkg-config"'
|
||||||
export OPENSSL_LIBS="-L/usr/local/opt/openssl/lib"
|
echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib
|
||||||
export OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include"
|
/usr/local/opt/readline/lib/libreadline.dylib
|
||||||
export READLINE_LIBS="-L/usr/local/opt/readline/lib"
|
/usr/local/opt/openssl/lib/libssl.dylib
|
||||||
export READLINE_CFLAGS="-I/usr/local/opt/readline/include"
|
/usr/local/opt/openssl/lib/libcrypto.dylib
|
||||||
export BZIP2_LIBS="-L/usr/local/opt/bzip2/lib"
|
/usr/local/opt/icu4c/lib/libicudata.dylib
|
||||||
export BZIP2_CFLAGS="-I/usr/local/opt/bzip2/include"
|
/usr/local/opt/icu4c/lib/libicui18n.dylib
|
||||||
export PKG_CONFIG_PATH="/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/obzip2pt/libffi/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig"
|
/usr/local/opt/icu4c/lib/libicuio.dylib
|
||||||
|
/usr/local/opt/icu4c/lib/libicutu.dylib
|
||||||
|
/usr/local/opt/icu4c/lib/libicuuc.dylib"'
|
||||||
|
} >> ~/.bash_profile
|
||||||
|
config_file=$(pwd)/config.yaml
|
||||||
cd ~ || echo "could not move to ~"
|
cd ~ || echo "could not move to ~"
|
||||||
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
|
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1
|
||||||
chmod +x ./phpbrew
|
chmod +x ./phpbrew
|
||||||
sudo mv phpbrew /usr/local/bin/phpbrew
|
sudo mv phpbrew /usr/local/bin/phpbrew
|
||||||
sudo mkdir -p /opt/phpbrew
|
sudo mkdir -p /opt/phpbrew
|
||||||
phpbrew init --root=/opt/phpbrew
|
sudo phpbrew init --root=/opt/phpbrew --config="$config_file" >/dev/null 2>&1
|
||||||
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
|
sudo chmod -R 777 /opt/phpbrew
|
||||||
source ~/.bashrc
|
export PHPBREW_ROOT=/opt/phpbrew
|
||||||
phpbrew install -j 10 7.4.0RC2 +default +bz2="$(brew --prefix bzip2)" +zlib="$(brew --prefix zlib)" -openssl -- --with-libxml
|
export PHPBREW_HOME=/opt/phpbrew
|
||||||
phpbrew switch php-7.4.0RC2 > /dev/null 2>&1
|
echo "[[ -e ~/.phpbrew/bash_profile ]] && source ~/.phpbrew/bash_profile" >> ~/.bash_profile
|
||||||
|
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 mkdir -p /usr/local/bin
|
||||||
sudo ln -sf /Users/runner/.phpbrew/php/php-7.4.0RC2/bin/php /usr/local/bin/php
|
sudo ln -sf /opt/phpbrew/php/php-7.4.0RC2/bin/* /usr/local/bin/
|
||||||
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*||")
|
pecl config-set php_ini $ini_file
|
||||||
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
sudo chmod 777 "$ini_file"
|
sudo chmod 777 "$ini_file"
|
||||||
brew install composer
|
brew install composer
|
60
src/config.yaml
Normal file
60
src/config.yaml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
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
|
@ -1,11 +1,11 @@
|
|||||||
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
||||||
brew tap exolnet/homebrew-deprecated > /dev/null 2>&1
|
brew tap exolnet/homebrew-deprecated >/dev/null 2>&1
|
||||||
brew install php@"$1" composer
|
brew install php@"$1" composer >/dev/null 2>&1
|
||||||
brew link --force --overwrite php@"$1"
|
brew link --force --overwrite php@"$1" >/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=$(/usr/bin/php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
sudo chmod 777 "$ini_file"
|
sudo chmod 777 "$ini_file"
|
||||||
mkdir -p "$(pecl config-get ext_dir)"
|
mkdir -p "$(pecl config-get ext_dir)"
|
||||||
composer global require hirak/prestissimo
|
composer global require hirak/prestissimo >/dev/null 2>&1
|
||||||
php -v
|
php -v
|
||||||
composer -V
|
composer -V
|
||||||
|
131
src/features.ts
131
src/features.ts
@ -48,11 +48,19 @@ 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) {
|
||||||
Enable-PhpExtension ${extension} C:\\tools\\php\n` +
|
Add-Content C:\\tools\\php\\php.ini "${await utils.getExtensionPrefix(
|
||||||
(await utils.log(extension + ' enabled', 'win32', 'success')) +
|
extension
|
||||||
`}
|
)}=php_${extension}.dll"\n` +
|
||||||
|
(await utils.log('Enabled ' + extension, 'win32', 'success')) +
|
||||||
|
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
||||||
|
(await utils.log(
|
||||||
|
'Extension ' + extension + ' was already enabled',
|
||||||
|
'win32',
|
||||||
|
'success'
|
||||||
|
)) +
|
||||||
|
` }
|
||||||
} catch [Exception] {\n` +
|
} catch [Exception] {\n` +
|
||||||
(await utils.log(extension + ' could not be installed', 'win32', 'error')) +
|
(await utils.log(extension + ' could not be enabled', 'win32', 'error')) +
|
||||||
` }\n`
|
` }\n`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -61,12 +69,24 @@ export async function enableExtensionWindows(extension: string) {
|
|||||||
* Enable extensions which are installed but not enabled on unix
|
* Enable extensions which are installed but not enabled on unix
|
||||||
*
|
*
|
||||||
* @param extension
|
* @param extension
|
||||||
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
export async function enableExtensionUnix(extension: string) {
|
export async function enableExtensionUnix(
|
||||||
|
extension: string,
|
||||||
|
os_version: string
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
`if [ ! "$(php -m | grep ${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(
|
||||||
(await utils.log(extension + ' enabled', 'unix', 'success')) +
|
extension
|
||||||
|
)}=php_${extension}.so" >> '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(
|
||||||
|
'Extension ' + extension + ' was already enabled',
|
||||||
|
os_version,
|
||||||
|
'success'
|
||||||
|
)) +
|
||||||
`; fi\n`
|
`; fi\n`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -86,21 +106,36 @@ export async function addExtensionDarwin(
|
|||||||
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);
|
script += await enableExtensionUnix(extension, 'darwin');
|
||||||
switch (await pecl.checkPECLExtension(extension)) {
|
switch (await pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
extension =
|
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 ' +
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
extension +
|
extension +
|
||||||
')" ]; then sudo pecl install ' +
|
')" ]; then sudo pecl install ' +
|
||||||
extension +
|
extension_version +
|
||||||
|
' >/dev/null 2>&1 && ' +
|
||||||
|
(await utils.log(
|
||||||
|
'Installed and enabled ' + extension,
|
||||||
|
'darwin',
|
||||||
|
'success'
|
||||||
|
)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
"Couldn't install extension: " + extension,
|
'Could not install ' + extension + ' on PHP' + version,
|
||||||
'darwin',
|
'darwin',
|
||||||
'error'
|
'error'
|
||||||
)) +
|
)) +
|
||||||
@ -109,11 +144,15 @@ export async function addExtensionDarwin(
|
|||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script +=
|
script +=
|
||||||
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
|
extension +
|
||||||
|
')" ]; then \n' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not find extension: ' + extension,
|
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
||||||
'darwin',
|
'darwin',
|
||||||
'error'
|
'error'
|
||||||
)) + '\n';
|
)) +
|
||||||
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -136,30 +175,46 @@ 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' +
|
||||||
|
(await utils.log(
|
||||||
|
'Installed and enabled ' + extension,
|
||||||
|
'win32',
|
||||||
|
'success'
|
||||||
|
)) +
|
||||||
' } catch [Exception] { ' +
|
' } catch [Exception] { ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not install extension: ' + extension,
|
'Could not install ' + extension + ' on PHP' + version,
|
||||||
'win32',
|
'win32',
|
||||||
'error'
|
'error'
|
||||||
)) +
|
)) +
|
||||||
@ -168,11 +223,15 @@ export async function addExtensionWindows(
|
|||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script +=
|
script +=
|
||||||
|
'if(!(php -m | findstr -i ' +
|
||||||
|
extension +
|
||||||
|
')) { ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not find extension: ' + extension,
|
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
||||||
'win32',
|
'win32',
|
||||||
'error'
|
'error'
|
||||||
)) + '\n';
|
)) +
|
||||||
|
' } \n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -194,17 +253,31 @@ export async function addExtensionLinux(
|
|||||||
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);
|
script += await enableExtensionUnix(extension, 'linux');
|
||||||
script +=
|
script +=
|
||||||
'if [ ! "$(php -m | grep ' +
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
extension +
|
extension +
|
||||||
')" ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
')" ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||||
version +
|
version +
|
||||||
'-' +
|
'-' +
|
||||||
extension +
|
extension +
|
||||||
|
' >/dev/null 2>&1 || sudo DEBIAN_FRONTEND=noninteractive apt install -y php-' +
|
||||||
|
extension +
|
||||||
|
' >/dev/null 2>&1 && ' +
|
||||||
|
(await utils.log(
|
||||||
|
'Installed and enabled ' + extension,
|
||||||
|
'linux',
|
||||||
|
'success'
|
||||||
|
)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
"Couldn't find extension php" + version + '-' + extension,
|
'Could not find php-' +
|
||||||
|
extension +
|
||||||
|
' or php' +
|
||||||
|
version +
|
||||||
|
'-' +
|
||||||
|
extension +
|
||||||
|
' on APT repository',
|
||||||
'linux',
|
'linux',
|
||||||
'error'
|
'error'
|
||||||
)) +
|
)) +
|
||||||
|
@ -22,6 +22,7 @@ async function run() {
|
|||||||
version,
|
version,
|
||||||
os_version
|
os_version
|
||||||
);
|
);
|
||||||
|
|
||||||
darwin += await features.addExtension(extension_csv, version, os_version);
|
darwin += await features.addExtension(extension_csv, version, os_version);
|
||||||
darwin += await features.addINIValues(ini_values_csv, os_version);
|
darwin += await features.addINIValues(ini_values_csv, os_version);
|
||||||
darwin += await features.addCoverage(coverage, version, os_version);
|
darwin += await features.addCoverage(coverage, version, os_version);
|
||||||
|
12
src/linux.sh
12
src/linux.sh
@ -1,13 +1,13 @@
|
|||||||
version=$(php-config --version | cut -c 1-3)
|
version=$(php-config --version | cut -c 1-3)
|
||||||
if [ "$version" != "$1" ]; then
|
if [ "$version" != "$1" ]; then
|
||||||
if [ ! -e "/usr/bin/php$1" ]; then
|
if [ ! -e "/usr/bin/php$1" ]; then
|
||||||
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y > /dev/null 2>&1
|
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 update -y >/dev/null 2>&1
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" curl php"$1"-curl;
|
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
for tool in php phar phar.phar php-cgi php-config phpize; do
|
for tool in php phar phar.phar php-cgi php-config phpize; do
|
||||||
if [ -e "/usr/bin/$tool$1" ]; then
|
if [ -e "/usr/bin/$tool$1" ]; then
|
||||||
sudo update-alternatives --set $tool /usr/bin/"$tool$1";
|
sudo update-alternatives --set $tool /usr/bin/"$tool$1"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@ -26,9 +26,9 @@ if [ ! -e "/usr/bin/composer" ]; then
|
|||||||
rm composer-setup.php
|
rm composer-setup.php
|
||||||
fi
|
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
|
||||||
|
28
src/utils.ts
28
src/utils.ts
@ -48,6 +48,9 @@ export async function readScript(
|
|||||||
case 'darwin':
|
case 'darwin':
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
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');
|
return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
|
||||||
case '7.3':
|
case '7.3':
|
||||||
default:
|
default:
|
||||||
@ -118,6 +121,11 @@ export async function log(
|
|||||||
os_version: string,
|
os_version: string,
|
||||||
log_type: string
|
log_type: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
const unix_color: any = {
|
||||||
|
error: '31',
|
||||||
|
success: '32',
|
||||||
|
warning: '33'
|
||||||
|
};
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
const color: any = {
|
const color: any = {
|
||||||
@ -128,15 +136,25 @@ export async function log(
|
|||||||
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
||||||
|
|
||||||
case 'linux':
|
case 'linux':
|
||||||
|
return (
|
||||||
|
'echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"'
|
||||||
|
);
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
default:
|
default:
|
||||||
const unix_color: any = {
|
|
||||||
error: '31',
|
|
||||||
success: '32',
|
|
||||||
warning: '33'
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
'echo -e "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"'
|
'echo -e "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user