Skip to content

Commit c66f337

Browse files
committed
chore: ✨ Update build tasks and add cspell configuration
* 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.
1 parent dcc2bb6 commit c66f337

File tree

8 files changed

+146
-111
lines changed

8 files changed

+146
-111
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## Unreleased
99

10-
### Breaking Changes
10+
### Changed
1111

1212
- [**#71**](https://github.com/psake/PowerShellBuild/pull/71) Compiled modules
1313
are now explicitly created as UTF-8 files.
1414
- [**#67**](https://github.com/psake/PowerShellBuild/pull/67) You can now
1515
overwrite existing markdown files using `$PSBPreference.Docs.Overwrite` and
1616
setting it to `$true`.
17+
- Loose dependencies by allowing them to be overwritten with $PSBPreference.
18+
- [**#71**](https://github.com/psake/PowerShellBuild/pull/71) Compiled modules
19+
are now explicitly created as UTF-8 files.
1720

1821
## [0.6.2] 2024-10-06
1922

PowerShellBuild/build.properties.ps1

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# spell-checker:ignore PSGALLERY BHPS MAML
12
BuildHelpers\Set-BuildEnvironment -Force
23

34
$outDir = [IO.Path]::Combine($env:BHProjectPath, 'Output')
@@ -22,7 +23,7 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul
2223
}
2324
Build = @{
2425

25-
Dependencies = @('StageFiles', 'BuildHelp')
26+
# "Dependencies" moved to TaskDependencies section
2627

2728
# Output directory when building a module
2829
OutDir = $outDir
@@ -98,7 +99,7 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul
9899
}
99100
}
100101
Help = @{
101-
# Path to updateable help CAB
102+
# Path to updatable help CAB
102103
UpdatableHelpOutDir = [IO.Path]::Combine($outDir, 'UpdatableHelp')
103104

104105
# Default Locale used for help generation, defaults to en-US
@@ -125,6 +126,19 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul
125126
# Credential to authenticate to PowerShell repository with
126127
PSRepositoryCredential = $null
127128
}
129+
TaskDependencies = @{
130+
Clean = @('Init')
131+
StageFiles = @('Clean')
132+
Build = @('StageFiles', 'BuildHelp')
133+
Analyze = @('Build')
134+
Pester = @('Build')
135+
Test = @('Pester', 'Analyze')
136+
BuildHelp = @('GenerateMarkdown', 'GenerateMAML')
137+
GenerateMarkdown = @('StageFiles')
138+
GenerateMAML = @('GenerateMarkdown')
139+
GenerateUpdatableHelp = @('BuildHelp')
140+
Publish = @('Test')
141+
}
128142
}
129143

130144
# Enable/disable generation of a catalog (.cat) file for the module.

PowerShellBuild/psakeFile.ps1

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Remove-Variable -Name PSBPreference -Scope Script -Force -ErrorAction Ignore
44
Set-Variable -Name PSBPreference -Option ReadOnly -Scope Script -Value (. ([IO.Path]::Combine($PSScriptRoot, 'build.properties.ps1')))
55

6-
properties {}
6+
Properties {}
77

88
FormatTaskName {
99
param($taskName)
@@ -15,24 +15,24 @@ FormatTaskName {
1515
# Can't have two 'default' tasks
1616
# Task default -depends Test
1717

18-
task Init {
18+
Task Init {
1919
Initialize-PSBuild -UseBuildHelpers -BuildEnvironment $PSBPreference
2020
} -description 'Initialize build environment variables'
2121

22-
task Clean -depends Init {
22+
Task Clean -depends $PSBPreference.TaskDependencies.Clean {
2323
Clear-PSBuildOutputFolder -Path $PSBPreference.Build.ModuleOutDir
2424
} -description 'Clears module output directory'
2525

26-
task StageFiles -depends Clean {
26+
Task StageFiles -depends $PSBPreference.TaskDependencies.StageFiles {
2727
$buildParams = @{
28-
Path = $PSBPreference.General.SrcRootDir
29-
ModuleName = $PSBPreference.General.ModuleName
30-
DestinationPath = $PSBPreference.Build.ModuleOutDir
31-
Exclude = $PSBPreference.Build.Exclude
32-
Compile = $PSBPreference.Build.CompileModule
33-
CompileDirectories = $PSBPreference.Build.CompileDirectories
34-
CopyDirectories = $PSBPreference.Build.CopyDirectories
35-
Culture = $PSBPreference.Help.DefaultLocale
28+
Path = $PSBPreference.General.SrcRootDir
29+
ModuleName = $PSBPreference.General.ModuleName
30+
DestinationPath = $PSBPreference.Build.ModuleOutDir
31+
Exclude = $PSBPreference.Build.Exclude
32+
Compile = $PSBPreference.Build.CompileModule
33+
CompileDirectories = $PSBPreference.Build.CompileDirectories
34+
CopyDirectories = $PSBPreference.Build.CopyDirectories
35+
Culture = $PSBPreference.Help.DefaultLocale
3636
}
3737

3838
if ($PSBPreference.Help.ConvertReadMeToAboutHelp) {
@@ -53,7 +53,7 @@ task StageFiles -depends Clean {
5353
Build-PSBuildModule @buildParams
5454
} -description 'Builds module based on source directory'
5555

56-
task Build -depends $PSBPreference.Build.Dependencies -description 'Builds module and generate help documentation'
56+
Task Build -depends $PSBPreference.TaskDependencies.Build -description 'Builds module and generate help documentation'
5757

5858
$analyzePreReqs = {
5959
$result = $true
@@ -67,11 +67,11 @@ $analyzePreReqs = {
6767
}
6868
$result
6969
}
70-
task Analyze -depends Build -precondition $analyzePreReqs {
70+
Task Analyze -depends $PSBPreference.TaskDependencies.Analyze -precondition $analyzePreReqs {
7171
$analyzeParams = @{
72-
Path = $PSBPreference.Build.ModuleOutDir
72+
Path = $PSBPreference.Build.ModuleOutDir
7373
SeverityThreshold = $PSBPreference.Test.ScriptAnalysis.FailBuildOnSeverityLevel
74-
SettingsPath = $PSBPreference.Test.ScriptAnalysis.SettingsPath
74+
SettingsPath = $PSBPreference.Test.ScriptAnalysis.SettingsPath
7575
}
7676
Test-PSBuildScriptAnalysis @analyzeParams
7777
} -description 'Execute PSScriptAnalyzer tests'
@@ -92,27 +92,27 @@ $pesterPreReqs = {
9292
}
9393
return $result
9494
}
95-
task Pester -depends Build -precondition $pesterPreReqs {
95+
Task Pester -depends $PSBPreference.TaskDependencies.Pester -precondition $pesterPreReqs {
9696
$pesterParams = @{
97-
Path = $PSBPreference.Test.RootDir
98-
ModuleName = $PSBPreference.General.ModuleName
99-
ModuleManifest = Join-Path $PSBPreference.Build.ModuleOutDir "$($PSBPreference.General.ModuleName).psd1"
100-
OutputPath = $PSBPreference.Test.OutputFile
101-
OutputFormat = $PSBPreference.Test.OutputFormat
102-
CodeCoverage = $PSBPreference.Test.CodeCoverage.Enabled
103-
CodeCoverageThreshold = $PSBPreference.Test.CodeCoverage.Threshold
104-
CodeCoverageFiles = $PSBPreference.Test.CodeCoverage.Files
105-
CodeCoverageOutputFile = $PSBPreference.Test.CodeCoverage.OutputFile
97+
Path = $PSBPreference.Test.RootDir
98+
ModuleName = $PSBPreference.General.ModuleName
99+
ModuleManifest = Join-Path $PSBPreference.Build.ModuleOutDir "$($PSBPreference.General.ModuleName).psd1"
100+
OutputPath = $PSBPreference.Test.OutputFile
101+
OutputFormat = $PSBPreference.Test.OutputFormat
102+
CodeCoverage = $PSBPreference.Test.CodeCoverage.Enabled
103+
CodeCoverageThreshold = $PSBPreference.Test.CodeCoverage.Threshold
104+
CodeCoverageFiles = $PSBPreference.Test.CodeCoverage.Files
105+
CodeCoverageOutputFile = $PSBPreference.Test.CodeCoverage.OutputFile
106106
CodeCoverageOutputFileFormat = $PSBPreference.Test.CodeCoverage.OutputFileFormat
107-
ImportModule = $PSBPreference.Test.ImportModule
107+
ImportModule = $PSBPreference.Test.ImportModule
108108
}
109109
Test-PSBuildPester @pesterParams
110110
} -description 'Execute Pester tests'
111111

112-
task Test -depends Pester, Analyze {
112+
Task Test -depends $PSBPreference.TaskDependencies.Test {
113113
} -description 'Execute Pester and ScriptAnalyzer tests'
114114

115-
task BuildHelp -depends GenerateMarkdown, GenerateMAML {} -description 'Builds help documentation'
115+
Task BuildHelp -depends $PSBPreference.TaskDependencies.BuildHelp {} -description 'Builds help documentation'
116116

117117
$genMarkdownPreReqs = {
118118
$result = $true
@@ -122,13 +122,13 @@ $genMarkdownPreReqs = {
122122
}
123123
$result
124124
}
125-
task GenerateMarkdown -depends StageFiles -precondition $genMarkdownPreReqs {
125+
Task GenerateMarkdown -depends $PSBPreference.TaskDependencies.GenerateMarkdown -precondition $genMarkdownPreReqs {
126126
$buildMDParams = @{
127127
ModulePath = $PSBPreference.Build.ModuleOutDir
128128
ModuleName = $PSBPreference.General.ModuleName
129-
DocsPath = $PSBPreference.Docs.RootDir
130-
Locale = $PSBPreference.Help.DefaultLocale
131-
Overwrite = $PSBPreference.Docs.Overwrite
129+
DocsPath = $PSBPreference.Docs.RootDir
130+
Locale = $PSBPreference.Help.DefaultLocale
131+
Overwrite = $PSBPreference.Docs.Overwrite
132132
}
133133
Build-PSBuildMarkdown @buildMDParams
134134
} -description 'Generates PlatyPS markdown files from module help'
@@ -141,7 +141,7 @@ $genHelpFilesPreReqs = {
141141
}
142142
$result
143143
}
144-
task GenerateMAML -depends GenerateMarkdown -precondition $genHelpFilesPreReqs {
144+
Task GenerateMAML -depends $PSBPreference.TaskDependencies.GenerateMAML -precondition $genHelpFilesPreReqs {
145145
Build-PSBuildMAMLHelp -Path $PSBPreference.Docs.RootDir -DestinationPath $PSBPreference.Build.ModuleOutDir
146146
} -description 'Generates MAML-based help from PlatyPS markdown files'
147147

@@ -153,18 +153,18 @@ $genUpdatableHelpPreReqs = {
153153
}
154154
$result
155155
}
156-
task GenerateUpdatableHelp -depends BuildHelp -precondition $genUpdatableHelpPreReqs {
156+
Task GenerateUpdatableHelp -depends $PSBPreference.TaskDependencies.GenerateUpdatableHelp -precondition $genUpdatableHelpPreReqs {
157157
Build-PSBuildUpdatableHelp -DocsPath $PSBPreference.Docs.RootDir -OutputPath $PSBPreference.Help.UpdatableHelpOutDir
158158
} -description 'Create updatable help .cab file based on PlatyPS markdown help'
159159

160-
task Publish -depends Test {
160+
Task Publish -depends $PSBPreference.TaskDependencies.Publish {
161161
Assert -conditionToCheck ($PSBPreference.Publish.PSRepositoryApiKey -or $PSBPreference.Publish.PSRepositoryCredential) -failureMessage "API key or credential not defined to authenticate with [$($PSBPreference.Publish.PSRepository)] with."
162162

163163
$publishParams = @{
164-
Path = $PSBPreference.Build.ModuleOutDir
165-
Version = $PSBPreference.General.ModuleVersion
164+
Path = $PSBPreference.Build.ModuleOutDir
165+
Version = $PSBPreference.General.ModuleVersion
166166
Repository = $PSBPreference.Publish.PSRepository
167-
Verbose = $VerbosePreference
167+
Verbose = $VerbosePreference
168168
}
169169
if ($PSBPreference.Publish.PSRepositoryApiKey) {
170170
$publishParams.ApiKey = $PSBPreference.Publish.PSRepositoryApiKey
@@ -177,7 +177,7 @@ task Publish -depends Test {
177177
Publish-PSBuildModule @publishParams
178178
} -description 'Publish module to the defined PowerShell repository'
179179

180-
task ? -description 'Lists the available tasks' {
180+
Task ? -description 'Lists the available tasks' {
181181
'Available tasks:'
182182
$psake.context.Peek().Tasks.Keys | Sort-Object
183183
}

build.ps1

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,22 @@ param(
33
# Build task(s) to execute
44
[parameter(ParameterSetName = 'task', position = 0)]
55
[ArgumentCompleter( {
6-
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams)
7-
$psakeFile = './psakeFile.ps1'
8-
switch ($Parameter) {
9-
'Task' {
10-
if ([string]::IsNullOrEmpty($WordToComplete)) {
11-
Get-PSakeScriptTasks -buildFile $psakeFile | Select-Object -ExpandProperty Name
6+
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams)
7+
$psakeFile = './psakeFile.ps1'
8+
switch ($Parameter) {
9+
'Task' {
10+
if ([string]::IsNullOrEmpty($WordToComplete)) {
11+
Get-PSakeScriptTasks -buildFile $psakeFile | Select-Object -ExpandProperty Name
12+
} else {
13+
Get-PSakeScriptTasks -buildFile $psakeFile |
14+
Where-Object { $_.Name -match $WordToComplete } |
15+
Select-Object -ExpandProperty Name
16+
}
1217
}
13-
else {
14-
Get-PSakeScriptTasks -buildFile $psakeFile |
15-
Where-Object { $_.Name -match $WordToComplete } |
16-
Select-Object -ExpandProperty Name
18+
default {
1719
}
1820
}
19-
Default {
20-
}
21-
}
22-
})]
21+
})]
2322
[string[]]$Task = 'default',
2423

2524
# Bootstrap dependencies
@@ -36,10 +35,10 @@ $ErrorActionPreference = 'Stop'
3635

3736
# Bootstrap dependencies
3837
if ($Bootstrap.IsPresent) {
39-
Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null
38+
PackageManagement\Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null
4039
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
4140
if (-not (Get-Module -Name PSDepend -ListAvailable)) {
42-
Install-module -Name PSDepend -Repository PSGallery
41+
Install-Module -Name PSDepend -Repository PSGallery
4342
}
4443
Import-Module -Name PSDepend -Verbose:$false
4544
Invoke-PSDepend -Path './requirements.psd1' -Install -Import -Force -WarningAction SilentlyContinue
@@ -48,7 +47,7 @@ if ($Bootstrap.IsPresent) {
4847
# Execute psake task(s)
4948
$psakeFile = './psakeFile.ps1'
5049
if ($PSCmdlet.ParameterSetName -eq 'Help') {
51-
Get-PSakeScriptTasks -buildFile $psakeFile |
50+
Get-PSakeScriptTasks -buildFile $psakeFile |
5251
Format-Table -Property Name, Description, Alias, DependsOn
5352
} else {
5453
Set-BuildEnvironment -Force

cspell.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.2",
3+
"ignorePaths": [],
4+
"dictionaryDefinitions": [],
5+
"dictionaries": [
6+
"powershell",
7+
"csharp",
8+
"json",
9+
"xml",
10+
"markdown"
11+
],
12+
"words": [],
13+
"ignoreWords": [
14+
"psake",
15+
"MAML"
16+
],
17+
"import": []
18+
}

requirements.psd1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
PSDependOptions = @{
33
Target = 'CurrentUser'
44
}
5-
BuildHelpers = '2.0.16'
6-
Pester = @{
5+
BuildHelpers = '2.0.16'
6+
Pester = @{
77
MinimumVersion = '5.6.1'
88
Parameters = @{
99
SkipPublisherCheck = $true
1010
}
1111
}
12-
psake = '4.9.0'
13-
PSScriptAnalyzer = '1.19.1'
14-
InvokeBuild = '5.8.1'
15-
platyPS = '0.14.2'
12+
psake = '4.9.0'
13+
PSScriptAnalyzer = '1.24.0'
14+
InvokeBuild = '5.8.1'
15+
platyPS = '0.14.2'
1616
}

tests/TestModule/.build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ Import-Module ../../Output/PowerShellBuild -Force
33

44
$PSBPreference.Build.CompileModule = $true
55

6-
task Build $PSBPreference.build.dependencies
6+
Task Build $PSBPreference.TaskDependencies.Build
77

8-
task . Build
8+
Task . Build

0 commit comments

Comments
 (0)