Skip to content

Commit 0969771

Browse files
🩹 [Patch]: Improve workflow logging by changing Write-Verbose to Write-Host (#91)
## Description This pull request focuses on changing the logging method from `Write-Verbose` to `Write-Host` in various PowerShell scripts. As most of these log lines anyway would be under a log group, it didn't make sense anymore to require additional input to get to the logs. Logging method changes: * [`scripts/helpers/Build-PSModule.ps1`](diffhunk://#diff-c688e346ad60fbe881bd05b6a5dbc1cd712fdca0bf8b8527965db583af825fd9L35-R47): Replaced `Write-Verbose` with `Write-Host` for logging source paths, module source folder, module output folder, and docs output folder. * [`scripts/helpers/Build/Build-PSModuleBase.ps1`](diffhunk://#diff-1ab7417b36702be4629b208ad7dd9ec76f94998bb625c4810edda2f9b5dbddb8L35-R35): Replaced `Write-Verbose` with `Write-Host` for logging the copying of files. * [`scripts/helpers/Build/Build-PSModuleDocumentation.ps1`](diffhunk://#diff-dc95bfbd255c5bb79df192179e9cc5141ef230a8d82e80bc12fc6fefe6186fffL37-R37): Replaced `Write-Verbose` with `Write-Host` for logging module import, processing files, and finding script paths. [[1]](diffhunk://#diff-dc95bfbd255c5bb79df192179e9cc5141ef230a8d82e80bc12fc6fefe6186fffL37-R37) [[2]](diffhunk://#diff-dc95bfbd255c5bb79df192179e9cc5141ef230a8d82e80bc12fc6fefe6186fffL78-R94) * [`scripts/helpers/Build/Build-PSModuleManifest.ps1`](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L36-R93): Replaced `Write-Verbose` with `Write-Host` for logging various steps in building the module manifest, such as loading the manifest, setting module properties, and processing required modules. [[1]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L36-R93) [[2]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L108-R181) [[3]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L194-R208) [[4]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L226-R226) [[5]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L245-R251) [[6]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L277-R283) ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent ae49488 commit 0969771

13 files changed

+131
-131
lines changed

scripts/helpers/Build-PSModule.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ function Build-PSModule {
3232
)
3333

3434
LogGroup "Building module [$ModuleName]" {
35-
Write-Verbose "Source path: [$ModuleSourceFolderPath]"
35+
Write-Host "Source path: [$ModuleSourceFolderPath]"
3636
if (-not (Test-Path -Path $ModuleSourceFolderPath)) {
3737
Write-Error "Source folder not found at [$ModuleSourceFolderPath]"
3838
exit 1
3939
}
4040
$moduleSourceFolder = Get-Item -Path $ModuleSourceFolderPath
41-
Write-Verbose "Module source folder: [$moduleSourceFolder]"
41+
Write-Host "Module source folder: [$moduleSourceFolder]"
4242

4343
$moduleOutputFolder = New-Item -Path $ModulesOutputFolderPath -Name $ModuleName -ItemType Directory -Force
44-
Write-Verbose "Module output folder: [$moduleOutputFolder]"
44+
Write-Host "Module output folder: [$moduleOutputFolder]"
4545

4646
$docsOutputFolder = New-Item -Path $DocsOutputFolderPath -ItemType Directory -Force
47-
Write-Verbose "Docs output folder: [$docsOutputFolder]"
47+
Write-Host "Docs output folder: [$docsOutputFolder]"
4848
}
4949

5050
Build-PSModuleBase -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder

scripts/helpers/Build/Build-PSModuleBase.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Build-PSModuleBase {
3232
)
3333

3434
LogGroup 'Build base' {
35-
Write-Verbose "Copying files from [$ModuleSourceFolder] to [$ModuleOutputFolder]"
35+
Write-Host "Copying files from [$ModuleSourceFolder] to [$ModuleOutputFolder]"
3636
Copy-Item -Path "$ModuleSourceFolder\*" -Destination $ModuleOutputFolder -Recurse -Force -Verbose -Exclude "$ModuleName.psm1"
3737
New-Item -Path $ModuleOutputFolder -Name "$ModuleName.psm1" -ItemType File -Force -Verbose
3838
}

scripts/helpers/Build/Build-PSModuleDocumentation.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function Build-PSModuleDocumentation {
3434
LogGroup 'Build docs - Generate markdown help' {
3535
$ModuleName | Remove-Module -Force
3636
Import-Module -Name $ModuleName -Force -RequiredVersion '999.0.0'
37-
Write-Verbose ($ModuleName | Get-Module)
37+
Write-Host ($ModuleName | Get-Module)
3838
$null = New-MarkdownHelp -Module $ModuleName -OutputFolder $DocsOutputFolder -Force -Verbose
3939
}
4040

@@ -75,23 +75,23 @@ function Build-PSModuleDocumentation {
7575
$PublicFunctionsFolder = Join-Path $ModuleSourceFolder.FullName 'functions\public' | Get-Item
7676
Get-ChildItem -Path $DocsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
7777
$file = $_
78-
Write-Verbose "Processing: $file"
78+
Write-Host "Processing: $file"
7979

8080
# find the source code file that matches the markdown file
8181
$scriptPath = Get-ChildItem -Path $PublicFunctionsFolder -Recurse -Force | Where-Object { $_.Name -eq ($file.BaseName + '.ps1') }
82-
Write-Verbose "Found script path: $scriptPath"
82+
Write-Host "Found script path: $scriptPath"
8383
$docsFilePath = ($scriptPath.FullName).Replace($PublicFunctionsFolder.FullName, $DocsOutputFolder.FullName).Replace('.ps1', '.md')
84-
Write-Verbose "Doc file path: $docsFilePath"
84+
Write-Host "Doc file path: $docsFilePath"
8585
$docsFolderPath = Split-Path -Path $docsFilePath -Parent
8686
New-Item -Path $docsFolderPath -ItemType Directory -Force
8787
Move-Item -Path $file.FullName -Destination $docsFilePath -Force
8888
}
8989
# Get the MD files that are in the public functions folder and move them to the same place in the docs folder
9090
Get-ChildItem -Path $PublicFunctionsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
9191
$file = $_
92-
Write-Verbose "Processing: $file"
92+
Write-Host "Processing: $file"
9393
$docsFilePath = ($file.FullName).Replace($PublicFunctionsFolder.FullName, $DocsOutputFolder.FullName)
94-
Write-Verbose "Doc file path: $docsFilePath"
94+
Write-Host "Doc file path: $docsFilePath"
9595
$docsFolderPath = Split-Path -Path $docsFilePath -Parent
9696
New-Item -Path $docsFolderPath -ItemType Directory -Force
9797
Move-Item -Path $file.FullName -Destination $docsFilePath -Force

scripts/helpers/Build/Build-PSModuleManifest.ps1

Lines changed: 81 additions & 81 deletions
Large diffs are not rendered by default.

scripts/helpers/Build/Build-PSModuleRootModule.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = {
129129
$exports.Add('Function', (Get-PSModuleFunctionsToExport -SourceFolderPath $ModuleOutputFolder))
130130
$exports.Add('Variable', (Get-PSModuleVariablesToExport -SourceFolderPath $ModuleOutputFolder))
131131

132-
Write-Verbose ($exports | Out-String)
132+
Write-Host ($exports | Out-String)
133133
#endregion - Analyze source files
134134

135135
#region - Module header
@@ -223,7 +223,7 @@ Write-Debug "[`$scriptName] - $relativePath - Done"
223223

224224
$exportsString = Convert-HashtableToString -Hashtable $exports
225225

226-
Write-Verbose ($exportsString | Out-String)
226+
Write-Host ($exportsString | Out-String)
227227

228228
$params = @{
229229
Path = $rootModuleFile

scripts/helpers/Build/Get-PSModuleAliasesToExport.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525
$manifest = Get-ModuleManifest -Path $manifestFilePath -Verbose:$false
2626

27-
Write-Verbose "[$manifestPropertyName]"
27+
Write-Host "[$manifestPropertyName]"
2828
$aliasesToExport = (($manifest.AliasesToExport).count -eq 0) -or ($manifest.AliasesToExport | IsNullOrEmpty) ? '*' : $manifest.AliasesToExport
2929
$aliasesToExport | ForEach-Object {
30-
Write-Verbose "[$manifestPropertyName] - [$_]"
30+
Write-Host "[$manifestPropertyName] - [$_]"
3131
}
3232

3333
$aliasesToExport

scripts/helpers/Build/Get-PSModuleCmdletsToExport.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525
$manifest = Get-ModuleManifest -Path $manifestFilePath -Verbose:$false
2626

27-
Write-Verbose "[$manifestPropertyName]"
27+
Write-Host "[$manifestPropertyName]"
2828
$cmdletsToExport = (($manifest.CmdletsToExport).count -eq 0) -or ($manifest.CmdletsToExport | IsNullOrEmpty) ? '' : $manifest.CmdletsToExport
2929
$cmdletsToExport | ForEach-Object {
30-
Write-Verbose "[$manifestPropertyName] - [$_]"
30+
Write-Host "[$manifestPropertyName] - [$_]"
3131
}
3232

3333
$cmdletsToExport

scripts/helpers/Build/Get-PSModuleFunctionsToExport.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@
1919

2020
$manifestPropertyName = 'FunctionsToExport'
2121

22-
Write-Verbose "[$manifestPropertyName]"
23-
Write-Verbose "[$manifestPropertyName] - Checking path for functions and filters"
22+
Write-Host "[$manifestPropertyName]"
23+
Write-Host "[$manifestPropertyName] - Checking path for functions and filters"
2424

2525
$publicFolderPath = Join-Path -Path $SourceFolderPath -ChildPath 'functions/public'
2626
if (-not (Test-Path -Path $publicFolderPath -PathType Container)) {
27-
Write-Verbose "[$manifestPropertyName] - [Folder not found] - [$publicFolderPath]"
27+
Write-Host "[$manifestPropertyName] - [Folder not found] - [$publicFolderPath]"
2828
return $functionsToExport
2929
}
30-
Write-Verbose "[$manifestPropertyName] - [$publicFolderPath]"
30+
Write-Host "[$manifestPropertyName] - [$publicFolderPath]"
3131
$functionsToExport = [Collections.Generic.List[string]]::new()
3232
$scriptFiles = Get-ChildItem -Path $publicFolderPath -Recurse -File -ErrorAction SilentlyContinue -Include '*.ps1'
33-
Write-Verbose "[$manifestPropertyName] - [$($scriptFiles.Count)]"
33+
Write-Host "[$manifestPropertyName] - [$($scriptFiles.Count)]"
3434
foreach ($file in $scriptFiles) {
3535
$fileContent = Get-Content -Path $file.FullName -Raw
3636
$containsFunction = ($fileContent -match 'function ') -or ($fileContent -match 'filter ')
37-
Write-Verbose "[$manifestPropertyName] - [$($file.BaseName)] - [$containsFunction]"
37+
Write-Host "[$manifestPropertyName] - [$($file.BaseName)] - [$containsFunction]"
3838
if ($containsFunction) {
3939
$functionsToExport.Add($file.BaseName)
4040
}

scripts/helpers/Build/Get-PSModuleVariablesToExport.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
$manifestPropertyName = 'VariablesToExport'
2121

22-
Write-Verbose "[$manifestPropertyName]"
22+
Write-Host "[$manifestPropertyName]"
2323

2424
$variableFolderPath = Join-Path -Path $SourceFolderPath -ChildPath 'variables/public'
2525
if (-not (Test-Path -Path $variableFolderPath -PathType Container)) {
26-
Write-Verbose "[$manifestPropertyName] - [Folder not found] - [$variableFolderPath]"
26+
Write-Host "[$manifestPropertyName] - [Folder not found] - [$variableFolderPath]"
2727
return $variablesToExport
2828
}
2929
$scriptFilePaths = Get-ChildItem -Path $variableFolderPath -Recurse -File -Filter *.ps1 | Select-Object -ExpandProperty FullName
@@ -38,7 +38,7 @@
3838
}
3939

4040
$variablesToExport | ForEach-Object {
41-
Write-Verbose "[$manifestPropertyName] - [$_]"
41+
Write-Host "[$manifestPropertyName] - [$_]"
4242
}
4343

4444
$variablesToExport

scripts/helpers/Build/Import-PSModule.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
$manifestFilePath = Join-Path -Path $Path $manifestFileName
2828
$manifestFile = Get-ModuleManifest -Path $manifestFilePath -As FileInfo -Verbose
2929

30-
Write-Verbose "Manifest file path: [$($manifestFile.FullName)]" -Verbose
30+
Write-Host "Manifest file path: [$($manifestFile.FullName)]" -Verbose
3131
$existingModule = Get-Module -Name $ModuleName -ListAvailable
3232
$existingModule | Remove-Module -Force -Verbose
3333
$existingModule.RequiredModules | ForEach-Object { $_ | Remove-Module -Force -Verbose -ErrorAction SilentlyContinue }
@@ -36,11 +36,11 @@
3636
Resolve-PSModuleDependencies -ManifestFilePath $manifestFile
3737
Import-Module -Name $ModuleName -RequiredVersion '999.0.0'
3838

39-
Write-Verbose 'List loaded modules'
39+
Write-Host 'List loaded modules'
4040
$availableModules = Get-Module -ListAvailable -Refresh -Verbose:$false
4141
$availableModules | Select-Object Name, Version, Path | Sort-Object Name | Format-Table -AutoSize
42-
Write-Verbose 'List commands'
43-
Write-Verbose (Get-Command -Module $moduleName | Format-Table -AutoSize | Out-String)
42+
Write-Host 'List commands'
43+
Write-Host (Get-Command -Module $moduleName | Format-Table -AutoSize | Out-String)
4444

4545
if ($ModuleName -notin $availableModules.Name) {
4646
throw 'Module not found'

scripts/helpers/Build/Resolve-PSModuleDependency.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ function Resolve-PSModuleDependency {
2626
[string] $ManifestFilePath
2727
)
2828

29-
Write-Verbose 'Resolving dependencies'
29+
Write-Host 'Resolving dependencies'
3030

3131
$manifest = Import-PowerShellDataFile -Path $ManifestFilePath
32-
Write-Verbose "Reading [$ManifestFilePath]"
33-
Write-Verbose "Found [$($manifest.RequiredModules.Count)] modules to install"
32+
Write-Host "Reading [$ManifestFilePath]"
33+
Write-Host "Found [$($manifest.RequiredModules.Count)] modules to install"
3434

3535
foreach ($requiredModule in $manifest.RequiredModules) {
3636
$installParams = @{}
@@ -46,19 +46,19 @@ function Resolve-PSModuleDependency {
4646
$installParams.Force = $true
4747
$installParams.Verbose = $false
4848

49-
Write-Verbose "[$($installParams.Name)] - Installing module"
49+
Write-Host "[$($installParams.Name)] - Installing module"
5050
$VerbosePreferenceOriginal = $VerbosePreference
5151
$VerbosePreference = 'SilentlyContinue'
5252
Retry -Count 5 -Delay 10 {
5353
Install-Module @installParams -AllowPrerelease:$false
5454
}
5555
$VerbosePreference = $VerbosePreferenceOriginal
56-
Write-Verbose "[$($installParams.Name)] - Importing module"
56+
Write-Host "[$($installParams.Name)] - Importing module"
5757
$VerbosePreferenceOriginal = $VerbosePreference
5858
$VerbosePreference = 'SilentlyContinue'
5959
Import-Module @installParams
6060
$VerbosePreference = $VerbosePreferenceOriginal
61-
Write-Verbose "[$($installParams.Name)] - Done"
61+
Write-Host "[$($installParams.Name)] - Done"
6262
}
63-
Write-Verbose 'Resolving dependencies - Done'
63+
Write-Host 'Resolving dependencies - Done'
6464
}

scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ function Update-PSModuleManifestAliasesToExport {
2121
[Parameter(Mandatory)]
2222
[System.IO.DirectoryInfo] $ModuleOutputFolder
2323
)
24-
LogGroup "Updating aliases to export in module manifest" {
25-
Write-Verbose "Module name: [$ModuleName]"
26-
Write-Verbose "Module output folder: [$ModuleOutputFolder]"
24+
LogGroup 'Updating aliases to export in module manifest' {
25+
Write-Host "Module name: [$ModuleName]"
26+
Write-Host "Module output folder: [$ModuleOutputFolder]"
2727
$aliases = Get-Command -Module $ModuleName -CommandType Alias
28-
Write-Verbose "Found aliases: [$($aliases.Count)]"
28+
Write-Host "Found aliases: [$($aliases.Count)]"
2929
foreach ($alias in $aliases) {
30-
Write-Verbose "Alias: [$($alias.Name)]"
30+
Write-Host "Alias: [$($alias.Name)]"
3131
}
3232
$outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1"
33-
Write-Verbose "Output manifest path: [$outputManifestPath]"
34-
Write-Verbose "Setting module manifest with AliasesToExport"
35-
Set-ModuleManifest -Path $outputManifestPath -AliasesToExport $aliases.Name
33+
Write-Host "Output manifest path: [$outputManifestPath]"
34+
Write-Host 'Setting module manifest with AliasesToExport'
35+
Set-ModuleManifest -Path $outputManifestPath -AliasesToExport $aliases.Name -Verbose
3636
}
3737
}

scripts/main.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@ param()
66
$path = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers')
77
LogGroup "Loading helper scripts from [$path]" {
88
Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | ForEach-Object {
9-
Write-Verbose "[$($_.FullName)]"
9+
Write-Host "[$($_.FullName)]"
1010
. $_.FullName
1111
}
1212
}
1313

1414
LogGroup 'Loading inputs' {
1515
$moduleName = ($env:GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) ? $env:GITHUB_REPOSITORY_NAME : $env:GITHUB_ACTION_INPUT_Name
16-
Write-Verbose "Module name: [$moduleName]"
16+
Write-Host "Module name: [$moduleName]"
1717

1818
$moduleSourceFolderPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_Path $moduleName
1919
if (-not (Test-Path -Path $moduleSourceFolderPath)) {
2020
$moduleSourceFolderPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_Path
2121
}
22-
Write-Verbose "Source module path: [$moduleSourceFolderPath]"
22+
Write-Host "Source module path: [$moduleSourceFolderPath]"
2323
if (-not (Test-Path -Path $moduleSourceFolderPath)) {
2424
throw "Module path [$moduleSourceFolderPath] does not exist."
2525
}
2626

2727
$modulesOutputFolderPath = Join-Path $env:GITHUB_WORKSPACE $env:GITHUB_ACTION_INPUT_ModulesOutputPath
28-
Write-Verbose "Modules output path: [$modulesOutputFolderPath]"
28+
Write-Host "Modules output path: [$modulesOutputFolderPath]"
2929
$docsOutputFolderPath = Join-Path $env:GITHUB_WORKSPACE $env:GITHUB_ACTION_INPUT_DocsOutputPath
30-
Write-Verbose "Docs output path: [$docsOutputFolderPath]"
30+
Write-Host "Docs output path: [$docsOutputFolderPath]"
3131
}
3232

3333
$params = @{

0 commit comments

Comments
 (0)