From 6218532278e739550a43ae146efcdebf1f97eb5a Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 15 Feb 2018 16:08:03 -0800 Subject: [PATCH 1/3] add build.ps1 --- build.ps1 | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 build.ps1 diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000000..69ad121d0a --- /dev/null +++ b/build.ps1 @@ -0,0 +1,121 @@ +#!/usr/bin/env pwsh +param( + [Parameter()] + [switch] + $Bootstrap, + + [Parameter()] + [switch] + $Clean, + + [Parameter()] + [switch] + $Test +) + +$NeededTools = @{ + VSCode = "Visual Studio Code" + NodeJS = "Node.js 6.0 or higher" + PowerShellGet = "PowerShellGet latest" + InvokeBuild = "InvokeBuild latest" +} + +if ((-not $PSVersionTable["OS"]) -or $PSVersionTable["OS"].Contains("Windows")) { + $OS = "Windows" +} elseif ($PSVersionTable["OS"].Contains("Darwin")) { + $OS = "macOS" +} else { + $OS = "Linux" +} + + +function needsVSCode () { + try { + $vscodeVersion = (code -v) + if (-not $vscodeVersion) { + Throw + } + } catch { + try { + $vscodeInsidersVersion = (code-insiders -v) + if (-not $vscodeInsidersVersion) { + Throw + } + } catch { + return $true + } + } + return $false +} + +function needsNodeJS () { + try { + $nodeJSVersion = (node -v) + + } catch { + return $true + } + return ($nodeJSVersion.Substring(1,1) -lt 6) +} + +function needsPowerShellGet () { + if (Get-Module -ListAvailable -Name PowerShellGet) { + return $false + } + return $true +} + +function needsInvokeBuild () { + if (Get-Module -ListAvailable -Name InvokeBuild) { + return $false + } + return $true +} + +function getMissingTools () { + $missingTools = @() + + if (needsVSCode) { + $missingTools += $NeededTools.VSCode + } + if (needsNodeJS) { + $missingTools += $NeededTools.NodeJS + } + if (needsPowerShellGet) { + $missingTools += $NeededTools.PowerShellGet + } + if (needsInvokeBuild) { + $missingTools += $NeededTools.InvokeBuild + } + + return $missingTools +} + +function hasMissingTools () { + return ((getMissingTools).Count -gt 0) +} + +if ($Bootstrap) { + $string = "Here is what your environment is missing:`n" + $missingTools = getMissingTools + if (($missingTools).Count -eq 0) { + $string += "* nothing!`n`n Run this script without a flag to build or a -Clean to clean." + } else { + $missingTools | ForEach-Object {$string += "* $_`n"} + $string += "`nAll instructions for installing these tools can be found on VSCode PowerShell's Github:`n" ` + + "https://github.com/PowerShell/vscode-powershell/blob/master/docs/development.md" + } + Write-Host "`n$string`n" +} elseif(hasMissingTools) { + Write-Host "You are missing needed tools. Run './build.ps1 -Bootstrap' to see what they are." +} else { + if($Clean) { + Invoke-Build Clean + } + + Invoke-Build Build + + if($Test) { + Invoke-Build Test + } +} \ No newline at end of file From 53dd3a2b5c45260321d067c53bc31e5b951e947a Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 20 Feb 2018 08:59:21 -0800 Subject: [PATCH 2/3] travis feedback --- build.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 69ad121d0a..699f7fe1b5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,4 +1,7 @@ #!/usr/bin/env pwsh +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + param( [Parameter()] [switch] @@ -118,4 +121,4 @@ if ($Bootstrap) { if($Test) { Invoke-Build Test } -} \ No newline at end of file +} From e36b794176630da48ba13c19bf2ed4b5b5a1b5a0 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Wed, 28 Feb 2018 17:02:44 -0800 Subject: [PATCH 3/3] address steve's feedback --- build.ps1 | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/build.ps1 b/build.ps1 index 699f7fe1b5..73159c40a4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,15 +3,15 @@ # Licensed under the MIT License. param( - [Parameter()] + [Parameter(ParameterSetName="Bootstrap")] [switch] $Bootstrap, - [Parameter()] + [Parameter(ParameterSetName="Build")] [switch] $Clean, - [Parameter()] + [Parameter(ParameterSetName="Build")] [switch] $Test ) @@ -23,15 +23,6 @@ $NeededTools = @{ InvokeBuild = "InvokeBuild latest" } -if ((-not $PSVersionTable["OS"]) -or $PSVersionTable["OS"].Contains("Windows")) { - $OS = "Windows" -} elseif ($PSVersionTable["OS"].Contains("Darwin")) { - $OS = "macOS" -} else { - $OS = "Linux" -} - - function needsVSCode () { try { $vscodeVersion = (code -v)