Skip to content

feat: add PSResourceGet dependency type (PSGet v3)#179

Open
HeyItsGilbert wants to merge 6 commits into
mainfrom
fix/psresourceget
Open

feat: add PSResourceGet dependency type (PSGet v3)#179
HeyItsGilbert wants to merge 6 commits into
mainfrom
fix/psresourceget

Conversation

@HeyItsGilbert
Copy link
Copy Markdown
Member

Summary

  • Adds a new PSResourceGet dependency type backed by Microsoft.PowerShell.PSResourceGet (PSGet v3), the successor to the deprecated PowerShellGet v2 Install-Module workflow
  • Registers the type in PSDependMap.psd1 and marks PSGalleryModule as legacy in its description
  • Adds a full Pester 5 contract test suite (Tests/PSResourceGet.Type.Tests.ps1, 13 tests across 10 contexts)

What's in the handler (PSResourceGet.ps1)

  • Availability guard — errors early with a clear message if Microsoft.PowerShell.PSResourceGet is not installed
  • Version handling — omits -Version for latest (installs newest); passes -Version for explicit versions using NuGet range syntax
  • Scope / path targetAllUsers/CurrentUserInstall-PSResource -Scope; any other value → Save-PSResource -Path
  • Repository validation — calls Get-PSResourceRepository and writes a non-terminating error if the repo isn't registered
  • TrustRepository = $true — always set so unattended / CI installs never block on a trust prompt
  • Parameter filtering — strips params not accepted by the target cmdlet at runtime (Install-PSResource vs Save-PSResource have different signatures)
  • SemVer-aware version comparison — uses [System.Management.Automation.SemanticVersion] first, falls back to [System.Version]
  • Credential pass-through — forwards [PSCredential] for private repositories
  • Switch parametersNoClobber, AcceptLicense, Prerelease are [switch], not [bool], matching the actual cmdlet signatures

Test coverage

Context What it verifies
Default Version handling -Version omitted for latest; passed for explicit
Name / DependencyName fallback Name resolution priority
Test action Returns $false / $true correctly
Test+Install short-circuit Skips install when already satisfied; still imports
Latest version comparison Installs when local version is behind gallery
Target as path Routes to Save-PSResource -Path
Credential pass-through Credential forwarded to install/save cmdlet
Repository validation Errors and skips on unknown repo
Availability guard Returns early when Install-PSResource is missing
TrustRepository Always included in splatted params

Test plan

  • .\build.ps1 StageFiles then Invoke-Pester Tests\PSResourceGet.Type.Tests.ps1 — all 13 pass
  • Full suite Invoke-Pester Tests\ — no regressions (402 tests, 0 failures)
  • On a machine with Microsoft.PowerShell.PSResourceGet installed: smoke-test Invoke-PSDepend with a PSResourceGet dependency entry

🤖 Generated with Claude Code

ASIF Adeel and others added 5 commits May 18, 2026 22:16
- 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>
Copilot AI review requested due to automatic review settings May 19, 2026 06:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ps1 dependency handler (Install vs Save routing, repo validation, parameter filtering, trust prompt suppression).
  • Registers PSResourceGet in PSDependMap.psd1 and marks PSGalleryModule as legacy in its description.
  • Adds Tests/PSResourceGet.Type.Tests.ps1 contract 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 explicit else { $false } fallback so $existingIsUpToDate can’t end up $null on parse failures (see PSGalleryModule.ps1’s isGalleryVersionLessEquals logic).
    elseif ([System.Version]::TryParse($ExistingVersion, [ref]$parsedVersion))
    {
        $GalleryVersion -le $parsedVersion
    }


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PSDepend/PSDependScripts/PSResourceGet.ps1 Outdated
Comment thread PSDepend/PSDependScripts/PSResourceGet.ps1 Outdated
Comment thread PSDepend/PSDependScripts/PSResourceGet.ps1
Comment thread Tests/PSResourceGet.Type.Tests.ps1
Comment thread Tests/PSResourceGet.Type.Tests.ps1
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

Test Results

    4 files  ± 0     76 suites  +4   2m 12s ⏱️ -4s
1 320 tests +46  1 232 ✅ +46  88 💤 ±0  0 ❌ ±0 
1 616 runs  +60  1 526 ✅ +60  90 💤 ±0  0 ❌ ±0 

Results for commit ce58352. ± Comparison against base commit b9891c8.

♻️ This comment has been updated with latest results.

- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants