Skip to content

Add two-tier version checking to Install-RequiredModule - #13

Merged
thisjustin816 merged 1 commit into
mainfrom
feature/install-required-module-listavailable
Jul 30, 2026
Merged

thisjustin816 merged 1 commit into
mainfrom
feature/install-required-module-listavailable

Conversation

@thisjustin816

@thisjustin816 thisjustin816 commented Jul 30, 2026 •

Copy link
Copy Markdown
Owner

@

Summary

Install-RequiredModule now uses a two-tier version-checking strategy:

  • First tier: Get-InstalledPSResource (~5ms) - fast, carries native range handling, prerelease support, version normalization per NuGet semantics
  • Second tier: Get-Module -ListAvailable + Test-VersionRange (~25ms) - catches file-copied modules (AWS.Tools zip bundles, pre-baked CI images, vendored PSModulePath folders) that the package manager never tracked

This avoids reinstalling modules that arrived by copy while preserving the speed advantage of the package-manager check.
@

@
Add two-tier version checking and AcceptLicense parameter

Install-RequiredModule now checks Get-InstalledPSResource first
(~5ms, native range handling, prerelease support) then falls back to
Get-Module -ListAvailable + Test-VersionRange for file-copied modules
(AWS zip bundles, pre-baked CI images). This avoids reinstalling
modules that arrived by copy while preserving the speed advantage.

- New private function Test-VersionRange: implements NuGet range
  matching for modules Get-Module returns, with defensive parsing
  (returns false rather than throwing on unreadable bounds).
- Install-RequiredModule: two-tier check, new -AcceptLicense parameter
  for modules requiring license acceptance.
- 8 new tests covering two-tier ordering, prerelease handling, and
  fallback behavior. Total: 19 tests passing.
- Revised comments to follow PowerShell standards (explain constraints,
  not justify choices).
@
@github-actions

Copy link
Copy Markdown

Test Results

206 tests  +39   206 ✅ +39   9m 25s ⏱️ -13s
 65 suites +10     0 💤 ± 0 
  1 files   ± 0     0 ❌ ± 0 

Results for commit 0948707. ± Comparison against base commit 225c7fc.

This pull request removes 7 and adds 46 tests. Note that renamed tests count towards both.
Unit Tests.-Intent parameter set.should preserve compound compatibility intents("ActionDetail","  message","Gray")
Unit Tests.-Intent parameter set.should preserve compound compatibility intents("Default","message",null)
Unit Tests.-Intent parameter set.should preserve compound compatibility intents("Detail","  message","Gray")
Unit Tests.-Intent parameter set.should preserve compound compatibility intents("MutedDetail","    message","DarkGray")
Unit Tests.-Intent parameter set.should preserve compound compatibility intents("SubHeader","message","DarkCyan")
Unit Tests.-Intent parameter set.should preserve compound compatibility intents("Usage","  message",null)
Unit Tests.-Intent parameter set.should preserve compound compatibility intents("UsageStep","    message",null)
Install-RequiredModule.should count a module a package manager never installed
Install-RequiredModule.should fall back to the PSModulePath scan when the package manager knows nothing
Install-RequiredModule.should forward AcceptLicense when asked
Install-RequiredModule.should install when neither source finds a satisfying version
Install-RequiredModule.should not consult either source when Force is used
Install-RequiredModule.should omit AcceptLicense by default
Install-RequiredModule.should prefer the package manager and skip the PSModulePath scan on a hit
Install-RequiredModule.should treat a version outside the range as not installed
Test-VersionRange.bare version is exact, not a floor.should match the same version
Test-VersionRange.bare version is exact, not a floor.should reject a newer version
…

@github-actions

Copy link
Copy Markdown

Summary

Summary
Generated on: 7/30/2026 - 12:30:28 AM
Coverage date: 7/30/2026 - 12:19:45 AM
Parser: JaCoCo
Assemblies: 2
Classes: 33
Files: 33
Line coverage: 93.4% (581 of 622)
Covered lines: 581
Uncovered lines: 41
Coverable lines: 622
Total lines: 2279
Covered branches: 0
Total branches: 0
Method coverage: Feature is only available for sponsors
Tag: 44_30502304639

Coverage

src/Private - 93.8%
Name Line Branch
src/Private 93.8% ****
src/Private/Get-UsernameSID 100%
src/Private/Invoke-Timeout 75%
src/Private/Test-VersionRange 100%
src/Public - 93.3%
Name Line Branch
src/Public 93.3% ****
src/Public/Add-AzPipelinesPathEntry 100%
src/Public/ConvertFrom-EncryptedSecureString 100%
src/Public/ConvertTo-Psd1 100%
src/Public/Enable-Tls12 100%
src/Public/Export-Screenshot 100%
src/Public/Get-EnvironmentVariable 100%
src/Public/Get-PatPSCredential 100%
src/Public/Get-PSVersion 100%
src/Public/Get-TempDirectory 100%
src/Public/Initialize-GitConfig 100%
src/Public/Install-NugetCLI 100%
src/Public/Install-RequiredModule 100%
src/Public/Reset-ConsoleColor 100%
src/Public/Set-EnvironmentVariable 100%
src/Public/Set-JsonFile 100%
src/Public/Show-ConsoleColor 100%
src/Public/Start-CliProcess 87.8%
src/Public/Start-StopWatch 100%
src/Public/Start-Timeout 100%
src/Public/Stop-DevProcess 92.5%
src/Public/Stop-ProcessTree 100%
src/Public/Stop-Stopwatch 100%
src/Public/Test-CommandAvailable 100%
src/Public/Test-IsAdmin 100%
src/Public/Test-IsFileLocked 0%
src/Public/Test-IsNonInteractiveShell 0%
src/Public/Test-PSEnvironment 100%
src/Public/Uninstall-ProgramByName 92.1%
src/Public/Write-ConsoleMessage 94.8%
src/Public/Write-ProgressToHost 100%

@thisjustin816
thisjustin816 merged commit ca55f7c into main Jul 30, 2026
4 checks passed
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.

1 participant