mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Use shivammathur/extensions for phalcon and psr
This commit is contained in:
parent
c485e8b283
commit
9fdc82bced
@ -84,7 +84,7 @@ describe('Extension tests', () => {
|
|||||||
|
|
||||||
it('checking addExtensionOnDarwin', async () => {
|
it('checking addExtensionOnDarwin', async () => {
|
||||||
let darwin: string = await extensions.addExtension(
|
let darwin: string = await extensions.addExtension(
|
||||||
'Xdebug, pcov, grpc, igbinary, imagick, protobuf, swoole, sqlite, ast-beta',
|
'Xdebug, pcov, grpc, igbinary, imagick, phalcon3, phalcon4, protobuf, psr, swoole, sqlite, ast-beta',
|
||||||
'7.2',
|
'7.2',
|
||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
@ -93,17 +93,14 @@ describe('Extension tests', () => {
|
|||||||
expect(darwin).toContain('add_brew_extension grpc');
|
expect(darwin).toContain('add_brew_extension grpc');
|
||||||
expect(darwin).toContain('add_brew_extension igbinary');
|
expect(darwin).toContain('add_brew_extension igbinary');
|
||||||
expect(darwin).toContain('add_brew_extension imagick');
|
expect(darwin).toContain('add_brew_extension imagick');
|
||||||
|
expect(darwin).toContain('add_brew_extension phalcon3');
|
||||||
|
expect(darwin).toContain('add_brew_extension phalcon4');
|
||||||
expect(darwin).toContain('add_brew_extension protobuf');
|
expect(darwin).toContain('add_brew_extension protobuf');
|
||||||
|
expect(darwin).toContain('add_brew_extension psr');
|
||||||
expect(darwin).toContain('add_brew_extension swoole');
|
expect(darwin).toContain('add_brew_extension swoole');
|
||||||
expect(darwin).toContain('pecl_install sqlite3');
|
expect(darwin).toContain('pecl_install sqlite3');
|
||||||
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
|
|
||||||
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
|
|
||||||
|
|
||||||
darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin');
|
|
||||||
expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3');
|
|
||||||
|
|
||||||
darwin = await extensions.addExtension('pcov', '5.6', 'darwin');
|
darwin = await extensions.addExtension('pcov', '5.6', 'darwin');
|
||||||
expect(darwin).toContain('pecl_install pcov');
|
expect(darwin).toContain('pecl_install pcov');
|
||||||
|
|
||||||
|
13
dist/index.js
vendored
13
dist/index.js
vendored
@ -1823,8 +1823,9 @@ async function addExtensionDarwin(extension_csv, version) {
|
|||||||
return;
|
return;
|
||||||
// match 5.6 to 8.0 amqp, grpc, igbinary, imagick, imap, msgpack, pecl_http, propro, protobuf, raphf, redis, swoole, xdebug, xdebug2, zmq
|
// match 5.6 to 8.0 amqp, grpc, igbinary, imagick, imap, msgpack, pecl_http, propro, protobuf, raphf, redis, swoole, xdebug, xdebug2, zmq
|
||||||
// match 7.1pcov to 8.0pcov
|
// match 7.1pcov to 8.0pcov
|
||||||
case /(5\.6|7\.[0-4]|8.0)(amqp|grpc|igbinary|imagick|imap|msgpack|^(pecl_)?http$|propro|protobuf|raphf|redis|swoole|xdebug|xdebug2|zmq)/.test(version_extension):
|
case /(5\.6|7\.[0-4]|8.0)(amqp|grpc|igbinary|imagick|imap|msgpack|^(pecl_)?http$|propro|protobuf|psr|raphf|redis|swoole|xdebug|xdebug2|zmq)/.test(version_extension):
|
||||||
case /(7\.[1-4]|8\.0])pcov/.test(version_extension):
|
case /(7\.[1-4]|8\.0])pcov/.test(version_extension):
|
||||||
|
case /^(5\.6|7\.[0-3])phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
command = 'add_brew_extension ' + extension_name.replace('pecl_', '');
|
command = 'add_brew_extension ' + extension_name.replace('pecl_', '');
|
||||||
break;
|
break;
|
||||||
// match sqlite
|
// match sqlite
|
||||||
@ -1832,16 +1833,6 @@ async function addExtensionDarwin(extension_csv, version) {
|
|||||||
extension = 'sqlite3';
|
extension = 'sqlite3';
|
||||||
command = command_prefix + extension;
|
command = command_prefix + extension;
|
||||||
break;
|
break;
|
||||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
|
||||||
script +=
|
|
||||||
'\nbash ' +
|
|
||||||
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
|
|
||||||
' ' +
|
|
||||||
extension +
|
|
||||||
' ' +
|
|
||||||
version;
|
|
||||||
return;
|
|
||||||
default:
|
default:
|
||||||
command = command_prefix + extension;
|
command = command_prefix + extension;
|
||||||
break;
|
break;
|
||||||
|
@ -32,10 +32,13 @@ export async function addExtensionDarwin(
|
|||||||
return;
|
return;
|
||||||
// match 5.6 to 8.0 amqp, grpc, igbinary, imagick, imap, msgpack, pecl_http, propro, protobuf, raphf, redis, swoole, xdebug, xdebug2, zmq
|
// match 5.6 to 8.0 amqp, grpc, igbinary, imagick, imap, msgpack, pecl_http, propro, protobuf, raphf, redis, swoole, xdebug, xdebug2, zmq
|
||||||
// match 7.1pcov to 8.0pcov
|
// match 7.1pcov to 8.0pcov
|
||||||
case /(5\.6|7\.[0-4]|8.0)(amqp|grpc|igbinary|imagick|imap|msgpack|^(pecl_)?http$|propro|protobuf|raphf|redis|swoole|xdebug|xdebug2|zmq)/.test(
|
case /(5\.6|7\.[0-4]|8.0)(amqp|grpc|igbinary|imagick|imap|msgpack|^(pecl_)?http$|propro|protobuf|psr|raphf|redis|swoole|xdebug|xdebug2|zmq)/.test(
|
||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
case /(7\.[1-4]|8\.0])pcov/.test(version_extension):
|
case /(7\.[1-4]|8\.0])pcov/.test(version_extension):
|
||||||
|
case /^(5\.6|7\.[0-3])phalcon3$|^7\.[2-4]phalcon4$/.test(
|
||||||
|
version_extension
|
||||||
|
):
|
||||||
command = 'add_brew_extension ' + extension_name.replace('pecl_', '');
|
command = 'add_brew_extension ' + extension_name.replace('pecl_', '');
|
||||||
break;
|
break;
|
||||||
// match sqlite
|
// match sqlite
|
||||||
@ -43,16 +46,6 @@ export async function addExtensionDarwin(
|
|||||||
extension = 'sqlite3';
|
extension = 'sqlite3';
|
||||||
command = command_prefix + extension;
|
command = command_prefix + extension;
|
||||||
break;
|
break;
|
||||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
|
||||||
script +=
|
|
||||||
'\nbash ' +
|
|
||||||
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
|
|
||||||
' ' +
|
|
||||||
extension +
|
|
||||||
' ' +
|
|
||||||
version;
|
|
||||||
return;
|
|
||||||
default:
|
default:
|
||||||
command = command_prefix + extension;
|
command = command_prefix + extension;
|
||||||
break;
|
break;
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
# Function to log result of a operation
|
|
||||||
add_log() {
|
|
||||||
mark=$1
|
|
||||||
subject=$2
|
|
||||||
message=$3
|
|
||||||
if [ "$mark" = "$tick" ]; then
|
|
||||||
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
||||||
else
|
|
||||||
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to install phalcon
|
|
||||||
install_phalcon() {
|
|
||||||
(
|
|
||||||
sed -i '' '/extension.*psr/d' "$ini_file"
|
|
||||||
brew tap shivammathur/homebrew-phalcon >/dev/null 2>&1
|
|
||||||
brew install phalcon@"$php_version"_"$extension_major" >/dev/null 2>&1
|
|
||||||
sudo cp /usr/local/opt/psr@"$php_version"/psr.so "$ext_dir" >/dev/null 2>&1
|
|
||||||
sudo cp /usr/local/opt/phalcon@"$php_version"_"$extension_major"/phalcon.so "$ext_dir" >/dev/null 2>&1
|
|
||||||
add_log "$tick" "$extension" "Installed and enabled"
|
|
||||||
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
|
||||||
}
|
|
||||||
|
|
||||||
tick="✓"
|
|
||||||
cross="✗"
|
|
||||||
extension=$1
|
|
||||||
extension_major=${extension: -1}
|
|
||||||
php_version=$2
|
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
|
||||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
|
||||||
if [ -e "$ext_dir/psr.so" ] && [ -e "$ext_dir/phalcon.so" ]; then
|
|
||||||
phalcon_version=$(php -d="extension=psr.so" -d="extension=phalcon.so" -r "echo phpversion('phalcon');" 2>/dev/null | cut -d'.' -f 1)
|
|
||||||
if php -m | grep -i -q -w psr; then
|
|
||||||
phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" 2>/dev/null | cut -d'.' -f 1)
|
|
||||||
fi
|
|
||||||
if [ "$phalcon_version" != "$extension_major" ]; then
|
|
||||||
install_phalcon
|
|
||||||
else
|
|
||||||
if ! php -m | grep -i -q -w psr; then echo "extension=psr.so" >>"$ini_file"; fi
|
|
||||||
echo "extension=phalcon.so" >>"$ini_file"
|
|
||||||
add_log "$tick" "$extension" "Enabled"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
install_phalcon
|
|
||||||
fi
|
|
Loading…
Reference in New Issue
Block a user