Implement new software report generator for macOS (#6690)

* Create environmentVariables.yml

* Update environmentVariables.yml

* Delete environmentVariables.yml

* Add new SoftwareReport generator

* Output generation fixes after review

* Add json output print in pipeline

* Modify json output print in pipeline

* Removed redundant space character
This commit is contained in:
bogdan-damian-bgd
2022-12-06 18:16:20 +01:00
committed by GitHub
parent fb3b6fd699
commit 69cdead4fc
10 changed files with 763 additions and 433 deletions

View File

@@ -6,7 +6,7 @@ param (
$ErrorActionPreference = "Stop"
Import-Module MarkdownPS
. ("$PSScriptRoot/SoftwareReport.Base.ps1")
Import-Module "$PSScriptRoot/SoftwareReport.Common.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Xcode.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Android.psm1" -DisableNameChecking
@@ -22,311 +22,246 @@ Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
# Operating System info
$os = Get-OSVersion
$markdown = ""
# OS info
$markdown += Build-OSInfoSection
$markdown += New-MDList -Style Unordered -Lines ("Image Version: {0}" -f $ImageName.Split('_')[1])
# Software report
$markdown += New-MDHeader "Installed Software" -Level 2
$markdown += New-MDHeader "Language and Runtime" -Level 3
$languageAndRuntimeList = @(
(Get-BashVersion)
(Get-MSBuildVersion)
(Get-NodeVersion)
(Get-NVMVersion)
(Get-NVMNodeVersionList)
(Get-PerlVersion)
(Get-PythonVersion)
(Get-Python3Version)
(Get-RubyVersion)
(Get-DotnetVersionList)
(Get-GoVersion)
(Get-JuliaVersion)
(Get-KotlinVersion)
(Get-PHPVersion)
(Get-ClangLLVMVersion)
(Get-GccVersion)
(Get-FortranVersion)
(Get-RVersion)
)
$osInfo = Build-OSInfoSection $ImageName
# To sort GCC and Gfortran correctly, we need to use natural sort https://gist.github.com/markwragg/e2a9dc05f3464103d6998298fb575d4e#file-sort-natural-ps1
$toNatural = { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) }
$markdown += New-MDList -Style Unordered -Lines ($languageAndRuntimeList | Sort-Object $toNatural)
# Software report
$softwareReport = [SoftwareReport]::new($osInfo)
$installedSoftware = $softwareReport.Root.AddHeaderNode("Installed Software")
# Language and Runtime
$languageAndRuntime = $installedSoftware.AddHeaderNode("Language and Runtime")
$languageAndRuntime.AddToolNode(".NET SDK", $(Get-DotnetVersionList))
$languageAndRuntime.AddToolNode("Bash", $(Get-BashVersion))
$languageAndRuntime.AddNodes($(Get-ClangLLVMVersions))
$languageAndRuntime.AddNodes($(Get-GccVersions))
$languageAndRuntime.AddNodes($(Get-FortranVersions))
$languageAndRuntime.AddToolNode("Go", $(Get-GoVersion))
$languageAndRuntime.AddToolNode("Julia", $(Get-JuliaVersion))
$languageAndRuntime.AddToolNode("Kotlin", $(Get-KotlinVersion))
$languageAndRuntime.AddToolNode("MSBuild", $(Get-MSBuildVersion))
$languageAndRuntime.AddToolNode("Node.js", $(Get-NodeVersion))
$languageAndRuntime.AddToolNode("NVM", $(Get-NVMVersion))
$languageAndRuntime.AddToolNode("NVM - Cached node versions:", $(Get-NVMNodeVersionList))
$languageAndRuntime.AddToolNode("Perl", $(Get-PerlVersion))
$languageAndRuntime.AddToolNode("PHP", $(Get-PHPVersion))
$languageAndRuntime.AddToolNode("Python", $(Get-PythonVersion))
$languageAndRuntime.AddToolNode("Python3", $(Get-Python3Version))
$languageAndRuntime.AddToolNode("R", $(Get-RVersion))
$languageAndRuntime.AddToolNode("Ruby", $(Get-RubyVersion))
# Package Management
$markdown += New-MDHeader "Package Management" -Level 3
$packageManagementList = @(
(Get-PipVersion -Version 2),
(Get-PipVersion -Version 3),
(Get-PipxVersion),
(Get-BundlerVersion),
(Get-CocoaPodsVersion),
(Get-CondaVersion),
(Get-HomebrewVersion),
(Get-NPMVersion),
(Get-YarnVersion),
(Get-NuGetVersion),
(Get-RubyGemsVersion),
(Get-ComposerVersion),
(Get-CarthageVersion),
(Get-VcpkgVersion)
)
$packageManagement = $installedSoftware.AddHeaderNode("Package Management")
$packageManagement.AddToolNode("Bundler", $(Get-BundlerVersion))
$packageManagement.AddToolNode("Carthage", $(Get-CarthageVersion))
$packageManagement.AddToolNode("CocoaPods", $(Get-CocoaPodsVersion))
$packageManagement.AddToolNode("Composer", $(Get-ComposerVersion))
$packageManagement.AddToolNode("Homebrew", $(Get-HomebrewVersion))
$packageManagement.AddToolNode("Miniconda", $(Get-CondaVersion))
$packageManagement.AddToolNode("NPM", $(Get-NPMVersion))
$packageManagement.AddToolNode("NuGet", $(Get-NuGetVersion))
$packageManagement.AddToolNode("Pip", $(Get-PipVersion -Version 2))
$packageManagement.AddToolNode("Pip3", $(Get-PipVersion -Version 3))
$packageManagement.AddToolNode("Pipx", $(Get-PipxVersion))
$packageManagement.AddToolNode("RubyGems", $(Get-RubyGemsVersion))
$packageManagement.AddToolNode("Vcpkg", $(Get-VcpkgVersion))
$packageManagement.AddToolNode("Yarn", $(Get-YarnVersion))
$markdown += New-MDList -Style Unordered -Lines ($packageManagementList | Sort-Object)
$markdown += New-MDHeader "Environment variables" -Level 4
$markdown += Build-PackageManagementEnvironmentTable | New-MDTable
$markdown += New-MDNewLine
$packageManagement.AddNode($(Build-PackageManagementEnvironmentTable))
# Project Management
$markdown += New-MDHeader "Project Management" -Level 3
$markdown += New-MDList -Style Unordered -Lines (@(
(Get-MavenVersion),
(Get-GradleVersion),
(Get-ApacheAntVersion),
(Get-SbtVersion)
) | Sort-Object
)
$projectanagement = $installedSoftware.AddHeaderNode("Project Management")
$projectanagement.AddToolNode("Apache Ant", $(Get-ApacheAntVersion))
$projectanagement.AddToolNode("Apache Maven", $(Get-MavenVersion))
$projectanagement.AddToolNode("Gradle", $(Get-GradleVersion))
$projectanagement.AddToolNode("Sbt", $(Get-SbtVersion))
# Utilities
$markdown += New-MDHeader "Utilities" -Level 3
$utilitiesList = @(
(Get-CurlVersion),
(Get-GitVersion),
(Get-GitLFSVersion),
(Get-GitHubCLIVersion),
(Get-HubVersion),
(Get-WgetVersion),
(Get-SVNVersion),
(Get-PackerVersion),
(Get-OpenSSLVersion),
(Get-JqVersion),
(Get-PostgresClientVersion),
(Get-PostgresServerVersion),
(Get-Aria2Version),
(Get-AzcopyVersion),
(Get-ZstdVersion),
(Get-BazelVersion),
(Get-BazeliskVersion),
(Get-MongoVersion),
(Get-MongodVersion),
(Get-7zipVersion),
(Get-BsdtarVersion),
(Get-GnuTarVersion),
(Get-GPGVersion),
(Get-SwitchAudioOsxVersion),
(Get-SoxVersion),
(Get-YqVersion),
(Get-ImageMagickVersion)
)
if ($os.IsLessThanMonterey) {
$utilitiesList += @(
(Get-HelmVersion)
)
}
if ($os.IsLessThanMonterey) {
$utilitiesList += @(
(Get-NewmanVersion)
)
}
$utilities = $installedSoftware.AddHeaderNode("Utilities")
$utilities.AddToolNode("7-Zip", $(Get-7zipVersion))
$utilities.AddToolNode("aria2", $(Get-Aria2Version))
$utilities.AddToolNode("azcopy", $(Get-AzcopyVersion))
$utilities.AddToolNode("bazel", $(Get-BazelVersion))
$utilities.AddToolNode("bazelisk", $(Get-BazeliskVersion))
$utilities.AddToolNode("bsdtar", $(Get-BsdtarVersion))
$utilities.AddToolNode("Curl", $(Get-CurlVersion))
$utilities.AddToolNode("Git", $(Get-GitVersion))
$utilities.AddToolNode("Git LFS", $(Get-GitLFSVersion))
$utilities.AddToolNode("GitHub CLI", $(Get-GitHubCLIVersion))
if ($os.IsCatalina) {
$utilitiesList += @(
(Get-ParallelVersion)
)
$utilities.AddToolNode("GNU parallel", $(Get-ParallelVersion))
}
$utilities.AddToolNode("GNU Tar", $(Get-GnuTarVersion))
$utilities.AddToolNode("GNU Wget", $(Get-WgetVersion))
$utilities.AddToolNode("gpg (GnuPG)", $(Get-GPGVersion))
if ($os.IsLessThanMonterey) {
$utilities.AddToolNode("helm", $(Get-HelmVersion))
}
$utilities.AddToolNode("Hub CLI", $(Get-HubVersion))
$utilities.AddToolNode("ImageMagick", $(Get-ImageMagickVersion))
$utilities.AddToolNode("jq", $(Get-JqVersion))
$utilities.AddToolNode("mongo", $(Get-MongoVersion))
$utilities.AddToolNode("mongod", $(Get-MongodVersion))
if ($os.IsLessThanMonterey) {
$utilities.AddToolNode("Newman", $(Get-NewmanVersion))
}
$utilities.AddToolNode("OpenSSL", $(Get-OpenSSLVersion))
$utilities.AddToolNode("Packer", $(Get-PackerVersion))
$utilities.AddToolNode("PostgreSQL", $(Get-PostgresServerVersion))
$utilities.AddToolNode("psql (PostgreSQL)", $(Get-PostgresClientVersion))
$utilities.AddToolNode("Sox", $(Get-SoxVersion))
$utilities.AddToolNode("Subversion (SVN)", $(Get-SVNVersion))
$utilities.AddToolNode("Switchaudio-osx", $(Get-SwitchAudioOsxVersion))
if (-not $os.IsBigSur) {
$utilitiesList += @(
(Get-VagrantVersion),
(Get-VirtualBoxVersion)
)
$utilities.AddToolNode("Vagrant", $(Get-VagrantVersion))
$utilities.AddToolNode("VirtualBox", $(Get-VirtualBoxVersion))
}
$markdown += New-MDList -Style Unordered -Lines ($utilitiesList | Sort-Object)
$utilities.AddToolNode("yq", $(Get-YqVersion))
$utilities.AddToolNode("zstd", $(Get-ZstdVersion))
# Tools
$markdown += New-MDHeader "Tools" -Level 3
$toolsList = @(
(Get-JazzyVersion),
(Get-FastlaneVersion),
(Get-CmakeVersion),
(Get-AppCenterCLIVersion),
(Get-AzureCLIVersion),
(Get-AzureDevopsVersion),
(Get-AWSCLIVersion),
(Get-AWSSAMCLIVersion),
(Get-AWSSessionManagerCLIVersion)
)
if (-not $os.IsCatalina) {
$toolsList += @(
(Get-CodeQLBundleVersion)
)
}
$tools = $installedSoftware.AddHeaderNode("Tools")
if ($os.IsLessThanMonterey) {
$toolsList += @(
(Get-AliyunCLIVersion)
)
$tools.AddToolNode("Aliyun CLI", $(Get-AliyunCLIVersion))
}
$toolsList += @(
(Get-XcodeCommandLineToolsVersion),
(Get-SwigVersion),
(Get-BicepVersion),
(Get-GHCupVersion),
(Get-GHCVersion),
(Get-CabalVersion),
(Get-StackVersion),
(Get-SwiftFormatVersion)
)
$tools.AddToolNode("App Center CLI", $(Get-AppCenterCLIVersion))
$tools.AddToolNode("AWS CLI", $(Get-AWSCLIVersion))
$tools.AddToolNode("AWS SAM CLI", $(Get-AWSSAMCLIVersion))
$tools.AddToolNode("AWS Session Manager CLI", $(Get-AWSSessionManagerCLIVersion))
$tools.AddToolNode("Azure CLI (azure-devops)", $(Get-AzureDevopsVersion))
$tools.AddToolNode("Azure CLI", $(Get-AzureCLIVersion))
$tools.AddToolNode("Bicep CLI", $(Get-BicepVersion))
$tools.AddToolNode("Cabal", $(Get-CabalVersion))
$tools.AddToolNode("Cmake", $(Get-CmakeVersion))
if (-not $os.IsCatalina) {
$toolsList += @(
(Get-ColimaVersion)
)
$tools.AddToolNode("CodeQL Action Bundle", $(Get-CodeQLBundleVersion))
}
$markdown += New-MDList -Style Unordered -Lines ($toolsList | Sort-Object)
if (-not $os.IsCatalina) {
$tools.AddToolNode("Colima", $(Get-ColimaVersion))
}
$tools.AddToolNode("Fastlane", $(Get-FastlaneVersion))
$tools.AddToolNode("GHC", $(Get-GHCVersion))
$tools.AddToolNode("GHCup", $(Get-GHCupVersion))
$tools.AddToolNode("Jazzy", $(Get-JazzyVersion))
$tools.AddToolNode("Stack", $(Get-StackVersion))
$tools.AddToolNode("SwiftFormat", $(Get-SwiftFormatVersion))
$tools.AddToolNode("Swig", $(Get-SwigVersion))
$tools.AddToolNode("Xcode Command Line Tools", $(Get-XcodeCommandLineToolsVersion))
# Linters
$markdown += New-MDHeader "Linters" -Level 3
$lintersList = @(
(Get-YamllintVersion),
(Get-SwiftLintVersion)
)
$linters = $installedSoftware.AddHeaderNode("Linters")
$linters.AddToolNode("Swift", $(Get-SwiftLintVersion))
$linters.AddToolNode("Yamllint", $(Get-YamllintVersion))
$markdown += New-MDList -Style Unordered -Lines ($lintersList | Sort-Object)
# Browsers
$browsers = $installedSoftware.AddHeaderNode("Browsers")
$browsers.AddNodes($(Build-BrowserSection))
$browsers.AddNode($(Build-BrowserWebdriversEnvironmentTable))
$markdown += New-MDHeader "Browsers" -Level 3
$markdown += Get-BrowserSection
$markdown += New-MDHeader "Environment variables" -Level 4
$markdown += Build-BrowserWebdriversEnvironmentTable | New-MDTable
$markdown += New-MDNewLine
# Java
$java = $installedSoftware.AddHeaderNode("Java")
$java.AddTableNode($(Get-JavaVersions))
$markdown += New-MDHeader "Java" -Level 3
$markdown += Get-JavaVersions | New-MDTable
$markdown += New-MDNewLine
$markdown += New-MDHeader "GraalVM" -Level 3
$markdown += Build-GraalVMTable | New-MDTable
$markdown += New-MDNewLine
# Graal
$graalvm = $installedSoftware.AddHeaderNode("GraalVM")
$graalvm.AddTableNode($(Build-GraalVMTable))
# Toolcache
$markdown += Build-ToolcacheSection
$markdown += New-MDNewLine
$toolcache = $installedSoftware.AddHeaderNode("Cached Tools")
$toolcache.AddNodes($(Build-ToolcacheSection))
$markdown += New-MDHeader "Rust Tools" -Level 3
$markdown += New-MDList -Style Unordered -Lines (@(
(Get-RustVersion),
(Get-RustupVersion),
(Get-RustdocVersion),
(Get-RustCargoVersion)
) | Sort-Object
)
# Rust
$rust = $installedSoftware.AddHeaderNode("Rust Tools")
$rust.AddToolNode("Cargo", $(Get-RustCargoVersion))
$rust.AddToolNode("Rust", $(Get-RustVersion))
$rust.AddToolNode("Rustdoc", $(Get-RustdocVersion))
$rust.AddToolNode("Rustup", $(Get-RustupVersion))
$markdown += New-MDHeader "Packages" -Level 4
$markdown += New-MDList -Style Unordered -Lines (@(
(Get-Bindgen),
(Get-Cbindgen),
(Get-Cargooutdated),
(Get-Cargoaudit),
(Get-RustfmtVersion),
(Get-RustClippyVersion)
) | Sort-Object
)
$rustPackages = $rust.AddHeaderNode("Packages")
$rustPackages.AddToolNode("Bindgen", $(Get-Bindgen))
$rustPackages.AddToolNode("Cargo-audit", $(Get-Cargoaudit))
$rustPackages.AddToolNode("Cargo-outdated", $(Get-Cargooutdated))
$rustPackages.AddToolNode("Cbindgen", $(Get-Cbindgen))
$rustPackages.AddToolNode("Clippy", $(Get-RustClippyVersion))
$rustPackages.AddToolNode("Rustfmt", $(Get-RustfmtVersion))
$markdown += New-MDHeader "PowerShell Tools" -Level 3
$markdown += New-MDList -Lines (Get-PowershellVersion) -Style Unordered
# PowerShell
$powerShell = $installedSoftware.AddHeaderNode("PowerShell Tools")
$powerShell.AddToolNode("PowerShell", $(Get-PowershellVersion))
$markdown += New-MDHeader "PowerShell Modules" -Level 4
$markdown += Get-PowerShellModules | New-MDTable
$markdown += New-MDNewLine
$powerShellModules = $powerShell.AddHeaderNode("PowerShell Modules")
$powerShellModules.AddTableNode($(Get-PowerShellModules))
# Web Servers
$markdown += Build-WebServersSection
$webServers = $installedSoftware.AddHeaderNode("Web Servers")
$webServers.AddTableNode($(Build-WebServersSection))
# Xamarin section
$markdown += New-MDHeader "Xamarin" -Level 3
$markdown += New-MDHeader "Visual Studio for Mac" -Level 4
$markdown += Build-VSMacTable | New-MDTable
$markdown += New-MDNewLine
$xamarin = $installedSoftware.AddHeaderNode("Xamarin")
$vsForMac = $xamarin.AddHeaderNode("Visual Studio for Mac")
$vsForMac.AddTableNode($(Build-VSMacTable))
if (-not $os.IsCatalina) {
$markdown += New-MDHeader "Notes:" -Level 5
$reportVS = @'
```
$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"
```
'@
$markdown += New-MDParagraph -Lines $reportVS
$vsForMacNotes = $vsForMac.AddHeaderNode("Notes")
$vsForMacNotes.AddNoteNode($note)
}
$markdown += New-MDHeader "Xamarin bundles" -Level 4
$markdown += Build-XamarinTable | New-MDTable
$markdown += New-MDNewLine
$xamarinBundles = $xamarin.AddHeaderNode("Xamarin bundles")
$xamarinBundles.AddTableNode($(Build-XamarinTable))
$markdown += New-MDHeader "Unit Test Framework" -Level 4
$markdown += New-MDList -Lines @(Get-NUnitVersion) -Style Unordered
$unitTestFramework = $xamarin.AddHeaderNode("Unit Test Framework")
$unitTestFramework.AddToolNode("NUnit", $(Get-NUnitVersion))
# Xcode section
$xcode = $installedSoftware.AddHeaderNode("Xcode")
# First run doesn't provide full data about devices and runtimes
Get-XcodeInfoList | Out-Null
# Xcode section
$xcodeInfo = Get-XcodeInfoList
$markdown += New-MDHeader "Xcode" -Level 3
$markdown += Build-XcodeTable $xcodeInfo | New-MDTable
$markdown += New-MDNewLine
$xcode.AddTableNode($(Build-XcodeTable $xcodeInfo))
$markdown += Build-XcodeSupportToolsSection
$xcodeTools = $xcode.AddHeaderNode("Xcode Support Tools")
$xcodeTools.AddNodes($(Build-XcodeSupportToolsSection))
$markdown += New-MDHeader "Installed SDKs" -Level 4
$markdown += Build-XcodeSDKTable $xcodeInfo | New-MDTable
$markdown += New-MDNewLine
$installedSdks = $xcode.AddHeaderNode("Installed SDKs")
$installedSdks.AddTableNode($(Build-XcodeSDKTable $xcodeInfo))
$markdown += New-MDHeader "Installed Simulators" -Level 4
$markdown += Build-XcodeSimulatorsTable $xcodeInfo | New-MDTable
$markdown += New-MDNewLine
$installedSimulators = $xcode.AddHeaderNode("Installed Simulators")
$installedSimulators.AddTableNode($(Build-XcodeSimulatorsTable $xcodeInfo))
# Android section
$markdown += New-MDHeader "Android" -Level 3
$android = $installedSoftware.AddHeaderNode("Android")
$androidTable = Build-AndroidTable
if ($os.IsCatalina) {
$androidTable += Get-IntelHaxmVersion
}
$markdown += $androidTable | New-MDTable
$markdown += New-MDNewLine
$markdown += New-MDHeader "Environment variables" -Level 4
$markdown += Build-AndroidEnvironmentTable | New-MDTable
$markdown += New-MDNewLine
$android.AddTableNode($androidTable)
$markdown += New-MDHeader "Miscellaneous" -Level 3
$markdown += New-MDList -Style Unordered -Lines (@(
(Get-ZlibVersion),
(Get-LibXextVersion),
(Get-LibXftVersion),
(Get-TclTkVersion)
) | Sort-Object
)
$androidEnv = $android.AddHeaderNode("Environment variables")
$androidEnv.AddTableNode($(Build-AndroidEnvironmentTable))
$miscellaneous = $installedSoftware.AddHeaderNode("Miscellaneous")
$miscellaneous.AddToolNode("libXext", $(Get-LibXextVersion))
$miscellaneous.AddToolNode("libXft", $(Get-LibXftVersion))
$miscellaneous.AddToolNode("Tcl/Tk", $(Get-TclTkVersion))
$miscellaneous.AddToolNode("Zlib", $(Get-ZlibVersion))
if ($os.IsMonterey) {
$markdown += New-MDHeader "Environment variables" -Level 4
$markdown += Build-MiscellaneousEnvironmentTable | New-MDTable
$markdown += New-MDNewLine
$miscellaneousEnv = $miscellaneous.AddHeaderNode("Environment variables")
$miscellaneousEnv.AddTableNode($(Build-MiscellaneousEnvironmentTable))
$markdown += New-MDHeader "Notes:" -Level 5
$misc = @'
```
$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.
```
'@
$markdown += New-MDParagraph -Lines $misc
$miscellaneousEnvNotes = $miscellaneousEnv.AddHeaderNode("Notes")
$miscellaneousEnvNotes.AddNoteNode($notes)
}
#
@@ -334,10 +269,9 @@ $markdown += New-MDParagraph -Lines $misc
#
$dateTime = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
$systemInfo = [string]::Join([System.Environment]::NewLine, @(
"Date: ${dateTime}",
"Image name: ${ImageName}"
))
"Date: ${dateTime}",
"Image name: ${ImageName}"
))
if (-not (Test-Path $OutputDirectory)) { New-Item -Path $OutputDirectory -ItemType Directory | Out-Null }
@@ -346,4 +280,6 @@ if (-not (Test-Path $OutputDirectory)) { New-Item -Path $OutputDirectory -ItemTy
#
Write-Host $markdownExtended
$systemInfo | Out-File -FilePath "${OutputDirectory}/systeminfo.txt" -Encoding UTF8NoBOM
$markdown | Out-File -FilePath "${OutputDirectory}/systeminfo.md" -Encoding UTF8NoBOM
$softwareReport.ToJson() | Out-File -FilePath "${OutputDirectory}/systeminfo.json" -Encoding UTF8NoBOM
$softwareReport.ToMarkdown() | Out-File -FilePath "${OutputDirectory}/systeminfo.md" -Encoding UTF8NoBOM