Use shivammathur/extensions for phalcon and psr

This commit is contained in:
Shivam Mathur 2021-04-19 00:54:25 +05:30
parent c485e8b283
commit 9fdc82bced
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
4 changed files with 10 additions and 76 deletions

View File

@ -84,7 +84,7 @@ describe('Extension tests', () => {
it('checking addExtensionOnDarwin', async () => {
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',
'darwin'
);
@ -93,17 +93,14 @@ describe('Extension tests', () => {
expect(darwin).toContain('add_brew_extension grpc');
expect(darwin).toContain('add_brew_extension igbinary');
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 psr');
expect(darwin).toContain('add_brew_extension swoole');
expect(darwin).toContain('pecl_install sqlite3');
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');
expect(darwin).toContain('pecl_install pcov');

13
dist/index.js vendored
View File

@ -1823,8 +1823,9 @@ async function addExtensionDarwin(extension_csv, version) {
return;
// 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
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 /^(5\.6|7\.[0-3])phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
command = 'add_brew_extension ' + extension_name.replace('pecl_', '');
break;
// match sqlite
@ -1832,16 +1833,6 @@ async function addExtensionDarwin(extension_csv, version) {
extension = 'sqlite3';
command = command_prefix + extension;
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:
command = command_prefix + extension;
break;

View File

@ -32,10 +32,13 @@ export async function addExtensionDarwin(
return;
// 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
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
):
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_', '');
break;
// match sqlite
@ -43,16 +46,6 @@ export async function addExtensionDarwin(
extension = 'sqlite3';
command = command_prefix + extension;
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:
command = command_prefix + extension;
break;

View File

@ -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