[Windows] Update documentation generation to use shared software report module (#6834)

This commit is contained in:
bogdan-damian-bgd
2022-12-30 10:24:22 +01:00
committed by GitHub
parent f7f519dcc4
commit 447c8387a2
10 changed files with 349 additions and 535 deletions

View File

@@ -11,16 +11,22 @@ function Get-OSName {
function Get-OSVersion {
$OSVersion = (Get-CimInstance -ClassName Win32_OperatingSystem).Version
$OSBuild = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion' UBR).UBR
return "OS Version: $OSVersion Build $OSBuild"
return "$OSVersion Build $OSBuild"
}
function Build-OSInfoSection {
$osInfoNode = [HeaderNode]::new($(Get-OSName))
$osInfoNode.AddToolVersion("OS Version:", $(Get-OSVersion))
$osInfoNode.AddToolVersion("Image Version:", $env:IMAGE_VERSION)
return $osInfoNode
}
function Get-BashVersion {
$version = bash --% -c 'echo ${BASH_VERSION}'
return "Bash $version"
return $version
}
function Get-RustVersion {
Initialize-RustEnvironment
$rustVersion = [regex]::matches($(rustc --version), "\d+\.\d+\.\d+").Value
return $rustVersion
}
@@ -52,145 +58,144 @@ function Get-RustClippyVersion {
}
function Get-BindgenVersion {
return bindgen --version
return ((bindgen --version) -replace "^bindgen").Trim()
}
function Get-CbindgenVersion {
return cbindgen --version
return ((cbindgen --version) -replace "^cbindgen").Trim()
}
function Get-CargoAuditVersion {
return cargo-audit --version
return ((cargo-audit --version) -replace "^cargo-audit").Trim()
}
function Get-CargoOutdatedVersion {
return cargo outdated --version
return ((cargo outdated --version) -replace "^cargo-outdated").Trim()
}
function Get-PythonVersion {
return & python --version
return ((python --version) -replace "^Python").Trim()
}
function Get-PowershellCoreVersion {
return & pwsh --version
return ((pwsh --version) -replace "^PowerShell").Trim()
}
function Get-RubyVersion {
$rubyVersion = $(ruby --version).split(" ")[1]
return "Ruby $rubyVersion"
return $rubyVersion
}
function Get-GoVersion {
$(go version) -match "go(?<version>\d+\.\d+\.\d+)" | Out-Null
$goVersion = $Matches.Version
return "Go $goVersion"
return $goVersion
}
function Get-KotlinVersion {
$kotlinVersion = $((cmd /c "kotlinc -version 2>&1") | Out-String).split(" ")[2]
return "Kotlin $kotlinVersion"
return $kotlinVersion
}
function Get-PHPVersion {
($(php --version) | Out-String) -match "PHP (?<version>\d+\.\d+\.\d+)" | Out-Null
$phpVersion = $Matches.Version
return "PHP $phpVersion"
return $phpVersion
}
function Get-JuliaVersion {
$juliaVersion = [regex]::matches($(julia --version), "\d+\.\d+\.\d+").Value
return "Julia $juliaVersion"
return $juliaVersion
}
function Get-LLVMVersion {
$llvmVersion = [regex]::matches($(clang --version), "\d+\.\d+\.\d+").Value
return "LLVM $llvmVersion"
return $llvmVersion
}
function Get-PerlVersion {
($(perl --version) | Out-String) -match "\(v(?<version>\d+\.\d+\.\d+)\)" | Out-Null
$perlVersion = $Matches.Version
return "Perl $perlVersion"
return $perlVersion
}
function Get-NodeVersion {
$nodeVersion = $(node --version).split("v")[1]
return "Node $nodeVersion"
return $nodeVersion
}
function Get-ChocoVersion {
return "Chocolatey $(choco --version)"
return $(choco --version)
}
function Get-VcpkgVersion {
$commitId = git -C "C:\vcpkg" rev-parse --short HEAD
return "Vcpkg (build from commit $commitId)"
return "(build from commit $commitId)"
}
function Get-NPMVersion {
return "NPM $(npm -version)"
return $(npm -version)
}
function Get-YarnVersion {
return "Yarn $(yarn -version)"
return $(yarn -version)
}
function Get-RubyGemsVersion {
return "RubyGems $(gem --version)"
return $(gem --version)
}
function Get-HelmVersion {
($(helm version --short) | Out-String) -match "v(?<version>\d+\.\d+\.\d+)" | Out-Null
$helmVersion = $Matches.Version
return "Helm $helmVersion"
return $helmVersion
}
function Get-PipVersion {
($(pip --version) | Out-String) -match "(?<version>pip [\d\.]+) .+ (?<python>\(python [\d\.]+\))" | Out-Null
$pipVersion = $Matches.Version
$pythonVersion = $Matches.Python
return "$pipVersion $pythonVersion"
return ("$pipVersion $pythonVersion" -replace "^pip").Trim()
}
function Get-CondaVersion {
$condaVersion = & "$env:CONDA\Scripts\conda.exe" --version
return "Mini$condaVersion (pre-installed on the image but not added to PATH)"
$condaVersion = ((& "$env:CONDA\Scripts\conda.exe" --version) -replace "^conda").Trim()
return "$condaVersion (pre-installed on the image but not added to PATH)"
}
function Get-ComposerVersion {
composer --version | Take-Part -Part 0,2
composer --version | Take-Part -Part 2
}
function Get-NugetVersion {
(nuget help) -match "NuGet Version" -replace "Version: "
return (((nuget help) -match "NuGet Version") -replace "NuGet Version:").Trim()
}
function Get-AntVersion {
($(ant -version) | Out-String) -match "version (?<version>\d+\.\d+\.\d+)" | Out-Null
$antVersion = $Matches.Version
return "Ant $antVersion"
return $antVersion
}
function Get-MavenVersion {
($(mvn -version) | Out-String) -match "Apache Maven (?<version>\d+\.\d+\.\d+)" | Out-Null
$mavenVersion = $Matches.Version
return "Maven $mavenVersion"
return $mavenVersion
}
function Get-GradleVersion {
($(gradle -version) | Out-String) -match "Gradle (?<version>\d+\.\d+)" | Out-Null
$gradleVersion = $Matches.Version
return "Gradle $gradleVersion"
return $gradleVersion
}
function Get-SbtVersion {
$sbtVersion = (sbt -version) -match "sbt script version:" -replace "script version: "
return "$sbtVersion"
return ((sbt -version) -match "sbt script version:" -replace "sbt script version:").Trim()
}
function Get-DotnetSdks {
$sdksRawList = dotnet --list-sdks
$sdkVersions = ($sdksRawList | Foreach-Object {$_.Split()[0]}) -join ', '
$sdkVersions = $sdksRawList | Foreach-Object {$_.Split()[0]}
$sdkPath = $sdksRawList[0].Split(' ', 2)[1] -replace '\[|]'
[PSCustomObject]@{
Versions = $sdkVersions
@@ -205,7 +210,8 @@ function Get-DotnetTools {
$toolsList = @()
foreach ($dotnetTool in $dotnetTools) {
$toolsList += $dotnetTool.name + " " + (Invoke-Expression $dotnetTool.getversion)
$version = Invoke-Expression $dotnetTool.getversion
$toolsList += [ToolVersionNode]::new($dotnetTool.name, $version)
}
return $toolsList
}
@@ -214,7 +220,7 @@ function Get-DotnetRuntimes {
$runtimesRawList = dotnet --list-runtimes
$runtimesRawList | Group-Object {$_.Split()[0]} | ForEach-Object {
$runtimeName = $_.Name
$runtimeVersions = ($_.Group | Foreach-Object {$_.split()[1]}) -join ', '
$runtimeVersions = $_.Group | Foreach-Object {$_.split()[1]}
$runtimePath = $_.Group[0].Split(' ', 3)[2] -replace '\[|]'
[PSCustomObject]@{
"Runtime" = $runtimeName
@@ -226,8 +232,7 @@ function Get-DotnetRuntimes {
function Get-DotnetFrameworkVersions {
$path = "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\*\*\NETFX * Tools"
$versions = Get-ChildItem -Path $path -Directory | ForEach-Object { $_.Name | Take-Part -Part 1 }
$versions -join ', '
return Get-ChildItem -Path $path -Directory | ForEach-Object { $_.Name | Take-Part -Part 1 }
}
function Get-PowerShellAzureModules {
@@ -236,32 +241,32 @@ function Get-PowerShellAzureModules {
[Array] $azInstalledModules = Get-ChildItem -Path "C:\Modules\az_*" -Directory | ForEach-Object { $_.Name.Split("_")[1] }
if ($azInstalledModules.Count -gt 0) {
$result += "Az: $($azInstalledModules -join ', ')"
$result += [ToolVersionsListNode]::new("Az", $($azInstalledModules), '^\d+\.\d+', "Inline")
}
[Array] $azureInstalledModules = Get-ChildItem -Path "C:\Modules\azure_*" -Directory | ForEach-Object { $_.Name.Split("_")[1] } | ForEach-Object { if ($_ -eq $defaultAzureModuleVersion) { "$($_) (Default)" } else { $_ } }
if ($azureInstalledModules.Count -gt 0) {
$result += "Azure: $($azureInstalledModules -join ', ')"
$result += [ToolVersionsListNode]::new("Azure", $($azureInstalledModules), '^\d+\.\d+', "Inline")
}
[Array] $azurermInstalledModules = Get-ChildItem -Path "C:\Modules\azurerm_*" -Directory | ForEach-Object { $_.Name.Split("_")[1] } | ForEach-Object { if ($_ -eq $defaultAzureModuleVersion) { "$($_) (Default)" } else { $_ } }
if ($azurermInstalledModules.Count -gt 0) {
$result += "AzureRM: $($azurermInstalledModules -join ', ')"
$result += [ToolVersionsListNode]::new("AzureRM", $($azurermInstalledModules), '^\d+\.\d+', "Inline")
}
[Array] $azCachedModules = Get-ChildItem -Path "C:\Modules\az_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] }
if ($azCachedModules.Count -gt 0) {
$result += "Az (Cached): $($azCachedModules -join ', ')"
$result += [ToolVersionsListNode]::new("Az (Cached)", $($azCachedModules), '^\d+\.\d+', "Inline")
}
[Array] $azureCachedModules = Get-ChildItem -Path "C:\Modules\azure_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] }
if ($azureCachedModules.Count -gt 0) {
$result += "Azure (Cached): $($azureCachedModules -join ', ')"
$result += [ToolVersionsListNode]::new("Azure (Cached)", $($azureCachedModules), '^\d+\.\d+', "Inline")
}
[Array] $azurermCachedModules = Get-ChildItem -Path "C:\Modules\azurerm_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] }
if ($azurermCachedModules.Count -gt 0) {
$result += "AzureRM: $($azurermCachedModules -join ', ')"
$result += [ToolVersionsListNode]::new("AzureRM (Cached)", $($azurermCachedModules), '^\d+\.\d+', "Inline")
}
return $result
@@ -275,7 +280,7 @@ function Get-PowerShellModules {
$result += (Get-ToolsetContent).powershellModules.name | Sort-Object | ForEach-Object {
$moduleName = $_
$moduleVersions = Get-Module -Name $moduleName -ListAvailable | Select-Object -ExpandProperty Version | Sort-Object -Unique
return "$($moduleName): $($moduleVersions -join ', ')"
return [ToolVersionsListNode]::new($moduleName, $moduleVersions, '^\d+', "Inline")
}
return $result
@@ -302,14 +307,13 @@ function Get-CachedDockerImagesTableData {
}
function Get-ShellTarget {
$shells = Get-ChildItem C:\shells -File | Select-Object Name, @{n="Target";e={
return Get-ChildItem C:\shells -File | Select-Object Name, @{n="Target";e={
if ($_.Name -eq "msys2bash.cmd") {
"C:\msys64\usr\bin\bash.exe"
} else {
@($_.Target)[0]
}
}} | Sort-Object Name
$shells | New-MDTable -Columns ([ordered]@{Name = "left"; Target = "left";})
}
function Get-PacmanVersion {
@@ -318,21 +322,21 @@ function Get-PacmanVersion {
$rawVersion = & $pacmanPath --version
$rawVersion.Split([System.Environment]::NewLine)[1] -match "\d+\.\d+(\.\d+)?" | Out-Null
$pacmanVersion = $matches[0]
return "Pacman $pacmanVersion"
return $pacmanVersion
}
function Get-YAMLLintVersion {
yamllint --version
return ((yamllint --version) -replace "^yamllint").Trim()
}
function Get-BizTalkVersion {
$bizTalkReg = Get-ItemProperty "HKLM:\SOFTWARE\WOW6432Node\Microsoft\BizTalk Server\3.0"
return "$($bizTalkReg.ProductName) $($bizTalkReg.ProductVersion)"
return [ToolVersionNode]::new($bizTalkReg.ProductName, $bizTalkReg.ProductVersion)
}
function Get-PipxVersion {
$pipxVersion = pipx --version
return "Pipx $pipxVersion"
return $pipxVersion
}
function Build-PackageManagementEnvironmentTable {