-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathhealth.ps1
More file actions
85 lines (76 loc) · 2.79 KB
/
Copy pathhealth.ps1
File metadata and controls
85 lines (76 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
param(
[switch]$contribute
)
$ErrorActionPreference = 'silentlycontinue'
[regex]$regex = "\d+\.\d+\.*\d*"
$hasErrors = $false
$color = [System.ConsoleColor]::Red
if ( $PSVersionTable.PSVersion.Major -eq 5 ) {
$yes = [char]0x221A
$no = [char]0x03A7
} else {
$yes = "`u{2714} "
$no = "`u{274c}"
}
Write-Host "Starting Build Tools for VMware Aria Checks..."
# version should be at lest <major.minor>
@(
@{ name = "Java"; cmd = "java"; min = "17.0"; max = "24.0"; project = "all" },
@{ name = "Maven"; cmd = "mvn"; min = "3.9"; max = ""; project = "all" },
@{ name = "Node.js"; cmd = "node"; min = "22.0"; max = ""; project = "all" },
@{ name = "OpenSSL"; cmd = "openssl"; min = "3.0"; max = ""; project = "polyglot" },
@{ name = "Python"; cmd = "python"; min = "3.7"; max = "3.10"; project = "polyglot" },
@{ name = "Pip"; cmd = "pip"; min = "25.0"; max = "26.0"; project = "polyglot" },
@{ name = "PowerShell"; cmd = "pwsh"; min = "7.1"; max = "7.4"; project = "polyglot" }
) |
Group-Object -Property { $_.project } |
ForEach-Object {
$project = $_.Name
if ($contribute -eq $false -and $project -ne "all") {
return
}
else {
if($project -ne "all") {
Write-Host
Write-Host "Needed for '$($_.Name)' project" -ForegroundColor Yellow
}
}
$_.Group | ForEach-Object {
$version = $min = $max = $result = $null
$name = $_.name
$command = "$($_.cmd) --version"
$min = [Version]::Parse($_.min)
$max = [Version]::Parse($_.max)
$project = $_.project
$result = (Invoke-Expression $command)
if ($result -eq $null) {
Write-Host "$no $name is not installed" -ForegroundColor $color
if ($project -eq "all") {
$hasErrors = $true
}
return
}
$versionString = $result.Split([Environment]::NewLine)[0]
$version = [Version]::Parse($regex.Matches($versionString)[0].Value)
if ( ($version.CompareTo($min) -ge 0 -or $min -eq $null) -and ($version.CompareTo($max) -le 0 -or $max -eq $null) ) {
Write-Host "$yes $name version '$version' is within the required range ($min - $max)." -ForegroundColor Green
}
elseif ($project -eq "all") {
$hasErrors = $true
Write-Host "$no $name version '$version' is outside of the range ($min - $max)." -ForegroundColor Red
}
else {
Write-Host "$no $name version '$version' is outside of the range ($min - $max)." -ForegroundColor Yellow
}
}
}
Write-Host
if ( $hasErrors -eq $true ) {
Write-Host "Some checks failed. Please review the above messages." -ForegroundColor Red
}
else {
Write-Host "All mandatory checks passed successfully." -ForegroundColor Green
}
Write-Host
Write-Host "If your project is of type polyglot there might be additional dependencies required based on your selected runtime environment (e.g. Python or PowerShell)." -ForegroundColor Yellow
Write-Host