Skip to content

Commit a0496b1

Browse files
committed
Update modules.json logic to use only RequiredVersion
We want to know exactly which version of each module is being bundled with the extension, so the min/max logic was removed and replaced with just a precise version. The field `AllowPrerelease` is now based off the same parameter given per module because, again, we want to be explicit about our versions.
1 parent 96baa02 commit a0496b1

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

PowerShellEditorServices.build.ps1

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ $script:IsNix = $IsLinux -or $IsMacOS
3232
$script:IsRosetta = $IsMacOS -and (sysctl -n sysctl.proc_translated) -eq 1 # Mac M1
3333
$script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerShellEditorServices.Hosting", "BuildInfo.cs")
3434
$script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditorServices.Common.props")
35-
$script:IsPreview = [bool]($script:PsesCommonProps.Project.PropertyGroup.VersionSuffix)
3635

3736
$script:NetRuntime = @{
3837
PS7 = 'netcoreapp3.1'
@@ -341,15 +340,13 @@ task RestorePsesModules -After Build {
341340
$name = $_.Name
342341
$body = @{
343342
Name = $name
344-
MinimumVersion = $_.Value.MinimumVersion
345-
MaximumVersion = $_.Value.MaximumVersion
346-
AllowPrerelease = $script:IsPreview
343+
Version = $_.Value.Version
344+
AllowPrerelease = $_.Value.AllowPrerelease
347345
Repository = if ($_.Value.Repository) { $_.Value.Repository } else { $DefaultModuleRepository }
348346
Path = $submodulePath
349347
}
350348

351-
if (-not $name)
352-
{
349+
if (-not $name) {
353350
throw "EditorServices module listed without name in '$ModulesJsonPath'"
354351
}
355352

@@ -364,10 +361,8 @@ task RestorePsesModules -After Build {
364361
}
365362

366363
# Save each module in the modules.json file
367-
foreach ($moduleName in $moduleInfos.Keys)
368-
{
369-
if (Test-Path -Path (Join-Path -Path $submodulePath -ChildPath $moduleName))
370-
{
364+
foreach ($moduleName in $moduleInfos.Keys) {
365+
if (Test-Path -Path (Join-Path -Path $submodulePath -ChildPath $moduleName)) {
371366
Write-Host "`tModule '${moduleName}' already detected. Skipping"
372367
continue
373368
}
@@ -376,18 +371,12 @@ task RestorePsesModules -After Build {
376371

377372
$splatParameters = @{
378373
Name = $moduleName
374+
RequiredVersion = $moduleInstallDetails.Version
379375
AllowPrerelease = $moduleInstallDetails.AllowPrerelease
380376
Repository = if ($moduleInstallDetails.Repository) { $moduleInstallDetails.Repository } else { $DefaultModuleRepository }
381377
Path = $submodulePath
382378
}
383379

384-
# Only add Min and Max version if we're doing a stable release.
385-
# This is due to a PSGet issue with AllowPrerelease not installing the latest preview.
386-
if (!$moduleInstallDetails.AllowPrerelease) {
387-
$splatParameters.MinimumVersion = $moduleInstallDetails.MinimumVersion
388-
$splatParameters.MaximumVersion = $moduleInstallDetails.MaximumVersion
389-
}
390-
391380
Write-Host "`tInstalling module: ${moduleName} with arguments $(ConvertTo-Json $splatParameters)"
392381

393382
Save-Module @splatParameters

modules.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
{
2-
"PSScriptAnalyzer":{
3-
"MinimumVersion":"1.19.1",
4-
"MaximumVersion":"1.99"
2+
"PSScriptAnalyzer": {
3+
"Version": "1.19.1"
54
},
6-
"Plaster":{
7-
"MinimumVersion":"1.0",
8-
"MaximumVersion":"1.99"
5+
"Plaster": {
6+
"Version": "1.1.3"
97
},
10-
"PSReadLine":{
11-
"MinimumVersion":"2.0.2"
8+
"PSReadLine": {
9+
"Version": "2.1.0"
1210
}
1311
}

0 commit comments

Comments
 (0)