Skip to content

Commit aa1732b

Browse files
committed
Initial commit
1 parent c59399a commit aa1732b

8 files changed

Lines changed: 74 additions & 19 deletions
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
function New-DocumentationScripts {
22
param(
3-
[string]$Name,
4-
[string]$BasePath
3+
[string]$BasePath,
4+
[string]$Name
55
)
66

77
$content = @'
88
Import-Module PlatyPS
99
10-
Update-MarkdownHelp -Module "__MODULE_PATH__" -OutputFolder "__DOCS_PATH__" -Force
10+
Update-MarkdownHelp -Module "$PSScriptRoot\..\__MODULE_NAME__.psd1" -OutputFolder "$PSScriptRoot\Docs" -Force
1111
'@
1212

13-
$content = $content.Replace('__MODULE_PATH__', "$BasePath\$Name.psd1")
14-
$content = $content.Replace('__DOCS_PATH__', "$BasePath\Docs")
13+
$content = $content.Replace('__MODULE_NAME__', "$Name")
14+
# $content = $content.Replace('__DOCS_PATH__', "$BasePath\Docs")
1515

1616
Set-Content -Path "$BasePath\Scripts\Update-ModuleDocumentation.ps1" -Value $content
1717
}

‎Public/New-ModuleChangelog.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ function New-ModuleChangelog {
44
[Parameter(Mandatory)]
55
[string]$Path,
66

7-
[Parameter(Mandatory)]
8-
[string]$Version,
7+
[Parameter()]
8+
[string]$Version = "1.0.0",
99

1010
[Parameter()]
1111
[string]$Notes = "Initial release."

‎Public/New-ModuleFolders.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function New-ModuleFolders {
1313
New-Item -ItemType Directory -Path $base -Force | Out-Null
1414

1515
# Standard module folder structure
16-
foreach ($folder in 'Public', 'Private', 'Tests', 'Docs', 'Analyzer') {
16+
foreach ($folder in 'Public', 'Private', 'Tests', 'Docs', 'Analyzer', 'Scripts') {
1717
New-Item -ItemType Directory -Path (Join-Path $base $folder) -Force | Out-Null
1818
}
1919

‎Public/New-ModuleManifestFile.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function New-ModuleManifestFile {
1212
-Author $env:USERNAME `
1313
-Description "$Name module" `
1414
-Guid $guid `
15-
-FunctionsToExport @('ExampleFunction') `
15+
-FunctionsToExport @() `
1616
-AliasesToExport @() `
1717
-CompatiblePSEditions @('Core', 'Desktop') `
1818
-PowerShellVersion '5.1' `

‎Public/New-ModulePsm1.ps1‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
function New-ModulePsm1 {
2+
[CmdletBinding()]
3+
param(
4+
[Parameter(Mandatory)]
5+
[string]$Name,
6+
7+
[Parameter(Mandatory)]
8+
[string]$BasePath
9+
)
10+
11+
$psm1Path = Join-Path $BasePath "$Name.psm1"
12+
13+
$content = @'
14+
# Auto-generated module file for {0}
15+
16+
Set-StrictMode -Version Latest
17+
18+
# Import public functions
19+
Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1" | ForEach-Object {
20+
. $_.FullName
21+
}
22+
23+
# Import private functions
24+
Get-ChildItem -Path "$PSScriptRoot\Private\*.ps1" | ForEach-Object {
25+
. $_.FullName
26+
}
27+
28+
# Export only public functions
29+
$publicFunctions = Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1" |
30+
ForEach-Object {
31+
$match = Select-String -Path $_.FullName -Pattern '^function\s+([^\s{]+)'
32+
if ($match) { $match.Matches.Groups[1].Value }
33+
}
34+
35+
Export-ModuleMember -Function $publicFunctions
36+
'@ -f $Name
37+
38+
Set-Content -Path $psm1Path -Value $content -Encoding UTF8
39+
40+
return $psm1Path
41+
}

‎Public/New-ModuleTemplate.ps1‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ function New-ModuleTemplate {
5353
$base = New-ModuleFolders -Name $Name -Path $Path
5454

5555
# Generate module components
56-
New-ModuleManifestFile -Name $Name -BasePath $base
57-
New-PesterTests -Name $Name -BasePath $base
56+
New-ModuleManifestFile -BasePath $base -Name $Name
57+
New-ModulePsm1 -BasePath $base -Name $Name
58+
New-PesterTests -BasePath $base -Name $Name
5859
New-AnalyzerSettings -BasePath $base
59-
New-DocumentationScripts -Name $Name -BasePath $base
60-
New-BuildScript -BasePath $base -Name $Name
61-
New-PublishScript -BasePath $base -Name $Name
62-
New-ModuleReadme -BasePath $base -ModuleName $Name
60+
New-ModuleChangelog -BasePath $base
61+
New-DocumentationScripts -BasePath $base -Name $Name
62+
New-BuildScript -BasePath $base -Name $Name
63+
New-PublishScript -BasePath $base -Name $Name
64+
New-ModuleReadme -BasePath $base -Name $Name
6365

6466
if ($InitGit) {
6567
Initialize-GitRepository -BasePath $base

‎Public/New-PesterTests.ps1‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ function New-PesterTests {
55
)
66

77
$test = @'
8-
BeforeAll {
9-
Import-Module "$PSScriptRoot/../__MODULE__.psd1" -Force
10-
}
11-
128
Describe "__MODULE__ Module" {
139
10+
BeforeAll {
11+
Import-Module "$PSScriptRoot/../__MODULE__.psd1" -Force
12+
}
13+
1414
It "Loads without error" {
1515
{ Import-Module "__MODULE__" -Force } | Should -Not -Throw
1616
}

‎Tests/New-ModulePsm1.Tests.ps1‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Describe "New-ModulePsm1" {
2+
3+
It "Creates a .psm1 file" {
4+
$temp = Join-Path $env:TEMP ([guid]::NewGuid().ToString())
5+
New-Item -ItemType Directory -Path $temp | Out-Null
6+
7+
$base = New-ModuleFolders -Name "TestModule" -Path $temp
8+
$result = New-ModulePsm1 -Name "TestModule" -BasePath $base
9+
10+
Test-Path $result | Should Be $true
11+
}
12+
}

0 commit comments

Comments
 (0)