mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Fix versions of composer tools
This commit is contained in:
parent
9ad81048ce
commit
6ebd1e5184
@ -206,7 +206,8 @@ add_unstable_extension() {
|
|||||||
get_tool_version() {
|
get_tool_version() {
|
||||||
tool=$1
|
tool=$1
|
||||||
param=$2
|
param=$2
|
||||||
version_regex="[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-zA-Z0-9]+){0,1}"
|
alp="[a-zA-Z0-9]"
|
||||||
|
version_regex="[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}"
|
||||||
if [ "$tool" = "composer" ]; then
|
if [ "$tool" = "composer" ]; then
|
||||||
if [ "$param" != "snapshot" ]; then
|
if [ "$param" != "snapshot" ]; then
|
||||||
composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
|
composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
|
||||||
@ -283,9 +284,9 @@ add_composertool() {
|
|||||||
fi
|
fi
|
||||||
(
|
(
|
||||||
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" 2>&1 | tee /tmp/composer.log >/dev/null 2>&1
|
||||||
json=$(grep "$prefix$tool" "$composer_json") &&
|
log=$(grep "$prefix$tool" /tmp/composer.log) &&
|
||||||
tool_version=$(get_tool_version 'echo' "$json") &&
|
tool_version=$(get_tool_version 'echo' "$log") &&
|
||||||
add_log "$tick" "$tool" "Added $tool $tool_version"
|
add_log "$tick" "$tool" "Added $tool $tool_version"
|
||||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
add_tools_helper "$tool"
|
add_tools_helper "$tool"
|
||||||
|
@ -225,7 +225,8 @@ Function Get-ToolVersion() {
|
|||||||
[Parameter(Position = 1, Mandatory = $true)]
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
$param
|
$param
|
||||||
)
|
)
|
||||||
$version_regex = "[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-z0-9]+){0,1}"
|
$alp = "[a-zA-Z0-9]"
|
||||||
|
$version_regex = "[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}"
|
||||||
if($tool -eq 'composer') {
|
if($tool -eq 'composer') {
|
||||||
if ($param -eq 'snapshot') {
|
if ($param -eq 'snapshot') {
|
||||||
$composer_version = (Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }) + '+' + (Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value })
|
$composer_version = (Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }) + '+' + (Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value })
|
||||||
@ -314,14 +315,15 @@ Function Add-Composertool() {
|
|||||||
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 2>&1 | Tee-Object -FilePath $env:APPDATA\Composer\composer.log) >$null 2>&1
|
||||||
$json = findstr $prefix$tool $env:APPDATA\Composer\composer.json
|
$json = findstr $prefix$tool $env:APPDATA\Composer\composer.json
|
||||||
|
$log = findstr $prefix$tool $env:APPDATA\Composer\composer.log
|
||||||
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
|
||||||
}
|
}
|
||||||
Add-ToolsHelper $tool
|
Add-ToolsHelper $tool
|
||||||
if($json) {
|
if($json) {
|
||||||
$tool_version = Get-ToolVersion "Write-Output" "$json"
|
$tool_version = Get-ToolVersion "Write-Output" "$log"
|
||||||
Add-Log $tick $tool "Added $tool $tool_version"
|
Add-Log $tick $tool "Added $tool $tool_version"
|
||||||
} else {
|
} else {
|
||||||
Add-Log $cross $tool "Could not setup $tool"
|
Add-Log $cross $tool "Could not setup $tool"
|
||||||
|
Loading…
Reference in New Issue
Block a user