Skip to content

Commit

Permalink
Merge pull request #24 from webmd-health-services/bugfix/find-module-…
Browse files Browse the repository at this point in the history
…only-prerelease-versions

Prism fails if a module only has prerelease versions
  • Loading branch information
splatteredbits authored Jan 30, 2024
2 parents 3b9fc5d + bb79aaf commit 26e9fb2
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 37 deletions.
47 changes: 36 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
<!--markdownlint-disable MD012 no-multiple-blanks-->
<!--markdownlint-disable MD024 no-duplicate-heading-->

# 0.6.0
# Prism Changelog

## 0.6.1

> Released 29 Jan 2024
Fixed: Prism fails to find modules that only have prerelease versions.


## 0.6.0

> Released 8 Aug 2022
* Adding an init.ps1 script that can be used to install Prism's dependencies (PackageManagement and PowerShellGet
modules) and install Prism.


# 0.5.2
## 0.5.2

> Released 4 Aug 2022
* Adding support for PackageManagement 1.4.8.1.


# 0.5.1
## 0.5.1

> Released 13 Jul 2022
## Fixed

* `prism install` fails if `Get-PSRepository` hasn't been run before it.
* Prism commands are very slow in Windows PowerShell on Windows 10, Server 2012R2, and Server 2019 due to some overzealous logging.


# 0.5.0
## 0.5.0

> Released 6 Jul 2022
## Changed

Expand All @@ -30,7 +49,9 @@ modules) and install Prism.
* Fixed: Prism commands fail if PowerShellGet and PackageManagement modules aren't already imported before being run.


# 0.4.0
## 0.4.0

> Released 28 Jun 2022
## Added

Expand All @@ -50,7 +71,9 @@ modules) and install Prism.
Windows 8.1/Server 2012 R2, but ends with no forward slash on later operating systems.)


# 0.3.0
## 0.3.0

> Released 17 Mar 2022
## Upgrade Instructions

Expand All @@ -75,7 +98,9 @@ by default.
the prism.json file.


# 0.2.0
## 0.2.0

> Released 16 Mar 2022
## Upgrade Instructions

Expand All @@ -100,12 +125,12 @@ We've renamed PxGet to Prism.
command. If a lock file doesn't exist, the `install` command will call the `update` command first.


# 0.1.3
## 0.1.3

* Improvements to documentation.


# 0.1.2
## 0.1.2

* Fixed: no progress shown to the user about what `prism install` is doing.
* Fixed: The `prism install` command fails to import its private PackageManagement and PowerShellGet modules in a
Expand All @@ -114,8 +139,8 @@ fresh repository.
* Fixed: Progress output from the `Save-Module` command shows when running the `prism install` command.


# 0.1.1
## 0.1.1

## Fixed

* Module fails to publish to PowerShell Gallery.
* Module fails to publish to PowerShell Gallery.
9 changes: 1 addition & 8 deletions Prism/Functions/Update-ModuleLock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Update-ModuleLock
$moduleNames = $Configuration.PSModules | Select-Object -ExpandProperty 'Name'
if( -not $moduleNames )
{
Write-Warning "There are no modules listed in ""$($Path | Resolve-Path -Relative)""."
Write-Warning "There are no modules listed in ""$($Configuration.Path | Resolve-Path -Relative)""."
return
}

Expand All @@ -38,13 +38,6 @@ function Update-ModuleLock
try
{
$modules = Find-Module -Name $uniqueModuleNames -ErrorAction Ignore @pkgMgmtPrefs
if( -not $modules )
{
$msg = "$($Path | Resolve-Path -Relative): Modules ""$($uniqueModuleNames -join '", "')"" not " +
'found.'
Write-Error $msg
return
}

# Find-Module is expensive. Limit calls as much as possible.
$findModuleCache = @{}
Expand Down
2 changes: 1 addition & 1 deletion Prism/Prism.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
RootModule = 'Prism.psm1'

# Version number of this module.
ModuleVersion = '0.6.0'
ModuleVersion = '0.6.1'

# ID used to uniquely identify this module
GUID = '5b244346-40c9-4a50-a098-8758c19f7f25'
Expand Down
19 changes: 10 additions & 9 deletions Tests/install.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BeforeAll {
Get-PSRepository -Name $script:latestNoOpModule.Repository | Select-Object -ExpandProperty 'SourceLocation'
$script:latestNoOpLockFile = @"
{
"PSModules": {
"PSModules": {
"name": "NoOp",
"version": "$($script:latestNoOpModule.Version)",
"repositorySourceLocation": "$($script:defaultLocation)"
Expand All @@ -31,7 +31,7 @@ BeforeAll {
param(
[Parameter(Mandatory)]
[String] $Contents,

[String] $In = $script:testRoot
)

Expand All @@ -50,7 +50,7 @@ BeforeAll {
param(
[Parameter(Mandatory)]
[String] $Contents,

[String] $In = $script:testRoot
)

Expand All @@ -71,7 +71,7 @@ BeforeAll {
[hashtable] $Module,

[String] $In = $script:testRoot,

[String] $UsingDirName = 'PSModules'
)

Expand Down Expand Up @@ -114,12 +114,12 @@ BeforeAll {
Select-Object -Unique |
Should -HaveCount $expectedCount
}

function ThenSucceeded
{
$Global:Error | Should -BeNullOrEmpty
}

function WhenInstalling
{
[CmdletBinding()]
Expand All @@ -144,7 +144,7 @@ AfterAll {
}

Describe 'prism install' {
BeforeEach {
BeforeEach {
$script:testRoot = $null
$script:moduleList = @()
$script:failed = $false
Expand Down Expand Up @@ -271,7 +271,7 @@ Describe 'prism install' {
$Global:DebugPreference = [Management.Automation.ActionPreference]::Continue
$output = WhenInstalling 5>&1
$output | Write-Verbose

# Import-Module doesn't output any debug messages.
# Save-Module does.
# From PowerShellGet. Can't find PackageManagement-only debug messages.
Expand Down Expand Up @@ -358,7 +358,8 @@ Describe 'prism install' {
ThenInstalled @{ 'NoOp' = '1.0.0' }
}

It 'should find repositories when Get-PSRepository has never been called before' {
$skip = (Test-Path -Path 'variable:IsMacOS') -and $IsMacOS
It 'should find repositories when Get-PSRepository has never been called before' -Skip:$skip {
GivenPrismFile @'
{
"PSModules": [
Expand Down
35 changes: 31 additions & 4 deletions Tests/update.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ BeforeAll {
}

Describe 'prism update' {
BeforeEach {
BeforeEach {
$script:testRoot = $null
$script:testRoot = Join-Path -Path $TestDrive -ChildPath ($script:testNum++)
New-Item -Path $script:testRoot -ItemType 'Directory'
Expand Down Expand Up @@ -145,7 +145,7 @@ Describe 'prism update' {
GivenPrismFile @'
{
"PSModules": [
{ "Name": "Carbon", "Version": "2.*-*" }
{ "Name": "Carbon", "Version": "2.11.*-*" }
]
}
'@
Expand Down Expand Up @@ -205,7 +205,7 @@ Describe 'prism update' {
repositorySourceLocation = $script:defaultLocation;
}
)
}
}
ThenLockFileIs $expectedLock -In 'dir1'
ThenLockFileIs $expectedLock -In 'dir1\dir2'
}
Expand All @@ -229,4 +229,31 @@ Describe 'prism update' {
)
})
}
}

# This test is only valid if the module being managed only has prerelease versions. When Carbon.Permissions no
# longer has only prerelease versions, the test will become invalid. But its valid now.
It 'handles module that only has prerelease version' {
GivenPrismFile @'
{
"PSModules": [
{ "Name": "Carbon.Permissions", "Version": "1.*-*" }
]
}
'@
WhenLocking
$expectedModule =
Find-Module -Name 'Carbon.Permissions' -AllVersions -AllowPrerelease | `
Where-Object 'Version' -like '1.*-*' | `
Select-Object -First 1
ThenLockFileIs ([pscustomobject]@{
PSModules = @(
[pscustomobject]@{
name = 'Carbon.Permissions';
version = $expectedModule.Version;
repositorySourceLocation = $script:defaultLocation;
}
)
})
}

}
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ skip_branch_with_pr: true
build:
verbosity: minimal

test: off
test: false

environment:
WHISKEY_DISABLE_ERROR_FORMAT: True
Expand Down
8 changes: 5 additions & 3 deletions whiskey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Build:
- Version:
Path: Prism\Prism.psd1
Prerelease:
- "*/*": alpha1+$(WHISKEY_BUILD_NUMBER)
- prerelease: rc1+$(WHISKEY_BUILD_NUMBER)
- main: ""
- "*": rc$(WHISKEY_BUILD_NUMBER)

# Update the AppVeyor build/version number.
- Exec:
Expand Down Expand Up @@ -80,4 +80,6 @@ Build:
TestResult:
Enabled: true
OutputPath: .output\pester.xml
TestSuiteName: Prism
TestSuiteName: Prism
Output:
Verbosity: Detailed

0 comments on commit 26e9fb2

Please sign in to comment.