From 0c0ae3977511e206d66248c295430fb67841778d Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 22 Feb 2021 14:39:22 +0530 Subject: [PATCH] Assorted fixes --- __tests__/extensions.test.ts | 4 ++-- src/extensions.ts | 6 +++--- src/scripts/darwin.sh | 13 ++++++++----- src/scripts/linux.sh | 8 ++++++-- src/scripts/win32.ps1 | 13 ++++++++----- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 834af2d6..e6cd1a05 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -116,8 +116,8 @@ describe('Extension tests', () => { darwin = await extensions.addExtension('xdebug', '7.0', 'darwin'); expect(darwin).toContain('add_brew_extension xdebug'); - darwin = await extensions.addExtension('xdebug', '7.2', 'darwin'); - expect(darwin).toContain('add_brew_extension xdebug'); + darwin = await extensions.addExtension('xdebug2', '7.2', 'darwin'); + expect(darwin).toContain('add_brew_extension xdebug2'); darwin = await extensions.addExtension( 'does_not_exist', diff --git a/src/extensions.ts b/src/extensions.ts index 9eff5119..4ad464a3 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -36,7 +36,7 @@ export async function addExtensionDarwin( version_extension ): case /(7\.[1-4]|8\.0])pcov/.test(version_extension): - command = 'add_brew_extension ' + extension_name; + command = 'add_brew_extension ' + extension_name.replace('pecl_', ''); break; // match sqlite case /^sqlite$/.test(extension): @@ -93,7 +93,7 @@ export async function addExtensionWindows( script += '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; break; - // match 7.2xdebug + // match 7.2xdebug2 to 7.4xdebug2 case /7\.[2-4]xdebug2/.test(version_extension): script += '\nAdd-Extension xdebug stable 2.9.8'; break; @@ -177,7 +177,7 @@ export async function addExtensionLinux( ' ' + version; return; - // match 7.2xdebug + // match 7.2xdebug2 to 7.4xdebug2 case /^7\.[2-4]xdebug2$/.test(version_extension): script += '\nadd_pecl_extension xdebug 2.9.8 ' + ext_prefix; return; diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 3dc42c61..060306a9 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -102,12 +102,13 @@ add_brew_tap() { # Function to install a php extension from shivammathur/extensions tap. add_brew_extension() { - extension=$1 + formula=$1 + extension=${formula//[0-9]/} add_brew_tap shivammathur/homebrew-php add_brew_tap shivammathur/homebrew-extensions - sudo mv "$tap_dir"/shivammathur/homebrew-extensions/.github/deps/"$extension"/* "$tap_dir/homebrew/homebrew-core/Formula/" 2>/dev/null || true - brew install "$extension@$version" - sudo cp "$brew_prefix/opt/$extension@$version/$extension.so" "$ext_dir" + sudo mv "$tap_dir"/shivammathur/homebrew-extensions/.github/deps/"$formula"/* "$tap_dir/homebrew/homebrew-core/Formula/" 2>/dev/null || true + brew install "$formula@$version" + sudo cp "$brew_prefix/opt/$formula@$version/$extension.so" "$ext_dir" } # Function to setup extensions @@ -211,13 +212,15 @@ add_composertool() { if [ -e "$composer_bin/composer" ]; then sudo cp -p "$tool_path_dir/composer" "$composer_bin" fi + if [ "$tool" = "codeception" ]; then + sudo ln -s $composer_bin/codecept $composer_bin/codeception + fi } # Function to configure PECL configure_pecl() { for tool in pear pecl; do sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1 - sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1 sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1 done } diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index cf9a3e97..be954e42 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -41,8 +41,8 @@ configure_pecl() { add_pecl >/dev/null 2>&1 fi for script in pear pecl; do - sudo "$script" config-set php_ini "${pecl_file:-${ini_file[@]}}" - sudo "$script" channel-update "$script".php.net + sudo "$script" config-set php_ini "${pecl_file:-$ini_file}" >/dev/null 2>&1 + sudo "$script" channel-update "$script".php.net >/dev/null 2>&1 done echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1 fi @@ -118,6 +118,7 @@ add_pecl_extension() { extension=$1 pecl_version=$2 prefix=$3 + configure_pecl if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then pecl_version=$(get_pecl_version "$extension" "$pecl_version") fi @@ -216,6 +217,9 @@ add_composertool() { if [ -e "$composer_bin/composer" ]; then sudo cp -p "$tool_path_dir/composer" "$composer_bin" fi + if [ "$tool" = "codeception" ]; then + sudo ln -s $composer_bin/codecept $composer_bin/codeception + fi } # Function to setup phpize and php-config diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index c5e3e252..64c4154a 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -203,15 +203,15 @@ Function Add-Tool() { $bat_content += "php %BIN_TARGET% %*" Set-Content -Path $php_dir\$tool.bat -Value $bat_content Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.bat" >$null 2>&1 - if($tool -eq "phan") { + if($tool -eq "composer") { + Edit-ComposerConfig $php_dir\$tool + } elseif($tool -eq "cs2pr") { + (Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr + } elseif($tool -eq "phan") { Add-Extension fileinfo >$null 2>&1 Add-Extension ast >$null 2>&1 } elseif($tool -eq "phive") { Add-Extension xml >$null 2>&1 - } elseif($tool -eq "cs2pr") { - (Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr - } elseif($tool -eq "composer") { - Edit-ComposerConfig $php_dir\$tool } elseif($tool -eq "wp-cli") { Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat } @@ -243,6 +243,9 @@ Function Add-Composertool() { Remove-Item -Path $composer_lock -Force } composer -q global require $prefix$release 2>&1 | out-null + if($tool -eq "codeception") { + Copy-Item $composer_bin\codecept.bat -Destination $composer_bin\codeception.bat + } if($?) { Add-Log $tick $tool "Added" } else {