diff --git a/.github/actions/ps-resolve-dependencies/action.yml b/.github/actions/ps-resolve-dependencies/action.yml index ffea79f..c3f84f6 100644 --- a/.github/actions/ps-resolve-dependencies/action.yml +++ b/.github/actions/ps-resolve-dependencies/action.yml @@ -13,6 +13,7 @@ runs: run: | $moduleRequirements = Import-PowerShellDataFile -Path './requirements.psd1' $moduleList = foreach ($module in $moduleRequirements.GetEnumerator()) { + if ($module.Key -eq 'PSDependOptions') { continue } $moduleName = $module.Key $moduleInfo = $module.Value diff --git a/.github/workflows/bootstrap.yml b/.github/workflows/bootstrap.yml index 3eb97bc..ffa7987 100644 --- a/.github/workflows/bootstrap.yml +++ b/.github/workflows/bootstrap.yml @@ -116,6 +116,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 }} @@ -224,4 +234,3 @@ jobs: } } } - diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c0c6f41..6ec61a5 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,5 @@ { "recommendations": [ - "GitHub.copilot", "GitHub.copilot-chat", // PowerShell extension for VS Code "ms-vscode.powershell", diff --git a/.vscode/settings.json b/.vscode/settings.json index 0a209bd..f51d5dd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,6 @@ "editor.renderWhitespace": "all", "editor.insertSpaces": true, "editor.defaultFormatter": "ms-vscode.powershell", - // File settings "[powershell]": { "files.trimTrailingWhitespace": true, @@ -15,11 +14,9 @@ "files.exclude": { "**/.DS_Store": true }, - // Enable PowerShell Script Analyzer in workspace "powershell.scriptAnalysis.enable": true, "powershell.scriptAnalysis.settingsPath": "tests/PSScriptAnalyzer/PSScriptAnalyzerSettings.psd1", - // PowerShell extension settings "powershell.codeFormatting.autoCorrectAliases": true, // Sets the codeformatting options to follow the given indent style in a way that is compatible with PowerShell syntax. For more information about the brace styles please refer to https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/81. @@ -39,8 +36,6 @@ "powershell.codeFormatting.useCorrectCasing": true, // Enables Pester 5 CodeLens features such as Run Test, Debug Test, and Code Coverage. "powershell.pester.useLegacyCodeLens": false, - - // Markdown lint settings // https://github.com/PowerShell/PowerShell/blob/master/.markdownlint.json "markdownlint.config": { @@ -72,4 +67,4 @@ "[jsonc]": { "editor.defaultFormatter": "vscode.json-language-features" }, -} +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 704f6f8..4addea8 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,6 +1,5 @@ { "version": "2.0.0", - "windows": { "options": { "shell": { @@ -36,13 +35,12 @@ } } }, - "tasks": [ { "label": "Bootstrap", "type": "shell", - "command": "if (-not (Get-Module -ListAvailable -Name PSDepend)) { Install-Module -Name PSDepend -Scope CurrentUser -Force }; Invoke-PSDepend -Path '${workspaceFolder}/requirements.psd1' -Install -Import -Force", - "problemMatcher": [ ] + "command": "if (-not (Get-Module -ListAvailable -Name PSDepend)) { Install-Module -Name PSDepend -Scope CurrentUser -Force }; Invoke-PSDepend -Path '${workspaceFolder}/requirements.psd1' -Install -Import -Force -Verbose", + "problemMatcher": [] }, { "label": "Clean Build", @@ -51,7 +49,7 @@ "group": { "kind": "build" }, - "problemMatcher": [ ] + "problemMatcher": [] }, { "label": "Build", @@ -61,54 +59,54 @@ "kind": "build", "isDefault": true }, - "problemMatcher": [ ] + "problemMatcher": [] }, { "label": "Test", "type": "shell", "command": "Invoke-Build Test", "group": "test", - "problemMatcher": [ ] + "problemMatcher": [] }, { "label": "UnitTests", "type": "shell", "command": "Invoke-Build UnitTests", "group": "test", - "problemMatcher": [ ] + "problemMatcher": [] }, { "label": "IntegrationTests", "type": "shell", "command": "Invoke-Build IntegrationTests", "group": "test", - "problemMatcher": [ ] + "problemMatcher": [] }, { "label": "PSScriptAnalyzer", "type": "shell", "command": "Invoke-Build PSScriptAnalyzer", "group": "test", - "problemMatcher": [ ] + "problemMatcher": [] }, { "label": "InjectionHunter", "type": "shell", "command": "Invoke-Build InjectionHunter", "group": "test", - "problemMatcher": [ ] + "problemMatcher": [] }, { "label": "Export-CommandHelp", "type": "shell", "command": "Invoke-Build Export-CommandHelp", - "problemMatcher": [ ] + "problemMatcher": [] }, { "label": "Clean", "type": "shell", "command": "Invoke-Build Clean", - "problemMatcher": [ ] + "problemMatcher": [] } ] } \ No newline at end of file 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/docs/help/Get-ModuleMetadata.md b/docs/help/Get-ModuleMetadata.md index 50bf50c..548ae06 100644 --- a/docs/help/Get-ModuleMetadata.md +++ b/docs/help/Get-ModuleMetadata.md @@ -4,7 +4,7 @@ external help file: PSScriptModule-Help.xml HelpUri: https://github.com/YourUsername/PSScriptModule Locale: en-US Module Name: PSScriptModule -ms.date: 01/26/2026 +ms.date: 03/23/2026 PlatyPS schema version: 2024-05-01 title: Get-ModuleMetadata --- diff --git a/requirements.psd1 b/requirements.psd1 index 1f345a1..e6c5d96 100644 --- a/requirements.psd1 +++ b/requirements.psd1 @@ -1,26 +1,34 @@ @{ + # NOTE: + # PSDependOptions with Target = 'CurrentUser' installs all declared module + # dependencies into the current user's scope rather than system-wide. + # This can impact multi-user development or shared build environments, + # where each user/agent will get their own copy of the dependencies. + PSDependOptions = @{ + Target = 'CurrentUser' + } 'InvokeBuild' = @{ - 'Version' = '5.14.22' + 'Version' = 'latest' 'Repository' = 'PSGallery' } 'ModuleBuilder' = @{ - 'Version' = '3.1.8' + 'Version' = 'latest' 'Repository' = 'PSGallery' } 'Pester' = @{ - 'Version' = '5.7.1' + 'Version' = 'latest' 'Repository' = 'PSGallery' } 'PSScriptAnalyzer' = @{ - 'Version' = '1.24.0' + 'Version' = 'latest' 'Repository' = 'PSGallery' } 'InjectionHunter' = @{ - 'Version' = '1.0.0' + 'Version' = 'latest' 'Repository' = 'PSGallery' } 'Microsoft.PowerShell.PlatyPS' = @{ - 'Version' = '1.0.1' + 'Version' = 'latest' 'Repository' = 'PSGallery' } } 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 #>