From 890bbd0046c0d3002d9c3b35033a142fb93db419 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Mon, 14 Jul 2025 19:42:37 -0700 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=E2=9C=A8=20Rename=20`Get-PlasterMa?= =?UTF-8?q?nifestPathForCulture`=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The function checks for culture-specific, parent culture, and invariant culture manifests. - Added parameter validation and detailed documentation for usage. - Updated references in `Invoke-Plaster` to use the new function name. - Created tests to ensure functionality and correctness of the new implementation. --- .../Get-PlasterManifestPathForCulture.ps1 | 69 +++++++++++++++++++ .../GetPlasterManifestPathForCulture.ps1 | 38 ---------- Plaster/Public/Invoke-Plaster.ps1 | 4 +- ...et-PlasterManifestPathForCulture.Tests.ps1 | 50 ++++++++++++++ 4 files changed, 121 insertions(+), 40 deletions(-) create mode 100644 Plaster/Private/Get-PlasterManifestPathForCulture.ps1 delete mode 100644 Plaster/Private/GetPlasterManifestPathForCulture.ps1 create mode 100644 tests/Get-PlasterManifestPathForCulture.Tests.ps1 diff --git a/Plaster/Private/Get-PlasterManifestPathForCulture.ps1 b/Plaster/Private/Get-PlasterManifestPathForCulture.ps1 new file mode 100644 index 0000000..1dd579f --- /dev/null +++ b/Plaster/Private/Get-PlasterManifestPathForCulture.ps1 @@ -0,0 +1,69 @@ +function Get-PlasterManifestPathForCulture { + <# + .SYNOPSIS + Returns the path to the Plaster manifest file for a specific culture. + + .DESCRIPTION + This function checks for the existence of a Plaster manifest file that + matches the specified culture. It first looks for a culture-specific + manifest, then checks for a parent culture manifest, and finally falls back + to an invariant culture manifest if no specific match is found. The function + returns the path to the manifest file if found, or $null if no matching + manifest is found. + + .PARAMETER TemplatePath + The path to the template directory. + This should be a fully qualified path to the directory containing the + Plaster manifest files. + + .PARAMETER Culture + The culture information for which to retrieve the Plaster manifest file. + + .EXAMPLE + GetPlasterManifestPathForCulture -TemplatePath "C:\Templates" -Culture (Get-Culture) + + This example retrieves the path to the Plaster manifest file for the current culture. + .NOTES + This is a private function used by Plaster to locate the appropriate + manifest file based on the specified culture. + #> + [CmdletBinding()] + [OutputType([String])] + param ( + [string] + $TemplatePath, + [ValidateNotNull()] + [CultureInfo] + $Culture + ) + if (![System.IO.Path]::IsPathRooted($TemplatePath)) { + $TemplatePath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($TemplatePath) + } + + # Check for culture-locale first. + $plasterManifestBasename = "plasterManifest" + $plasterManifestFilename = "${plasterManifestBasename}_$($culture.Name).xml" + $plasterManifestPath = Join-Path $TemplatePath $plasterManifestFilename + if (Test-Path $plasterManifestPath) { + return $plasterManifestPath + } + + # Check for culture next. + if ($culture.Parent.Name) { + $plasterManifestFilename = "${plasterManifestBasename}_$($culture.Parent.Name).xml" + $plasterManifestPath = Join-Path $TemplatePath $plasterManifestFilename + if (Test-Path $plasterManifestPath) { + return $plasterManifestPath + } + } + + # Fallback to invariant culture manifest. + $plasterManifestPath = Join-Path $TemplatePath "${plasterManifestBasename}.xml" + if (Test-Path $plasterManifestPath) { + return $plasterManifestPath + } + + # If no manifest is found, return $null. + # TODO: Should we throw an error instead? + return $null +} diff --git a/Plaster/Private/GetPlasterManifestPathForCulture.ps1 b/Plaster/Private/GetPlasterManifestPathForCulture.ps1 deleted file mode 100644 index 1a5625a..0000000 --- a/Plaster/Private/GetPlasterManifestPathForCulture.ps1 +++ /dev/null @@ -1,38 +0,0 @@ -function GetPlasterManifestPathForCulture { - [CmdletBinding()] - param ( - [string] - $TemplatePath, - [ValidateNotNull()] - [CultureInfo] - $Culture - ) - if (![System.IO.Path]::IsPathRooted($TemplatePath)) { - $TemplatePath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($TemplatePath) - } - - # Check for culture-locale first. - $plasterManifestBasename = "plasterManifest" - $plasterManifestFilename = "${plasterManifestBasename}_$($culture.Name).xml" - $plasterManifestPath = Join-Path $TemplatePath $plasterManifestFilename - if (Test-Path $plasterManifestPath) { - return $plasterManifestPath - } - - # Check for culture next. - if ($culture.Parent.Name) { - $plasterManifestFilename = "${plasterManifestBasename}_$($culture.Parent.Name).xml" - $plasterManifestPath = Join-Path $TemplatePath $plasterManifestFilename - if (Test-Path $plasterManifestPath) { - return $plasterManifestPath - } - } - - # Fallback to invariant culture manifest. - $plasterManifestPath = Join-Path $TemplatePath "${plasterManifestBasename}.xml" - if (Test-Path $plasterManifestPath) { - return $plasterManifestPath - } - - $null -} \ No newline at end of file diff --git a/Plaster/Public/Invoke-Plaster.ps1 b/Plaster/Public/Invoke-Plaster.ps1 index f233c7c..eb434a7 100644 --- a/Plaster/Public/Invoke-Plaster.ps1 +++ b/Plaster/Public/Invoke-Plaster.ps1 @@ -75,7 +75,7 @@ function Invoke-Plaster { } # Load manifest file using culture lookup - $manifestPath = GetPlasterManifestPathForCulture $templateAbsolutePath $PSCulture + $manifestPath = Get-PlasterManifestPathForCulture $templateAbsolutePath $PSCulture if (($null -eq $manifestPath) -or (!(Test-Path $manifestPath))) { return } @@ -175,7 +175,7 @@ function Invoke-Plaster { # or it wasn't valid. If so, let's try to load it here. If anything, we can provide better errors here. if ($null -eq $manifest) { if ($null -eq $manifestPath) { - $manifestPath = GetPlasterManifestPathForCulture $templateAbsolutePath $PSCulture + $manifestPath = Get-PlasterManifestPathForCulture $templateAbsolutePath $PSCulture } if (Test-Path -LiteralPath $manifestPath -PathType Leaf) { diff --git a/tests/Get-PlasterManifestPathForCulture.Tests.ps1 b/tests/Get-PlasterManifestPathForCulture.Tests.ps1 new file mode 100644 index 0000000..3ae9ad6 --- /dev/null +++ b/tests/Get-PlasterManifestPathForCulture.Tests.ps1 @@ -0,0 +1,50 @@ +BeforeDiscovery { + if ($null -eq $env:BHProjectPath) { + $path = Join-Path -Path $PSScriptRoot -ChildPath '..\build.ps1' + . $path -Task Build + } + $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest + $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' + $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName + $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion + $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" + Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore + Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop +} +Describe 'Get-PlasterManifestPathForCulture' { + BeforeEach { + $script:examplesPath = Resolve-Path "$env:BHProjectPath/examples/" + } + + Context "when given a template path and culture" { + InModuleScope $env:BHProjectName { + It "returns the manifest for the specified culture" { + $culture = Get-Culture -name "en-US" + $plasterManifestFilename = "plasterManifest_en-US.xml" + Mock -CommandName 'Test-Path' -MockWith { $true } -ParameterFilter { $Path -like "*$($script:examplesPath)" } + $manifestPath = Get-PlasterManifestPathForCulture -TemplatePath $script:examplesPath -Culture $culture + $manifestPath | Should -BeLike "*$($plasterManifestFilename)" + } + + It "returns the parent culture manifest if available" { + $culture = New-Object System.Globalization.CultureInfo("fr-FR") + $plasterManifestFilename = "plasterManifest_fr-FR.xml" + + Mock -CommandName 'Test-Path' -MockWith { $False } -ParameterFilter { $Path -like "*en-US*" } + Mock -CommandName 'Test-Path' -MockWith { $True } -ParameterFilter { $Path -like "*fr-FR*" } + + $manifestPath = Get-PlasterManifestPathForCulture -TemplatePath $script:examplesPath -Culture $culture + $manifestPath | Should -BeLike "*$($plasterManifestFilename)" + } + + It "falls back to invariant culture manifest if no specific match is found" { + $culture = New-Object System.Globalization.CultureInfo("xx-XX") + Mock -CommandName 'Test-Path' -MockWith { $False } -ParameterFilter { $Path -like "*en-US*" } + Mock -CommandName 'Test-Path' -MockWith { $True } -ParameterFilter { $Path -like "*fr-FR*" } + Mock -CommandName 'Test-Path' -MockWith { $True } -ParameterFilter { $Path -like "*plasterManifest.xml" } + $manifestPath = Get-PlasterManifestPathForCulture -TemplatePath $script:examplesPath -Culture $culture + $manifestPath | Should -BeLike "*plasterManifest.xml" + } + } + } +} From 89d3e6231aa2cbce7d973d047ceeb1c6eb87ad5b Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Mon, 14 Jul 2025 19:56:04 -0700 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20`Initialize-Prede?= =?UTF-8?q?finedVariables`=20function=20and=20corresponding=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Introduced the `Initialize-PredefinedVariables` function to set up essential variables for Plaster template processing. * Updated `Invoke-Plaster` to call the new function with appropriate parameters. * Added tests for `Initialize-PredefinedVariables` to ensure correct initialization of predefined variables. * Modified `.vscode/settings.json` to refine search exclusion patterns. --- .vscode/settings.json | 4 +- ...ps1 => Initialize-PredefinedVariables.ps1} | 30 ++++++++- Plaster/Public/Invoke-Plaster.ps1 | 2 +- .../Initialize-PredefinedVariables.Tests.ps1 | 65 +++++++++++++++++++ 4 files changed, 96 insertions(+), 5 deletions(-) rename Plaster/Private/{InitializePredefinedVariables.ps1 => Initialize-PredefinedVariables.ps1} (60%) create mode 100644 tests/Initialize-PredefinedVariables.Tests.ps1 diff --git a/.vscode/settings.json b/.vscode/settings.json index d237442..f12a289 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,7 +7,7 @@ // -------- Search configuration -------- // Exclude the Output folder from search results. "search.exclude": { - "Output/**": true, + "Output": true, }, //-------- PowerShell Configuration -------- // Use a custom PowerShell Script Analyzer settings file for this workspace. @@ -17,4 +17,4 @@ "powershell.codeFormatting.preset": "OTBS", "editor.formatOnSave": true, "powershell.scriptAnalysis.enable": true -} \ No newline at end of file +} diff --git a/Plaster/Private/InitializePredefinedVariables.ps1 b/Plaster/Private/Initialize-PredefinedVariables.ps1 similarity index 60% rename from Plaster/Private/InitializePredefinedVariables.ps1 rename to Plaster/Private/Initialize-PredefinedVariables.ps1 index 25c248f..4bcfbb1 100644 --- a/Plaster/Private/InitializePredefinedVariables.ps1 +++ b/Plaster/Private/Initialize-PredefinedVariables.ps1 @@ -1,4 +1,29 @@ -function InitializePredefinedVariables { +function Initialize-PredefinedVariables { + <# + .SYNOPSIS + Initializes predefined variables used by Plaster. + + .DESCRIPTION + This function sets up several predefined variables that are used throughout + the Plaster template processing. It includes variables for the template + path, destination path, and other relevant information. + + .PARAMETER TemplatePath + The file system path to the Plaster template directory. + + .PARAMETER DestPath + The file system path to the destination directory. + + .EXAMPLE + Initialize-PredefinedVariables -TemplatePath "C:\Templates\MyTemplate" -DestPath "C:\Projects\MyProject" + + This example initializes the predefined variables with the specified + template and destination paths. + .NOTES + This function is typically called at the beginning of the Plaster template + processing to ensure that all necessary variables are set up before any + template processing occurs. + #> [CmdletBinding()] param( [string] @@ -6,6 +31,7 @@ function InitializePredefinedVariables { [string] $DestPath ) + # Always set these variables, even if the command has been run with -WhatIf $WhatIfPreference = $false @@ -28,4 +54,4 @@ function InitializePredefinedVariables { Set-Variable -Name PLASTER_Date -Value ($now.ToShortDateString()) -Scope Script Set-Variable -Name PLASTER_Time -Value ($now.ToShortTimeString()) -Scope Script Set-Variable -Name PLASTER_Year -Value ($now.Year) -Scope Script -} \ No newline at end of file +} diff --git a/Plaster/Public/Invoke-Plaster.ps1 b/Plaster/Public/Invoke-Plaster.ps1 index eb434a7..fd1cba8 100644 --- a/Plaster/Public/Invoke-Plaster.ps1 +++ b/Plaster/Public/Invoke-Plaster.ps1 @@ -207,7 +207,7 @@ function Invoke-Plaster { } # Create the pre-defined Plaster variables. - InitializePredefinedVariables $templateAbsolutePath $destinationAbsolutePath + Initialize-PredefinedVariables -TemplatePath $templateAbsolutePath -DestPath $destinationAbsolutePath # Check for any existing default value store file and load default values if file exists. $templateId = $manifest.plasterManifest.metadata.id diff --git a/tests/Initialize-PredefinedVariables.Tests.ps1 b/tests/Initialize-PredefinedVariables.Tests.ps1 new file mode 100644 index 0000000..79de9cd --- /dev/null +++ b/tests/Initialize-PredefinedVariables.Tests.ps1 @@ -0,0 +1,65 @@ +BeforeDiscovery { + if ($null -eq $env:BHProjectPath) { + $path = Join-Path -Path $PSScriptRoot -ChildPath '..\build.ps1' + . $path -Task Build + } + $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest + $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' + $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName + $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion + $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" + Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore + Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop +} +Describe 'Initialize-PredefinedVariables' { + InModuleScope $env:BHProjectName { + BeforeDiscovery { + $script:variables = @( + 'PLASTER_TemplatePath', + 'PLASTER_DestinationPath', + 'PLASTER_DestinationName', + 'PLASTER_DirSepChar', + 'PLASTER_HostName', + 'PLASTER_Version', + 'PLASTER_Guid1', + 'PLASTER_Guid2', + 'PLASTER_Guid3', + 'PLASTER_Guid4', + 'PLASTER_Guid5', + 'PLASTER_Date', + 'PLASTER_Time', + 'PLASTER_Year' + ) + foreach ($var in $script:variables) { + if (Get-Variable -Name $var -ErrorAction SilentlyContinue) { + Remove-Variable -Name $var -Scope Script + } + } + } + BeforeAll { + $script:examplesPath = Resolve-Path "$env:BHProjectPath/examples/" + $script:destPath = 'Test:\Destination' + $script:output = Initialize-PredefinedVariables -TemplatePath $script:examplesPath -DestPath $script:destPath + } + It 'should not return any output' { + $script:output | Should -BeNullOrEmpty + } + + It "initializes predefined variable <_>" -ForEach $script:variables { + $varValue = Get-Variable -name $_ -Scope Script -ErrorAction SilentlyContinue + $varValue | Should -Not -BeNullOrEmpty + } + + It 'PLASTER_TemplatePath should match the provided template path' { + $expectedPath = $script:examplesPath.TrimEnd('\', '/') + $actualPath = (Get-Variable -Name 'PLASTER_TemplatePath' -Scope Script).Value + $actualPath | Should -Be $expectedPath + } + + It 'PLASTER_DestinationPath should match the provided destination path' { + $expectedPath = $script:destPath.TrimEnd('\', '/') + $actualPath = (Get-Variable -Name 'PLASTER_DestinationPath' -Scope Script).Value + $actualPath | Should -Be $expectedPath + } + } +} From 33a80ad145e12dd15d9578ac2268697e998f95e3 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Mon, 14 Jul 2025 20:00:12 -0700 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20=E2=9C=A8=20Enhance=20documentation?= =?UTF-8?q?=20for=20`Invoke-PlasterOperation`=20and=20`Write-PlasterLog`?= =?UTF-8?q?=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added detailed synopsis, description, parameters, examples, and notes to improve clarity and usability. * Ensured consistent logging and error handling across operations within the Plaster module. --- Plaster/Private/Invoke-PlasterOperation.ps1 | 43 ++++++++++++++++++--- Plaster/Private/Write-PlasterLog.ps1 | 31 ++++++++++++++- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/Plaster/Private/Invoke-PlasterOperation.ps1 b/Plaster/Private/Invoke-PlasterOperation.ps1 index 4219e05..8b40fe6 100644 --- a/Plaster/Private/Invoke-PlasterOperation.ps1 +++ b/Plaster/Private/Invoke-PlasterOperation.ps1 @@ -1,13 +1,46 @@ # Enhanced error handling wrapper function Invoke-PlasterOperation { + <# + .SYNOPSIS + Wraps the execution of a script block with enhanced error handling and + logging capabilities. + + .DESCRIPTION + This function wraps the execution of a script block with enhanced error + handling and logging capabilities. + + .PARAMETER ScriptBlock + The script block to execute. + + .PARAMETER OperationName + The name of the operation being performed. + + .PARAMETER PassThru + If specified, the output of the script block output will be returned. + + .EXAMPLE + Invoke-PlasterOperation -ScriptBlock { Get-Process } -OperationName 'GetProcesses' -PassThru + + This example executes the `Get-Process` cmdlet within the context of the + `Invoke-PlasterOperation` function, logging the operation and returning the + output. + + .NOTES + This function is designed to be used within the Plaster module to ensure + consistent logging and error handling across various operations. + It is not intended for direct use outside of the Plaster context. + #> [CmdletBinding()] param( [Parameter(Mandatory)] - [scriptblock]$ScriptBlock, + [scriptblock] + $ScriptBlock, - [string]$OperationName = 'PlasterOperation', + [string] + $OperationName = 'PlasterOperation', - [switch]$PassThru + [switch] + $PassThru ) try { @@ -15,7 +48,7 @@ function Invoke-PlasterOperation { $result = & $ScriptBlock Write-PlasterLog -Level Debug -Message "Completed operation: $OperationName" - if ($PassThru) { + if ($PassThru.IsPresent) { return $result } } catch { @@ -23,4 +56,4 @@ function Invoke-PlasterOperation { Write-PlasterLog -Level Error -Message $errorMessage throw $_ } -} \ No newline at end of file +} diff --git a/Plaster/Private/Write-PlasterLog.ps1 b/Plaster/Private/Write-PlasterLog.ps1 index b71631c..b5538d3 100644 --- a/Plaster/Private/Write-PlasterLog.ps1 +++ b/Plaster/Private/Write-PlasterLog.ps1 @@ -1,4 +1,33 @@ function Write-PlasterLog { + <# + .SYNOPSIS + Logs messages with different severity levels for Plaster operations. + + .DESCRIPTION + This function logs messages with different severity levels for Plaster + operations. + + .PARAMETER Level + The severity level of the log message. Possible values are 'Error', + 'Warning', 'Information', 'Verbose', and 'Debug'. The log message will be + formatted with a timestamp and the source of the log. + + .PARAMETER Message + The message to log. + + .PARAMETER Source + The source of the log message. + + .EXAMPLE + Write-PlasterLog -Level 'Information' -Message 'This is an informational message.' + + This example logs an informational message with the specified level and + source. + .NOTES + This function is designed to be used within the Plaster module to ensure + consistent logging across various operations. + It is not intended for direct use outside of the Plaster context. + #> [CmdletBinding()] param( [Parameter(Mandatory)] @@ -21,4 +50,4 @@ function Write-PlasterLog { 'Verbose' { Write-Verbose $logMessage } 'Debug' { Write-Debug $logMessage } } -} \ No newline at end of file +} From 1867c28992220590e11d199060c70442d280ac09 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Mon, 14 Jul 2025 20:09:17 -0700 Subject: [PATCH 4/7] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20`Resolve-ModuleVe?= =?UTF-8?q?rsionString`=20function=20and=20corresponding=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Introduced `Resolve-ModuleVersionString` to parse version strings into valid version objects. * Replaced the inline version parsing logic in `Get-ModuleExtension` with a call to `Resolve-ModuleVersionString`. * Added tests for `Resolve-ModuleVersionString` to ensure correct functionality and error handling. --- .vscode/settings.json | 1 + .../Private/Resolve-ModuleVersionString.ps1 | 58 +++++++++++++++++++ Plaster/Public/Get-ModuleExtension.ps1 | 24 +------- tests/Resolve-ModuleVersionString.Tests.ps1 | 35 +++++++++++ 4 files changed, 96 insertions(+), 22 deletions(-) create mode 100644 Plaster/Private/Resolve-ModuleVersionString.ps1 create mode 100644 tests/Resolve-ModuleVersionString.Tests.ps1 diff --git a/.vscode/settings.json b/.vscode/settings.json index f12a289..c97ebbc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,6 +4,7 @@ "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, "editor.insertSpaces": true, + "editor.tabSize": 4, // -------- Search configuration -------- // Exclude the Output folder from search results. "search.exclude": { diff --git a/Plaster/Private/Resolve-ModuleVersionString.ps1 b/Plaster/Private/Resolve-ModuleVersionString.ps1 new file mode 100644 index 0000000..f059e1a --- /dev/null +++ b/Plaster/Private/Resolve-ModuleVersionString.ps1 @@ -0,0 +1,58 @@ +function Resolve-ModuleVersionString { + <# + .SYNOPSIS + Resolve a module version string to a System.Version or + System.Management.Automation.SemanticVersion object. + + .DESCRIPTION + This function takes a version string and returns a parsed version object. + It ensures that the version string is in a valid format, particularly for + Semantic Versioning 2.0, which requires at least three components + (major.minor.patch). If the patch component is missing, the function will + append ".0" to the version string. + + .PARAMETER versionString + The version string to resolve. + + .EXAMPLE + Resolve-ModuleVersionString -versionString "1.2" + + This example resolves the version string "1.2" to a valid version object. + .NOTES + This function is designed to be used within the Plaster module to ensure consistent version handling. + It is not intended for direct use outside of the Plaster context. + #> + param( + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string] + $versionString + ) + $parsedVersion = $null + + if ($versionString) { + # We're targeting Semantic Versioning 2.0 so make sure the version has + # at least 3 components (X.X.X). This logic ensures that the "patch" + # (third) component has been specified. + $versionParts = $versionString.Split('.') + if ($versionParts.Length -lt 3) { + $versionString = "$versionString.0" + } + + if ($PSVersionTable.PSEdition -eq "Core") { + $newObjectSplat = @{ + TypeName = "System.Management.Automation.SemanticVersion" + ArgumentList = $versionString + } + $parsedVersion = New-Object @newObjectSplat + } else { + $newObjectSplat = @{ + TypeName = "System.Version" + ArgumentList = $versionString + } + $parsedVersion = New-Object @newObjectSplat + } + } + + return $parsedVersion +} diff --git a/Plaster/Public/Get-ModuleExtension.ps1 b/Plaster/Public/Get-ModuleExtension.ps1 index 3f2d410..eccfaf4 100644 --- a/Plaster/Public/Get-ModuleExtension.ps1 +++ b/Plaster/Public/Get-ModuleExtension.ps1 @@ -25,27 +25,7 @@ function Get-ModuleExtension { Write-Verbose "Found $($modules.Length) installed modules to scan for extensions." - function ParseVersion($versionString) { - $parsedVersion = $null - if ($versionString) { - # We're targeting Semantic Versioning 2.0 so make sure the version has - # at least 3 components (X.X.X). This logic ensures that the "patch" - # (third) component has been specified. - $versionParts = $versionString.Split('.') - if ($versionParts.Length -lt 3) { - $versionString = "$versionString.0" - } - - if ($PSVersionTable.PSEdition -eq "Core") { - $parsedVersion = New-Object -TypeName "System.Management.Automation.SemanticVersion" -ArgumentList $versionString - } else { - $parsedVersion = New-Object -TypeName "System.Version" -ArgumentList $versionString - } - } - - return $parsedVersion - } foreach ($module in $modules) { if ($module.PrivateData -and @@ -58,8 +38,8 @@ function Get-ModuleExtension { Write-Verbose "Comparing against module extension: $($extension.Module)" - $minimumVersion = ParseVersion $extension.MinimumVersion - $maximumVersion = ParseVersion $extension.MaximumVersion + $minimumVersion = Resolve-ModuleVersionString $extension.MinimumVersion + $maximumVersion = Resolve-ModuleVersionString $extension.MaximumVersion if (($extension.Module -eq $ModuleName) -and (!$minimumVersion -or $ModuleVersion -ge $minimumVersion) -and diff --git a/tests/Resolve-ModuleVersionString.Tests.ps1 b/tests/Resolve-ModuleVersionString.Tests.ps1 new file mode 100644 index 0000000..a6f875e --- /dev/null +++ b/tests/Resolve-ModuleVersionString.Tests.ps1 @@ -0,0 +1,35 @@ +BeforeDiscovery { + if ($null -eq $env:BHProjectPath) { + $path = Join-Path -Path $PSScriptRoot -ChildPath '..\build.ps1' + . $path -Task Build + } + $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest + $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' + $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName + $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion + $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" + Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore + Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop +} +Describe 'Resolve-ModuleVersionString' { + InModuleScope $env:BHProjectName { + It 'Should resolve a valid version string' { + $versionString = "1.2.3" + $result = Resolve-ModuleVersionString -versionString $versionString + $result | Should -BeOfType [System.Management.Automation.SemanticVersion] + $result.ToString() | Should -Be $versionString + } + + It 'Should append .0 to a version string with only two components' { + $versionString = "1.2" + $result = Resolve-ModuleVersionString -versionString $versionString + $result | Should -BeOfType [System.Management.Automation.SemanticVersion] + $result.ToString() | Should -Be "1.2.0" + } + + It 'Should handle invalid version strings gracefully' { + $versionString = "invalid.version" + { Resolve-ModuleVersionString -versionString $versionString } | Should -Throw + } + } +} From e94490970abf2c76d263df42f271b95b5b5bd097 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Mon, 14 Jul 2025 21:12:34 -0700 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20`Get-ModuleExtens?= =?UTF-8?q?ion`=20function=20to=20retrieve=20module=20extensions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rename existing function * Supports an optional parameter to list all available modules or only the latest version of each module. * Includes detailed documentation and examples for ease of use. --- .../Get-ModuleExtension.ps1 | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) rename Plaster/{Public => Private}/Get-ModuleExtension.ps1 (69%) diff --git a/Plaster/Public/Get-ModuleExtension.ps1 b/Plaster/Private/Get-ModuleExtension.ps1 similarity index 69% rename from Plaster/Public/Get-ModuleExtension.ps1 rename to Plaster/Private/Get-ModuleExtension.ps1 index eccfaf4..723fd1d 100644 --- a/Plaster/Public/Get-ModuleExtension.ps1 +++ b/Plaster/Private/Get-ModuleExtension.ps1 @@ -1,4 +1,29 @@ function Get-ModuleExtension { + <# + .SYNOPSIS + Retrieves module extensions based on specified criteria. + + .DESCRIPTION + This function retrieves module extensions that match the specified module + name and version criteria. + + .PARAMETER ModuleName + The name of the module to retrieve extensions for. + + .PARAMETER ModuleVersion + The version of the module to retrieve extensions for. + + .PARAMETER ListAvailable + Indicates whether to list all available modules or only the the latest + version of each module. + + .EXAMPLE + Get-ModuleExtension -ModuleName "MyModule" -ModuleVersion "1.0.0" + + Retrieves extensions for the module "MyModule" with version "1.0.0". + .NOTES + + #> [CmdletBinding()] param( [string] @@ -11,9 +36,9 @@ function Get-ModuleExtension { $ListAvailable ) - #Only get the latest version of each module + # Only get the latest version of each module $modules = Get-Module -ListAvailable - if (!$ListAvailable) { + if (!$ListAvailable.IsPresent) { $modules = $modules | Group-Object Name | ForEach-Object { @@ -25,8 +50,6 @@ function Get-ModuleExtension { Write-Verbose "Found $($modules.Length) installed modules to scan for extensions." - - foreach ($module in $modules) { if ($module.PrivateData -and $module.PrivateData.PSData -and From 05c01a5a3da5ca267fe04f257349c4062f189181 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Tue, 15 Jul 2025 15:27:27 -0700 Subject: [PATCH 6/7] Refactor + Tests for Get-ModuleExtension --- Plaster/Private/Get-ModuleExtension.ps1 | 14 +- .../Private/Resolve-ModuleVersionString.ps1 | 46 +- docs/en-US/Get-ModuleExtension.md | 106 - tests/Fixtures/ModuleList.xml | 3895 +++++++++++++++++ tests/Get-ModuleExtension.Tests.ps1 | 41 + 5 files changed, 3968 insertions(+), 134 deletions(-) delete mode 100644 docs/en-US/Get-ModuleExtension.md create mode 100644 tests/Fixtures/ModuleList.xml create mode 100644 tests/Get-ModuleExtension.Tests.ps1 diff --git a/Plaster/Private/Get-ModuleExtension.ps1 b/Plaster/Private/Get-ModuleExtension.ps1 index 723fd1d..db89cab 100644 --- a/Plaster/Private/Get-ModuleExtension.ps1 +++ b/Plaster/Private/Get-ModuleExtension.ps1 @@ -61,8 +61,18 @@ function Get-ModuleExtension { Write-Verbose "Comparing against module extension: $($extension.Module)" - $minimumVersion = Resolve-ModuleVersionString $extension.MinimumVersion - $maximumVersion = Resolve-ModuleVersionString $extension.MaximumVersion + if ([String]::IsNullOrEmpty($extension.MinimumVersion)) { + # Fill with a default value if not specified + $minimumVersion = $null + } else { + $minimumVersion = Resolve-ModuleVersionString $extension.MinimumVersion + } + if ([String]::IsNullOrEmpty($extension.MaximumVersion)) { + # Fill with a default value if not specified + $maximumVersion = $null + } else { + $maximumVersion = Resolve-ModuleVersionString $extension.MaximumVersion + } if (($extension.Module -eq $ModuleName) -and (!$minimumVersion -or $ModuleVersion -ge $minimumVersion) -and diff --git a/Plaster/Private/Resolve-ModuleVersionString.ps1 b/Plaster/Private/Resolve-ModuleVersionString.ps1 index f059e1a..f451aad 100644 --- a/Plaster/Private/Resolve-ModuleVersionString.ps1 +++ b/Plaster/Private/Resolve-ModuleVersionString.ps1 @@ -23,36 +23,30 @@ function Resolve-ModuleVersionString { It is not intended for direct use outside of the Plaster context. #> param( - [Parameter(Mandatory)] + [Parameter(Mandatory, Position = 0)] [ValidateNotNullOrEmpty()] - [string] - $versionString + $VersionString ) - $parsedVersion = $null - if ($versionString) { - # We're targeting Semantic Versioning 2.0 so make sure the version has - # at least 3 components (X.X.X). This logic ensures that the "patch" - # (third) component has been specified. - $versionParts = $versionString.Split('.') - if ($versionParts.Length -lt 3) { - $versionString = "$versionString.0" - } + # We're targeting Semantic Versioning 2.0 so make sure the version has + # at least 3 components (X.X.X). This logic ensures that the "patch" + # (third) component has been specified. + $versionParts = $VersionString.Split('.') + if ($versionParts.Length -lt 3) { + $VersionString = "$VersionString.0" + } - if ($PSVersionTable.PSEdition -eq "Core") { - $newObjectSplat = @{ - TypeName = "System.Management.Automation.SemanticVersion" - ArgumentList = $versionString - } - $parsedVersion = New-Object @newObjectSplat - } else { - $newObjectSplat = @{ - TypeName = "System.Version" - ArgumentList = $versionString - } - $parsedVersion = New-Object @newObjectSplat + if ($PSVersionTable.PSEdition -eq "Core") { + $newObjectSplat = @{ + TypeName = "System.Management.Automation.SemanticVersion" + ArgumentList = $VersionString } + return New-Object @newObjectSplat + } else { + $newObjectSplat = @{ + TypeName = "System.Version" + ArgumentList = $VersionString + } + return New-Object @newObjectSplat } - - return $parsedVersion } diff --git a/docs/en-US/Get-ModuleExtension.md b/docs/en-US/Get-ModuleExtension.md deleted file mode 100644 index ed2ab82..0000000 --- a/docs/en-US/Get-ModuleExtension.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -external help file: Plaster-help.xml -Module Name: Plaster -online version: -schema: 2.0.0 ---- - -# Get-ModuleExtension - -## SYNOPSIS -{{ Fill in the Synopsis }} - -## SYNTAX - -``` -Get-ModuleExtension [[-ModuleName] ] [[-ModuleVersion] ] [-ListAvailable] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### Example 1 -```powershell -PS C:\> {{ Add example code here }} -``` - -{{ Add example description here }} - -## PARAMETERS - -### -ListAvailable -{{ Fill ListAvailable Description }} - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ModuleName -{{ Fill ModuleName Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 0 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ModuleVersion -{{ Fill ModuleVersion Description }} - -```yaml -Type: Version -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### None - -## OUTPUTS - -### System.Object -## NOTES - -## RELATED LINKS diff --git a/tests/Fixtures/ModuleList.xml b/tests/Fixtures/ModuleList.xml new file mode 100644 index 0000000..2bb1c8b --- /dev/null +++ b/tests/Fixtures/ModuleList.xml @@ -0,0 +1,3895 @@ + + + + ModuleInfoGrouping + System.Management.Automation.PSModuleInfo + System.Object + + PSStucco + + false + PSStucco + C:\Users\me\OneDrive\Documents\PowerShell\Modules\PSStucco\0.6.0\PSStucco.psd1 + + + An opinionated Plaster template for high-quality PowerShell modules + 24effa48-ac05-4efd-872d-40d556089ce0 + + C:\Users\me\OneDrive\Documents\PowerShell\Modules\PSStucco\0.6.1 + + + System.Collections.Hashtable + System.Object + + + + PSData + + + + + IconUri + https://raw.githubusercontent.com/jimbrig/Stucco/main/media/trowel.png + + + Tags + + + System.Object[] + System.Array + System.Object + + + Plaster + Module + Template + PSEdition_Core + PSEdition_Desktop + + + + + LicenseUri + https://raw.githubusercontent.com/jimbrig/PSStucco/main/LICENSE + + + ReleaseNotes + https://raw.githubusercontent.com/jimbrig/Stucco/main/CHANGELOG.md + + + Extensions + + + + + + + + Module + Plaster + + + MinimumVersion + 1.1.4 + + + Details + + + + + TemplatePaths + + + + . + + + + + + + + + + + + + ProjectUri + https://github.com/jimbrig/PSStucco + + + + + + + + + System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.ExperimentalFeature, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + System.Collections.Generic.List`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] + System.Object + + + Plaster + Module + Template + PSEdition_Core + PSEdition_Desktop + + + https://github.com/jimbrig/PSStucco + https://raw.githubusercontent.com/jimbrig/Stucco/main/media/trowel.png + https://raw.githubusercontent.com/jimbrig/PSStucco/main/LICENSE + https://raw.githubusercontent.com/jimbrig/Stucco/main/CHANGELOG.md + https://www.powershellgallery.com/api/v2 + 0.6.1 + + + System.Management.Automation.ModuleType + System.Enum + System.ValueType + System.Object + + Script + 0 + + Jimmy Briggs + + + System.Management.Automation.ModuleAccessMode + System.Enum + System.ValueType + System.Object + + ReadWrite + 0 + + + Community + (c) Jimmy Briggs. All rights reserved. + + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.FunctionInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + Get-StuccoTemplate + + + System.Management.Automation.FunctionInfo + System.Management.Automation.CommandInfo + System.Object + + Get-StuccoTemplate + + + false + + + None + + Get + StuccoTemplate + + + + System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.PSTypeName, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + Get-StuccoTemplate + Function + PSStucco + 0.6.1 + Public + PSStucco + + + PSStucco + + PowerShell + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.ParameterMetadata, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.CommandParameterSetInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + + + PSStucco + + + + + + New-StuccoModule + + + New-StuccoModule + + + false + + + None + + New + StuccoModule + + + + + + New-StuccoModule + Function + PSStucco + 0.6.1 + Public + PSStucco + + + PSStucco + + PowerShell + + + + + + + + + + + + + PSStucco + + + + + + + + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.CmdletInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.CommandInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + Get-StuccoTemplate + + + Get-StuccoTemplate + + + false + + + None + + Get + StuccoTemplate + + + + + + Get-StuccoTemplate + Function + PSStucco + 0.6.1 + Public + PSStucco + + + PSStucco + + PowerShell + + + + + + + + + + + + + PSStucco + + + + + + New-StuccoModule + + + New-StuccoModule + + + false + + + None + + New + StuccoModule + + + + + + New-StuccoModule + Function + PSStucco + 0.6.1 + Public + PSStucco + + + PSStucco + + PowerShell + + + + + + + + + + + + + PSStucco + + + + + + + + + + + + + + + + + System.Collections.ObjectModel.Collection`1[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] + System.Object + + + + + + System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.PSModuleInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + 3.0 + + + System.Reflection.ProcessorArchitecture + System.Enum + System.ValueType + System.Object + + None + 0 + + + + + + + + System.Collections.ObjectModel.Collection`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] + System.Object + + + + + + + + PSStucco.psm1 + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.PSVariable, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.AliasInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + System.Collections.ObjectModel.ReadOnlyCollection`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] + System.Object + + + + + + + + + + + + + + + + + + ModuleInfoGrouping + System.Management.Automation.PSModuleInfo + System.Object + + PSStucco + + false + PSStucco + C:\Users\me\OneDrive\Documents\PowerShell\Modules\PSStucco\0.6.0\PSStucco.psd1 + + + An opinionated Plaster template for high-quality PowerShell modules + 24effa48-ac05-4efd-872d-40d556089ce0 + + C:\Users\me\OneDrive\Documents\PowerShell\Modules\PSStucco\0.6.0 + + + System.Collections.Hashtable + System.Object + + + + PSData + + + + + IconUri + https://raw.githubusercontent.com/jimbrig/Stucco/main/media/trowel.png + + + Tags + + + System.Object[] + System.Array + System.Object + + + Plaster + Module + Template + PSEdition_Core + PSEdition_Desktop + + + + + LicenseUri + https://raw.githubusercontent.com/jimbrig/PSStucco/main/LICENSE + + + ReleaseNotes + https://raw.githubusercontent.com/jimbrig/Stucco/main/CHANGELOG.md + + + Extensions + + + + + + + + Module + Plaster + + + MinimumVersion + 1.1.4 + + + Details + + + + + TemplatePaths + + + + . + + + + + + + + + + + + + ProjectUri + https://github.com/jimbrig/PSStucco + + + + + + + + + System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.ExperimentalFeature, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + System.Collections.Generic.List`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] + System.Object + + + Plaster + Module + Template + PSEdition_Core + PSEdition_Desktop + + + https://github.com/jimbrig/PSStucco + https://raw.githubusercontent.com/jimbrig/Stucco/main/media/trowel.png + https://raw.githubusercontent.com/jimbrig/PSStucco/main/LICENSE + https://raw.githubusercontent.com/jimbrig/Stucco/main/CHANGELOG.md + https://www.powershellgallery.com/api/v2 + 0.6.0 + + + System.Management.Automation.ModuleType + System.Enum + System.ValueType + System.Object + + Script + 0 + + Jimmy Briggs + + + System.Management.Automation.ModuleAccessMode + System.Enum + System.ValueType + System.Object + + ReadWrite + 0 + + + Community + (c) Jimmy Briggs. All rights reserved. + + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.FunctionInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + Get-StuccoTemplate + + + System.Management.Automation.FunctionInfo + System.Management.Automation.CommandInfo + System.Object + + Get-StuccoTemplate + + + false + + + None + + Get + StuccoTemplate + + + + System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.PSTypeName, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + Get-StuccoTemplate + Function + PSStucco + 0.6.0 + Public + PSStucco + + + PSStucco + + PowerShell + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.ParameterMetadata, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.CommandParameterSetInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + + + PSStucco + + + + + + New-StuccoModule + + + New-StuccoModule + + + false + + + None + + New + StuccoModule + + + + + + New-StuccoModule + Function + PSStucco + 0.6.0 + Public + PSStucco + + + PSStucco + + PowerShell + + + + + + + + + + + + + PSStucco + + + + + + + + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.CmdletInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.CommandInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + Get-StuccoTemplate + + + Get-StuccoTemplate + + + false + + + None + + Get + StuccoTemplate + + + + + + Get-StuccoTemplate + Function + PSStucco + 0.6.0 + Public + PSStucco + + + PSStucco + + PowerShell + + + + + + + + + + + + + PSStucco + + + + + + New-StuccoModule + + + New-StuccoModule + + + false + + + None + + New + StuccoModule + + + + + + New-StuccoModule + Function + PSStucco + 0.6.0 + Public + PSStucco + + + PSStucco + + PowerShell + + + + + + + + + + + + + PSStucco + + + + + + + + + + + + + + + + + System.Collections.ObjectModel.Collection`1[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] + System.Object + + + + + + System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.PSModuleInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + 3.0 + + + System.Reflection.ProcessorArchitecture + System.Enum + System.ValueType + System.Object + + None + 0 + + + + + + + + System.Collections.ObjectModel.Collection`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] + System.Object + + + + + + + + PSStucco.psm1 + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.PSVariable, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.AliasInfo, System.Management.Automation, Version=7.5.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] + System.Object + + + + + + System.Collections.ObjectModel.ReadOnlyCollection`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] + System.Object + + + + + + + + + + + + + + + + + + Sampler + + false + Sampler + C:\Users\me\OneDrive\Documents\PowerShell\Modules\Sampler\0.118.3\Sampler.psd1 + + + Sample Module with Pipeline scripts and its Plaster template to create a module following some of the community accepted practices. + b59b8442-9cf9-4c4b-bc40-035336ace573 + + C:\Users\me\OneDrive\Documents\PowerShell\Modules\Sampler\0.118.3 + + + + + PSData + + + + + IconUri + https://raw.githubusercontent.com/gaelcolas/Sampler/main/Sampler/assets/sampler.png + + + Tags + + + + Template + pipeline + plaster + DesiredStateConfiguration + DSC + DSCResourceKit + DSCResource + Windows + MacOS + Linux + + + + + LicenseUri + https://github.com/gaelcolas/Sampler/blob/main/LICENSE + + + ReleaseNotes + ## [0.118.3] - 2025-04-29_x000D__x000A__x000D__x000A_### Changed_x000D__x000A__x000D__x000A_- Renamed function `Get-BuildVersion` to `Get-SamplerBuildVersion` to maintain_x000D__x000A_ consistency with the module's naming convention and updated all references_x000D__x000A_ throughout the codebase ([issue #520](https://github.com/gaelcolas/Sampler/issues/520))._x000D__x000A__x000D__x000A_### Fixed_x000D__x000A__x000D__x000A_- Fixed issue with localization string testing with new version of the HQRM_x000D__x000A_ tests (module DscResource.Test)._x000D__x000A_- Integration test for SimpleModule template was not using the built Sampler_x000D__x000A_ module._x000D__x000A__x000D__x000A_ + + + Prerelease + + + + Extensions + + + + + + + + Module + Plaster + + + minimumVersion + 1.1.3 + + + Details + + + + + TemplatePaths + + + + Templates\Classes + Templates\ClassResource + Templates\Composite + Templates\Enum + Templates\MofResource + Templates\PrivateFunction + Templates\PublicCallPrivateFunctions + Templates\PublicFunction + Templates\Sampler + + + + + + + + + + + + + ProjectUri + https://github.com/gaelcolas/Sampler + + + + + + + + + + + Template + pipeline + plaster + DesiredStateConfiguration + DSC + DSCResourceKit + DSCResource + Windows + MacOS + Linux + Template + pipeline + plaster + DesiredStateConfiguration + DSC + DSCResourceKit + DSCResource + Windows + MacOS + Linux + + + https://github.com/gaelcolas/Sampler + https://raw.githubusercontent.com/gaelcolas/Sampler/main/Sampler/assets/sampler.png + https://github.com/gaelcolas/Sampler/blob/main/LICENSE + ## [0.118.3] - 2025-04-29_x000D__x000A__x000D__x000A_### Changed_x000D__x000A__x000D__x000A_- Renamed function `Get-BuildVersion` to `Get-SamplerBuildVersion` to maintain_x000D__x000A_ consistency with the module's naming convention and updated all references_x000D__x000A_ throughout the codebase ([issue #520](https://github.com/gaelcolas/Sampler/issues/520))._x000D__x000A__x000D__x000A_### Fixed_x000D__x000A__x000D__x000A_- Fixed issue with localization string testing with new version of the HQRM_x000D__x000A_ tests (module DscResource.Test)._x000D__x000A_- Integration test for SimpleModule template was not using the built Sampler_x000D__x000A_ module._x000D__x000A__x000D__x000A_ + https://www.powershellgallery.com/api/v2 + 0.118.3 + + + Script + 0 + + Gael Colas + + + ReadWrite + 0 + + + SynEdgy Limited + (c) Gael Colas. All rights reserved. + + + + + + Add-Sample + + + Add-Sample + + + false + + + None + + Add + Sample + + + + + + Add-Sample + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Convert-SamplerHashtableToString + + + Convert-SamplerHashtableToString + + + false + + + None + + Convert + SamplerHashtableToString + + + + + + Convert-SamplerHashtableToString + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-BuiltModuleVersion + + + Get-BuiltModuleVersion + + + false + + + None + + Get + BuiltModuleVersion + + + + + + Get-BuiltModuleVersion + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-ClassBasedResourceName + + + Get-ClassBasedResourceName + + + false + + + None + + Get + ClassBasedResourceName + + + + + + Get-ClassBasedResourceName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-CodeCoverageThreshold + + + Get-CodeCoverageThreshold + + + false + + + None + + Get + CodeCoverageThreshold + + + + + + Get-CodeCoverageThreshold + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-MofSchemaName + + + Get-MofSchemaName + + + false + + + None + + Get + MofSchemaName + + + + + + Get-MofSchemaName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-OperatingSystemShortName + + + Get-OperatingSystemShortName + + + false + + + None + + Get + OperatingSystemShortName + + + + + + Get-OperatingSystemShortName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-PesterOutputFileFileName + + + Get-PesterOutputFileFileName + + + false + + + None + + Get + PesterOutputFileFileName + + + + + + Get-PesterOutputFileFileName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-Psm1SchemaName + + + Get-Psm1SchemaName + + + false + + + None + + Get + Psm1SchemaName + + + + + + Get-Psm1SchemaName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerAbsolutePath + + + Get-SamplerAbsolutePath + + + false + + + None + + Get + SamplerAbsolutePath + + + + + + Get-SamplerAbsolutePath + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerBuildVersion + + + Get-SamplerBuildVersion + + + false + + + None + + Get + SamplerBuildVersion + + + + + + Get-SamplerBuildVersion + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerBuiltModuleBase + + + Get-SamplerBuiltModuleBase + + + false + + + None + + Get + SamplerBuiltModuleBase + + + + + + Get-SamplerBuiltModuleBase + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerBuiltModuleManifest + + + Get-SamplerBuiltModuleManifest + + + false + + + None + + Get + SamplerBuiltModuleManifest + + + + + + Get-SamplerBuiltModuleManifest + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerCodeCoverageOutputFile + + + Get-SamplerCodeCoverageOutputFile + + + false + + + None + + Get + SamplerCodeCoverageOutputFile + + + + + + Get-SamplerCodeCoverageOutputFile + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerCodeCoverageOutputFileEncoding + + + Get-SamplerCodeCoverageOutputFileEncoding + + + false + + + None + + Get + SamplerCodeCoverageOutputFileEncoding + + + + + + Get-SamplerCodeCoverageOutputFileEncoding + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerModuleInfo + + + Get-SamplerModuleInfo + + + false + + + None + + Get + SamplerModuleInfo + + + + + + Get-SamplerModuleInfo + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerModuleRootPath + + + Get-SamplerModuleRootPath + + + false + + + None + + Get + SamplerModuleRootPath + + + + + + Get-SamplerModuleRootPath + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerProjectName + + + Get-SamplerProjectName + + + false + + + None + + Get + SamplerProjectName + + + + + + Get-SamplerProjectName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerSourcePath + + + Get-SamplerSourcePath + + + false + + + None + + Get + SamplerSourcePath + + + + + + Get-SamplerSourcePath + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Invoke-SamplerGit + + + Invoke-SamplerGit + + + false + + + None + + Invoke + SamplerGit + + + + + + Invoke-SamplerGit + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Merge-JaCoCoReport + + + Merge-JaCoCoReport + + + false + + + None + + Merge + JaCoCoReport + + + + + + Merge-JaCoCoReport + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + New-SampleModule + + + New-SampleModule + + + false + + + None + + New + SampleModule + + + + + + New-SampleModule + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + New-SamplerJaCoCoDocument + + + New-SamplerJaCoCoDocument + + + false + + + None + + New + SamplerJaCoCoDocument + + + + + + New-SamplerJaCoCoDocument + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + New-SamplerPipeline + + + New-SamplerPipeline + + + false + + + None + + New + SamplerPipeline + + + + + + New-SamplerPipeline + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Out-SamplerXml + + + Out-SamplerXml + + + false + + + None + + Out + SamplerXml + + + + + + Out-SamplerXml + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Set-SamplerPSModulePath + + + Set-SamplerPSModulePath + + + false + + + None + + Set + SamplerPSModulePath + + + + + + Set-SamplerPSModulePath + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Split-ModuleVersion + + + Split-ModuleVersion + + + false + + + None + + Split + ModuleVersion + + + + + + Split-ModuleVersion + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Update-JaCoCoStatistic + + + Update-JaCoCoStatistic + + + false + + + None + + Update + JaCoCoStatistic + + + + + + Update-JaCoCoStatistic + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + + + + + + + + + + + Add-Sample + + + Add-Sample + + + false + + + None + + Add + Sample + + + + + + Add-Sample + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Convert-SamplerHashtableToString + + + Convert-SamplerHashtableToString + + + false + + + None + + Convert + SamplerHashtableToString + + + + + + Convert-SamplerHashtableToString + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-BuiltModuleVersion + + + Get-BuiltModuleVersion + + + false + + + None + + Get + BuiltModuleVersion + + + + + + Get-BuiltModuleVersion + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-ClassBasedResourceName + + + Get-ClassBasedResourceName + + + false + + + None + + Get + ClassBasedResourceName + + + + + + Get-ClassBasedResourceName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-CodeCoverageThreshold + + + Get-CodeCoverageThreshold + + + false + + + None + + Get + CodeCoverageThreshold + + + + + + Get-CodeCoverageThreshold + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-MofSchemaName + + + Get-MofSchemaName + + + false + + + None + + Get + MofSchemaName + + + + + + Get-MofSchemaName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-OperatingSystemShortName + + + Get-OperatingSystemShortName + + + false + + + None + + Get + OperatingSystemShortName + + + + + + Get-OperatingSystemShortName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-PesterOutputFileFileName + + + Get-PesterOutputFileFileName + + + false + + + None + + Get + PesterOutputFileFileName + + + + + + Get-PesterOutputFileFileName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-Psm1SchemaName + + + Get-Psm1SchemaName + + + false + + + None + + Get + Psm1SchemaName + + + + + + Get-Psm1SchemaName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerAbsolutePath + + + Get-SamplerAbsolutePath + + + false + + + None + + Get + SamplerAbsolutePath + + + + + + Get-SamplerAbsolutePath + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerBuildVersion + + + Get-SamplerBuildVersion + + + false + + + None + + Get + SamplerBuildVersion + + + + + + Get-SamplerBuildVersion + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerBuiltModuleBase + + + Get-SamplerBuiltModuleBase + + + false + + + None + + Get + SamplerBuiltModuleBase + + + + + + Get-SamplerBuiltModuleBase + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerBuiltModuleManifest + + + Get-SamplerBuiltModuleManifest + + + false + + + None + + Get + SamplerBuiltModuleManifest + + + + + + Get-SamplerBuiltModuleManifest + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerCodeCoverageOutputFile + + + Get-SamplerCodeCoverageOutputFile + + + false + + + None + + Get + SamplerCodeCoverageOutputFile + + + + + + Get-SamplerCodeCoverageOutputFile + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerCodeCoverageOutputFileEncoding + + + Get-SamplerCodeCoverageOutputFileEncoding + + + false + + + None + + Get + SamplerCodeCoverageOutputFileEncoding + + + + + + Get-SamplerCodeCoverageOutputFileEncoding + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerModuleInfo + + + Get-SamplerModuleInfo + + + false + + + None + + Get + SamplerModuleInfo + + + + + + Get-SamplerModuleInfo + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerModuleRootPath + + + Get-SamplerModuleRootPath + + + false + + + None + + Get + SamplerModuleRootPath + + + + + + Get-SamplerModuleRootPath + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerProjectName + + + Get-SamplerProjectName + + + false + + + None + + Get + SamplerProjectName + + + + + + Get-SamplerProjectName + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Get-SamplerSourcePath + + + Get-SamplerSourcePath + + + false + + + None + + Get + SamplerSourcePath + + + + + + Get-SamplerSourcePath + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Invoke-SamplerGit + + + Invoke-SamplerGit + + + false + + + None + + Invoke + SamplerGit + + + + + + Invoke-SamplerGit + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Merge-JaCoCoReport + + + Merge-JaCoCoReport + + + false + + + None + + Merge + JaCoCoReport + + + + + + Merge-JaCoCoReport + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + New-SampleModule + + + New-SampleModule + + + false + + + None + + New + SampleModule + + + + + + New-SampleModule + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + New-SamplerJaCoCoDocument + + + New-SamplerJaCoCoDocument + + + false + + + None + + New + SamplerJaCoCoDocument + + + + + + New-SamplerJaCoCoDocument + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + New-SamplerPipeline + + + New-SamplerPipeline + + + false + + + None + + New + SamplerPipeline + + + + + + New-SamplerPipeline + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Out-SamplerXml + + + Out-SamplerXml + + + false + + + None + + Out + SamplerXml + + + + + + Out-SamplerXml + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Set-SamplerPSModulePath + + + Set-SamplerPSModulePath + + + false + + + None + + Set + SamplerPSModulePath + + + + + + Set-SamplerPSModulePath + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Split-ModuleVersion + + + Split-ModuleVersion + + + false + + + None + + Split + ModuleVersion + + + + + + Split-ModuleVersion + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + Update-JaCoCoStatistic + + + Update-JaCoCoStatistic + + + false + + + None + + Update + JaCoCoStatistic + + + + + + Update-JaCoCoStatistic + Function + Sampler + 0.118.3 + Public + Sampler + + + Sampler + + PowerShell + + + + + + + + + + + + + Sampler + + + + + + + + + + + + + + + + + + + + + + + + + 5.0 + + + None + 0 + + + + + + + + + + + + + + + System.Management.Automation.PSModuleInfo + System.Object + + Plaster + + false + Plaster + D:\Plaster\Plaster + + + + 00000000-0000-0000-0000-000000000000 + + D:\Plaster + + + + + + + + + + + + + Script + + ReadWrite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sampler.psm1 + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Get-ModuleExtension.Tests.ps1 b/tests/Get-ModuleExtension.Tests.ps1 new file mode 100644 index 0000000..cdc4629 --- /dev/null +++ b/tests/Get-ModuleExtension.Tests.ps1 @@ -0,0 +1,41 @@ +BeforeDiscovery { + if ($null -eq $env:BHProjectPath) { + $path = Join-Path -Path $PSScriptRoot -ChildPath '..\build.ps1' + . $path -Task Build + } + $global:manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest + $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' + $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName + $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion + $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" + Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore + Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop +} +Describe 'Get-PlasterManifestPathForCulture' { + InModuleScope $env:BHProjectName { + BeforeEach { + Mock Get-Module { + Get-Content -Raw $PSScriptRoot\Fixtures\ModuleList.xml | ConvertFrom-CliXml + } + } + + It 'Returns a list of modules' { + $extensions = Get-ModuleExtension -ModuleName "Plaster" -ModuleVersion '2.0.0' -ListAvailable + $extensions | Should -Not -BeNullOrEmpty + $extensions | Should -BeOfType 'PSCustomObject' + $extensions.Count | Should -Be 3 + $extensions[0].Module | Should -Be "PSStucco" + $extensions[1].Module | Should -Be "PSStucco" + $extensions[2].Module | Should -Be "Sampler" + } + + It 'Returns the latest' { + $extensions = Get-ModuleExtension -ModuleName "Plaster" -ModuleVersion '2.0.0' + $extensions | Should -Not -BeNullOrEmpty + $extensions | Should -BeOfType 'PSCustomObject' + $extensions.Count | Should -Be 2 + $extensions[0].Module | Should -Be "PSStucco" + $extensions[1].Module | Should -Be "Sampler" + } + } +} From cca71cb8c7415f837453238016b8e0e675ce5ec6 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Tue, 15 Jul 2025 15:28:05 -0700 Subject: [PATCH 7/7] =?UTF-8?q?test:=20=F0=9F=A7=AA=20Update=20tests=20for?= =?UTF-8?q?=20`Initialize-PredefinedVariables`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refactor test structure for improved readability * Ensure all predefined variables are initialized correctly * Validate that `PLASTER_TemplatePath` and `PLASTER_DestinationPath` match expected values --- .../Initialize-PredefinedVariables.Tests.ps1 | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/tests/Initialize-PredefinedVariables.Tests.ps1 b/tests/Initialize-PredefinedVariables.Tests.ps1 index 79de9cd..34bbb09 100644 --- a/tests/Initialize-PredefinedVariables.Tests.ps1 +++ b/tests/Initialize-PredefinedVariables.Tests.ps1 @@ -1,65 +1,65 @@ BeforeDiscovery { - if ($null -eq $env:BHProjectPath) { - $path = Join-Path -Path $PSScriptRoot -ChildPath '..\build.ps1' - . $path -Task Build - } - $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest - $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' - $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName - $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion - $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" - Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore - Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop + if ($null -eq $env:BHProjectPath) { + $path = Join-Path -Path $PSScriptRoot -ChildPath '..\build.ps1' + . $path -Task Build + } + $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest + $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' + $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName + $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion + $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" + Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore + Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop } Describe 'Initialize-PredefinedVariables' { - InModuleScope $env:BHProjectName { - BeforeDiscovery { - $script:variables = @( - 'PLASTER_TemplatePath', - 'PLASTER_DestinationPath', - 'PLASTER_DestinationName', - 'PLASTER_DirSepChar', - 'PLASTER_HostName', - 'PLASTER_Version', - 'PLASTER_Guid1', - 'PLASTER_Guid2', - 'PLASTER_Guid3', - 'PLASTER_Guid4', - 'PLASTER_Guid5', - 'PLASTER_Date', - 'PLASTER_Time', - 'PLASTER_Year' - ) - foreach ($var in $script:variables) { - if (Get-Variable -Name $var -ErrorAction SilentlyContinue) { - Remove-Variable -Name $var -Scope Script + InModuleScope $env:BHProjectName { + BeforeDiscovery { + $script:variables = @( + 'PLASTER_TemplatePath', + 'PLASTER_DestinationPath', + 'PLASTER_DestinationName', + 'PLASTER_DirSepChar', + 'PLASTER_HostName', + 'PLASTER_Version', + 'PLASTER_Guid1', + 'PLASTER_Guid2', + 'PLASTER_Guid3', + 'PLASTER_Guid4', + 'PLASTER_Guid5', + 'PLASTER_Date', + 'PLASTER_Time', + 'PLASTER_Year' + ) + foreach ($var in $script:variables) { + if (Get-Variable -Name $var -ErrorAction SilentlyContinue) { + Remove-Variable -Name $var -Scope Script + } + } + } + BeforeAll { + $script:examplesPath = Resolve-Path "$env:BHProjectPath/examples/" + $script:destPath = 'Test:\Destination' + $script:output = Initialize-PredefinedVariables -TemplatePath $script:examplesPath -DestPath $script:destPath + } + It 'should not return any output' { + $script:output | Should -BeNullOrEmpty } - } - } - BeforeAll { - $script:examplesPath = Resolve-Path "$env:BHProjectPath/examples/" - $script:destPath = 'Test:\Destination' - $script:output = Initialize-PredefinedVariables -TemplatePath $script:examplesPath -DestPath $script:destPath - } - It 'should not return any output' { - $script:output | Should -BeNullOrEmpty - } - It "initializes predefined variable <_>" -ForEach $script:variables { - $varValue = Get-Variable -name $_ -Scope Script -ErrorAction SilentlyContinue - $varValue | Should -Not -BeNullOrEmpty - } + It "initializes predefined variable <_>" -ForEach $script:variables { + $varValue = Get-Variable -Name $_ -Scope Script -ErrorAction SilentlyContinue + $varValue | Should -Not -BeNullOrEmpty + } - It 'PLASTER_TemplatePath should match the provided template path' { - $expectedPath = $script:examplesPath.TrimEnd('\', '/') - $actualPath = (Get-Variable -Name 'PLASTER_TemplatePath' -Scope Script).Value - $actualPath | Should -Be $expectedPath - } + It 'PLASTER_TemplatePath should match the provided template path' { + $expectedPath = ($script:examplesPath).ToString().TrimEnd('\', '/') + $actualPath = (Get-Variable -Name 'PLASTER_TemplatePath' -Scope Script).Value + $actualPath | Should -Be $expectedPath + } - It 'PLASTER_DestinationPath should match the provided destination path' { - $expectedPath = $script:destPath.TrimEnd('\', '/') - $actualPath = (Get-Variable -Name 'PLASTER_DestinationPath' -Scope Script).Value - $actualPath | Should -Be $expectedPath + It 'PLASTER_DestinationPath should match the provided destination path' { + $expectedPath = ($script:destPath).ToString().TrimEnd('\', '/') + $actualPath = (Get-Variable -Name 'PLASTER_DestinationPath' -Scope Script).Value + $actualPath | Should -Be $expectedPath + } } - } }