From c66f337ddbb13d80ca36571d0dffac9ea4dbea60 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sun, 30 Mar 2025 15:48:44 -0700 Subject: [PATCH 1/6] =?UTF-8?q?chore:=20=E2=9C=A8=20Update=20build=20tasks?= =?UTF-8?q?=20and=20add=20cspell=20configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refactored build tasks to use `$PSBPreference.TaskDependencies`. * Introduced `cspell.json` for spell checking configuration. * Updated `CHANGELOG.md` to reflect changes in task dependencies. * Adjusted formatting in several scripts for consistency. --- CHANGELOG.md | 5 +- PowerShellBuild/build.properties.ps1 | 18 +++++- PowerShellBuild/psakeFile.ps1 | 80 ++++++++++++------------- build.ps1 | 33 +++++------ cspell.json | 18 ++++++ requirements.psd1 | 12 ++-- tests/TestModule/.build.ps1 | 4 +- tests/build.tests.ps1 | 87 ++++++++++++++-------------- 8 files changed, 146 insertions(+), 111 deletions(-) create mode 100644 cspell.json diff --git a/CHANGELOG.md b/CHANGELOG.md index da0da61..2ab4f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased -### Breaking Changes +### Changed - [**#71**](https://github.com/psake/PowerShellBuild/pull/71) Compiled modules are now explicitly created as UTF-8 files. - [**#67**](https://github.com/psake/PowerShellBuild/pull/67) You can now overwrite existing markdown files using `$PSBPreference.Docs.Overwrite` and setting it to `$true`. +- Loose dependencies by allowing them to be overwritten with $PSBPreference. +- [**#71**](https://github.com/psake/PowerShellBuild/pull/71) Compiled modules + are now explicitly created as UTF-8 files. ## [0.6.2] 2024-10-06 diff --git a/PowerShellBuild/build.properties.ps1 b/PowerShellBuild/build.properties.ps1 index ba39881..15570cd 100644 --- a/PowerShellBuild/build.properties.ps1 +++ b/PowerShellBuild/build.properties.ps1 @@ -1,3 +1,4 @@ +# spell-checker:ignore PSGALLERY BHPS MAML BuildHelpers\Set-BuildEnvironment -Force $outDir = [IO.Path]::Combine($env:BHProjectPath, 'Output') @@ -22,7 +23,7 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul } Build = @{ - Dependencies = @('StageFiles', 'BuildHelp') + # "Dependencies" moved to TaskDependencies section # Output directory when building a module OutDir = $outDir @@ -98,7 +99,7 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul } } Help = @{ - # Path to updateable help CAB + # Path to updatable help CAB UpdatableHelpOutDir = [IO.Path]::Combine($outDir, 'UpdatableHelp') # Default Locale used for help generation, defaults to en-US @@ -125,6 +126,19 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul # Credential to authenticate to PowerShell repository with PSRepositoryCredential = $null } + TaskDependencies = @{ + Clean = @('Init') + StageFiles = @('Clean') + Build = @('StageFiles', 'BuildHelp') + Analyze = @('Build') + Pester = @('Build') + Test = @('Pester', 'Analyze') + BuildHelp = @('GenerateMarkdown', 'GenerateMAML') + GenerateMarkdown = @('StageFiles') + GenerateMAML = @('GenerateMarkdown') + GenerateUpdatableHelp = @('BuildHelp') + Publish = @('Test') + } } # Enable/disable generation of a catalog (.cat) file for the module. diff --git a/PowerShellBuild/psakeFile.ps1 b/PowerShellBuild/psakeFile.ps1 index 23712e8..11eb4fe 100644 --- a/PowerShellBuild/psakeFile.ps1 +++ b/PowerShellBuild/psakeFile.ps1 @@ -3,7 +3,7 @@ Remove-Variable -Name PSBPreference -Scope Script -Force -ErrorAction Ignore Set-Variable -Name PSBPreference -Option ReadOnly -Scope Script -Value (. ([IO.Path]::Combine($PSScriptRoot, 'build.properties.ps1'))) -properties {} +Properties {} FormatTaskName { param($taskName) @@ -15,24 +15,24 @@ FormatTaskName { # Can't have two 'default' tasks # Task default -depends Test -task Init { +Task Init { Initialize-PSBuild -UseBuildHelpers -BuildEnvironment $PSBPreference } -description 'Initialize build environment variables' -task Clean -depends Init { +Task Clean -depends $PSBPreference.TaskDependencies.Clean { Clear-PSBuildOutputFolder -Path $PSBPreference.Build.ModuleOutDir } -description 'Clears module output directory' -task StageFiles -depends Clean { +Task StageFiles -depends $PSBPreference.TaskDependencies.StageFiles { $buildParams = @{ - Path = $PSBPreference.General.SrcRootDir - ModuleName = $PSBPreference.General.ModuleName - DestinationPath = $PSBPreference.Build.ModuleOutDir - Exclude = $PSBPreference.Build.Exclude - Compile = $PSBPreference.Build.CompileModule - CompileDirectories = $PSBPreference.Build.CompileDirectories - CopyDirectories = $PSBPreference.Build.CopyDirectories - Culture = $PSBPreference.Help.DefaultLocale + Path = $PSBPreference.General.SrcRootDir + ModuleName = $PSBPreference.General.ModuleName + DestinationPath = $PSBPreference.Build.ModuleOutDir + Exclude = $PSBPreference.Build.Exclude + Compile = $PSBPreference.Build.CompileModule + CompileDirectories = $PSBPreference.Build.CompileDirectories + CopyDirectories = $PSBPreference.Build.CopyDirectories + Culture = $PSBPreference.Help.DefaultLocale } if ($PSBPreference.Help.ConvertReadMeToAboutHelp) { @@ -53,7 +53,7 @@ task StageFiles -depends Clean { Build-PSBuildModule @buildParams } -description 'Builds module based on source directory' -task Build -depends $PSBPreference.Build.Dependencies -description 'Builds module and generate help documentation' +Task Build -depends $PSBPreference.TaskDependencies.Build -description 'Builds module and generate help documentation' $analyzePreReqs = { $result = $true @@ -67,11 +67,11 @@ $analyzePreReqs = { } $result } -task Analyze -depends Build -precondition $analyzePreReqs { +Task Analyze -depends $PSBPreference.TaskDependencies.Analyze -precondition $analyzePreReqs { $analyzeParams = @{ - Path = $PSBPreference.Build.ModuleOutDir + Path = $PSBPreference.Build.ModuleOutDir SeverityThreshold = $PSBPreference.Test.ScriptAnalysis.FailBuildOnSeverityLevel - SettingsPath = $PSBPreference.Test.ScriptAnalysis.SettingsPath + SettingsPath = $PSBPreference.Test.ScriptAnalysis.SettingsPath } Test-PSBuildScriptAnalysis @analyzeParams } -description 'Execute PSScriptAnalyzer tests' @@ -92,27 +92,27 @@ $pesterPreReqs = { } return $result } -task Pester -depends Build -precondition $pesterPreReqs { +Task Pester -depends $PSBPreference.TaskDependencies.Pester -precondition $pesterPreReqs { $pesterParams = @{ - Path = $PSBPreference.Test.RootDir - ModuleName = $PSBPreference.General.ModuleName - ModuleManifest = Join-Path $PSBPreference.Build.ModuleOutDir "$($PSBPreference.General.ModuleName).psd1" - OutputPath = $PSBPreference.Test.OutputFile - OutputFormat = $PSBPreference.Test.OutputFormat - CodeCoverage = $PSBPreference.Test.CodeCoverage.Enabled - CodeCoverageThreshold = $PSBPreference.Test.CodeCoverage.Threshold - CodeCoverageFiles = $PSBPreference.Test.CodeCoverage.Files - CodeCoverageOutputFile = $PSBPreference.Test.CodeCoverage.OutputFile + Path = $PSBPreference.Test.RootDir + ModuleName = $PSBPreference.General.ModuleName + ModuleManifest = Join-Path $PSBPreference.Build.ModuleOutDir "$($PSBPreference.General.ModuleName).psd1" + OutputPath = $PSBPreference.Test.OutputFile + OutputFormat = $PSBPreference.Test.OutputFormat + CodeCoverage = $PSBPreference.Test.CodeCoverage.Enabled + CodeCoverageThreshold = $PSBPreference.Test.CodeCoverage.Threshold + CodeCoverageFiles = $PSBPreference.Test.CodeCoverage.Files + CodeCoverageOutputFile = $PSBPreference.Test.CodeCoverage.OutputFile CodeCoverageOutputFileFormat = $PSBPreference.Test.CodeCoverage.OutputFileFormat - ImportModule = $PSBPreference.Test.ImportModule + ImportModule = $PSBPreference.Test.ImportModule } Test-PSBuildPester @pesterParams } -description 'Execute Pester tests' -task Test -depends Pester, Analyze { +Task Test -depends $PSBPreference.TaskDependencies.Test { } -description 'Execute Pester and ScriptAnalyzer tests' -task BuildHelp -depends GenerateMarkdown, GenerateMAML {} -description 'Builds help documentation' +Task BuildHelp -depends $PSBPreference.TaskDependencies.BuildHelp {} -description 'Builds help documentation' $genMarkdownPreReqs = { $result = $true @@ -122,13 +122,13 @@ $genMarkdownPreReqs = { } $result } -task GenerateMarkdown -depends StageFiles -precondition $genMarkdownPreReqs { +Task GenerateMarkdown -depends $PSBPreference.TaskDependencies.GenerateMarkdown -precondition $genMarkdownPreReqs { $buildMDParams = @{ ModulePath = $PSBPreference.Build.ModuleOutDir ModuleName = $PSBPreference.General.ModuleName - DocsPath = $PSBPreference.Docs.RootDir - Locale = $PSBPreference.Help.DefaultLocale - Overwrite = $PSBPreference.Docs.Overwrite + DocsPath = $PSBPreference.Docs.RootDir + Locale = $PSBPreference.Help.DefaultLocale + Overwrite = $PSBPreference.Docs.Overwrite } Build-PSBuildMarkdown @buildMDParams } -description 'Generates PlatyPS markdown files from module help' @@ -141,7 +141,7 @@ $genHelpFilesPreReqs = { } $result } -task GenerateMAML -depends GenerateMarkdown -precondition $genHelpFilesPreReqs { +Task GenerateMAML -depends $PSBPreference.TaskDependencies.GenerateMAML -precondition $genHelpFilesPreReqs { Build-PSBuildMAMLHelp -Path $PSBPreference.Docs.RootDir -DestinationPath $PSBPreference.Build.ModuleOutDir } -description 'Generates MAML-based help from PlatyPS markdown files' @@ -153,18 +153,18 @@ $genUpdatableHelpPreReqs = { } $result } -task GenerateUpdatableHelp -depends BuildHelp -precondition $genUpdatableHelpPreReqs { +Task GenerateUpdatableHelp -depends $PSBPreference.TaskDependencies.GenerateUpdatableHelp -precondition $genUpdatableHelpPreReqs { Build-PSBuildUpdatableHelp -DocsPath $PSBPreference.Docs.RootDir -OutputPath $PSBPreference.Help.UpdatableHelpOutDir } -description 'Create updatable help .cab file based on PlatyPS markdown help' -task Publish -depends Test { +Task Publish -depends $PSBPreference.TaskDependencies.Publish { Assert -conditionToCheck ($PSBPreference.Publish.PSRepositoryApiKey -or $PSBPreference.Publish.PSRepositoryCredential) -failureMessage "API key or credential not defined to authenticate with [$($PSBPreference.Publish.PSRepository)] with." $publishParams = @{ - Path = $PSBPreference.Build.ModuleOutDir - Version = $PSBPreference.General.ModuleVersion + Path = $PSBPreference.Build.ModuleOutDir + Version = $PSBPreference.General.ModuleVersion Repository = $PSBPreference.Publish.PSRepository - Verbose = $VerbosePreference + Verbose = $VerbosePreference } if ($PSBPreference.Publish.PSRepositoryApiKey) { $publishParams.ApiKey = $PSBPreference.Publish.PSRepositoryApiKey @@ -177,7 +177,7 @@ task Publish -depends Test { Publish-PSBuildModule @publishParams } -description 'Publish module to the defined PowerShell repository' -task ? -description 'Lists the available tasks' { +Task ? -description 'Lists the available tasks' { 'Available tasks:' $psake.context.Peek().Tasks.Keys | Sort-Object } diff --git a/build.ps1 b/build.ps1 index 06f810b..8529de6 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,23 +3,22 @@ param( # Build task(s) to execute [parameter(ParameterSetName = 'task', position = 0)] [ArgumentCompleter( { - param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams) - $psakeFile = './psakeFile.ps1' - switch ($Parameter) { - 'Task' { - if ([string]::IsNullOrEmpty($WordToComplete)) { - Get-PSakeScriptTasks -buildFile $psakeFile | Select-Object -ExpandProperty Name + param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams) + $psakeFile = './psakeFile.ps1' + switch ($Parameter) { + 'Task' { + if ([string]::IsNullOrEmpty($WordToComplete)) { + Get-PSakeScriptTasks -buildFile $psakeFile | Select-Object -ExpandProperty Name + } else { + Get-PSakeScriptTasks -buildFile $psakeFile | + Where-Object { $_.Name -match $WordToComplete } | + Select-Object -ExpandProperty Name + } } - else { - Get-PSakeScriptTasks -buildFile $psakeFile | - Where-Object { $_.Name -match $WordToComplete } | - Select-Object -ExpandProperty Name + default { } } - Default { - } - } - })] + })] [string[]]$Task = 'default', # Bootstrap dependencies @@ -36,10 +35,10 @@ $ErrorActionPreference = 'Stop' # Bootstrap dependencies if ($Bootstrap.IsPresent) { - Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null + PackageManagement\Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null Set-PSRepository -Name PSGallery -InstallationPolicy Trusted if (-not (Get-Module -Name PSDepend -ListAvailable)) { - Install-module -Name PSDepend -Repository PSGallery + Install-Module -Name PSDepend -Repository PSGallery } Import-Module -Name PSDepend -Verbose:$false Invoke-PSDepend -Path './requirements.psd1' -Install -Import -Force -WarningAction SilentlyContinue @@ -48,7 +47,7 @@ if ($Bootstrap.IsPresent) { # Execute psake task(s) $psakeFile = './psakeFile.ps1' if ($PSCmdlet.ParameterSetName -eq 'Help') { - Get-PSakeScriptTasks -buildFile $psakeFile | + Get-PSakeScriptTasks -buildFile $psakeFile | Format-Table -Property Name, Description, Alias, DependsOn } else { Set-BuildEnvironment -Force diff --git a/cspell.json b/cspell.json new file mode 100644 index 0000000..a8959d9 --- /dev/null +++ b/cspell.json @@ -0,0 +1,18 @@ +{ + "version": "0.2", + "ignorePaths": [], + "dictionaryDefinitions": [], + "dictionaries": [ + "powershell", + "csharp", + "json", + "xml", + "markdown" + ], + "words": [], + "ignoreWords": [ + "psake", + "MAML" + ], + "import": [] +} diff --git a/requirements.psd1 b/requirements.psd1 index 9f9d4b1..e768dba 100755 --- a/requirements.psd1 +++ b/requirements.psd1 @@ -2,15 +2,15 @@ PSDependOptions = @{ Target = 'CurrentUser' } - BuildHelpers = '2.0.16' - Pester = @{ + BuildHelpers = '2.0.16' + Pester = @{ MinimumVersion = '5.6.1' Parameters = @{ SkipPublisherCheck = $true } } - psake = '4.9.0' - PSScriptAnalyzer = '1.19.1' - InvokeBuild = '5.8.1' - platyPS = '0.14.2' + psake = '4.9.0' + PSScriptAnalyzer = '1.24.0' + InvokeBuild = '5.8.1' + platyPS = '0.14.2' } diff --git a/tests/TestModule/.build.ps1 b/tests/TestModule/.build.ps1 index 459b589..fad87e2 100644 --- a/tests/TestModule/.build.ps1 +++ b/tests/TestModule/.build.ps1 @@ -3,6 +3,6 @@ Import-Module ../../Output/PowerShellBuild -Force $PSBPreference.Build.CompileModule = $true -task Build $PSBPreference.build.dependencies +Task Build $PSBPreference.TaskDependencies.Build -task . Build +Task . Build diff --git a/tests/build.tests.ps1 b/tests/build.tests.ps1 index 0a8a6b7..b0b60ce 100644 --- a/tests/build.tests.ps1 +++ b/tests/build.tests.ps1 @@ -1,24 +1,25 @@ -describe 'Build' { +# spell-checker:ignore excludeme +Describe 'Build' { BeforeAll { # Hack for GH Actions # For some reason, the TestModule build process create the output in the project root # and not relative to it's own build file. if ($env:GITHUB_ACTION) { - $testModuleOutputPath = [IO.Path]::Combine($env:BHProjectPath, 'Output', 'TestModule', '0.1.0') + $script:testModuleOutputPath = [IO.Path]::Combine($env:BHProjectPath, 'Output', 'TestModule', '0.1.0') } else { - $testModuleOutputPath = [IO.Path]::Combine($env:BHProjectPath, 'tests', 'TestModule', 'Output', 'TestModule', '0.1.0') + $script:testModuleOutputPath = [IO.Path]::Combine($env:BHProjectPath, 'tests', 'TestModule', 'Output', 'TestModule', '0.1.0') } } - context 'Compile module' { + Context 'Compile module' { BeforeAll { Write-Host "PSScriptRoot: $PSScriptRoot" - Write-Host "OutputPath: $testModuleOutputPath" + Write-Host "OutputPath: $script:testModuleOutputPath" # build is PS job so psake doesn't freak out because it's nested - Start-Job -ScriptBlock { + Start-Job -Scriptblock { Set-Location $using:PSScriptRoot/TestModule $global:PSBuildCompile = $true ./build.ps1 -Task Build @@ -26,51 +27,51 @@ describe 'Build' { } AfterAll { - Remove-Item $testModuleOutputPath -Recurse -Force + Remove-Item $script:testModuleOutputPath -Recurse -Force } - it 'Creates module' { - $testModuleOutputPath | Should -Exist + It 'Creates module' { + $script:testModuleOutputPath | Should -Exist } - it 'Has PSD1 and monolithic PSM1' { - (Get-ChildItem -Path $testModuleOutputPath -File).Count | Should -Be 2 - "$testModuleOutputPath/TestModule.psd1" | Should -Exist - "$testModuleOutputPath/TestModule.psm1" | Should -Exist - "$testModuleOutputPath/Public" | Should -Not -Exist - "$testModuleOutputPath/Private" | Should -Not -Exist + It 'Has PSD1 and monolithic PSM1' { + (Get-ChildItem -Path $script:testModuleOutputPath -File).Count | Should -Be 2 + "$script:testModuleOutputPath/TestModule.psd1" | Should -Exist + "$script:testModuleOutputPath/TestModule.psm1" | Should -Exist + "$script:testModuleOutputPath/Public" | Should -Not -Exist + "$script:testModuleOutputPath/Private" | Should -Not -Exist } - it 'Has module header text' { - "$testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Module Header' + It 'Has module header text' { + "$script:testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Module Header' } - it 'Has module footer text' { - "$testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Module Footer' + It 'Has module footer text' { + "$script:testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Module Footer' } - it 'Has function header text' { - "$testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Function header' + It 'Has function header text' { + "$script:testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Function header' } - it 'Has function footer text' { - "$testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Function footer' + It 'Has function footer text' { + "$script:testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Function footer' } - it 'Does not contain excluded files' { - (Get-ChildItem -Path $testModuleOutputPath -File -Filter '*excludeme*' -Recurse).Count | Should -Be 0 - "$testModuleOutputPath/TestModule.psm1" | Should -Not -FileContentMatch '=== EXCLUDE ME ===' + It 'Does not contain excluded files' { + (Get-ChildItem -Path $script:testModuleOutputPath -File -Filter '*excludeme*' -Recurse).Count | Should -Be 0 + "$script:testModuleOutputPath/TestModule.psm1" | Should -Not -FileContentMatch '=== EXCLUDE ME ===' } - it 'Has MAML help XML' { - "$testModuleOutputPath/en-US/TestModule-help.xml" | Should -Exist + It 'Has MAML help XML' { + "$script:testModuleOutputPath/en-US/TestModule-help.xml" | Should -Exist } } - context 'Dot-sourced module' { + Context 'Dot-sourced module' { BeforeAll { # build is PS job so psake doesn't freak out because it's nested - Start-Job -ScriptBlock { + Start-Job -Scriptblock { Set-Location $using:PSScriptRoot/TestModule $global:PSBuildCompile = $false ./build.ps1 -Task Build @@ -78,27 +79,27 @@ describe 'Build' { } AfterAll { - Remove-Item $testModuleOutputPath -Recurse -Force + Remove-Item $script:testModuleOutputPath -Recurse -Force } - it 'Creates module' { - $testModuleOutputPath | Should -Exist + It 'Creates module' { + $script:testModuleOutputPath | Should -Exist } - it 'Has PSD1 and dot-sourced functions' { - (Get-ChildItem -Path $testModuleOutputPath).Count | Should -Be 6 - "$testModuleOutputPath/TestModule.psd1" | Should -Exist - "$testModuleOutputPath/TestModule.psm1" | Should -Exist - "$testModuleOutputPath/Public" | Should -Exist - "$testModuleOutputPath/Private" | Should -Exist + It 'Has PSD1 and dot-sourced functions' { + (Get-ChildItem -Path $script:testModuleOutputPath).Count | Should -Be 6 + "$script:testModuleOutputPath/TestModule.psd1" | Should -Exist + "$script:testModuleOutputPath/TestModule.psm1" | Should -Exist + "$script:testModuleOutputPath/Public" | Should -Exist + "$script:testModuleOutputPath/Private" | Should -Exist } - it 'Does not contain excluded stuff' { - (Get-ChildItem -Path $testModuleOutputPath -File -Filter '*excludeme*' -Recurse).Count | Should -Be 0 + It 'Does not contain excluded stuff' { + (Get-ChildItem -Path $script:testModuleOutputPath -File -Filter '*excludeme*' -Recurse).Count | Should -Be 0 } - it 'Has MAML help XML' { - "$testModuleOutputPath/en-US/TestModule-help.xml" | Should -Exist + It 'Has MAML help XML' { + "$script:testModuleOutputPath/en-US/TestModule-help.xml" | Should -Exist } } } From b6466f4fb43156b7386c40dff4e50cb7de9646c4 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sun, 30 Mar 2025 15:53:34 -0700 Subject: [PATCH 2/6] =?UTF-8?q?chore:=20=F0=9F=94=84=20Loosen=20dependenci?= =?UTF-8?q?es=20with=20$PSBPreference.TaskDependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated CHANGELOG.md to reflect changes in dependency management. * Allows task dependencies to be overwritten, enhancing flexibility. --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ab4f07..2ebcb73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). overwrite existing markdown files using `$PSBPreference.Docs.Overwrite` and setting it to `$true`. - Loose dependencies by allowing them to be overwritten with $PSBPreference. -- [**#71**](https://github.com/psake/PowerShellBuild/pull/71) Compiled modules - are now explicitly created as UTF-8 files. +- [**#72**](https://github.com/psake/PowerShellBuild/pull/72) Loosen + dependencies by allowing them to be overwritten with + `$PSBPreference.TaskDependencies`. ## [0.6.2] 2024-10-06 From 02d8856e420a7e59bfc8da6ebbb48d2cdbfca0a3 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sun, 30 Mar 2025 16:33:55 -0700 Subject: [PATCH 3/6] =?UTF-8?q?chore:=20=E2=9C=A8=20Update=20VSCode=20sett?= =?UTF-8?q?ings=20and=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added new PowerShell code formatting options in `.vscode/settings.json` * Cleaned up and reorganized entries in `CHANGELOG.md` * Improved code readability in `psakeFile.ps1` with consistent formatting --- .vscode/settings.json | 6 +++- CHANGELOG.md | 14 +++++----- PowerShellBuild/psakeFile.ps1 | 52 +++++++++++++++++------------------ 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index bb482c1..227163e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,9 @@ "editor.insertSpaces": true, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, - "powershell.codeFormatting.preset": "OTBS" + "powershell.codeFormatting.preset": "OTBS", + "powershell.codeFormatting.addWhitespaceAroundPipe": true, + "powershell.codeFormatting.useCorrectCasing": true, + "powershell.codeFormatting.newLineAfterOpenBrace": true, + "powershell.codeFormatting.alignPropertyValuePairs": true } diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ebcb73..511c3e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -137,13 +137,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). 'Public' folder when dot sourcing functions in PSM1 (via [@pauby](https://github.com/pauby)) -### Changed - -- [**#19**](https://github.com/psake/PowerShellBuild/pull/19) Allow the - `BHBuildOutput` environment variable defined by `BuildHelpers` to be set via - the `$PSBPreference.Build.ModuleOutDir` property of the build tasks (via - [@pauby](https://github.com/pauby)) - ### Breaking changes - Refactor build properties into a single hashtable `$PSBPreference` @@ -154,6 +147,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). tasks are now auto-generated from the psake tasks via a converter script (via [@JustinGrote](https://github.com/JustinGrote)) +- [**#19**](https://github.com/psake/PowerShellBuild/pull/19) Allow the + `BHBuildOutput` environment variable defined by `BuildHelpers` to be set via + the `$PSBPreference.Build.ModuleOutDir` property of the build tasks (via + [@pauby](https://github.com/pauby)) + ## [0.2.0] - 2018-11-15 ### Added @@ -174,3 +172,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Initial commit + + diff --git a/PowerShellBuild/psakeFile.ps1 b/PowerShellBuild/psakeFile.ps1 index 11eb4fe..91073e4 100644 --- a/PowerShellBuild/psakeFile.ps1 +++ b/PowerShellBuild/psakeFile.ps1 @@ -1,4 +1,4 @@ - +# spell-checker:ignore Reqs # Load in build settings Remove-Variable -Name PSBPreference -Scope Script -Force -ErrorAction Ignore Set-Variable -Name PSBPreference -Option ReadOnly -Scope Script -Value (. ([IO.Path]::Combine($PSScriptRoot, 'build.properties.ps1'))) @@ -25,14 +25,14 @@ Task Clean -depends $PSBPreference.TaskDependencies.Clean { Task StageFiles -depends $PSBPreference.TaskDependencies.StageFiles { $buildParams = @{ - Path = $PSBPreference.General.SrcRootDir - ModuleName = $PSBPreference.General.ModuleName - DestinationPath = $PSBPreference.Build.ModuleOutDir - Exclude = $PSBPreference.Build.Exclude - Compile = $PSBPreference.Build.CompileModule + Path = $PSBPreference.General.SrcRootDir + ModuleName = $PSBPreference.General.ModuleName + DestinationPath = $PSBPreference.Build.ModuleOutDir + Exclude = $PSBPreference.Build.Exclude + Compile = $PSBPreference.Build.CompileModule CompileDirectories = $PSBPreference.Build.CompileDirectories - CopyDirectories = $PSBPreference.Build.CopyDirectories - Culture = $PSBPreference.Help.DefaultLocale + CopyDirectories = $PSBPreference.Build.CopyDirectories + Culture = $PSBPreference.Help.DefaultLocale } if ($PSBPreference.Help.ConvertReadMeToAboutHelp) { @@ -69,9 +69,9 @@ $analyzePreReqs = { } Task Analyze -depends $PSBPreference.TaskDependencies.Analyze -precondition $analyzePreReqs { $analyzeParams = @{ - Path = $PSBPreference.Build.ModuleOutDir + Path = $PSBPreference.Build.ModuleOutDir SeverityThreshold = $PSBPreference.Test.ScriptAnalysis.FailBuildOnSeverityLevel - SettingsPath = $PSBPreference.Test.ScriptAnalysis.SettingsPath + SettingsPath = $PSBPreference.Test.ScriptAnalysis.SettingsPath } Test-PSBuildScriptAnalysis @analyzeParams } -description 'Execute PSScriptAnalyzer tests' @@ -94,17 +94,17 @@ $pesterPreReqs = { } Task Pester -depends $PSBPreference.TaskDependencies.Pester -precondition $pesterPreReqs { $pesterParams = @{ - Path = $PSBPreference.Test.RootDir - ModuleName = $PSBPreference.General.ModuleName - ModuleManifest = Join-Path $PSBPreference.Build.ModuleOutDir "$($PSBPreference.General.ModuleName).psd1" - OutputPath = $PSBPreference.Test.OutputFile - OutputFormat = $PSBPreference.Test.OutputFormat - CodeCoverage = $PSBPreference.Test.CodeCoverage.Enabled - CodeCoverageThreshold = $PSBPreference.Test.CodeCoverage.Threshold - CodeCoverageFiles = $PSBPreference.Test.CodeCoverage.Files - CodeCoverageOutputFile = $PSBPreference.Test.CodeCoverage.OutputFile + Path = $PSBPreference.Test.RootDir + ModuleName = $PSBPreference.General.ModuleName + ModuleManifest = Join-Path $PSBPreference.Build.ModuleOutDir "$($PSBPreference.General.ModuleName).psd1" + OutputPath = $PSBPreference.Test.OutputFile + OutputFormat = $PSBPreference.Test.OutputFormat + CodeCoverage = $PSBPreference.Test.CodeCoverage.Enabled + CodeCoverageThreshold = $PSBPreference.Test.CodeCoverage.Threshold + CodeCoverageFiles = $PSBPreference.Test.CodeCoverage.Files + CodeCoverageOutputFile = $PSBPreference.Test.CodeCoverage.OutputFile CodeCoverageOutputFileFormat = $PSBPreference.Test.CodeCoverage.OutputFileFormat - ImportModule = $PSBPreference.Test.ImportModule + ImportModule = $PSBPreference.Test.ImportModule } Test-PSBuildPester @pesterParams } -description 'Execute Pester tests' @@ -126,9 +126,9 @@ Task GenerateMarkdown -depends $PSBPreference.TaskDependencies.GenerateMarkdown $buildMDParams = @{ ModulePath = $PSBPreference.Build.ModuleOutDir ModuleName = $PSBPreference.General.ModuleName - DocsPath = $PSBPreference.Docs.RootDir - Locale = $PSBPreference.Help.DefaultLocale - Overwrite = $PSBPreference.Docs.Overwrite + DocsPath = $PSBPreference.Docs.RootDir + Locale = $PSBPreference.Help.DefaultLocale + Overwrite = $PSBPreference.Docs.Overwrite } Build-PSBuildMarkdown @buildMDParams } -description 'Generates PlatyPS markdown files from module help' @@ -161,10 +161,10 @@ Task Publish -depends $PSBPreference.TaskDependencies.Publish { Assert -conditionToCheck ($PSBPreference.Publish.PSRepositoryApiKey -or $PSBPreference.Publish.PSRepositoryCredential) -failureMessage "API key or credential not defined to authenticate with [$($PSBPreference.Publish.PSRepository)] with." $publishParams = @{ - Path = $PSBPreference.Build.ModuleOutDir - Version = $PSBPreference.General.ModuleVersion + Path = $PSBPreference.Build.ModuleOutDir + Version = $PSBPreference.General.ModuleVersion Repository = $PSBPreference.Publish.PSRepository - Verbose = $VerbosePreference + Verbose = $VerbosePreference } if ($PSBPreference.Publish.PSRepositoryApiKey) { $publishParams.ApiKey = $PSBPreference.Publish.PSRepositoryApiKey From 0545e921d1e4af0a39be5a08c0bfe3c187c7bc2a Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sun, 30 Mar 2025 16:36:44 -0700 Subject: [PATCH 4/6] =?UTF-8?q?chore:=20=F0=9F=94=84=20Update=20formatting?= =?UTF-8?q?=20in=20requirements.psd1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adjusted spacing for better readability. * No functional changes made to the dependencies. --- requirements.psd1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements.psd1 b/requirements.psd1 index e768dba..5e22bd3 100755 --- a/requirements.psd1 +++ b/requirements.psd1 @@ -1,16 +1,16 @@ @{ - PSDependOptions = @{ + PSDependOptions = @{ Target = 'CurrentUser' } - BuildHelpers = '2.0.16' - Pester = @{ + BuildHelpers = '2.0.16' + Pester = @{ MinimumVersion = '5.6.1' - Parameters = @{ + Parameters = @{ SkipPublisherCheck = $true } } - psake = '4.9.0' + psake = '4.9.0' PSScriptAnalyzer = '1.24.0' - InvokeBuild = '5.8.1' - platyPS = '0.14.2' + InvokeBuild = '5.8.1' + platyPS = '0.14.2' } From 2babf9a795e17c30e6a17a47cd8e00de7e7a67bf Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sun, 30 Mar 2025 16:37:20 -0700 Subject: [PATCH 5/6] =?UTF-8?q?chore:=20=F0=9F=94=84=20Update=20`Start-Job?= =?UTF-8?q?`=20to=20use=20`ScriptBlock`=20for=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Changed `Scriptblock` to `ScriptBlock` in `build.tests.ps1` for uniformity. * Ensures adherence to PowerShell naming conventions. --- tests/build.tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/build.tests.ps1 b/tests/build.tests.ps1 index b0b60ce..9bbbdc3 100644 --- a/tests/build.tests.ps1 +++ b/tests/build.tests.ps1 @@ -19,7 +19,7 @@ Describe 'Build' { Write-Host "OutputPath: $script:testModuleOutputPath" # build is PS job so psake doesn't freak out because it's nested - Start-Job -Scriptblock { + Start-Job -ScriptBlock { Set-Location $using:PSScriptRoot/TestModule $global:PSBuildCompile = $true ./build.ps1 -Task Build @@ -71,7 +71,7 @@ Describe 'Build' { Context 'Dot-sourced module' { BeforeAll { # build is PS job so psake doesn't freak out because it's nested - Start-Job -Scriptblock { + Start-Job -ScriptBlock { Set-Location $using:PSScriptRoot/TestModule $global:PSBuildCompile = $false ./build.ps1 -Task Build From 23662a311a12bf91a11e6ca831fc0c97a11d9b1b Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Mon, 31 Mar 2025 09:35:41 -0700 Subject: [PATCH 6/6] =?UTF-8?q?chore:=20=F0=9F=94=84=20Add=20TaskDependenc?= =?UTF-8?q?ies=20to=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Improved alignment and consistency of task tables. * Enhanced readability of dependencies and descriptions. --- README.md | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 1909e0d..bd992f5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PowerShellBuild -| GitHub Actions | PS Gallery | License | -|----------------|------------|---------| +| GitHub Actions | PS Gallery | License | +|-------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|--------------------------------------| | [![GitHub Actions Status][github-actions-badge]][github-actions-build] [![GitHub Actions Status][github-actions-badge-publish]][github-actions-build] | [![PowerShell Gallery][psgallery-badge]][psgallery] | [![License][license-badge]][license] | This project aims to provide common [psake](https://github.com/psake/psake) and @@ -53,28 +53,28 @@ other projects. These primary tasks are the main tasks you'll typically call as part of PowerShell module development. -| Name | Dependencies | Description | -| --------------------- | --------------------- | ----------- | -| Init | _none_ | Initialize psake and task variables | -| Clean | init | Clean output directory | -| Build | StageFiles, BuildHelp | Clean and build module in output directory | -| Analyze | Build | Run PSScriptAnalyzer tests | -| Pester | Build | Run Pester tests | -| Test | Analyze, Pester | Run combined tests | -| Publish | Test | Publish module to defined PowerShell repository | +| Name | Dependencies | Description | +|---------|-----------------------|-------------------------------------------------| +| Init | _none_ | Initialize psake and task variables | +| Clean | init | Clean output directory | +| Build | StageFiles, BuildHelp | Clean and build module in output directory | +| Analyze | Build | Run PSScriptAnalyzer tests | +| Pester | Build | Run Pester tests | +| Test | Analyze, Pester | Run combined tests | +| Publish | Test | Publish module to defined PowerShell repository | ### Secondary Tasks These secondary tasks are called as dependencies from the primary tasks but may also be called directly. -| Name | Dependencies | Description | -| --------------------- | -------------------------------| ----------- | -| BuildHelp | GenerateMarkdown, GenerateMAML | Build all help files | +| Name | Dependencies | Description | +|-----------------------|--------------------------------|----------------------------------| +| BuildHelp | GenerateMarkdown, GenerateMAML | Build all help files | | StageFiles | Clean | Build module in output directory | -| GenerateMarkdown | StageFiles | Build markdown-based help | -| GenerateMAML | GenerateMarkdown | Build MAML help | -| GenerateUpdatableHelp | BuildHelp | Build updatable help cab | +| GenerateMarkdown | StageFiles | Build markdown-based help | +| GenerateMAML | GenerateMarkdown | Build MAML help | +| GenerateUpdatableHelp | BuildHelp | Build updatable help cab | ## Task customization @@ -119,10 +119,21 @@ match your environment. | $PSBPreference.Help.DefaultLocale | `(Get-UICulture).Name` | Default locale used for help generation | | $PSBPreference.Help.ConvertReadMeToAboutHelp | `$false` | Convert project readme into the module about file | | $PSBPreference.Docs.RootDir | `$projectRoot/docs` | Directory PlatyPS markdown documentation will be saved to | -| $PSBPreference.Docs.Overwrite | `$false` | Overwrite the markdown files in the docs folder using the comment based help as the source of truth. | +| $PSBPreference.Docs.Overwrite | `$false` | Overwrite the markdown files in the docs folder using the comment based help as the source of truth. | | $PSBPreference.Publish.PSRepository | `PSGallery` | PowerShell repository name to publish | | $PSBPreference.Publish.PSRepositoryApiKey | `$env:PSGALLERY_API_KEY` | API key to authenticate to PowerShell repository with | | $PSBPreference.Publish.PSRepositoryCredential | `$null` | Credential to authenticate to PowerShell repository with. Overrides `$psRepositoryApiKey` if defined | +| $PSBPreference.TaskDependencies.Clean | 'Init' | Tasks the 'Clean' task depends on. | +| $PSBPreference.TaskDependencies.StageFiles | 'Clean' | Tasks the 'StageFiles' task depends on. | +| $PSBPreference.TaskDependencies.Build | 'StageFiles', 'BuildHelp' | Tasks the 'Build' task depends on. | +| $PSBPreference.TaskDependencies.Analyze | 'Build' | Tasks the 'Analyze' task depends on. | +| $PSBPreference.TaskDependencies.Pester | 'Build' | Tasks the 'Pester' task depends on. | +| $PSBPreference.TaskDependencies.Test | 'Pester', 'Analyze' | Tasks the 'Test' task depends on. | +| $PSBPreference.TaskDependencies.BuildHelp | 'GenerateMarkdown', 'GenerateMAML' | Tasks the 'BuildHelp' task depends on. | +| $PSBPreference.TaskDependencies.GenerateMarkdown | 'StageFiles' | Tasks the 'GenerateMarkdown' task depends on. | +| $PSBPreference.TaskDependencies.GenerateMAML | 'GenerateMarkdown' | Tasks the 'GenerateMAML' task depends on. | +| $PSBPreference.TaskDependencies.GenerateUpdatableHelp | 'BuildHelp' | Tasks the 'GenerateUpdatableHelp' task depends on. | +| $PSBPreference.TaskDependencies.Publish | 'Test' | Tasks the 'Publish' task depends on. | ## Examples