ModuleFast icon indicating copy to clipboard operation
ModuleFast copied to clipboard

ModuleFast/PWSHGallery do not have support for hiding/filtering unlisted packages

Open o-l-a-v opened this issue 1 year ago • 2 comments

Because pwsh.gallery does not handle prereleases properly, at least for some modules, ModuleFast offers prerelease versions as stable.

More info in this issue: https://github.com/JustinGrote/PWSHGallery/issues/5

Testing with PowerShell v7.4.6 -NoProfile and ModuleFast v0.5.1:

PowerShell 7.4.6
PS C:\Users\olav.birkeland> Import-module -name 'modulefast'
PS C:\Users\olav.birkeland> $Destination = [string] '{0}\Microsoft\PowerShell\Modules' -f $env:LOCALAPPDATA
PS C:\Users\olav.birkeland> $InstalledModules = [string[]](
>>     [System.IO.Directory]::GetDirectories($Destination).ForEach{$_.Split([System.IO.Path]::DirectorySeparatorChar)[-1]}
>> )
PS C:\Users\olav.birkeland> ModuleFast\Install-ModuleFast -Destination $Destination -Name $InstalledModules `
>>     -DestinationOnly -NoPSModulePathUpdate -NoProfileUpdate -Update -WhatIf
Install-ModuleFast [Plan                                                                                             ]
What if: Performing the operation "Install 2 Modules" on target "C:\Users\olav.birkeland\AppData\Local\Microsoft\PowerShell\Modules".

Name                           ModuleVersion Location
----                           ------------- --------
EnterprisePolicyAsCode         10.7.6        https://pwsh.gallery/flatcontainer/enterprisepolicyascode/10.7.6/enterprisepolicyascode.10.7.6.nupkg
Microsoft.PowerShell.ThreadJob 3.0.0         https://pwsh.gallery/flatcontainer/microsoft.powershell.threadjob/3.0.0/microsoft.powershell.threadjob.3.0.0.nupkg

PS C:\Users\olav.birkeland>
  • EnterprisePolicyAsCode v10.7.6 is a prerelease, 10.7.6-beta
  • Microsoft.PowerShell.ThreadJob v3.0.0 does not exist anywhere else (PowerShell Gallery, repo)

o-l-a-v avatar Jan 24 '25 09:01 o-l-a-v

So the problem is that, at least in ThreadJob's case, the module actually does exist in PowerShell Gallery, it's just unlisted. https://psg-prod-eastus.azureedge.net/packages/threadjob.3.0.0.nupkg

I don't think sleet is respecting the listed property, tho I'm having trouble getting it to appear for powershellgallery itself with the same queries. https://pwsh.gallery/registration/microsoft.powershell.threadjob/3.0.0.json

The same is true of EnterprisePolicyAsCode, a 10.7.6 actually does exist, it's just unlisted, but it has a higher preference than -beta per Semver Rules.

This isn't modulefast specific as far as I can tell, tho I'll need to check for honoring unlisted entries if they show up. Instead I need to make sure listed:false is carrying thru in https://github.com/justingrote/gallerysync

JustinGrote avatar Jan 26 '25 02:01 JustinGrote

I found that the listed property isn't part of the nuget package itself (I guess obviously) so I'm going to need a separate process that updates the sleet registry and flips the listed bool for packages not listed in PowerShell Gallery.

As a workaround, please pin your module versions. imf microsoft.powershell.threadjob=2.1.0,enterprisepolicyascode=10.7.6-beta -verbose

JustinGrote avatar Jan 26 '25 02:01 JustinGrote