feat: add PSResourceGet dependency type (PSGet v3)#179
Open
HeyItsGilbert wants to merge 6 commits into
Open
Conversation
- Rename map key PsResourceGet -> PSResourceGet to match module name - Update PSGalleryModule description to note legacy status - Replace Get-PackageProvider/NuGet bootstrap (PSResourceGet has own NuGet client) with an explicit Install-PSResource availability guard - Fix Install-Module parameter filter: was validating $params against Install-Module (PSGet v2); now routes to Install-PSResource or Save-PSResource depending on $command, so NoClobber and other PSResourceGet-only params survive - Fix RequiredVersion -> Version (Install-PSResource uses -Version with NuGet range syntax, not -RequiredVersion) - Change NoClobber, AcceptLicense, Prerelease from [bool] to [switch] to match Install-PSResource signature; only splat when explicitly provided - Remove Verbose = $VerbosePreference from $params splat (common param, not a named one) - Add TrustRepository = $true to params so unattended CI installs do not hang on a trust prompt - Pass -Scope $Scope explicitly to Install-PSResource (was missing) - Fix $command casing: set and compared consistently as lowercase - Fix $params/$Params variable casing drift throughout - Fix [cmdletbinding()] -> [CmdletBinding()] - Rename $isGalleryVersionLessEquals -> $existingIsUpToDate for clarity - Remove Write-verbose "$($Repository)" and Write-verbose "$params" debug remnants; replace with null/safe messages - Fix $True/$False/$Null -> $true/$false/$null - Fix double space in Join-Path assignment - Add newline at end of file - Fix .PARAMETER NoClobber description (was inverted: said Allow, means Prevents) - Add .PARAMETER Dependency block - Fix Example 3: remove SkipPublisherCheck (PSGet v2 only); replace with valid private-repo example - Add DependencyType = 'PSResourceGet' to all examples - Fix Credential description to name [PSCredential] type - Use ASCII hyphen in map descriptions (em dash caused Pester module-scope failures due to encoding) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ency 13 tests across 10 contexts covering: version handling (omit vs explicit), Name/DependencyName fallback, Test action ($false/$true), Test+Install short-circuit, latest version comparison, Save-PSResource path target, credential pass-through, repository validation, availability guard, and TrustRepository always-on. Stubs declare realistic parameter signatures so PSResourceGet.ps1's param- stripping loop retains all params, keeping ParameterFilter assertions valid on machines where Microsoft.PowerShell.PSResourceGet is not installed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new PSResourceGet dependency type to PSDepend to support PSGet v3 workflows via Microsoft.PowerShell.PSResourceGet, including registering the type in PSDependMap.psd1 and adding a Pester v5 contract test suite.
Changes:
- Introduces
PSDependScripts/PSResourceGet.ps1dependency handler (Install vs Save routing, repo validation, parameter filtering, trust prompt suppression). - Registers
PSResourceGetinPSDependMap.psd1and marksPSGalleryModuleas legacy in its description. - Adds
Tests/PSResourceGet.Type.Tests.ps1contract tests covering the core behaviors.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
PSDepend/PSDependScripts/PSResourceGet.ps1 |
New dependency script implementing PSResourceGet-backed install/save/test/import behavior. |
PSDepend/PSDependMap.psd1 |
Registers the new dependency type and updates PSGalleryModule description. |
Tests/PSResourceGet.Type.Tests.ps1 |
Adds Pester contract tests for the new dependency type. |
Comments suppressed due to low confidence (1)
PSDepend/PSDependScripts/PSResourceGet.ps1:306
- In the System.Version fallback branch you only TryParse the existing version, not the gallery version, and then compare
$GalleryVersion(unparsed) to$parsedVersion. This should parse both sides and compare the parsed values, and should also include an explicitelse { $false }fallback so$existingIsUpToDatecan’t end up$nullon parse failures (see PSGalleryModule.ps1’sisGalleryVersionLessEqualslogic).
elseif ([System.Version]::TryParse($ExistingVersion, [ref]$parsedVersion))
{
$GalleryVersion -le $parsedVersion
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix multi-version short-circuit: compare requested version against all
installed versions, not just the maximum, so a lower installed version
is correctly detected as satisfied
- Fix SemVer comparison: compare parsed types on both sides instead of
mixing parsed SemanticVersion with unparsed string
- Fix System.Version fallback: parse gallery version before comparing,
add else { $false } so existingIsUpToDate is never $null on failure
- Fix NuGet range import: resolve range strings to the concrete installed
version before passing to Import-PSDependModule
- Add tests: NuGet range version syntax and multi-version installed scenario
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PSResourceGetdependency type backed byMicrosoft.PowerShell.PSResourceGet(PSGet v3), the successor to the deprecated PowerShellGet v2Install-ModuleworkflowPSDependMap.psd1and marksPSGalleryModuleas legacy in its descriptionTests/PSResourceGet.Type.Tests.ps1, 13 tests across 10 contexts)What's in the handler (
PSResourceGet.ps1)Microsoft.PowerShell.PSResourceGetis not installed-Versionforlatest(installs newest); passes-Versionfor explicit versions using NuGet range syntaxAllUsers/CurrentUser→Install-PSResource -Scope; any other value →Save-PSResource -PathGet-PSResourceRepositoryand writes a non-terminating error if the repo isn't registeredTrustRepository = $true— always set so unattended / CI installs never block on a trust promptInstall-PSResourcevsSave-PSResourcehave different signatures)[System.Management.Automation.SemanticVersion]first, falls back to[System.Version][PSCredential]for private repositoriesNoClobber,AcceptLicense,Prereleaseare[switch], not[bool], matching the actual cmdlet signaturesTest coverage
-Versionomitted for latest; passed for explicit$false/$truecorrectlySave-PSResource -PathInstall-PSResourceis missingTest plan
.\build.ps1 StageFilesthenInvoke-Pester Tests\PSResourceGet.Type.Tests.ps1— all 13 passInvoke-Pester Tests\— no regressions (402 tests, 0 failures)Microsoft.PowerShell.PSResourceGetinstalled: smoke-testInvoke-PSDependwith aPSResourceGetdependency entry🤖 Generated with Claude Code