Skip to content

Commit c1b2255

Browse files
🩹 [Patch]: Cleanup code that is managed in Build-PSModule (#14)
## Description This pull request includes changes to streamline the module requirements and clean up the script execution order in the PowerShell scripts. * Removed version specifications from the `#Requires -Modules` statements. * Deleted the block of code that builds local scripts, which included retrieving and executing build scripts in a specific order. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas
1 parent 24c651c commit c1b2255

File tree

4 files changed

+44
-57
lines changed

4 files changed

+44
-57
lines changed

scripts/helpers/Build-PSModuleDocumentation.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#Requires -Modules @{ ModuleName = 'GitHub'; ModuleVersion = '0.13.2' }
2-
#Requires -Modules @{ ModuleName = 'Utilities'; ModuleVersion = '0.3.0' }
1+
#Requires -Modules GitHub
2+
#Requires -Modules Utilities
33

44
function Build-PSModuleDocumentation {
55
<#

scripts/helpers/Import-PSModule.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Requires -Modules @{ ModuleName = 'Utilities'; ModuleVersion = '0.3.0' }
1+
#Requires -Modules Utilities
22

33
function Import-PSModule {
44
<#

scripts/helpers/Resolve-PSModuleDependency.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Requires -Modules @{ ModuleName = 'Retry'; ModuleVersion = '0.1.3' }
1+
#Requires -Modules Retry
22

33
function Resolve-PSModuleDependency {
44
<#

scripts/main.ps1

Lines changed: 40 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,40 @@
1-
#Requires -Modules Utilities
2-
3-
[CmdletBinding()]
4-
param()
5-
6-
$path = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers') | Get-Item | Resolve-Path -Relative
7-
LogGroup "Loading helper scripts from [$path]" {
8-
Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | Resolve-Path -Relative | ForEach-Object {
9-
Write-Host "$_"
10-
. $_
11-
}
12-
}
13-
14-
LogGroup 'Loading inputs' {
15-
$moduleName = ($env:GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) ? $env:GITHUB_REPOSITORY_NAME : $env:GITHUB_ACTION_INPUT_Name
16-
Write-Host "Module name: [$moduleName]"
17-
18-
$moduleSourceFolderPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_Path/$moduleName
19-
if (-not (Test-Path -Path $moduleSourceFolderPath)) {
20-
$moduleSourceFolderPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_Path
21-
}
22-
Write-Host "Source module path: [$moduleSourceFolderPath]"
23-
if (-not (Test-Path -Path $moduleSourceFolderPath)) {
24-
throw "Module path [$moduleSourceFolderPath] does not exist."
25-
}
26-
27-
$modulesOutputFolderPath = Join-Path $env:GITHUB_WORKSPACE $env:GITHUB_ACTION_INPUT_ModulesOutputPath
28-
Write-Host "Modules output path: [$modulesOutputFolderPath]"
29-
$docsOutputFolderPath = Join-Path $env:GITHUB_WORKSPACE $env:GITHUB_ACTION_INPUT_DocsOutputPath
30-
Write-Host "Docs output path: [$docsOutputFolderPath]"
31-
}
32-
33-
LogGroup 'Build local scripts' {
34-
Write-Host 'Execution order:'
35-
$scripts = Get-ChildItem -Filter '*build.ps1' -Recurse | Sort-Object -Property Name | Resolve-Path -Relative
36-
$scripts | ForEach-Object {
37-
Write-Host " - $_"
38-
}
39-
$scripts | ForEach-Object {
40-
LogGroup "Build local scripts - [$_]" {
41-
. $_
42-
}
43-
}
44-
}
45-
46-
$params = @{
47-
ModuleName = $moduleName
48-
ModuleSourceFolderPath = $moduleSourceFolderPath
49-
ModulesOutputFolderPath = $modulesOutputFolderPath
50-
DocsOutputFolderPath = $docsOutputFolderPath
51-
}
52-
53-
Build-PSModuleDocumentation @params
1+
#Requires -Modules Utilities
2+
3+
[CmdletBinding()]
4+
param()
5+
6+
$path = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers') | Get-Item | Resolve-Path -Relative
7+
LogGroup "Loading helper scripts from [$path]" {
8+
Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | Resolve-Path -Relative | ForEach-Object {
9+
Write-Host "$_"
10+
. $_
11+
}
12+
}
13+
14+
LogGroup 'Loading inputs' {
15+
$moduleName = ($env:GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) ? $env:GITHUB_REPOSITORY_NAME : $env:GITHUB_ACTION_INPUT_Name
16+
Write-Host "Module name: [$moduleName]"
17+
18+
$moduleSourceFolderPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_Path/$moduleName
19+
if (-not (Test-Path -Path $moduleSourceFolderPath)) {
20+
$moduleSourceFolderPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_Path
21+
}
22+
Write-Host "Source module path: [$moduleSourceFolderPath]"
23+
if (-not (Test-Path -Path $moduleSourceFolderPath)) {
24+
throw "Module path [$moduleSourceFolderPath] does not exist."
25+
}
26+
27+
$modulesOutputFolderPath = Join-Path $env:GITHUB_WORKSPACE $env:GITHUB_ACTION_INPUT_ModulesOutputPath
28+
Write-Host "Modules output path: [$modulesOutputFolderPath]"
29+
$docsOutputFolderPath = Join-Path $env:GITHUB_WORKSPACE $env:GITHUB_ACTION_INPUT_DocsOutputPath
30+
Write-Host "Docs output path: [$docsOutputFolderPath]"
31+
}
32+
33+
$params = @{
34+
ModuleName = $moduleName
35+
ModuleSourceFolderPath = $moduleSourceFolderPath
36+
ModulesOutputFolderPath = $modulesOutputFolderPath
37+
DocsOutputFolderPath = $docsOutputFolderPath
38+
}
39+
40+
Build-PSModuleDocumentation @params

0 commit comments

Comments
 (0)