Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/ps-resolve-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -224,4 +234,3 @@ jobs:
}
}
}

1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"recommendations": [
"GitHub.copilot",
"GitHub.copilot-chat",
// PowerShell extension for VS Code
"ms-vscode.powershell",
Expand Down
7 changes: 1 addition & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"editor.renderWhitespace": "all",
"editor.insertSpaces": true,
"editor.defaultFormatter": "ms-vscode.powershell",

// File settings
"[powershell]": {
"files.trimTrailingWhitespace": true,
Expand All @@ -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.
Expand All @@ -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": {
Expand Down Expand Up @@ -72,4 +67,4 @@
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
}
}
24 changes: 11 additions & 13 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"version": "2.0.0",

"windows": {
"options": {
"shell": {
Expand Down Expand Up @@ -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",
Expand All @@ -51,7 +49,7 @@
"group": {
"kind": "build"
},
"problemMatcher": [ ]
"problemMatcher": []
},
{
"label": "Build",
Expand All @@ -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": []
}
]
}
34 changes: 18 additions & 16 deletions PSScriptModule.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ param (
)

# Synopsis: Default task
task . Clean, Build
Task . Clean, Build

# Setup build environment
Enter-Build {
Expand All @@ -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)
}
Expand All @@ -57,7 +57,7 @@ task PSScriptAnalyzer {
}

# Synopsis: Scan the project with Injection Hunter
task InjectionHunter {
Task InjectionHunter {

$config = New-PesterConfiguration @{
Run = @{
Expand All @@ -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 @{
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -182,7 +182,7 @@ task Export-CommandHelp {
}

# Synopsis: Build the project
task Build Clean, {
Task Build Clean, {

# Copy src directory to ./build folder
$requestParam = @{
Expand All @@ -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)
Expand All @@ -227,15 +229,15 @@ task Package {
SourceLocation = $packageOutputPath
PublishLocation = $packageOutputPath
InstallationPolicy = 'Trusted'
ErrorAction = 'Stop'
ErrorAction = [System.Management.Automation.ActionPreference]::Stop
}
[void] (Register-PSRepository @requestParam)

$requestParam = @{
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)

Expand All @@ -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 = @{
Expand Down
2 changes: 1 addition & 1 deletion docs/help/Get-ModuleMetadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand Down
20 changes: 14 additions & 6 deletions requirements.psd1
Original file line number Diff line number Diff line change
@@ -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'
}
}
Empty file added src/Classes/.gitkeep
Empty file.
Empty file added src/Enum/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions src/PSScriptModule.prefix.ps1
Original file line number Diff line number Diff line change
@@ -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 #>
3 changes: 3 additions & 0 deletions src/PSScriptModule.suffix.ps1
Original file line number Diff line number Diff line change
@@ -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 #>
Loading