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

@@ -107,7 +107,11 @@ jobs:
- bash: | - bash: |
cat "$(Build.ArtifactStagingDirectory)/systeminfo.md" cat "$(Build.ArtifactStagingDirectory)/systeminfo.md"
displayName: Print software report displayName: Print markdown software report
- bash: |
cat "$(Build.ArtifactStagingDirectory)/systeminfo.json"
displayName: Print json software report
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
inputs: inputs:

View File

@@ -20,7 +20,7 @@ if is_Monterey; then
fi fi
# Put documentation to $HOME root # Put documentation to $HOME root
cp $HOME/image-generation/output/software-report/systeminfo.txt $HOME/image-generation/output/software-report/systeminfo.md $HOME/ cp $HOME/image-generation/output/software-report/systeminfo.* $HOME/
# Put build vm assets scripts to proper directory # Put build vm assets scripts to proper directory
mkdir -p /usr/local/opt/$USER/scripts mkdir -p /usr/local/opt/$USER/scripts

View File

@@ -0,0 +1,370 @@
class SoftwareReport {
[HeaderNode] $Root
SoftwareReport([String] $Title) {
$this.Root = [HeaderNode]::new($Title)
}
SoftwareReport([HeaderNode] $Root) {
$this.Root = $Root
}
[String] ToJson() {
return $this.Root.ToJsonObject() | ConvertTo-Json -Depth 10
}
static [SoftwareReport] FromJson($jsonString) {
$jsonObj = $jsonString | ConvertFrom-Json
$rootNode = [SoftwareReport]::ParseNodeFromObject($jsonObj)
return [SoftwareReport]::new($rootNode)
}
[String] ToMarkdown() {
return $this.Root.ToMarkdown(1).Trim()
}
# This method is Nodes factory that simplifies parsing different types of notes
# Every node has own logic of parsing and this method just invokes "FromJsonObject" of correct node type
static [BaseNode] ParseNodeFromObject($jsonObj) {
if ($jsonObj.NodeType -eq [HeaderNode].Name) {
return [HeaderNode]::FromJsonObject($jsonObj)
} elseif ($jsonObj.NodeType -eq [ToolNode].Name) {
return [ToolNode]::FromJsonObject($jsonObj)
} elseif ($jsonObj.NodeType -eq [ToolVersionsNode].Name) {
return [ToolVersionsNode]::FromJsonObject($jsonObj)
} elseif ($jsonObj.NodeType -eq [TableNode].Name) {
return [TableNode]::FromJsonObject($jsonObj)
} elseif ($jsonObj.NodeType -eq [NoteNode].Name) {
return [NoteNode]::FromJsonObject($jsonObj)
}
throw "Unknown node type in ParseNodeFromObject '$($jsonObj.NodeType)'"
}
}
# class BaseNode doesn't really have any business logic or functionality
# We just create it to unite all types of Nodes and differ them from "object" type
class BaseNode {}
# It is a node type to describe headers: "# Node.js"
# Header has Title and children nodes (HeaderNode is the single node type who has children)
class HeaderNode: BaseNode {
[String] $Title
[System.Collections.ArrayList] $Children
HeaderNode([String] $Title) {
$this.Title = $Title
$this.Children = @()
}
[void] AddNode([BaseNode] $node) {
if ($node.GetType() -eq [TableNode]) {
$existingTableNodesCount = $this.Children.Where({ $_.GetType() -eq [TableNode] }).Count
if ($existingTableNodesCount -gt 0) {
throw "Having multiple TableNode on the same header level is not supported"
}
}
$this.Children.Add($node)
}
[void] AddNodes([Array] $nodes) {
$nodes | ForEach-Object { $this.AddNode($_) }
}
[HeaderNode] AddHeaderNode([String] $Title) {
$node = [HeaderNode]::new($Title)
$this.AddNode($node)
return $node
}
[void] AddToolNode([String] $ToolName, [String] $Version) {
$this.AddNode([ToolNode]::new($ToolName, $Version))
}
[void] AddToolVersionsNode([String] $ToolName, [Array] $Version) {
$this.AddNode([ToolVersionsNode]::new($ToolName, $Version))
}
[void] AddTableNode([Array] $Table) {
$this.AddNode([TableNode]::FromObjectsArray($Table))
}
[void] AddNoteNode([String] $Content) {
$this.AddNode([NoteNode]::new($Content))
}
[String] ToMarkdown($level) {
$sb = [System.Text.StringBuilder]::new()
$sb.AppendLine()
$sb.AppendLine("$("#" * $level) $($this.Title)")
$this.Children | ForEach-Object {
$sb.AppendLine($_.ToMarkdown($level + 1))
}
return $sb.ToString().TrimEnd()
}
[PSCustomObject] ToJsonObject() {
return [PSCustomObject]@{
NodeType = $this.GetType().Name
Title = $this.Title
Children = $this.Children | ForEach-Object { $_.ToJsonObject() }
}
}
static [HeaderNode] FromJsonObject($jsonObj) {
$node = [HeaderNode]::new($jsonObj.Title)
$jsonObj.Children | Where-Object { $_ } | ForEach-Object { $node.AddNode([SoftwareReport]::ParseNodeFromObject($_)) }
return $node
}
[Boolean] IsSimilarTo([BaseNode] $OtherNode) {
if ($OtherNode.GetType() -ne [HeaderNode]) {
return $false
}
return $this.Title -eq $OtherNode.Title
}
[Boolean] IsIdenticalTo([BaseNode] $OtherNode) {
return $this.IsSimilarTo($OtherNode)
}
}
# It is a node type to describe the single tool "Bash 5.1.16(1)-release"
class ToolNode: BaseNode {
[String] $ToolName
[String] $Version
ToolNode([String] $ToolName, [String] $Version) {
$this.ToolName = $ToolName
$this.Version = $Version
}
[String] ToMarkdown($level) {
return "- $($this.ToolName) $($this.Version)"
}
[String] ToString() {
return "$($this.ToolName) $($this.Version)"
}
[PSCustomObject] ToJsonObject() {
return [PSCustomObject]@{
NodeType = $this.GetType().Name
ToolName = $this.ToolName
Version = $this.Version
}
}
static [BaseNode] FromJsonObject($jsonObj) {
return [ToolNode]::new($jsonObj.ToolName, $jsonObj.Version)
}
[Boolean] IsSimilarTo([BaseNode] $OtherNode) {
if ($OtherNode.GetType() -ne [ToolNode]) {
return $false
}
# Don't compare by Version in SimilarTo method
# It is necessary to treat changing of tool version as "ChangedNodes" rather than "RemovedNodes" + "AddedNodes"
return $this.ToolName -eq $OtherNode.ToolName
}
[Boolean] IsIdenticalTo([BaseNode] $OtherNode) {
return $this.IsSimilarTo($OtherNode) -and $this.Version -eq $OtherNode.Version
}
}
# It is a node type to describe the single tool "Toolcache Node.js 14.17.6 16.2.0 18.2.3"
class ToolVersionsNode: BaseNode {
[String] $ToolName
[Array] $Versions
ToolVersionsNode([String] $ToolName, [Array] $Versions) {
$this.ToolName = $ToolName
$this.Versions = $Versions
}
[String] ToMarkdown($level) {
$sb = [System.Text.StringBuilder]::new()
$sb.AppendLine()
$sb.AppendLine("$("#" * $level) $($this.ToolName)")
$this.Versions | ForEach-Object {
$sb.AppendLine("- $_")
}
return $sb.ToString().TrimEnd()
}
[String] ToString() {
return "$($this.ToolName) $($this.Versions -join ', ')"
}
[PSCustomObject] ToJsonObject() {
return [PSCustomObject]@{
NodeType = $this.GetType().Name
ToolName = $this.ToolName
Versions = $this.Versions
}
}
static [ToolVersionsNode] FromJsonObject($jsonObj) {
return [ToolVersionsNode]::new($jsonObj.ToolName, $jsonObj.Versions)
}
[Boolean] IsSimilarTo([BaseNode] $OtherNode) {
if ($OtherNode.GetType() -ne [ToolVersionsNode]) {
return $false
}
return $this.ToolName -eq $OtherNode.ToolName
}
[Boolean] IsIdenticalTo([BaseNode] $OtherNode) {
if (-not $this.IsSimilarTo($OtherNode)) {
return $false
}
return ($this.Versions -join " ") -eq ($OtherNode.Versions -join " ")
}
}
# It is a node type to describe tables
class TableNode: BaseNode {
# It is easier to store the table as rendered lines because we will simplify finding differences in rows later
[String] $Headers
[System.Collections.ArrayList] $Rows
TableNode($Headers, $Rows) {
$this.Headers = $Headers
$this.Rows = $Rows
}
static [TableNode] FromObjectsArray([Array] $Table) {
# take column names from the first row in table because all rows that should have the same columns
[String] $tableHeaders = [TableNode]::ArrayToTableRow($Table[0].PSObject.Properties.Name)
[System.Collections.ArrayList] $tableRows = @()
$Table | ForEach-Object {
$tableRows.Add([TableNode]::ArrayToTableRow($_.PSObject.Properties.Value))
}
return [TableNode]::new($tableHeaders, $tableRows)
}
[String] ToMarkdown($level) {
$maxColumnWidths = $this.Headers.Split("|") | ForEach-Object { $_.Length }
$columnsCount = $maxColumnWidths.Count
$this.Rows | ForEach-Object {
$columnWidths = $_.Split("|") | ForEach-Object { $_.Length }
for ($colIndex = 0; $colIndex -lt $columnsCount; $colIndex++) {
$maxColumnWidths[$colIndex] = [Math]::Max($maxColumnWidths[$colIndex], $columnWidths[$colIndex])
}
}
$delimeterLine = [String]::Join("|", @("-") * $columnsCount)
$sb = [System.Text.StringBuilder]::new()
@($this.Headers) + @($delimeterLine) + $this.Rows | ForEach-Object {
$sb.Append("|")
$row = $_.Split("|")
for ($colIndex = 0; $colIndex -lt $columnsCount; $colIndex++) {
$padSymbol = $row[$colIndex] -eq "-" ? "-" : " "
$cellContent = $row[$colIndex].PadRight($maxColumnWidths[$colIndex], $padSymbol)
$sb.Append(" $($cellContent) |")
}
$sb.AppendLine()
}
return $sb.ToString().TrimEnd()
}
[PSCustomObject] ToJsonObject() {
return [PSCustomObject]@{
NodeType = $this.GetType().Name
Headers = $this.Headers
Rows = $this.Rows
}
}
static [TableNode] FromJsonObject($jsonObj) {
return [TableNode]::new($jsonObj.Headers, $jsonObj.Rows)
}
[Boolean] IsSimilarTo([BaseNode] $OtherNode) {
if ($OtherNode.GetType() -ne [TableNode]) {
return $false
}
# We don't support having multiple TableNode instances on the same header level so such check is fine
return $true
}
[Boolean] IsIdenticalTo([BaseNode] $OtherNode) {
if (-not $this.IsSimilarTo($OtherNode)) {
return $false
}
if ($this.Headers -ne $OtherNode.Headers) {
return $false
}
if ($this.Rows.Count -ne $OtherNode.Rows.Count) {
return $false
}
for ($rowIndex = 0; $rowIndex -lt $this.Rows.Count; $rowIndex++) {
if ($this.Rows[$rowIndex] -ne $OtherNode.Rows[$rowIndex]) {
return $false
}
}
return $true
}
hidden static [String] ArrayToTableRow([Array] $Values) {
return [String]::Join("|", $Values)
}
}
class NoteNode: BaseNode {
[String] $Content
NoteNode([String] $Content) {
$this.Content = $Content
}
[String] ToMarkdown($level) {
return @(
'```',
$this.Content,
'```'
) -join "`n"
}
[PSCustomObject] ToJsonObject() {
return [PSCustomObject]@{
NodeType = $this.GetType().Name
Content = $this.Content
}
}
static [NoteNode] FromJsonObject($jsonObj) {
return [NoteNode]::new($jsonObj.Content)
}
[Boolean] IsSimilarTo([BaseNode] $OtherNode) {
if ($OtherNode.GetType() -ne [NoteNode]) {
return $false
}
return $this.Content -eq $OtherNode.Content
}
[Boolean] IsIdenticalTo([BaseNode] $OtherNode) {
return $this.IsSimilarTo($OtherNode)
}
}

View File

@@ -1,64 +1,70 @@
function Get-BrowserSection { function Build-BrowserSection {
return New-MDList -Style Unordered -Lines @( return @(
(Get-SafariVersion), [ToolNode]::new("Safari", $(Get-SafariVersion))
(Get-SafariDriverVersion), [ToolNode]::new("SafariDriver", $(Get-SafariDriverVersion))
(Get-ChromeVersion), [ToolNode]::new("Google Chrome", $(Get-ChromeVersion))
(Get-ChromeDriverVersion), [ToolNode]::new("ChromeDriver", $(Get-ChromeDriverVersion))
(Get-EdgeVersion), [ToolNode]::new("Microsoft Edge", $(Get-EdgeVersion))
(Get-EdgeDriverVersion), [ToolNode]::new("Microsoft Edge WebDriver", $(Get-EdgeDriverVersion))
(Get-FirefoxVersion), [ToolNode]::new("Mozilla Firefox", $(Get-FirefoxVersion))
(Get-GeckodriverVersion), [ToolNode]::new("geckodriver", $(Get-GeckodriverVersion))
(Get-SeleniumVersion) [ToolNode]::new("Selenium server", $(Get-SeleniumVersion))
) )
} }
function Get-SafariVersion { function Get-SafariVersion {
$version = Run-Command "defaults read /Applications/Safari.app/Contents/Info CFBundleShortVersionString" $version = Run-Command "defaults read /Applications/Safari.app/Contents/Info CFBundleShortVersionString"
$build = Run-Command "defaults read /Applications/Safari.app/Contents/Info CFBundleVersion" $build = Run-Command "defaults read /Applications/Safari.app/Contents/Info CFBundleVersion"
"Safari $version ($build)" return "$version ($build)"
} }
function Get-SafariDriverVersion { function Get-SafariDriverVersion {
$version = Run-Command "safaridriver --version" | Take-Part -Part 3,4 $version = Run-Command "safaridriver --version" | Take-Part -Part 3,4
"SafariDriver $version" return $version
} }
function Get-ChromeVersion { function Get-ChromeVersion {
$chromePath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" $chromePath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
return Run-Command "'${chromePath}' --version" $version = Run-Command "'${chromePath}' --version"
return ($version -replace ("^Google Chrome")).Trim()
} }
function Get-ChromeDriverVersion { function Get-ChromeDriverVersion {
$rawOutput = Run-Command "chromedriver --version" $rawOutput = Run-Command "chromedriver --version"
$version = $rawOutput | Take-Part -Part 1 $version = $rawOutput | Take-Part -Part 1
return "ChromeDriver ${version}" return $version
} }
function Get-EdgeVersion { function Get-EdgeVersion {
$edgePath = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" $edgePath = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
return Run-Command "'${edgePath}' --version" $version = Run-Command "'${edgePath}' --version"
return ($version -replace ("^Microsoft Edge")).Trim()
} }
function Get-EdgeDriverVersion { function Get-EdgeDriverVersion {
return Run-Command "msedgedriver --version" | Take-Part -Part 0,1,2,3 return Run-Command "msedgedriver --version" | Take-Part -Part 3
} }
function Get-FirefoxVersion { function Get-FirefoxVersion {
$firefoxPath = "/Applications/Firefox.app/Contents/MacOS/firefox" $firefoxPath = "/Applications/Firefox.app/Contents/MacOS/firefox"
return Run-Command "'${firefoxPath}' --version" $version = Run-Command "'${firefoxPath}' --version"
return ($version -replace "^Mozilla Firefox").Trim()
} }
function Get-GeckodriverVersion { function Get-GeckodriverVersion {
return Run-Command "geckodriver --version" | Select-Object -First 1 $version = Run-Command "geckodriver --version" | Select-Object -First 1
return ($version -replace "^geckodriver").Trim()
} }
function Get-SeleniumVersion { function Get-SeleniumVersion {
$seleniumVersion = (Get-ChildItem -Path "/usr/local/Cellar/selenium-server*/*").Name $seleniumVersion = (Get-ChildItem -Path "/usr/local/Cellar/selenium-server*/*").Name
return "Selenium server $seleniumVersion" return $seleniumVersion
} }
function Build-BrowserWebdriversEnvironmentTable { function Build-BrowserWebdriversEnvironmentTable {
return @( $node = [HeaderNode]::new("Environment variables")
$table = @(
@{ @{
"Name" = "CHROMEWEBDRIVER" "Name" = "CHROMEWEBDRIVER"
"Value" = $env:CHROMEWEBDRIVER "Value" = $env:CHROMEWEBDRIVER
@@ -77,4 +83,8 @@ function Build-BrowserWebdriversEnvironmentTable {
"Value" = $_.Value "Value" = $_.Value
} }
} }
$node.AddTableNode($table)
return $node
} }

View File

@@ -1,12 +1,12 @@
function Get-BashVersion { function Get-BashVersion {
$version = bash -c 'echo ${BASH_VERSION}' $version = bash -c 'echo ${BASH_VERSION}'
return "Bash $version" return $version
} }
function Get-DotnetVersionList { function Get-DotnetVersionList {
$sdkRawList = Run-Command "dotnet --list-sdks" $sdkRawList = Run-Command "dotnet --list-sdks"
$sdkVersionList = $sdkRawList | ForEach-Object { Take-Part $_ -Part 0 } $sdkVersionList = $sdkRawList | ForEach-Object { Take-Part $_ -Part 0 }
return ".NET SDK " + [string]::Join(" ", $sdkVersionList) return [string]::Join(" ", $sdkVersionList)
} }
function Get-GoVersion { function Get-GoVersion {
@@ -15,101 +15,109 @@ function Get-GoVersion {
$goOutput = $goOutput.Substring(2) $goOutput = $goOutput.Substring(2)
} }
return "Go $goOutput" return $goOutput
} }
function Get-RVersion { function Get-RVersion {
$rVersion = Run-Command "R --version | grep 'R version'" | Take-Part -Part 2 $rVersion = Run-Command "R --version | grep 'R version'" | Take-Part -Part 2
return "R $rVersion" return $rVersion
} }
function Get-RustVersion { function Get-RustVersion {
$rustVersion = Run-Command "rustc --version" | Take-Part -Part 1 $rustVersion = Run-Command "rustc --version" | Take-Part -Part 1
return "Rust $rustVersion" return $rustVersion
} }
function Get-RustfmtVersion { function Get-RustfmtVersion {
$version = Run-Command "rustfmt --version" | Take-Part -Part 1 $version = Run-Command "rustfmt --version" | Take-Part -Part 1
return "Rustfmt $version" return $version
} }
function Get-RustdocVersion { function Get-RustdocVersion {
$version = Run-Command "rustdoc --version" | Take-Part -Part 1 $version = Run-Command "rustdoc --version" | Take-Part -Part 1
return "Rustdoc $version" return $version
} }
function Get-RustCargoVersion { function Get-RustCargoVersion {
$version = Run-Command "cargo --version" | Take-Part -Part 1 $version = Run-Command "cargo --version" | Take-Part -Part 1
return "Cargo $version" return $version
} }
function Get-RustClippyVersion { function Get-RustClippyVersion {
$version = Run-Command "cargo clippy --version" | Take-Part -Part 1 $version = Run-Command "cargo clippy --version" | Take-Part -Part 1
return "Clippy $version" return $version
} }
function Get-Bindgen { function Get-Bindgen {
$bindgenVersion = Run-Command "bindgen --version" | Take-Part -Part 1 $bindgenVersion = Run-Command "bindgen --version" | Take-Part -Part 1
return "Bindgen $bindgenVersion" return $bindgenVersion
} }
function Get-Cbindgen { function Get-Cbindgen {
$cbindgenVersion = Run-Command "cbindgen --version" | Take-Part -Part 1 $cbindgenVersion = Run-Command "cbindgen --version" | Take-Part -Part 1
return "Cbindgen $cbindgenVersion" return $cbindgenVersion
} }
function Get-Cargooutdated { function Get-Cargooutdated {
$cargoOutdatedVersion = Run-Command "cargo outdated --version" | Take-Part -Part 1 $cargoOutdatedVersion = Run-Command "cargo outdated --version" | Take-Part -Part 1
return "Cargo-outdated $cargoOutdatedVersion" return $cargoOutdatedVersion
} }
function Get-Cargoaudit { function Get-Cargoaudit {
$cargoAuditVersion = Run-Command "cargo-audit --version" | Take-Part -Part 1 $cargoAuditVersion = Run-Command "cargo-audit --version" | Take-Part -Part 1
return "Cargo-audit $cargoAuditVersion" return $cargoAuditVersion
} }
function Get-RustupVersion { function Get-RustupVersion {
$rustupVersion = Run-Command "rustup --version" | Select-Object -First 1 | Take-Part -Part 1 $rustupVersion = Run-Command "rustup --version" | Select-Object -First 1 | Take-Part -Part 1
return "Rustup ${rustupVersion}" return $rustupVersion
} }
function Get-VcpkgVersion { function Get-VcpkgVersion {
$vcpkgVersion = Run-Command "vcpkg version" | Select-Object -First 1 | Take-Part -Part 5 | Take-Part -Part 0 -Delimiter "-" $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 $commitId = git -C "/usr/local/share/vcpkg" rev-parse --short HEAD
return "Vcpkg $vcpkgVersion (build from master \<$commitId>)" return "$vcpkgVersion (build from master \<$commitId>)"
} }
function Get-GccVersion { function Get-GccVersions {
$versionList = Get-ToolsetValue -KeyPath gcc.versions $versionList = Get-ToolsetValue -KeyPath gcc.versions
$versionList | Foreach-Object { $versionList | Foreach-Object {
$version = Run-Command "gcc-${_} --version" | Select-Object -First 1 $nameVersion = Run-Command "gcc-${_} --version" | Select-Object -First 1
"$version - available by ``gcc-${_}`` alias" $version = ($nameVersion -replace "^gcc-${_}").Trim() -replace '\).*$', ')'
return [ToolNode]::new("GCC ${_}", "$version - available by ``gcc-${_}`` alias")
} }
} }
function Get-FortranVersion { function Get-FortranVersions {
$versionList = Get-ToolsetValue -KeyPath gcc.versions $versionList = Get-ToolsetValue -KeyPath gcc.versions
$versionList | Foreach-Object { $versionList | Foreach-Object {
$version = Run-Command "gfortran-${_} --version" | Select-Object -First 1 $nameVersion = Run-Command "gfortran-${_} --version" | Select-Object -First 1
"$version - available by ``gfortran-${_}`` alias" $version = ($nameVersion -replace "^GNU Fortran").Trim() -replace '\).*$', ')'
return [ToolNode]::new("GNU Fortran ${_}", "$version - available by ``gfortran-${_}`` alias")
} }
} }
function Get-ClangLLVMVersion { function Get-ClangLLVMVersions {
$toolsetVersion = '$(brew --prefix llvm@{0})/bin/clang' -f (Get-ToolsetValue 'llvm.version') $clangVersionRegex = [Regex]::new("(?<version>\d+\.\d+\.\d+)")
$locationsList = @("$((Get-Command clang).Source)", $toolsetVersion)
$locationsList | Foreach-Object { $defaultClangOutput = Run-Command "clang --version" | Out-String
(Run-Command "${_} --version" | Out-String) -match "(?<version>\d+\.\d+\.\d+)" | Out-Null $defaultClangVersion = $clangVersionRegex.Match($defaultClangOutput).Groups['version'].Value
$version = $Matches.version
"Clang/LLVM $version " + $(if(${_} -Match "brew") {"is available on ```'${_}`'``"} else {"is default"}) $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 @(
[ToolNode]::new("Clang/LLVM", $defaultClangVersion)
[ToolNode]::new("Clang/LLVM (Homebrew)", "$homebrewClangVersion - available on ```'$homebrewClangPath`'``")
)
} }
function Get-NVMVersion { function Get-NVMVersion {
$nvmPath = Join-Path $env:HOME ".nvm" "nvm.sh" $nvmPath = Join-Path $env:HOME ".nvm" "nvm.sh"
$nvmInitCommand = ". ${nvmPath} > /dev/null 2>&1 || true" $nvmInitCommand = ". ${nvmPath} > /dev/null 2>&1 || true"
$nodejsVersion = Run-Command "${nvmInitCommand} && nvm --version" $nodejsVersion = Run-Command "${nvmInitCommand} && nvm --version"
return "NVM $nodejsVersion" return $nodejsVersion
} }
function Get-PipVersion { function Get-PipVersion {
@@ -123,12 +131,12 @@ function Get-PipVersion {
$versionPart1 = $commandOutput | Take-Part -Part 1 $versionPart1 = $commandOutput | Take-Part -Part 1
$versionPart2 = $commandOutput | Take-Part -Part 4 $versionPart2 = $commandOutput | Take-Part -Part 4
$versionPart3 = $commandOutput | Take-Part -Part 5 $versionPart3 = $commandOutput | Take-Part -Part 5
return "Pip ${versionPart1} ${versionPart2} ${versionPart3}" return "${versionPart1} ${versionPart2} ${versionPart3}"
} }
function Get-PipxVersion { function Get-PipxVersion {
$pipxVersion = Run-Command "pipx --version" -SuppressStderr $pipxVersion = Run-Command "pipx --version" -SuppressStderr
return "Pipx $pipxVersion" return $pipxVersion
} }
function Get-NVMNodeVersionList { function Get-NVMNodeVersionList {
@@ -137,19 +145,27 @@ function Get-NVMNodeVersionList {
$nodejsVersionsRaw = Run-Command "${nvmInitCommand} && nvm ls" $nodejsVersionsRaw = Run-Command "${nvmInitCommand} && nvm ls"
$nodeVersions = $nodejsVersionsRaw | ForEach-Object { $_.TrimStart(" ").TrimEnd(" *") } | Where-Object { $_.StartsWith("v") } $nodeVersions = $nodejsVersionsRaw | ForEach-Object { $_.TrimStart(" ").TrimEnd(" *") } | Where-Object { $_.StartsWith("v") }
$result = [string]::Join(" ", $nodeVersions) $result = [string]::Join(" ", $nodeVersions)
return "NVM - Cached node versions: $result" return $result
} }
function Build-OSInfoSection { function Build-OSInfoSection {
param (
[string] $ImageName
)
$fieldsToInclude = @("System Version:", "Kernel Version:") $fieldsToInclude = @("System Version:", "Kernel Version:")
$rawSystemInfo = Invoke-Expression "system_profiler SPSoftwareDataType" $rawSystemInfo = Invoke-Expression "system_profiler SPSoftwareDataType"
$parsedSystemInfo = $rawSystemInfo | Where-Object { -not ($_ | Select-String -NotMatch $fieldsToInclude) } | ForEach-Object { $_.Trim() } $parsedSystemInfo = $rawSystemInfo | Where-Object { -not ($_ | Select-String -NotMatch $fieldsToInclude) } | ForEach-Object { $_.Trim() }
$output = ""
$parsedSystemInfo[0] -match "System Version: macOS (?<version>\d+\.\d+)" | Out-Null $parsedSystemInfo[0] -match "System Version: macOS (?<version>\d+\.\d+)" | Out-Null
$version = $Matches.Version $version = $Matches.Version
$output += New-MDHeader "macOS $version info" -Level 1 $systemVersion = $parsedSystemInfo[0].Replace($fieldsToInclude[0],"").Trim()
$output += New-MDList -Style Unordered -Lines $parsedSystemInfo -NoNewLine $kernelVersion = $parsedSystemInfo[1].Replace($fieldsToInclude[1],"").Trim()
return $output
$osInfoNode = [HeaderNode]::new("macOS $version info")
$osInfoNode.AddToolNode("System Version:", $systemVersion)
$osInfoNode.AddToolNode("Kernel Version:", $kernelVersion)
$osInfoNode.AddToolNode("Image Version:", $ImageName.Split('_')[1])
return $osInfoNode
} }
function Get-MSBuildVersion { function Get-MSBuildVersion {
@@ -157,404 +173,407 @@ function Get-MSBuildVersion {
$result = Select-String -Path (Get-Command msbuild).Source -Pattern "msbuild" $result = Select-String -Path (Get-Command msbuild).Source -Pattern "msbuild"
$result -match "(?<path>\/\S*\.dll)" | Out-Null $result -match "(?<path>\/\S*\.dll)" | Out-Null
$msbuildPath = $Matches.path $msbuildPath = $Matches.path
return "MSBuild $msbuildVersion (from $msbuildPath)" return "$msbuildVersion (from $msbuildPath)"
} }
function Get-NodeVersion { function Get-NodeVersion {
$nodeVersion = Run-Command "node --version" $nodeVersion = Run-Command "node --version"
return "Node.js $nodeVersion" return $nodeVersion
} }
function Get-PerlVersion { function Get-PerlVersion {
$version = Run-Command "perl -e 'print substr(`$^V,1)'" $version = Run-Command "perl -e 'print substr(`$^V,1)'"
return "Perl $version" return $version
} }
function Get-PythonVersion { function Get-PythonVersion {
$pythonVersion = Run-Command "python --version" $pythonVersion = Run-Command "python --version"
return $pythonVersion return ($pythonVersion -replace "^Python").Trim()
} }
function Get-Python3Version { function Get-Python3Version {
$python3Version = Run-Command "python3 --version" $python3Version = Run-Command "python3 --version"
return $python3Version return ($python3Version -replace "^Python").Trim()
} }
function Get-RubyVersion { function Get-RubyVersion {
$rubyVersion = Run-Command "ruby --version" | Take-Part -Part 1 $rubyVersion = Run-Command "ruby --version" | Take-Part -Part 1
return "Ruby $rubyVersion" return $rubyVersion
} }
function Get-PHPVersion { function Get-PHPVersion {
$PHPVersion = Run-Command "php --version" | Select-Object -First 1 | Take-Part -Part 0,1 $PHPVersion = Run-Command "php --version" | Select-Object -First 1 | Take-Part -Part 0,1
return $PHPVersion return ($PHPVersion -replace "^PHP").Trim()
} }
function Get-JuliaVersion { function Get-JuliaVersion {
$juliaVersion = Run-Command "julia --version" | Take-Part -Part 0,2 $juliaVersion = Run-Command "julia --version" | Take-Part -Part 0,2
return $juliaVersion return ($juliaVersion -replace "^Julia").Trim()
} }
function Get-BundlerVersion { function Get-BundlerVersion {
$bundlerVersion = Run-Command "bundle --version" $bundlerVersion = Run-Command "bundle --version"
return $bundlerVersion return ($bundlerVersion -replace "^Bundler").Trim()
} }
function Get-CarthageVersion { function Get-CarthageVersion {
$carthageVersion = Run-Command "carthage version" -SuppressStderr $carthageVersion = Run-Command "carthage version" -SuppressStderr
return "Carthage $carthageVersion" return $carthageVersion
} }
function Get-CocoaPodsVersion { function Get-CocoaPodsVersion {
$cocoaPodsVersion = Run-Command "pod --version" $cocoaPodsVersion = Run-Command "pod --version"
return "CocoaPods $cocoaPodsVersion" return $cocoaPodsVersion
} }
function Get-HomebrewVersion { function Get-HomebrewVersion {
$homebrewVersion = Run-Command "brew --version" | Select-Object -First 1 $homebrewVersion = Run-Command "brew --version" | Select-Object -First 1
return $homebrewVersion return ($homebrewVersion -replace "^Homebrew").Trim()
} }
function Get-NPMVersion { function Get-NPMVersion {
$NPMVersion = Run-Command "npm --version" $NPMVersion = Run-Command "npm --version"
return "NPM $NPMVersion" return $NPMVersion
} }
function Get-YarnVersion { function Get-YarnVersion {
$yarmVersion = Run-Command "yarn --version" $yarmVersion = Run-Command "yarn --version"
return "Yarn $yarmVersion" return $yarmVersion
} }
function Get-NuGetVersion { function Get-NuGetVersion {
$nugetVersion = Run-Command "nuget help" | Select-Object -First 1 | Take-Part -Part 2 $nugetVersion = Run-Command "nuget help" | Select-Object -First 1 | Take-Part -Part 2
return "NuGet $nugetVersion" return $nugetVersion
} }
function Get-CondaVersion { function Get-CondaVersion {
$condaVersion = Invoke-Expression "conda --version" $condaVersion = Invoke-Expression "conda --version"
return "Mini$condaVersion" return ($condaVersion -replace "^conda").Trim()
} }
function Get-RubyGemsVersion { function Get-RubyGemsVersion {
$rubyGemsVersion = Run-Command "gem --version" $rubyGemsVersion = Run-Command "gem --version"
return "RubyGems $rubyGemsVersion" return $rubyGemsVersion
} }
function Get-ComposerVersion { function Get-ComposerVersion {
$composerVersion = Run-Command "composer --version" | Take-Part -Part 2 $composerVersion = Run-Command "composer --version" | Take-Part -Part 2
return "Composer $composerVersion" return $composerVersion
} }
function Get-MavenVersion { function Get-MavenVersion {
$mavenVersion = Run-Command "mvn -version" | Select-Object -First 1 | Take-Part -Part 2 $mavenVersion = Run-Command "mvn -version" | Select-Object -First 1 | Take-Part -Part 2
return "Apache Maven $mavenVersion" 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 #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 { function Get-GradleVersion {
$gradleVersion = (Run-Command "gradle --version" | Select-String "Gradle")[-1] $gradleVersion = (Run-Command "gradle --version" | Select-String "Gradle")[-1]
return $gradleVersion return ($gradleVersion.Line -replace "^Gradle").Trim()
} }
function Get-ApacheAntVersion { function Get-ApacheAntVersion {
$apacheAntVersion = Run-Command "ant -version" | Take-Part -Part 0,1,3 $apacheAntVersion = Run-Command "ant -version" | Take-Part -Part 0,1,3
return $apacheAntVersion return ($apacheAntVersion -replace "^Apache Ant\(TM\)").Trim()
} }
function Get-CurlVersion { function Get-CurlVersion {
$curlVersion = Run-Command "curl --version" | Select-Object -First 1 | Take-Part -Part 1 $curlVersion = Run-Command "curl --version" | Select-Object -First 1 | Take-Part -Part 1
return "Curl $curlVersion" return $curlVersion
} }
function Get-GitVersion { function Get-GitVersion {
$gitVersion = Run-Command "git --version" | Take-Part -Part -1 $gitVersion = Run-Command "git --version" | Take-Part -Part -1
return "Git $gitVersion" return $gitVersion
} }
function Get-GitLFSVersion { function Get-GitLFSVersion {
$gitLFSVersion = Run-Command "git-lfs version" | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/" $gitLFSVersion = Run-Command "git-lfs version" | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/"
return "Git LFS: $gitLFSVersion" return $gitLFSVersion
} }
function Get-GitHubCLIVersion { function Get-GitHubCLIVersion {
$ghVersion = Run-Command "gh --version" | Select-String "gh version" | Select-Object -First 1 | Take-Part -Part 2 $ghVersion = Run-Command "gh --version" | Select-String "gh version" | Select-Object -First 1 | Take-Part -Part 2
return "GitHub CLI: $ghVersion" return $ghVersion
} }
function Get-HubVersion { function Get-HubVersion {
$hubVersion = Run-Command "brew list --versions hub" | Take-Part -Part 1 $hubVersion = Run-Command "brew list --versions hub" | Take-Part -Part 1
return "Hub CLI: $hubVersion" return $hubVersion
} }
function Get-WgetVersion { function Get-WgetVersion {
$wgetVersion = Run-Command "wget --version" | Select-String "GNU Wget" | Take-Part -Part 2 $wgetVersion = Run-Command "wget --version" | Select-String "GNU Wget" | Take-Part -Part 2
return "GNU Wget $wgetVersion" return $wgetVersion
} }
function Get-SVNVersion { function Get-SVNVersion {
$svnVersion = Run-Command "svn --version --quiet" $svnVersion = Run-Command "svn --version --quiet"
return "Subversion (SVN) $svnVersion" return $svnVersion
} }
function Get-PackerVersion { 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 # 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" $result = Run-Command -Command "packer --version"
$packerVersion = [regex]::matches($result, "(\d+.){2}\d+").Value $packerVersion = [regex]::matches($result, "(\d+.){2}\d+").Value
return "Packer $packerVersion" return $packerVersion
} }
function Get-OpenSSLVersion { function Get-OpenSSLVersion {
$opensslVersion = Get-Item /usr/local/opt/openssl@1.1 | ForEach-Object {"{0} ``({1} -> {2})``" -f (Run-Command "openssl version"), $_.FullName, $_.Target} $opensslVersion = Get-Item /usr/local/opt/openssl@1.1 | ForEach-Object {"{0} ``({1} -> {2})``" -f (Run-Command "openssl version"), $_.FullName, $_.Target}
return $opensslVersion return ($opensslVersion -replace "^OpenSSL").Trim()
} }
function Get-JqVersion { function Get-JqVersion {
$jqVersion = Run-Command "jq --version" | Take-Part -Part 1 -Delimiter "-" $jqVersion = Run-Command "jq --version" | Take-Part -Part 1 -Delimiter "-"
return "jq $jqVersion" return $jqVersion
} }
function Get-GPGVersion { function Get-GPGVersion {
$gpgVersion = Run-Command "gpg --version" | Select-String 'gpg (GnuPG)' -SimpleMatch $gpgVersion = Run-Command "gpg --version" | Select-String 'gpg (GnuPG)' -SimpleMatch
return $gpgVersion return ($gpgVersion.Line -replace "^gpg \(GnuPG\)").Trim()
} }
function Get-PostgresClientVersion { function Get-PostgresClientVersion {
$postgresClientVersion = Run-Command "psql --version" $postgresClientVersion = Run-Command "psql --version"
return $postgresClientVersion return ($postgresClientVersion -replace "^psql \(PostgreSQL\)").Trim()
} }
function Get-PostgresServerVersion { function Get-PostgresServerVersion {
$postgresServerVersion = Run-Command "pg_config --version" $postgresServerVersion = Run-Command "pg_config --version"
return $postgresServerVersion return ($postgresServerVersion -replace "^PostgreSQL").Trim()
} }
function Get-Aria2Version { function Get-Aria2Version {
$aria2Version = Run-Command "aria2c --version" | Select-Object -First 1 | Take-Part -Part 2 $aria2Version = Run-Command "aria2c --version" | Select-Object -First 1 | Take-Part -Part 2
return "aria2 $aria2Version" return $aria2Version
} }
function Get-AzcopyVersion { function Get-AzcopyVersion {
$azcopyVersion = Run-Command "azcopy --version" | Take-Part -Part 2 $azcopyVersion = Run-Command "azcopy --version" | Take-Part -Part 2
return "azcopy $azcopyVersion" return $azcopyVersion
} }
function Get-ZstdVersion { function Get-ZstdVersion {
$zstdVersion = Run-Command "zstd --version" | Take-Part -Part 1 -Delimiter "v" | Take-Part -Part 0 -Delimiter "," $zstdVersion = Run-Command "zstd --version" | Take-Part -Part 1 -Delimiter "v" | Take-Part -Part 0 -Delimiter ","
return "zstd $zstdVersion" return $zstdVersion
} }
function Get-BazelVersion { function Get-BazelVersion {
$bazelVersion = Run-Command "bazel --version" | Take-Part -Part 0 -Delimiter "-" $bazelVersion = Run-Command "bazel --version" | Take-Part -Part 0 -Delimiter "-"
return $bazelVersion return ($bazelVersion -replace "^bazel").Trim()
} }
function Get-BazeliskVersion { function Get-BazeliskVersion {
$bazeliskVersion = Run-Command "brew list bazelisk --versions" $bazeliskVersion = Run-Command "brew list bazelisk --versions"
return $bazeliskVersion return ($bazeliskVersion -replace "^bazelisk").Trim()
} }
function Get-HelmVersion { function Get-HelmVersion {
$helmVersion = Run-Command "helm version --short" $helmVersion = Run-Command "helm version --short"
return "helm $helmVersion" return $helmVersion
} }
function Get-MongoVersion { function Get-MongoVersion {
$mongo = Run-Command "mongo --version" | Select-String "MongoDB shell version" | Take-Part -Part 3 $mongo = Run-Command "mongo --version" | Select-String "MongoDB shell version" | Take-Part -Part 3
return "mongo $mongo" return $mongo
} }
function Get-MongodVersion { function Get-MongodVersion {
$mongod = Run-Command "mongod --version" | Select-String "db version " | Take-Part -Part 2 $mongod = Run-Command "mongod --version" | Select-String "db version " | Take-Part -Part 2
return "mongod $mongod" return $mongod
} }
function Get-7zipVersion { function Get-7zipVersion {
$7zip = Run-Command "7z i" | Select-String "7-Zip" | Take-Part -Part 0,2 $7zip = Run-Command "7z i" | Select-String "7-Zip" | Take-Part -Part 0,2
return $7zip return ($7zip -replace "^7-Zip").Trim()
} }
function Get-GnuTarVersion { function Get-GnuTarVersion {
$gnuTar = Run-Command "gtar --version" | Select-String "tar" | Take-Part -Part 3 $gnuTar = Run-Command "gtar --version" | Select-String "tar" | Take-Part -Part 3
return "GNU Tar $gnuTar - available by 'gtar' alias" return "$gnuTar - available by 'gtar' alias"
} }
function Get-BsdtarVersion { function Get-BsdtarVersion {
$bsdtar = Run-Command "tar --version" | Take-Part -Part 1 $bsdtar = Run-Command "tar --version" | Take-Part -Part 1
return "bsdtar $bsdtar - available by 'tar' alias" return "$bsdtar - available by 'tar' alias"
} }
function Get-NewmanVersion { function Get-NewmanVersion {
$newmanVersion = Run-Command "newman --version" $newmanVersion = Run-Command "newman --version"
return "Newman $newmanVersion" return $newmanVersion
} }
function Get-VirtualBoxVersion { function Get-VirtualBoxVersion {
$virtualBox = Run-Command "vboxmanage -v" $virtualBox = Run-Command "vboxmanage -v"
return "VirtualBox $virtualBox" return $virtualBox
} }
function Get-VagrantVersion { function Get-VagrantVersion {
$vagrant = Run-Command "vagrant -v" $vagrant = Run-Command "vagrant -v"
return $vagrant return ($vagrant -replace "^Vagrant").Trim()
} }
function Get-ParallelVersion { function Get-ParallelVersion {
$parallelVersion = Run-Command "parallel --version" | Select-String "GNU parallel" | Select-Object -First 1 $parallelVersion = Run-Command "parallel --version" | Select-String "GNU parallel" | Select-Object -First 1
return $parallelVersion return ($parallelVersion -replace "^GNU parallel").Trim()
} }
function Get-FastlaneVersion { function Get-FastlaneVersion {
$fastlaneVersion = Run-Command "fastlane --version" | Select-String "^fastlane [0-9]" | Take-Part -Part 1 $fastlaneVersion = Run-Command "fastlane --version" | Select-String "^fastlane [0-9]" | Take-Part -Part 1
return "Fastlane $fastlaneVersion" return $fastlaneVersion
} }
function Get-CmakeVersion { function Get-CmakeVersion {
$cmakeVersion = Run-Command "cmake --version" | Select-Object -First 1 | Take-Part -Part 2 $cmakeVersion = Run-Command "cmake --version" | Select-Object -First 1 | Take-Part -Part 2
return "Cmake $cmakeVersion" return $cmakeVersion
} }
function Get-AppCenterCLIVersion { function Get-AppCenterCLIVersion {
$appcenterCLIVersion = Run-Command "appcenter --version" | Take-Part -Part 2 $appcenterCLIVersion = Run-Command "appcenter --version" | Take-Part -Part 2
return "App Center CLI $appcenterCLIVersion" return $appcenterCLIVersion
} }
function Get-AzureCLIVersion { function Get-AzureCLIVersion {
$azureCLIVersion = (az version | ConvertFrom-Json).'azure-cli' $azureCLIVersion = (az version | ConvertFrom-Json).'azure-cli'
return "Azure CLI $azureCLIVersion" return $azureCLIVersion
} }
function Get-AzureDevopsVersion { function Get-AzureDevopsVersion {
$azdevopsVersion = (az version | ConvertFrom-Json).extensions.'azure-devops' $azdevopsVersion = (az version | ConvertFrom-Json).extensions.'azure-devops'
return "Azure CLI (azure-devops) $azdevopsVersion" return $azdevopsVersion
} }
function Get-AWSCLIVersion { function Get-AWSCLIVersion {
$awsVersion = Run-Command "aws --version" | Take-Part -Part 0 | Take-Part -Delimiter "/" -Part 1 $awsVersion = Run-Command "aws --version" | Take-Part -Part 0 | Take-Part -Delimiter "/" -Part 1
return "AWS CLI $awsVersion" return $awsVersion
} }
function Get-AWSSAMCLIVersion { function Get-AWSSAMCLIVersion {
$awsSamVersion = Run-Command "sam --version" | Take-Part -Part 3 $awsSamVersion = Run-Command "sam --version" | Take-Part -Part 3
return "AWS SAM CLI $awsSamVersion" return $awsSamVersion
} }
function Get-AWSSessionManagerCLIVersion { function Get-AWSSessionManagerCLIVersion {
$awsSessionManagerVersion = Run-Command "session-manager-plugin --version" $awsSessionManagerVersion = Run-Command "session-manager-plugin --version"
return "AWS Session Manager CLI $awsSessionManagerVersion" return $awsSessionManagerVersion
} }
function Get-AliyunCLIVersion { function Get-AliyunCLIVersion {
$aliyunVersion = Run-Command "aliyun --version" | Select-String "Alibaba Cloud Command Line Interface Version " | Take-Part -Part 6 $aliyunVersion = Run-Command "aliyun --version" | Select-String "Alibaba Cloud Command Line Interface Version " | Take-Part -Part 6
return "Aliyun CLI $aliyunVersion" return $aliyunVersion
} }
function Get-GHCupVersion { function Get-GHCupVersion {
$ghcUpVersion = (Run-Command "ghcup --version" | Take-Part -Part 5).Replace('v','') $ghcUpVersion = (Run-Command "ghcup --version" | Take-Part -Part 5).Replace('v','')
return "GHCup $ghcUpVersion" return $ghcUpVersion
} }
function Get-GHCVersion { function Get-GHCVersion {
$ghcVersion = Run-Command "ghc --version" | Take-Part -Part 7 $ghcVersion = Run-Command "ghc --version" | Take-Part -Part 7
return "GHC $ghcVersion" return $ghcVersion
} }
function Get-CabalVersion { function Get-CabalVersion {
$cabalVersion = Run-Command "cabal --version" | Take-Part -Part 3 $cabalVersion = Run-Command "cabal --version" | Take-Part -Part 3
return "Cabal $cabalVersion" return $cabalVersion
} }
function Get-SwitchAudioOsxVersion { function Get-SwitchAudioOsxVersion {
$switchAudioVersion = Get-BrewPackageVersion -CommandName "SwitchAudioSource" $switchAudioVersion = Get-BrewPackageVersion -CommandName "SwitchAudioSource"
return "Switchaudio-osx $switchAudioVersion" return $switchAudioVersion
} }
function Get-SoxVersion { function Get-SoxVersion {
$soxVersion = Get-BrewPackageVersion -CommandName "sox" $soxVersion = Get-BrewPackageVersion -CommandName "sox"
return "Sox $soxVersion" return $soxVersion
} }
function Get-StackVersion { function Get-StackVersion {
$stackVersion = Run-Command "stack --version" | Take-Part -Part 1 | ForEach-Object {$_.replace(",","")} $stackVersion = Run-Command "stack --version" | Take-Part -Part 1 | ForEach-Object {$_.replace(",","")}
return "Stack $stackVersion" return $stackVersion
} }
function Get-SwiftFormatVersion { function Get-SwiftFormatVersion {
$swiftFormatVersion = Run-Command "swiftformat --version" $swiftFormatVersion = Run-Command "swiftformat --version"
return "SwiftFormat $swiftFormatVersion" return $swiftFormatVersion
} }
function Get-YamllintVersion { function Get-YamllintVersion {
$yamllintVersion = Run-Command "yamllint --version" $yamllintVersion = Run-Command "yamllint --version"
return $yamllintVersion return ($yamllintVersion -replace "^Yamllint").Trim()
} }
function Get-SwiftLintVersion { function Get-SwiftLintVersion {
$swiftlintVersion = Run-Command "swiftlint version" $swiftlintVersion = Run-Command "swiftlint version"
return "SwiftLint $swiftlintVersion" return $swiftlintVersion
} }
function Get-PowershellVersion { function Get-PowershellVersion {
$powershellVersion = Run-Command "powershell --version" $powershellVersion = Run-Command "powershell --version"
return $powershellVersion return ($powershellVersion -replace "^PowerShell").Trim()
} }
function Get-SwigVersion { function Get-SwigVersion {
$swigVersion = Run-Command "swig -version" | Select-Object -First 2 | Take-Part -Part 2 $swigVersion = Run-Command "swig -version" | Select-Object -First 2 | Take-Part -Part 2
return "Swig $swigVersion" return $swigVersion
} }
function Get-BicepVersion { function Get-BicepVersion {
$bicepVersion = Run-Command "bicep --version" | Take-Part -Part 3 $bicepVersion = Run-Command "bicep --version" | Take-Part -Part 3
return "Bicep CLI $bicepVersion" return $bicepVersion
} }
function Get-KotlinVersion { function Get-KotlinVersion {
$kotlinVersion = Run-Command "kotlin -version" | Take-Part -Part 2 $kotlinVersion = Run-Command "kotlin -version" | Take-Part -Part 2
return "Kotlin $kotlinVersion" return $kotlinVersion
} }
function Get-SbtVersion { function Get-SbtVersion {
$sbtVersion = Run-Command "sbt -version" | Take-Part -Part 3 $sbtVersion = Run-Command "sbt -version" | Take-Part -Part 3
return "Sbt $sbtVersion" return $sbtVersion
} }
function Get-JazzyVersion { function Get-JazzyVersion {
$jazzyVersion = Run-Command "jazzy --version" | Take-Part -Part 2 $jazzyVersion = Run-Command "jazzy --version" | Take-Part -Part 2
return "Jazzy $jazzyVersion" return $jazzyVersion
} }
function Get-ZlibVersion { function Get-ZlibVersion {
$zlibVersion = brew info --json zlib | jq -r '.[].installed[].version' $zlibVersion = brew info --json zlib | jq -r '.[].installed[].version'
return "Zlib $zlibVersion" return $zlibVersion
} }
function Get-LibXftVersion { function Get-LibXftVersion {
$libXftVersion = brew info --json libxft | jq -r '.[].installed[].version' $libXftVersion = brew info --json libxft | jq -r '.[].installed[].version'
return "libXft $libXftVersion" return $libXftVersion
} }
function Get-LibXextVersion { function Get-LibXextVersion {
$libXextVersion = brew info --json libxext | jq -r '.[].installed[].version' $libXextVersion = brew info --json libxext | jq -r '.[].installed[].version'
return "libXext $libXextVersion" return $libXextVersion
} }
function Get-TclTkVersion { function Get-TclTkVersion {
$tcltkVersion = brew info --json tcl-tk | jq -r '.[].installed[].version' $tcltkVersion = brew info --json tcl-tk | jq -r '.[].installed[].version'
return "Tcl/Tk $tcltkVersion" return $tcltkVersion
} }
function Get-YqVersion { function Get-YqVersion {
$yqVersion = Run-Command "yq --version" $yqVersion = Run-Command "yq --version"
return "$yqVersion" $yqVersion -match "\d{1,2}\.\d{1,2}\.\d{1,2}" | Out-Null
return ($Matches[0])
} }
function Get-ImageMagickVersion { function Get-ImageMagickVersion {
$imagemagickVersion = Run-Command "magick --version" | Select-Object -First 1 | Take-Part -Part 1,2 $imagemagickVersion = Run-Command "magick --version" | Select-Object -First 1 | Take-Part -Part 1,2
return "$imagemagickVersion" return ($imagemagickVersion -replace "^ImageMagick").Trim()
} }
function Build-PackageManagementEnvironmentTable { function Build-PackageManagementEnvironmentTable {
return @( $node = [HeaderNode]::new("Environment variables")
$table = @(
@{ @{
"Name" = "CONDA" "Name" = "CONDA"
"Value" = $env:CONDA "Value" = $env:CONDA
@@ -569,6 +588,10 @@ function Build-PackageManagementEnvironmentTable {
"Value" = $_.Value "Value" = $_.Value
} }
} }
$node.AddTableNode($table)
return $node
} }
function Build-MiscellaneousEnvironmentTable { function Build-MiscellaneousEnvironmentTable {
@@ -605,10 +628,10 @@ function Get-CodeQLBundleVersion {
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionWildcard | Select-Object -First 1 -Expand FullName $CodeQLVersionPath = Get-ChildItem $CodeQLVersionWildcard | Select-Object -First 1 -Expand FullName
$CodeQLPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "codeql" $CodeQLPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "codeql"
$CodeQLVersion = & $CodeQLPath version --quiet $CodeQLVersion = & $CodeQLPath version --quiet
return "CodeQL Action Bundle $CodeQLVersion" return $CodeQLVersion
} }
function Get-ColimaVersion { function Get-ColimaVersion {
$colimaVersion = Run-Command "colima version" | Select-String "colima version" | Take-Part -Part 2 $colimaVersion = Run-Command "colima version" | Select-String "colima version" | Take-Part -Part 2
return "Colima $colimaVersion" return $colimaVersion
} }

View File

@@ -6,7 +6,7 @@ param (
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
Import-Module MarkdownPS . ("$PSScriptRoot/SoftwareReport.Base.ps1")
Import-Module "$PSScriptRoot/SoftwareReport.Common.psm1" -DisableNameChecking Import-Module "$PSScriptRoot/SoftwareReport.Common.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Xcode.psm1" -DisableNameChecking Import-Module "$PSScriptRoot/SoftwareReport.Xcode.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/SoftwareReport.Android.psm1" -DisableNameChecking Import-Module "$PSScriptRoot/SoftwareReport.Android.psm1" -DisableNameChecking
@@ -22,311 +22,246 @@ Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
# Operating System info # Operating System info
$os = Get-OSVersion $os = Get-OSVersion
$markdown = ""
# OS info # OS info
$markdown += Build-OSInfoSection $osInfo = Build-OSInfoSection $ImageName
$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)
)
# To sort GCC and Gfortran correctly, we need to use natural sort https://gist.github.com/markwragg/e2a9dc05f3464103d6998298fb575d4e#file-sort-natural-ps1 # Software report
$toNatural = { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) } $softwareReport = [SoftwareReport]::new($osInfo)
$markdown += New-MDList -Style Unordered -Lines ($languageAndRuntimeList | Sort-Object $toNatural) $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 # Package Management
$markdown += New-MDHeader "Package Management" -Level 3 $packageManagement = $installedSoftware.AddHeaderNode("Package Management")
$packageManagementList = @( $packageManagement.AddToolNode("Bundler", $(Get-BundlerVersion))
(Get-PipVersion -Version 2), $packageManagement.AddToolNode("Carthage", $(Get-CarthageVersion))
(Get-PipVersion -Version 3), $packageManagement.AddToolNode("CocoaPods", $(Get-CocoaPodsVersion))
(Get-PipxVersion), $packageManagement.AddToolNode("Composer", $(Get-ComposerVersion))
(Get-BundlerVersion), $packageManagement.AddToolNode("Homebrew", $(Get-HomebrewVersion))
(Get-CocoaPodsVersion), $packageManagement.AddToolNode("Miniconda", $(Get-CondaVersion))
(Get-CondaVersion), $packageManagement.AddToolNode("NPM", $(Get-NPMVersion))
(Get-HomebrewVersion), $packageManagement.AddToolNode("NuGet", $(Get-NuGetVersion))
(Get-NPMVersion), $packageManagement.AddToolNode("Pip", $(Get-PipVersion -Version 2))
(Get-YarnVersion), $packageManagement.AddToolNode("Pip3", $(Get-PipVersion -Version 3))
(Get-NuGetVersion), $packageManagement.AddToolNode("Pipx", $(Get-PipxVersion))
(Get-RubyGemsVersion), $packageManagement.AddToolNode("RubyGems", $(Get-RubyGemsVersion))
(Get-ComposerVersion), $packageManagement.AddToolNode("Vcpkg", $(Get-VcpkgVersion))
(Get-CarthageVersion), $packageManagement.AddToolNode("Yarn", $(Get-YarnVersion))
(Get-VcpkgVersion)
)
$markdown += New-MDList -Style Unordered -Lines ($packageManagementList | Sort-Object) $packageManagement.AddNode($(Build-PackageManagementEnvironmentTable))
$markdown += New-MDHeader "Environment variables" -Level 4
$markdown += Build-PackageManagementEnvironmentTable | New-MDTable
$markdown += New-MDNewLine
# Project Management # Project Management
$markdown += New-MDHeader "Project Management" -Level 3 $projectanagement = $installedSoftware.AddHeaderNode("Project Management")
$markdown += New-MDList -Style Unordered -Lines (@( $projectanagement.AddToolNode("Apache Ant", $(Get-ApacheAntVersion))
(Get-MavenVersion), $projectanagement.AddToolNode("Apache Maven", $(Get-MavenVersion))
(Get-GradleVersion), $projectanagement.AddToolNode("Gradle", $(Get-GradleVersion))
(Get-ApacheAntVersion), $projectanagement.AddToolNode("Sbt", $(Get-SbtVersion))
(Get-SbtVersion)
) | Sort-Object
)
# Utilities # Utilities
$markdown += New-MDHeader "Utilities" -Level 3 $utilities = $installedSoftware.AddHeaderNode("Utilities")
$utilitiesList = @( $utilities.AddToolNode("7-Zip", $(Get-7zipVersion))
(Get-CurlVersion), $utilities.AddToolNode("aria2", $(Get-Aria2Version))
(Get-GitVersion), $utilities.AddToolNode("azcopy", $(Get-AzcopyVersion))
(Get-GitLFSVersion), $utilities.AddToolNode("bazel", $(Get-BazelVersion))
(Get-GitHubCLIVersion), $utilities.AddToolNode("bazelisk", $(Get-BazeliskVersion))
(Get-HubVersion), $utilities.AddToolNode("bsdtar", $(Get-BsdtarVersion))
(Get-WgetVersion), $utilities.AddToolNode("Curl", $(Get-CurlVersion))
(Get-SVNVersion), $utilities.AddToolNode("Git", $(Get-GitVersion))
(Get-PackerVersion), $utilities.AddToolNode("Git LFS", $(Get-GitLFSVersion))
(Get-OpenSSLVersion), $utilities.AddToolNode("GitHub CLI", $(Get-GitHubCLIVersion))
(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)
)
}
if ($os.IsCatalina) { if ($os.IsCatalina) {
$utilitiesList += @( $utilities.AddToolNode("GNU parallel", $(Get-ParallelVersion))
(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) { if (-not $os.IsBigSur) {
$utilitiesList += @( $utilities.AddToolNode("Vagrant", $(Get-VagrantVersion))
(Get-VagrantVersion), $utilities.AddToolNode("VirtualBox", $(Get-VirtualBoxVersion))
(Get-VirtualBoxVersion)
)
} }
$utilities.AddToolNode("yq", $(Get-YqVersion))
$markdown += New-MDList -Style Unordered -Lines ($utilitiesList | Sort-Object) $utilities.AddToolNode("zstd", $(Get-ZstdVersion))
# Tools # Tools
$markdown += New-MDHeader "Tools" -Level 3 $tools = $installedSoftware.AddHeaderNode("Tools")
$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)
)
}
if ($os.IsLessThanMonterey) { if ($os.IsLessThanMonterey) {
$toolsList += @( $tools.AddToolNode("Aliyun CLI", $(Get-AliyunCLIVersion))
(Get-AliyunCLIVersion)
)
} }
$tools.AddToolNode("App Center CLI", $(Get-AppCenterCLIVersion))
$toolsList += @( $tools.AddToolNode("AWS CLI", $(Get-AWSCLIVersion))
(Get-XcodeCommandLineToolsVersion), $tools.AddToolNode("AWS SAM CLI", $(Get-AWSSAMCLIVersion))
(Get-SwigVersion), $tools.AddToolNode("AWS Session Manager CLI", $(Get-AWSSessionManagerCLIVersion))
(Get-BicepVersion), $tools.AddToolNode("Azure CLI (azure-devops)", $(Get-AzureDevopsVersion))
(Get-GHCupVersion), $tools.AddToolNode("Azure CLI", $(Get-AzureCLIVersion))
(Get-GHCVersion), $tools.AddToolNode("Bicep CLI", $(Get-BicepVersion))
(Get-CabalVersion), $tools.AddToolNode("Cabal", $(Get-CabalVersion))
(Get-StackVersion), $tools.AddToolNode("Cmake", $(Get-CmakeVersion))
(Get-SwiftFormatVersion)
)
if (-not $os.IsCatalina) { if (-not $os.IsCatalina) {
$toolsList += @( $tools.AddToolNode("CodeQL Action Bundle", $(Get-CodeQLBundleVersion))
(Get-ColimaVersion)
)
} }
if (-not $os.IsCatalina) {
$markdown += New-MDList -Style Unordered -Lines ($toolsList | Sort-Object) $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 # Linters
$markdown += New-MDHeader "Linters" -Level 3 $linters = $installedSoftware.AddHeaderNode("Linters")
$lintersList = @( $linters.AddToolNode("Swift", $(Get-SwiftLintVersion))
(Get-YamllintVersion), $linters.AddToolNode("Yamllint", $(Get-YamllintVersion))
(Get-SwiftLintVersion)
)
$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 # Java
$markdown += Get-BrowserSection $java = $installedSoftware.AddHeaderNode("Java")
$markdown += New-MDHeader "Environment variables" -Level 4 $java.AddTableNode($(Get-JavaVersions))
$markdown += Build-BrowserWebdriversEnvironmentTable | New-MDTable
$markdown += New-MDNewLine
$markdown += New-MDHeader "Java" -Level 3 # Graal
$markdown += Get-JavaVersions | New-MDTable $graalvm = $installedSoftware.AddHeaderNode("GraalVM")
$markdown += New-MDNewLine $graalvm.AddTableNode($(Build-GraalVMTable))
$markdown += New-MDHeader "GraalVM" -Level 3
$markdown += Build-GraalVMTable | New-MDTable
$markdown += New-MDNewLine
# Toolcache # Toolcache
$markdown += Build-ToolcacheSection $toolcache = $installedSoftware.AddHeaderNode("Cached Tools")
$markdown += New-MDNewLine $toolcache.AddNodes($(Build-ToolcacheSection))
$markdown += New-MDHeader "Rust Tools" -Level 3 # Rust
$markdown += New-MDList -Style Unordered -Lines (@( $rust = $installedSoftware.AddHeaderNode("Rust Tools")
(Get-RustVersion), $rust.AddToolNode("Cargo", $(Get-RustCargoVersion))
(Get-RustupVersion), $rust.AddToolNode("Rust", $(Get-RustVersion))
(Get-RustdocVersion), $rust.AddToolNode("Rustdoc", $(Get-RustdocVersion))
(Get-RustCargoVersion) $rust.AddToolNode("Rustup", $(Get-RustupVersion))
) | Sort-Object
)
$markdown += New-MDHeader "Packages" -Level 4 $rustPackages = $rust.AddHeaderNode("Packages")
$markdown += New-MDList -Style Unordered -Lines (@( $rustPackages.AddToolNode("Bindgen", $(Get-Bindgen))
(Get-Bindgen), $rustPackages.AddToolNode("Cargo-audit", $(Get-Cargoaudit))
(Get-Cbindgen), $rustPackages.AddToolNode("Cargo-outdated", $(Get-Cargooutdated))
(Get-Cargooutdated), $rustPackages.AddToolNode("Cbindgen", $(Get-Cbindgen))
(Get-Cargoaudit), $rustPackages.AddToolNode("Clippy", $(Get-RustClippyVersion))
(Get-RustfmtVersion), $rustPackages.AddToolNode("Rustfmt", $(Get-RustfmtVersion))
(Get-RustClippyVersion)
) | Sort-Object
)
$markdown += New-MDHeader "PowerShell Tools" -Level 3 # PowerShell
$markdown += New-MDList -Lines (Get-PowershellVersion) -Style Unordered $powerShell = $installedSoftware.AddHeaderNode("PowerShell Tools")
$powerShell.AddToolNode("PowerShell", $(Get-PowershellVersion))
$markdown += New-MDHeader "PowerShell Modules" -Level 4 $powerShellModules = $powerShell.AddHeaderNode("PowerShell Modules")
$markdown += Get-PowerShellModules | New-MDTable $powerShellModules.AddTableNode($(Get-PowerShellModules))
$markdown += New-MDNewLine
# Web Servers # Web Servers
$markdown += Build-WebServersSection $webServers = $installedSoftware.AddHeaderNode("Web Servers")
$webServers.AddTableNode($(Build-WebServersSection))
# Xamarin section # Xamarin section
$markdown += New-MDHeader "Xamarin" -Level 3 $xamarin = $installedSoftware.AddHeaderNode("Xamarin")
$markdown += New-MDHeader "Visual Studio for Mac" -Level 4 $vsForMac = $xamarin.AddHeaderNode("Visual Studio for Mac")
$markdown += Build-VSMacTable | New-MDTable $vsForMac.AddTableNode($(Build-VSMacTable))
$markdown += New-MDNewLine
if (-not $os.IsCatalina) { if (-not $os.IsCatalina) {
$markdown += New-MDHeader "Notes:" -Level 5 $note =
$reportVS = @' @'
```
To use Visual Studio 2019 by default rename the app: To use Visual Studio 2019 by default rename the app:
mv "/Applications/Visual Studio.app" "/Applications/Visual Studio 2022.app" mv "/Applications/Visual Studio.app" "/Applications/Visual Studio 2022.app"
mv "/Applications/Visual Studio 2019.app" "/Applications/Visual Studio.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 $xamarinBundles = $xamarin.AddHeaderNode("Xamarin bundles")
$markdown += Build-XamarinTable | New-MDTable $xamarinBundles.AddTableNode($(Build-XamarinTable))
$markdown += New-MDNewLine
$markdown += New-MDHeader "Unit Test Framework" -Level 4 $unitTestFramework = $xamarin.AddHeaderNode("Unit Test Framework")
$markdown += New-MDList -Lines @(Get-NUnitVersion) -Style Unordered $unitTestFramework.AddToolNode("NUnit", $(Get-NUnitVersion))
# Xcode section
$xcode = $installedSoftware.AddHeaderNode("Xcode")
# First run doesn't provide full data about devices and runtimes # First run doesn't provide full data about devices and runtimes
Get-XcodeInfoList | Out-Null Get-XcodeInfoList | Out-Null
# Xcode section
$xcodeInfo = Get-XcodeInfoList $xcodeInfo = Get-XcodeInfoList
$markdown += New-MDHeader "Xcode" -Level 3 $xcode.AddTableNode($(Build-XcodeTable $xcodeInfo))
$markdown += Build-XcodeTable $xcodeInfo | New-MDTable
$markdown += New-MDNewLine
$markdown += Build-XcodeSupportToolsSection $xcodeTools = $xcode.AddHeaderNode("Xcode Support Tools")
$xcodeTools.AddNodes($(Build-XcodeSupportToolsSection))
$markdown += New-MDHeader "Installed SDKs" -Level 4 $installedSdks = $xcode.AddHeaderNode("Installed SDKs")
$markdown += Build-XcodeSDKTable $xcodeInfo | New-MDTable $installedSdks.AddTableNode($(Build-XcodeSDKTable $xcodeInfo))
$markdown += New-MDNewLine
$markdown += New-MDHeader "Installed Simulators" -Level 4 $installedSimulators = $xcode.AddHeaderNode("Installed Simulators")
$markdown += Build-XcodeSimulatorsTable $xcodeInfo | New-MDTable $installedSimulators.AddTableNode($(Build-XcodeSimulatorsTable $xcodeInfo))
$markdown += New-MDNewLine
# Android section # Android section
$markdown += New-MDHeader "Android" -Level 3 $android = $installedSoftware.AddHeaderNode("Android")
$androidTable = Build-AndroidTable $androidTable = Build-AndroidTable
if ($os.IsCatalina) { if ($os.IsCatalina) {
$androidTable += Get-IntelHaxmVersion $androidTable += Get-IntelHaxmVersion
} }
$markdown += $androidTable | New-MDTable $android.AddTableNode($androidTable)
$markdown += New-MDNewLine
$markdown += New-MDHeader "Environment variables" -Level 4
$markdown += Build-AndroidEnvironmentTable | New-MDTable
$markdown += New-MDNewLine
$markdown += New-MDHeader "Miscellaneous" -Level 3 $androidEnv = $android.AddHeaderNode("Environment variables")
$markdown += New-MDList -Style Unordered -Lines (@( $androidEnv.AddTableNode($(Build-AndroidEnvironmentTable))
(Get-ZlibVersion),
(Get-LibXextVersion), $miscellaneous = $installedSoftware.AddHeaderNode("Miscellaneous")
(Get-LibXftVersion), $miscellaneous.AddToolNode("libXext", $(Get-LibXextVersion))
(Get-TclTkVersion) $miscellaneous.AddToolNode("libXft", $(Get-LibXftVersion))
) | Sort-Object $miscellaneous.AddToolNode("Tcl/Tk", $(Get-TclTkVersion))
) $miscellaneous.AddToolNode("Zlib", $(Get-ZlibVersion))
if ($os.IsMonterey) { if ($os.IsMonterey) {
$markdown += New-MDHeader "Environment variables" -Level 4 $miscellaneousEnv = $miscellaneous.AddHeaderNode("Environment variables")
$markdown += Build-MiscellaneousEnvironmentTable | New-MDTable $miscellaneousEnv.AddTableNode($(Build-MiscellaneousEnvironmentTable))
$markdown += New-MDNewLine
$markdown += New-MDHeader "Notes:" -Level 5 $notes = @'
$misc = @'
```
If you want to use Parallels Desktop you should download a package from URL stored in 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. 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") $dateTime = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
$systemInfo = [string]::Join([System.Environment]::NewLine, @( $systemInfo = [string]::Join([System.Environment]::NewLine, @(
"Date: ${dateTime}", "Date: ${dateTime}",
"Image name: ${ImageName}" "Image name: ${ImageName}"
)) ))
if (-not (Test-Path $OutputDirectory)) { New-Item -Path $OutputDirectory -ItemType Directory | Out-Null } 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 Write-Host $markdownExtended
$systemInfo | Out-File -FilePath "${OutputDirectory}/systeminfo.txt" -Encoding UTF8NoBOM $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

View File

@@ -35,37 +35,34 @@ function Get-ToolcacheGoTable {
$Instance."Environment Variable" = "GOROOT_$($Version.major)_$($Version.minor)_X64" $Instance."Environment Variable" = "GOROOT_$($Version.major)_$($Version.minor)_X64"
} }
$Content = $ToolInstances | New-MDTable -Columns ([ordered]@{ $Content = $ToolInstances | ForEach-Object {
Version = "left"; return [PSCustomObject]@{
Architecture = "left"; Version = $_.Version
"Environment Variable" = "left" Architecture = $_.Architecture
}) "Environment Variable" = $_."Environment Variable"
}
}
return $Content return $Content
} }
function Build-ToolcacheSection { function Build-ToolcacheSection {
$output = "" $goToolNode = [HeaderNode]::new("Go")
$output += New-MDHeader "Cached Tools" -Level 3 $goToolNode.AddTableNode($(Get-ToolcacheGoTable))
$output += New-MDHeader "Ruby" -Level 4 return @(
$output += New-MDList -Lines (Get-ToolcacheRubyVersions) -Style Unordered [ToolVersionsNode]::new("Ruby", $(Get-ToolcacheRubyVersions))
$output += New-MDHeader "Python" -Level 4 [ToolVersionsNode]::new("Python", $(Get-ToolcachePythonVersions))
$output += New-MDList -Lines (Get-ToolcachePythonVersions) -Style Unordered [ToolVersionsNode]::new("PyPy", $(Get-ToolcachePyPyVersions))
$output += New-MDHeader "PyPy" -Level 4 [ToolVersionsNode]::new("Node.js", $(Get-ToolcacheNodeVersions))
$output += New-MDList -Lines (Get-ToolcachePyPyVersions) -Style Unordered $goToolNode
$output += New-MDHeader "Node.js" -Level 4 )
$output += New-MDList -Lines (Get-ToolcacheNodeVersions) -Style Unordered
$output += New-MDHeader "Go" -Level 4
$output += Get-ToolcacheGoTable
return $output
} }
function Get-PowerShellModules { function Get-PowerShellModules {
$modules = (Get-ToolsetValue powershellModules).name $modules = (Get-ToolsetValue powershellModules).name
$psModules = Get-Module -Name $modules -ListAvailable | Sort-Object Name | Group-Object Name $psModules = Get-Module -Name $modules -ListAvailable | Sort-Object Name | Group-Object Name
$psModules | ForEach-Object { return $psModules | ForEach-Object {
$moduleName = $_.Name $moduleName = $_.Name
$moduleVersions = ($_.group.Version | Sort-Object -Unique) -join '<br>' $moduleVersions = ($_.group.Version | Sort-Object -Unique) -join '<br>'

View File

@@ -29,13 +29,8 @@ function Get-NginxVersion {
} }
function Build-WebServersSection { function Build-WebServersSection {
$output = "" return @(
$output += New-MDHeader "Web Servers" -Level 3
$output += @(
(Get-ApacheVersion), (Get-ApacheVersion),
(Get-NginxVersion) (Get-NginxVersion)
) | Sort-Object Name | New-MDTable )
$output += New-MDNewLine
return $output
} }

View File

@@ -4,7 +4,7 @@ function Build-VSMacTable {
$vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions" $vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions"
$defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default" $defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default"
$vsMacVersions | ForEach-Object { return $vsMacVersions | ForEach-Object {
$isDefault = $_ -eq $defaultVSMacVersion $isDefault = $_ -eq $defaultVSMacVersion
$vsPath = "/Applications/Visual Studio $_.app" $vsPath = "/Applications/Visual Studio $_.app"
if ($isDefault) { if ($isDefault) {
@@ -25,7 +25,7 @@ function Build-VSMacTable {
function Get-NUnitVersion { function Get-NUnitVersion {
$version = Run-Command "nunit3-console --version" | Select-Object -First 1 | Take-Part -Part 3 $version = Run-Command "nunit3-console --version" | Select-Object -First 1 | Take-Part -Part 3
return "NUnit ${version}" return $version
} }
function Build-XamarinTable { function Build-XamarinTable {

View File

@@ -78,7 +78,7 @@ function Get-XcodePlatformOrder {
function Get-XcodeCommandLineToolsVersion { function Get-XcodeCommandLineToolsVersion {
$xcodeCommandLineToolsVersion = Run-Command "pkgutil --pkg-info com.apple.pkg.CLTools_Executables" | Select -Index 1 | Take-Part -Part 1 $xcodeCommandLineToolsVersion = Run-Command "pkgutil --pkg-info com.apple.pkg.CLTools_Executables" | Select -Index 1 | Take-Part -Part 1
return "Xcode Command Line Tools $xcodeCommandLineToolsVersion" return $xcodeCommandLineToolsVersion
} }
function Build-XcodeTable { function Build-XcodeTable {
@@ -226,13 +226,13 @@ function Build-XcodeSimulatorsTable {
} }
function Build-XcodeSupportToolsSection { function Build-XcodeSupportToolsSection {
$toolNodes = @()
$xcpretty = Run-Command "xcpretty --version" $xcpretty = Run-Command "xcpretty --version"
$xcversion = Run-Command "xcversion --version" | Select-String "^[0-9]" $xcversion = Run-Command "xcversion --version" | Select-String "^[0-9]"
$toolList = @( $toolNodes += [ToolNode]::new("xcpretty", $xcpretty)
"xcpretty $xcpretty", $toolNodes += [ToolNode]::new("xcversion", $xcversion)
"xcversion $xcversion"
)
$nomadOutput = Run-Command "gem list nomad-cli" $nomadOutput = Run-Command "gem list nomad-cli"
$nomadCLI = [regex]::matches($nomadOutput, "(\d+.){2}\d+").Value $nomadCLI = [regex]::matches($nomadOutput, "(\d+.){2}\d+").Value
@@ -240,14 +240,9 @@ function Build-XcodeSupportToolsSection {
$nomadShenzhen = [regex]::matches($nomadShenzhenOutput, "(\d+.){2}\d+").Value $nomadShenzhen = [regex]::matches($nomadShenzhenOutput, "(\d+.){2}\d+").Value
if ($os.IsLessThanMonterey) { if ($os.IsLessThanMonterey) {
$toolList += @( $toolNodes += [ToolNode]::new("Nomad CLI", $nomadCLI)
"Nomad CLI $nomadCLI", $toolNodes += [ToolNode]::new("Nomad shenzhen CLI", $nomadShenzhen)
"Nomad shenzhen CLI $nomadShenzhen"
)
} }
$output = "" return $toolNodes
$output += New-MDHeader "Xcode Support Tools" -Level 4
$output += New-MDList -Style Unordered -Lines $toolList
return $output
} }