mirror of
https://github.com/actions/runner-images.git
synced 2025-12-10 19:16:48 +00:00
* Minor improvements * fix typos * fix brew rendering * add temp test * Implement tests * Add arguments validation * ToMarkdown() * Use before-All and helpers * Get rid of arrays * Add validation, no new nodes after header * Fix naming * add workflow * Revisit comments + tiny improvements * Fix tables * Fix html table indent * remove comment * attemp to break test - testing CI * revert breaking test * fix nitpicks
34 lines
1012 B
PowerShell
34 lines
1012 B
PowerShell
using module ./SoftwareReport.BaseNodes.psm1
|
|
using module ./SoftwareReport.Nodes.psm1
|
|
|
|
class SoftwareReport {
|
|
[ValidateNotNullOrEmpty()]
|
|
[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([String] $JsonString) {
|
|
$jsonObj = $JsonString | ConvertFrom-Json
|
|
$rootNode = [NodesFactory]::ParseNodeFromObject($jsonObj)
|
|
return [SoftwareReport]::new($rootNode)
|
|
}
|
|
|
|
[String] ToMarkdown() {
|
|
return $this.Root.ToMarkdown().Trim()
|
|
}
|
|
|
|
[String] GetImageVersion() {
|
|
$imageVersionNode = $this.Root.Children ?? @() | Where-Object { ($_ -is [ToolVersionNode]) -and ($_.ToolName -eq "Image Version:") } | Select-Object -First 1
|
|
return $imageVersionNode.Version ?? "Unknown version"
|
|
}
|
|
} |