@@ -225,6 +225,81 @@ function Update-Changelog {
225225 Pop-Location
226226}
227227
228+ <#
229+ . SYNOPSIS
230+ Updates version in repository.
231+ . DESCRIPTION
232+ Note that our Git tags and changelog prefix all versions with `v`.
233+
234+ PowerShellEditorServices: version is `x.y.z-preview.d`
235+
236+ - PowerShellEditorServices.psd1:
237+ - `ModuleVersion` variable with `'x.y.z'` string, no pre-release info
238+ - PowerShellEditorServices.Common.props:
239+ - `VersionPrefix` field with `x.y.z`
240+ - `VersionSuffix` field with pre-release portion excluding hyphen
241+
242+ vscode-powershell: version is `yyyy.mm.x-preview`
243+
244+ - package.json:
245+ - `version` field with `"x.y.z"` and no prefix or suffix
246+ - `preview` field set to `true` or `false` if version is a preview
247+ - `name` field has `-preview` appended similarly
248+ - `displayName` field has ` Preview` appended similarly
249+ - `description` field has `(Preview) ` prepended similarly
250+ #>
251+ function Update-Version {
252+ param (
253+ [Parameter (Mandatory )]
254+ [ValidateSet ([RepoNames ])]
255+ [string ]$RepositoryName
256+ )
257+ # NOTE: This a side effect neccesary for Git operations to work.
258+ Push-Location - Path " $PSScriptRoot /../../$RepositoryName "
259+
260+ $Version = Get-Version - RepositoryName $RepositoryName
261+ $v = " $ ( $Version.Major ) .$ ( $Version.Minor ) .$ ( $Version.Patch ) "
262+ # TODO: Maybe cleanup the replacement logic.
263+ switch ($RepositoryName ) {
264+ " vscode-powershell" {
265+ $d = " Develop PowerShell scripts in Visual Studio Code!"
266+ if ($Version.PreReleaseLabel ) {
267+ $name = " powershell-preview"
268+ $displayName = " PowerShell Preview"
269+ $preview = " true"
270+ $description = " (Preview) $d "
271+ } else {
272+ $name = " powershell"
273+ $displayName = " PowerShell"
274+ $preview = " false"
275+ $description = $d
276+ }
277+ $f = Get-Content - Path " package.json"
278+ # NOTE: The prefix regex match two spaces exactly to avoid matching
279+ # nested objects in the file.
280+ $f = $f -replace ' ^(?<prefix> "name":\s+")(.+)(?<suffix>",)$' , " `$ {prefix}${name} `$ {suffix}"
281+ $f = $f -replace ' ^(?<prefix> "displayName":\s+")(.+)(?<suffix>",)$' , " `$ {prefix}${displayName} `$ {suffix}"
282+ $f = $f -replace ' ^(?<prefix> "version":\s+")(.+)(?<suffix>",)$' , " `$ {prefix}${v} `$ {suffix}"
283+ $f = $f -replace ' ^(?<prefix> "preview":\s+)(.+)(?<suffix>,)$' , " `$ {prefix}${preview} `$ {suffix}"
284+ $f = $f -replace ' ^(?<prefix> "description":\s+")(.+)(?<suffix>",)$' , " `$ {prefix}${description} `$ {suffix}"
285+ $f | Set-Content - Path " package.json"
286+ }
287+ " PowerShellEditorServices" {
288+ $f = Get-Content - Path " PowerShellEditorServices.Common.props"
289+ $f = $f -replace ' ^(?<prefix>\s+<VersionPrefix>)(.+)(?<suffix></VersionPrefix>)$' , " `$ {prefix}${v} `$ {suffix}"
290+ $f = $f -replace ' ^(?<prefix>\s+<VersionSuffix>)(.*)(?<suffix></VersionSuffix>)$' , " `$ {prefix}$ ( $Version.PreReleaseLabel ) `$ {suffix}"
291+ $f | Set-Content - Path " PowerShellEditorServices.Common.props"
292+
293+ $f = Get-Content - Path " module/PowerShellEditorServices/PowerShellEditorServices.psd1"
294+ $f = $f -replace " ^(?<prefix>ModuleVersion = ')(.+)(?<suffix>')`$ " , " `$ {prefix}${v} `$ {suffix}"
295+ $f | Set-Content - Path " module/PowerShellEditorServices/PowerShellEditorServices.psd1"
296+ }
297+ }
298+
299+ # TODO: Git commit changes.
300+ Pop-Location
301+ }
302+
228303<#
229304. SYNOPSIS
230305 Creates a new draft GitHub release from the updated changelog.
@@ -254,4 +329,4 @@ function New-DraftRelease {
254329 New-GitHubRelease @ReleaseParams
255330}
256331
257- Export-ModuleMember - Function Update-Changelog , New-DraftRelease
332+ # ANDY: Export-ModuleMember -Function Update-Changelog, New-DraftRelease
0 commit comments