Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ jobs:
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: ./build/build.ps1 -Task Analyze, Test, Build, Publish -NuGetApiKey $env:NUGET_API_KEY

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: output/MEMZone.WriteLog/**/*
31 changes: 29 additions & 2 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
- Test : Run Pester unit and integration tests.
- Build : Compile module into a single-file .psm1 in the output directory.
- Publish : Publish the module to the PowerShell Gallery (requires -NuGetApiKey).
.PARAMETER VersionBump
Bump the module version before building. Accepted values: Major, Minor, Patch.
Default: Patch. Updates the ModuleVersion in the source .psd1 manifest.
.PARAMETER NuGetApiKey
API key for publishing to the PowerShell Gallery. Required for the Publish task.
Store securely and never commit to source control.
Expand All @@ -18,6 +21,9 @@
.EXAMPLE
./build.ps1
Runs Analyze and Test tasks with default settings.
.EXAMPLE
./build.ps1 -Task Build -VersionBump Minor
Bumps the minor version and compiles the module.
.EXAMPLE
./build.ps1 -Task Build
Compiles the module into a single-file build.
Expand All @@ -30,6 +36,9 @@ param (
[ValidateSet('Analyze', 'Test', 'Build', 'Publish')]
[string[]]$Task = @('Analyze', 'Test'),

[ValidateSet('Major', 'Minor', 'Patch')]
[string]$VersionBump = 'Patch',

[string]$NuGetApiKey,

[string]$OutputPath = (Join-Path -Path $PSScriptRoot -ChildPath '../output/MEMZone.WriteLog')
Expand Down Expand Up @@ -108,8 +117,23 @@ if ('Build' -in $Task) {
}
$null = New-Item -Path $OutputPath -ItemType Directory -Force

## Bump version in the source manifest if requested
[string]$ManifestPath = Join-Path -Path $ModuleSourcePath -ChildPath "$ModuleName.psd1"
if ($VersionBump) {
$ManifestData = Import-PowerShellDataFile -Path $ManifestPath
[version]$OldVersion = $ManifestData.ModuleVersion
[version]$NewVersion = switch ($VersionBump) {
'Major' { [version]::new($OldVersion.Major + 1, 0, 0) }
'Minor' { [version]::new($OldVersion.Major, $OldVersion.Minor + 1, 0) }
'Patch' { [version]::new($OldVersion.Major, $OldVersion.Minor, $OldVersion.Build + 1) }
}
(Get-Content -Path $ManifestPath -Raw) -replace "ModuleVersion\s*=\s*'$OldVersion'", "ModuleVersion = '$NewVersion'" |
Set-Content -Path $ManifestPath -Encoding UTF8 -NoNewline
Write-Host " Version bump: $OldVersion -> $NewVersion" -ForegroundColor Yellow
}

## Read the manifest to get version info
$ManifestData = Import-PowerShellDataFile -Path (Join-Path -Path $ModuleSourcePath -ChildPath "$ModuleName.psd1")
$ManifestData = Import-PowerShellDataFile -Path $ManifestPath
Write-Host " Building $ModuleName v$($ManifestData.ModuleVersion)" -ForegroundColor Yellow

## Compile all function files into a single .psm1 for distribution performance
Expand All @@ -120,7 +144,10 @@ if ('Build' -in $Task) {
$SectionDivider = "##*============================================="
$HeaderMatch = [regex]::Match($SourcePsm1, '(?s)\A.*?##\*\s*END MODULE STATE\s*\r?\n##\*=+')
if ($HeaderMatch.Success) {
[void]$CompiledContent.AppendLine($HeaderMatch.Value)
## Update Module Version and Last Modified in the header
[string]$HeaderContent = $HeaderMatch.Value -replace '(?<=Module Version:\s*)[\d.]+', $ManifestData.ModuleVersion
$HeaderContent = $HeaderContent -replace '(?<=Last Modified:\s*)[\d-]+', (Get-Date -Format 'yyyy-MM-dd')
[void]$CompiledContent.AppendLine($HeaderContent)
[void]$CompiledContent.AppendLine()
}

Expand Down
22 changes: 22 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ All notable changes to the **MEMZone.WriteLog** module will be documented in thi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.8] - 2026-03-27

### Changed

- `[BREAKING]` Renamed module from `PSWriteLog` to `MEMZone.WriteLog`.
- `[BREAKING]` Renamed `Initialize-PSWriteLog` to `Initialize-WriteLog`.
- Build script auto-increments patch version by default; use `-VersionBump Minor` or `-VersionBump Major` to override.

### Added

- Automatic GitHub Release creation on tag push.
- `VersionBump` parameter in build script (`Major`, `Minor`, `Patch`) to auto-update the manifest version.
- `Last Modified` date in compiled module header, auto-set at build time.
- `Module Version` in compiled module header, auto-synced from manifest at build time.

### Fixed

- Single-character table cell values (e.g. ✓, ✗) are now centered within the column.
- `Write-LogBuffer` no longer warns on module import when log path is not yet initialized.
- Pester `PassThru` configuration for reliable test result reporting.
- GitHub Actions upgraded to Node.js 24 (`actions/checkout@v5`, `actions/upload-artifact@v5`).

## [1.0.0] - 2025-01-14

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/MEMZone.WriteLog/MEMZone.WriteLog.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RootModule = 'MEMZone.WriteLog.psm1'

# Version number of this module (SemVer)
ModuleVersion = '2.0.0'
ModuleVersion = '2.0.8'

# Supported PSEditions
CompatiblePSEditions = @('Desktop', 'Core')
Expand Down
1 change: 1 addition & 0 deletions src/MEMZone.WriteLog/MEMZone.WriteLog.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.NOTES
Author: Ioan Popovici
Creation Date: 2025-01-14
Last Modified: 2025-01-14
Module Version: 1.0.0
.LINK
https://MEM.Zone
Expand Down
7 changes: 7 additions & 0 deletions src/MEMZone.WriteLog/Public/Format-Message.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ function Format-Message {
# Format the value
$FormattedValue = if ($null -eq $Value) { '' } else { $Value.ToString() }
}
# Center single-character values (e.g. status indicators) within the column
[int]$ColWidth = $ColumnWidths[$Counter]
if ($FormattedValue.Length -eq 1 -and $ColWidth -gt 1) {
[int]$LeftPad = [Math]::Floor(($ColWidth - $FormattedValue.Length) / 2)
[int]$RightPad = $ColWidth - $FormattedValue.Length - $LeftPad
$FormattedValue = (' ' * $LeftPad) + $FormattedValue + (' ' * $RightPad)
}
# Add padding if requested
if ($CellPadding -gt 0) { $RowData += (' ' * $CellPadding) + $FormattedValue + (' ' * $CellPadding) }
else { $RowData += $FormattedValue }
Expand Down
2 changes: 1 addition & 1 deletion src/MEMZone.WriteLog/Public/Write-LogBuffer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Write-LogBuffer {
[string[]]$LogEntries = $Script:LogBuffer.ToArray()

## Append to log file
if ($null -ne $Script:LogFullName -and (Test-Path -Path (Split-Path -Path $Script:LogFullName -Parent) -PathType Container)) {
if (-not [string]::IsNullOrEmpty($Script:LogFullName) -and (Test-Path -Path (Split-Path -Path $Script:LogFullName -Parent) -PathType Container)) {
Add-Content -Path $Script:LogFullName -Value $LogEntries -Encoding UTF8 -ErrorAction Stop
}

Expand Down
Loading