Skip to content

Commit e5528a9

Browse files
committed
Remove preview label from marketplace
We were using this as an easy way to determine if the version is a pre-release. However, the marketplace always looks a the latest version meaning it was placing a "preview" label and our preview icon on the webpage. So we had to write a different way to determine if the extension is a pre-release.
1 parent 970f18e commit e5528a9

File tree

4 files changed

+50
-22
lines changed

4 files changed

+50
-22
lines changed

.vsts-ci/templates/publish-markets.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ steps:
77

88
- pwsh: |
99
npm ci --loglevel=error
10-
$PackageJson = Get-Content -Raw $(Build.SourcesDirectory)/package.json | ConvertFrom-Json
10+
Import-Module $(Build.SourcesDirectory)/tools/ReleaseTools.psm1
11+
$Version = Get-Version -RepositoryName vscode-powershell
12+
$PackageVersion = Get-MajorMinorPatch -Version $Version
1113
$PublishArgs = @(
12-
if ($PackageJson.preview) { '--pre-release' }
14+
if (Test-IsPreRelease) { '--pre-release' }
1315
'--packagePath'
14-
"$(Pipeline.Workspace)/vscode-powershell/powershell-$($PackageJson.version).vsix"
16+
"$(Pipeline.Workspace)/vscode-powershell/powershell-$PackageVersion.vsix"
1517
'--pat'
1618
'$(VsceToken)'
1719
)

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "powershell",
33
"displayName": "PowerShell",
44
"version": "2023.3.1",
5-
"preview": true,
5+
"preview": false,
66
"publisher": "ms-vscode",
77
"description": "Develop PowerShell modules, commands and scripts in Visual Studio Code!",
88
"engines": {
@@ -23,7 +23,7 @@
2323
"PowerShell",
2424
"pwsh"
2525
],
26-
"icon": "media/PowerShell_Preview_Icon.png",
26+
"icon": "media/PowerShell_Icon.png",
2727
"galleryBanner": {
2828
"color": "#ACD1EC",
2929
"theme": "light"

tools/ReleaseTools.psm1

+32-12
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,28 @@ function Get-Version {
209209
}
210210
}
211211

212+
<#
213+
.SYNOPSIS
214+
Gets the version as a semantic version string without the 'v' prefix or
215+
pre-release suffix.
216+
#>
217+
function Get-MajorMinorPatch {
218+
param(
219+
[Parameter(Mandatory)]
220+
[semver]$Version
221+
)
222+
return "$($Version.Major).$($Version.Minor).$($Version.Patch)"
223+
}
224+
225+
<#
226+
.SYNOPSIS
227+
Tests if this is a pre-release (specifically for the extension).
228+
#>
229+
function Test-IsPreRelease {
230+
$Version = Get-Version -RepositoryName vscode-powershell
231+
return [bool]$Version.PreReleaseLabel
232+
}
233+
212234
<#
213235
.SYNOPSIS
214236
Validates the given version string.
@@ -341,8 +363,8 @@ function Update-Changelog {
341363
342364
- package.json:
343365
- `version` field with `"X.Y.Z"` and no prefix or suffix
344-
- `preview` field set to `true` or `false` if version is a preview
345-
- `icon` field has `_Preview ` inserted if preview
366+
- `preview` field is always `false` because now we do "pre-releases"
367+
- TODO: `icon` field has `_Preview ` inserted if preview
346368
#>
347369
function Update-Version {
348370
[CmdletBinding(SupportsShouldProcess)]
@@ -352,28 +374,26 @@ function Update-Version {
352374
[string]$RepositoryName
353375
)
354376
$Version = Get-Version -RepositoryName $RepositoryName
355-
$v = "$($Version.Major).$($Version.Minor).$($Version.Patch)"
377+
$v = Get-MajorMinorPatch -Version $Version
356378

357379
Update-Branch -RepositoryName $RepositoryName
358380

359381
Use-Repository -RepositoryName $RepositoryName -Script {
360382
switch ($RepositoryName) {
361383
"vscode-powershell" {
362-
if ($Version.PreReleaseLabel) {
363-
$preview = "true"
364-
$icon = "media/PowerShell_Preview_Icon.png"
365-
} else {
366-
$preview = "false"
367-
$icon = "media/PowerShell_Icon.png"
368-
}
384+
# TODO: Bring this back when the marketplace supports it.
385+
# if ($Version.PreReleaseLabel) {
386+
# $icon = "media/PowerShell_Preview_Icon.png"
387+
# } else {
388+
# $icon = "media/PowerShell_Icon.png"
389+
# }
369390

370391
$path = "package.json"
371392
$f = Get-Content -Path $path
372393
# NOTE: The prefix regex match two spaces exactly to avoid matching
373394
# nested objects in the file.
374395
$f = $f -replace '^(?<prefix> "version":\s+")(.+)(?<suffix>",)$', "`${prefix}${v}`${suffix}"
375-
$f = $f -replace '^(?<prefix> "preview":\s+)(.+)(?<suffix>,)$', "`${prefix}${preview}`${suffix}"
376-
$f = $f -replace '^(?<prefix> "icon":\s+")(.+)(?<suffix>",)$', "`${prefix}${icon}`${suffix}"
396+
# TODO: $f = $f -replace '^(?<prefix> "icon":\s+")(.+)(?<suffix>",)$', "`${prefix}${icon}`${suffix}"
377397
$f | Set-Content -Path $path
378398
git add $path
379399
}

vscode-powershell.build.ps1

+11-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ param(
77
[string]$EditorServicesRepoPath = $null
88
)
99

10-
#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.0.0"}
10+
#Requires -Modules @{ ModuleName = "InvokeBuild"; ModuleVersion = "3.0.0" }
1111

12-
# Grab package.json data which is used throughout the build.
12+
# Sanity check our changelog version versus package.json (which lacks pre-release label)
13+
Import-Module $PSScriptRoot/tools/ReleaseTools.psm1
14+
$script:Version = Get-Version -RepositoryName vscode-powershell
15+
$script:PackageVersion = Get-MajorMinorPatch -Version $Version
1316
$script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json
14-
Write-Host "`n### Extension: $($script:PackageJson.name)-$($script:PackageJson.version)`n" -ForegroundColor Green
17+
Assert-Build ($script:PackageJson.version -eq $script:PackageVersion)
18+
Write-Host "`n### Building Extension Version: $script:Version`n" -ForegroundColor Green
1519

1620
function Get-EditorServicesPath {
1721
$psesRepoPath = if ($EditorServicesRepoPath) {
@@ -95,6 +99,7 @@ task Build Restore, {
9599
Write-Host "`n### Building vscode-powershell`n" -ForegroundColor Green
96100
Assert-Build (Test-Path ./modules/PowerShellEditorServices/bin) "Extension requires PSES"
97101

102+
Write-Host "`n### Linting TypeScript`n" -ForegroundColor Green
98103
Invoke-BuildExec { & npm run lint }
99104

100105
# TODO: When supported we should use `esbuild` for the tests too. Although
@@ -128,9 +133,10 @@ task TestEditorServices -If (Get-EditorServicesPath) {
128133
#region Package tasks
129134

130135
task Package Build, {
131-
Write-Host "`n### Packaging $($script:PackageJson.name)-$($script:PackageJson.version).vsix`n" -ForegroundColor Green
136+
Write-Host "`n### Packaging powershell-$script:PackageVersion.vsix`n" -ForegroundColor Green
132137
Assert-Build ((Get-Item ./modules).LinkType -ne "SymbolicLink") "Packaging requires a copy of PSES, not a symlink!"
133-
if ($script:PackageJson.preview) {
138+
if (Test-IsPreRelease) {
139+
Write-Host "`n### This is a pre-release!`n" -ForegroundColor Green
134140
Invoke-BuildExec { & npm run package -- --pre-release }
135141
} else {
136142
Invoke-BuildExec { & npm run package }

0 commit comments

Comments
 (0)