[macOS] Refactor Common.Helpers (#8924)

* [macOS] Refactor Common.Helpers

* Update readme file

* Remove unnecessary double quotes

---------

Co-authored-by: Alexey Ayupov <“alexey.ayupov@akvelon.com”>
This commit is contained in:
Alexey-Ayupov
2023-12-04 12:13:08 +01:00
committed by GitHub
parent ff1dc02cbc
commit 69db5c6c63
46 changed files with 292 additions and 359 deletions

View File

@@ -2,9 +2,10 @@ Import-Module "$PSScriptRoot/SoftwareReport.Helpers.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
function Split-TableRowByColumns {
param(
param (
[string] $Row
)
return $Row.Split("|") | ForEach-Object { $_.trim() }
}
@@ -46,6 +47,7 @@ function Get-AndroidPackages {
function Build-AndroidTable {
Write-Host "Build-AndroidTable"
$packageInfo = Get-AndroidInstalledPackages
return @(
@{
"Package" = "Android Command Line Tools"
@@ -62,7 +64,7 @@ function Build-AndroidTable {
@{
"Package" = "Android SDK Platforms"
"Version" = Get-AndroidPlatformVersions -PackageInfo $packageInfo
},
},
@{
"Package" = "Android SDK Platform-Tools"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Platform-Tools"
@@ -111,6 +113,7 @@ function Build-AndroidEnvironmentTable {
$androidVersions = Get-Item env:ANDROID_*
$shoulddResolveLink = 'ANDROID_NDK', 'ANDROID_NDK_HOME', 'ANDROID_NDK_ROOT', 'ANDROID_NDK_LATEST_HOME'
return $androidVersions | Sort-Object -Property Name | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
@@ -191,7 +194,7 @@ function Get-AndroidGoogleAPIsVersions {
function Get-AndroidNDKVersions {
$ndkFolderPath = Join-Path (Get-AndroidSDKRoot) "ndk"
$versions += Get-ChildItem -Path $ndkFolderPath -Name
$ndkDefaultVersion = Get-ToolsetValue "android.ndk.default"
$ndkDefaultVersion = (Get-ToolsetContent).android.ndk.default
$ndkDefaultFullVersion = Get-ChildItem "$env:ANDROID_HOME/ndk/$ndkDefaultVersion.*" -Name | Select-Object -Last 1
return ($versions | ForEach-Object {

View File

@@ -10,7 +10,7 @@ function Build-BrowserSection {
[ToolVersionNode]::new("Google Chrome for Testing", $(Get-ChromeForTestingVersion))
[ToolVersionNode]::new("ChromeDriver", $(Get-ChromeDriverVersion))
)
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$nodes += @(
[ToolVersionNode]::new("Microsoft Edge", $(Get-EdgeVersion))
@@ -19,7 +19,7 @@ function Build-BrowserSection {
[ToolVersionNode]::new("geckodriver", $(Get-GeckodriverVersion))
)
}
$nodes += @(
[ToolVersionNode]::new("Selenium server", $(Get-SeleniumVersion))
)

View File

@@ -1,7 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
function Get-BashVersion {
$version = bash -c 'echo ${BASH_VERSION}'
return $version
@@ -83,7 +81,7 @@ function Get-VcpkgVersion {
}
function Get-GccVersions {
$versionList = Get-ToolsetValue -KeyPath gcc.versions
$versionList = (Get-ToolsetContent).gcc.versions
$versionList | Foreach-Object {
$nameVersion = Run-Command "gcc-${_} --version" | Select-Object -First 1
$version = ($nameVersion -replace "^gcc-${_}").Trim() -replace '\).*$', ')'
@@ -92,7 +90,7 @@ function Get-GccVersions {
}
function Get-FortranVersions {
$versionList = Get-ToolsetValue -KeyPath gcc.versions
$versionList = (Get-ToolsetContent).gcc.versions
$versionList | Foreach-Object {
$nameVersion = Run-Command "gfortran-${_} --version" | Select-Object -First 1
$version = ($nameVersion -replace "^GNU Fortran").Trim() -replace '\).*$', ')'
@@ -106,7 +104,7 @@ function Get-ClangLLVMVersions {
$defaultClangOutput = Run-Command "clang --version" | Out-String
$defaultClangVersion = $clangVersionRegex.Match($defaultClangOutput).Groups['version'].Value
$homebrewClangPath = '$(brew --prefix llvm@{0})/bin/clang' -f (Get-ToolsetValue 'llvm.version')
$homebrewClangPath = '$(brew --prefix llvm@{0})/bin/clang' -f ((Get-ToolsetContent).llvm.version)
$homebrewClangOutput = Run-Command "$homebrewClangPath --version" | Out-String
$homebrewClangVersion = $clangVersionRegex.Match($homebrewClangOutput).Groups['version'].Value

View File

@@ -47,7 +47,7 @@ function Get-BrewPackageVersion {
[string] $CommandName
)
(Get-LinkTarget (Get-Command $CommandName).Source | Out-String) -match "(?<version>(\d+.){2}\d+)" | Out-Null
(Get-LinkTarget (Get-Command $CommandName).Source | Out-String) -match "(?<version>(\d+.){2}\d+)" | Out-Null
$packageVersion = $Matches.Version
return $packageVersion

View File

@@ -1,14 +1,15 @@
function Get-JavaVersions {
$defaultJavaPath = (Get-Item env:JAVA_HOME).value
$os = Get-OSVersion
if ($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
$javaVersions = Get-Item env:JAVA_HOME_*_arm64
} else {
$javaVersions = Get-Item env:JAVA_HOME_*_X64
}
$sortRules = @{
Expression = { [Int32]$_.Name.Split("_")[2] }
Expression = { [Int32]$_.Name.Split("_")[2] }
Descending = $false
}

View File

@@ -54,7 +54,7 @@ function Build-ToolcacheSection {
}
function Get-PowerShellModules {
$modules = (Get-ToolsetValue powershellModules).name
$modules = ((Get-ToolsetContent).powershellModules).name
$modules | ForEach-Object {
$moduleName = $_
$moduleVersions = Get-Module -Name $moduleName -ListAvailable | Select-Object -ExpandProperty Version | Sort-Object -Unique

View File

@@ -1,8 +1,8 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
function Build-VSMacTable {
$vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions"
$defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default"
$vsMacVersions = (Get-ToolsetContent).xamarin.vsmac.versions
$defaultVSMacVersion = (Get-ToolsetContent).xamarin.vsmac.default
return $vsMacVersions | ForEach-Object {
$isDefault = $_ -eq $defaultVSMacVersion
@@ -29,8 +29,8 @@ function Get-NUnitVersion {
}
function Build-XamarinTable {
$xamarinBundles = Get-ToolsetValue "xamarin.bundles"
$defaultSymlink = Get-ToolsetValue "xamarin.bundle-default"
$xamarinBundles = (Get-ToolsetContent).xamarin.bundles
$defaultSymlink = (Get-ToolsetContent).xamarin.bundle_default
if ($defaultSymlink -eq "latest") {
$defaultSymlink = $xamarinBundles[0].symlink
}
@@ -38,7 +38,7 @@ function Build-XamarinTable {
return $xamarinBundles | ForEach-Object {
$defaultPostfix = ($_.symlink -eq $defaultSymlink ) ? " (default)" : ""
[PSCustomObject] @{
"symlink" = $_.symlink + $defaultPostfix
"symlink" = $_.symlink + $defaultPostfix
"Xamarin.Mono" = $_.mono
"Xamarin.iOS" = $_.ios
"Xamarin.Mac" = $_.mac

View File

@@ -4,7 +4,7 @@ Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
$os = Get-OSVersion
function Get-XcodePaths {
$xcodePaths = Get-ChildItemWithoutSymlinks "/Applications" -Filter "Xcode_*.app"
$xcodePaths = Get-ChildItem -Path "/Applications" -Filter "Xcode_*.app" | Where-Object { !$_.LinkType }
return $xcodePaths | Select-Object -ExpandProperty Fullname
}