Skip to content

Remove preview label from marketplace #4464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions .vsts-ci/templates/ci-general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ parameters:
default: false

steps:
- task: PowerShell@2
displayName: PowerShell version
inputs:
targetType: inline
script: $PSVersionTable
pwsh: ${{ parameters.pwsh }}

- checkout: self

# NOTE: We either checkout the Git repo for PowerShellEditorServices, or we
Expand Down Expand Up @@ -62,19 +55,32 @@ steps:
version: 6.0.x
performMultiLevelLookup: true

# The build script is always run with PowerShell Core
- task: PowerShell@2
displayName: Build and test
displayName: Build and package
inputs:
targetType: inline
script: |
Get-ChildItem env:
Get-Module -ListAvailable Pester
Install-Module InvokeBuild -Scope CurrentUser -Force
Install-Module platyPS -Scope CurrentUser -Force
Invoke-Build -Configuration Release
Invoke-Build -Configuration Release Package
$PackageJson = Get-Content -Raw package.json | ConvertFrom-Json
Write-Host "##vso[task.setvariable variable=vsixPath]$(Resolve-Path powershell-$($PackageJson.version).vsix)"
workingDirectory: $(Build.SourcesDirectory)/vscode-powershell
pwsh: true

# Tests in particular are run with either PowerShell Core or Windows PowerShell
- task: PowerShell@2
displayName: Run unit tests
inputs:
targetType: inline
script: |
$PSVersionTable
Get-ChildItem env:
Get-Module -ListAvailable Pester
Install-Module InvokeBuild -Scope CurrentUser -Force
Invoke-Build -Configuration Release Test
workingDirectory: $(Build.SourcesDirectory)/vscode-powershell
pwsh: ${{ parameters.pwsh }}

- task: PowerShell@2
Expand All @@ -87,7 +93,7 @@ steps:
Write-Host '##vso[task.LogIssue type=error;]PowerShell Editor Services bits were not built in release configuration!'
exit 1
}
pwsh: ${{ parameters.pwsh }}
pwsh: true

- publish: $(vsixPath)
artifact: vscode-powershell-vsix-$(System.JobId)
Expand Down
8 changes: 5 additions & 3 deletions .vsts-ci/templates/publish-markets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ steps:

- pwsh: |
npm ci --loglevel=error
$PackageJson = Get-Content -Raw $(Build.SourcesDirectory)/package.json | ConvertFrom-Json
Import-Module $(Build.SourcesDirectory)/tools/VersionTools.psm1
$Version = Get-Version -RepositoryName vscode-powershell
$PackageVersion = Get-MajorMinorPatch -Version $Version
$PublishArgs = @(
if ($PackageJson.preview) { '--pre-release' }
if (Test-IsPreRelease) { '--pre-release' }
'--packagePath'
"$(Pipeline.Workspace)/vscode-powershell/powershell-$($PackageJson.version).vsix"
"$(Pipeline.Workspace)/vscode-powershell/powershell-$PackageVersion.vsix"
'--pat'
'$(VsceToken)'
)
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ major update.

These major updates have also been tested over the last 6 months, in 13 releases of our
[PowerShell Preview extension for Visual Studio
Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell-preview). A
Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode.powershell). A
huge thank you to all of the community members who have tested these changes to the
extension and have worked with us to polish the extension before releasing it through our
stable channel.
Expand Down Expand Up @@ -1079,7 +1079,7 @@ are updating the stable extension to bring some bug fixes forward. Please try ou
[PowerShell Preview extension][] for the latest and hopefully greatest experience, and
help us squash those bugs!

[PowerShell Preview extension]: https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell-Preview
[PowerShell Preview extension]: https://marketplace.visualstudio.com/items?itemName=ms-vscode.powershell

#### [PowerShellEditorServices](https://github.com/PowerShell/PowerShellEditorServices)

Expand Down
2 changes: 1 addition & 1 deletion extension-dev.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"josefpihrt-vscode.roslynator",
"ms-azure-devops.azure-pipelines",
"ms-dotnettools.csharp",
"ms-vscode.powershell-preview"
"ms-vscode.powershell"
]
},
"settings": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "powershell",
"displayName": "PowerShell",
"version": "2023.3.1",
"preview": true,
"preview": false,
"publisher": "ms-vscode",
"description": "Develop PowerShell modules, commands and scripts in Visual Studio Code!",
"engines": {
Expand All @@ -23,7 +23,7 @@
"PowerShell",
"pwsh"
],
"icon": "media/PowerShell_Preview_Icon.png",
"icon": "media/PowerShell_Icon.png",
"galleryBanner": {
"color": "#ACD1EC",
"theme": "light"
Expand Down
5 changes: 2 additions & 3 deletions src/features/ExternalApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ export class ExternalApiFeature extends LanguageClientConsumer implements IPower
throw new Error(`No extension installed with id '${id}'. You must use a valid extension id.`);
}

// These are only allowed to be used in our unit tests.
if ((id === "ms-vscode.powershell" || id === "ms-vscode.powershell-preview")
&& !(this.extensionContext.extensionMode === vscode.ExtensionMode.Test)) {
// Our ID is only only allowed to be used in our unit tests.
if (id === "ms-vscode.powershell" && !(this.extensionContext.extensionMode === vscode.ExtensionMode.Test)) {
throw new Error("You can't use the PowerShell extension's id in this registration.");
}

Expand Down
8 changes: 0 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower

telemetryReporter = new TelemetryReporter(PackageJSON.name, PackageJSON.version, AI_KEY);

// If both extensions are enabled, this will cause unexpected behavior since both register the same commands.
// TODO: Merge extensions and use preview channel in marketplace instead.
if (PackageJSON.name.toLowerCase() === "powershell-preview"
&& vscode.extensions.getExtension("ms-vscode.powershell")) {
void logger.writeAndShowError(
"'PowerShell' and 'PowerShell Preview' are both enabled. Please disable one for best performance.");
}

// Load and validate settings (will prompt for 'cwd' if necessary).
await validateCwdSetting(logger);
const settings = getSettings();
Expand Down
125 changes: 21 additions & 104 deletions tools/ReleaseTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,26 @@
using module PowerShellForGitHub
using namespace System.Management.Automation

class RepoNames: IValidateSetValuesGenerator {
# NOTE: This is super over-engineered, but it was fun.
static [string[]] $Values = "vscode-powershell", "PowerShellEditorServices"
[String[]] GetValidValues() { return [RepoNames]::Values }
}

$ChangelogFile = "CHANGELOG.md"
Import-Module $PSScriptRoot/VersionTools.psm1

<#
.SYNOPSIS
Given the repository name, execute the script in its directory.
Creates and checks out `release` if not already on it.
#>
function Use-Repository {
[CmdletBinding()]
function Update-Branch {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)]
[ValidateSet([RepoNames])]
[string]$RepositoryName,

[Parameter(Mandatory)]
[scriptblock]$Script
[string]$RepositoryName
)
try {
switch ($RepositoryName) {
"vscode-powershell" {
Push-Location -Path "$PSScriptRoot/../"
}
"PowerShellEditorServices" {
Push-Location -Path "$PSScriptRoot/../../PowerShellEditorServices"
Use-Repository -RepositoryName $RepositoryName -Script {
$Branch = git branch --show-current
if ($Branch -ne "release") {
if ($PSCmdlet.ShouldProcess("release", "git checkout -B")) {
git checkout -B "release"
}
}
& $Script
} finally {
Pop-Location
}
}

Expand Down Expand Up @@ -143,72 +129,6 @@ function Get-Bullets {
}
}

<#
.SYNOPSIS
Gets the unpublished content from the changelog.
.DESCRIPTION
This is used so that we can manually touch-up the automatically updated
changelog, and then bring its contents into the extension's changelog or
the GitHub release. It just gets the first header's contents.
#>
function Get-FirstChangelog {
param(
[Parameter(Mandatory)]
[ValidateSet([RepoNames])]
[string]$RepositoryName
)
$Changelog = Use-Repository -RepositoryName $RepositoryName -Script {
Get-Content -Path $ChangelogFile
}
# NOTE: The space after the header marker is important! Otherwise ### matches.
$Header = $Changelog.Where({$_.StartsWith("## ")}, "First")
$Changelog.Where(
{ $_ -eq $Header }, "SkipUntil"
).Where(
{ $_.StartsWith("## ") -and $_ -ne $Header }, "Until"
)
}

<#
.SYNOPSIS
Creates and checks out `release` if not already on it.
#>
function Update-Branch {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)]
[ValidateSet([RepoNames])]
[string]$RepositoryName
)
Use-Repository -RepositoryName $RepositoryName -Script {
$Branch = git branch --show-current
if ($Branch -ne "release") {
if ($PSCmdlet.ShouldProcess("release", "git checkout -B")) {
git checkout -B "release"
}
}
}
}

<#
.SYNOPSIS
Gets current version from changelog as `[semver]`.
#>
function Get-Version {
param(
[Parameter(Mandatory)]
[ValidateSet([RepoNames])]
[string]$RepositoryName
)
# NOTE: The first line should always be the header.
$Changelog = (Get-FirstChangelog -RepositoryName $RepositoryName)[0]
if ($Changelog -match '## v(?<version>\d+\.\d+\.\d+(-preview\.?\d*)?)') {
return [semver]$Matches.version
} else {
Write-Error "Couldn't find version from changelog!"
}
}

<#
.SYNOPSIS
Updates the CHANGELOG file with PRs merged since the last release.
Expand All @@ -224,9 +144,8 @@ function Update-Changelog {
[ValidateSet([RepoNames])]
[string]$RepositoryName,

# TODO: Validate version style for each repo.
[Parameter(Mandatory)]
[ValidateScript({ $_.StartsWith("v") })]
[ValidateScript({ Test-VersionIsValid -RepositoryName $RepositoryName -Version $_ })]
[string]$Version
)

Expand Down Expand Up @@ -300,8 +219,8 @@ function Update-Changelog {

- package.json:
- `version` field with `"X.Y.Z"` and no prefix or suffix
- `preview` field set to `true` or `false` if version is a preview
- `icon` field has `_Preview ` inserted if preview
- `preview` field is always `false` because now we do "pre-releases"
- TODO: `icon` field has `_Preview ` inserted if preview
#>
function Update-Version {
[CmdletBinding(SupportsShouldProcess)]
Expand All @@ -311,28 +230,26 @@ function Update-Version {
[string]$RepositoryName
)
$Version = Get-Version -RepositoryName $RepositoryName
$v = "$($Version.Major).$($Version.Minor).$($Version.Patch)"
$v = Get-MajorMinorPatch -Version $Version

Update-Branch -RepositoryName $RepositoryName

Use-Repository -RepositoryName $RepositoryName -Script {
switch ($RepositoryName) {
"vscode-powershell" {
if ($Version.PreReleaseLabel) {
$preview = "true"
$icon = "media/PowerShell_Preview_Icon.png"
} else {
$preview = "false"
$icon = "media/PowerShell_Icon.png"
}
# TODO: Bring this back when the marketplace supports it.
# if ($Version.PreReleaseLabel) {
# $icon = "media/PowerShell_Preview_Icon.png"
# } else {
# $icon = "media/PowerShell_Icon.png"
# }

$path = "package.json"
$f = Get-Content -Path $path
# NOTE: The prefix regex match two spaces exactly to avoid matching
# nested objects in the file.
$f = $f -replace '^(?<prefix> "version":\s+")(.+)(?<suffix>",)$', "`${prefix}${v}`${suffix}"
$f = $f -replace '^(?<prefix> "preview":\s+)(.+)(?<suffix>,)$', "`${prefix}${preview}`${suffix}"
$f = $f -replace '^(?<prefix> "icon":\s+")(.+)(?<suffix>",)$', "`${prefix}${icon}`${suffix}"
# TODO: $f = $f -replace '^(?<prefix> "icon":\s+")(.+)(?<suffix>",)$', "`${prefix}${icon}`${suffix}"
$f | Set-Content -Path $path
git add $path
}
Expand Down
Loading