Skip to content

Commit 8a1b9d7

Browse files
Merge pull request #93 from PowershellFrameworkCollective/development
2.2.6.62
2 parents abce25d + 9946335 commit 8a1b9d7

File tree

14 files changed

+477
-65
lines changed

14 files changed

+477
-65
lines changed

PSModuleDevelopment/PSModuleDevelopment.psd1

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,74 @@
11
@{
2-
2+
33
# Script module or binary module file associated with this manifest
44
RootModule = 'PSModuleDevelopment.psm1'
5-
5+
66
# Version number of this module.
7-
ModuleVersion = '2.2.6.51'
8-
7+
ModuleVersion = '2.2.6.62'
8+
99
# ID used to uniquely identify this module
1010
GUID = '37dd5fce-e7b5-4d57-ac37-832055ce49d6'
11-
11+
1212
# Author of this module
1313
Author = 'Friedrich Weinmann'
14-
14+
1515
# Company or vendor of this module
1616
CompanyName = 'Infernal Associates ltd.'
17-
17+
1818
# Copyright statement for this module
1919
Copyright = '(c) 2016. All rights reserved.'
20-
20+
2121
# Description of the functionality provided by this module
2222
Description = 'A module designed to speed up the development of PowerShell modules'
23-
23+
2424
# Minimum version of the Windows PowerShell engine required by this module
2525
PowerShellVersion = '3.0'
26-
26+
2727
# Name of the Windows PowerShell host required by this module
2828
PowerShellHostName = ''
29-
29+
3030
# Minimum version of the Windows PowerShell host required by this module
3131
PowerShellHostVersion = ''
32-
32+
3333
# Minimum version of the .NET Framework required by this module
3434
DotNetFrameworkVersion = '2.0'
35-
35+
3636
# Minimum version of the common language runtime (CLR) required by this module
3737
CLRVersion = '2.0.50727'
38-
38+
3939
# Processor architecture (None, X86, Amd64, IA64) required by this module
4040
ProcessorArchitecture = 'None'
41-
41+
4242
# Modules that must be imported into the global environment prior to importing
4343
# this module
4444
RequiredModules = @(
4545
@{ ModuleName = 'PSFramework'; ModuleVersion = '0.10.31.176' }
4646
)
47-
47+
4848
# Assemblies that must be loaded prior to importing this module
4949
RequiredAssemblies = @('bin\PSModuleDevelopment.dll')
50-
50+
5151
# Script files (.ps1) that are run in the caller's environment prior to
5252
# importing this module
5353
ScriptsToProcess = @()
54-
54+
5555
# Type files (.ps1xml) to be loaded when importing this module
5656
TypesToProcess = @('xml\PSModuleDevelopment.Types.ps1xml')
57-
57+
5858
# Format files (.ps1xml) to be loaded when importing this module
5959
FormatsToProcess = @('xml\PSModuleDevelopment.Format.ps1xml')
60-
60+
6161
# Modules to import as nested modules of the module specified in
6262
# ModuleToProcess
6363
NestedModules = @()
64-
64+
6565
# Functions to export from this module
6666
FunctionsToExport = @(
6767
'Expand-PSMDTypeName',
6868
'Find-PSMDFileContent',
6969
'Find-PSMDType',
7070
'Format-PSMDParameter',
71+
'Get-PSMDArgumentCompleter',
7172
'Get-PSMDAssembly',
7273
'Get-PSMDConstructor',
7374
'Get-PSMDHelpEx',
@@ -98,13 +99,13 @@
9899
'Show-PSMDSyntax',
99100
'Split-PSMDScriptFile'
100101
)
101-
102+
102103
# Cmdlets to export from this module
103-
CmdletsToExport = ''
104-
104+
CmdletsToExport = ''
105+
105106
# Variables to export from this module
106107
VariablesToExport = ''
107-
108+
108109
# Aliases to export from this module
109110
AliasesToExport = @(
110111
'dotnetnew',
@@ -117,36 +118,36 @@
117118
'rss',
118119
'smd'
119120
)
120-
121+
121122
# List of all modules packaged with this module
122123
ModuleList = @()
123-
124+
124125
# List of all files packaged with this module
125126
FileList = @()
126-
127+
127128
# Private data to pass to the module specified in ModuleToProcess
128129
PrivateData = @{
129-
130+
130131
#Support for PowerShellGet galleries.
131132
PSData = @{
132-
133+
133134
# Tags applied to this module. These help with module discovery in online galleries.
134135
Tags = @('Development', 'Module')
135-
136+
136137
# A URL to the license for this module.
137138
# LicenseUri = ''
138-
139+
139140
# A URL to the main website for this project.
140141
ProjectUri = 'http://psframework.org'
141-
142+
142143
# A URL to an icon representing this module.
143144
# IconUri = ''
144-
145+
145146
# ReleaseNotes of this module
146147
# ReleaseNotes = ''
147-
148+
148149
} # End of PSData hashtable
149-
150+
150151
} # End of PrivateData hashtable
151152
}
152153

PSModuleDevelopment/PSModuleDevelopment.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$script:PSModuleRoot = $PSScriptRoot
2-
$script:PSModuleVersion = "2.2.6.51"
2+
$script:PSModuleVersion = (Import-PowerShellDataFile -Path "$($script:PSModuleRoot)\PSModuleDevelopment.psd1").ModuleVersion
33

44
$script:doDotSource = $false
55
if (Get-PSFConfigValue -FullName PSModuleDevelopment.Import.DoDotSource) { $script:doDotSource = $true }

PSModuleDevelopment/changelog.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
# Changelog
2+
##
3+
- New: Get-PSMDArgumentCompleter - Lists registered argument completers on PS5+
4+
- New: Template: PSFLoggingProvider - Creates a custom logfile logging provider for module specific logging.
5+
- Upd: Template: PSFTest - Adding test against module tags with whitespace
6+
- Upd: Get-PSMDConstructor - Added `-NonPublic` parameter to show hidden constructors.
7+
- Upd: Template: PSFModule - Improved import speed.
8+
- Upd: Template: PSFProject - Add parameter `-LocalRepo`
9+
- Upd: Template: PSFProject - Add parameter `-AutoVersion`
10+
- Fix: New-PSMDModuleNugetPackage - Resolving input path.
11+
- Fix: New-PSMDModuleNugetPackage - Reregistering temp export repository if accidentally not cleaned up.
12+
- Fix: Template: PSFModule - Fixed format xml closing tag
13+
- Fix: Template: PSFModule - Fixed import from network share.
14+
215
## 2.2.6.51 (January 29th, 2019)
316
- New: Format-PSMDParameter - updates legacy parameter notation
417
- New: Measure-PSMDLinesOfCode - Measures the lines of code in a scriptfile.

PSModuleDevelopment/functions/assembly/Get-PSMDConstructor.ps1

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
1616
.PARAMETER InputObject
1717
The object the constructor of which should be retrieved.
18+
19+
.PARAMETER NonPublic
20+
Show non-public constructors instead.
1821
1922
.EXAMPLE
2023
Get-ChildItem | Get-PSMDConstructor
@@ -30,7 +33,10 @@
3033
[CmdletBinding()]
3134
Param (
3235
[Parameter(ValueFromPipeline = $true)]
33-
$InputObject
36+
$InputObject,
37+
38+
[switch]
39+
$NonPublic
3440
)
3541

3642
begin
@@ -47,16 +53,22 @@
4753

4854
if ($processedTypes -contains $type) { continue }
4955

50-
foreach ($constructor in $type.GetConstructors())
56+
if ($NonPublic)
57+
{
58+
foreach ($constructor in $type.GetConstructors([System.Reflection.BindingFlags]'NonPublic, Instance'))
59+
{
60+
New-Object PSModuleDevelopment.PsmdAssembly.Constructor($constructor)
61+
}
62+
}
63+
else
5164
{
52-
New-Object PSModuleDevelopment.PsmdAssembly.Constructor($constructor)
65+
foreach ($constructor in $type.GetConstructors())
66+
{
67+
New-Object PSModuleDevelopment.PsmdAssembly.Constructor($constructor)
68+
}
5369
}
5470

5571
$processedTypes += $type
5672
}
5773
}
58-
end
59-
{
60-
61-
}
6274
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
function Get-PSMDArgumentCompleter
2+
{
3+
<#
4+
.SYNOPSIS
5+
Gets the registered argument completers.
6+
7+
.DESCRIPTION
8+
This function can be used to serach the argument completers registered using either the Register-ArgumentCompleter command or created using the ArgumentCompleter attribute.
9+
10+
.PARAMETER CommandName
11+
Filter the results to a specific command. Wildcards are supported.
12+
13+
.PARAMETER ParameterName
14+
Filter results to a specific parameter name. Wildcards are supported.
15+
16+
.EXAMPLE
17+
PS C:\> Get-PSMDArgumentCompleter
18+
19+
Get all argument completers in use in the current PowerShell session.
20+
21+
#>
22+
[CmdletBinding()]
23+
Param (
24+
[Parameter(Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)]
25+
[Alias('Name')]
26+
[String]
27+
$CommandName = '*',
28+
29+
[String]
30+
$ParameterName = '*'
31+
)
32+
33+
begin
34+
{
35+
$internalExecutionContext = [PSFramework.Utility.UtilityHost]::GetExecutionContextFromTLS()
36+
$customArgumentCompletersProperty = $internalExecutionContext.GetType().GetProperty(
37+
'CustomArgumentCompleters',
38+
[System.Reflection.BindingFlags]'NonPublic, Instance'
39+
)
40+
$customArgumentCompleters = $customArgumentCompletersProperty.GetGetMethod($true).Invoke(
41+
$internalExecutionContext,
42+
[System.Reflection.BindingFlags]'Instance, NonPublic, GetProperty',
43+
$null,
44+
@(),
45+
$psculture
46+
)
47+
}
48+
process
49+
{
50+
foreach ($argumentCompleter in $customArgumentCompleters.Keys)
51+
{
52+
$name, $parameter = $argumentCompleter -split ':'
53+
54+
if ($name -like $CommandName)
55+
{
56+
if ($parameter -like $ParameterName)
57+
{
58+
New-Object PSObject -Property @{
59+
CommandName = $name
60+
ParameterName = $parameter
61+
Definition = $customArgumentCompleters[$argumentCompleter]
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}

PSModuleDevelopment/functions/utility/New-PSMDModuleNugetPackage.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,20 @@
8181
return
8282
}
8383
}
84+
$resolvedPath = (Get-Item -Path $PackagePath).FullName
8485
#endregion Input validation and prerequisites check
8586

8687
#region Prepare local Repository
8788
try
8889
{
90+
if (Get-PSRepository | Where-Object Name -EQ 'PSModuleDevelopment_TempLocalRepository')
91+
{
92+
Unregister-PSRepository -Name 'PSModuleDevelopment_TempLocalRepository'
93+
}
8994
$paramRegisterPSRepository = @{
9095
Name = 'PSModuleDevelopment_TempLocalRepository'
91-
PublishLocation = $PackagePath
92-
SourceLocation = $PackagePath
96+
PublishLocation = $resolvedPath
97+
SourceLocation = $resolvedPath
9398
InstallationPolicy = 'Trusted'
9499
ErrorAction = 'Stop'
95100
}
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
1-
Describe "Validating the module manifest" {
1+
Describe "Validating the module manifest" {
22
$moduleRoot = (Resolve-Path "$PSScriptRoot\..\..").Path
33
$manifest = ((Get-Content "$moduleRoot\PSModuleDevelopment.psd1") -join "`n") | Invoke-Expression
4-
[version]$moduleVersion = Get-Item "$moduleRoot\PSModuleDevelopment.psm1" | Select-String -Pattern '\$script:PSModuleVersion = "(.*?)"' | ForEach-Object { $_.Matches[0].Groups[1].Value }
54
Context "Basic resources validation" {
65
It "Exports all functions in the public folder" {
76
$files = Get-ChildItem "$moduleRoot\functions" -Recurse -File -Filter "*.ps1"
87
$count = (Compare-Object -ReferenceObject $files.BaseName -DifferenceObject $manifest.FunctionsToExport).Count
98
$count | Should be 0
109
}
11-
10+
1211
It "Exports none of its internal functions" {
1312
$files = Get-ChildItem "$moduleRoot\internal\functions" -Recurse -File -Filter "*.ps1"
1413
$files | Where-Object BaseName -In $manifest.FunctionsToExport | Should Be $null
1514
}
16-
17-
It "Has the same version as the psm1 file" {
18-
([version]$manifest.ModuleVersion) | Should Be $moduleVersion
19-
}
2015
}
21-
16+
2217
Context "Individual file validation" {
2318
It "The root module file exists" {
2419
Test-Path "$moduleRoot\$($manifest.RootModule)" | Should Be $true
2520
}
26-
21+
2722
foreach ($format in $manifest.FormatsToProcess)
2823
{
2924
It "The file $format should exist" {
3025
Test-Path "$moduleRoot\$format" | Should Be $true
3126
}
3227
}
33-
28+
3429
foreach ($type in $manifest.TypesToProcess)
3530
{
3631
It "The file $type should exist" {
3732
Test-Path "$moduleRoot\$type" | Should Be $true
3833
}
3934
}
40-
35+
4136
foreach ($assembly in $manifest.RequiredAssemblies)
4237
{
4338
It "The file $assembly should exist" {
4439
Test-Path "$moduleRoot\$assembly" | Should Be $true
4540
}
4641
}
42+
43+
foreach ($tag in $manifest.PrivateData.PSData.Tags) {
44+
It "Tags should have no spaces in name" {
45+
$tag -match " " | Should -Be $false
46+
}
47+
}
4748
}
48-
}
49+
}

0 commit comments

Comments
 (0)