mirror of
				https://github.com/shivammathur/setup-php.git
				synced 2025-10-31 15:26:23 +07:00 
			
		
		
		
	Add --ignore-platform-req=ext-* while installing composer packages with composer v2
This commit is contained in:
		| @ -147,13 +147,16 @@ Function Add-ComposertoolHelper() { | ||||
|     $prefix, | ||||
|     [Parameter(Position = 3, Mandatory = $true)] | ||||
|     [string] | ||||
|     $scope | ||||
|     $scope, | ||||
|     [Parameter(Position = 4, Mandatory = $false)] | ||||
|     [string] | ||||
|     $composer_args | ||||
|   ) | ||||
|   if($scope -eq 'global') { | ||||
|     if(Test-Path $composer_lock) { | ||||
|       Remove-Item -Path $composer_lock -Force | ||||
|     } | ||||
|     composer global require $prefix$release >$null 2>&1 | ||||
|     composer global require $prefix$release $composer_args >$null 2>&1 | ||||
|     return composer global show $prefix$tool 2>&1 | findstr '^versions' | ||||
|   } else { | ||||
|     $release_stream = [System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($release)) | ||||
| @ -162,7 +165,7 @@ Function Add-ComposertoolHelper() { | ||||
|     $unix_scoped_dir = $scoped_dir.replace('\', '/') | ||||
|     if(-not(Test-Path $scoped_dir)) { | ||||
|       New-Item -ItemType Directory -Force -Path $scoped_dir > $null 2>&1 | ||||
|       composer require $prefix$release -d $unix_scoped_dir >$null 2>&1 | ||||
|       composer require $prefix$release -d $unix_scoped_dir $composer_args >$null 2>&1 | ||||
|     } | ||||
|     [System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin") | ||||
|     Add-Path $scoped_dir\vendor\bin | ||||
| @ -194,13 +197,16 @@ Function Add-Composertool() { | ||||
|     [string] | ||||
|     $scope | ||||
|   ) | ||||
|   if($tool -match "prestissimo|composer-prefetcher" -and $composer_version.split('.')[0] -ne "1") { | ||||
|     Write-Output "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool" | ||||
|     Add-Log $cross $tool "Skipped" | ||||
|     Return | ||||
|   if($composer_version.split('.')[0] -ne "1") { | ||||
|     $composer_args = "--ignore-platform-req=ext-*" | ||||
|     if($tool -match "prestissimo|composer-prefetcher") { | ||||
|       Write-Output "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool" | ||||
|       Add-Log $cross $tool "Skipped" | ||||
|       Return | ||||
|     } | ||||
|   } | ||||
|   Enable-PhpExtension -Extension mbstring, openssl -Path $php_dir | ||||
|   $log = Add-ComposertoolHelper -tool $tool -release $release -prefix $prefix -scope $scope | ||||
|   Enable-PhpExtension -Extension curl, mbstring, openssl -Path $php_dir | ||||
|   $log = Add-ComposertoolHelper $tool $release $prefix $scope $composer_args | ||||
|   if(Test-Path $composer_bin\composer) { | ||||
|     Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force | ||||
|   } | ||||
|  | ||||
| @ -117,17 +117,18 @@ add_composertool_helper() { | ||||
|   release=$2 | ||||
|   prefix=$3 | ||||
|   scope=$4 | ||||
|   composer_args=$5 | ||||
|   enable_extension mbstring extension >/dev/null 2>&1 | ||||
|   enable_extension openssl extension >/dev/null 2>&1 | ||||
|   if [ "$scope" = "global" ]; then | ||||
|     sudo rm -f "$composer_lock" >/dev/null 2>&1 || true | ||||
|     composer global require "$prefix$release" >/dev/null 2>&1 | ||||
|     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.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" | ||||
|       composer require "$prefix$release" -d "$scoped_dir" >/dev/null 2>&1 | ||||
|       composer require "$prefix$release" -d "$scoped_dir" "$composer_args" >/dev/null 2>&1 | ||||
|       composer show "$prefix$tool" -d "$scoped_dir" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1 | ||||
|     fi | ||||
|     add_path "$scoped_dir"/vendor/bin | ||||
| @ -140,15 +141,16 @@ add_composertool() { | ||||
|   release=$2 | ||||
|   prefix=$3 | ||||
|   scope=$4 | ||||
|   if [[ "$tool" =~ prestissimo|composer-prefetcher ]]; then | ||||
|     composer_version=$(cat /tmp/composer_version) | ||||
|     if [ "$(echo "$composer_version" | cut -d'.' -f 1)" != "1" ]; then | ||||
|   composer_major_version=$(cat /tmp/composer_version | cut -d'.' -f 1) | ||||
|   if [ "$composer_major_version" != "1" ]; then | ||||
|     composer_args="--ignore-platform-req=ext-*" | ||||
|     if [[ "$tool" =~ prestissimo|composer-prefetcher ]]; then | ||||
|       echo "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool" | ||||
|       add_log "$cross" "$tool" "Skipped" | ||||
|       return | ||||
|     fi | ||||
|   fi | ||||
|   add_composertool_helper "$tool" "$release" "$prefix" "$scope" | ||||
|   add_composertool_helper "$tool" "$release" "$prefix" "$scope" "$composer_args" | ||||
|   tool_version=$(get_tool_version cat /tmp/composer.log) | ||||
|   ([ -s /tmp/composer.log ] && add_log "$tick" "$tool" "Added $tool $tool_version" | ||||
|   ) || add_log "$cross" "$tool" "Could not setup $tool" | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shivam Mathur
					Shivam Mathur