diff --git a/.github/workflows/bootstrap.yml b/.github/workflows/bootstrap.yml index c9ebc4c..52cc1be 100644 --- a/.github/workflows/bootstrap.yml +++ b/.github/workflows/bootstrap.yml @@ -109,6 +109,16 @@ jobs: } [void] (New-ModuleManifest @Params) + - name: Rename prefix file to match module name + run: | + MODULE_NAME=${{ github.event.repository.name }} + git mv src/PSScriptModule.prefix.ps1 "src/$MODULE_NAME.prefix.ps1" + + - name: Rename suffix file to match module name + run: | + MODULE_NAME=${{ github.event.repository.name }} + git mv src/PSScriptModule.suffix.ps1 "src/$MODULE_NAME.suffix.ps1" + - name: Update README.md run: | OWNER=${{ github.repository_owner }} @@ -217,4 +227,3 @@ jobs: } } } - diff --git a/PSScriptModule.build.ps1 b/PSScriptModule.build.ps1 index d89aaa3..eb93177 100644 --- a/PSScriptModule.build.ps1 +++ b/PSScriptModule.build.ps1 @@ -23,7 +23,7 @@ param ( ) # Synopsis: Default task -task . Clean, Build +Task . Clean, Build # Setup build environment Enter-Build { @@ -36,7 +36,7 @@ Enter-Build { } # Synopsis: Analyze the project with PSScriptAnalyzer -task PSScriptAnalyzer { +Task PSScriptAnalyzer { if (-not (Test-Path $testOutputPath)) { [void] (New-Item -Path $testOutputPath -ItemType Directory) } @@ -57,7 +57,7 @@ task PSScriptAnalyzer { } # Synopsis: Scan the project with Injection Hunter -task InjectionHunter { +Task InjectionHunter { $config = New-PesterConfiguration @{ Run = @{ @@ -75,7 +75,7 @@ task InjectionHunter { } # Synopsis: Run unit tests and generate code coverage report -task UnitTests { +Task UnitTests { $container = New-PesterContainer -Path $Script:moduleSourcePath -Data @{ SourcePath = $script:moduleSourcePath } $config = New-PesterConfiguration @{ @@ -102,7 +102,7 @@ task UnitTests { } # Synopsis: Run integration tests on built module -task IntegrationTests { +Task IntegrationTests { if (-not (Test-Path $testOutputPath)) { [void] (New-Item -Path $testOutputPath -ItemType Directory) } @@ -136,10 +136,10 @@ task IntegrationTests { } # Synopsis: Run all tests -task Test UnitTests, PSScriptAnalyzer, InjectionHunter +Task Test UnitTests, PSScriptAnalyzer, InjectionHunter # Synopsis: Generate module help documentation -task Export-CommandHelp { +Task Export-CommandHelp { # Import the module being built and PlatyPS module [void] (Import-Module (Join-Path -Path $buildPath -ChildPath "out/$moduleName/$moduleName.psd1") -Force) @@ -182,7 +182,7 @@ task Export-CommandHelp { } # Synopsis: Build the project -task Build Clean, { +Task Build Clean, { # Copy src directory to ./build folder $requestParam = @{ @@ -206,17 +206,19 @@ task Build Clean, { # Build Powershell module [void] (Import-Module ModuleBuilder) $requestParam = @{ - Path = (Join-Path -Path $buildPath -ChildPath "src/$moduleName.psd1") + SourcePath = (Join-Path -Path $buildPath -ChildPath "src/$moduleName.psd1") OutputDirectory = (Join-Path -Path $buildPath -ChildPath "out/$moduleName") + Prefix = if (Test-Path (Join-Path -Path $buildPath -ChildPath "src/$moduleName.prefix.ps1")) { (Join-Path -Path $buildPath -ChildPath "src/$moduleName.prefix.ps1") } else { $null } + Suffix = if (Test-Path (Join-Path -Path $buildPath -ChildPath "src/$moduleName.suffix.ps1")) { (Join-Path -Path $buildPath -ChildPath "src/$moduleName.suffix.ps1") } else { $null } SemVer = $SemanticVersion UnversionedOutputDirectory = $true - ErrorAction = 'Stop' + ErrorAction = [System.Management.Automation.ActionPreference]::Stop } Build-Module @requestParam } # Synopsis: Create a NuGet package for the module -task Package { +Task Package { $packageOutputPath = Join-Path -Path $buildPath -ChildPath 'package' if (!(Test-Path $packageOutputPath)) { [void] (New-Item -Path $packageOutputPath -ItemType Directory -Force) @@ -227,7 +229,7 @@ task Package { SourceLocation = $packageOutputPath PublishLocation = $packageOutputPath InstallationPolicy = 'Trusted' - ErrorAction = 'Stop' + ErrorAction = [System.Management.Automation.ActionPreference]::Stop } [void] (Register-PSRepository @requestParam) @@ -235,7 +237,7 @@ task Package { Path = (Join-Path -Path $buildPath -ChildPath "out/$moduleName") Repository = "$($moduleName)_local_feed" NuGetApiKey = 'ABC123' - ErrorAction = 'Stop' + ErrorAction = [System.Management.Automation.ActionPreference]::Stop } [void] (Publish-Module @requestParam) @@ -244,17 +246,17 @@ task Package { } # Synopsis: Publish the module to PSGallery -task Publish -If ($NugetApiKey) { +Task Publish -If ($NugetApiKey) { $requestParam = @{ Path = (Join-Path -Path $buildPath -ChildPath "out/$moduleName") NuGetApiKey = $NugetApiKey - ErrorAction = 'Stop' + ErrorAction = [System.Management.Automation.ActionPreference]::Stop } [void] (Publish-Module @requestParam) } # Synopsis: Clean up the target build directory -task Clean { +Task Clean { if (Test-Path $buildPath) { Write-Warning "Removing build output folder at '$buildPath'" $requestParam = @{ diff --git a/src/Classes/.gitkeep b/src/Classes/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/Enum/.gitkeep b/src/Enum/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/PSScriptModule.prefix.ps1 b/src/PSScriptModule.prefix.ps1 new file mode 100644 index 0000000..8767c46 --- /dev/null +++ b/src/PSScriptModule.prefix.ps1 @@ -0,0 +1,3 @@ +<# Code inserted in this file will be placed at the top of the .PSM1 file generated by ModuleBuilder #> +<# Delete this file if not needed for your module #> +<# Delete these comments if you don't want them in your module #> diff --git a/src/PSScriptModule.suffix.ps1 b/src/PSScriptModule.suffix.ps1 new file mode 100644 index 0000000..d02f1ea --- /dev/null +++ b/src/PSScriptModule.suffix.ps1 @@ -0,0 +1,3 @@ +<# Code inserted in this file will be placed at the bottom of the .PSM1 file generated by ModuleBuilder #> +<# Delete this file if not needed for your module #> +<# Delete these comments if you don't want them in your module #>