From 0d9a1ba5ae14203fcaa289234e84725c92292eda Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sat, 16 Jul 2022 00:46:28 +0530 Subject: [PATCH] Add support for phalcon5 on Linux and macOS Fix get_pecl_version --- __tests__/extensions.test.ts | 2 +- dist/index.js | 4 +-- src/configs/brew_extensions | 1 + src/extensions.ts | 12 ++++++--- src/scripts/extensions/add_extensions.sh | 5 ++-- src/scripts/extensions/phalcon.sh | 34 ++++++++++++++++++++---- 6 files changed, 44 insertions(+), 14 deletions(-) diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index eacb91f9..735eb07c 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -117,7 +117,7 @@ describe('Extension tests', () => { ) ? `add_${extension}` : `add_brew_extension ${formula} ${prefix}`; - return [formula, '7.3', output]; + return [formula, formula === 'phalcon3' ? '7.3' : '7.4', output]; }); it.each(data)( diff --git a/dist/index.js b/dist/index.js index aeba2ec2..f14ace44 100644 --- a/dist/index.js +++ b/dist/index.js @@ -247,7 +247,7 @@ async function addExtensionDarwin(extension_csv, version) { case /^(5\.[3-6]|7\.[0-4]|8\.[0-1])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^couchbase|^event|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension): case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension): - case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/.test(version_extension): + case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4|(7\.4|8\.[0-2])phalcon5/.test(version_extension): case /(?/dev/null 2>&1 || update_ppa ondrej/php - check_package "${packages[0]}" && install_packages "${packages[@]}" + (check_package "${packages[0]}" && install_packages "${packages[@]}") || pecl_install "phalcon-$(get_phalcon_version)" fi } @@ -44,15 +56,27 @@ add_phalcon4() { fi } +# Function to add phalcon3. +add_phalcon5() { + if shared_extension phalcon; then + phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1) + if [ "$phalcon_version" != "$extension_major_version" ]; then + add_phalcon_helper + else + enable_extension phalcon extension + fi + else + add_phalcon_helper + fi +} + # Function to add phalcon. add_phalcon() { extension=$1 status='Enabled' extension_major_version=${extension: -1} - if [ "$extension_major_version" = "4" ]; then - add_phalcon4 >/dev/null 2>&1 - elif [ "$extension_major_version" = "3" ]; then - add_phalcon3 >/dev/null 2>&1 + if [[ "$extension_major_version" =~ [3-5] ]]; then + add_phalcon"$extension_major_version" >/dev/null 2>&1 fi add_extension_log "phalcon" "$status" }