From 4122dd73c75dc5e5821f957fd5938759d13ef325 Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Wed, 15 Mar 2023 11:51:23 -0700 Subject: [PATCH 1/4] Update release tools to combine preview and stable extensions Still need to pass `--pre-release` to the `vsce` scripts. --- package.json | 6 +++--- tools/ReleaseTools.psm1 | 16 +--------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index a0400870a3..352b9fb652 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "powershell-preview", - "displayName": "PowerShell Preview", + "name": "powershell", + "displayName": "PowerShell", "version": "2023.3.0", "preview": true, "publisher": "ms-vscode", - "description": "(Preview) Develop PowerShell modules, commands and scripts in Visual Studio Code!", + "description": "Develop PowerShell modules, commands and scripts in Visual Studio Code!", "engines": { "vscode": "^1.67.0" }, diff --git a/tools/ReleaseTools.psm1 b/tools/ReleaseTools.psm1 index 522c456030..4a9ce3093d 100644 --- a/tools/ReleaseTools.psm1 +++ b/tools/ReleaseTools.psm1 @@ -301,10 +301,7 @@ 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 - - `name` field has `-preview` appended similarly - - `displayName` field has ` Preview` appended similarly - - `description` field has `(Preview) ` prepended similarly - - `icon` field has `_Preview ` inserted similarly + - `icon` field has `_Preview ` inserted if preview #> function Update-Version { [CmdletBinding(SupportsShouldProcess)] @@ -318,22 +315,14 @@ function Update-Version { Update-Branch -RepositoryName $RepositoryName - # TODO: Maybe cleanup the replacement logic. Use-Repository -RepositoryName $RepositoryName -Script { switch ($RepositoryName) { "vscode-powershell" { - $d = "Develop PowerShell modules, commands and scripts in Visual Studio Code!" if ($Version.PreReleaseLabel) { - $name = "powershell-preview" - $displayName = "PowerShell Preview" $preview = "true" - $description = "(Preview) $d" $icon = "media/PowerShell_Preview_Icon.png" } else { - $name = "powershell" - $displayName = "PowerShell" $preview = "false" - $description = $d $icon = "media/PowerShell_Icon.png" } @@ -341,11 +330,8 @@ function Update-Version { $f = Get-Content -Path $path # NOTE: The prefix regex match two spaces exactly to avoid matching # nested objects in the file. - $f = $f -replace '^(? "name":\s+")(.+)(?",)$', "`${prefix}${name}`${suffix}" - $f = $f -replace '^(? "displayName":\s+")(.+)(?",)$', "`${prefix}${displayName}`${suffix}" $f = $f -replace '^(? "version":\s+")(.+)(?",)$', "`${prefix}${v}`${suffix}" $f = $f -replace '^(? "preview":\s+)(.+)(?,)$', "`${prefix}${preview}`${suffix}" - $f = $f -replace '^(? "description":\s+")(.+)(?",)$', "`${prefix}${description}`${suffix}" $f = $f -replace '^(? "icon":\s+")(.+)(?",)$', "`${prefix}${icon}`${suffix}" $f | Set-Content -Path $path git add $path From 41003c10f76724ba01e11f520b292f637a2cbfcd Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Wed, 15 Mar 2023 12:07:51 -0700 Subject: [PATCH 2/4] Update build script to package with `--pre-release` And not modify the readme with that note any more! --- vscode-powershell.build.ps1 | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1 index 1e170a3a1f..01ce533648 100644 --- a/vscode-powershell.build.ps1 +++ b/vscode-powershell.build.ps1 @@ -11,7 +11,6 @@ param( # Grab package.json data which is used throughout the build. $script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json -$script:IsPreviewExtension = $script:PackageJson.name -like "*preview*" -or $script:PackageJson.displayName -like "*preview*" Write-Host "`n### Extension: $($script:PackageJson.name)-$($script:PackageJson.version)`n" -ForegroundColor Green function Get-EditorServicesPath { @@ -128,26 +127,14 @@ task TestEditorServices -If (Get-EditorServicesPath) { #endregion #region Package tasks -task UpdateReadme -If { $script:IsPreviewExtension } { - # Add the preview text - $newReadmeTop = '# PowerShell Language Support for Visual Studio Code - -> ## 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. -> ### 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") -> ## 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)' - $readmePath = (Join-Path $PSScriptRoot README.md) - - $readmeContent = Get-Content -Path $readmePath - if (!($readmeContent -match "This is the PREVIEW version of the PowerShell extension")) { - $readmeContent[0] = $newReadmeTop - $readmeContent | Set-Content $readmePath -Encoding utf8 - } -} - -task Package UpdateReadme, Build, { +task Package Build, { Write-Host "`n### Packaging $($script:PackageJson.name)-$($script:PackageJson.version).vsix`n" -ForegroundColor Green assert ((Get-Item ./modules).LinkType -ne "SymbolicLink") "Packaging requires a copy of PSES, not a symlink!" - exec { & npm run package } + if ($script:PackageJson.preview) { + exec { & npm run package -- --pre-release } + } else { + exec { & npm run package } + } } #endregion From ca052fc84bfaeedae0187e67c867312a91da76e3 Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Wed, 15 Mar 2023 12:38:17 -0700 Subject: [PATCH 3/4] Update ADO to handle `--pre-release` And better quoting/pathing. --- .vsts-ci/templates/ci-general.yml | 7 ++++--- .vsts-ci/templates/publish-github.yml | 3 ++- .vsts-ci/templates/publish-markets.yml | 10 +++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index e0ca47be03..93018ec5be 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -72,7 +72,8 @@ steps: Install-Module InvokeBuild -Scope CurrentUser -Force Install-Module platyPS -Scope CurrentUser -Force Invoke-Build -Configuration Release - Write-Host "##vso[task.setvariable variable=vsixPath]$(Resolve-Path powershell-*.vsix)" + $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: ${{ parameters.pwsh }} @@ -81,9 +82,9 @@ steps: inputs: targetType: inline script: | - $assembly = [Reflection.Assembly]::LoadFile("$(Build.SourcesDirectory)/vscode-powershell/modules/PowerShellEditorServices.VSCode/bin/Microsoft.PowerShell.EditorServices.VSCode.dll") + $assembly = [Reflection.Assembly]::LoadFile('$(Build.SourcesDirectory)/vscode-powershell/modules/PowerShellEditorServices.VSCode/bin/Microsoft.PowerShell.EditorServices.VSCode.dll') if ($assembly.GetCustomAttributes([System.Diagnostics.DebuggableAttribute], $true).IsJITOptimizerDisabled) { - Write-Host "##vso[task.LogIssue type=error;] PowerShell Editor Services bits were not built in release configuration!" + Write-Host '##vso[task.LogIssue type=error;]PowerShell Editor Services bits were not built in release configuration!' exit 1 } pwsh: ${{ parameters.pwsh }} diff --git a/.vsts-ci/templates/publish-github.yml b/.vsts-ci/templates/publish-github.yml index c2c17feeda..7299cc56bb 100644 --- a/.vsts-ci/templates/publish-github.yml +++ b/.vsts-ci/templates/publish-github.yml @@ -6,6 +6,7 @@ steps: displayName: Download signed artifacts - pwsh: | + $PackageJson = Get-Content -Raw $(Build.SourcesDirectory)/package.json | ConvertFrom-Json $(Build.SourcesDirectory)/tools/setupReleaseTools.ps1 -Token $(GitHubToken) - New-DraftRelease -RepositoryName vscode-powershell -Assets $(Pipeline.Workspace)/vscode-powershell/powershell-*.vsix,$(Pipeline.Workspace)/vscode-powershell/Install-VSCode.ps1 + New-DraftRelease -RepositoryName vscode-powershell -Assets $(Pipeline.Workspace)/vscode-powershell/powershell-$($PackageJson.version).vsix,$(Pipeline.Workspace)/vscode-powershell/Install-VSCode.ps1 displayName: Drafting a GitHub Release diff --git a/.vsts-ci/templates/publish-markets.yml b/.vsts-ci/templates/publish-markets.yml index e7d278754b..538bacdb35 100644 --- a/.vsts-ci/templates/publish-markets.yml +++ b/.vsts-ci/templates/publish-markets.yml @@ -7,7 +7,15 @@ steps: - pwsh: | npm ci --loglevel=error - npm run publish -- --packagePath $(Pipeline.Workspace)/vscode-powershell/powershell-*.vsix --pat $(VsceToken) + $PackageJson = Get-Content -Raw $(Build.SourcesDirectory)/package.json | ConvertFrom-Json + $PublishArgs = @( + if ($PackageJson.preview) { '--pre-release' } + '--packagePath' + "$(Pipeline.Workspace)/vscode-powershell/powershell-$($PackageJson.version).vsix" + '--pat' + '$(VsceToken)' + ) + npm run publish -- @PublishArgs displayName: Publishing VSIX to VS Code Marketplace # NOTE: We rarely update this script, so we can ignore errors from the gallery From b05a3f935746c42afbe96282e95d47aa654309ab Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Wed, 15 Mar 2023 13:18:23 -0700 Subject: [PATCH 4/4] Expand `Invoke-Build` aliases for consistency --- vscode-powershell.build.ps1 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1 index 01ce533648..f31f990e8f 100644 --- a/vscode-powershell.build.ps1 +++ b/vscode-powershell.build.ps1 @@ -31,9 +31,9 @@ task RestoreNodeModules -If { !(Test-Path ./node_modules) } { # When in a CI build use the --loglevel=error parameter so that # package install warnings don't cause PowerShell to throw up if ($env:TF_BUILD) { - exec { & npm ci --loglevel=error } + Invoke-BuildExec { & npm ci --loglevel=error } } else { - exec { & npm install } + Invoke-BuildExec { & npm install } } } @@ -44,7 +44,7 @@ task RestoreEditorServices -If (Get-EditorServicesPath) { # that developers always have the latest local bits. if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -ne "SymbolicLink") { Write-Host "`n### Creating symbolic link to PSES" -ForegroundColor Green - remove ./modules + Remove-BuildItem ./modules New-Item -ItemType SymbolicLink -Path ./modules -Target "$(Split-Path (Get-EditorServicesPath))/module" } @@ -56,7 +56,7 @@ task RestoreEditorServices -If (Get-EditorServicesPath) { # and only if they don't already exist. if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -eq "SymbolicLink") { Write-Host "`n### Deleting PSES symbolic link" -ForegroundColor Green - remove ./modules + Remove-BuildItem ./modules } if (!(Test-Path ./modules)) { @@ -80,7 +80,7 @@ task Restore RestoreEditorServices, RestoreNodeModules task Clean { Write-Host "`n### Cleaning vscode-powershell`n" -ForegroundColor Green - remove ./modules, ./out, ./node_modules, *.vsix + Remove-BuildItem ./modules, ./out, ./node_modules, *.vsix } task CleanEditorServices -If (Get-EditorServicesPath) { @@ -93,9 +93,9 @@ task CleanEditorServices -If (Get-EditorServicesPath) { task Build Restore, { Write-Host "`n### Building vscode-powershell`n" -ForegroundColor Green - assert (Test-Path ./modules/PowerShellEditorServices/bin) "Extension requires PSES" + Assert-Build (Test-Path ./modules/PowerShellEditorServices/bin) "Extension requires PSES" - exec { & npm run lint } + Invoke-BuildExec { & npm run lint } # TODO: When supported we should use `esbuild` for the tests too. Although # we now use `esbuild` to transpile, bundle, and minify the extension, we @@ -104,8 +104,8 @@ task Build Restore, { # Unfortunately `esbuild` doesn't support emitting 1:1 files (yet). # https://github.com/evanw/esbuild/issues/944 switch ($Configuration) { - "Debug" { exec { & npm run build -- --sourcemap } } - "Release" { exec { & npm run build -- --minify } } + "Debug" { Invoke-BuildExec { & npm run build -- --sourcemap } } + "Release" { Invoke-BuildExec { & npm run build -- --minify } } } } @@ -114,9 +114,9 @@ task Build Restore, { task Test -If (!($env:TF_BUILD -and $global:IsLinux)) Build, { Write-Host "`n### Running extension tests" -ForegroundColor Green - exec { & npm run test } + Invoke-BuildExec { & npm run test } # Reset the state of files modified by tests - exec { git checkout package.json test/.vscode/settings.json} + Invoke-BuildExec { git checkout package.json test/.vscode/settings.json} } task TestEditorServices -If (Get-EditorServicesPath) { @@ -129,11 +129,11 @@ task TestEditorServices -If (Get-EditorServicesPath) { task Package Build, { Write-Host "`n### Packaging $($script:PackageJson.name)-$($script:PackageJson.version).vsix`n" -ForegroundColor Green - assert ((Get-Item ./modules).LinkType -ne "SymbolicLink") "Packaging requires a copy of PSES, not a symlink!" + Assert-Build ((Get-Item ./modules).LinkType -ne "SymbolicLink") "Packaging requires a copy of PSES, not a symlink!" if ($script:PackageJson.preview) { - exec { & npm run package -- --pre-release } + Invoke-BuildExec { & npm run package -- --pre-release } } else { - exec { & npm run package } + Invoke-BuildExec { & npm run package } } }