Skip to content

Commit b6ab339

Browse files
Merge pull request #4462 from PowerShell/andschwa/combine-extensions
Adopt the pre-release extension feature
2 parents dfd2bba + b05a3f9 commit b6ab339

File tree

6 files changed

+37
-54
lines changed

6 files changed

+37
-54
lines changed

Diff for: .vsts-ci/templates/ci-general.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ steps:
7272
Install-Module InvokeBuild -Scope CurrentUser -Force
7373
Install-Module platyPS -Scope CurrentUser -Force
7474
Invoke-Build -Configuration Release
75-
Write-Host "##vso[task.setvariable variable=vsixPath]$(Resolve-Path powershell-*.vsix)"
75+
$PackageJson = Get-Content -Raw package.json | ConvertFrom-Json
76+
Write-Host "##vso[task.setvariable variable=vsixPath]$(Resolve-Path powershell-$($PackageJson.version).vsix)"
7677
workingDirectory: $(Build.SourcesDirectory)/vscode-powershell
7778
pwsh: ${{ parameters.pwsh }}
7879

@@ -81,9 +82,9 @@ steps:
8182
inputs:
8283
targetType: inline
8384
script: |
84-
$assembly = [Reflection.Assembly]::LoadFile("$(Build.SourcesDirectory)/vscode-powershell/modules/PowerShellEditorServices.VSCode/bin/Microsoft.PowerShell.EditorServices.VSCode.dll")
85+
$assembly = [Reflection.Assembly]::LoadFile('$(Build.SourcesDirectory)/vscode-powershell/modules/PowerShellEditorServices.VSCode/bin/Microsoft.PowerShell.EditorServices.VSCode.dll')
8586
if ($assembly.GetCustomAttributes([System.Diagnostics.DebuggableAttribute], $true).IsJITOptimizerDisabled) {
86-
Write-Host "##vso[task.LogIssue type=error;] PowerShell Editor Services bits were not built in release configuration!"
87+
Write-Host '##vso[task.LogIssue type=error;]PowerShell Editor Services bits were not built in release configuration!'
8788
exit 1
8889
}
8990
pwsh: ${{ parameters.pwsh }}

Diff for: .vsts-ci/templates/publish-github.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ steps:
66
displayName: Download signed artifacts
77

88
- pwsh: |
9+
$PackageJson = Get-Content -Raw $(Build.SourcesDirectory)/package.json | ConvertFrom-Json
910
$(Build.SourcesDirectory)/tools/setupReleaseTools.ps1 -Token $(GitHubToken)
10-
New-DraftRelease -RepositoryName vscode-powershell -Assets $(Pipeline.Workspace)/vscode-powershell/powershell-*.vsix,$(Pipeline.Workspace)/vscode-powershell/Install-VSCode.ps1
11+
New-DraftRelease -RepositoryName vscode-powershell -Assets $(Pipeline.Workspace)/vscode-powershell/powershell-$($PackageJson.version).vsix,$(Pipeline.Workspace)/vscode-powershell/Install-VSCode.ps1
1112
displayName: Drafting a GitHub Release

Diff for: .vsts-ci/templates/publish-markets.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ steps:
77

88
- pwsh: |
99
npm ci --loglevel=error
10-
npm run publish -- --packagePath $(Pipeline.Workspace)/vscode-powershell/powershell-*.vsix --pat $(VsceToken)
10+
$PackageJson = Get-Content -Raw $(Build.SourcesDirectory)/package.json | ConvertFrom-Json
11+
$PublishArgs = @(
12+
if ($PackageJson.preview) { '--pre-release' }
13+
'--packagePath'
14+
"$(Pipeline.Workspace)/vscode-powershell/powershell-$($PackageJson.version).vsix"
15+
'--pat'
16+
'$(VsceToken)'
17+
)
18+
npm run publish -- @PublishArgs
1119
displayName: Publishing VSIX to VS Code Marketplace
1220

1321
# NOTE: We rarely update this script, so we can ignore errors from the gallery

Diff for: package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "powershell-preview",
3-
"displayName": "PowerShell Preview",
2+
"name": "powershell",
3+
"displayName": "PowerShell",
44
"version": "2023.3.0",
55
"preview": true,
66
"publisher": "ms-vscode",
7-
"description": "(Preview) Develop PowerShell modules, commands and scripts in Visual Studio Code!",
7+
"description": "Develop PowerShell modules, commands and scripts in Visual Studio Code!",
88
"engines": {
99
"vscode": "^1.67.0"
1010
},

Diff for: tools/ReleaseTools.psm1

+1-15
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,7 @@ function Update-Changelog {
301301
- package.json:
302302
- `version` field with `"X.Y.Z"` and no prefix or suffix
303303
- `preview` field set to `true` or `false` if version is a preview
304-
- `name` field has `-preview` appended similarly
305-
- `displayName` field has ` Preview` appended similarly
306-
- `description` field has `(Preview) ` prepended similarly
307-
- `icon` field has `_Preview ` inserted similarly
304+
- `icon` field has `_Preview ` inserted if preview
308305
#>
309306
function Update-Version {
310307
[CmdletBinding(SupportsShouldProcess)]
@@ -318,34 +315,23 @@ function Update-Version {
318315

319316
Update-Branch -RepositoryName $RepositoryName
320317

321-
# TODO: Maybe cleanup the replacement logic.
322318
Use-Repository -RepositoryName $RepositoryName -Script {
323319
switch ($RepositoryName) {
324320
"vscode-powershell" {
325-
$d = "Develop PowerShell modules, commands and scripts in Visual Studio Code!"
326321
if ($Version.PreReleaseLabel) {
327-
$name = "powershell-preview"
328-
$displayName = "PowerShell Preview"
329322
$preview = "true"
330-
$description = "(Preview) $d"
331323
$icon = "media/PowerShell_Preview_Icon.png"
332324
} else {
333-
$name = "powershell"
334-
$displayName = "PowerShell"
335325
$preview = "false"
336-
$description = $d
337326
$icon = "media/PowerShell_Icon.png"
338327
}
339328

340329
$path = "package.json"
341330
$f = Get-Content -Path $path
342331
# NOTE: The prefix regex match two spaces exactly to avoid matching
343332
# nested objects in the file.
344-
$f = $f -replace '^(?<prefix> "name":\s+")(.+)(?<suffix>",)$', "`${prefix}${name}`${suffix}"
345-
$f = $f -replace '^(?<prefix> "displayName":\s+")(.+)(?<suffix>",)$', "`${prefix}${displayName}`${suffix}"
346333
$f = $f -replace '^(?<prefix> "version":\s+")(.+)(?<suffix>",)$', "`${prefix}${v}`${suffix}"
347334
$f = $f -replace '^(?<prefix> "preview":\s+)(.+)(?<suffix>,)$', "`${prefix}${preview}`${suffix}"
348-
$f = $f -replace '^(?<prefix> "description":\s+")(.+)(?<suffix>",)$', "`${prefix}${description}`${suffix}"
349335
$f = $f -replace '^(?<prefix> "icon":\s+")(.+)(?<suffix>",)$', "`${prefix}${icon}`${suffix}"
350336
$f | Set-Content -Path $path
351337
git add $path

Diff for: vscode-powershell.build.ps1

+18-31
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ param(
1111

1212
# Grab package.json data which is used throughout the build.
1313
$script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json
14-
$script:IsPreviewExtension = $script:PackageJson.name -like "*preview*" -or $script:PackageJson.displayName -like "*preview*"
1514
Write-Host "`n### Extension: $($script:PackageJson.name)-$($script:PackageJson.version)`n" -ForegroundColor Green
1615

1716
function Get-EditorServicesPath {
@@ -32,9 +31,9 @@ task RestoreNodeModules -If { !(Test-Path ./node_modules) } {
3231
# When in a CI build use the --loglevel=error parameter so that
3332
# package install warnings don't cause PowerShell to throw up
3433
if ($env:TF_BUILD) {
35-
exec { & npm ci --loglevel=error }
34+
Invoke-BuildExec { & npm ci --loglevel=error }
3635
} else {
37-
exec { & npm install }
36+
Invoke-BuildExec { & npm install }
3837
}
3938
}
4039

@@ -45,7 +44,7 @@ task RestoreEditorServices -If (Get-EditorServicesPath) {
4544
# that developers always have the latest local bits.
4645
if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -ne "SymbolicLink") {
4746
Write-Host "`n### Creating symbolic link to PSES" -ForegroundColor Green
48-
remove ./modules
47+
Remove-BuildItem ./modules
4948
New-Item -ItemType SymbolicLink -Path ./modules -Target "$(Split-Path (Get-EditorServicesPath))/module"
5049
}
5150

@@ -57,7 +56,7 @@ task RestoreEditorServices -If (Get-EditorServicesPath) {
5756
# and only if they don't already exist.
5857
if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -eq "SymbolicLink") {
5958
Write-Host "`n### Deleting PSES symbolic link" -ForegroundColor Green
60-
remove ./modules
59+
Remove-BuildItem ./modules
6160
}
6261

6362
if (!(Test-Path ./modules)) {
@@ -81,7 +80,7 @@ task Restore RestoreEditorServices, RestoreNodeModules
8180

8281
task Clean {
8382
Write-Host "`n### Cleaning vscode-powershell`n" -ForegroundColor Green
84-
remove ./modules, ./out, ./node_modules, *.vsix
83+
Remove-BuildItem ./modules, ./out, ./node_modules, *.vsix
8584
}
8685

8786
task CleanEditorServices -If (Get-EditorServicesPath) {
@@ -94,9 +93,9 @@ task CleanEditorServices -If (Get-EditorServicesPath) {
9493

9594
task Build Restore, {
9695
Write-Host "`n### Building vscode-powershell`n" -ForegroundColor Green
97-
assert (Test-Path ./modules/PowerShellEditorServices/bin) "Extension requires PSES"
96+
Assert-Build (Test-Path ./modules/PowerShellEditorServices/bin) "Extension requires PSES"
9897

99-
exec { & npm run lint }
98+
Invoke-BuildExec { & npm run lint }
10099

101100
# TODO: When supported we should use `esbuild` for the tests too. Although
102101
# we now use `esbuild` to transpile, bundle, and minify the extension, we
@@ -105,8 +104,8 @@ task Build Restore, {
105104
# Unfortunately `esbuild` doesn't support emitting 1:1 files (yet).
106105
# https://github.com/evanw/esbuild/issues/944
107106
switch ($Configuration) {
108-
"Debug" { exec { & npm run build -- --sourcemap } }
109-
"Release" { exec { & npm run build -- --minify } }
107+
"Debug" { Invoke-BuildExec { & npm run build -- --sourcemap } }
108+
"Release" { Invoke-BuildExec { & npm run build -- --minify } }
110109
}
111110
}
112111

@@ -115,9 +114,9 @@ task Build Restore, {
115114

116115
task Test -If (!($env:TF_BUILD -and $global:IsLinux)) Build, {
117116
Write-Host "`n### Running extension tests" -ForegroundColor Green
118-
exec { & npm run test }
117+
Invoke-BuildExec { & npm run test }
119118
# Reset the state of files modified by tests
120-
exec { git checkout package.json test/.vscode/settings.json}
119+
Invoke-BuildExec { git checkout package.json test/.vscode/settings.json}
121120
}
122121

123122
task TestEditorServices -If (Get-EditorServicesPath) {
@@ -128,26 +127,14 @@ task TestEditorServices -If (Get-EditorServicesPath) {
128127
#endregion
129128
#region Package tasks
130129

131-
task UpdateReadme -If { $script:IsPreviewExtension } {
132-
# Add the preview text
133-
$newReadmeTop = '# PowerShell Language Support for Visual Studio Code
134-
135-
> ## ATTENTION: This is the PREVIEW version of the PowerShell extension for VSCode which contains features that are being evaluated for stable. It works with PowerShell 5.1 and up.
136-
> ### If you are looking for the stable version, please [go here](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell) or install the extension called "PowerShell" (not "PowerShell Preview")
137-
> ## NOTE: If you have both stable (aka "PowerShell") and preview (aka "PowerShell Preview") installed, you MUST [DISABLE](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension) one of them for the best performance. Docs on how to disable an extension can be found [here](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension)'
138-
$readmePath = (Join-Path $PSScriptRoot README.md)
139-
140-
$readmeContent = Get-Content -Path $readmePath
141-
if (!($readmeContent -match "This is the PREVIEW version of the PowerShell extension")) {
142-
$readmeContent[0] = $newReadmeTop
143-
$readmeContent | Set-Content $readmePath -Encoding utf8
144-
}
145-
}
146-
147-
task Package UpdateReadme, Build, {
130+
task Package Build, {
148131
Write-Host "`n### Packaging $($script:PackageJson.name)-$($script:PackageJson.version).vsix`n" -ForegroundColor Green
149-
assert ((Get-Item ./modules).LinkType -ne "SymbolicLink") "Packaging requires a copy of PSES, not a symlink!"
150-
exec { & npm run package }
132+
Assert-Build ((Get-Item ./modules).LinkType -ne "SymbolicLink") "Packaging requires a copy of PSES, not a symlink!"
133+
if ($script:PackageJson.preview) {
134+
Invoke-BuildExec { & npm run package -- --pre-release }
135+
} else {
136+
Invoke-BuildExec { & npm run package }
137+
}
151138
}
152139

153140
#endregion

0 commit comments

Comments
 (0)