From f440023e7042a9d3b5e7796f231e44c07f24f702 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 25 Aug 2021 10:57:38 -0700 Subject: [PATCH 1/3] Update `vscode` engine to `1.56.0` This is the latest version that Azure Data Studio targets, and is greater than our current version. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6107ea0415..7e9ab29169 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "publisher": "ms-vscode", "description": "Develop PowerShell modules, commands and scripts in Visual Studio Code!", "engines": { - "vscode": "^1.53.0" + "vscode": "^1.56.0" }, "license": "SEE LICENSE IN LICENSE.txt", "homepage": "https://github.com/PowerShell/vscode-powershell/blob/master/README.md", @@ -63,7 +63,7 @@ "@types/semver": "~7.3.8", "@types/sinon": "~10.0.2", "@types/uuid": "~8.3.1", - "@types/vscode": "~1.53.0", + "@types/vscode": "~1.56.0", "@vscode/test-electron": "~1.6.2", "mocha": "~9.1.0", "mocha-junit-reporter": "~2.0.0", From d685d2847db6fc7df3542ced92597797ce32025d Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 25 Aug 2021 10:59:00 -0700 Subject: [PATCH 2/3] Run `npm update` and commit `package-lock.json` --- package-lock.json | 76 +++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index 20dc2a90f8..85ad5289a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,7 @@ "@types/semver": "~7.3.8", "@types/sinon": "~10.0.2", "@types/uuid": "~8.3.1", - "@types/vscode": "~1.53.0", + "@types/vscode": "~1.56.0", "@vscode/test-electron": "~1.6.2", "mocha": "~9.1.0", "mocha-junit-reporter": "~2.0.0", @@ -39,7 +39,7 @@ "vsce": "~1.96.1" }, "engines": { - "vscode": "^1.53.0" + "vscode": "^1.56.0" } }, "node_modules/@babel/code-frame": { @@ -224,9 +224,9 @@ } }, "node_modules/@types/node": { - "version": "14.17.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.9.tgz", - "integrity": "sha512-CMjgRNsks27IDwI785YMY0KLt3co/c0cQ5foxHYv/shC2w8oOnVwz5Ubq1QG5KzrcW+AXk6gzdnxIkDnTvzu3g==", + "version": "14.17.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.11.tgz", + "integrity": "sha512-n2OQ+0Bz6WEsUjrvcHD1xZ8K+Kgo4cn9/w94s1bJS690QMUWfJPW/m7CCb7gPkA1fcYwL2UpjXP/rq/Eo41m6w==", "dev": true }, "node_modules/@types/node-fetch": { @@ -267,9 +267,9 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.53.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.53.0.tgz", - "integrity": "sha512-XjFWbSPOM0EKIT2XhhYm3D3cx3nn3lshMUcWNy1eqefk+oqRuBq8unVb6BYIZqXy9lQZyeUl7eaBCOZWv+LcXQ==", + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.56.0.tgz", + "integrity": "sha512-Q5VmQxOx+L1Y6lIJiGcJzwcyV3pQo/eiW8P+7sNLhFI16tJCwtua2DLjHRcpjbCLNVYpQM73kzfFo1Z0HyP9eQ==", "dev": true }, "node_modules/@ungap/promise-all-settled": { @@ -468,6 +468,9 @@ "dependencies": { "buffers": "~0.1.1", "chainsaw": "~0.1.0" + }, + "engines": { + "node": "*" } }, "node_modules/binary-extensions": { @@ -595,6 +598,9 @@ "dev": true, "dependencies": { "traverse": ">=0.3.0 <0.4" + }, + "engines": { + "node": "*" } }, "node_modules/chalk": { @@ -678,9 +684,9 @@ } }, "node_modules/cheerio/node_modules/tslib": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", - "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", "dev": true }, "node_modules/chokidar": { @@ -1865,9 +1871,9 @@ "dev": true }, "node_modules/is-core-module": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.5.0.tgz", - "integrity": "sha512-TXCMSDsEHMEEZ6eCA8rwRDbLu55MRGmrctljsBX/2v1d9/GzqHOxW5c5oPSgrUt2vBFXebu9rGqckXGPWOlYpg==", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.6.0.tgz", + "integrity": "sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ==", "dev": true, "dependencies": { "has": "^1.0.3" @@ -3193,7 +3199,10 @@ "version": "0.3.9", "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, "node_modules/tslib": { "version": "1.14.1", @@ -3395,9 +3404,10 @@ } }, "node_modules/typed-rest-client": { - "version": "1.8.4", - "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.8.4.tgz", - "integrity": "sha512-MyfKKYzk3I6/QQp6e1T50py4qg+c+9BzOEl2rBmQIpStwNUoqQ73An+Tkfy9YuV7O+o2mpVVJpe+fH//POZkbg==", + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.8.5.tgz", + "integrity": "sha512-952/Aegu3lTqUAI1anbDLbewojnF/gh8at9iy1CIrfS1h/+MtNjB1Y9z6ZF5n2kZd+97em56lZ9uu7Zz3y/pwg==", + "deprecated": "1.8.5 contains changes that are not compatible with Node 6", "dev": true, "dependencies": { "qs": "^6.9.1", @@ -4030,9 +4040,9 @@ } }, "@types/node": { - "version": "14.17.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.9.tgz", - "integrity": "sha512-CMjgRNsks27IDwI785YMY0KLt3co/c0cQ5foxHYv/shC2w8oOnVwz5Ubq1QG5KzrcW+AXk6gzdnxIkDnTvzu3g==", + "version": "14.17.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.11.tgz", + "integrity": "sha512-n2OQ+0Bz6WEsUjrvcHD1xZ8K+Kgo4cn9/w94s1bJS690QMUWfJPW/m7CCb7gPkA1fcYwL2UpjXP/rq/Eo41m6w==", "dev": true }, "@types/node-fetch": { @@ -4073,9 +4083,9 @@ "dev": true }, "@types/vscode": { - "version": "1.53.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.53.0.tgz", - "integrity": "sha512-XjFWbSPOM0EKIT2XhhYm3D3cx3nn3lshMUcWNy1eqefk+oqRuBq8unVb6BYIZqXy9lQZyeUl7eaBCOZWv+LcXQ==", + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.56.0.tgz", + "integrity": "sha512-Q5VmQxOx+L1Y6lIJiGcJzwcyV3pQo/eiW8P+7sNLhFI16tJCwtua2DLjHRcpjbCLNVYpQM73kzfFo1Z0HyP9eQ==", "dev": true }, "@ungap/promise-all-settled": { @@ -4373,9 +4383,9 @@ }, "dependencies": { "tslib": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", - "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", "dev": true } } @@ -5295,9 +5305,9 @@ "dev": true }, "is-core-module": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.5.0.tgz", - "integrity": "sha512-TXCMSDsEHMEEZ6eCA8rwRDbLu55MRGmrctljsBX/2v1d9/GzqHOxW5c5oPSgrUt2vBFXebu9rGqckXGPWOlYpg==", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.6.0.tgz", + "integrity": "sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ==", "dev": true, "requires": { "has": "^1.0.3" @@ -6496,9 +6506,9 @@ "dev": true }, "typed-rest-client": { - "version": "1.8.4", - "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.8.4.tgz", - "integrity": "sha512-MyfKKYzk3I6/QQp6e1T50py4qg+c+9BzOEl2rBmQIpStwNUoqQ73An+Tkfy9YuV7O+o2mpVVJpe+fH//POZkbg==", + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.8.5.tgz", + "integrity": "sha512-952/Aegu3lTqUAI1anbDLbewojnF/gh8at9iy1CIrfS1h/+MtNjB1Y9z6ZF5n2kZd+97em56lZ9uu7Zz3y/pwg==", "dev": true, "requires": { "qs": "^6.9.1", From ddad0d8d3383a3496222d6d424f97c60bc83efb9 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 25 Aug 2021 11:05:44 -0700 Subject: [PATCH 3/3] Delete defunct scripts to update ADS These were fragile and stopped working a long time ago. After a discussion with the ADS maintainers, they're willing to manually pull in new PowerShell extension updates when they update ADS itself, so we don't need to rewrite these. --- tools/FileUpdateTools.psm1 | 230 ------ tools/GitHubTools.psm1 | 777 ------------------ .../updateAzureDataStudio.ps1 | 280 ------- 3 files changed, 1287 deletions(-) delete mode 100644 tools/FileUpdateTools.psm1 delete mode 100644 tools/GitHubTools.psm1 delete mode 100644 tools/postReleaseScripts/updateAzureDataStudio.ps1 diff --git a/tools/FileUpdateTools.psm1 b/tools/FileUpdateTools.psm1 deleted file mode 100644 index 35ed19de18..0000000000 --- a/tools/FileUpdateTools.psm1 +++ /dev/null @@ -1,230 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -#requires -Version 6.0 - -function ConvertToJToken -{ - param( - [Parameter()] - $Object - ) - - if ($null -eq $Object) - { - return [Newtonsoft.Json.Linq.JValue]::CreateNull() - } - - if ($Object -is [pscustomobject]) - { - $jObject = [Newtonsoft.Json.Linq.JObject]::new() - foreach ($field in $Object) - { - $jObject.Add($field, $Object.$field) - } - return $jObject - } - - if ($Object -is [version]) - { - return [Newtonsoft.Json.Linq.JToken]::new($Object.ToString()) - } - - return (,[Newtonsoft.Json.Linq.JToken]::FromObject($Object)) -} - -function New-StringWithSegment -{ - [OutputType([string])] - param( - [Parameter(Mandatory)] - [string] - $String, - - [Parameter(Mandatory)] - [string] - $NewSegment, - - [Parameter(Mandatory)] - [int] - $StartIndex, - - [Parameter()] - [int] - $EndIndex = $StartIndex, - - [switch] - $AutoIndent - ) - - if ($AutoIndent) - { - $indentBuilder = [System.Text.StringBuilder]::new() - $indentIdx = $StartIndex - 1 - $currChar = $String[$indentIdx] - while ($currChar -ne "`n") - { - $null = $indentBuilder.Append($currChar) - $indentIdx-- - $currChar = $String[$indentIdx] - } - $indent = $indentBuilder.ToString() - } - else - { - $indent = '' - } - - $newStringBuilder = [System.Text.StringBuilder]::new() - $null = $newStringBuilder.Append($String.Substring(0, $StartIndex)) - - $segmentLines = $NewSegment.Split("`n") - - $null = $newStringBuilder.Append($segmentLines[0]) - for ($i = 1; $i -lt $segmentLines.Length; $i++) - { - $null = $newStringBuilder.Append("`n").Append($indent).Append($segmentLines[$i]) - } - - $null = $newStringBuilder.Append($String.Substring($EndIndex)) - - return $newStringBuilder.ToString() -} - -function Get-StringOffsetFromSpan -{ - [OutputType([int])] - param( - [Parameter()] - [string] - $String, - - [Parameter()] - [int] - $EndLine, - - [Parameter()] - [int] - $StartLine = 1, - - [Parameter()] - [int] - $Column = 0, - - [Parameter()] - [int] - $InitialOffset = 0 - ) - - $lfChar = 0xA - - $idx = $InitialOffset - $spanLines = $EndLine - $StartLine - for ($i = 0; $i -lt $spanLines; $i++) - { - $idx = $String.IndexOf($lfChar, $idx + 1) - - if ($idx -lt 0) - { - return $idx - } - } - - return $idx + $Column -} - -function ConvertTo-IndentedJson -{ - param( - [Parameter(Position=0)] - $Object, - - [Parameter()] - [int] - $IndentWidth = 4, - - [Parameter()] - [char] - $IndentChar = ' ' - ) - - # Convert the object to a JToken - $jObject = ConvertToJToken $Object - - # Reformat the entry with tab-based indentation, like the existing file - $stringBuilder = [System.Text.StringBuilder]::new() - try - { - $stringWriter = [System.IO.StringWriter]::new($stringBuilder) - $jsonWriter = [Newtonsoft.Json.JsonTextWriter]::new($stringWriter) - $jsonWriter.Indentation = $IndentWidth - $jsonWriter.IndentChar = $IndentChar - $jsonWriter.Formatting = 'Indented' - $null = $jObject.WriteTo($jsonWriter) - } - finally - { - $jsonWriter.Dispose() - $stringWriter.Dispose() - } - return $stringBuilder.ToString().Replace([System.Environment]::NewLine, "`r`n") -} - -function Get-IncrementedVersion -{ - param( - [Parameter(Mandatory)] - [semver] - $Version, - - [Parameter(Mandatory)] - [ValidateSet('Major', 'Minor', 'Patch', 'Preview')] - [string] - $IncrementLevel - ) - - switch ($IncrementLevel) - { - 'Major' - { - return [semver]::new($version.Major+1, $version.Minor, $version.Patch, $version.PreReleaseLabel) - } - - 'Minor' - { - return [semver]::new($version.Major, $version.Minor+1, $version.Patch, $version.PreReleaseLabel) - } - - 'Patch' - { - return [semver]::new($version.Major, $version.Minor, $version.Patch+1, $version.PreReleaseLabel) - } - - 'Preview' - { - $newPreviewNumber = [int]$version.PreReleaseLabel.Substring(8) + 1 - return [semver]::new($version.Major, $version.Minor, $version.Patch, "preview.$newPreviewNumber") - } - } -} - -function Get-VersionFromSemVer -{ - [OutputType([version])] - param( - [Parameter(Mandatory)] - [semver] - $SemVer - ) - - $svStr = $SemVer.ToString() - - if (-not $SemVer.PreReleaseLabel) - { - return [version]$svStr - } - - return $svStr.Substring(0, $svStr.IndexOf('-')) -} - -Export-ModuleMember -Function New-StringWithSegment,Get-StringOffsetFromSpan,ConvertTo-IndentedJson,Get-IncrementedVersion,Get-VersionFromSemVer diff --git a/tools/GitHubTools.psm1 b/tools/GitHubTools.psm1 deleted file mode 100644 index 464a27c581..0000000000 --- a/tools/GitHubTools.psm1 +++ /dev/null @@ -1,777 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -#requires -Version 6.0 - -class GitCommitInfo -{ - [string]$Hash - [string[]]$ParentHashes - [string]$Subject - [string]$Body - [string]$ContributorName - [string]$ContributorEmail - [string[]]$CommitLabels - [int]$PRNumber = -1 -} - -class GitHubCommitInfo : GitCommitInfo -{ - [string]$Organization - [string]$Repository - [pscustomobject]$GitHubCommitData -} - -class GitHubIssueInfo -{ - [int]$Number - [string]$Organization - [string]$Repository - - [uri]GetHtmlUri() - { - return [uri]"https://github.com/$($this.Organization)/$($this.Repository)/issues/$($this.Number)" - } - - [uri]GetApiUri() - { - return [uri]"https://api.github.com/repos/$($this.Organization)/$($this.Repository)/issues/$($this.Number)" - } -} - -class GitHubIssue : GitHubIssueInfo -{ - [pscustomobject]$RawResponse - [string]$Body - [string[]]$Labels -} - -class GitHubPR : GitHubIssue -{ - hidden [GitHubIssueInfo[]]$ClosedIssues = $null - - [GitHubIssueInfo[]]GetClosedIssueInfos() - { - if ($null -eq $this.ClosedIssues) - { - $this.ClosedIssues = $this.Body | - GetClosedIssueUrisInBodyText | - GetGitHubIssueFromUri - } - - return $this.ClosedIssues - } - - [uri]GetHtmlUri() - { - return [uri]"https://github.com/$($this.Organization)/$($this.Repository)/pull/$($this.Number)" - } - - [uri]GetApiUri() - { - return [uri]"https://api.github.com/repos/$($this.Organization)/$($this.Repository)/pulls/$($this.Number)" - } -} - -function GetGitHubHeaders -{ - param( - [Parameter()] - [string] - $GitHubToken, - - [Parameter()] - [string] - $Accept - ) - - $headers = @{} - - if ($GitHubToken) - { - $headers.Authorization = "token $GitHubToken" - } - - if ($Accept) - { - $headers.Accept = $Accept - } - - return $headers -} - -$script:CloseKeywords = @( - 'close' - 'closes' - 'closed' - 'fix' - 'fixes' - 'fixed' - 'resolve' - 'resolves' - 'resolved' -) -$script:EndNonCharRegex = [regex]::new('[^0-9]*$', 'compiled') -filter GetClosedIssueUrisInBodyText -{ - param( - [Parameter(ValueFromPipeline)] - [string] - $Text - ) - - $words = $Text.Split() - - $expectIssue = $false - for ($i = 0; $i -lt $words.Length; $i++) - { - $currWord = $words[$i] - - if ($script:CloseKeywords -contains $currWord) - { - $expectIssue = $true - continue - } - - if (-not $expectIssue) - { - continue - } - - $expectIssue = $false - - $trimmedWord = $script:EndNonCharRegex.Replace($currWord, '') - - if ([uri]::IsWellFormedUriString($trimmedWord, 'Absolute')) - { - # Yield - [uri]$trimmedWord - } - } -} - -filter GetGitHubIssueFromUri -{ - param( - [Parameter(ValueFromPipeline)] - [uri] - $IssueUri - ) - - if ($IssueUri.Authority -ne 'github.com') - { - return - } - - if ($IssueUri.Segments.Length -ne 5) - { - return - } - - if ($IssueUri.Segments[3] -ne 'issues/') - { - return - } - - $issueNum = -1 - if (-not [int]::TryParse($IssueUri.Segments[4], [ref]$issueNum)) - { - return - } - - return [GitHubIssueInfo]@{ - Organization = $IssueUri.Segments[1].TrimEnd('/') - Repository = $IssueUri.Segments[2].TrimEnd('/') - Number = $issueNum - } -} - -filter GetHumanishRepositoryDetails -{ - param( - [string] - $RemoteUrl - ) - - if ($RemoteUrl.EndsWith('.git')) - { - $RemoteUrl = $RemoteUrl.Substring(0, $RemoteUrl.Length - 4) - } - else - { - $RemoteUrl = $RemoteUrl.Trim('/') - } - - $lastSlashIdx = $RemoteUrl.LastIndexOf('/') - $repository = $RemoteUrl.Substring($lastSlashIdx + 1) - $secondLastSlashIdx = $RemoteUrl.LastIndexOfAny(('/', ':'), $lastSlashIdx - 1) - $organization = $RemoteUrl.Substring($secondLastSlashIdx + 1, $lastSlashIdx - $secondLastSlashIdx - 1) - - return @{ - Organization = $organization - Repository = $repository - } -} - -function Exec -{ - param([scriptblock]$Invocation) - - & $Invocation - - if ($LASTEXITCODE -ne 0) - { - # Get caller location for easier debugging - $caller = Get-PSCallStack -ErrorAction SilentlyContinue - if($caller) - { - $callerLocationParts = $caller[1].Location -split ":\s*line\s*" - $callerFile = $callerLocationParts[0] - $callerLine = $callerLocationParts[1] - - $errorMessage = "Execution of {$Invocation} by ${callerFile}: line $callerLine failed with exit code $LASTEXITCODE" - throw $errorMessage - } - throw "Execution of {$Invocation} failed with exit code $LASTEXITCODE" - } -} - -function Copy-GitRepository -{ - param( - [Parameter(Mandatory)] - [string] - $OriginRemote, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [string] - $Destination = ((GetHumanishRepositoryDetails $OriginRemote).Repository), - - [Parameter()] - [string] - $CloneBranch = 'master', - - [Parameter()] - [string] - $CheckoutBranch, - - [Parameter()] - [hashtable] - $Remotes, - - [switch] - $Clobber, - - [switch] - $PullUpstream, - - [switch] - $UpdateOrigin - ) - - $Destination = $PSCmdlet.GetUnresolvedProviderPathFromPSPath($Destination) - - if (Test-Path $Destination) - { - if (-not $Clobber) - { - throw "Cannot clone repo to '$Destination'; path already exists." - } - - Remove-Item -Force -Recurse $Destination -ErrorAction Stop - } - - $containingDir = Split-Path $Destination - if (-not (Test-Path $containingDir)) - { - New-Item -Path $containingDir -ItemType Directory -ErrorAction Stop - } - - Write-Verbose "Cloning git repository '$OriginRemote' to path '$Destination'" - - Exec { git clone $OriginRemote --branch $CloneBranch --single-branch $Destination } - - if ($CloneBranch) - { - Write-Verbose "Cloned branch: $CloneBranch" - } - - Push-Location $Destination - try - { - Exec { git config core.autocrlf true } - - if ($Remotes) - { - foreach ($remote in $Remotes.get_Keys()) - { - Exec { git remote add $remote $Remotes[$remote] } - } - - if ($PullUpstream -and $Remotes['upstream']) - { - Exec { git pull upstream $CloneBranch } - - if ($UpdateOrigin) - { - Exec { git push origin "+$CloneBranch"} - } - } - } - - if ($CheckoutBranch) - { - Exec { git checkout -b $CheckoutBranch } - } - } - finally - { - Pop-Location - } -} - -function Submit-GitChanges -{ - param( - [Parameter(Mandatory)] - [string] - $Message, - - [Parameter(Mandatory)] - [string] - $Branch, - - [Parameter()] - [string] - $RepositoryLocation = (Get-Location), - - [Parameter()] - [string[]] - $File, - - [Parameter()] - [string] - $Remote = 'origin' - ) - - Push-Location $RepositoryLocation - try - { - # Try to checkout the relevant branch - try - { - Exec { git checkout $Branch } - } - catch - { - Exec { git checkout -b $Branch } - } - - if ($File) - { - Exec { git add $File } - } - else - { - Exec { git add -A } - } - - Write-Verbose "Commiting and pushing changes in '$RepositoryLocation' to '$Remote/$Branch'" - - Exec { git commit -m $Message } - Exec { git push $Remote $Branch } - } - finally - { - Pop-Location - } -} - -function Get-GitCommit -{ - [OutputType([GitHubCommitInfo])] - [CmdletBinding(DefaultParameterSetName='SinceRef')] - param( - [Parameter(Mandatory, ParameterSetName='SinceRef')] - [Alias('SinceBranch', 'SinceTag')] - [string] - $SinceRef, - - [Parameter(ParameterSetName='SinceRef')] - [Alias('UntilBranch', 'UntilTag')] - [string] - $UntilRef = 'HEAD', - - [Parameter()] - [string] - $Remote, - - [Parameter()] - [string] - $GitHubToken, - - [Parameter()] - [string] - $RepositoryPath - ) - - if ($RepositoryPath) - { - Push-Location $RepositoryPath - } - try - { - if (-not $Remote) - { - $Remote = 'upstream' - try - { - $null = Exec { git remote get-url $Remote } - } - catch - { - $Remote = 'origin' - } - } - - $originDetails = GetHumanishRepositoryDetails -RemoteUrl (Exec { git remote get-url $Remote }) - $organization = $originDetails.Organization - $repository = $originDetails.Repository - - Write-Verbose "Getting local git commit data" - - $null = Exec { git fetch --all } - - $lastCommonCommit = Exec { git merge-base $SinceRef $UntilRef } - - $format = '%H||%P||%aN||%aE||%s' - $commits = Exec { git --no-pager log "$lastCommonCommit..$UntilRef" --format=$format } - - $irmParams = if ($GitHubToken) - { - @{ Headers = GetGitHubHeaders -GitHubToken $GitHubToken -Accept 'application/vnd.github.v3+json' } - } - else - { - @{ Headers = GetGitHubHeaders -Accept 'application/vnd.github.v3+json' } - } - - return $commits | - ForEach-Object { - $hash,$parents,$name,$email,$subject = $_.Split('||') - $body = (Exec { git --no-pager show $hash -s --format=%b }) -join "`n" - $commitVal = [GitHubCommitInfo]@{ - Hash = $hash - ParentHashes = $parents - ContributorName = $name - ContributorEmail = $email - Subject = $subject - Body = $body - Organization = $organization - Repository = $repository - } - - # Query the GitHub API for more commit information - Write-Verbose "Querying GitHub api for data on commit $hash" - $commitVal.GitHubCommitData = Invoke-RestMethod -Method Get -Uri "https://api.github.com/repos/$organization/$repository/commits/$hash" @irmParams - - # Look for something like 'This is a commit message (#1224)' - $pr = [regex]::Match($subject, '\(#(\d+)\)$').Groups[1].Value - if ($pr) - { - $commitVal.PRNumber = $pr - } - - # Look for something like '[Ignore] [giraffe] Fix tests' - $commitLabels = [regex]::Matches($subject, '^(\[(.*?)\]\s*)*') - if ($commitLabels.Groups.Length -ge 3 -and $commitLabels.Groups[2].Captures.Value) - { - $commitVal.CommitLabels = $commitLabels.Groups[2].Captures.Value - } - - $commitVal - } - } - finally - { - if ($RepositoryPath) - { - Pop-Location - } - } -} - -function New-GitHubPR -{ - param( - [Parameter(Mandatory)] - [string] - $Branch, - - [Parameter(Mandatory)] - [string] - $Title, - - [Parameter(Mandatory)] - [string] - $GitHubToken, - - [Parameter(Mandatory)] - [string] - $Organization, - - [Parameter(Mandatory)] - $Repository, - - [Parameter()] - [string] - $TargetBranch = 'master', - - [Parameter()] - [string] - $Description = '', - - [Parameter()] - [string] - $FromOrg - ) - - $uri = "https://api.github.com/repos/$Organization/$Repository/pulls" - - if ($FromOrg -and $FromOrg -ne $Organization) - { - $Branch = "${FromOrg}:${Branch}" - } - - $body = @{ - title = $Title - body = $Description - head = $Branch - base = $TargetBranch - draft = $true - maintainer_can_modify = $true - } | ConvertTo-Json - - $headers = GetGitHubHeaders -GitHubToken $GitHubToken -Accept 'application/vnd.github.v3+json' - - Write-Verbose "Opening new GitHub pull request on '$Organization/$Repository' with title '$Title'" - Invoke-RestMethod -Method Post -Uri $uri -Body $body -Headers $headers -} - -function Get-GitHubPR -{ - param( - [Parameter(Mandatory)] - [string] - $Organization, - - [Parameter(Mandatory)] - [string] - $Repository, - - [Parameter(Mandatory)] - [int[]] - $PullNumber, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [string] - $GitHubToken - ) - - return $PullNumber | - ForEach-Object { - $params = @{ - Method = 'Get' - Uri = "https://api.github.com/repos/$Organization/$Repository/pulls/$_" - } - - if ($GitHubToken) - { - $params.Headers = GetGitHubHeaders -GitHubToken $GitHubToken - } - - Write-Verbose "Retrieving GitHub pull request #$_" - - $prResponse = Invoke-RestMethod @params - - [GitHubPR]@{ - RawResponse = $prResponse - Number = $prResponse.Number - Organization = $Organization - Repository = $Repository - Body = $prResponse.body - Labels = $prResponse.labels.name - } - } -} - -filter Get-GitHubIssue -{ - [CmdletBinding(DefaultParameterSetName='IssueInfo')] - param( - [Parameter(Mandatory, ValueFromPipeline, Position=0, ParameterSetName='IssueInfo')] - [GitHubIssueInfo[]] - $IssueInfo, - - [Parameter(Mandatory, ParameterSetName='Params')] - [string] - $Organization, - - [Parameter(Mandatory, ParameterSetName='Params')] - [string] - $Repository, - - [Parameter(Mandatory, ParameterSetName='Params')] - [int] - $Number, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [string] - $GitHubToken - ) - - foreach ($issue in $IssueInfo) - { - if (-not $issue) - { - $issue = [GitHubIssueInfo]@{ - Organization = $Organization - Repository = $Repository - Number = $Number - } - } - - $irmParams = @{ - Method = 'Get' - Uri = $IssueInfo.GetApiUri() - } - - if ($GitHubToken) - { - $irmParams.Headers = GetGitHubHeaders -GitHubToken $GitHubToken - } - - Write-Verbose "Retrieving GitHub issue #$($issue.Number)" - $issueResponse = Invoke-RestMethod @irmParams - - return [GitHubIssue]@{ - Organization = $issue.Organization - Repository = $issue.Repository - Number = $issue.Number - RawResponse = $issueResponse - Body = $issueResponse.body - Labels = $issueResponse.labels.name - } - } -} - -function Publish-GitHubRelease -{ - param( - [Parameter(Mandatory)] - [string] - $Organization, - - [Parameter(Mandatory)] - [string] - $Repository, - - [Parameter(Mandatory)] - [string] - $Tag, - - [Parameter(Mandatory)] - [string] - $ReleaseName, - - [Parameter(Mandatory)] - [string] - $Description, - - [Parameter(Mandatory)] - [string] - $GitHubToken, - - [Parameter()] - [Alias('Branch', 'Commit')] - [string] - $Commitish, - - [Parameter()] - [string[]] - $AssetPath, - - [switch] - $Draft, - - [switch] - $Prerelease - ) - - $restParams = @{ - tag_name = $Tag - name = $ReleaseName - body = $Description - draft = [bool]$Draft - prerelease = [bool]$Prerelease - } - - if ($Commitish) - { - $restParams.target_commitish = $Commitish - } - - $restBody = ConvertTo-Json -InputObject $restParams - $uri = "https://api.github.com/repos/$Organization/$Repository/releases" - $headers = GetGitHubHeaders -GitHubToken $GitHubToken -Accept 'application/vnd.github.v3+json' - - Write-Verbose "Publishing GitHub release '$ReleaseName' to $Organization/$Repository" - - $response = Invoke-RestMethod -Method Post -Uri $uri -Body $restBody -Headers $headers - - $releaseId = $response.id - $assetBaseUri = "https://uploads.github.com/repos/$Organization/$Repository/releases/$releaseId/assets" - foreach ($asset in $AssetPath) - { - $extension = [System.IO.Path]::GetExtension($asset) - $fileName = [uri]::EscapeDataString([System.IO.Path]::GetFileName($asset)) - $contentType = 'text/plain' - switch ($extension) - { - { $_ -in '.zip','.vsix' } - { - $contentType = 'application/zip' - break - } - - '.json' - { - $contentType = 'application/json' - break - } - } - - $assetUri = "${assetBaseUri}?name=$fileName" - $headers = GetGitHubHeaders -GitHubToken $GitHubToken - - Write-Verbose "Uploading release asset '$fileName' to release '$ReleaseName' in $Organization/$Repository" - - # This can be very slow, but it does work - $null = Invoke-RestMethod -Method Post -Uri $assetUri -InFile $asset -ContentType $contentType -Headers $headers - } - - return $response -} - -Export-ModuleMember -Function @( - 'Copy-GitRepository', - 'Submit-GitChanges', - 'Get-GitCommit', - 'New-GitHubPR', - 'Get-GitHubPR', - 'Get-GitHubIssue', - 'Publish-GitHubRelease' -) diff --git a/tools/postReleaseScripts/updateAzureDataStudio.ps1 b/tools/postReleaseScripts/updateAzureDataStudio.ps1 deleted file mode 100644 index 8337c77ac0..0000000000 --- a/tools/postReleaseScripts/updateAzureDataStudio.ps1 +++ /dev/null @@ -1,280 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -#requires -Version 6.0 - -param( - [Parameter(Mandatory)] - [string] - $GitHubToken, - - [Parameter(Mandatory)] - [version] - $ExtensionVersion, - - [Parameter()] - [string[]] - $GalleryFileName = ('extensionsGallery.json','extensionsGallery-insider.json'), - - [Parameter()] - [string] - $SourceFork = 'rjmholt', - - [Parameter()] - [string] - $TargetFork = 'Microsoft', - - [Parameter()] - [string] - $BranchName = "update-psext-$ExtensionVersion", - - [Parameter()] - [string] - $PRDescription = "Updates the version of the PowerShell extension in ADS to $ExtensionVersion.`n**Note**: This is an automated PR." -) - -Import-Module "$PSScriptRoot/../GitHubTools.psm1" -Force -Import-Module "$PSScriptRoot/../FileUpdateTools.psm1" -Force - -function NewReleaseVersionEntry -{ - param( - [Parameter()] - [version] - $Version, - - [Parameter()] - [datetime] - $UpdateDate = [datetime]::Now.Date - ) - - return [ordered]@{ - version = "$Version" - lastUpdated = $UpdateDate.ToString('M/dd/yyyy') - assetUri = '' - fallbackAssetUri = 'fallbackAssetUri' - files = @( - [ordered]@{ - assetType = 'Microsoft.VisualStudio.Services.VSIXPackage' - source = "https://sqlopsextensions.blob.core.windows.net/extensions/powershell/ms-vscode.PowerShell-$Version.vsix" - } - [ordered]@{ - assetType = 'Microsoft.VisualStudio.Services.Icons.Default' - source = 'https://raw.githubusercontent.com/PowerShell/vscode-powershell/master/media/PowerShell_Icon.png' - } - [ordered]@{ - assetType = 'Microsoft.VisualStudio.Services.Content.Details' - source = 'https://raw.githubusercontent.com/PowerShell/vscode-powershell/master/docs/azure_data_studio/README_FOR_MARKETPLACE.md' - } - [ordered]@{ - assetType = 'Microsoft.VisualStudio.Code.Manifest' - source = 'https://raw.githubusercontent.com/PowerShell/vscode-powershell/master/package.json' - } - [ordered]@{ - assetType = 'Microsoft.VisualStudio.Services.Content.License' - source = 'https://raw.githubusercontent.com/PowerShell/vscode-powershell/master/LICENSE.txt' - } - ) - properties = @( - [ordered]@{ - key = 'Microsoft.VisualStudio.Code.ExtensionDependencies' - value = '' - } - [ordered]@{ - key = 'Microsoft.VisualStudio.Code.Engine' - value = '>=0.32.1' - } - [ordered]@{ - key = 'Microsoft.VisualStudio.Services.Links.Source' - value = 'https://github.com/PowerShell/vscode-powershell/' - } - ) - } -} - -function NewPowerShellExtensionEntry -{ - param( - [Parameter()] - [version] - $ExtensionVersion - ) - - return [ordered]@{ - extensionId = '35' - extensionName = 'powershell' - displayName = 'PowerShell' - shortDescription = 'Develop PowerShell modules, commands and scripts in Azure Data Studio' - publisher = [ordered]@{ - displayName = 'Microsoft' - publisherId = 'Microsoft' - publisherName = 'Microsoft' - } - versions = @( - NewReleaseVersionEntry -Version $ExtensionVersion - ) - statistics = @() - flags = 'preview' - } - -} - -function FindPSExtensionJsonSpan -{ - param( - [Parameter()] - [string] - $GalleryExtensionFileContent - ) - - try - { - $reader = [System.IO.StringReader]::new($GalleryExtensionFileContent) - $jsonReader = [Newtonsoft.Json.JsonTextReader]::new($reader) - - $depth = 0 - $startLine = -1 - $startColumn = -1 - $startDepth = -1 - $awaitingExtensionName = $false - $foundPowerShell = $false - while ($jsonReader.Read()) - { - switch ($jsonReader.TokenType) - { - 'StartObject' - { - if (-not $foundPowerShell) - { - $startDepth = $depth - $startLine = $jsonReader.LineNumber - $startColumn = $jsonReader.LinePosition - } - $depth++ - continue - } - - 'EndObject' - { - if ($foundPowerShell -and $depth -eq $startDepth + 1) - { - return @{ - Start = @{ - Line = $startLine - Column = $startColumn - } - End = @{ - Line = $jsonReader.LineNumber - Column = $jsonReader.LinePosition - } - } - } - $depth-- - continue - } - - 'PropertyName' - { - if ($jsonReader.Value -eq 'extensionName') - { - $awaitingExtensionName = $true - } - continue - } - - 'String' - { - if (-not $awaitingExtensionName) - { - continue - } - - $awaitingExtensionName = $false - - if ($jsonReader.Value -eq 'PowerShell') - { - $foundPowerShell = $true - } - - continue - } - } - } - } - finally - { - $reader.Dispose() - $jsonReader.Dispose() - } - - throw 'Did not find PowerShell extension' -} - -function UpdateGalleryFile -{ - param( - [Parameter(Mandatory)] - [version] - $ExtensionVersion, - - [Parameter(Mandatory, ValueFromPipeline)] - [string[]] - $GalleryFilePath - ) - - process - { - foreach ($galleryFile in $GalleryFilePath) - { - # Create a new PowerShell extension entry - $powershellEntry = NewPowerShellExtensionEntry -ExtensionVersion $ExtensionVersion - $entryStr = ConvertTo-IndentedJson $powershellEntry -IndentChar "`t" -IndentWidth 1 - - # Find the position in the existing file where the PowerShell extension should go - $galleryFileContent = Get-Content -Raw $GalleryFilePath - $span = FindPSExtensionJsonSpan -GalleryExtensionFileContent $galleryFileContent - $startOffset = Get-StringOffsetFromSpan -String $galleryFileContent -EndLine $span.Start.Line -Column $span.Start.Column - $endOffset = Get-StringOffsetFromSpan -String $galleryFileContent -EndLine $span.End.Line -StartLine $span.Start.Line -Column $span.End.Column -InitialOffset $startOffset - - # Create the new file contents with the inserted segment - $newGalleryFileContent = New-StringWithSegment -String $galleryFileContent -NewSegment $entryStr -StartIndex $startOffset -EndIndex ($endOffset+1) -AutoIndent - - # Write out the new entry - Set-Content -Path $GalleryFilePath -Value $newGalleryFileContent -Encoding utf8NoBOM -NoNewline - } - } -} - -$repoLocation = Join-Path ([System.IO.Path]::GetTempPath()) 'ads-temp-checkout' - -$cloneParams = @{ - OriginRemote = "https://github.com/$SourceFork/AzureDataStudio" - Destination = $repoLocation - CloneBranch = 'release/extensions' - CheckoutBranch = $branchName - Clobber = $true - PullUpstream = $true - UpdateOrigin = $true - Remotes = @{ - upstream = 'https://github.com/Microsoft/AzureDataStudio' - } -} -Copy-GitRepository @cloneParams - -$GalleryFileName | - ForEach-Object { "$repoLocation/$_" } | - UpdateGalleryFile -ExtensionVersion $ExtensionVersion - -Submit-GitChanges -RepositoryLocation $repoLocation -File $GalleryFileName -Branch $branchName -Message "Update PS extension to v$ExtensionVersion" - -$prParams = @{ - Organization = $TargetFork - Repository = 'AzureDataStudio' - TargetBranch = 'release/extensions' - Branch = $branchName - Title = "Update PowerShell extension to v$ExtensionVersion" - Description = $PRDescription - GitHubToken = $GitHubToken - FromOrg = $SourceFork -} -New-GitHubPR @prParams