-
Notifications
You must be signed in to change notification settings - Fork 537
Expand file tree
/
Copy pathvscode-powershell.build.ps1
More file actions
117 lines (94 loc) · 3.79 KB
/
vscode-powershell.build.ps1
File metadata and controls
117 lines (94 loc) · 3.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
param(
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Debug",
[string]$EditorServicesRepoPath = $null
)
#Requires -Modules @{ ModuleName = "InvokeBuild"; ModuleVersion = "5.0.0" }
function Get-EditorServicesPath {
$psesRepoPath = if ($EditorServicesRepoPath) {
$EditorServicesRepoPath
} else {
"$PSScriptRoot/../PowerShellEditorServices/"
}
# NOTE: The ErrorActionPreference for both Invoke-Build and Azure DevOps
# scripts is Stop, but we want to continue and return false here.
return Resolve-Path "$psesRepoPath/PowerShellEditorServices.build.ps1" -ErrorAction SilentlyContinue
}
#region Setup tasks
task RestoreNode -If { !(Test-Path ./node_modules/esbuild) } {
Write-Build DarkGreen "Restoring build dependencies"
Invoke-BuildExec { & npm ci --omit=optional }
}
task RestoreNodeOptional -If { !(Test-Path ./node_modules/eslint) } {
Write-Build DarkMagenta "Restoring build, test, and lint dependencies"
Invoke-BuildExec { & npm ci --include=optional }
}
task RestoreEditorServices -If (Get-EditorServicesPath) {
# With VSCE --follow-symlinks support, we can now use symlinks consistently
# for both Debug and Release configurations.
if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -ne "SymbolicLink") {
Write-Build DarkMagenta "Creating symbolic link to PSES"
Remove-BuildItem ./modules
New-Item -ItemType SymbolicLink -Path ./modules -Target "$(Split-Path (Get-EditorServicesPath))/module"
}
Write-Build DarkGreen "Building PSES"
Invoke-Build Build (Get-EditorServicesPath) -Configuration $Configuration
}
#endregion
#region Clean tasks
task Clean {
Write-Build DarkMagenta "Cleaning vscode-powershell"
Remove-BuildItem *.js, *.js.map, ./dist, ./modules, ./node_modules, ./out
}
task CleanEditorServices -If (Get-EditorServicesPath) {
Write-Build DarkMagenta "Cleaning PSES"
Invoke-Build Clean (Get-EditorServicesPath)
}
#endregion
#region Build tasks
task Lint RestoreNodeOptional, {
Write-Build DarkMagenta "Linting TypeScript"
Invoke-BuildExec { & npm run lint }
Write-Build DarkMagenta "Checking formatting of TypeScript, JSON, etc."
Invoke-BuildExec { & npm run format }
}
task Build RestoreEditorServices, RestoreNode, {
Write-Build DarkGreen "Building vscode-powershell"
Assert-Build (Test-Path ./modules/PowerShellEditorServices/bin) "Extension requires PSES"
switch ($Configuration) {
"Debug" { Invoke-BuildExec { & npm run compile } }
"Release" { Invoke-BuildExec { & npm run compile -- --minify } }
}
}
#endregion
#region Test tasks
task Test Lint, Build, {
Write-Build DarkMagenta "Running extension tests"
Invoke-BuildExec { & npm run test }
# Reset the state of files modified by tests
Invoke-BuildExec { git checkout test/TestEnvironment.code-workspace }
}
task TestEditorServices -If (Get-EditorServicesPath) {
Write-Build DarkMagenta "Testing PSES"
Invoke-Build Test (Get-EditorServicesPath)
}
#endregion
#region Package tasks
task Package {
[semver]$version = $((Get-Content -Raw -Path package.json | ConvertFrom-Json).version)
Write-Build DarkGreen "Packaging powershell-$version.vsix"
Remove-BuildItem ./out
New-Item -ItemType Directory -Force out | Out-Null
Assert-Build (Test-Path ./dist/extension.js) "Extension must be built!"
Assert-Build (Test-Path ./modules/PowerShellEditorServices/bin) "PowerShell Editor Services must be built under modules!"
if ($version.Minor % 2 -ne 0) {
Write-Build DarkRed "This is a pre-release!"
Invoke-BuildExec { & npm run package -- --pre-release }
} else {
Invoke-BuildExec { & npm run package }
}
}
#endregion
task . Test, Package