Skip to content

Commit e95df92

Browse files
Merge branch 'feature/modulebuilderadds'
2 parents c305281 + c7c9f11 commit e95df92

6 files changed

Lines changed: 34 additions & 17 deletions

File tree

.github/workflows/bootstrap.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ jobs:
109109
}
110110
[void] (New-ModuleManifest @Params)
111111
112+
- name: Rename prefix file to match module name
113+
run: |
114+
MODULE_NAME=${{ github.event.repository.name }}
115+
git mv src/PSScriptModule.prefix.ps1 "src/$MODULE_NAME.prefix.ps1"
116+
117+
- name: Rename suffix file to match module name
118+
run: |
119+
MODULE_NAME=${{ github.event.repository.name }}
120+
git mv src/PSScriptModule.suffix.ps1 "src/$MODULE_NAME.suffix.ps1"
121+
112122
- name: Update README.md
113123
run: |
114124
OWNER=${{ github.repository_owner }}
@@ -217,4 +227,3 @@ jobs:
217227
}
218228
}
219229
}
220-

PSScriptModule.build.ps1

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ param (
2323
)
2424

2525
# Synopsis: Default task
26-
task . Clean, Build
26+
Task . Clean, Build
2727

2828
# Setup build environment
2929
Enter-Build {
@@ -36,7 +36,7 @@ Enter-Build {
3636
}
3737

3838
# Synopsis: Analyze the project with PSScriptAnalyzer
39-
task PSScriptAnalyzer {
39+
Task PSScriptAnalyzer {
4040
if (-not (Test-Path $testOutputPath)) {
4141
[void] (New-Item -Path $testOutputPath -ItemType Directory)
4242
}
@@ -57,7 +57,7 @@ task PSScriptAnalyzer {
5757
}
5858

5959
# Synopsis: Scan the project with Injection Hunter
60-
task InjectionHunter {
60+
Task InjectionHunter {
6161

6262
$config = New-PesterConfiguration @{
6363
Run = @{
@@ -75,7 +75,7 @@ task InjectionHunter {
7575
}
7676

7777
# Synopsis: Run unit tests and generate code coverage report
78-
task UnitTests {
78+
Task UnitTests {
7979

8080
$container = New-PesterContainer -Path $Script:moduleSourcePath -Data @{ SourcePath = $script:moduleSourcePath }
8181
$config = New-PesterConfiguration @{
@@ -102,7 +102,7 @@ task UnitTests {
102102
}
103103

104104
# Synopsis: Run integration tests on built module
105-
task IntegrationTests {
105+
Task IntegrationTests {
106106
if (-not (Test-Path $testOutputPath)) {
107107
[void] (New-Item -Path $testOutputPath -ItemType Directory)
108108
}
@@ -136,10 +136,10 @@ task IntegrationTests {
136136
}
137137

138138
# Synopsis: Run all tests
139-
task Test UnitTests, PSScriptAnalyzer, InjectionHunter
139+
Task Test UnitTests, PSScriptAnalyzer, InjectionHunter
140140

141141
# Synopsis: Generate module help documentation
142-
task Export-CommandHelp {
142+
Task Export-CommandHelp {
143143

144144
# Import the module being built and PlatyPS module
145145
[void] (Import-Module (Join-Path -Path $buildPath -ChildPath "out/$moduleName/$moduleName.psd1") -Force)
@@ -182,7 +182,7 @@ task Export-CommandHelp {
182182
}
183183

184184
# Synopsis: Build the project
185-
task Build Clean, {
185+
Task Build Clean, {
186186

187187
# Copy src directory to ./build folder
188188
$requestParam = @{
@@ -206,17 +206,19 @@ task Build Clean, {
206206
# Build Powershell module
207207
[void] (Import-Module ModuleBuilder)
208208
$requestParam = @{
209-
Path = (Join-Path -Path $buildPath -ChildPath "src/$moduleName.psd1")
209+
SourcePath = (Join-Path -Path $buildPath -ChildPath "src/$moduleName.psd1")
210210
OutputDirectory = (Join-Path -Path $buildPath -ChildPath "out/$moduleName")
211+
Prefix = if (Test-Path (Join-Path -Path $buildPath -ChildPath "src/$moduleName.prefix.ps1")) { (Join-Path -Path $buildPath -ChildPath "src/$moduleName.prefix.ps1") } else { $null }
212+
Suffix = if (Test-Path (Join-Path -Path $buildPath -ChildPath "src/$moduleName.suffix.ps1")) { (Join-Path -Path $buildPath -ChildPath "src/$moduleName.suffix.ps1") } else { $null }
211213
SemVer = $SemanticVersion
212214
UnversionedOutputDirectory = $true
213-
ErrorAction = 'Stop'
215+
ErrorAction = [System.Management.Automation.ActionPreference]::Stop
214216
}
215217
Build-Module @requestParam
216218
}
217219

218220
# Synopsis: Create a NuGet package for the module
219-
task Package {
221+
Task Package {
220222
$packageOutputPath = Join-Path -Path $buildPath -ChildPath 'package'
221223
if (!(Test-Path $packageOutputPath)) {
222224
[void] (New-Item -Path $packageOutputPath -ItemType Directory -Force)
@@ -227,15 +229,15 @@ task Package {
227229
SourceLocation = $packageOutputPath
228230
PublishLocation = $packageOutputPath
229231
InstallationPolicy = 'Trusted'
230-
ErrorAction = 'Stop'
232+
ErrorAction = [System.Management.Automation.ActionPreference]::Stop
231233
}
232234
[void] (Register-PSRepository @requestParam)
233235

234236
$requestParam = @{
235237
Path = (Join-Path -Path $buildPath -ChildPath "out/$moduleName")
236238
Repository = "$($moduleName)_local_feed"
237239
NuGetApiKey = 'ABC123'
238-
ErrorAction = 'Stop'
240+
ErrorAction = [System.Management.Automation.ActionPreference]::Stop
239241
}
240242
[void] (Publish-Module @requestParam)
241243

@@ -244,17 +246,17 @@ task Package {
244246
}
245247

246248
# Synopsis: Publish the module to PSGallery
247-
task Publish -If ($NugetApiKey) {
249+
Task Publish -If ($NugetApiKey) {
248250
$requestParam = @{
249251
Path = (Join-Path -Path $buildPath -ChildPath "out/$moduleName")
250252
NuGetApiKey = $NugetApiKey
251-
ErrorAction = 'Stop'
253+
ErrorAction = [System.Management.Automation.ActionPreference]::Stop
252254
}
253255
[void] (Publish-Module @requestParam)
254256
}
255257

256258
# Synopsis: Clean up the target build directory
257-
task Clean {
259+
Task Clean {
258260
if (Test-Path $buildPath) {
259261
Write-Warning "Removing build output folder at '$buildPath'"
260262
$requestParam = @{

src/Classes/.gitkeep

Whitespace-only changes.

src/Enum/.gitkeep

Whitespace-only changes.

src/PSScriptModule.prefix.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<# Code inserted in this file will be placed at the top of the .PSM1 file generated by ModuleBuilder #>
2+
<# Delete this file if not needed for your module #>
3+
<# Delete these comments if you don't want them in your module #>

src/PSScriptModule.suffix.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<# Code inserted in this file will be placed at the bottom of the .PSM1 file generated by ModuleBuilder #>
2+
<# Delete this file if not needed for your module #>
3+
<# Delete these comments if you don't want them in your module #>

0 commit comments

Comments
 (0)