From ab12e42197721def2fac4fc5d75f7777bbee87bd Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Tue, 28 Sep 2021 01:38:12 +0530 Subject: [PATCH] Add support for expect and ssh2 using shivammathur/extensions on macOS Add config to brew extensions and refactor add_brew_extension in darwin.sh to use it --- __tests__/extensions.test.ts | 4 +++- dist/index.js | 2 +- src/configs/brew_extensions | 28 ++++++++++++++++++++++++++++ src/extensions.ts | 4 ++-- src/scripts/darwin.sh | 3 ++- 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 src/configs/brew_extensions diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index f10a294c..9b30977d 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -73,12 +73,13 @@ describe('Extension tests', () => { it('checking addExtensionOnDarwin', async () => { let darwin: string = await extensions.addExtension( - 'Xdebug, pcov, grpc, igbinary, imagick, phalcon3, phalcon4, protobuf, psr, rdkafka, swoole, vips, sqlite, ast-beta', + 'Xdebug, pcov, expect, grpc, igbinary, imagick, phalcon3, phalcon4, protobuf, psr, rdkafka, ssh2, swoole, vips, sqlite, ast-beta', '7.2', 'darwin' ); expect(darwin).toContain('add_brew_extension xdebug'); expect(darwin).toContain('add_brew_extension pcov'); + expect(darwin).toContain('add_brew_extension expect'); expect(darwin).toContain('add_brew_extension grpc'); expect(darwin).toContain('add_brew_extension igbinary'); expect(darwin).toContain('add_brew_extension imagick'); @@ -87,6 +88,7 @@ describe('Extension tests', () => { expect(darwin).toContain('add_brew_extension protobuf'); expect(darwin).toContain('add_brew_extension psr'); expect(darwin).toContain('add_brew_extension rdkafka'); + expect(darwin).toContain('add_brew_extension ssh2'); expect(darwin).toContain('add_brew_extension swoole'); expect(darwin).toContain('add_brew_extension vips'); expect(darwin).toContain('pecl_install sqlite3'); diff --git a/dist/index.js b/dist/index.js index a7662039..37948de1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -230,7 +230,7 @@ async function addExtensionDarwin(extension_csv, version) { ' ' + ext_prefix; return; - case /(5\.6|7\.[0-4]|8.0)(amqp|grpc|igbinary|imagick|imap|mongodb|msgpack|^(pecl_)?http$|propro|protobuf|psr|raphf|rdkafka|redis|swoole|xdebug|xdebug2|yaml|zmq)/.test(version_extension): + case /(5\.6|7\.[0-4]|8.0)(amqp|expect|grpc|igbinary|imagick|imap|mongodb|msgpack|^(pecl_)?http$|propro|protobuf|psr|raphf|rdkafka|redis|ssh2|swoole|xdebug|xdebug2|yaml|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): case /(7\.[0-4]|8\.0])vips/.test(version_extension): diff --git a/src/configs/brew_extensions b/src/configs/brew_extensions new file mode 100644 index 00000000..d7f1212e --- /dev/null +++ b/src/configs/brew_extensions @@ -0,0 +1,28 @@ +amqp=amqp +apcu=apcu +expect=expect +grpc=grpc +igbinary=igbinary +imagick=imagick +imap=imap +memcache=memcache +memcached=memcached +mongodb=mongodb +msgpack=msgpack +pcov=pcov +pecl_http=http +phalcon3=phalcon +phalcon4=phalcon +propro=propro +protobuf=protobuf +psr=psr +raphf=raphf +rdkafka=rdkafka +redis=redis +ssh2=ssh2 +swoole=swoole +vips=vips +xdebug=xdebug +xdebug2=xdebug +yaml=yaml +zmq=zmq diff --git a/src/extensions.ts b/src/extensions.ts index eccf753f..d5dcce61 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -30,10 +30,10 @@ export async function addExtensionDarwin( ' ' + ext_prefix; return; - // match 5.6 to 8.0 amqp, grpc, igbinary, imagick, imap, mongodb, msgpack, pecl_http, propro, protobuf, raphf, rdkafka, redis, swoole, xdebug, xdebug2, yaml, zmq + // match 5.6 to 8.0 amqp, expect, grpc, igbinary, imagick, imap, mongodb, msgpack, pecl_http, propro, protobuf, raphf, rdkafka, redis, ssh2, swoole, xdebug, xdebug2, yaml, zmq // match 7.1pcov to 8.0pcov // match 7.0vips to 8.0vips - case /(5\.6|7\.[0-4]|8.0)(amqp|grpc|igbinary|imagick|imap|mongodb|msgpack|^(pecl_)?http$|propro|protobuf|psr|raphf|rdkafka|redis|swoole|xdebug|xdebug2|yaml|zmq)/.test( + case /(5\.6|7\.[0-4]|8.0)(amqp|expect|grpc|igbinary|imagick|imap|mongodb|msgpack|^(pecl_)?http$|propro|protobuf|psr|raphf|rdkafka|redis|ssh2|swoole|xdebug|xdebug2|yaml|zmq)/.test( version_extension ): case /(7\.[1-4]|8\.0])pcov/.test(version_extension): diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 914f690c..3f57d7af 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -103,7 +103,8 @@ add_brew_tap() { # Function to install a php extension from shivammathur/extensions tap. add_brew_extension() { formula=$1 - extension=${formula//[0-9]/} + extension=$(grep "$formula=" "$dist"/../src/configs/brew_extensions | cut -d '=' -f 2) + [[ -z "$extension" ]] && extension="$(echo "$formula" | sed -E "s/pecl_|[0-9]//g")" add_brew_tap shivammathur/homebrew-php add_brew_tap shivammathur/homebrew-extensions sudo mv "$tap_dir"/shivammathur/homebrew-extensions/.github/deps/"$formula"/* "$tap_dir/homebrew/homebrew-core/Formula/" 2>/dev/null || true