Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/source-pipe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Pipe source checks
on:
push:
branches: [fix/build-pipe]
pull_request:
branches: [Pipe/develop]
permissions:
contents: read
jobs:
source:
uses: stadub/PowershellScripts/.github/workflows/validate-module-source.yml@d3fa5897213e3ff4e0d64897559bdfb516356512
with:
module: Pipe
source_sha: ${{ github.event.pull_request.head.sha || github.sha }}
automation_sha: d3fa5897213e3ff4e0d64897559bdfb516356512
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# File types to ignore globally
.history
.vscode
TestResults/
14 changes: 8 additions & 6 deletions Shared-Functions/Pipe/Aliases.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Set-Alias skip Skip-Items -Scope Global
Set-Alias wtype Where-Type -Scope Global
Set-Alias take Limit-Items -Scope Global
Set-Alias skip Skip-Items
Set-Alias wtype Limit-Type
Set-Alias take Limit-Items

Set-Alias first Limit-First -Scope Global
Set-Alias last Limit-Last -Scope Global
Set-Alias first Limit-First
Set-Alias last Limit-Last

Set-Alias suppress Hide-Out -Scope Global
Set-Alias suppress Hide-Out

Set-Alias filter-type Limit-Type
Set-Alias where-type Limit-Type
42 changes: 42 additions & 0 deletions Shared-Functions/Pipe/Pipe.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
$manifest = Join-Path $PSScriptRoot 'Pipe.psd1'
Describe 'Pipe source imports and aliases' {
BeforeAll {
$script:importOutput = @(Import-Module $manifest -Force -PassThru -WarningAction SilentlyContinue)
}
AfterAll { Remove-Module Pipe -ErrorAction SilentlyContinue }

It 'validates the source manifest and imports without example output' {
(Test-ModuleManifest $manifest).Name | Should -Be 'Pipe'
$script:importOutput.Count | Should -Be 1
$script:importOutput[0] | Should -BeOfType System.Management.Automation.PSModuleInfo
}
It 'exports six filters and eight aliases with valid targets' {
$module = Get-Module Pipe
$module.ExportedFunctions.Count | Should -Be 6
$module.ExportedAliases.Count | Should -Be 8
foreach ($alias in $module.ExportedAliases.Values) {
$module.ExportedFunctions.ContainsKey($alias.Definition) | Should -BeTrue
}
}
It 'filters type through each reconciled alias' -TestCases @(
@{ Name = 'wtype' }, @{ Name = 'filter-type' }, @{ Name = 'where-type' }
) {
param($Name)
@('text', 1, 2 | & $Name -TypeName String).Count | Should -Be 1
'text', 1, 2 | & $Name -TypeName String | Should -BeExactly 'text'
}
It 'supports assignable types and wildcard names' {
@(1, 'text' | Limit-Type -Type ([object]) -Strict $false).Count | Should -Be 2
1, 'text' | Limit-Type -TypeName '*str*' -Strict $false | Should -BeExactly 'text'
}
It 'preserves skip, take, last, and suppression behavior' {
(1..5 | skip -Count 2 | take -Count 2) -join ',' | Should -BeExactly '3,4'
1..5 | last | Should -Be 5
@(1..5 | suppress).Count | Should -Be 0
}
It 'exports aliases through a second clean import' {
Remove-Module Pipe
Import-Module $manifest -Force -WarningAction SilentlyContinue
(Get-Alias wtype).Definition | Should -BeExactly 'Limit-Type'
}
}
10 changes: 5 additions & 5 deletions Shared-Functions/Pipe/Pipe.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
Description = 'Powershell Pipe filtering functions.
Full documentation at the Github: https://github.com/stadub/PowershellScripts/tree/master/Shared-Functions/Pipe
'
NestedModules = @('Limit-First.ps1','Limit-Last.ps1', 'Hide-Out.ps1', 'Limit-Items.ps1', 'Limit-Type.ps1', 'Skip-Items.ps1', 'Aliases.ps1')
RootModule = 'Pipe.psm1'
#RootModule = "Base64String.psm1"

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @('*')
FunctionsToExport = @('Limit-First', 'Limit-Last', 'Hide-Out', 'Limit-Items', 'Limit-Type', 'Skip-Items')

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @('Limit-First', 'Limit-Last', 'Hide-Out', 'Limit-Items', 'Limit-Type', 'Skip-Items')
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = '*'
VariablesToExport = @()

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @('*')
AliasesToExport = @('skip', 'wtype', 'filter-type', 'where-type', 'take', 'first', 'last', 'suppress')

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
Expand Down
6 changes: 6 additions & 0 deletions Shared-Functions/Pipe/Pipe.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Load only the maintained source filters; exclude historical examples and out/.
foreach ($name in @('Limit-First', 'Limit-Last', 'Hide-Out', 'Limit-Items', 'Limit-Type', 'Skip-Items')) {
. (Join-Path $PSScriptRoot "Functions/$name.ps1")
}
. (Join-Path $PSScriptRoot 'Aliases.ps1')
Export-ModuleMember -Function Limit-First, Limit-Last, Hide-Out, Limit-Items, Limit-Type, Skip-Items -Alias skip, wtype, filter-type, where-type, take, first, last, suppress
9 changes: 9 additions & 0 deletions Shared-Functions/Pipe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,12 @@ Import-Module Pipe
### 📬 Suggestions and feedback

If you have any idea or suggestion - please add a github issue.

## Source layout and validation

Import `Pipe.psd1` from the source directory. `Pipe.psm1` loads the six filters
from `Functions/` and exports their aliases. `wtype`, `filter-type`, and
`where-type` all resolve to `Limit-Type`; historical example scripts are not loaded.
Run `Invoke-Pester ./Pipe.Tests.ps1` with Pester 4.10.1 to validate the real source
manifest, imports, exports, aliases, and filtering. Release `out/` packages are
reviewed separately and are unchanged by this source fix.
Loading