1+ # !/usr/bin/env pwsh
2+ param (
3+ [Parameter ()]
4+ [switch ]
5+ $Clean ,
6+
7+ [Parameter ()]
8+ [switch ]
9+ $BootstrapBuildEnv
10+ )
11+
12+ $NeededTools = @ {
13+ OpenSsl = " openssl for macOS"
14+ DotNet451TargetingPack = " .NET 4.5.1 Targeting Pack"
15+ PowerShellGet = " PowerShellGet latest"
16+ InvokeBuild = " InvokeBuild latest"
17+ }
18+
19+ if ((-not $PSVersionTable [" OS" ]) -or $PSVersionTable [" OS" ].Contains(" Windows" )) {
20+ $OS = " Windows"
21+ } elseif ($PSVersionTable [" OS" ].Contains(" Darwin" )) {
22+ $OS = " macOS"
23+ } else {
24+ $OS = " Linux"
25+ }
26+
27+
28+ function needsOpenSsl () {
29+ if ($OS -eq " macOS" ) {
30+ try {
31+ $opensslVersion = (openssl version)
32+ } catch {
33+ return $true
34+ }
35+ }
36+ return $false
37+ }
38+
39+ function needsDotNet451TargetingPack () {
40+ # how could we check for this?
41+ return $false
42+ }
43+
44+ function needsPowerShellGet () {
45+ if (Get-Module - ListAvailable - Name PowerShellGet) {
46+ return $false
47+ }
48+ return $true
49+ }
50+
51+ function needsInvokeBuild () {
52+ if (Get-Module - ListAvailable - Name InvokeBuild) {
53+ return $false
54+ }
55+ return $true
56+ }
57+
58+ function getMissingTools () {
59+ $missingTools = @ ()
60+
61+ if (needsOpenSsl) {
62+ $missingTools += $NeededTools.OpenSsl
63+ }
64+ if (needsDotNet451TargetingPack) {
65+ $missingTools += $NeededTools.DotNet451TargetingPack
66+ }
67+ if (needsPowerShellGet) {
68+ $missingTools += $NeededTools.PowerShellGet
69+ }
70+ if (needsInvokeBuild) {
71+ $missingTools += $NeededTools.InvokeBuild
72+ }
73+
74+ return $missingTools
75+ }
76+
77+ function hasMissingTools () {
78+ return ((getMissingTools).Count -gt 0 )
79+ }
80+
81+ if ($BootstrapBuildEnv ) {
82+ $string = " Here is what your environment is missing:`n "
83+ $missingTools = getMissingTools
84+ if (($missingTools ).Count -eq 0 ) {
85+ $string += " * nothing!`n`n Run this script without a flag to build or a -Clean to clean."
86+ } else {
87+ $missingTools | ForEach-Object {$string += " * $_ `n " }
88+ $string += " `n All instructions for installing these tools can be found on PowerShell Editor Services' Github:`n " `
89+ + " https://github.com/powershell/PowerShellEditorServices#development"
90+ }
91+ Write-Host " `n $string `n "
92+ } elseif ($Clean ) {
93+ Invoke-Build Clean
94+ } else {
95+ Invoke-Build Build
96+ }
0 commit comments