From ce49f82dd822a20d970610323f774495636dea67 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Wed, 6 Jul 2022 16:51:44 +0530 Subject: [PATCH] Do not add composer plugins to allow list for composer v1 --- src/scripts/tools/add_tools.ps1 | 5 +++-- src/scripts/tools/add_tools.sh | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/scripts/tools/add_tools.ps1 b/src/scripts/tools/add_tools.ps1 index 1d6e77bf..cfe90071 100644 --- a/src/scripts/tools/add_tools.ps1 +++ b/src/scripts/tools/add_tools.ps1 @@ -205,7 +205,7 @@ Function Add-ComposertoolHelper() { if(Test-Path $composer_lock) { Remove-Item -Path $composer_lock -Force } - if(composer global show $prefix$tool -a 2>&1 | findstr '^type *: *composer-plugin') { + if((composer global show $prefix$tool -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) { composer global config --no-plugins allow-plugins."$prefix$tool" true >$null 2>&1 } composer global require $prefix$release $composer_args >$null 2>&1 @@ -215,7 +215,7 @@ Function Add-ComposertoolHelper() { $scoped_dir_suffix = (Get-FileHash -InputStream $release_stream -Algorithm sha256).Hash $scoped_dir = "$composer_bin\_tools\$tool-$scoped_dir_suffix" $unix_scoped_dir = $scoped_dir.replace('\', '/') - if(composer show $prefix$tool -d $unix_scoped_dir -a 2>&1 | findstr '^type *: *composer-plugin') { + if((composer show $prefix$tool -d $unix_scoped_dir -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) { composer config -d $unix_scoped_dir --no-plugins allow-plugins."$prefix$release" true >$null 2>&1 } if(-not(Test-Path $scoped_dir)) { @@ -252,6 +252,7 @@ Function Add-Composertool() { [string] $scope ) + $composer_args = "" if($composer_version.split('.')[0] -ne "1") { $composer_args = "--ignore-platform-req=ext-*" if($tool -match "prestissimo|composer-prefetcher") { diff --git a/src/scripts/tools/add_tools.sh b/src/scripts/tools/add_tools.sh index 4e0af8c1..0568fda3 100644 --- a/src/scripts/tools/add_tools.sh +++ b/src/scripts/tools/add_tools.sh @@ -162,17 +162,17 @@ add_composertool_helper() { enable_extensions curl mbstring openssl if [ "$scope" = "global" ]; then sudo rm -f "$composer_lock" >/dev/null 2>&1 || true - if composer global show "$prefix$tool" -a 2>&1 | grep -qE '^type *: *composer-plugin'; then + if composer global show "$prefix$tool" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then composer global config --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1 fi composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1 - composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer_show.log >/dev/null 2>&1 + composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1 else scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)" if ! [ -d "$scoped_dir" ]; then mkdir -p "$scoped_dir" echo '{}' | tee "$scoped_dir/composer.json" >/dev/null - if composer show "$prefix$tool" -d "$scoped_dir" -a 2>&1 | grep -qE '^type *: *composer-plugin'; then + if composer show "$prefix$tool" -d "$scoped_dir" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then composer config -d "$scoped_dir" --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1 fi composer require "$prefix$release" -d "$scoped_dir" "$composer_args" >/dev/null 2>&1 @@ -188,6 +188,7 @@ add_composertool() { release=$2 prefix=$3 scope=$4 + composer_args= composer_major_version=$(cut -d'.' -f 1 /tmp/composer_version) if [ "$composer_major_version" != "1" ]; then composer_args="--ignore-platform-req=ext-*"