From 2019b688fc347132b94483caff7daeb82b39e2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Wed, 17 Jun 2026 09:30:21 +0200 Subject: [PATCH 01/25] feat(include): add version and date to include file output --- public/listIncludes.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/listIncludes.ps1 b/public/listIncludes.ps1 index d60ab72..0bab16d 100644 --- a/public/listIncludes.ps1 +++ b/public/listIncludes.ps1 @@ -70,11 +70,15 @@ function Get-IncludeFile{ $items = Get-ChildItem -Path $path -Filter "*$Filter*" -File -ErrorAction SilentlyContinue | ForEach-Object { + $version = Get-IncludeFileVersion -Path $_.FullName + [PSCustomObject]@{ Name = Compress-FileNameTransformation -FileName $_.Name -SourceModulePath $ModuleRootPath FolderName = $FolderName ModuleName = $moduleName Path = $_.FullName + Version = $version.Version + Date = $version.Date } } if ($items.Count -ne 0) { From ae434eaa21ad238d4452582b24c889495232a57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Thu, 18 Jun 2026 14:28:46 +0200 Subject: [PATCH 02/25] chore(header): update version and date in MyWrite.ps1 --- include/MyWrite.ps1 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/MyWrite.ps1 b/include/MyWrite.ps1 index 607b4ac..34f8c69 100644 --- a/include/MyWrite.ps1 +++ b/include/MyWrite.ps1 @@ -1,6 +1,6 @@ -# {"Version":"1.0.2","Date":"2026-06-16","HeaderVersion":1} +# {"Version":"1.2.0","Date":"2026-06-18","Source":"include","HeaderVersion":1} # DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE. -# + # Include MyWrite.ps1 # Provides Write-MyError, Write-MyWarning, Write-MyVerbose, Write-MyHost, Write-MyDebug # and Test-MyVerbose, Test-MyDebug functions for consistent logging and debugging output. @@ -67,7 +67,7 @@ function Clear-MyHost { [CmdletBinding()] param() -© # If debug do not clear host page + # If debug do not clear host page if (-not (Test-MyDebug -section "donotclearhost")) { Clear-Host } @@ -256,7 +256,8 @@ function Enable-ModuleNameDebug{ param( [Parameter(Position = 0)][string[]]$Sections, [Parameter()][string[]]$AddSections, - [Parameter()][string]$LoggingFilePath + [Parameter()][string]$LoggingFilePath, + [Parameter()][switch]$DoNotClearHost ) # Check if logging file path is provided @@ -269,6 +270,10 @@ function Enable-ModuleNameDebug{ } } + if($DoNotClearHost){ + $sectons += "donotclearhost" + } + $sectionsString = $sections -join " " $addedFlagsString = $AddSections -join " " From 570da8f005f98853b742e89e8b43c0ff4789e28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Thu, 18 Jun 2026 17:43:11 +0200 Subject: [PATCH 03/25] fix(datehelper): update command aliases for date retrieval functions --- include/datehelper.ps1 | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/include/datehelper.ps1 b/include/datehelper.ps1 index 97f5cd2..6ecb80d 100644 --- a/include/datehelper.ps1 +++ b/include/datehelper.ps1 @@ -1,3 +1,5 @@ +# {"Version":"1.0.0","Date":"2026-06-18","Source":"IncludeHelper","HeaderVersion":1} +# DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE. # DATE HELPER # @@ -9,8 +11,23 @@ # - Getting current date and time (with Invoke-MyCommand pattern for testability) # -Set-MyInvokeCommandAlias -Alias GetNow -Command "Get-Date -Format 'yyyy-MM-dd'" +Set-MyInvokeCommandAlias -Alias GetNowString -Command "Get-Date -Format 'yyyy-MM-dd'" Set-MyInvokeCommandAlias -Alias GetUtcNow -Command "Get-Date -AsUTC" +Set-MyInvokeCommandAlias -Alias GetNow -Command "Get-Date" + + +function Get-DateString{ + [CmdletBinding()] + param( + [Parameter(Position = 0)][DateTime]$Date + ) + + $date = $Date ?? (Invoke-MyCommand -Command GetNow) + + $datestring = $date.ToString("yyyy-MM-dd") + + return $datestring +} function Get-DaysBetweenDates { [CmdletBinding()] @@ -20,7 +37,7 @@ function Get-DaysBetweenDates { ) if ([string]::IsNullOrWhiteSpace($StartDate)) { - $StartDate = Invoke-MyCommand -Command GetNow + $StartDate = Invoke-MyCommand -Command GetNowString } $start = [DateTime]::ParseExact($StartDate, 'yyyy-MM-dd', $null) @@ -69,4 +86,4 @@ function ConvertTo-EpochTime { $timeSpan = $DateTime.ToUniversalTime() - $epoch return [long]$timeSpan.TotalSeconds -} +} \ No newline at end of file From 341cfec311917190ad84bea0e155f3856542c617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Fri, 19 Jun 2026 06:14:47 +0200 Subject: [PATCH 04/25] feat(versioning): implement version header management for include files --- public/addIncludeToWorkspace.ps1 | 27 ++++++++++++++--- public/githelper.ps1 | 50 ++++++++++++++++++++++++++++++++ public/listIncludes.ps1 | 13 ++++++++- public/setfileversion.ps1 | 40 +++++++++++++++---------- 4 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 public/githelper.ps1 diff --git a/public/addIncludeToWorkspace.ps1 b/public/addIncludeToWorkspace.ps1 index 0e1d968..9d0175d 100644 --- a/public/addIncludeToWorkspace.ps1 +++ b/public/addIncludeToWorkspace.ps1 @@ -110,15 +110,34 @@ function Add-IncludeToWorkspace { } if ($PSCmdlet.ShouldProcess("$sourceFile", "copy to $destinationFile")) { - # TODO: Add version info header to each file. + # Add version info header to each file. # The header will contain a do not modify this file manually message # Avoid using Set-Content as it adds an empty tail line at the end of the file # Implement a Get-ModuleInfo function on module.helper.ps1 to get module name and version # This function will read the psd1 file that has the same name as the folder name. This will allow having more than one psd1 file in the same folder # - Copy-Item -Path $sourceFile -Destination $destinationFile -Force - # Set-Content -Path $destinationFile -Value $content -Force - Write-Output $destinationFile + $content = Get-Content -Path $sourceFile + $version = Get-VersionHeader $content + # Find the name of the source module for leater adding to version header + $sourceModuleRootPath = Find-ModuleRootPath -Path $sourcePath | split-path -Leaf + + if($version){ + + # If version header exists, update the version header with the new module name and version + $newVersionHeader = Build-VersionHeader -Version $version.Version -Source $sourceModuleRootPath + $content = Remove-VersionHeader -content $content + } else { + $newVersionHeader = Build-VersionHeader -Version "1.0.0" -Source $sourceModuleRootPath + } + + # Build new content + $content = @($newVersionHeader) + $content + + # write fto file + $finalContent = $content -join "`n" + $finalContent | Out-File -Path $destinationFile -NoNewline -Force + + return $destinationFile } } diff --git a/public/githelper.ps1 b/public/githelper.ps1 new file mode 100644 index 0000000..6735a68 --- /dev/null +++ b/public/githelper.ps1 @@ -0,0 +1,50 @@ +function Test-RepoFileChanged { + [CmdletBinding()] + param( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + [string]$Path + ) + + process { + try { + if ([string]::IsNullOrWhiteSpace($Path)) { + return $false + } + + $absolutePath = if ([System.IO.Path]::IsPathRooted($Path)) { + [System.IO.Path]::GetFullPath($Path) + } else { + [System.IO.Path]::GetFullPath((Join-Path (Get-Location).Path $Path)) + } + + $candidateDir = if (Test-Path -LiteralPath $absolutePath -PathType Container) { + $absolutePath + } else { + Split-Path -Path $absolutePath -Parent + } + + if (-not (Test-Path -LiteralPath $candidateDir -PathType Container)) { + return $false + } + + $repoRoot = (& git -C $candidateDir rev-parse --show-toplevel 2>$null | Select-Object -First 1) + if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($repoRoot)) { + return $false + } + $repoRoot = $repoRoot.Trim() + + $repoRootFull = [System.IO.Path]::GetFullPath($repoRoot) + if ($absolutePath -notlike "$repoRootFull*") { + return $false + } + + $relativePath = [System.IO.Path]::GetRelativePath($repoRootFull, $absolutePath) + $status = (& git -C $repoRootFull status --porcelain -- $relativePath 2>$null) + + return -not [string]::IsNullOrWhiteSpace(($status | Out-String).Trim()) + } + catch { + return $false + } + } +} \ No newline at end of file diff --git a/public/listIncludes.ps1 b/public/listIncludes.ps1 index 0bab16d..267d9eb 100644 --- a/public/listIncludes.ps1 +++ b/public/listIncludes.ps1 @@ -70,7 +70,16 @@ function Get-IncludeFile{ $items = Get-ChildItem -Path $path -Filter "*$Filter*" -File -ErrorAction SilentlyContinue | ForEach-Object { - $version = Get-IncludeFileVersion -Path $_.FullName + $content = Get-Content -Path $_.FullName + $version = Get-VersionHeader -content $content + if($version){ + $body = Remove-VersionHeader -content $content + } else { + $body = $content + } + + $sha = $body | Out-String | Get-HashCode + $gitStatus = $(Test-RepoFileChanged -Path $_.FullName )? "Modified" : "Unmodified" [PSCustomObject]@{ Name = Compress-FileNameTransformation -FileName $_.Name -SourceModulePath $ModuleRootPath @@ -79,6 +88,8 @@ function Get-IncludeFile{ Path = $_.FullName Version = $version.Version Date = $version.Date + Sha = $sha + GitStatus = $gitStatus } } if ($items.Count -ne 0) { diff --git a/public/setfileversion.ps1 b/public/setfileversion.ps1 index d06b4c0..9a44a8e 100644 --- a/public/setfileversion.ps1 +++ b/public/setfileversion.ps1 @@ -2,9 +2,10 @@ function Set-IncludeFileVersion{ [CmdletBinding()] [outputtype([bool])] param( - [string]$Path, - [string]$Version, - [string]$Date + [string]$Path, + [string]$Version, + [string]$Date, + [string]$Source ) # Return of file does not exist @@ -21,20 +22,23 @@ function Set-IncludeFileVersion{ # Get actual version $actualVersion = $null -eq $content ? $null : $(Get-VersionHeader -content $content) - if($actualVersion){ - # Check if actual version is the same as the new version, if so return true - if(($actualVersion.Version -eq $Version) -and ($actualVersion.Date -eq $Date)){ - return $true - } - } + # if($actualVersion){ + # # Check if actual version is the same as the new version, if so return true + # if(($actualVersion.Version -eq $Version) -and ($actualVersion.Date -eq $Date)){ + # return $true + # } + # } # If version remove header if($actualVersion){ $content = Remove-VersionHeader -content $content } + # Get Module Name from path + $sourceModuleRootPath = Find-ModuleRootPath -Path $Path | split-path -Leaf + # Build Target version line - $tragetFirstLine = Build-VersionHeader -Version $Version -Date $Date + $tragetFirstLine = Build-VersionHeader -Version $Version -Date $Date -Source $sourceModuleRootPath # Add the new version header as the first line of the file $newContent = @($tragetFirstLine) + $content @@ -47,7 +51,7 @@ function Set-IncludeFileVersion{ } Export-ModuleMember -Function Set-IncludeFileVersion $script:HEADER_V1 = @( - '# {"Version":"{version}","Date":"{date}","HeaderVersion":{headerversion}}', + '# {"Version":"{version}","Date":"{date}","Source":"{source}","HeaderVersion":{headerversion}}', "# DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE." ) @@ -55,20 +59,24 @@ function Build-VersionHeader_V1{ [alias("Build-VersionHeader")] param( [string]$Version, - [string]$Date + [string]$Date, + [string]$Source ) $headerversion = 1 $header = $script:HEADER_V1 - + + $Date = [string]::IsNullOrEmpty($Date) ? (Get-DateString) : $Date + # replace the {json} placeholder with the actual json $header = $header | ForEach-Object { $_ -replace "{headerversion}", "$headerversion" } $header = $header | ForEach-Object { $_ -replace "{version}", $Version } $header = $header | ForEach-Object { $_ -replace "{date}", $Date } + $header = $header | ForEach-Object { $_ -replace "{source}", $Source } return $header -} +} Export-ModuleMember -Function Build-VersionHeader_V1 -Alias Build-VersionHeader function Remove-VersionHeader($content){ @@ -95,7 +103,7 @@ function Remove-VersionHeader($content){ } return $content -} +} Export-ModuleMember -Function Remove-VersionHeader function Get-VersionHeader($content){ @@ -115,5 +123,5 @@ function Get-VersionHeader($content){ try { $version = $json | ConvertFrom-Json } catch { return $null } return $version -} +} export-ModuleMember -Function Get-VersionHeader From 8de110eb793e76d2f2bdcde71cf05bf1f84e9cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Wed, 24 Jun 2026 18:26:26 +0200 Subject: [PATCH 05/25] feat(alias): add aliases for Add-IncludeToWorkspace and Get-IncludeFile functions --- public/addIncludeToWorkspace.ps1 | 3 ++- public/listIncludes.ps1 | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public/addIncludeToWorkspace.ps1 b/public/addIncludeToWorkspace.ps1 index 9d0175d..7f0cca0 100644 --- a/public/addIncludeToWorkspace.ps1 +++ b/public/addIncludeToWorkspace.ps1 @@ -26,6 +26,7 @@ Add-IncludeToWorkspace -Name "TestInclude.txt" -FolderName "TestInclude" #> function Add-IncludeToWorkspace { [CmdletBinding(SupportsShouldProcess)] + [Alias("aif")] param ( [Parameter(Mandatory,ValueFromPipelineByPropertyName,Position=0)][string]$Name, [Parameter(Mandatory,ValueFromPipelineByPropertyName, Position = 1)] @@ -145,7 +146,7 @@ function Add-IncludeToWorkspace { #"<< Add-IncludeToWorkspace" | Write-MyDebug } -} Export-ModuleMember -Function Add-IncludeToWorkspace +} Export-ModuleMember -Function Add-IncludeToWorkspace -Alias "aif" function Resolve-SourceDestinationPath{ [CmdletBinding()] diff --git a/public/listIncludes.ps1 b/public/listIncludes.ps1 index 267d9eb..2e19da9 100644 --- a/public/listIncludes.ps1 +++ b/public/listIncludes.ps1 @@ -32,6 +32,7 @@ Displays the available includes. #> function Get-IncludeFile{ [CmdletBinding()] + [Alias("gif")] param( #add filter pattern [Parameter( Position = 0 )] [string]$Filter = '*', @@ -99,7 +100,7 @@ function Get-IncludeFile{ return $ret -} Export-ModuleMember -Function Get-IncludeFile +} Export-ModuleMember -Function Get-IncludeFile -Alias "gif" <# .SYNOPSIS From 51722682307a8005097b29e76510185b0de54dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Wed, 24 Jun 2026 18:36:26 +0200 Subject: [PATCH 06/25] fix(header): update version and date in MyWrite.ps1 --- include/MyWrite.ps1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/MyWrite.ps1 b/include/MyWrite.ps1 index 34f8c69..f559a24 100644 --- a/include/MyWrite.ps1 +++ b/include/MyWrite.ps1 @@ -1,4 +1,4 @@ -# {"Version":"1.2.0","Date":"2026-06-18","Source":"include","HeaderVersion":1} +# {"Version":"1.3.1","Date":"2026-06-24","Source":"IncludeHelper","HeaderVersion":1} # DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE. # Include MyWrite.ps1 @@ -79,7 +79,8 @@ function Write-MyDebug { param( [Parameter(Position = 0)][string]$section = "none", [Parameter(Position = 1, ValueFromPipeline)][string]$Message, - [Parameter(Position = 2)][object]$Object + [Parameter(Position = 2)][object]$Object, + [Parameter()][int]$objectDepth = 10 ) process{ @@ -87,7 +88,7 @@ function Write-MyDebug { if (Test-MyDebug -section $section) { if ($Object) { - $objString = $Object | Get-ObjetString + $objString = $Object | Get-ObjetString -Depth $objectDepth $message = $message + " - " + $objString } @@ -347,7 +348,8 @@ Export-ModuleMember -Function "Get-$($MODULE_NAME)Debug" function Get-ObjetString { param( - [Parameter(ValueFromPipeline, Position = 0)][object]$Object + [Parameter(ValueFromPipeline, Position = 0)][object]$Object, + [Parameter()][int]$Depth = 10 ) process{ @@ -360,7 +362,7 @@ function Get-ObjetString { return $Object } - return $Object | ConvertTo-Json -Depth 10 -ErrorAction SilentlyContinue + return $Object | ConvertTo-Json -Depth $Depth -ErrorAction SilentlyContinue } } From 767d7eb72e098e1bb5d3b37e6328bf8d5900a2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Wed, 24 Jun 2026 18:36:43 +0200 Subject: [PATCH 07/25] fix(setfileversion): update parameter attributes for Set-IncludeFileVersion function --- public/setfileversion.ps1 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/public/setfileversion.ps1 b/public/setfileversion.ps1 index 9a44a8e..f7be78b 100644 --- a/public/setfileversion.ps1 +++ b/public/setfileversion.ps1 @@ -2,10 +2,10 @@ function Set-IncludeFileVersion{ [CmdletBinding()] [outputtype([bool])] param( - [string]$Path, - [string]$Version, - [string]$Date, - [string]$Source + [parameter(Mandatory,ValueFromPipelineByPropertyName)][string]$Path, + [parameter(Mandatory)][string]$Version, + [parameter()][string]$Date, + [parameter()][string]$Source ) # Return of file does not exist @@ -34,11 +34,13 @@ function Set-IncludeFileVersion{ $content = Remove-VersionHeader -content $content } - # Get Module Name from path - $sourceModuleRootPath = Find-ModuleRootPath -Path $Path | split-path -Leaf + # If source not specified, get the source from the path + if([string]::IsNullOrEmpty($Source)){ + $source = Find-ModuleRootPath -Path $Path | split-path -Leaf + } # Build Target version line - $tragetFirstLine = Build-VersionHeader -Version $Version -Date $Date -Source $sourceModuleRootPath + $tragetFirstLine = Build-VersionHeader -Version $Version -Date $Date -Source $source # Add the new version header as the first line of the file $newContent = @($tragetFirstLine) + $content From 13d01ed50af81f9327ddc9afc256f854a2bfd1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Wed, 24 Jun 2026 18:37:01 +0200 Subject: [PATCH 08/25] chore(header): update header comments in functionParameterHelper.ps1 --- include/functionParameterHelper.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/functionParameterHelper.ps1 b/include/functionParameterHelper.ps1 index d9abb5e..eef7606 100644 --- a/include/functionParameterHelper.ps1 +++ b/include/functionParameterHelper.ps1 @@ -1,3 +1,5 @@ +# {"Version":"1.0.0","Date":"2026-06-23","Source":"IncludeHelper","HeaderVersion":1} +# DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE. # Register-ArgumentCompleter # # To control the parametrs autofil we can register a scriptblock variable with a function to manage From f806a02514107cae83ecf02b3eece23d0118d376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Thu, 25 Jun 2026 09:13:17 +0200 Subject: [PATCH 09/25] fix(githelper): Test-RepoFileChanged --- Test/public/githelper.test.ps1 | 38 +++++++++++++++++++++++++++++ public/githelper.ps1 | 44 +++++++++++++--------------------- 2 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 Test/public/githelper.test.ps1 diff --git a/Test/public/githelper.test.ps1 b/Test/public/githelper.test.ps1 new file mode 100644 index 0000000..e89f53d --- /dev/null +++ b/Test/public/githelper.test.ps1 @@ -0,0 +1,38 @@ +function Test_TestRepoFileChanged_Changed{ + + + $repo = "reponame" + New-TestingFolder -Path $repo + git init $repo + + # Arrange Not changed + $folder = "folder1/folder2" + $file = "file1.txt" + New-TestingFile -Path "$repo/$folder" -Name $file -Content "Hello World" + $targetpath = Join-Path -Path $repo -childPath $folder -AdditionalChildPath $file + + # Act + $result = Test-RepoFileChanged -Path $targetpath + + # Assert + Assert-IsTrue -Condition $result + + # Arrange Not Changed + git -C $repo add . + git -C $repo commit -m "Initial commit" + + # Act + $result = Test-RepoFileChanged -Path $targetpath + + # Assert + Assert-IsFalse -Condition $result -Comment "File should not be marked as changed after commit" + + # Arrange change the file again + Set-Content -Path $targetpath -Value "Hello World Changed" + + # Act + $result = Test-RepoFileChanged -Path $targetpath + + # Assert + Assert-IsTrue -Condition $result -Comment "File should be marked as changed after modification" +} diff --git a/public/githelper.ps1 b/public/githelper.ps1 index 6735a68..ac62984 100644 --- a/public/githelper.ps1 +++ b/public/githelper.ps1 @@ -11,40 +11,30 @@ function Test-RepoFileChanged { return $false } - $absolutePath = if ([System.IO.Path]::IsPathRooted($Path)) { - [System.IO.Path]::GetFullPath($Path) - } else { - [System.IO.Path]::GetFullPath((Join-Path (Get-Location).Path $Path)) - } - - $candidateDir = if (Test-Path -LiteralPath $absolutePath -PathType Container) { - $absolutePath - } else { - Split-Path -Path $absolutePath -Parent - } + # convert to full routed path + $absolutePath = $Path | Convert-Path - if (-not (Test-Path -LiteralPath $candidateDir -PathType Container)) { - return $false - } + "Testing [$Path] converted to absolute path [$absolutePath]" | Write-MyDebug -Section "githelper" - $repoRoot = (& git -C $candidateDir rev-parse --show-toplevel 2>$null | Select-Object -First 1) + # Get the reporoot. needed for git commands + $parentDir = Split-Path -Path $absolutePath -Parent + $repoRoot = git -C $parentDir rev-parse --show-toplevel 2>$null if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($repoRoot)) { + "Not a git repository: $parentDir" | Write-MyDebug -Section "githelper" return $false } - $repoRoot = $repoRoot.Trim() - - $repoRootFull = [System.IO.Path]::GetFullPath($repoRoot) - if ($absolutePath -notlike "$repoRootFull*") { - return $false - } - - $relativePath = [System.IO.Path]::GetRelativePath($repoRootFull, $absolutePath) - $status = (& git -C $repoRootFull status --porcelain -- $relativePath 2>$null) - - return -not [string]::IsNullOrWhiteSpace(($status | Out-String).Trim()) + + # Check status of the file using absolute path and repo root + $status = (& git -C $repoRoot status --porcelain -- $absolutePath 2>$null) + $ret = -not [string]::IsNullOrWhiteSpace($status) + + # return + "Testing [$ret] for [$Path] absolute path [$absolutePath] repoRoot [$repoRoot] status [$status]" | Write-MyDebug -Section "githelper" + return $ret } catch { + "Error occurred while testing [$Path]: $_" | Write-MyDebug -Section "githelper" return $false } } -} \ No newline at end of file +} Export-ModuleMember -Function Test-RepoFileChanged \ No newline at end of file From 7e08b1316098e55bd62bac9d6391e06e70456e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Thu, 25 Jun 2026 09:14:07 +0200 Subject: [PATCH 10/25] fix(tests): remove redundant Reset-InvokeCommandMock call in addIncludeToWorkspace test --- Test/include/run_BeforeAfter.ps1 | 5 +++++ Test/public/addIncludeToWorkspace.test.ps1 | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Test/include/run_BeforeAfter.ps1 b/Test/include/run_BeforeAfter.ps1 index 2ddb3d1..03d6c94 100644 --- a/Test/include/run_BeforeAfter.ps1 +++ b/Test/include/run_BeforeAfter.ps1 @@ -20,6 +20,11 @@ function Run_BeforeEach{ # Write-Verbose "Run_BeforeEach" Disable-IncludeHelperDebug + Reset-InvokeCommandMock + + # Mock get the now date + Set-InvokeCommandMock -Alias "Get-Date" -Command "Get-Date" + } # function Run_AfterEach{ diff --git a/Test/public/addIncludeToWorkspace.test.ps1 b/Test/public/addIncludeToWorkspace.test.ps1 index 5d21023..0bade63 100644 --- a/Test/public/addIncludeToWorkspace.test.ps1 +++ b/Test/public/addIncludeToWorkspace.test.ps1 @@ -164,8 +164,6 @@ function Test_AddIncludeToWorkspace_WithoutSource_WithoutDestination{ function Test_AddIncludeToWorkspace_FromSourceToDestination{ - Reset-InvokeCommandMock - $TargetModuleName = "TargetModule" $SourceModuleName = "SourceModule" From 1bb9a21b45a9c880386d19d5e0721c8c1750fd5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Thu, 25 Jun 2026 09:34:49 +0200 Subject: [PATCH 11/25] refactor(version): rename Get-VersionHeader to Get-VersionFromHeader --- public/addIncludeToWorkspace.ps1 | 2 +- public/getfileversion.ps1 | 2 +- public/listIncludes.ps1 | 2 +- public/setfileversion.ps1 | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/public/addIncludeToWorkspace.ps1 b/public/addIncludeToWorkspace.ps1 index 7f0cca0..010afaf 100644 --- a/public/addIncludeToWorkspace.ps1 +++ b/public/addIncludeToWorkspace.ps1 @@ -118,7 +118,7 @@ function Add-IncludeToWorkspace { # This function will read the psd1 file that has the same name as the folder name. This will allow having more than one psd1 file in the same folder # $content = Get-Content -Path $sourceFile - $version = Get-VersionHeader $content + $version = Get-VersionFromHeader $content # Find the name of the source module for leater adding to version header $sourceModuleRootPath = Find-ModuleRootPath -Path $sourcePath | split-path -Leaf diff --git a/public/getfileversion.ps1 b/public/getfileversion.ps1 index c47eb6b..b33f2d7 100644 --- a/public/getfileversion.ps1 +++ b/public/getfileversion.ps1 @@ -16,7 +16,7 @@ function Get-IncludeFileVersion{ return $null } - $version = Get-VersionHeader -content $content + $version = Get-VersionFromHeader -content $content if($version){ $ret = [PsCustomObject]@{ diff --git a/public/listIncludes.ps1 b/public/listIncludes.ps1 index 2e19da9..05a2b1c 100644 --- a/public/listIncludes.ps1 +++ b/public/listIncludes.ps1 @@ -72,7 +72,7 @@ function Get-IncludeFile{ $items = Get-ChildItem -Path $path -Filter "*$Filter*" -File -ErrorAction SilentlyContinue | ForEach-Object { $content = Get-Content -Path $_.FullName - $version = Get-VersionHeader -content $content + $version = Get-VersionFromHeader -content $content if($version){ $body = Remove-VersionHeader -content $content } else { diff --git a/public/setfileversion.ps1 b/public/setfileversion.ps1 index f7be78b..ba44f44 100644 --- a/public/setfileversion.ps1 +++ b/public/setfileversion.ps1 @@ -20,7 +20,7 @@ function Set-IncludeFileVersion{ $content = Get-Content -Path $Path # Get actual version - $actualVersion = $null -eq $content ? $null : $(Get-VersionHeader -content $content) + $actualVersion = $null -eq $content ? $null : $(Get-VersionFromHeader -content $content) # if($actualVersion){ # # Check if actual version is the same as the new version, if so return true @@ -85,7 +85,7 @@ function Remove-VersionHeader($content){ $headerSizeV0 = 1 $headersSizeV1 = $script:HEADER_V1.Count - $version = Get-VersionHeader -content $content + $version = Get-VersionFromHeader -content $content if(-not $version){ throw "No version header found in content" @@ -107,7 +107,7 @@ function Remove-VersionHeader($content){ return $content } Export-ModuleMember -Function Remove-VersionHeader -function Get-VersionHeader($content){ +function Get-VersionFromHeader($content){ # So far the version json is always on the first line @@ -125,5 +125,5 @@ function Get-VersionHeader($content){ try { $version = $json | ConvertFrom-Json } catch { return $null } return $version -} export-ModuleMember -Function Get-VersionHeader +} export-ModuleMember -Function Get-VersionFromHeader From 89cc8cbf40439b21686df72343e86a8829644049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Thu, 25 Jun 2026 09:45:29 +0200 Subject: [PATCH 12/25] feat(MyWrite): add Get-ModuleLastError function --- include/MyWrite.ps1 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/MyWrite.ps1 b/include/MyWrite.ps1 index f559a24..f4658d3 100644 --- a/include/MyWrite.ps1 +++ b/include/MyWrite.ps1 @@ -1,6 +1,5 @@ -# {"Version":"1.3.1","Date":"2026-06-24","Source":"IncludeHelper","HeaderVersion":1} +# {"Version":"1.4.0","Date":"2026-06-25","Source":"IncludeHelper","HeaderVersion":1} # DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE. - # Include MyWrite.ps1 # Provides Write-MyError, Write-MyWarning, Write-MyVerbose, Write-MyHost, Write-MyDebug # and Test-MyVerbose, Test-MyDebug functions for consistent logging and debugging output. @@ -22,10 +21,19 @@ function Write-MyError { param( [Parameter(Mandatory, ValueFromPipeline)][string]$Message ) + $script:LastError= $Message # Write-Host "Error: $message" -ForegroundColor $ERROR_COLOR Write-ToConsole "Error: $message" -Color $ERROR_COLOR } +function Get-ModuleLastError { + [CmdletBinding()] + param() + + return $script:LastError +}Copy-Item -path Function:Get-ModuleLastError -Destination Function:"Get-$($MODULE_NAME)LastError" +Export-ModuleMember -Function "Get-$($MODULE_NAME)LastError" + function Write-MyWarning { [CmdletBinding()] [Alias("Write-Warning")] @@ -272,7 +280,7 @@ function Enable-ModuleNameDebug{ } if($DoNotClearHost){ - $sectons += "donotclearhost" + $sections += "donotclearhost" } $sectionsString = $sections -join " " From a7f6a5a25638f0458f08faf433d69d4cb8d1eddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 5 Jul 2026 07:51:35 +0200 Subject: [PATCH 13/25] refactor(tests): move Reset-InvokeCommandMock calls from test functions to Run_BeforeEach --- Test/public/callAPI.test.ps1 | 5 +---- Test/public/databasev2.test.ps1 | 6 ------ Test/public/dependencies.test.ps1 | 6 ------ Test/public/invokeCommand.mock.test.ps1 | 10 ---------- Test/public/openFilesUrls.test.ps1 | 2 -- 5 files changed, 1 insertion(+), 28 deletions(-) diff --git a/Test/public/callAPI.test.ps1 b/Test/public/callAPI.test.ps1 index 64912fe..a667648 100644 --- a/Test/public/callAPI.test.ps1 +++ b/Test/public/callAPI.test.ps1 @@ -1,7 +1,7 @@ function Test_CallAPI_RESTAPI_Withpagination_1{ Assert-SkipTest "This test is not implemented" - Reset-InvokeCommandMock + Enable-InvokeCommandAliasModule # Act @@ -20,7 +20,6 @@ function Test_CallAPI_RESTAPI_Withpagination_2{ Assert-SkipTest "This test is not implemented" - Reset-InvokeCommandMock Enable-InvokeCommandAliasModule # Act @@ -34,7 +33,6 @@ function Test_Call_API_GraphQL{ Assert-SkipTest "This test is not implemented" - Reset-InvokeCommandMock Enable-InvokeCommandAliasModule $query = @' @@ -54,7 +52,6 @@ function Test_Call_API_GraphQL_outfile{ Assert-SkipTest "This test is not implemented" - Reset-InvokeCommandMock Enable-InvokeCommandAliasModule $file = "outfile.json" diff --git a/Test/public/databasev2.test.ps1 b/Test/public/databasev2.test.ps1 index fc81e77..1dc874a 100644 --- a/Test/public/databasev2.test.ps1 +++ b/Test/public/databasev2.test.ps1 @@ -1,7 +1,6 @@ function Test_Database{ - Reset-InvokeCommandMock Mock_Database -ResetDatabase # Load include files needed to test database @@ -47,7 +46,6 @@ function Test_Database{ function Test_Database_JSON{ - Reset-InvokeCommandMock Mock_Database -ResetDatabase # Load include files needed to test database @@ -93,7 +91,6 @@ function Test_Database_JSON{ function Test_Database_JSON_ComplexObject{ - Reset-InvokeCommandMock Mock_Database -ResetDatabase # Load include files needed to test database @@ -133,7 +130,6 @@ function Test_Database_JSON_ComplexObject{ function Test_Database_XML{ - Reset-InvokeCommandMock Mock_Database -ResetDatabase # Load include files needed to test database @@ -179,7 +175,6 @@ function Test_Database_XML{ function Test_Database_TXT{ - Reset-InvokeCommandMock Mock_Database -ResetDatabase # Load include files needed to test database @@ -225,7 +220,6 @@ function Test_Database_TXT{ function Test_Database_MultyKey{ - Reset-InvokeCommandMock Mock_Database -ResetDatabase . $(Get-Ps1FullPath -Name "databaseV2.ps1" -FolderName "Include" -ModuleRootPath $MODULE_ROOT_PATH) diff --git a/Test/public/dependencies.test.ps1 b/Test/public/dependencies.test.ps1 index 0c866de..cc23bb3 100644 --- a/Test/public/dependencies.test.ps1 +++ b/Test/public/dependencies.test.ps1 @@ -2,7 +2,6 @@ function Test_ImportDepepency_Already_loaded{ $name = "TargetModule" ; $modulesFolder = "ModulesFolder" - Reset-InvokeCommandMock New-moduleV3 -Name $name -Path $modulesFolder @@ -27,7 +26,6 @@ function Test_ImportDepepency_Already_loaded{ function Test_ImportDepepency_SideBySide{ $name = "TargetModule" ; $modulesFolder = "ModulesFolder" - Reset-InvokeCommandMock # Create new module on test folder New-moduleV3 -Name $name -Path $modulesFolder @@ -59,8 +57,6 @@ function Test_ImportDepepency_Import_From_Module_Manager{ $name = "TargetModule" ; $modulesFolder = "ModulesFolder" - Reset-InvokeCommandMock - New-ModuleV3 -Name $name -Path $modulesFolder # Mock Get-Module to Null @@ -92,7 +88,6 @@ function Test_ImportDepepency_Import_From_Module_Manager{ function Test_ImportDepepency_Install_From_Gallery{ $name = "TargetModule" ; $modulesFolder = "ModulesFolder" - Reset-InvokeCommandMock New-ModuleV3 -Name $name -Path $modulesFolder # Mock Get-Module to Null @@ -134,7 +129,6 @@ function Test_ImportDependency_Clone_From_GitHub{ $name = "TargetModule" ; $modulesFolder = "ModulesFolder" $owner = "rulasg" - Reset-InvokeCommandMock # Mock Get-Module to Null Mock_GetModule_Null -Name $name diff --git a/Test/public/invokeCommand.mock.test.ps1 b/Test/public/invokeCommand.mock.test.ps1 index 3830091..adcd84d 100644 --- a/Test/public/invokeCommand.mock.test.ps1 +++ b/Test/public/invokeCommand.mock.test.ps1 @@ -1,8 +1,6 @@ function Test_MockCallJson{ - Reset-InvokeCommandMock - $fileName = 'test.json' MockCallJson -Command 'Test-Command' -filename $fileName @@ -16,8 +14,6 @@ function Test_MockCallJson{ function Test_MockCallJson_AsHashtable{ - Reset-InvokeCommandMock - $fileName = 'test.json' # Act @@ -33,8 +29,6 @@ function Test_MockCallJson_AsHashtable{ function Test_MockCallToObject{ - Reset-InvokeCommandMock - $data = @{ Name = 'Test' Value = 42 @@ -50,8 +44,6 @@ function Test_MockCallToObject{ function Test_MockCallToObject_ResetMockObject{ - Reset-InvokeCommandMock - MockCallToObject -Command 'kk1' -OutObject 'Testkk1' MockCallToObject -Command 'kk2' -OutObject 'Testkk2' MockCallToObject -Command 'kk3' -OutObject 'Testkk3' @@ -71,8 +63,6 @@ function Test_MockCallToObject_ResetMockObject{ function Test_MockCallExpression{ - Reset-InvokeCommandMock - $expression = @' echo "new string from mock 2" echo "more things to say" diff --git a/Test/public/openFilesUrls.test.ps1 b/Test/public/openFilesUrls.test.ps1 index f786081..92c21a6 100644 --- a/Test/public/openFilesUrls.test.ps1 +++ b/Test/public/openFilesUrls.test.ps1 @@ -5,7 +5,6 @@ function Test_OpenUrl_SingleUrl { # Arrange - Reset-InvokeCommandMock $url = "https://github.com" $tag = New-Guid @@ -28,7 +27,6 @@ function Test_OpenUrl_SingleUrl { function Test_OpenUrl_MultipleUrls_Pipeline { # Arrange - Reset-InvokeCommandMock $url1 = "https://github.com" $url2 = "https://google.com" $url3 = "https://microsoft.com" From 3e7f59edcd12aff9a2b9b217e812e87dd935ca23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 5 Jul 2026 07:55:18 +0200 Subject: [PATCH 14/25] feat(invokeCommand): add asynchronous command handling functions --- helper/invokeCommand.helper.ps1 | 96 ++++++++++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 8 deletions(-) diff --git a/helper/invokeCommand.helper.ps1 b/helper/invokeCommand.helper.ps1 index 5a08f46..25da803 100644 --- a/helper/invokeCommand.helper.ps1 +++ b/helper/invokeCommand.helper.ps1 @@ -1,3 +1,5 @@ +# {"Version":"1.3.0","Date":"","Source":"IncludeHelper","HeaderVersion":1} +# DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE. # SET MY INVOKE COMMAND ALIAS # @@ -21,6 +23,17 @@ function Set-MyInvokeCommandAlias{ } } +function Reset-MyInvokeCommandAlias{ + [CmdletBinding(SupportsShouldProcess)] + param() + + # throw if MODULE_INVOKATION_TAG is not set or is "MyModuleModule" + if (-not $MODULE_INVOKATION_TAG) { + throw "MODULE_INVOKATION_TAG is not set. Please set it to a unique value before calling Set-MyInvokeCommandAlias." + } + InvokeHelper\Reset-InvokeCommandAlias -Tag $MODULE_INVOKATION_TAG +} + function Invoke-MyCommand{ [CmdletBinding()] param( @@ -33,17 +46,84 @@ function Invoke-MyCommand{ return InvokeHelper\Invoke-MyCommand -Command $Command -Parameters $Parameters } +function Invoke-MyCommandAsync{ + [CmdletBinding()] + param( + [Parameter(Mandatory,ValueFromPipeline,Position=0)][string]$Command, + [Parameter(Position=1)][hashtable]$Parameters + ) -function Reset-MyInvokeCommandAlias{ - [CmdletBinding(SupportsShouldProcess)] - param() + Write-MyDebug "invoke" $Command $Parameters - # throw if MODULE_INVOKATION_TAG is not set or is "MyModuleModule" - if (-not $MODULE_INVOKATION_TAG) { - throw "MODULE_INVOKATION_TAG is not set. Please set it to a unique value before calling Set-MyInvokeCommandAlias." + $job = InvokeHelper\Start-MyJob -Command $Command -Parameters $Parameters + + $call = [pscustomobject]@{ + Job = $job + Command = $Command + Parameters = $Parameters + } + + return $call +} + +function Wait-MyCommandAsync{ + [CmdletBinding()] + param( + [Parameter(Mandatory,ValueFromPipeline,Position=0)][pscustomobject]$call + ) + + begin{ + $jobs = @() + } + + process{ + + $jobs += $call.Job + + } + + end { + + $waitingJobs = $jobs + + $all = $waitingJobs.Count + "Waiting for [$all] jobs to complete " | Write-MyHost -noNewline + + while ($waitingJobs.Count -ne 0) { + + $waitings = $waitingJobs | Wait-Job -Any + + "." | Write-MyHost -NoNewline + + # Remove completed jobs from the waiting list + $waitingJobs = $waitingJobs | Where-Object { $_.Id -ne $waitings.Id } + + } + + $completed = $jobs | Where-Object { $_.State -eq 'Completed' } | Measure-Object | Select-Object -ExpandProperty Count + $failed = $jobs | Where-Object { $_.State -eq 'Failed' } | Measure-Object | Select-Object -ExpandProperty Count + $all = $jobs.Count + + "" | Write-MyHost + "Completed [$completed] Failed [$failed]" | Write-MyHost + } +} + +function Receive-MyCommandAsync{ + [CmdletBinding()] + param( + [Parameter(Mandatory,ValueFromPipeline,Position=0)][pscustomobject]$call + ) + + $res = Receive-Job -Job $call.Job -ErrorAction SilentlyContinue + + # Check for false if update failed + if(-not $res){ + "Failed calling to update project [$($call.Parameters.projectnumber)]." | Write-MyError + } else { + $res } - InvokeHelper\Reset-InvokeCommandAlias -Tag $MODULE_INVOKATION_TAG } # Reset all aliases for this module on each refresh -Reset-MyInvokeCommandAlias +Reset-MyInvokeCommandAlias \ No newline at end of file From 3368be1cd2e43a7985476594b60890089cb68ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 5 Jul 2026 08:11:54 +0200 Subject: [PATCH 15/25] feat(tests): add mock date helper functions for testing date-related functionality --- Test/include/Mock_datehelper.ps1 | 17 +++++++++++++++++ Test/include/run_BeforeAfter.ps1 | 3 +-- Test/public/datehelper.test.ps1 | 24 +++++++++++++----------- include/datehelper.ps1 | 1 - 4 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 Test/include/Mock_datehelper.ps1 diff --git a/Test/include/Mock_datehelper.ps1 b/Test/include/Mock_datehelper.ps1 new file mode 100644 index 0000000..97948d3 --- /dev/null +++ b/Test/include/Mock_datehelper.ps1 @@ -0,0 +1,17 @@ + +$mockDate = "1975-02-18 00:12:15" +$mockDatetime = [DateTime]::ParseExact($mockDate, 'yyyy-MM-dd HH:mm:ss', $null) +$mockDatetimeUtc = [DateTime]::SpecifyKind($mockDatetime, [DateTimeKind]::Utc) + +function Mock_GetToday{ + + return $mockDatetime + +} + +function MockCall_DateHelper { + + MockCallToObject -command "Get-Date" -OutObject $mockDatetime + MockCallToObject -command "Get-Date -Format 'yyyy-MM-dd'" -OutObject $mockDatetime.ToString("yyyy-MM-dd") + MockCallToObject -command "Get-Date -AsUTC" -OutObject $mockDatetimeUtc +} diff --git a/Test/include/run_BeforeAfter.ps1 b/Test/include/run_BeforeAfter.ps1 index 03d6c94..7968d46 100644 --- a/Test/include/run_BeforeAfter.ps1 +++ b/Test/include/run_BeforeAfter.ps1 @@ -23,8 +23,7 @@ function Run_BeforeEach{ Reset-InvokeCommandMock # Mock get the now date - Set-InvokeCommandMock -Alias "Get-Date" -Command "Get-Date" - + MockCall_DateHelper } # function Run_AfterEach{ diff --git a/Test/public/datehelper.test.ps1 b/Test/public/datehelper.test.ps1 index da5a704..37e07ac 100644 --- a/Test/public/datehelper.test.ps1 +++ b/Test/public/datehelper.test.ps1 @@ -53,21 +53,23 @@ function Test_GetDaysBetweenDates_OneYear { } function Test_GetDaysBetweenDates_DefaultStartDate { + # Arrange - Reset-InvokeCommandMock - $now = Get-Date -Format 'yyyy-MM-dd' MockCallToObject -Command "GetNow" -OutObject $now + $futureDate = (Mock_GetToday).AddDays(10) + $futureDateString = $futureDate | Get-Date -Format 'yyyy-MM-dd' - # Act & Assert - Invoke-PrivateContext { - $futureDate = (Get-Date).AddDays(10) | Get-Date -Format 'yyyy-MM-dd' - - $result = Get-DaysBetweenDates -EndDate $futureDate - - # Result should be approximately 10 days (allowing for same-day test execution) - Assert-AreEqual -Expected 10 -Presented $result - } + # Act + $result = Invoke-PrivateContext { + param($Arguments) + + Get-DaysBetweenDates -EndDate $Arguments[0] + + } -Arguments $futureDateString + + # Result should be approximately 10 days (allowing for same-day test execution) + Assert-AreEqual -Expected 10 -Presented $result } function Test_ConvertFromEpochTime_OneDay { diff --git a/include/datehelper.ps1 b/include/datehelper.ps1 index 6ecb80d..45bb438 100644 --- a/include/datehelper.ps1 +++ b/include/datehelper.ps1 @@ -15,7 +15,6 @@ Set-MyInvokeCommandAlias -Alias GetNowString -Command "Get-Date -Format 'yyyy-MM Set-MyInvokeCommandAlias -Alias GetUtcNow -Command "Get-Date -AsUTC" Set-MyInvokeCommandAlias -Alias GetNow -Command "Get-Date" - function Get-DateString{ [CmdletBinding()] param( From ef4738b0b17b83a691774afd4eb79fc435304e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 5 Jul 2026 08:12:02 +0200 Subject: [PATCH 16/25] test(addIncludeToWorkspace): include version header in file assertions --- Test/public/addIncludeToWorkspace.test.ps1 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Test/public/addIncludeToWorkspace.test.ps1 b/Test/public/addIncludeToWorkspace.test.ps1 index 0bade63..187ac2b 100644 --- a/Test/public/addIncludeToWorkspace.test.ps1 +++ b/Test/public/addIncludeToWorkspace.test.ps1 @@ -82,6 +82,8 @@ function Test_AddIncludeToWorkspace_IfExists{ $moduleName = "TestModule" Import-Module -Name TestingHelper + $header = Build-VersionHeader -Version "1.0.0" -Source "IncludeHelper" + # Test for Include $includefiles = Get-IncludeFile $include1 = $includefiles | Where-Object { $_.FolderName -eq "Helper" } | Select-Object -First 1 @@ -101,13 +103,13 @@ function Test_AddIncludeToWorkspace_IfExists{ $filesDest1 = Get-ChildItem -Path $destFolder1 Assert-Count -Expected 1 -Presented $filesDest1 $contentFile1 = Get-Content -Path $filesDest1.FullName | Out-String - $sourceFile1 = Get-Content -Path $include1.Path | Out-String + $sourceFile1 = $header + (Get-Content -Path $include1.Path) | Out-String Assert-AreEqual -Expected $sourceFile1.Trim() -Presented $contentFile1.Trim() $filesDest2 = Get-ChildItem -Path $destFolder2 Assert-Count -Expected 1 -Presented $filesDest2 $contentFile2 = Get-Content -Path $filesDest2.FullName | Out-String - $sourceFile2 = Get-Content -Path $include2.Path | Out-String + $sourceFile2 = $header + (Get-Content -Path $include2.Path) | Out-String Assert-AreEqual -Expected $sourceFile2.Trim() -Presented $contentFile2.Trim() } @@ -134,13 +136,10 @@ function Test_AddIncludeToWorkspace_PipeParameters{ $folderNamePath = get-Modulefolder -FolderName "TestInclude" -ModuleRootPath $destinationModulePath $path = $folderNamePath | Join-Path -ChildPath "config.mock.ps1" Assert-ItemExist -path $path - } function Test_AddIncludeToWorkspace_WithoutSource_WithoutDestination{ - Reset-InvokeCommandMock - Import-Module -Name TestingHelper New-ModuleV3 -Name TestModule @@ -150,7 +149,6 @@ function Test_AddIncludeToWorkspace_WithoutSource_WithoutDestination{ $destinationFilePath = $destinationPath | Join-Path -ChildPath $destinationName Remove-Item -Path $destinationFilePath -ErrorAction SilentlyContinue - # Act Assert-itemNotExist -path $destinationFilePath @@ -196,8 +194,6 @@ function Test_AddIncludeToWorkspace_FromSourceToDestination{ # With soruce not destination function Test_AddIncludeToWorkspace_FromSourceToDestination_WithoutDestination{ - Reset-InvokeCommandMock - $FileName1 = "MyInclude1.ps1" $FileName2 = "MyInclude2.ps1" From 147a8aaf12bab6f7903a5596cf7749bcff93c9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 5 Jul 2026 08:12:17 +0200 Subject: [PATCH 17/25] feat(test): include source in file version JSON structure --- Test/public/setfileversion.test.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Test/public/setfileversion.test.ps1 b/Test/public/setfileversion.test.ps1 index c859531..1683479 100644 --- a/Test/public/setfileversion.test.ps1 +++ b/Test/public/setfileversion.test.ps1 @@ -89,7 +89,7 @@ function Assert-FileVersion{ $headeersizeinlines = $script:TEST_HEADER_V1.Count $content = Get-Content -Path $Path | Out-String - $json = Build-TestFileVersionJson $Version $Date $headerversion + $json = Build-TestFileVersionJson $Version $Date "IncludeHelper" $headerversion $expected = "# $json" $content = @(Get-Content -Path $Path) @@ -111,13 +111,14 @@ function Assert-FileVersion{ } } -function Build-TestFileVersionJson($Version, $Date, $Headerversion){ +function Build-TestFileVersionJson($Version, $Date, $Source, $Headerversion){ # Need to create the full object to control the order of members for mocking if(-not [string]::IsNullOrWhiteSpace($Headerversion)){ $json = [pscustomobject]@{ Version = $Version Date = $Date + Source = "IncludeHelper" HeaderVersion = $Headerversion } } else { @@ -133,7 +134,7 @@ function Build-TestFileVersionJson($Version, $Date, $Headerversion){ } $script:TEST_HEADER_V1 = @( - '# {"Version":"{version}","Date":"{date}","HeaderVersion":{headerversion}}', + '# {"Version":"{version}","Date":"{date}", "Source":"{source}","HeaderVersion":{headerversion}}', "# DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE." ) @@ -146,6 +147,7 @@ function Build-TestVersionHeader($version, $Date, $headerversion){ # replace the {json} placeholder with the actual json $header = $header | ForEach-Object { $_ -replace "{headerversion}", "$headerversion" } + $header = $header | ForEach-Object { $_ -replace "{source}", "IncludeHelper" } $header = $header | ForEach-Object { $_ -replace "{version}", $Version } $header = $header | ForEach-Object { $_ -replace "{date}", $Date } From 362c4fe5e15f8654ff320ab2ecf02bc96f220d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 5 Jul 2026 08:12:25 +0200 Subject: [PATCH 18/25] feat: add Compare-IncludeFile function for comparing local and remote include files --- public/listIncludes.ps1 | 73 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/public/listIncludes.ps1 b/public/listIncludes.ps1 index 05a2b1c..d4544ad 100644 --- a/public/listIncludes.ps1 +++ b/public/listIncludes.ps1 @@ -146,3 +146,76 @@ function Open-IncludeFile{ } } Export-ModuleMember -Function Open-IncludeFile + +function Compare-IncludeFile{ + [CmdletBinding()] + [Alias("cif")] + param( + #add filter pattern + [Parameter( Position = 0 )] [string]$Filter = '*', + [Parameter()][string[]]$Folders, + [Parameter()][string]$ModuleRootPath, + [Parameter()][switch]$PassThru, + [Parameter()][switch]$All + ) + + # If not ModuleRootPath specified, use local + if([string]::IsNullOrWhiteSpace($ModuleRootPath)){ $local = $true } + + $allLocal = Get-IncludeFile -Filter $Filter -Folders $Folders -ModuleRootPath:$ModuleRootPath -Local:$Local + $allRemote = Get-IncludeFile -Filter $Filter -Folders $Folders -ModuleRootPath $ModuleRootPath + + $allLocal =$allLocal ?? @() + $allRemote =$allRemote ?? @() + + "Found $($allLocal.Count) local and $($allRemote.Count) remote include files for filter [$Filter] in folders [$($Folders -join ', ')]" | Write-MyDebug -Section "cif" + + $ret = @() + $done = @() + + # Compare existing files + $allItems = $All ? $($allLocal + $allRemote) : $alllocal + + $allItems | ForEach-Object { + # Check if done + $filetag = "$($_.FolderName)_$($_.Name)" + + if($done -notcontains $filetag){ + + $done += $filetag + + $local = $allLocal | Where-Object { "$($_.FolderName)_$($_.Name)" -eq $filetag } + $remote = $allRemote | Where-Object { "$($_.FolderName)_$($_.Name)" -eq $filetag } + "Local : $($local.Name) $($local.FolderName) $($local.Version) $($local.Date) $($local.Sha) $($local.GitStatus)" | Write-MyDebug -Section "cif" + "Remote : $($remote.Name) $($remote.FolderName) $($remote.Version) $($remote.Date) $($remote.Sha) $($remote.GitStatus)" | Write-MyDebug -Section "cif" + + $areEqual = $local.Sha -eq $remote.Sha + + $item = [PsCustomObject]@{ + Name = $_.Name + FolderName = $_.FolderName + + AreEqual = $areEqual + + LocalVersion = $local.Version + LocalDate = $local.Date + LocalGitStatus = $local.GitStatus + + RemoteVersion = $remote.Version + RemoteDate = $remote.Date + RemoteGitStatus = $remote.GitStatus + } + $ret += $item + } + } + + $ret = $ret |sort-object -Property AreEqual,FolderName, Name + + if($PassThru){ + return $ret + } else { + $ret | Format-Table -AutoSize + } + +} Export-ModuleMember -Function Compare-IncludeFile -Alias "cif" + From 7023a5735c234b97c3ca8b8168fbc8995acab42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 5 Jul 2026 09:21:46 +0200 Subject: [PATCH 19/25] test: update assertions to include source parameter in file version tests --- Test/public/addIncludeToWorkspace.test.ps1 | 24 ++++++++--- Test/public/getfileversion.test.ps1 | 13 +++--- Test/public/invokeCommand.mock.test.ps1 | 3 ++ Test/public/setfileversion.test.ps1 | 50 ++++++++++++---------- 4 files changed, 55 insertions(+), 35 deletions(-) diff --git a/Test/public/addIncludeToWorkspace.test.ps1 b/Test/public/addIncludeToWorkspace.test.ps1 index 187ac2b..1d4542f 100644 --- a/Test/public/addIncludeToWorkspace.test.ps1 +++ b/Test/public/addIncludeToWorkspace.test.ps1 @@ -99,18 +99,28 @@ function Test_AddIncludeToWorkspace_IfExists{ #Act $includefiles | Add-IncludeToWorkspace -DestinationModulePath $moduleName -IfExists - #Assert + #Assert check that existing files were updatated $filesDest1 = Get-ChildItem -Path $destFolder1 Assert-Count -Expected 1 -Presented $filesDest1 - $contentFile1 = Get-Content -Path $filesDest1.FullName | Out-String - $sourceFile1 = $header + (Get-Content -Path $include1.Path) | Out-String - Assert-AreEqual -Expected $sourceFile1.Trim() -Presented $contentFile1.Trim() + $targetFile1 = Get-Content -Path $filesDest1.FullName + $sourceFile1 = (Get-Content -Path $include1.Path) + + # Remove the header as they may be different due to the versioning and date of the file + $targetFile1 = Remove-VersionHeader -Content $targetFile1 | Out-String + $sourceFile1 = Remove-VersionHeader -Content $sourceFile1 | Out-String + + Assert-AreEqual -Expected $sourceFile1.Trim() -Presented $targetFile1.Trim() $filesDest2 = Get-ChildItem -Path $destFolder2 Assert-Count -Expected 1 -Presented $filesDest2 - $contentFile2 = Get-Content -Path $filesDest2.FullName | Out-String - $sourceFile2 = $header + (Get-Content -Path $include2.Path) | Out-String - Assert-AreEqual -Expected $sourceFile2.Trim() -Presented $contentFile2.Trim() + $targetFile2 = Get-Content -Path $filesDest2.FullName + $sourceFile2 = $header + (Get-Content -Path $include2.Path) + + # Remove the header as they may be different due to the versioning and date of the file + $targetFile2 = Remove-VersionHeader -Content $targetFile2 | Out-String + $sourceFile2 = Remove-VersionHeader -Content $sourceFile2 | Out-String + + Assert-AreEqual -Expected $sourceFile2.Trim() -Presented $targetFile2.Trim() } function Test_AddIncludeToWorkspace_PipeParameters{ diff --git a/Test/public/getfileversion.test.ps1 b/Test/public/getfileversion.test.ps1 index c1ce95b..9df361e 100644 --- a/Test/public/getfileversion.test.ps1 +++ b/Test/public/getfileversion.test.ps1 @@ -10,7 +10,6 @@ function Test_GetFileVersion_EmptyFile{ function Test_GetFileVersion_NoVersion{ - New-Testingfile -Name "TestFile.ps1" -Content $FILE_FACKE_CONTENT # Act @@ -18,7 +17,6 @@ function Test_GetFileVersion_NoVersion{ # Assert Assert-IsNull -Object $result - } function Test_GetFileVersion_OnlyVersion{ @@ -27,7 +25,9 @@ function Test_GetFileVersion_OnlyVersion{ $headerversion = 1 $version = "1.0.0" $date = "1975-02-18" - $json = Build-TestFileVersionJson $Version $Date $headerversion + $source = "IncludeHelper" + + $json = Build-TestFileVersionJson $Version $Date $source $headerversion New-Testingfile -Name "TestFile.ps1" -Content $("# $json") Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date @@ -38,6 +38,8 @@ function Test_GetFileVersion_OnlyVersion{ Assert-IsNotNull -Object $result Assert-AreEqual -Expected $version -Presented $result.Version Assert-AreEqual -Expected $date -Presented $result.Date + Assert-AreEqual -Expected $source -Presented $result.Source + Assert-AreEqual -Expected $headerversion -Presented $result.HeaderVersion } function Test_GetFileVersion_VersionAndBody{ @@ -46,11 +48,12 @@ function Test_GetFileVersion_VersionAndBody{ $headerversion = 1 $version = "1.0.0" $date = "1975-02-18" - $header = Build-TestVersionHeader $Version $Date $headerversion + $source = "IncludeHelper" + $header = Build-TestVersionHeader $Version $Date $source $headerversion $body = $FILE_FACKE_CONTENT $content = $header + $body | Out-String New-Testingfile -Name "TestFile.ps1" -Content $content - Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date -Body $body + Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date -Body $body # Act $result = Get-IncludeFileVersion -Path "TestFile.ps1" diff --git a/Test/public/invokeCommand.mock.test.ps1 b/Test/public/invokeCommand.mock.test.ps1 index adcd84d..c4e121e 100644 --- a/Test/public/invokeCommand.mock.test.ps1 +++ b/Test/public/invokeCommand.mock.test.ps1 @@ -44,6 +44,9 @@ function Test_MockCallToObject{ function Test_MockCallToObject_ResetMockObject{ + # Reset again toremove the preset dates variables + Reset-InvokeCommandMock + MockCallToObject -Command 'kk1' -OutObject 'Testkk1' MockCallToObject -Command 'kk2' -OutObject 'Testkk2' MockCallToObject -Command 'kk3' -OutObject 'Testkk3' diff --git a/Test/public/setfileversion.test.ps1 b/Test/public/setfileversion.test.ps1 index 1683479..e534b1b 100644 --- a/Test/public/setfileversion.test.ps1 +++ b/Test/public/setfileversion.test.ps1 @@ -1,29 +1,31 @@ function Test_SetFileVersion_EmptyFile{ $version = "1.0.0" + $source = "kk" touch "TestFile.ps1" # Act - $result = Set-IncludeFileVersion -Path "TestFile.ps1" -Version $version + $result = Set-IncludeFileVersion -Path "TestFile.ps1" -Version $version -Source $source # Assert Assert-IsTrue -Condition $result - Assert-FileVersion -Path "TestFile.ps1" -Version $version + Assert-FileVersion -Path "TestFile.ps1" -Version $version -source $source } function Test_SetFileVersion_NoVersion{ $version = "1.0.0" + $source = "kk" New-Testingfile -Name "TestFile.ps1" -Content $FILE_FACKE_CONTENT # Act - $result = Set-IncludeFileVersion -Path "TestFile.ps1" -Version $version + $result = Set-IncludeFileVersion -Path "TestFile.ps1" -Version $version -Source $source # Assert Assert-IsTrue -Condition $result - Assert-FileVersion -Path "TestFile.ps1" -Version $version -Body $FILE_FACKE_CONTENT + Assert-FileVersion -Path "TestFile.ps1" -Version $version -Body $FILE_FACKE_CONTENT -Source $source } @@ -35,37 +37,39 @@ function Test_SetFileVersion_OnlyVersion{ $headerversion = 1 $version = "1.0.0" $date = "1975-02-18" - $json = Build-TestFileVersionJson $Version $Date $headerversion + $source = "kk" + $json = Build-TestFileVersionJson $Version $Date $source $headerversion New-Testingfile -Name "TestFile.ps1" -Content $("# $json") - Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date + Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date -Source $source # Act - $result = Set-IncludeFileVersion -Path "TestFile.ps1" -Version $version + $result = Set-IncludeFileVersion -Path "TestFile.ps1" -Version $version -Source $source # Assert Assert-IsTrue -Condition $result - Assert-FileVersion -Path "TestFile.ps1" -Version $version + Assert-FileVersion -Path "TestFile.ps1" -Version $version -Source $source } function Test_SetFileVersion_VersionAndBody{ $version = "3.2.1" + $source = "kk" # Arrange version in file $headerversion = 1 $version = "1.0.0" $date = "1975-02-18" - $json = Build-TestFileVersionJson $Version $Date $headerversion + $json = Build-TestFileVersionJson $Version $Date $source $headerversion New-Testingfile -Name "TestFile.ps1" -Content $("# $json") - Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date + Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date -Source $source # Act - $result = Set-IncludeFileVersion -Path "TestFile.ps1" -Version $version + $result = Set-IncludeFileVersion -Path "TestFile.ps1" -Version $version -Source $source # Assert Assert-IsTrue -Condition $result Enable-IncludeHelperDebug -Section "Assert-FileVersion" - Assert-FileVersion -Path "TestFile.ps1" -Version $version -Body $body + Assert-FileVersion -Path "TestFile.ps1" -Version $version -Body $body -Source $source Disable-IncludeHelperDebug } @@ -82,14 +86,15 @@ function Assert-FileVersion{ [string]$Path, [string]$Version, [string]$Date = (Get-Date -Format "yyyy-MM-dd"), - [string]$Body + [string]$Body, + [string]$Source = "IncludeHelper" ) $headerversion = 1 $headeersizeinlines = $script:TEST_HEADER_V1.Count - $content = Get-Content -Path $Path | Out-String - $json = Build-TestFileVersionJson $Version $Date "IncludeHelper" $headerversion + $content = (Get-Content -Path $Path) -join "`n" + $json = Build-TestFileVersionJson $Version $Date $Source $headerversion $expected = "# $json" $content = @(Get-Content -Path $Path) @@ -101,13 +106,12 @@ function Assert-FileVersion{ # Assert content if provided if(-not [string]::IsNullOrWhiteSpace($Body)){ # "Comparing body" | Write-MyDebug -Section "Assert-FileVersion" - # Remove the first line from content + + # Remove header from content to compare with body $rest = $content | Select-Object -Skip $headeersizeinlines - # join string[] to string $rest = $rest -join "`n" - # "Body presented:" | Write-MyDebug -Section "Assert-FileVersion" -Object $Body - # "Rest Content :" | Write-MyDebug -Section "Assert-FileVersion" -Object $rest - Assert-AreEqual -Expected $Body -Presented $rest -Comment "Rest of the file content should be the same" + + Assert-AreEqual -Expected $Body -Presented $rest } } @@ -118,7 +122,7 @@ function Build-TestFileVersionJson($Version, $Date, $Source, $Headerversion){ $json = [pscustomobject]@{ Version = $Version Date = $Date - Source = "IncludeHelper" + Source = $Source HeaderVersion = $Headerversion } } else { @@ -134,11 +138,11 @@ function Build-TestFileVersionJson($Version, $Date, $Source, $Headerversion){ } $script:TEST_HEADER_V1 = @( - '# {"Version":"{version}","Date":"{date}", "Source":"{source}","HeaderVersion":{headerversion}}', + '# {"Version":"{version}","Date":"{date}","Source":"{source}","HeaderVersion":{headerversion}}', "# DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE." ) -function Build-TestVersionHeader($version, $Date, $headerversion){ +function Build-TestVersionHeader($version, $Date, $source,$headerversion){ # Sync this code with Build-VersionHeader at public/setfileversion.ps1 $headerversion = $headerversion From 1a6b110d3b628d7a07b06de2c45608a578049ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 5 Jul 2026 09:21:53 +0200 Subject: [PATCH 20/25] refactor(Get-IncludeFileVersion): simplify return value by directly returning version --- public/getfileversion.ps1 | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/public/getfileversion.ps1 b/public/getfileversion.ps1 index b33f2d7..8a55e5b 100644 --- a/public/getfileversion.ps1 +++ b/public/getfileversion.ps1 @@ -18,16 +18,7 @@ function Get-IncludeFileVersion{ $version = Get-VersionFromHeader -content $content - if($version){ - $ret = [PsCustomObject]@{ - Version = $version.Version - Date = $version.Date - } - } else { - $ret = $null - } - - return $ret + return $version } Export-ModuleMember -Function Get-IncludeFileVersion From 174701ad98b8fdb36016df24289f9f9b4a39150c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 5 Jul 2026 09:22:04 +0200 Subject: [PATCH 21/25] refactor(tests): unify content retrieval by joining lines in test assertions --- Test/include/invokeCommand.mock.ps1 | 2 +- Test/public/addIncludeToWorkspace.test.ps1 | 8 ++++---- Test/public/getfileversion.test.ps1 | 2 +- Test/public/module.helper.test.ps1 | 5 ++--- public/listIncludes.ps1 | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Test/include/invokeCommand.mock.ps1 b/Test/include/invokeCommand.mock.ps1 index ad8f4c7..6cd8d3a 100644 --- a/Test/include/invokeCommand.mock.ps1 +++ b/Test/include/invokeCommand.mock.ps1 @@ -173,7 +173,7 @@ function Get-MockFileContent{ $filePath = Get-MockFileFullPath -fileName $fileName - $content = Get-Content -Path $filePath | Out-String + $content = (Get-Content -Path $filePath) -join "`n" return $content } Export-ModuleMember -Function Get-MockFileContent diff --git a/Test/public/addIncludeToWorkspace.test.ps1 b/Test/public/addIncludeToWorkspace.test.ps1 index 1d4542f..f11c339 100644 --- a/Test/public/addIncludeToWorkspace.test.ps1 +++ b/Test/public/addIncludeToWorkspace.test.ps1 @@ -106,8 +106,8 @@ function Test_AddIncludeToWorkspace_IfExists{ $sourceFile1 = (Get-Content -Path $include1.Path) # Remove the header as they may be different due to the versioning and date of the file - $targetFile1 = Remove-VersionHeader -Content $targetFile1 | Out-String - $sourceFile1 = Remove-VersionHeader -Content $sourceFile1 | Out-String + $targetFile1 = (Remove-VersionHeader -Content $targetFile1) -join "`n" + $sourceFile1 = (Remove-VersionHeader -Content $sourceFile1) -join "`n" Assert-AreEqual -Expected $sourceFile1.Trim() -Presented $targetFile1.Trim() @@ -117,8 +117,8 @@ function Test_AddIncludeToWorkspace_IfExists{ $sourceFile2 = $header + (Get-Content -Path $include2.Path) # Remove the header as they may be different due to the versioning and date of the file - $targetFile2 = Remove-VersionHeader -Content $targetFile2 | Out-String - $sourceFile2 = Remove-VersionHeader -Content $sourceFile2 | Out-String + $targetFile2 = (Remove-VersionHeader -Content $targetFile2) -join "`n" + $sourceFile2 = (Remove-VersionHeader -Content $sourceFile2) -join "`n" Assert-AreEqual -Expected $sourceFile2.Trim() -Presented $targetFile2.Trim() } diff --git a/Test/public/getfileversion.test.ps1 b/Test/public/getfileversion.test.ps1 index 9df361e..fc66154 100644 --- a/Test/public/getfileversion.test.ps1 +++ b/Test/public/getfileversion.test.ps1 @@ -51,7 +51,7 @@ function Test_GetFileVersion_VersionAndBody{ $source = "IncludeHelper" $header = Build-TestVersionHeader $Version $Date $source $headerversion $body = $FILE_FACKE_CONTENT - $content = $header + $body | Out-String + $content = ($header + $body) -join "`n" New-Testingfile -Name "TestFile.ps1" -Content $content Assert-FileVersion -Path "TestFile.ps1" -Version $version -Date $date -Body $body diff --git a/Test/public/module.helper.test.ps1 b/Test/public/module.helper.test.ps1 index a4abb4f..6e8826b 100644 --- a/Test/public/module.helper.test.ps1 +++ b/Test/public/module.helper.test.ps1 @@ -15,9 +15,8 @@ function Test_ModuleHelper_AreEqual_InModule_And_TestModule{ $filePath[$_]= $path | Join-Path -ChildPath $files[$_].Name } - $content1 = Get-Content -Path $filePath[0] | Out-String - $content2 = Get-Content -Path $filePath[1] | Out-String - + $content1 = (Get-Content -Path $filePath[0]) -join "`n" + $content2 = (Get-Content -Path $filePath[1]) -join "`n" Assert-AreEqual -Expected $content1 -Presented $content2 } diff --git a/public/listIncludes.ps1 b/public/listIncludes.ps1 index d4544ad..2b65d34 100644 --- a/public/listIncludes.ps1 +++ b/public/listIncludes.ps1 @@ -79,7 +79,7 @@ function Get-IncludeFile{ $body = $content } - $sha = $body | Out-String | Get-HashCode + $sha = $body -join "`n" | Get-HashCode $gitStatus = $(Test-RepoFileChanged -Path $_.FullName )? "Modified" : "Unmodified" [PSCustomObject]@{ From d43055c604ae05b38608c810f66e0e6cc2988631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Sun, 5 Jul 2026 09:51:59 +0200 Subject: [PATCH 22/25] feat(Write-MyDebug): add ObjectNotCompress parameter for debug output --- include/MyWrite.ps1 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/MyWrite.ps1 b/include/MyWrite.ps1 index f4658d3..5da954a 100644 --- a/include/MyWrite.ps1 +++ b/include/MyWrite.ps1 @@ -1,4 +1,4 @@ -# {"Version":"1.4.0","Date":"2026-06-25","Source":"IncludeHelper","HeaderVersion":1} +# {"Version":"1.5.0","Date":"2026-06-25","Source":"IncludeHelper","HeaderVersion":1} # DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE. # Include MyWrite.ps1 # Provides Write-MyError, Write-MyWarning, Write-MyVerbose, Write-MyHost, Write-MyDebug @@ -88,7 +88,8 @@ function Write-MyDebug { [Parameter(Position = 0)][string]$section = "none", [Parameter(Position = 1, ValueFromPipeline)][string]$Message, [Parameter(Position = 2)][object]$Object, - [Parameter()][int]$objectDepth = 10 + [Parameter()][int]$objectDepth = 10, + [Parameter()][switch]$ObjectNotCompress ) process{ @@ -96,7 +97,8 @@ function Write-MyDebug { if (Test-MyDebug -section $section) { if ($Object) { - $objString = $Object | Get-ObjetString -Depth $objectDepth + $compress = -not $ObjectNotCompress + $objString = $Object | Get-ObjetString -Depth $objectDepth -Compress:$compress $message = $message + " - " + $objString } @@ -280,7 +282,7 @@ function Enable-ModuleNameDebug{ } if($DoNotClearHost){ - $sections += "donotclearhost" + $sectons += "donotclearhost" } $sectionsString = $sections -join " " @@ -357,7 +359,8 @@ Export-ModuleMember -Function "Get-$($MODULE_NAME)Debug" function Get-ObjetString { param( [Parameter(ValueFromPipeline, Position = 0)][object]$Object, - [Parameter()][int]$Depth = 10 + [Parameter()][int]$Depth = 10, + [Parameter()][switch]$Compress ) process{ @@ -370,7 +373,7 @@ function Get-ObjetString { return $Object } - return $Object | ConvertTo-Json -Depth $Depth -ErrorAction SilentlyContinue + return $Object | ConvertTo-Json -Depth $Depth -ErrorAction SilentlyContinue -Compress:$Compress } } From dd7ee2ea9a91746c61d553ec13fb675273712a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Fri, 17 Jul 2026 18:18:20 +0200 Subject: [PATCH 23/25] feat(MyWrite): update version and add InNewLine parameter to Write-MyHost and Write-MyDebug functions --- include/MyWrite.ps1 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/include/MyWrite.ps1 b/include/MyWrite.ps1 index 5da954a..6288c73 100644 --- a/include/MyWrite.ps1 +++ b/include/MyWrite.ps1 @@ -1,4 +1,4 @@ -# {"Version":"1.5.0","Date":"2026-06-25","Source":"IncludeHelper","HeaderVersion":1} +# {"Version":"1.6.0","Date":"2026-07-17","Source":"includehelper","HeaderVersion":1} # DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE. # Include MyWrite.ps1 # Provides Write-MyError, Write-MyWarning, Write-MyVerbose, Write-MyHost, Write-MyDebug @@ -62,9 +62,14 @@ function Write-MyHost { param( [Parameter(ValueFromPipeline)][string]$Message, [Parameter()][string]$ForegroundColor = $OUTPUT_COLOR, - [Parameter()][switch]$NoNewLine + [Parameter()][switch]$NoNewLine, + [Parameter()][switch]$InNewLine + ) + # Add starting new line if InNewLine is specified + if ($InNewLine) { $Message = "`n" + $Message } + Write-MyDebug -Section "MyHost" -Message $Message # Write-Host $message -ForegroundColor $OUTPUT_COLOR @@ -89,7 +94,8 @@ function Write-MyDebug { [Parameter(Position = 1, ValueFromPipeline)][string]$Message, [Parameter(Position = 2)][object]$Object, [Parameter()][int]$objectDepth = 10, - [Parameter()][switch]$ObjectNotCompress + [Parameter()][switch]$ObjectNotCompress, + [Parameter()][switch]$InNewLine ) process{ @@ -104,6 +110,10 @@ function Write-MyDebug { $logMessage = normalizeMessage -Message $message -Section $section -Tag "D" + if ($InNewLine) { + $logMessage = "`n" + $logMessage + } + $logMessage | Write-ToConsole -Color $DEBUG_COLOR $logMessage | Write-MyDebugLogging } From 5c14fb1e9433720d090866309c1a432be3b713a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Fri, 17 Jul 2026 18:18:46 +0200 Subject: [PATCH 24/25] feat(Compare-IncludeFile): add OpenDiff parameter to open diffs for unequal files --- public/listIncludes.ps1 | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/public/listIncludes.ps1 b/public/listIncludes.ps1 index 2b65d34..4d8eb73 100644 --- a/public/listIncludes.ps1 +++ b/public/listIncludes.ps1 @@ -156,7 +156,9 @@ function Compare-IncludeFile{ [Parameter()][string[]]$Folders, [Parameter()][string]$ModuleRootPath, [Parameter()][switch]$PassThru, - [Parameter()][switch]$All + [Parameter()][switch]$All, + [Parameter()][switch]$Opendiff + ) # If not ModuleRootPath specified, use local @@ -200,10 +202,12 @@ function Compare-IncludeFile{ LocalVersion = $local.Version LocalDate = $local.Date LocalGitStatus = $local.GitStatus + LocalPath = $local.Path RemoteVersion = $remote.Version RemoteDate = $remote.Date RemoteGitStatus = $remote.GitStatus + RemotePath = $remote.Path } $ret += $item } @@ -211,11 +215,21 @@ function Compare-IncludeFile{ $ret = $ret |sort-object -Property AreEqual,FolderName, Name + if($OpenDiff){ + $ret | foreach-object{ + if(-not $_.AreEqual){ + Write-MyDebug "Opening diff for $($_.Name) in folder $($_.FolderName)" -Section "cif" + code --diff $($_.LocalPath) $($_.RemotePath) + } else { + Write-MyDebug "Skipping diff for $($_.Name) in folder $($_.FolderName) as they are equal" -Section "cif" + } + } + } + if($PassThru){ return $ret } else { - $ret | Format-Table -AutoSize + $ret | Format-Table -Property Name,FolderName,AreEqual,LocalVersion,LocalDate,LocalGitStatus,RemoteVersion,RemoteDate,RemoteGitStatus -AutoSize } } Export-ModuleMember -Function Compare-IncludeFile -Alias "cif" - From da9e3629872324a54505d7e0624cf5e0042cb17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20=28Dibildos=29=20Gonz=C3=A1lez?= Date: Fri, 17 Jul 2026 18:22:18 +0200 Subject: [PATCH 25/25] style(MyWrite): add newline for improved readability --- include/MyWrite.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/include/MyWrite.ps1 b/include/MyWrite.ps1 index 6288c73..d6ce0bc 100644 --- a/include/MyWrite.ps1 +++ b/include/MyWrite.ps1 @@ -1,5 +1,6 @@ # {"Version":"1.6.0","Date":"2026-07-17","Source":"includehelper","HeaderVersion":1} # DO NOT MODIFY THIS FILE MANUALLY. IT IS GENERATED BY THE IncludeHelper MODULE. + # Include MyWrite.ps1 # Provides Write-MyError, Write-MyWarning, Write-MyVerbose, Write-MyHost, Write-MyDebug # and Test-MyVerbose, Test-MyDebug functions for consistent logging and debugging output.