[macOS] Implement new directories hierarchy (#8741)

This commit is contained in:
Shamil Mubarakshin
2023-11-15 12:12:28 +01:00
committed by GitHub
parent 5d40b1e213
commit 8d6a01b370
133 changed files with 1713 additions and 1677 deletions

View File

@@ -0,0 +1,201 @@
Import-Module "$PSScriptRoot/../helpers/SoftwareReport.Helpers.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
function Split-TableRowByColumns {
param(
[string] $Row
)
return $Row.Split("|") | ForEach-Object { $_.trim() }
}
function Get-AndroidSDKRoot {
return Join-Path $env:HOME "Library" "Android" "sdk"
}
function Get-AndroidSDKManagerPath {
$androidSDKDir = Get-AndroidSDKRoot
return Join-Path $androidSDKDir "cmdline-tools" "latest" "bin" "sdkmanager"
}
function Get-AndroidInstalledPackages {
$androidSDKManagerPath = Get-AndroidSDKManagerPath
$androidSDKManagerList = Invoke-Expression "$androidSDKManagerPath --list_installed"
return $androidSDKManagerList
}
function Get-AndroidPackages {
$androidSDKDir = Get-AndroidSDKRoot
$androidSDKManagerPath = Get-AndroidSDKManagerPath
$packagesListFile = Join-Path $androidSDKDir "packages-list.txt"
if (-Not (Test-Path -Path $packagesListFile -PathType Leaf)) {
(& $androidSDKManagerPath --list --verbose) |
Where-Object { $_ -Match "^[^\s]" } |
Where-Object { $_ -NotMatch "^(Loading |Info: Parsing |---|\[=+|Installed |Available )" } |
Where-Object { $_ -NotMatch "^[^;]*$" } |
Out-File -FilePath $packagesListFile
Write-Host Android packages list:
Get-Content $packagesListFile
}
return Get-Content $packagesListFile
}
function Build-AndroidTable {
Write-Host "Build-AndroidTable"
$packageInfo = Get-AndroidInstalledPackages
return @(
@{
"Package" = "Android Command Line Tools"
"Version" = Get-AndroidCommandLineToolsVersion
},
@{
"Package" = "Android Emulator"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android Emulator"
},
@{
"Package" = "Android SDK Build-tools"
"Version" = Get-AndroidBuildToolVersions -PackageInfo $packageInfo
},
@{
"Package" = "Android SDK Platforms"
"Version" = Get-AndroidPlatformVersions -PackageInfo $packageInfo
},
@{
"Package" = "Android SDK Platform-Tools"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Platform-Tools"
},
@{
"Package" = "Android SDK Tools"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Tools"
},
@{
"Package" = "Android Support Repository"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android Support Repository"
},
@{
"Package" = "CMake"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "cmake"
},
@{
"Package" = "Google APIs"
"Version" = Get-AndroidGoogleAPIsVersions -PackageInfo $packageInfo
},
@{
"Package" = "Google Play services"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Google Play services"
},
@{
"Package" = "Google Repository"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Google Repository"
},
@{
"Package" = "NDK"
"Version" = Get-AndroidNDKVersions
},
@{
"Package" = "SDK Patch Applier v4"
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "SDK Patch Applier v4"
}
) | Where-Object { $_.Version } | ForEach-Object {
[PSCustomObject] @{
"Package Name" = $_.Package
"Version" = $_.Version
}
}
}
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
"Value" = if ($shoulddResolveLink.Contains($_.Name )) { Get-PathWithLink($_.Value) } else { $_.Value }
}
}
}
function Get-AndroidPackageVersions {
param (
[Parameter(Mandatory)]
[object] $PackageInfo,
[Parameter(Mandatory)]
[object] $MatchedString
)
$versions = $packageInfo | Where-Object { $_ -Match $MatchedString } | ForEach-Object {
$packageInfoParts = Split-TableRowByColumns $_
return $packageInfoParts[1]
}
return ($versions -Join "<br>")
}
function Get-AndroidPlatformVersions {
param (
[Parameter(Mandatory)]
[object] $PackageInfo
)
$versions = $packageInfo | Where-Object { $_ -Match "Android SDK Platform " } | ForEach-Object {
$packageInfoParts = Split-TableRowByColumns $_
$revision = $packageInfoParts[1]
$version = $packageInfoParts[0].split(";")[1]
return "$version (rev $revision)"
}
[array]::Reverse($versions)
return ($versions -Join "<br>")
}
function Get-AndroidCommandLineToolsVersion {
$commandLineTools = Get-AndroidSDKManagerPath
(& $commandLineTools --version | Out-String).Trim() -match "(?<version>^(\d+\.){1,}\d+$)" | Out-Null
$commandLineToolsVersion = $Matches.Version
return $commandLineToolsVersion
}
function Get-AndroidBuildToolVersions {
param (
[Parameter(Mandatory)]
[object] $PackageInfo
)
$versions = $packageInfo | Where-Object { $_ -Match "Android SDK Build-Tools" } | ForEach-Object {
$packageInfoParts = Split-TableRowByColumns $_
return $packageInfoParts[1]
}
$groupVersions = @()
$versions | ForEach-Object {
$majorVersion = $_.Split(".")[0]
$groupVersions += $versions | Where-Object { $_.StartsWith($majorVersion) } | Join-String -Separator " "
}
return ($groupVersions | Sort-Object -Descending -Unique | Join-String -Separator "<br>")
}
function Get-AndroidGoogleAPIsVersions {
param (
[Parameter(Mandatory)]
[object] $PackageInfo
)
$versions = $packageInfo | Where-Object { $_ -Match "Google APIs" } | ForEach-Object {
$packageInfoParts = Split-TableRowByColumns $_
return $packageInfoParts[0].split(";")[1]
}
return ($versions -Join "<br>")
}
function Get-AndroidNDKVersions {
$ndkFolderPath = Join-Path (Get-AndroidSDKRoot) "ndk"
$versions += Get-ChildItem -Path $ndkFolderPath -Name
$ndkDefaultVersion = Get-ToolsetValue "android.ndk.default"
$ndkDefaultFullVersion = Get-ChildItem "$env:ANDROID_HOME/ndk/$ndkDefaultVersion.*" -Name | Select-Object -Last 1
return ($versions | ForEach-Object {
$defaultPostfix = ( $_ -eq $ndkDefaultFullVersion ) ? " (default)" : ""
$_ + $defaultPostfix
} | Join-String -Separator "<br>")
}

View File

@@ -0,0 +1,117 @@
function Build-BrowserSection {
$nodes = @()
$os = Get-OSVersion
$nodes += @(
[ToolVersionNode]::new("Safari", $(Get-SafariVersion))
[ToolVersionNode]::new("SafariDriver", $(Get-SafariDriverVersion))
[ToolVersionNode]::new("Google Chrome", $(Get-ChromeVersion))
[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))
[ToolVersionNode]::new("Microsoft Edge WebDriver", $(Get-EdgeDriverVersion))
[ToolVersionNode]::new("Mozilla Firefox", $(Get-FirefoxVersion))
[ToolVersionNode]::new("geckodriver", $(Get-GeckodriverVersion))
)
}
$nodes += @(
[ToolVersionNode]::new("Selenium server", $(Get-SeleniumVersion))
)
return $nodes
}
function Get-SafariVersion {
$version = Run-Command "defaults read /Applications/Safari.app/Contents/Info CFBundleShortVersionString"
$build = Run-Command "defaults read /Applications/Safari.app/Contents/Info CFBundleVersion"
return "$version ($build)"
}
function Get-SafariDriverVersion {
$version = Run-Command "safaridriver --version" | Take-Part -Part 3, 4
return $version
}
function Get-ChromeVersion {
$chromePath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
$version = Run-Command "'${chromePath}' --version"
return ($version -replace ("^Google Chrome")).Trim()
}
function Get-ChromeForTestingVersion {
$chromePath = "/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"
$version = Run-Command "'${chromePath}' --version"
return ($version -replace ("^Google Chrome for Testing")).Trim()
}
function Get-ChromeDriverVersion {
$rawOutput = Run-Command "chromedriver --version"
$version = $rawOutput | Take-Part -Part 1
return $version
}
function Get-EdgeVersion {
$edgePath = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
$version = Run-Command "'${edgePath}' --version"
return ($version -replace ("^Microsoft Edge")).Trim()
}
function Get-EdgeDriverVersion {
return Run-Command "msedgedriver --version" | Take-Part -Part 3
}
function Get-FirefoxVersion {
$firefoxPath = "/Applications/Firefox.app/Contents/MacOS/firefox"
$version = Run-Command "'${firefoxPath}' --version"
return ($version -replace "^Mozilla Firefox").Trim()
}
function Get-GeckodriverVersion {
$version = Run-Command "geckodriver --version" | Select-Object -First 1
return ($version -replace "^geckodriver").Trim()
}
function Get-SeleniumVersion {
$os = Get-OSVersion
if ($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
$cellarPath = "/opt/homebrew/Cellar"
} else {
$cellarPath = "/usr/local/Cellar"
}
$seleniumVersion = (Get-ChildItem -Path "$cellarPath/selenium-server*/*").Name
return $seleniumVersion
}
function Build-BrowserWebdriversEnvironmentTable {
$node = [HeaderNode]::new("Environment variables")
$table = @(
@{
"Name" = "CHROMEWEBDRIVER"
"Value" = $env:CHROMEWEBDRIVER
},
@{
"Name" = "EDGEWEBDRIVER"
"Value" = $env:EDGEWEBDRIVER
},
@{
"Name" = "GECKOWEBDRIVER"
"Value" = $env:GECKOWEBDRIVER
}
) | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
"Value" = $_.Value
}
}
$node.AddTable($table)
return $node
}

View File

@@ -0,0 +1,628 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
function Get-BashVersion {
$version = bash -c 'echo ${BASH_VERSION}'
return $version
}
function Get-DotnetVersionList {
$sdkRawList = Run-Command "dotnet --list-sdks"
return $sdkRawList | ForEach-Object { Take-Part $_ -Part 0 }
}
function Get-GoVersion {
$goOutput = Run-Command "go version" | Take-Part -Part 2
if ($goOutput.StartsWith("go")) {
$goOutput = $goOutput.Substring(2)
}
return $goOutput
}
function Get-RVersion {
$rVersion = Run-Command "R --version | grep 'R version'" | Take-Part -Part 2
return $rVersion
}
function Get-RustVersion {
$rustVersion = Run-Command "rustc --version" | Take-Part -Part 1
return $rustVersion
}
function Get-RustfmtVersion {
$version = Run-Command "rustfmt --version" | Take-Part -Part 1
return $version
}
function Get-RustdocVersion {
$version = Run-Command "rustdoc --version" | Take-Part -Part 1
return $version
}
function Get-RustCargoVersion {
$version = Run-Command "cargo --version" | Take-Part -Part 1
return $version
}
function Get-RustClippyVersion {
$version = Run-Command "cargo clippy --version" | Take-Part -Part 1
return $version
}
function Get-Bindgen {
$bindgenVersion = Run-Command "bindgen --version" | Take-Part -Part 1
return $bindgenVersion
}
function Get-Cbindgen {
$cbindgenVersion = Run-Command "cbindgen --version" | Take-Part -Part 1
return $cbindgenVersion
}
function Get-Cargooutdated {
$cargoOutdatedVersion = Run-Command "cargo outdated --version" | Take-Part -Part 1
return $cargoOutdatedVersion
}
function Get-Cargoaudit {
$cargoAuditVersion = Run-Command "cargo-audit --version" | Take-Part -Part 1
return $cargoAuditVersion
}
function Get-RustupVersion {
$rustupVersion = Run-Command "rustup --version" | Select-Object -First 1 | Take-Part -Part 1
return $rustupVersion
}
function Get-VcpkgVersion {
$vcpkgVersion = Run-Command "vcpkg version" | Select-Object -First 1 | Take-Part -Part 5 | Take-Part -Part 0 -Delimiter "-"
$commitId = git -C "/usr/local/share/vcpkg" rev-parse --short HEAD
return "$vcpkgVersion (build from commit $commitId)"
}
function Get-GccVersions {
$versionList = Get-ToolsetValue -KeyPath gcc.versions
$versionList | Foreach-Object {
$nameVersion = Run-Command "gcc-${_} --version" | Select-Object -First 1
$version = ($nameVersion -replace "^gcc-${_}").Trim() -replace '\).*$', ')'
return [ToolVersionNode]::new("GCC ${_}", "$version - available by ``gcc-${_}`` alias")
}
}
function Get-FortranVersions {
$versionList = Get-ToolsetValue -KeyPath gcc.versions
$versionList | Foreach-Object {
$nameVersion = Run-Command "gfortran-${_} --version" | Select-Object -First 1
$version = ($nameVersion -replace "^GNU Fortran").Trim() -replace '\).*$', ')'
return [ToolVersionNode]::new("GNU Fortran ${_}", "$version - available by ``gfortran-${_}`` alias")
}
}
function Get-ClangLLVMVersions {
$clangVersionRegex = [Regex]::new("(?<version>\d+\.\d+\.\d+)")
$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')
$homebrewClangOutput = Run-Command "$homebrewClangPath --version" | Out-String
$homebrewClangVersion = $clangVersionRegex.Match($homebrewClangOutput).Groups['version'].Value
return @(
[ToolVersionNode]::new("Clang/LLVM", $defaultClangVersion)
[ToolVersionNode]::new("Clang/LLVM (Homebrew)", "$homebrewClangVersion - available on ``$homebrewClangPath``")
)
}
function Get-NVMVersion {
$nvmPath = Join-Path $env:HOME ".nvm" "nvm.sh"
$nvmInitCommand = ". ${nvmPath} > /dev/null 2>&1 || true"
$nodejsVersion = Run-Command "${nvmInitCommand} && nvm --version"
return $nodejsVersion
}
function Get-PipVersion {
param (
[Parameter(Mandatory)][ValidateRange(2, 3)]
[int] $Version
)
$command = If ($Version -eq 2) { "/Library/Frameworks/Python.framework/Versions/2.7/bin/pip --version" } Else { "pip3 --version" }
$commandOutput = Run-Command $command
$versionPart1 = $commandOutput | Take-Part -Part 1
$versionPart2 = $commandOutput | Take-Part -Part 4
$versionPart3 = $commandOutput | Take-Part -Part 5
return "${versionPart1} ${versionPart2} ${versionPart3}"
}
function Get-PipxVersion {
$pipxVersion = Run-Command "pipx --version" -SuppressStderr
return $pipxVersion
}
function Get-NVMNodeVersionList {
$nvmPath = Join-Path $env:HOME ".nvm" "nvm.sh"
$nvmInitCommand = ". ${nvmPath} > /dev/null 2>&1 || true"
$nodejsVersionsRaw = Run-Command "${nvmInitCommand} && nvm ls"
$nodeVersions = $nodejsVersionsRaw | ForEach-Object { $_.TrimStart(" ").TrimEnd(" *") } | Where-Object { $_.StartsWith("v") }
return $nodeVersions | ForEach-Object { $_.TrimStart("v") }
}
function Build-OSInfoSection {
param (
[string] $ImageName
)
$fieldsToInclude = @("System Version:", "Kernel Version:")
$rawSystemInfo = Invoke-Expression "system_profiler SPSoftwareDataType"
$parsedSystemInfo = $rawSystemInfo | Where-Object { -not ($_ | Select-String -NotMatch $fieldsToInclude) } | ForEach-Object { $_.Trim() }
$parsedSystemInfo[0] -match "System Version: macOS (?<version>\d+)" | Out-Null
$version = $Matches.Version
$systemVersion = $parsedSystemInfo[0].Replace($fieldsToInclude[0],"").Trim()
$kernelVersion = $parsedSystemInfo[1].Replace($fieldsToInclude[1],"").Trim()
$osInfoNode = [HeaderNode]::new("macOS $version")
$osInfoNode.AddToolVersion("OS Version:", $systemVersion)
$osInfoNode.AddToolVersion("Kernel Version:", $kernelVersion)
$osInfoNode.AddToolVersion("Image Version:", $ImageName.Split('_')[1])
return $osInfoNode
}
function Get-MonoVersion {
$monoVersion = mono --version | Out-String | Take-Part -Part 4
return $monoVersion
}
function Get-MSBuildVersion {
$msbuildVersion = msbuild -version | Select-Object -Last 1
$monoVersion = Get-MonoVersion
return "$msbuildVersion (Mono $monoVersion)"
}
function Get-NodeVersion {
$nodeVersion = Run-Command "node --version"
return $nodeVersion.TrimStart("v")
}
function Get-PerlVersion {
$version = Run-Command "perl -e 'print substr(`$^V,1)'"
return $version
}
function Get-PythonVersion {
$pythonVersion = Run-Command "/Library/Frameworks/Python.framework/Versions/2.7/bin/python --version"
return ($pythonVersion -replace "^Python").Trim()
}
function Get-Python3Version {
$python3Version = Run-Command "python3 --version"
return ($python3Version -replace "^Python").Trim()
}
function Get-RubyVersion {
$rubyVersion = Run-Command "ruby --version" | Take-Part -Part 1
return $rubyVersion
}
function Get-PHPVersion {
$PHPVersion = Run-Command "php --version" | Select-Object -First 1 | Take-Part -Part 0,1
return ($PHPVersion -replace "^PHP").Trim()
}
function Get-JuliaVersion {
$juliaVersion = Run-Command "julia --version" | Take-Part -Part 0,2
return ($juliaVersion -replace "^Julia").Trim()
}
function Get-BundlerVersion {
$bundlerVersion = Run-Command "bundle --version"
return ($bundlerVersion -replace "^Bundler version").Trim()
}
function Get-CarthageVersion {
$carthageVersion = Run-Command "carthage version" -SuppressStderr
return $carthageVersion
}
function Get-CocoaPodsVersion {
$cocoaPodsVersion = Run-Command "pod --version"
return $cocoaPodsVersion
}
function Get-HomebrewVersion {
$homebrewVersion = Run-Command "brew --version" | Select-Object -First 1
return ($homebrewVersion -replace "^Homebrew").Trim()
}
function Get-NPMVersion {
$NPMVersion = Run-Command "npm --version"
return $NPMVersion
}
function Get-YarnVersion {
$yarmVersion = Run-Command "yarn --version"
return $yarmVersion
}
function Get-NuGetVersion {
$nugetVersion = Run-Command "nuget help" | Select-Object -First 1 | Take-Part -Part 2
return $nugetVersion
}
function Get-CondaVersion {
$condaVersion = Invoke-Expression "conda --version"
return ($condaVersion -replace "^conda").Trim()
}
function Get-RubyGemsVersion {
$rubyGemsVersion = Run-Command "gem --version"
return $rubyGemsVersion
}
function Get-ComposerVersion {
$composerVersion = Run-Command "composer --version" | Take-Part -Part 2
return $composerVersion
}
function Get-MavenVersion {
$mavenVersion = Run-Command "mvn -version" | Select-Object -First 1 | Take-Part -Part 2
return $mavenVersion
}
#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]
return ($gradleVersion.Line -replace "^Gradle").Trim()
}
function Get-ApacheAntVersion {
$apacheAntVersion = Run-Command "ant -version" | Take-Part -Part 0,1,3
return ($apacheAntVersion -replace "^Apache Ant\(TM\)").Trim()
}
function Get-CurlVersion {
$curlVersion = Run-Command "curl --version" | Select-Object -First 1 | Take-Part -Part 1
return $curlVersion
}
function Get-GitVersion {
$gitVersion = Run-Command "git --version" | Take-Part -Part -1
return $gitVersion
}
function Get-GitLFSVersion {
$gitLFSVersion = Run-Command "git-lfs version" | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/"
return $gitLFSVersion
}
function Get-GitHubCLIVersion {
$ghVersion = Run-Command "gh --version" | Select-String "gh version" | Select-Object -First 1 | Take-Part -Part 2
return $ghVersion
}
function Get-WgetVersion {
$wgetVersion = Run-Command "wget --version" | Select-String "GNU Wget" | Take-Part -Part 2
return $wgetVersion
}
function Get-SVNVersion {
$svnVersion = Run-Command "svn --version --quiet"
return $svnVersion
}
function Get-PackerVersion {
# Packer 1.7.1 has a bug and outputs version to stderr instead of stdout https://github.com/hashicorp/packer/issues/10855
$result = Run-Command -Command "packer --version"
$packerVersion = [regex]::matches($result, "(\d+.){2}\d+").Value
return $packerVersion
}
function Get-OpenSSLVersion {
$opensslVersion = Run-Command "openssl version"
return ($opensslVersion -replace "^OpenSSL").Trim()
}
function Get-JqVersion {
$jqVersion = Run-Command "jq --version" | Take-Part -Part 1 -Delimiter "-"
return $jqVersion
}
function Get-GPGVersion {
$gpgVersion = Run-Command "gpg --version" | Select-String 'gpg (GnuPG)' -SimpleMatch
return ($gpgVersion.Line -replace "^gpg \(GnuPG\)").Trim()
}
function Get-PostgresClientVersion {
$postgresClientVersion = Run-Command "psql --version"
return ($postgresClientVersion -replace "^psql \(PostgreSQL\)").Trim()
}
function Get-PostgresServerVersion {
$postgresServerVersion = Run-Command "pg_config --version"
return ($postgresServerVersion -replace "^PostgreSQL").Trim()
}
function Get-Aria2Version {
$aria2Version = Run-Command "aria2c --version" | Select-Object -First 1 | Take-Part -Part 2
return $aria2Version
}
function Get-AzcopyVersion {
$azcopyVersion = Run-Command "azcopy --version" | Take-Part -Part 2
return $azcopyVersion
}
function Get-ZstdVersion {
$zstdVersion = Run-Command "zstd --version" | Take-Part -Part 1 -Delimiter "v" | Take-Part -Part 0 -Delimiter ","
return $zstdVersion
}
function Get-BazelVersion {
$bazelVersion = Run-Command "bazel --version" | Take-Part -Part 0 -Delimiter "-"
return ($bazelVersion -replace "^bazel").Trim()
}
function Get-BazeliskVersion {
$bazeliskVersion = Run-Command "brew list bazelisk --versions"
return ($bazeliskVersion -replace "^bazelisk").Trim()
}
function Get-HelmVersion {
$helmVersion = Run-Command "helm version --short"
return $helmVersion
}
function Get-MongoVersion {
$mongo = Run-Command "mongo --version" | Select-String "MongoDB shell version" | Take-Part -Part 3
return $mongo.TrimStart("v").Trim()
}
function Get-MongodVersion {
$mongod = Run-Command "mongod --version" | Select-String "db version " | Take-Part -Part 2
return $mongod.TrimStart("v").Trim()
}
function Get-7zipVersion {
$7zip = Run-Command "7z i" | Select-String "7-Zip" | Take-Part -Part 0,2
return ($7zip -replace "^7-Zip").Trim()
}
function Get-GnuTarVersion {
$gnuTar = Run-Command "gtar --version" | Select-String "tar" | Take-Part -Part 3
return "$gnuTar - available by 'gtar' alias"
}
function Get-BsdtarVersion {
$bsdtar = Run-Command "tar --version" | Take-Part -Part 1
return "$bsdtar - available by 'tar' alias"
}
function Get-NewmanVersion {
$newmanVersion = Run-Command "newman --version"
return $newmanVersion
}
function Get-VirtualBoxVersion {
$virtualBox = Run-Command "vboxmanage -v"
return $virtualBox
}
function Get-VagrantVersion {
$vagrant = Run-Command "vagrant -v"
return ($vagrant -replace "^Vagrant").Trim()
}
function Get-ParallelVersion {
$parallelVersion = Run-Command "parallel --version" | Select-String "GNU parallel" | Select-Object -First 1
return ($parallelVersion -replace "^GNU parallel").Trim()
}
function Get-FastlaneVersion {
$fastlaneVersion = Run-Command "fastlane --version" | Select-String "^fastlane [0-9]" | Take-Part -Part 1
return $fastlaneVersion
}
function Get-CmakeVersion {
$cmakeVersion = Run-Command "cmake --version" | Select-Object -First 1 | Take-Part -Part 2
return $cmakeVersion
}
function Get-AppCenterCLIVersion {
$appcenterCLIVersion = Run-Command "appcenter --version" | Take-Part -Part 2
return $appcenterCLIVersion
}
function Get-AzureCLIVersion {
$azureCLIVersion = (az version | ConvertFrom-Json).'azure-cli'
return $azureCLIVersion
}
function Get-AzureDevopsVersion {
$azdevopsVersion = (az version | ConvertFrom-Json).extensions.'azure-devops'
return $azdevopsVersion
}
function Get-AWSCLIVersion {
$awsVersion = Run-Command "aws --version" | Take-Part -Part 0 | Take-Part -Delimiter "/" -Part 1
return $awsVersion
}
function Get-AWSSAMCLIVersion {
$awsSamVersion = Run-Command "sam --version" | Take-Part -Part 3
return $awsSamVersion
}
function Get-AWSSessionManagerCLIVersion {
$awsSessionManagerVersion = Run-Command "session-manager-plugin --version"
return $awsSessionManagerVersion
}
function Get-AliyunCLIVersion {
$aliyunVersion = Run-Command "aliyun --version" | Select-String "Alibaba Cloud Command Line Interface Version " | Take-Part -Part 6
return $aliyunVersion
}
function Get-GHCupVersion {
$ghcUpVersion = (Run-Command "ghcup --version" | Take-Part -Part 5).Replace('v','')
return $ghcUpVersion
}
function Get-GHCVersion {
$ghcVersion = Run-Command "ghc --version" | Take-Part -Part 7
return $ghcVersion
}
function Get-CabalVersion {
$cabalVersion = Run-Command "cabal --version" | Take-Part -Part 3
return $cabalVersion
}
function Get-SwitchAudioOsxVersion {
$switchAudioVersion = Get-BrewPackageVersion -CommandName "SwitchAudioSource"
return $switchAudioVersion
}
function Get-SoxVersion {
$soxVersion = Get-BrewPackageVersion -CommandName "sox"
return $soxVersion
}
function Get-StackVersion {
$stackVersion = Run-Command "stack --version" | Take-Part -Part 1 | ForEach-Object {$_.replace(",","")}
return $stackVersion
}
function Get-SwiftFormatVersion {
$swiftFormatVersion = Run-Command "swiftformat --version"
return $swiftFormatVersion
}
function Get-YamllintVersion {
$yamllintVersion = Run-Command "yamllint --version"
return ($yamllintVersion -replace "^Yamllint").Trim()
}
function Get-SwiftLintVersion {
$swiftlintVersion = Run-Command "swiftlint version"
return $swiftlintVersion
}
function Get-PowershellVersion {
$powershellVersion = Run-Command "powershell --version"
return ($powershellVersion -replace "^PowerShell").Trim()
}
function Get-SwigVersion {
$swigVersion = Run-Command "swig -version" | Select-Object -First 2 | Take-Part -Part 2
return $swigVersion
}
function Get-BicepVersion {
$bicepVersion = Run-Command "bicep --version" | Take-Part -Part 3
return $bicepVersion
}
function Get-KotlinVersion {
$kotlinVersion = Run-Command "kotlin -version" | Take-Part -Part 2
return $kotlinVersion
}
function Get-SbtVersion {
$sbtVersion = Run-Command "sbt -version" | Take-Part -Part 3
return $sbtVersion
}
function Get-JazzyVersion {
$jazzyVersion = Run-Command "jazzy --version" | Take-Part -Part 2
return $jazzyVersion
}
function Get-ZlibVersion {
$zlibVersion = brew info --json zlib | jq -r '.[].installed[].version'
return $zlibVersion
}
function Get-LibXftVersion {
$libXftVersion = brew info --json libxft | jq -r '.[].installed[].version'
return $libXftVersion
}
function Get-LibXextVersion {
$libXextVersion = brew info --json libxext | jq -r '.[].installed[].version'
return $libXextVersion
}
function Get-TclTkVersion {
$tcltkVersion = brew info --json tcl-tk | jq -r '.[].installed[].version'
return $tcltkVersion
}
function Get-YqVersion {
$yqVersion = Run-Command "yq --version"
$yqVersion -match "\d{1,2}\.\d{1,2}\.\d{1,2}" | Out-Null
return ($Matches[0])
}
function Get-ImageMagickVersion {
$imagemagickVersion = Run-Command "magick --version" | Select-Object -First 1 | Take-Part -Part 1,2
return ($imagemagickVersion -replace "^ImageMagick").Trim()
}
function Build-PackageManagementEnvironmentTable {
$node = [HeaderNode]::new("Environment variables")
$table = @(
@{
"Name" = "CONDA"
"Value" = $env:CONDA
},
@{
"Name" = "VCPKG_INSTALLATION_ROOT"
"Value" = $env:VCPKG_INSTALLATION_ROOT
}
) | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
"Value" = $_.Value
}
}
$node.AddTable($table)
return $node
}
function Build-MiscellaneousEnvironmentTable {
return @(
@{
"Name" = "PARALLELS_DMG_URL"
"Value" = $env:PARALLELS_DMG_URL
}
) | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
"Value" = $_.Value
}
}
}
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
}
function Get-ColimaVersion {
$colimaVersion = Run-Command "colima version" | Select-String "colima version" | Take-Part -Part 2
return $colimaVersion
}
function Get-PKGConfigVersion {
$pkgconfigVersion = Run-Command "pkg-config --version"
return $pkgconfigVersion
}

View File

@@ -0,0 +1,319 @@
using module ./software-report-base/SoftwareReport.psm1
using module ./software-report-base/SoftwareReport.Nodes.psm1
param (
[Parameter(Mandatory)][string]
$OutputDirectory,
$ImageName
)
$ErrorActionPreference = "Stop"
Import-Module "$PSScriptRoot/SoftwareReport.Common.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Xcode.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Android.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Java.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Xamarin.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Toolcache.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Browsers.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.WebServers.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/../helpers/SoftwareReport.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
# Operating System info
$os = Get-OSVersion
# OS info
$osInfo = Build-OSInfoSection $ImageName
# Software report
$softwareReport = [SoftwareReport]::new($osInfo)
$installedSoftware = $softwareReport.Root.AddHeader("Installed Software")
# Language and Runtime
$languageAndRuntime = $installedSoftware.AddHeader("Language and Runtime")
$languageAndRuntime.AddToolVersionsListInline(".NET Core SDK", $(Get-DotnetVersionList), '^\d+\.\d+\.\d')
$languageAndRuntime.AddToolVersion("Bash", $(Get-BashVersion))
$languageAndRuntime.AddNodes($(Get-ClangLLVMVersions))
$languageAndRuntime.AddNodes($(Get-GccVersions))
$languageAndRuntime.AddNodes($(Get-FortranVersions))
$languageAndRuntime.AddToolVersion("Julia", $(Get-JuliaVersion))
$languageAndRuntime.AddToolVersion("Kotlin", $(Get-KotlinVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$languageAndRuntime.AddToolVersion("Go", $(Get-GoVersion))
}
$languageAndRuntime.AddToolVersion("Mono", $(Get-MonoVersion))
$languageAndRuntime.AddToolVersion("Node.js", $(Get-NodeVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$languageAndRuntime.AddToolVersion("MSBuild", $(Get-MSBuildVersion))
$languageAndRuntime.AddToolVersion("NVM", $(Get-NVMVersion))
$languageAndRuntime.AddToolVersionsListInline("NVM - Cached node versions", $(Get-NVMNodeVersionList), '^\d+')
}
$languageAndRuntime.AddToolVersion("Perl", $(Get-PerlVersion))
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$languageAndRuntime.AddToolVersion("PHP", $(Get-PHPVersion))
}
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$languageAndRuntime.AddToolVersion("Python", $(Get-PythonVersion))
}
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$languageAndRuntime.AddToolVersion("Python3", $(Get-Python3Version))
}
$languageAndRuntime.AddToolVersion("R", $(Get-RVersion))
$languageAndRuntime.AddToolVersion("Ruby", $(Get-RubyVersion))
# Package Management
$packageManagement = $installedSoftware.AddHeader("Package Management")
$packageManagement.AddToolVersion("Bundler", $(Get-BundlerVersion))
$packageManagement.AddToolVersion("Carthage", $(Get-CarthageVersion))
$packageManagement.AddToolVersion("CocoaPods", $(Get-CocoaPodsVersion))
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$packageManagement.AddToolVersion("Composer", $(Get-ComposerVersion))
}
$packageManagement.AddToolVersion("Homebrew", $(Get-HomebrewVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$packageManagement.AddToolVersion("Miniconda", $(Get-CondaVersion))
}
$packageManagement.AddToolVersion("NPM", $(Get-NPMVersion))
$packageManagement.AddToolVersion("NuGet", $(Get-NuGetVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$packageManagement.AddToolVersion("Pip", $(Get-PipVersion -Version 2))
}
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$packageManagement.AddToolVersion("Pip3", $(Get-PipVersion -Version 3))
$packageManagement.AddToolVersion("Pipx", $(Get-PipxVersion))
}
$packageManagement.AddToolVersion("RubyGems", $(Get-RubyGemsVersion))
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$packageManagement.AddToolVersion("Vcpkg", $(Get-VcpkgVersion))
}
$packageManagement.AddToolVersion("Yarn", $(Get-YarnVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$packageManagement.AddNode($(Build-PackageManagementEnvironmentTable))
}
# Project Management
$projectManagement = $installedSoftware.AddHeader("Project Management")
$projectManagement.AddToolVersion("Apache Ant", $(Get-ApacheAntVersion))
$projectManagement.AddToolVersion("Apache Maven", $(Get-MavenVersion))
$projectManagement.AddToolVersion("Gradle", $(Get-GradleVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$projectManagement.AddToolVersion("Sbt", $(Get-SbtVersion))
}
# Utilities
$utilities = $installedSoftware.AddHeader("Utilities")
$utilities.AddToolVersion("7-Zip", $(Get-7zipVersion))
$utilities.AddToolVersion("aria2", $(Get-Aria2Version))
$utilities.AddToolVersion("azcopy", $(Get-AzcopyVersion))
$utilities.AddToolVersion("bazel", $(Get-BazelVersion))
$utilities.AddToolVersion("bazelisk", $(Get-BazeliskVersion))
$utilities.AddToolVersion("bsdtar", $(Get-BsdtarVersion))
$utilities.AddToolVersion("Curl", $(Get-CurlVersion))
$utilities.AddToolVersion("Git", $(Get-GitVersion))
$utilities.AddToolVersion("Git LFS", $(Get-GitLFSVersion))
$utilities.AddToolVersion("GitHub CLI", $(Get-GitHubCLIVersion))
$utilities.AddToolVersion("GNU Tar", $(Get-GnuTarVersion))
$utilities.AddToolVersion("GNU Wget", $(Get-WgetVersion))
$utilities.AddToolVersion("gpg (GnuPG)", $(Get-GPGVersion))
if ($os.IsBigSur) {
$utilities.AddToolVersion("helm", $(Get-HelmVersion))
}
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$utilities.AddToolVersion("ImageMagick", $(Get-ImageMagickVersion))
}
$utilities.AddToolVersion("jq", $(Get-JqVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$utilities.AddToolVersion("mongo", $(Get-MongoVersion))
$utilities.AddToolVersion("mongod", $(Get-MongodVersion))
}
if ($os.IsBigSur) {
$utilities.AddToolVersion("Newman", $(Get-NewmanVersion))
}
$utilities.AddToolVersion("OpenSSL", $(Get-OpenSSLVersion))
$utilities.AddToolVersion("Packer", $(Get-PackerVersion))
$utilities.AddToolVersion("pkg-config", $(Get-PKGConfigVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$utilities.AddToolVersion("PostgreSQL", $(Get-PostgresServerVersion))
$utilities.AddToolVersion("psql (PostgreSQL)", $(Get-PostgresClientVersion))
$utilities.AddToolVersion("Sox", $(Get-SoxVersion))
$utilities.AddToolVersion("Subversion (SVN)", $(Get-SVNVersion))
$utilities.AddToolVersion("Switchaudio-osx", $(Get-SwitchAudioOsxVersion))
}
if ($os.IsMonterey) {
$utilities.AddToolVersion("Vagrant", $(Get-VagrantVersion))
$utilities.AddToolVersion("VirtualBox", $(Get-VirtualBoxVersion))
}
$utilities.AddToolVersion("yq", $(Get-YqVersion))
$utilities.AddToolVersion("zstd", $(Get-ZstdVersion))
# Tools
$tools = $installedSoftware.AddHeader("Tools")
if ($os.IsBigSur) {
$tools.AddToolVersion("Aliyun CLI", $(Get-AliyunCLIVersion))
}
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$tools.AddToolVersion("App Center CLI", $(Get-AppCenterCLIVersion))
}
$tools.AddToolVersion("AWS CLI", $(Get-AWSCLIVersion))
$tools.AddToolVersion("AWS SAM CLI", $(Get-AWSSAMCLIVersion))
$tools.AddToolVersion("AWS Session Manager CLI", $(Get-AWSSessionManagerCLIVersion))
$tools.AddToolVersion("Azure CLI", $(Get-AzureCLIVersion))
$tools.AddToolVersion("Azure CLI (azure-devops)", $(Get-AzureDevopsVersion))
$tools.AddToolVersion("Bicep CLI", $(Get-BicepVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$tools.AddToolVersion("Cabal", $(Get-CabalVersion))
}
$tools.AddToolVersion("Cmake", $(Get-CmakeVersion))
$tools.AddToolVersion("CodeQL Action Bundle", $(Get-CodeQLBundleVersion))
if ($os.IsMonterey) {
$tools.AddToolVersion("Colima", $(Get-ColimaVersion))
}
$tools.AddToolVersion("Fastlane", $(Get-FastlaneVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$tools.AddToolVersion("GHC", $(Get-GHCVersion))
$tools.AddToolVersion("GHCup", $(Get-GHCupVersion))
$tools.AddToolVersion("Jazzy", $(Get-JazzyVersion))
}
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$tools.AddToolVersion("Stack", $(Get-StackVersion))
}
$tools.AddToolVersion("SwiftFormat", $(Get-SwiftFormatVersion))
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$tools.AddToolVersion("Swig", $(Get-SwigVersion))
}
$tools.AddToolVersion("Xcode Command Line Tools", $(Get-XcodeCommandLineToolsVersion))
# Linters
$linters = $installedSoftware.AddHeader("Linters")
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$linters.AddToolVersion("SwiftLint", $(Get-SwiftLintVersion))
}
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$linters.AddToolVersion("Yamllint", $(Get-YamllintVersion))
}
# Browsers
$browsers = $installedSoftware.AddHeader("Browsers")
$browsers.AddNodes($(Build-BrowserSection))
$browsers.AddNode($(Build-BrowserWebdriversEnvironmentTable))
# Java
$java = $installedSoftware.AddHeader("Java")
$java.AddTable($(Get-JavaVersions))
# Toolcache
if (-not $os.IsSonoma) {
$toolcache = $installedSoftware.AddHeader("Cached Tools")
$toolcache.AddNodes($(Build-ToolcacheSection))
# Rust
$rust = $installedSoftware.AddHeader("Rust Tools")
$rust.AddToolVersion("Cargo", $(Get-RustCargoVersion))
$rust.AddToolVersion("Rust", $(Get-RustVersion))
$rust.AddToolVersion("Rustdoc", $(Get-RustdocVersion))
$rust.AddToolVersion("Rustup", $(Get-RustupVersion))
$rustPackages = $rust.AddHeader("Packages")
if (-not $os.IsVentura) {
$rustPackages.AddToolVersion("Bindgen", $(Get-Bindgen))
$rustPackages.AddToolVersion("Cargo-audit", $(Get-Cargoaudit))
$rustPackages.AddToolVersion("Cargo-outdated", $(Get-Cargooutdated))
$rustPackages.AddToolVersion("Cbindgen", $(Get-Cbindgen))
}
$rustPackages.AddToolVersion("Clippy", $(Get-RustClippyVersion))
$rustPackages.AddToolVersion("Rustfmt", $(Get-RustfmtVersion))
}
# PowerShell
$powerShell = $installedSoftware.AddHeader("PowerShell Tools")
$powerShell.AddToolVersion("PowerShell", $(Get-PowershellVersion))
$powerShellModules = $powerShell.AddHeader("PowerShell Modules")
$powerShellModules.AddNodes($(Get-PowerShellModules))
# Web Servers
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$webServers = $installedSoftware.AddHeader("Web Servers")
$webServers.AddTable($(Build-WebServersSection))
}
# Xamarin section
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$xamarin = $installedSoftware.AddHeader("Xamarin")
$vsForMac = $xamarin.AddHeader("Visual Studio for Mac")
$vsForMac.AddTable($(Build-VSMacTable))
$note =
@'
To use Visual Studio 2019 by default rename the app:
mv "/Applications/Visual Studio.app" "/Applications/Visual Studio 2022.app"
mv "/Applications/Visual Studio 2019.app" "/Applications/Visual Studio.app"
'@
$vsForMacNotes = $vsForMac.AddHeader("Notes")
$vsForMacNotes.AddNote($note)
$xamarinBundles = $xamarin.AddHeader("Xamarin bundles")
$xamarinBundles.AddTable($(Build-XamarinTable))
$unitTestFramework = $xamarin.AddHeader("Unit Test Framework")
$unitTestFramework.AddToolVersion("NUnit", $(Get-NUnitVersion))
}
# Xcode section
$xcode = $installedSoftware.AddHeader("Xcode")
# First run doesn't provide full data about devices and runtimes
Get-XcodeInfoList | Out-Null
$xcodeInfo = Get-XcodeInfoList
$xcode.AddTable($(Build-XcodeTable $xcodeInfo))
$xcodeTools = $xcode.AddHeader("Xcode Support Tools")
$xcodeTools.AddNodes($(Build-XcodeSupportToolsSection))
$installedSdks = $xcode.AddHeader("Installed SDKs")
$installedSdks.AddTable($(Build-XcodeSDKTable $xcodeInfo))
$installedSimulators = $xcode.AddHeader("Installed Simulators")
$installedSimulators.AddTable($(Build-XcodeSimulatorsTable $xcodeInfo))
# Android section
$android = $installedSoftware.AddHeader("Android")
$androidTable = Build-AndroidTable
$android.AddTable($androidTable)
$androidEnv = $android.AddHeader("Environment variables")
$androidEnv.AddTable($(Build-AndroidEnvironmentTable))
if ($os.IsBigSur -or $os.IsMonterey) {
$miscellaneous = $installedSoftware.AddHeader("Miscellaneous")
$miscellaneous.AddToolVersion("libXext", $(Get-LibXextVersion))
$miscellaneous.AddToolVersion("libXft", $(Get-LibXftVersion))
$miscellaneous.AddToolVersion("Tcl/Tk", $(Get-TclTkVersion))
$miscellaneous.AddToolVersion("Zlib", $(Get-ZlibVersion))
}
if ($os.IsMonterey) {
$miscellaneousEnv = $miscellaneous.AddHeader("Environment variables")
$miscellaneousEnv.AddTable($(Build-MiscellaneousEnvironmentTable))
$notes = @'
If you want to use Parallels Desktop you should download a package from URL stored in
PARALLELS_DMG_URL environment variable. A system extension is allowed for this version.
'@
$miscellaneousEnvNotes = $miscellaneousEnv.AddHeader("Notes")
$miscellaneousEnvNotes.AddNote($notes)
}
if (-not (Test-Path $OutputDirectory)) { New-Item -Path $OutputDirectory -ItemType Directory | Out-Null }
#
# Write final reports
#
Write-Host $markdownExtended
$softwareReport.ToJson() | Out-File -FilePath "${OutputDirectory}/systeminfo.json" -Encoding UTF8NoBOM
$softwareReport.ToMarkdown() | Out-File -FilePath "${OutputDirectory}/systeminfo.md" -Encoding UTF8NoBOM

View File

@@ -0,0 +1,27 @@
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] }
Descending = $false
}
return $javaVersions | Sort-Object $sortRules | ForEach-Object {
$javaPath = $_.Value
# Take semver from the java path
$version = $javaPath.split('/')[5]
$fullVersion = $version.Replace('-', '+')
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
[PSCustomObject] @{
"Version" = $fullVersion + $defaultPostfix
"Environment Variable" = $_.Name
}
}
}

View File

@@ -0,0 +1,63 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
function Get-ToolcacheRubyVersions {
$toolcachePath = Join-Path $env:HOME "hostedtoolcache" "Ruby"
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
}
function Get-ToolcachePythonVersions {
$toolcachePath = Join-Path $env:HOME "hostedtoolcache" "Python"
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
}
function Get-ToolcachePyPyVersions {
$toolcachePath = Join-Path $env:HOME "hostedtoolcache/PyPy/*/x64"
Get-ChildItem -Path $toolcachePath | Sort-Object { [Version] $_.Parent.Name } | ForEach-Object {
$foundVersionPath = $_.FullName
$foundVersionName = (Get-Item ($foundVersionPath -replace "x64") | Sort-Object -Property {[version]$_.name} -Descending | Select-Object -First 1).name
$arrPyPyVersion = ((& "$foundVersionPath/bin/python" -c "import sys;print(sys.version.split('\n')[1])") -split " ")
$pypyVersion = "$($arrPyPyVersion[0]) $($arrPyPyVersion[1])"
return "{0} {1}]" -f $foundVersionName, $pypyVersion
}
}
function Get-ToolcacheNodeVersions {
$toolcachePath = Join-Path $env:HOME "hostedtoolcache" "Node"
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
}
function Get-ToolcacheGoVersions {
$toolcachePath = Join-Path $env:HOME "hostedtoolcache" "Go"
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
}
function Build-ToolcacheSection {
$nodes = @()
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$nodes += @(
[ToolVersionsListNode]::new("Ruby", $(Get-ToolcacheRubyVersions), '^\d+\.\d+', "List"),
[ToolVersionsListNode]::new("PyPy", $(Get-ToolcachePyPyVersions), '^\d+\.\d+', "List")
)
}
$nodes += @(
[ToolVersionsListNode]::new("Python", $(Get-ToolcachePythonVersions), '^\d+\.\d+', "List"),
[ToolVersionsListNode]::new("Node.js", $(Get-ToolcacheNodeVersions), '^\d+', "List"),
[ToolVersionsListNode]::new("Go", $(Get-ToolcacheGoVersions), '^\d+\.\d+', "List")
)
return $nodes
}
function Get-PowerShellModules {
$modules = (Get-ToolsetValue powershellModules).name
$modules | ForEach-Object {
$moduleName = $_
$moduleVersions = Get-Module -Name $moduleName -ListAvailable | Select-Object -ExpandProperty Version | Sort-Object -Unique
return [ToolVersionsListNode]::new($moduleName, $moduleVersions, '^\d+', "Inline")
}
}

View File

@@ -0,0 +1,36 @@
function Get-ApacheVersion {
$name = "httpd"
$port = 80
$version = brew list $name --versions | Take-Part -Part 1
$serviceStatus = (brew services list) -match $name | Take-Part -Part 1
$configFile = "$(brew --prefix)/etc/httpd/httpd.conf"
return [PsCustomObject]@{
"Name" = $name
"Version" = $version
"ConfigFile" = $configFile
"ServiceStatus" = $serviceStatus
"ListenPort" = $port
}
}
function Get-NginxVersion {
$name = "nginx"
$port = 80
$version = brew list $name --versions | Take-Part -Part 1
$serviceStatus = (brew services list) -match $name | Take-Part -Part 1
$configFile = "$(brew --prefix)/etc/nginx/nginx.conf"
return [PsCustomObject]@{
"Name" = $name
"Version" = $version
"ConfigFile" = $configFile
"ServiceStatus" = $serviceStatus
"ListenPort" = $port
}
}
function Build-WebServersSection {
return @(
(Get-ApacheVersion),
(Get-NginxVersion)
)
}

View File

@@ -0,0 +1,48 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
function Build-VSMacTable {
$vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions"
$defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default"
return $vsMacVersions | ForEach-Object {
$isDefault = $_ -eq $defaultVSMacVersion
$vsPath = "/Applications/Visual Studio $_.app"
if ($isDefault) {
$vsPath = "/Applications/Visual Studio.app"
}
$plistPath = "$vsPath/Contents/Info.plist"
$build = Run-Command "/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' '$plistPath'"
$defaultPostfix = $isDefault ? " (default)" : ""
[PSCustomObject] @{
"Version" = $_ + $defaultPostfix
"Build" = $build
"Path" = $vsPath
}
}
}
function Get-NUnitVersion {
$version = Run-Command "nunit3-console --version" | Select-Object -First 1 | Take-Part -Part 3
return $version
}
function Build-XamarinTable {
$xamarinBundles = Get-ToolsetValue "xamarin.bundles"
$defaultSymlink = Get-ToolsetValue "xamarin.bundle-default"
if ($defaultSymlink -eq "latest") {
$defaultSymlink = $xamarinBundles[0].symlink
}
return $xamarinBundles | ForEach-Object {
$defaultPostfix = ($_.symlink -eq $defaultSymlink ) ? " (default)" : ""
[PSCustomObject] @{
"symlink" = $_.symlink + $defaultPostfix
"Xamarin.Mono" = $_.mono
"Xamarin.iOS" = $_.ios
"Xamarin.Mac" = $_.mac
"Xamarin.Android" = $_.android
}
}
}

View File

@@ -0,0 +1,254 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
$os = Get-OSVersion
function Get-XcodePaths {
$xcodePaths = Get-ChildItemWithoutSymlinks "/Applications" -Filter "Xcode_*.app"
return $xcodePaths | Select-Object -ExpandProperty Fullname
}
function Get-XcodeSDKList {
param(
[Parameter(Mandatory)]
[string]$XcodeRootPath
)
$versionInfo = Get-XcodeVersionInfo -XcodeRootPath $XcodeRootPath
$xcodebuildPath = Get-XcodeToolPath -XcodeRootPath $XcodeRootPath -ToolName "xcodebuild"
if ($versionInfo.Version -le [System.Version]::Parse("9.4.1")) {
$output = Invoke-Expression "$xcodebuildPath -showsdks"
$sdkList = $output | Where-Object { $_ -Match "-sdk" }
return $sdkList | ForEach-Object {
$displayName, $canonicalName = $_.Split("-sdk")
return @{
canonicalName = $canonicalName.Trim()
displayName = $displayName.Trim()
}
}
}
[string]$output = Invoke-Expression "$xcodebuildPath -showsdks -json"
return $output | ConvertFrom-Json
}
function Get-XcodeInfoList {
$defaultXcodeRootPath = Get-DefaultXcodeRootPath
$xcodeInfo = @{}
Get-XcodePaths | ForEach-Object {
$xcodeRootPath = $_
Switch-Xcode -XcodeRootPath $xcodeRootPath
$versionInfo = Get-XcodeVersionInfo -XcodeRootPath $xcodeRootPath
$versionInfo.Path = $xcodeRootPath
$versionInfo.IsDefault = ($xcodeRootPath -eq $defaultXcodeRootPath)
$versionInfo.IsStable = Test-XcodeStableRelease -XcodeRootPath $xcodeRootPath
$xcodeInfo.Add($xcodeRootPath, [PSCustomObject] @{
VersionInfo = $versionInfo
SDKInfo = Get-XcodeSDKList -XcodeRootPath $xcodeRootPath
SimulatorsInfo = Get-XcodeSimulatorsInfo
})
}
Switch-Xcode -XcodeRootPath $defaultXcodeRootPath
return $xcodeInfo
}
function Get-XcodePlatformOrder {
param (
[Parameter(Mandatory)]
[string] $PlatformName
)
Switch ($PlatformName) {
"macOS" { 1 }
"iOS" { 2 }
"Simulator - iOS" { 3 }
"tvOS" { 4 }
"Simulator - tvOS" { 5 }
"watchOS" { 6 }
"Simulator - watchOS" { 7 }
Default { 100 }
}
}
function Get-XcodeCommandLineToolsVersion {
$xcodeCommandLineToolsVersion = Run-Command "pkgutil --pkg-info com.apple.pkg.CLTools_Executables" | Select -Index 1 | Take-Part -Part 1
return $xcodeCommandLineToolsVersion
}
function Build-XcodeTable {
param (
[Parameter(Mandatory)]
[hashtable] $xcodeInfo
)
$sortRules = @{
Expression = { $_.Version }
Descending = $true
}
$xcodeList = $xcodeInfo.Values | ForEach-Object { $_.VersionInfo } | Sort-Object $sortRules
return $xcodeList | ForEach-Object {
$defaultPostfix = If ($_.IsDefault) { " (default)" } else { "" }
$betaPostfix = If ($_.IsStable) { "" } else { " (beta)" }
return [PSCustomObject] @{
"Version" = $_.Version.ToString() + $betaPostfix + $defaultPostfix
"Build" = $_.Build
"Path" = $_.Path
}
}
}
function Build-XcodeDevicesList {
param (
[Parameter(Mandatory)][object] $XcodeInfo,
[Parameter(Mandatory)][object] $Runtime
)
$runtimeId = $Runtime.identifier
$runtimeName = $Runtime.name
$output = $XcodeInfo.SimulatorsInfo.devices.$runtimeId
if ($null -eq $output) {
$output = $XcodeInfo.SimulatorsInfo.devices.$runtimeName
}
return $output
}
function Build-XcodeSDKTable {
param (
[Parameter(Mandatory)]
[hashtable] $xcodeInfo
)
$sdkNames = @()
$xcodeInfo.Values | ForEach-Object {
$_.SDKInfo | ForEach-Object {
$sdkNames += $_.canonicalName
}
}
$sdkNames = $sdkNames | Select-Object -Unique
return $sdkNames | ForEach-Object {
$sdkName = $_
$sdkDisplayName = ""
$xcodeList = @()
$xcodeInfo.Values | ForEach-Object {
$sdk = $_.SDKInfo | Where-Object { $_.canonicalName -eq $sdkName } | Select-Object -First 1
if ($sdk) {
$sdkDisplayName = $sdk.displayName
$xcodeList += $_.VersionInfo.Version
}
}
$xcodeList = $xcodeList | Sort-Object
return [PSCustomObject] @{
"SDK" = $sdkDisplayName
"SDK Name" = $sdkName
"Xcode Version" = [String]::Join(", ", $xcodeList)
}
} | Sort-Object {
# Sort rule 1
$sdkNameParts = $_."SDK".Split(" ")
$platformName = [String]::Join(" ", $sdkNameParts[0..($sdkNameParts.Length - 2)])
return Get-XcodePlatformOrder $platformName
}, {
# Sort rule 2
$sdkNameParts = $_."SDK".Split(" ")
return [System.Version]::Parse($sdkNameParts[-1])
}
}
function Format-XcodeSimulatorName {
param(
[Parameter(Mandatory)][string] $Device
)
$formattedDeviceName = $Device.Replace("ʀ", "R")
return $formattedDeviceName
}
function Build-XcodeSimulatorsTable {
param (
[Parameter(Mandatory)]
[hashtable] $xcodeInfo
)
$runtimes = @()
$xcodeInfo.Values | ForEach-Object {
$_.SimulatorsInfo.runtimes | ForEach-Object {
$runtimes += $_
}
}
$runtimes = $runtimes | Sort-Object @{ Expression = { $_.identifier } } -Unique
return $runtimes | ForEach-Object {
$runtime = $_
$runtimeDevices = @()
$xcodeList = @()
$xcodeInfo.Values | ForEach-Object {
$runtimeFound = $_.SimulatorsInfo.runtimes | Where-Object { $_.identifier -eq $runtime.identifier } | Select-Object -First 1
if ($runtimeFound) {
$devicesToAdd = Build-XcodeDevicesList -XcodeInfo $_ -Runtime $runtimeFound
$runtimeDevices += $devicesToAdd | Select-Object -ExpandProperty name
$xcodeList += $_.VersionInfo.Version
}
}
$xcodeList = $xcodeList | Sort-Object
$runtimeDevices = $runtimeDevices | ForEach-Object { Format-XcodeSimulatorName $_ } | Select-Object -Unique
$sortedRuntimeDevices = $runtimeDevices | Sort-Object @{
Expression = { $_.Split(" ")[0] };
Descending = $true;
}, {
$_.Split(" ") | Select-Object -Skip 1 | Join-String -Separator " "
}
return [PSCustomObject] @{
"OS" = $runtime.name
"Xcode Version" = [String]::Join("<br>", $xcodeList)
"Simulators" = [String]::Join("<br>", $sortedRuntimeDevices)
}
} | Sort-Object {
# Sort rule 1
$sdkNameParts = $_."OS".Split(" ")
$platformName = [String]::Join(" ", $sdkNameParts[0..($sdkNameParts.Length - 2)])
return Get-XcodePlatformOrder $platformName
}, {
# Sort rule 2
$sdkNameParts = $_."OS".Split(" ")
return [System.Version]::Parse($sdkNameParts[-1])
}
}
function Build-XcodeSupportToolsSection {
$toolNodes = @()
$xcpretty = Run-Command "xcpretty --version"
$xcversion = Run-Command "xcversion --version" | Select-String "^[0-9]"
$toolNodes += [ToolVersionNode]::new("xcpretty", $xcpretty)
if ($os.IsBigSur -or $os.IsMonterey) {
$toolNodes += [ToolVersionNode]::new("xcversion", $xcversion)
}
$nomadOutput = Run-Command "gem list nomad-cli"
$nomadCLI = [regex]::matches($nomadOutput, "(\d+.){2}\d+").Value
$nomadShenzhenOutput = Run-Command "ipa -version"
$nomadShenzhen = [regex]::matches($nomadShenzhenOutput, "(\d+.){2}\d+").Value
if ($os.IsBigSur) {
$toolNodes += [ToolVersionNode]::new("Nomad CLI", $nomadCLI)
$toolNodes += [ToolVersionNode]::new("Nomad shenzhen CLI", $nomadShenzhen)
}
return $toolNodes
}