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