Skip to content

Commit 5a469ad

Browse files
Merge pull request #119 from PowershellFrameworkCollective/development
2.2.7.98
2 parents eadd5ea + 81f8c4e commit 5a469ad

36 files changed

+585
-528
lines changed

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
FriedrichWeinmann
5+
patreon: # Replace with a single Patreon username
6+
open_collective: # Replace with a single Open Collective username
7+
ko_fi: # Replace with a single Ko-fi username
8+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
9+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
10+
liberapay: # Replace with a single Liberapay username
11+
issuehunt: # Replace with a single IssueHunt username
12+
otechie: # Replace with a single Otechie username
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

PSModuleDevelopment/PSModuleDevelopment.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RootModule = 'PSModuleDevelopment.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '2.2.7.90'
7+
ModuleVersion = '2.2.7.98'
88

99
# ID used to uniquely identify this module
1010
GUID = '37dd5fce-e7b5-4d57-ac37-832055ce49d6'

PSModuleDevelopment/changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
# Changelog
2+
## 2.2.7.98 (May 30th, 2020)
3+
4+
- Upd: Template PSFTest - Pester v5 compatibility
5+
- Upd: Template PSFModule - Pester v5 compatibility
6+
- Upd: Template PSFProject - Pester v5 compatibility
7+
- Upd: Template PSFProject - Simplified module import workflow
8+
- Upd: Template PSFProject - Improved build process cross-agent convenience
9+
- Upd: Template PSFProject - Prerequisites task automatically detects module dependencies
10+
- Upd: Template PSFProject - Prerequisites task can be configured to work with any registered repository
11+
- Upd: Export-PSMDString - Now also detects splatted localization strings (thanks @StevePlp ; #117)
12+
213
## 2.2.7.90 (September 1st, 2019)
314
- New: Export-PSMDString - Parses strings from modules using the PSFramework localization feature.
415
- Upd: Measure-PSMDCommand - Renamed from Measure-PSMDCommandEx, performance upgrades, adding option for comparing multiple test sets.

PSModuleDevelopment/functions/moduledebug/Get-PSMDModuleDebug.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
1717
Returns the module debugging configuration for all modules with a name that contains "net"
1818
#>
19+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '')]
1920
[CmdletBinding()]
2021
Param (
2122
[string]

PSModuleDevelopment/functions/moduledebug/Import-PSMDModuleDebug.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
{
2626
# Get original module configuration
2727
$____module = $null
28-
$____module = Import-Clixml -Path (Get-PSFConfigValue -FullName 'PSModuleDevelopment.Debug.ConfigPath') | Where-Object { $_.Name -eq $Name }
28+
$____module = Import-Clixml -Path (Get-PSFConfigValue -FullName 'PSModuleDevelopment.Debug.ConfigPath') | Where-Object Name -eq $Name
2929
if (-not $____module) { throw "No matching module configuration found" }
3030

3131
# Process entry

PSModuleDevelopment/functions/refactor/Export-PSMDString.ps1

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,67 @@
7272
StringValues = $stringValueParamValue
7373
}
7474
}
75-
75+
76+
# Additional checks for splatted commands
77+
# find all splatted commands
78+
$splattedVariables = $ast.FindAll( {
79+
if ($args[0] -isnot [System.Management.Automation.Language.VariableExpressionAst ]) { return $false }
80+
if (-not ($args[0].Splatted -eq $true)) { return $false }
81+
$true
82+
}, $true)
83+
84+
foreach ($splattedVariable in $splattedVariables)
85+
{
86+
#get the variable name
87+
$splatParamName = $splattedVariable.VariablePath.UserPath
88+
if ($splatParamName)
89+
{
90+
# match the $param = @{
91+
$splatParamNameRegex = "^\s?\`$$($splatParamName)\s?=\s?\@\{"
92+
# get all variable assignments where the
93+
# left side matches our param
94+
# operator is =
95+
# matches our assignment regex
96+
$splatAssignmentAsts = $ast.FindAll( {
97+
if ($args[0] -isnot [System.Management.Automation.Language.AssignmentStatementAst ]) { return $false }
98+
if (-not ($args[0].Left -match $splatParamName)) { return $false }
99+
if (-not ($args[0].Operator -eq 'Equals')) { return $false }
100+
if (-not ($args[0].Extent -match $splatParamNameRegex)) { return $false }
101+
$true
102+
}, $true)
103+
foreach ($splatAssignmentAst in $splatAssignmentAsts)
104+
{
105+
# get the hashtable
106+
$splatHashTable = $splatAssignmentAst.Right.Expression
107+
# see if its an empty assignment or null
108+
if ($splatHashTable -and $splatHashTable.KeyValuePairs.Count -gt 0)
109+
{
110+
# find any String or ActionString
111+
$splatParam = $splatAssignmentAst.Right.Expression.KeyValuePairs | Where-Object Item1 -match '^String$|^ActionString$'
112+
# The kvp.item.extent.text returns nested quotes where as the commandast.extent.text doesn't so strip them off
113+
$splatParamValue = $splatParam.Item2.Extent.Text.Trim('"').Trim("'")
114+
# find any StringValue or ActionStringValue
115+
$splatValueParam = $splatAssignmentAst.Right.Expression.KeyValuePairs | Where-Object Item1 -match '^StringValues$|^ActionStringValues$'
116+
if ($splatValueParam)
117+
{
118+
# The kvp.item.extent.text returns nested quotes whereas the commandast.extent.text doesn't so strip them off
119+
$splatValueParamValue = $splatValueParam.Item2.Extent.Text.Trim('"').Trim("'")
120+
}
121+
else { $splatValueParamValue = '' }
122+
123+
[PSCustomObject]@{
124+
PSTypeName = 'PSModuleDevelopment.String.ParsedItem'
125+
File = $file.FullName
126+
Line = $splatHashTable.Extent.StartLineNumber
127+
CommandName = $splattedVariable.Parent.CommandElements[0].Value
128+
String = $splatParamValue
129+
StringValues = $splatValueParamValue
130+
}
131+
}
132+
}
133+
}
134+
}
135+
76136
$validateAsts = $ast.FindAll({
77137
if ($args[0] -isnot [System.Management.Automation.Language.AttributeAst]) { return $false }
78138
if ($args[0].TypeName -notmatch '^PsfValidateScript$|^PsfValidatePattern$') { return $false }

PSModuleDevelopment/functions/refactor/Format-PSMDParameter.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
3131
Updates all commands in the module to have a cmdletbinding attribute.
3232
#>
33+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '')]
3334
[CmdletBinding(SupportsShouldProcess = $true)]
3435
param (
3536
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
@@ -45,6 +46,7 @@
4546
#region Utility functions
4647
function Invoke-AstWalk
4748
{
49+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '')]
4850
[CmdletBinding()]
4951
param (
5052
$Ast,

PSModuleDevelopment/functions/refactor/Set-PSMDCmdletBinding.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#region Utility functions
4747
function Invoke-AstWalk
4848
{
49+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '')]
4950
[CmdletBinding()]
5051
Param (
5152
$Ast,

PSModuleDevelopment/functions/refactor/Split-PSMDScriptFile.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
foreach ($functionAst in ($ast.EndBlock.Statements | Where-Object { $_.GetType().FullName -eq "System.Management.Automation.Language.FunctionDefinitionAst" }))
4949
{
50-
$ast.Extent.Text.Substring($functionAst.Extent.StartOffset, ($functionAst.Extent.EndOffset - $functionAst.Extent.StartOffset)) | Set-Content "$Path\$($functionAst.Name).ps1" -Encoding UTF8
50+
$ast.Extent.Text.Substring($functionAst.Extent.StartOffset, ($functionAst.Extent.EndOffset - $functionAst.Extent.StartOffset)) | Set-Content "$Path\$($functionAst.Name).ps1" -Encoding $Encoding
5151
}
5252
}
5353
}

PSModuleDevelopment/functions/templating/Invoke-PSMDTemplate.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
Creates a project based on the module template with the name "MyModule"
7979
#>
8080
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSPossibleIncorrectUsageOfAssignmentOperator", "")]
81+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '')]
8182
[CmdletBinding(SupportsShouldProcess = $true)]
8283
param (
8384
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'NameStore')]

0 commit comments

Comments
 (0)