Skip to content

Commit 5f85aba

Browse files
Loosen Dependencies (#72)
* 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. ## Related Issue Resolves #12 ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> ## How Has This Been Tested? Verified that existing tests continue to pass. ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] My code follows the code style of this project. - [x] I have updated the documentation accordingly. - [x] I have added this change to the CHANGELOG.md. - [x] I have read the **CONTRIBUTING** document. - [ ] I have added tests to cover my changes. - [x] All new and existing tests passed.
1 parent dcc2bb6 commit 5f85aba

File tree

10 files changed

+166
-115
lines changed

10 files changed

+166
-115
lines changed

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
"editor.insertSpaces": true,
33
"files.trimTrailingWhitespace": true,
44
"files.insertFinalNewline": true,
5-
"powershell.codeFormatting.preset": "OTBS"
5+
"powershell.codeFormatting.preset": "OTBS",
6+
"powershell.codeFormatting.addWhitespaceAroundPipe": true,
7+
"powershell.codeFormatting.useCorrectCasing": true,
8+
"powershell.codeFormatting.newLineAfterOpenBrace": true,
9+
"powershell.codeFormatting.alignPropertyValuePairs": true
610
}

CHANGELOG.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ 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+
- [**#72**](https://github.com/psake/PowerShellBuild/pull/72) Loosen
19+
dependencies by allowing them to be overwritten with
20+
`$PSBPreference.TaskDependencies`.
1721

1822
## [0.6.2] 2024-10-06
1923

@@ -133,13 +137,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
133137
'Public' folder when dot sourcing functions in PSM1 (via
134138
[@pauby](https://github.com/pauby))
135139

136-
### Changed
137-
138-
- [**#19**](https://github.com/psake/PowerShellBuild/pull/19) Allow the
139-
`BHBuildOutput` environment variable defined by `BuildHelpers` to be set via
140-
the `$PSBPreference.Build.ModuleOutDir` property of the build tasks (via
141-
[@pauby](https://github.com/pauby))
142-
143140
### Breaking changes
144141

145142
- Refactor build properties into a single hashtable `$PSBPreference`
@@ -150,6 +147,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
150147
tasks are now auto-generated from the psake tasks via a converter script (via
151148
[@JustinGrote](https://github.com/JustinGrote))
152149

150+
- [**#19**](https://github.com/psake/PowerShellBuild/pull/19) Allow the
151+
`BHBuildOutput` environment variable defined by `BuildHelpers` to be set via
152+
the `$PSBPreference.Build.ModuleOutDir` property of the build tasks (via
153+
[@pauby](https://github.com/pauby))
154+
153155
## [0.2.0] - 2018-11-15
154156

155157
### Added
@@ -170,3 +172,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
170172
### Added
171173

172174
- Initial commit
175+
176+
<!--spell-checker:ignore IMJLA webtroter joshooaj pauby joeypiccola nightroman -->

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: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
1+
# spell-checker:ignore Reqs
22
# Load in build settings
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,7 +67,7 @@ $analyzePreReqs = {
6767
}
6868
$result
6969
}
70-
task Analyze -depends Build -precondition $analyzePreReqs {
70+
Task Analyze -depends $PSBPreference.TaskDependencies.Analyze -precondition $analyzePreReqs {
7171
$analyzeParams = @{
7272
Path = $PSBPreference.Build.ModuleOutDir
7373
SeverityThreshold = $PSBPreference.Test.ScriptAnalysis.FailBuildOnSeverityLevel
@@ -92,7 +92,7 @@ $pesterPreReqs = {
9292
}
9393
return $result
9494
}
95-
task Pester -depends Build -precondition $pesterPreReqs {
95+
Task Pester -depends $PSBPreference.TaskDependencies.Pester -precondition $pesterPreReqs {
9696
$pesterParams = @{
9797
Path = $PSBPreference.Test.RootDir
9898
ModuleName = $PSBPreference.General.ModuleName
@@ -109,10 +109,10 @@ task Pester -depends Build -precondition $pesterPreReqs {
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,7 +122,7 @@ $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
@@ -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,11 +153,11 @@ $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 = @{
@@ -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
}

README.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PowerShellBuild
22

3-
| GitHub Actions | PS Gallery | License |
4-
|----------------|------------|---------|
3+
| GitHub Actions | PS Gallery | License |
4+
|-------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|--------------------------------------|
55
| [![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] |
66

77
This project aims to provide common [psake](https://github.com/psake/psake) and
@@ -53,28 +53,28 @@ other projects.
5353
These primary tasks are the main tasks you'll typically call as part of
5454
PowerShell module development.
5555

56-
| Name | Dependencies | Description |
57-
| --------------------- | --------------------- | ----------- |
58-
| Init | _none_ | Initialize psake and task variables |
59-
| Clean | init | Clean output directory |
60-
| Build | StageFiles, BuildHelp | Clean and build module in output directory |
61-
| Analyze | Build | Run PSScriptAnalyzer tests |
62-
| Pester | Build | Run Pester tests |
63-
| Test | Analyze, Pester | Run combined tests |
64-
| Publish | Test | Publish module to defined PowerShell repository |
56+
| Name | Dependencies | Description |
57+
|---------|-----------------------|-------------------------------------------------|
58+
| Init | _none_ | Initialize psake and task variables |
59+
| Clean | init | Clean output directory |
60+
| Build | StageFiles, BuildHelp | Clean and build module in output directory |
61+
| Analyze | Build | Run PSScriptAnalyzer tests |
62+
| Pester | Build | Run Pester tests |
63+
| Test | Analyze, Pester | Run combined tests |
64+
| Publish | Test | Publish module to defined PowerShell repository |
6565

6666
### Secondary Tasks
6767

6868
These secondary tasks are called as dependencies from the primary tasks but may
6969
also be called directly.
7070

71-
| Name | Dependencies | Description |
72-
| --------------------- | -------------------------------| ----------- |
73-
| BuildHelp | GenerateMarkdown, GenerateMAML | Build all help files |
71+
| Name | Dependencies | Description |
72+
|-----------------------|--------------------------------|----------------------------------|
73+
| BuildHelp | GenerateMarkdown, GenerateMAML | Build all help files |
7474
| StageFiles | Clean | Build module in output directory |
75-
| GenerateMarkdown | StageFiles | Build markdown-based help |
76-
| GenerateMAML | GenerateMarkdown | Build MAML help |
77-
| GenerateUpdatableHelp | BuildHelp | Build updatable help cab |
75+
| GenerateMarkdown | StageFiles | Build markdown-based help |
76+
| GenerateMAML | GenerateMarkdown | Build MAML help |
77+
| GenerateUpdatableHelp | BuildHelp | Build updatable help cab |
7878

7979
## Task customization
8080

@@ -119,10 +119,21 @@ match your environment.
119119
| $PSBPreference.Help.DefaultLocale | `(Get-UICulture).Name` | Default locale used for help generation |
120120
| $PSBPreference.Help.ConvertReadMeToAboutHelp | `$false` | Convert project readme into the module about file |
121121
| $PSBPreference.Docs.RootDir | `$projectRoot/docs` | Directory PlatyPS markdown documentation will be saved to |
122-
| $PSBPreference.Docs.Overwrite | `$false` | Overwrite the markdown files in the docs folder using the comment based help as the source of truth. |
122+
| $PSBPreference.Docs.Overwrite | `$false` | Overwrite the markdown files in the docs folder using the comment based help as the source of truth. |
123123
| $PSBPreference.Publish.PSRepository | `PSGallery` | PowerShell repository name to publish |
124124
| $PSBPreference.Publish.PSRepositoryApiKey | `$env:PSGALLERY_API_KEY` | API key to authenticate to PowerShell repository with |
125125
| $PSBPreference.Publish.PSRepositoryCredential | `$null` | Credential to authenticate to PowerShell repository with. Overrides `$psRepositoryApiKey` if defined |
126+
| $PSBPreference.TaskDependencies.Clean | 'Init' | Tasks the 'Clean' task depends on. |
127+
| $PSBPreference.TaskDependencies.StageFiles | 'Clean' | Tasks the 'StageFiles' task depends on. |
128+
| $PSBPreference.TaskDependencies.Build | 'StageFiles', 'BuildHelp' | Tasks the 'Build' task depends on. |
129+
| $PSBPreference.TaskDependencies.Analyze | 'Build' | Tasks the 'Analyze' task depends on. |
130+
| $PSBPreference.TaskDependencies.Pester | 'Build' | Tasks the 'Pester' task depends on. |
131+
| $PSBPreference.TaskDependencies.Test | 'Pester', 'Analyze' | Tasks the 'Test' task depends on. |
132+
| $PSBPreference.TaskDependencies.BuildHelp | 'GenerateMarkdown', 'GenerateMAML' | Tasks the 'BuildHelp' task depends on. |
133+
| $PSBPreference.TaskDependencies.GenerateMarkdown | 'StageFiles' | Tasks the 'GenerateMarkdown' task depends on. |
134+
| $PSBPreference.TaskDependencies.GenerateMAML | 'GenerateMarkdown' | Tasks the 'GenerateMAML' task depends on. |
135+
| $PSBPreference.TaskDependencies.GenerateUpdatableHelp | 'BuildHelp' | Tasks the 'GenerateUpdatableHelp' task depends on. |
136+
| $PSBPreference.TaskDependencies.Publish | 'Test' | Tasks the 'Publish' task depends on. |
126137

127138
## Examples
128139

0 commit comments

Comments
 (0)