Skip to content

Commit

Permalink
Do not add composer plugins to allow list for composer v1
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Jul 7, 2022
1 parent cf5cd90 commit ce49f82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/scripts/tools/add_tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)) {
Expand Down Expand Up @@ -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") {
Expand Down
7 changes: 4 additions & 3 deletions src/scripts/tools/add_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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-*"
Expand Down

0 comments on commit ce49f82

Please sign in to comment.