Skip to content

Commit 7573edb

Browse files
committed
New-ModuleFolders now respects switches. Added Changelog
Corrected `-and` operator parsing issue in New-ModuleTemplate
1 parent c0cd906 commit 7573edb

8 files changed

Lines changed: 245 additions & 22 deletions

‎CHANGELOG.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.1.0] - 2026-08-01
9+
10+
### Added
11+
12+
- New-ModuleFolders now respects -NoTests, -NoDocs, -NoAnalyzer, and -NoScripts switches.
13+
- Added comprehensive Pester tests for New-ModuleTemplate and New-ModuleFolders switch behavior.
14+
- Added .gitattributes generation to normalize line endings and silence Git CRLF/LF warnings.
15+
16+
### Changed
17+
18+
- Updated Initialize-GitRepository to apply normalization using `git add --renormalize .`.
19+
- Improved orchestrator logic for consistent folder creation across all scaffolding switches.
20+
21+
### Fixed
22+
23+
- Corrected `-and` operator parsing issue in New-ModuleTemplate.
24+
25+
## [1.0.0] - 2026-08-01
26+
27+
### Added
28+
29+
- Initial release.

‎Docs/New-ModuleFolders.md‎

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Creates the folder structure for a new PowerShell module.
1313
## SYNTAX
1414

1515
```
16-
New-ModuleFolders [-Path] <String> [-Name] <String> [-Minimal] [-ProgressAction <ActionPreference>]
17-
[<CommonParameters>]
16+
New-ModuleFolders [-Path] <String> [-Name] <String> [-Minimal] [-NoTests] [-NoDocs] [-NoAnalyzer] [-NoScripts]
17+
[-ProgressAction <ActionPreference>] [<CommonParameters>]
1818
```
1919

2020
## DESCRIPTION
@@ -89,6 +89,66 @@ Accept pipeline input: False
8989
Accept wildcard characters: False
9090
```
9191
92+
### -NoTests
93+
{{ Fill NoTests Description }}
94+
95+
```yaml
96+
Type: SwitchParameter
97+
Parameter Sets: (All)
98+
Aliases:
99+
100+
Required: False
101+
Position: Named
102+
Default value: False
103+
Accept pipeline input: False
104+
Accept wildcard characters: False
105+
```
106+
107+
### -NoDocs
108+
{{ Fill NoDocs Description }}
109+
110+
```yaml
111+
Type: SwitchParameter
112+
Parameter Sets: (All)
113+
Aliases:
114+
115+
Required: False
116+
Position: Named
117+
Default value: False
118+
Accept pipeline input: False
119+
Accept wildcard characters: False
120+
```
121+
122+
### -NoAnalyzer
123+
{{ Fill NoAnalyzer Description }}
124+
125+
```yaml
126+
Type: SwitchParameter
127+
Parameter Sets: (All)
128+
Aliases:
129+
130+
Required: False
131+
Position: Named
132+
Default value: False
133+
Accept pipeline input: False
134+
Accept wildcard characters: False
135+
```
136+
137+
### -NoScripts
138+
{{ Fill NoScripts Description }}
139+
140+
```yaml
141+
Type: SwitchParameter
142+
Parameter Sets: (All)
143+
Aliases:
144+
145+
Required: False
146+
Position: Named
147+
Default value: False
148+
Accept pipeline input: False
149+
Accept wildcard characters: False
150+
```
151+
92152
### -ProgressAction
93153
{{ Fill ProgressAction Description }}
94154

‎NewModuleTemplate.psd1‎

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

55
@{
66
RootModule = 'NewModuleTemplate.psm1'
7-
ModuleVersion = '1.0.0'
7+
ModuleVersion = '1.1.0'
88
GUID = 'cd7818d1-6b04-4bb5-a644-3a28e7d6db77'
99
Author = 'Kael Sterling'
1010
CompanyName = 'Untapped Technologies'

‎Public/New-ModuleFolders.ps1‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,44 @@ function New-ModuleFolders {
4242
[Parameter(Mandatory)]
4343
[string]$Name,
4444

45-
[switch]$Minimal
45+
[switch]$Minimal,
46+
[switch]$NoTests,
47+
[switch]$NoDocs,
48+
[switch]$NoAnalyzer,
49+
[switch]$NoScripts
4650
)
4751

48-
# Build the module root path: <Path>\<Name>
4952
$moduleRoot = Join-Path $Path $Name
5053

51-
# Create the root folder
54+
# Create root
5255
New-Item -ItemType Directory -Path $moduleRoot -Force | Out-Null
5356

5457
# Always create core folders
5558
foreach ($folder in 'Public', 'Private') {
5659
New-Item -ItemType Directory -Path (Join-Path $moduleRoot $folder) -Force | Out-Null
5760
}
5861

59-
# Create full scaffolding folders only when not minimal
62+
# Full scaffolding only when not minimal
6063
if (-not $Minimal) {
61-
foreach ($folder in 'Tests', 'Docs', 'Analyzer', 'Scripts') {
62-
New-Item -ItemType Directory -Path (Join-Path $moduleRoot $folder) -Force | Out-Null
64+
65+
if (-not $NoTests) {
66+
New-Item -ItemType Directory -Path (Join-Path $moduleRoot 'Tests') -Force | Out-Null
67+
}
68+
69+
if (-not $NoDocs) {
70+
New-Item -ItemType Directory -Path (Join-Path $moduleRoot 'Docs') -Force | Out-Null
71+
}
72+
73+
if (-not $NoAnalyzer) {
74+
New-Item -ItemType Directory -Path (Join-Path $moduleRoot 'Analyzer') -Force | Out-Null
75+
}
76+
77+
if (-not $NoScripts) {
78+
New-Item -ItemType Directory -Path (Join-Path $moduleRoot 'Scripts') -Force | Out-Null
6379
}
6480
}
6581

6682
return $moduleRoot
6783
}
6884

85+

‎Public/New-ModuleTemplate.ps1‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,15 @@ function New-ModuleTemplate {
9191
}
9292

9393
# Create folder structure
94-
$moduleroot = New-ModuleFolders -Path $Path -Name $Name -Minimal:$Minimal
94+
$moduleroot = New-ModuleFolders `
95+
-Path $Path `
96+
-Name $Name `
97+
-Minimal:$Minimal `
98+
-NoTests:$NoTests `
99+
-NoDocs:$NoDocs `
100+
-NoAnalyzer:$NoAnalyzer `
101+
-NoScripts:$NoScripts
102+
95103

96104
# Always generate core module components
97105
New-ModuleManifestFile -ModulePath $moduleroot -Name $Name

‎Tests/Initialize-GitRepository.Tests.ps1‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,26 @@ Describe "Initialize-GitRepository" {
2121
Set-Variable -Name TempRoot -Value $root -Scope Local
2222
}
2323

24-
It "Creates .gitignore and initializes a repo when Git is available" -Skip:(-not $GitAvailable) {
25-
$result = Initialize-GitRepository -ModulePath $TempRoot
24+
It "Creates .gitignore and initializes a repo when Git is available" {
25+
$modulePath = Join-Path $TempRoot "GitModule"
26+
New-Item -ItemType Directory -Path $modulePath | Out-Null
2627

27-
$gitignorePath = Join-Path $TempRoot ".gitignore"
28+
$result = Initialize-GitRepository -ModulePath $modulePath
2829

29-
# .gitignore exists
30-
Test-Path $gitignorePath | Should -Be $true
30+
# .gitignore was created
31+
Test-Path (Join-Path $modulePath ".gitignore") | Should -Be $true
3132

32-
# Function returns correct path
33-
$result | Should -Be $gitignorePath
33+
# .gitattributes was created
34+
Test-Path (Join-Path $modulePath ".gitattributes") | Should -Be $true
3435

35-
# .git folder exists
36-
Test-Path (Join-Path $TempRoot ".git") | Should -Be $true
36+
# Git repo initialized
37+
Test-Path (Join-Path $modulePath ".git") | Should -Be $true
3738

38-
# Initial commit exists
39-
$log = git -C $TempRoot log --oneline
40-
$log | Should -Not -BeNullOrEmpty
39+
# The function returned the .gitignore path
40+
$result | Should -Be (Join-Path $modulePath ".gitignore")
4141
}
4242

43+
4344
It "Does not create a repo when Git is NOT available" -Skip:$GitAvailable {
4445
$result = Initialize-GitRepository -ModulePath $TempRoot
4546

‎Tests/New-ModuleFolders.Tests.ps1‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ Describe "New-ModuleFolders" {
6666
Test-Path "$modulePath\Private" | Should -Be $true
6767
}
6868

69+
It "Respects NoTests, NoDocs, NoAnalyzer, and NoScripts switches" {
70+
$modulePath = New-ModuleFolders `
71+
-Path $TempRoot `
72+
-Name "SwitchModule" `
73+
-NoTests `
74+
-NoDocs `
75+
-NoAnalyzer `
76+
-NoScripts
77+
78+
Test-Path "$modulePath\Tests" | Should -Be $false
79+
Test-Path "$modulePath\Docs" | Should -Be $false
80+
Test-Path "$modulePath\Analyzer" | Should -Be $false
81+
Test-Path "$modulePath\Scripts" | Should -Be $false
82+
83+
# Core folders still exist
84+
Test-Path "$modulePath\Public" | Should -Be $true
85+
Test-Path "$modulePath\Private" | Should -Be $true
86+
}
87+
6988
It "Returns the correct module root path" {
7089
$modulePath = New-ModuleFolders -Path $TempRoot -Name "TestModule"
7190

‎Tests/New-ModuleTemplate.Tests.ps1‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Requires -Module Pester
2+
Describe "New-ModuleTemplate" {
3+
4+
BeforeEach {
5+
$root = Join-Path $env:TEMP ([guid]::NewGuid().ToString())
6+
New-Item -ItemType Directory -Path $root | Out-Null
7+
Set-Variable -Name TempRoot -Value $root -Scope Local
8+
}
9+
10+
It "Creates the core module scaffold" {
11+
$modulePath = Join-Path $TempRoot "TestModule"
12+
New-ModuleTemplate -Path $TempRoot -Name "TestModule" -NoGit
13+
14+
Test-Path $modulePath | Should -Be $true
15+
Test-Path (Join-Path $modulePath "TestModule.psd1") | Should -Be $true
16+
Test-Path (Join-Path $modulePath "TestModule.psm1") | Should -Be $true
17+
Test-Path (Join-Path $modulePath "README.md") | Should -Be $true
18+
Test-Path (Join-Path $modulePath "CHANGELOG.md") | Should -Be $true
19+
Test-Path (Join-Path $modulePath "Public") | Should -Be $true
20+
Test-Path (Join-Path $modulePath "Private") | Should -Be $true
21+
}
22+
23+
It "Throws when module exists and -Force is not used" {
24+
$modulePath = Join-Path $TempRoot "TestModule"
25+
New-Item -ItemType Directory -Path $modulePath | Out-Null
26+
27+
{
28+
New-ModuleTemplate -Path $TempRoot -Name "TestModule"
29+
} | Should -Throw
30+
}
31+
32+
It "Overwrites existing module when -Force is used" {
33+
$modulePath = Join-Path $TempRoot "TestModule"
34+
New-Item -ItemType Directory -Path $modulePath | Out-Null
35+
36+
{
37+
New-ModuleTemplate -Path $TempRoot -Name "TestModule" -Force -NoGit
38+
} | Should -Not -Throw
39+
40+
Test-Path (Join-Path $modulePath "TestModule.psd1") | Should -Be $true
41+
}
42+
43+
It "Creates a minimal scaffold when -Minimal is used" {
44+
$modulePath = Join-Path $TempRoot "MiniModule"
45+
New-ModuleTemplate -Path $TempRoot -Name "MiniModule" -Minimal -NoGit
46+
47+
# Core files exist
48+
Test-Path (Join-Path $modulePath "MiniModule.psd1") | Should -Be $true
49+
Test-Path (Join-Path $modulePath "MiniModule.psm1") | Should -Be $true
50+
Test-Path (Join-Path $modulePath "README.md") | Should -Be $true
51+
Test-Path (Join-Path $modulePath "CHANGELOG.md") | Should -Be $true
52+
53+
# Optional components do NOT exist
54+
Test-Path (Join-Path $modulePath "Tests") | Should -Be $false
55+
Test-Path (Join-Path $modulePath "Analyzer") | Should -Be $false
56+
Test-Path (Join-Path $modulePath "Docs") | Should -Be $false
57+
Test-Path (Join-Path $modulePath "Scripts") | Should -Be $false
58+
}
59+
60+
It "Respects NoTests, NoDocs, NoAnalyzer, and NoScripts switches" {
61+
$modulePath = Join-Path $TempRoot "SwitchModule"
62+
63+
New-ModuleTemplate -Path $TempRoot -Name "SwitchModule" `
64+
-NoTests -NoDocs -NoAnalyzer -NoScripts -NoGit
65+
66+
Test-Path (Join-Path $modulePath "Tests") | Should -Be $false
67+
Test-Path (Join-Path $modulePath "Docs") | Should -Be $false
68+
Test-Path (Join-Path $modulePath "Analyzer") | Should -Be $false
69+
Test-Path (Join-Path $modulePath "Scripts") | Should -Be $false
70+
}
71+
72+
It "Initializes Git when not disabled" {
73+
$modulePath = Join-Path $TempRoot "GitModule"
74+
75+
New-ModuleTemplate -Path $TempRoot -Name "GitModule"
76+
77+
Test-Path (Join-Path $modulePath ".git") | Should -Be $true
78+
Test-Path (Join-Path $modulePath ".gitignore") | Should -Be $true
79+
Test-Path (Join-Path $modulePath ".gitattributes") | Should -Be $true
80+
}
81+
82+
It "Skips Git initialization when -NoGit is used" {
83+
$modulePath = Join-Path $TempRoot "NoGitModule"
84+
85+
New-ModuleTemplate -Path $TempRoot -Name "NoGitModule" -NoGit
86+
87+
Test-Path (Join-Path $modulePath ".git") | Should -Be $false
88+
}
89+
}

0 commit comments

Comments
 (0)