2022-12-08 19:14:16 +01:00
Import-Module " $PSScriptRoot /../helpers/Common.Helpers.psm1"
2020-12-14 09:29:07 +03:00
function Get-BashVersion {
$version = bash -c 'echo ${BASH_VERSION}'
2022-12-06 18:16:20 +01:00
return $version
2020-12-14 09:29:07 +03:00
}
2020-09-10 14:34:08 +03:00
function Get-DotnetVersionList {
$sdkRawList = Run-Command "dotnet --list-sdks"
2022-12-13 16:54:41 +01:00
return $sdkRawList | ForEach-Object { Take-Part $_ -Part 0 }
2020-09-10 14:34:08 +03:00
}
function Get-RustVersion {
$rustVersion = Run-Command "rustc --version" | Take-Part -Part 1
2022-12-06 18:16:20 +01:00
return $rustVersion
2020-09-10 14:34:08 +03:00
}
2021-01-11 12:57:51 +05:00
function Get-RustfmtVersion {
$version = Run-Command "rustfmt --version" | Take-Part -Part 1
2022-12-06 18:16:20 +01:00
return $version
2021-01-11 12:57:51 +05:00
}
function Get-RustdocVersion {
$version = Run-Command "rustdoc --version" | Take-Part -Part 1
2022-12-06 18:16:20 +01:00
return $version
2021-01-11 12:57:51 +05:00
}
function Get-RustCargoVersion {
$version = Run-Command "cargo --version" | Take-Part -Part 1
2022-12-06 18:16:20 +01:00
return $version
2021-01-11 12:57:51 +05:00
}
function Get-RustClippyVersion {
$version = Run-Command "cargo clippy --version" | Take-Part -Part 1
2022-12-06 18:16:20 +01:00
return $version
2021-01-11 12:57:51 +05:00
}
2020-09-10 14:34:08 +03:00
function Get-RustupVersion {
2020-12-03 19:50:09 +03:00
$rustupVersion = Run-Command "rustup --version" | Select-Object -First 1 | Take-Part -Part 1
2022-12-06 18:16:20 +01:00
return $rustupVersion
2020-09-10 14:34:08 +03:00
}
function Get-VcpkgVersion {
$vcpkgVersion = Run-Command "vcpkg version" | Select-Object -First 1 | Take-Part -Part 5 | Take-Part -Part 0 -Delimiter "-"
2020-12-04 10:21:32 +03:00
$commitId = git -C "/usr/local/share/vcpkg" rev-parse - -short HEAD
2022-12-08 19:14:16 +01:00
return " $vcpkgVersion (build from commit $commitId )"
2020-09-10 14:34:08 +03:00
}
2022-12-06 18:16:20 +01:00
function Get-GccVersions {
2023-12-04 12:13:08 +01:00
$versionList = ( Get-ToolsetContent ). gcc . versions
2020-09-10 14:34:08 +03:00
$versionList | Foreach-Object {
2022-12-06 18:16:20 +01:00
$nameVersion = Run-Command "gcc- ${_} --version" | Select-Object -First 1
$version = ( $nameVersion -replace "^gcc- ${_} " ). Trim () -replace '\).*$' , ')'
2022-12-14 10:24:47 +01:00
return [ ToolVersionNode ]:: new ( "GCC ${_} " , " $version - available by `` gcc- ${_} `` alias" )
2020-09-10 14:34:08 +03:00
}
}
2022-12-06 18:16:20 +01:00
function Get-FortranVersions {
2023-12-04 12:13:08 +01:00
$versionList = ( Get-ToolsetContent ). gcc . versions
2020-09-10 14:34:08 +03:00
$versionList | Foreach-Object {
2022-12-06 18:16:20 +01:00
$nameVersion = Run-Command "gfortran- ${_} --version" | Select-Object -First 1
$version = ( $nameVersion -replace "^GNU Fortran" ). Trim () -replace '\).*$' , ')'
2022-12-14 10:24:47 +01:00
return [ ToolVersionNode ]:: new ( "GNU Fortran ${_} " , " $version - available by `` gfortran- ${_} `` alias" )
2020-09-10 14:34:08 +03:00
}
}
2022-12-06 18:16:20 +01:00
function Get-ClangLLVMVersions {
$clangVersionRegex = [ Regex ]:: new ( "(?<version>\d+\.\d+\.\d+)" )
$defaultClangOutput = Run-Command "clang --version" | Out-String
$defaultClangVersion = $clangVersionRegex . Match ( $defaultClangOutput ). Groups [ 'version' ]. Value
2023-12-04 12:13:08 +01:00
$homebrewClangPath = '$(brew --prefix llvm@{0})/bin/clang' -f (( Get-ToolsetContent ). llvm . version )
2022-12-06 18:16:20 +01:00
$homebrewClangOutput = Run-Command " $homebrewClangPath --version" | Out-String
$homebrewClangVersion = $clangVersionRegex . Match ( $homebrewClangOutput ). Groups [ 'version' ]. Value
return @ (
2022-12-14 10:24:47 +01:00
[ ToolVersionNode ]:: new ( "Clang/LLVM" , $defaultClangVersion )
[ ToolVersionNode ]:: new ( "Clang/LLVM (Homebrew)" , " $homebrewClangVersion - available on `` $homebrewClangPath `` " )
2022-12-06 18:16:20 +01:00
)
2020-09-10 14:34:08 +03:00
}
2025-01-27 14:09:51 +01:00
function Get-Pip3Version {
$command = "pip3 --version"
2020-09-10 14:34:08 +03:00
$commandOutput = Run-Command $command
$versionPart1 = $commandOutput | Take-Part -Part 1
$versionPart2 = $commandOutput | Take-Part -Part 4
$versionPart3 = $commandOutput | Take-Part -Part 5
2022-12-06 18:16:20 +01:00
return " ${versionPart1} ${versionPart2} ${versionPart3} "
2020-09-10 14:34:08 +03:00
}
2020-10-07 09:29:37 +03:00
function Get-PipxVersion {
2020-10-12 11:10:02 +03:00
$pipxVersion = Run-Command "pipx --version" -SuppressStderr
2022-12-06 18:16:20 +01:00
return $pipxVersion
2020-10-07 09:29:37 +03:00
}
2020-09-10 14:34:08 +03:00
function Build-OSInfoSection {
2022-12-06 18:16:20 +01:00
param (
[ string ] $ImageName
)
2020-09-10 14:34:08 +03:00
$fieldsToInclude = @ ( "System Version:" , "Kernel Version:" )
2024-01-04 10:46:00 +01:00
$rawSystemInfo = Run-Command "system_profiler SPSoftwareDataType"
2020-09-10 14:34:08 +03:00
$parsedSystemInfo = $rawSystemInfo | Where-Object { -not ( $_ | Select-String -NotMatch $fieldsToInclude ) } | ForEach-Object { $_ . Trim () }
2023-02-13 16:40:48 +01:00
$parsedSystemInfo [ 0 ] -match "System Version: macOS (?<version>\d+)" | Out-Null
2020-09-10 14:34:08 +03:00
$version = $Matches . Version
2022-12-06 18:16:20 +01:00
$systemVersion = $parsedSystemInfo [ 0 ]. Replace ( $fieldsToInclude [ 0 ], "" ). Trim ()
$kernelVersion = $parsedSystemInfo [ 1 ]. Replace ( $fieldsToInclude [ 1 ], "" ). Trim ()
2022-12-08 19:14:16 +01:00
$osInfoNode = [ HeaderNode ]:: new ( "macOS $version " )
2022-12-14 10:24:47 +01:00
$osInfoNode . AddToolVersion ( "OS Version:" , $systemVersion )
$osInfoNode . AddToolVersion ( "Kernel Version:" , $kernelVersion )
$osInfoNode . AddToolVersion ( "Image Version:" , $ImageName . Split ( '_' )[ 1 ])
2022-12-06 18:16:20 +01:00
return $osInfoNode
2020-12-28 11:15:54 +03:00
}
2022-12-08 19:14:16 +01:00
function Get-MonoVersion {
2024-01-04 10:46:00 +01:00
$monoVersion = Run-Command "mono --version" | Out-String | Take-Part -Part 4
2022-12-08 19:14:16 +01:00
return $monoVersion
}
2020-12-28 11:15:54 +03:00
function Get-NodeVersion {
$nodeVersion = Run-Command "node --version"
2022-12-08 19:14:16 +01:00
return $nodeVersion . TrimStart ( "v" )
2020-12-28 11:15:54 +03:00
}
2021-01-20 10:07:43 +03:00
function Get-PerlVersion {
$version = Run-Command "perl -e 'print substr( `$ ^V,1)'"
2022-12-06 18:16:20 +01:00
return $version
2021-01-20 10:07:43 +03:00
}
2020-12-28 11:15:54 +03:00
function Get-Python3Version {
$python3Version = Run-Command "python3 --version"
2022-12-06 18:16:20 +01:00
return ( $python3Version -replace "^Python" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-RubyVersion {
$rubyVersion = Run-Command "ruby --version" | Take-Part -Part 1
2022-12-06 18:16:20 +01:00
return $rubyVersion
2020-12-28 11:15:54 +03:00
}
function Get-PHPVersion {
$PHPVersion = Run-Command "php --version" | Select-Object -First 1 | Take-Part -Part 0 , 1
2022-12-06 18:16:20 +01:00
return ( $PHPVersion -replace "^PHP" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-BundlerVersion {
$bundlerVersion = Run-Command "bundle --version"
2022-12-08 19:14:16 +01:00
return ( $bundlerVersion -replace "^Bundler version" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-CarthageVersion {
$carthageVersion = Run-Command "carthage version" -SuppressStderr
2022-12-06 18:16:20 +01:00
return $carthageVersion
2020-12-28 11:15:54 +03:00
}
function Get-CocoaPodsVersion {
$cocoaPodsVersion = Run-Command "pod --version"
2022-12-06 18:16:20 +01:00
return $cocoaPodsVersion
2020-12-28 11:15:54 +03:00
}
function Get-HomebrewVersion {
$homebrewVersion = Run-Command "brew --version" | Select-Object -First 1
2022-12-06 18:16:20 +01:00
return ( $homebrewVersion -replace "^Homebrew" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-NPMVersion {
$NPMVersion = Run-Command "npm --version"
2022-12-06 18:16:20 +01:00
return $NPMVersion
2020-12-28 11:15:54 +03:00
}
function Get-YarnVersion {
$yarmVersion = Run-Command "yarn --version"
2022-12-06 18:16:20 +01:00
return $yarmVersion
2020-12-28 11:15:54 +03:00
}
function Get-NuGetVersion {
$nugetVersion = Run-Command "nuget help" | Select-Object -First 1 | Take-Part -Part 2
2022-12-06 18:16:20 +01:00
return $nugetVersion
2020-12-28 11:15:54 +03:00
}
function Get-RubyGemsVersion {
$rubyGemsVersion = Run-Command "gem --version"
2022-12-06 18:16:20 +01:00
return $rubyGemsVersion
2020-12-28 11:15:54 +03:00
}
function Get-ComposerVersion {
2024-03-28 17:26:46 +01:00
$composerVersion = Run-Command "composer --version" | Select-Object -First 1 | Take-Part -Part 2
2022-12-06 18:16:20 +01:00
return $composerVersion
2020-12-28 11:15:54 +03:00
}
function Get-MavenVersion {
$mavenVersion = Run-Command "mvn -version" | Select-Object -First 1 | Take-Part -Part 2
2022-12-06 18:16:20 +01:00
return $mavenVersion
2020-12-28 11:15:54 +03:00
}
#gradle output differs on the first launch – a welcome message, that we don't need is rendered. The solution is to take the last "Gradle" occurrence from the output
function Get-GradleVersion {
$gradleVersion = ( Run-Command "gradle --version" | Select-String "Gradle" )[ -1 ]
2022-12-06 18:16:20 +01:00
return ( $gradleVersion . Line -replace "^Gradle" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-ApacheAntVersion {
$apacheAntVersion = Run-Command "ant -version" | Take-Part -Part 0 , 1 , 3
2022-12-06 18:16:20 +01:00
return ( $apacheAntVersion -replace "^Apache Ant\(TM\)" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-CurlVersion {
$curlVersion = Run-Command "curl --version" | Select-Object -First 1 | Take-Part -Part 1
2022-12-06 18:16:20 +01:00
return $curlVersion
2020-12-28 11:15:54 +03:00
}
function Get-GitVersion {
2022-02-18 10:23:34 +03:00
$gitVersion = Run-Command "git --version" | Take-Part -Part -1
2022-12-06 18:16:20 +01:00
return $gitVersion
2020-12-28 11:15:54 +03:00
}
function Get-GitLFSVersion {
$gitLFSVersion = Run-Command "git-lfs version" | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/"
2022-12-06 18:16:20 +01:00
return $gitLFSVersion
2020-12-28 11:15:54 +03:00
}
function Get-GitHubCLIVersion {
$ghVersion = Run-Command "gh --version" | Select-String "gh version" | Select-Object -First 1 | Take-Part -Part 2
2022-12-06 18:16:20 +01:00
return $ghVersion
2020-12-28 11:15:54 +03:00
}
function Get-WgetVersion {
$wgetVersion = Run-Command "wget --version" | Select-String "GNU Wget" | Take-Part -Part 2
2022-12-06 18:16:20 +01:00
return $wgetVersion
2020-12-28 11:15:54 +03:00
}
function Get-PackerVersion {
2025-08-11 16:32:51 +02:00
$packerVersion = Run-Command "packer --version" | Select-String "Packer" | Select-Object -First 1 | Take-Part -Part 1
return ( $packerVersion . Trim ( "v" ))
2020-12-28 11:15:54 +03:00
}
function Get-OpenSSLVersion {
2022-12-13 16:54:41 +01:00
$opensslVersion = Run-Command "openssl version"
2022-12-06 18:16:20 +01:00
return ( $opensslVersion -replace "^OpenSSL" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-JqVersion {
$jqVersion = Run-Command "jq --version" | Take-Part -Part 1 -Delimiter "-"
2022-12-06 18:16:20 +01:00
return $jqVersion
2020-12-28 11:15:54 +03:00
}
function Get-GPGVersion {
$gpgVersion = Run-Command "gpg --version" | Select-String 'gpg (GnuPG)' -SimpleMatch
2022-12-06 18:16:20 +01:00
return ( $gpgVersion . Line -replace "^gpg \(GnuPG\)" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-Aria2Version {
$aria2Version = Run-Command "aria2c --version" | Select-Object -First 1 | Take-Part -Part 2
2022-12-06 18:16:20 +01:00
return $aria2Version
2020-12-28 11:15:54 +03:00
}
function Get-AzcopyVersion {
2023-12-11 22:26:33 +01:00
$azcopyVersion = [ string ] $ ( Run-Command "azcopy --version" ) | Take-Part -Part 2
2022-12-06 18:16:20 +01:00
return $azcopyVersion
2020-12-28 11:15:54 +03:00
}
function Get-ZstdVersion {
$zstdVersion = Run-Command "zstd --version" | Take-Part -Part 1 -Delimiter "v" | Take-Part -Part 0 -Delimiter ","
2022-12-06 18:16:20 +01:00
return $zstdVersion
2020-12-28 11:15:54 +03:00
}
function Get-BazelVersion {
$bazelVersion = Run-Command "bazel --version" | Take-Part -Part 0 -Delimiter "-"
2022-12-06 18:16:20 +01:00
return ( $bazelVersion -replace "^bazel" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-BazeliskVersion {
$bazeliskVersion = Run-Command "brew list bazelisk --versions"
2022-12-06 18:16:20 +01:00
return ( $bazeliskVersion -replace "^bazelisk" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-7zipVersion {
$7zip = Run-Command "7z i" | Select-String "7-Zip" | Take-Part -Part 0 , 2
2022-12-06 18:16:20 +01:00
return ( $7zip -replace "^7-Zip" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-GnuTarVersion {
$gnuTar = Run-Command "gtar --version" | Select-String "tar" | Take-Part -Part 3
2022-12-06 18:16:20 +01:00
return " $gnuTar - available by 'gtar' alias"
2020-12-28 11:15:54 +03:00
}
function Get-BsdtarVersion {
$bsdtar = Run-Command "tar --version" | Take-Part -Part 1
2022-12-06 18:16:20 +01:00
return " $bsdtar - available by 'tar' alias"
2020-12-28 11:15:54 +03:00
}
function Get-ParallelVersion {
$parallelVersion = Run-Command "parallel --version" | Select-String "GNU parallel" | Select-Object -First 1
2022-12-06 18:16:20 +01:00
return ( $parallelVersion -replace "^GNU parallel" ). Trim ()
2020-12-28 11:15:54 +03:00
}
function Get-FastlaneVersion {
$fastlaneVersion = Run-Command "fastlane --version" | Select-String "^fastlane [0-9]" | Take-Part -Part 1
2022-12-06 18:16:20 +01:00
return $fastlaneVersion
2020-12-28 11:15:54 +03:00
}
function Get-CmakeVersion {
$cmakeVersion = Run-Command "cmake --version" | Select-Object -First 1 | Take-Part -Part 2
2022-12-06 18:16:20 +01:00
return $cmakeVersion
2020-12-28 11:15:54 +03:00
}
function Get-AzureCLIVersion {
2021-11-02 19:29:24 +03:00
$azureCLIVersion = ( az version | ConvertFrom-Json ). 'azure-cli'
2022-12-06 18:16:20 +01:00
return $azureCLIVersion
2020-12-28 11:15:54 +03:00
}
2022-02-11 12:53:36 +03:00
function Get-AzureDevopsVersion {
$azdevopsVersion = ( az version | ConvertFrom-Json ). extensions . 'azure-devops'
2022-12-06 18:16:20 +01:00
return $azdevopsVersion
2022-02-11 12:53:36 +03:00
}
2020-12-28 11:15:54 +03:00
function Get-AWSCLIVersion {
$awsVersion = Run-Command "aws --version" | Take-Part -Part 0 | Take-Part -Delimiter "/" -Part 1
2022-12-06 18:16:20 +01:00
return $awsVersion
2020-12-28 11:15:54 +03:00
}
function Get-AWSSAMCLIVersion {
$awsSamVersion = Run-Command "sam --version" | Take-Part -Part 3
2022-12-06 18:16:20 +01:00
return $awsSamVersion
2020-12-28 11:15:54 +03:00
}
function Get-AWSSessionManagerCLIVersion {
$awsSessionManagerVersion = Run-Command "session-manager-plugin --version"
2022-12-06 18:16:20 +01:00
return $awsSessionManagerVersion
2020-12-28 11:15:54 +03:00
}
2021-04-14 10:22:41 +03:00
function Get-SwiftFormatVersion {
$swiftFormatVersion = Run-Command "swiftformat --version"
2022-12-06 18:16:20 +01:00
return $swiftFormatVersion
2021-04-14 10:22:41 +03:00
}
2020-12-28 11:15:54 +03:00
function Get-SwiftLintVersion {
$swiftlintVersion = Run-Command "swiftlint version"
2022-12-06 18:16:20 +01:00
return $swiftlintVersion
2020-12-28 11:15:54 +03:00
}
function Get-PowershellVersion {
$powershellVersion = Run-Command "powershell --version"
2022-12-06 18:16:20 +01:00
return ( $powershellVersion -replace "^PowerShell" ). Trim ()
2021-02-08 11:45:16 +05:00
}
2021-07-07 09:10:31 -05:00
function Get-BicepVersion {
$bicepVersion = Run-Command "bicep --version" | Take-Part -Part 3
2022-12-06 18:16:20 +01:00
return $bicepVersion
2021-07-07 09:10:31 -05:00
}
2021-07-29 17:21:09 +03:00
function Get-KotlinVersion {
$kotlinVersion = Run-Command "kotlin -version" | Take-Part -Part 2
2022-12-06 18:16:20 +01:00
return $kotlinVersion
2021-07-29 17:21:09 +03:00
}
2022-02-07 11:12:13 +03:00
function Get-TclTkVersion {
2024-11-15 03:45:48 -08:00
$tcltkVersion = ( Run-Command "brew info --json tcl-tk@8" | ConvertFrom-Json ). installed . version
2022-12-06 18:16:20 +01:00
return $tcltkVersion
2022-02-07 11:12:13 +03:00
}
2022-03-23 11:20:36 +01:00
function Get-YqVersion {
$yqVersion = Run-Command "yq --version"
2022-12-06 18:16:20 +01:00
$yqVersion -match "\d{1,2}\.\d{1,2}\.\d{1,2}" | Out-Null
return ( $Matches [ 0 ])
2022-03-23 11:20:36 +01:00
}
2022-09-28 19:06:08 +02:00
function Build-MiscellaneousEnvironmentTable {
return @ (
@ {
"Name" = "PARALLELS_DMG_URL"
"Value" = $env:PARALLELS_DMG_URL
}
) | ForEach-Object {
[ PSCustomObject ] @ {
"Name" = $_ . Name
"Value" = $_ . Value
}
}
}
2023-10-17 21:18:48 +01:00
function Get-CodeQLBundleVersion {
$CodeQLVersionWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionWildcard | Select-Object -First 1 -Expand FullName
$CodeQLPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "codeql"
$CodeQLVersion = & $CodeQLPath version - -quiet
return $CodeQLVersion
2022-09-27 09:54:35 +02:00
}
2024-11-22 06:23:29 -08:00
function Get-PKGConfVersion {
$pkgconfVersion = Run-Command "pkgconf --version"
return $pkgconfVersion
2023-09-26 09:32:02 +02:00
}
2023-11-20 14:47:33 +01:00
function Get-XcbeautifyVersion {
$XcbeautifyVersion = Run-Command "xcbeautify --version"
return $XcbeautifyVersion
}
function Get-XcodesVersion {
$XcodesVersion = Run-Command "xcodes version"
return $XcodesVersion
}
2024-11-05 08:41:59 -06:00
function Get-UnxipVersion {
$unxipVersion = Run-Command "unxip --version" | Take-Part -Part 1
return $unxipVersion
}
2025-03-04 15:56:00 +01:00
function Get-NinjaVersion {
return $ ( ninja - -version )
}