mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-10-16 00:05:10 +07:00
Improve symfony-cli support
Fingers crossed symfony-cli keeps the artifact format in their releases
This commit is contained in:
@ -1,18 +1,32 @@
|
||||
Function Add-Symfony() {
|
||||
$arch_name ='amd64'
|
||||
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
||||
$arch_name = '386'
|
||||
}
|
||||
$url = "https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_windows_${arch_name}.zip"
|
||||
Get-File -Url $url -OutFile $bin_dir\symfony.zip >$null 2>&1
|
||||
Expand-Archive -Path $bin_dir\symfony.zip -DestinationPath $bin_dir -Force >$null 2>&1
|
||||
if(Test-Path $bin_dir\symfony.exe) {
|
||||
Copy-Item -Path $bin_dir\symfony.exe -Destination $bin_dir\symfony-cli.exe > $null 2>&1
|
||||
Add-ToProfile $current_profile 'symfony' "New-Alias symfony $bin_dir\symfony.exe"
|
||||
Add-ToProfile $current_profile 'symfony_cli' "New-Alias symfony-cli $bin_dir\symfony-cli.exe"
|
||||
$tool_version = Get-ToolVersion symfony "-V"
|
||||
Add-Log $tick "symfony-cli" "Added symfony-cli $tool_version"
|
||||
param(
|
||||
[Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Symfony version to be installed')]
|
||||
[string] $protobuf_tag
|
||||
)
|
||||
$protobuf_tag = $protobuf_tag.replace('v', '')
|
||||
if($protobuf_tag -ne 'latest' -and $protobuf_tag -notmatch '^\d+(\.\d+)*$') {
|
||||
Add-Log $cross "symfony-cli" "Invalid symfony version: $protobuf_tag"
|
||||
} else {
|
||||
Add-Log $cross "symfony-cli" "Could not setup symfony-cli"
|
||||
$arch_name = 'amd64'
|
||||
if (-not ([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
||||
$arch_name = '386'
|
||||
}
|
||||
$symfony_releases = "https://github.com/symfony-cli/symfony-cli/releases"
|
||||
if ($protobuf_tag -eq 'latest') {
|
||||
$url = "$symfony_releases/latest/download/symfony-cli_windows_${arch_name}.zip"
|
||||
} else {
|
||||
$url = "$symfony_releases/download/v$protobuf_tag/symfony-cli_windows_${arch_name}.zip"
|
||||
}
|
||||
Get-File -Url $url -OutFile $bin_dir\symfony.zip > $null 2>&1
|
||||
Expand-Archive -Path $bin_dir\symfony.zip -DestinationPath $bin_dir -Force > $null 2>&1
|
||||
if (Test-Path $bin_dir\symfony.exe) {
|
||||
Copy-Item -Path $bin_dir\symfony.exe -Destination $bin_dir\symfony-cli.exe > $null 2>&1
|
||||
Add-ToProfile $current_profile 'symfony' "New-Alias symfony $bin_dir\symfony.exe"
|
||||
Add-ToProfile $current_profile 'symfony_cli' "New-Alias symfony-cli $bin_dir\symfony-cli.exe"
|
||||
$tool_version = Get-ToolVersion symfony "-V"
|
||||
Add-Log $tick "symfony-cli" "Added symfony-cli $tool_version"
|
||||
} else {
|
||||
Add-Log $cross "symfony-cli" "Could not setup symfony-cli"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,44 @@
|
||||
add_symfony_with_brew() {
|
||||
add_brew_tap symfony-cli/homebrew-tap
|
||||
brew install symfony-cli/tap/symfony-cli
|
||||
}
|
||||
|
||||
get_symfony_artifact_url() {
|
||||
arch=$(dpkg --print-architecture)
|
||||
url=$(get -s -n "" https://raw.githubusercontent.com/symfony-cli/homebrew-tap/main/Formula/symfony-cli.rb 2<&1 | grep -m 1 "url.*linux.*${arch}" | cut -d\" -f 2)
|
||||
if [ -z "$url" ]; then
|
||||
url="https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_linux_${arch}.tar.gz"
|
||||
fi
|
||||
echo "$url"
|
||||
local symfony_tag=$1
|
||||
local os
|
||||
local arch
|
||||
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
||||
arch="$(uname -m)"
|
||||
case "$arch" in
|
||||
arm|armv6*|armv7*) arch="armv6" ;;
|
||||
aarch64*|armv8*|arm64) arch="arm64" ;;
|
||||
i[36]86) arch="386" ;;
|
||||
x86_64|amd64) arch="amd64" ;;
|
||||
esac
|
||||
[ "$os" = "darwin" ] && arch="all"
|
||||
symfony_releases="https://github.com/symfony-cli/symfony-cli/releases"
|
||||
if [ "$symfony_tag" = "latest" ]; then
|
||||
echo "$symfony_releases/latest/download/symfony-cli_${os}_${arch}.tar.gz"
|
||||
else
|
||||
echo "$symfony_releases/download/v$symfony_tag/symfony-cli_${os}_${arch}.tar.gz"
|
||||
fi
|
||||
}
|
||||
|
||||
add_symfony_helper() {
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
url="$(get_symfony_artifact_url)"
|
||||
if [ -z "$url" ]; then
|
||||
. "${0%/*}"/tools/brew.sh
|
||||
configure_brew
|
||||
add_symfony_with_brew
|
||||
else
|
||||
get -s -n "" "$url" | sudo tar -xz -C "${tool_path_dir:?}" 2>/dev/null
|
||||
sudo chmod a+x /usr/local/bin/symfony
|
||||
fi
|
||||
elif [ "$(uname -s)" = "Darwin" ]; then
|
||||
add_symfony_with_brew
|
||||
fi
|
||||
local install_dir=/usr/local/bin
|
||||
[ "$(uname -s)" = "Darwin" ] && install_dir=${brew_prefix:?}/bin
|
||||
get -s -n "" "$(get_symfony_artifact_url "$symfony_tag")" | sudo tar -xz -C "$install_dir" 2>/dev/null
|
||||
sudo chmod a+x "$install_dir"/symfony
|
||||
}
|
||||
|
||||
add_symfony() {
|
||||
add_symfony_helper >/dev/null 2>&1
|
||||
symfony_path="$(command -v symfony)"
|
||||
if [[ -n "$symfony_path" ]]; then
|
||||
sudo ln -s "$symfony_path" "${tool_path_dir:?}"/symfony-cli
|
||||
tool_version=$(get_tool_version "symfony" "-V")
|
||||
add_log "${tick:?}" "symfony-cli" "Added symfony-cli $tool_version"
|
||||
local symfony_tag="${1/v/}"
|
||||
if ! [[ "$symfony_tag" =~ ^[0-9]+(\.[0-9]+)*$ || "$symfony_tag" == 'latest' ]]; then
|
||||
add_log "${cross:?}" "symfony-cli" "Version '$symfony_tag' is not valid for symfony-cli"
|
||||
else
|
||||
add_log "${cross:?}" "symfony-cli" "Could not setup symfony-cli"
|
||||
add_symfony_helper "$symfony_tag" >/dev/null 2>&1
|
||||
symfony_path="$(command -v symfony)"
|
||||
if [[ -n "$symfony_path" ]]; then
|
||||
sudo ln -s "$symfony_path" "${tool_path_dir:?}"/symfony-cli
|
||||
tool_version=$(get_tool_version "symfony" "-V")
|
||||
add_log "${tick:?}" "symfony-cli" "Added symfony-cli $tool_version"
|
||||
else
|
||||
add_log "${cross:?}" "symfony-cli" "Could not setup symfony-cli"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
Reference in New Issue
Block a user