Skip to content

Commit 6ded0ac

Browse files
committed
🚜 [refactor] Stabilize module-root resolution and localization loading
- πŸ› οΈ [fix] Add Get-Module -ListAvailable (ModuleBase) and respect COLOR_SCRIPTS_ENHANCED_MODULE_ROOT env var as fallback candidates so localized resources resolve from the intended module location - πŸ“ [docs] Add detailed import/debug tracing to a temp cs-module-root-debug.log (captures ModuleInfo, PSScriptRoot, candidate enumeration, found/not-found paths, Import-LocalizedData successes and failures) to aid diagnosis - πŸ”§ [build] Bump ModuleVersion to 2025.11.02.1436 and update ReleaseNotes; sync UICultureVersion entries in localized HelpInfo.xml files - πŸ§ͺ [test] Set and restore COLOR_SCRIPTS_ENHANCED_MODULE_ROOT in tests to force imports from the repo module path and reduce environment-specific flakiness Signed-off-by: Nick2bad4u <20943337+Nick2bad4u@users.noreply.github.com>
1 parent 9df9e8f commit 6ded0ac

16 files changed

Lines changed: 72 additions & 13 deletions

β€ŽColorScripts-Enhanced/ColorScripts-Enhanced.psd1β€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
RootModule = 'ColorScripts-Enhanced.psm1'
1212

1313
# Version number of this module.
14-
ModuleVersion = '2025.11.02.1403'
14+
ModuleVersion = '2025.11.02.1436'
1515

1616
# Supported PSEditions
1717
CompatiblePSEditions = @('Desktop', 'Core')
@@ -211,7 +211,7 @@ PERFECT FOR
211211

212212
# ReleaseNotes of this module
213213
ReleaseNotes = @'
214-
Version 2025.11.02.1403:
214+
Version 2025.11.02.1436:
215215
- Enhanced caching system with OS-wide cache in AppData
216216
- 6-19x performance improvement
217217
- Cache stored in centralized location

β€ŽColorScripts-Enhanced/ColorScripts-Enhanced.psm1β€Ž

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ $script:PowerShellMajorVersion = $PSVersionTable.PSVersion.Major
4040
# Determine the actual module root so that localized resources resolve correctly
4141
$moduleInfo = $ExecutionContext.SessionState.Module
4242
$moduleRootCandidates = @()
43+
$moduleRootDebugPath = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath 'cs-module-root-debug.log'
44+
"--- Import begin: $(Get-Date -Format o) ---" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
45+
"ModuleInfo.ModuleBase = $($moduleInfo?.ModuleBase)" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
46+
"ModuleInfo.Path = $($moduleInfo?.Path)" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
47+
"PSScriptRoot = $PSScriptRoot" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
4348

4449
if ($moduleInfo) {
4550
if ($moduleInfo.ModuleBase) {
@@ -55,6 +60,20 @@ if ($PSScriptRoot) {
5560
$moduleRootCandidates += $PSScriptRoot
5661
}
5762

63+
$availableModule = Get-Module -ListAvailable -Name 'ColorScripts-Enhanced' | Select-Object -First 1
64+
if ($availableModule -and $availableModule.ModuleBase) {
65+
$moduleRootCandidates += $availableModule.ModuleBase
66+
"ListAvailable ModuleBase = $($availableModule.ModuleBase)" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
67+
}
68+
69+
$environmentModuleRoot = $env:COLOR_SCRIPTS_ENHANCED_MODULE_ROOT
70+
if ($environmentModuleRoot) {
71+
$moduleRootCandidates += $environmentModuleRoot
72+
"Environment module root = $environmentModuleRoot" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
73+
}
74+
75+
"Initial candidates: $($moduleRootCandidates -join ';')" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
76+
5877
$resolvedCandidates = @()
5978
foreach ($candidate in $moduleRootCandidates) {
6079
if (-not $candidate) {
@@ -73,6 +92,7 @@ foreach ($candidate in $moduleRootCandidates) {
7392
}
7493

7594
$moduleRootCandidates = $resolvedCandidates
95+
"Resolved candidates: $($moduleRootCandidates -join ';')" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
7696

7797
$cultureFallback = @()
7898
try {
@@ -117,6 +137,7 @@ $searchedPaths = @()
117137

118138
foreach ($candidatePath in $moduleRootCandidates) {
119139
$searchedPaths += $candidatePath
140+
"Evaluating candidate: ${candidatePath}" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
120141

121142
$hasLocalizedFile = $false
122143
foreach ($cultureName in $cultureFallback) {
@@ -131,20 +152,24 @@ foreach ($candidatePath in $moduleRootCandidates) {
131152
$rootFallback = Join-Path -Path $candidatePath -ChildPath 'Messages.psd1'
132153
if (Test-Path -LiteralPath $rootFallback) {
133154
$hasLocalizedFile = $true
155+
"Found root fallback at ${rootFallback}" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
134156
}
135157
}
136158

137159
if (-not $hasLocalizedFile) {
160+
"No localized data found under ${candidatePath}" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
138161
continue
139162
}
140163

141164
try {
142165
Import-LocalizedData -BindingVariable "script:Messages" -FileName "Messages" -BaseDirectory $candidatePath -ErrorAction Stop
143166
$script:ModuleRoot = $candidatePath
144167
$localizedDataLoaded = $true
168+
"Localization loaded from ${candidatePath}" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
145169
break
146170
}
147171
catch {
172+
"Import-LocalizedData failed for ${candidatePath}: $($_.Exception.Message)" | Out-File -FilePath $moduleRootDebugPath -Encoding utf8 -Append
148173
continue
149174
}
150175
}

β€ŽColorScripts-Enhanced/de/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>de</UICultureName>
7-
<UICultureVersion>2025.11.02.1403</UICultureVersion>
7+
<UICultureVersion>2025.11.02.1436</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

β€ŽColorScripts-Enhanced/en-US/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>en-US</UICultureName>
7-
<UICultureVersion>2025.11.02.1403</UICultureVersion>
7+
<UICultureVersion>2025.11.02.1436</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

β€ŽColorScripts-Enhanced/es/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>es</UICultureName>
7-
<UICultureVersion>2025.11.02.1403</UICultureVersion>
7+
<UICultureVersion>2025.11.02.1436</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

β€ŽColorScripts-Enhanced/fr/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>fr</UICultureName>
7-
<UICultureVersion>2025.11.02.1403</UICultureVersion>
7+
<UICultureVersion>2025.11.02.1436</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

β€ŽColorScripts-Enhanced/it/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>it</UICultureName>
7-
<UICultureVersion>2025.11.02.1403</UICultureVersion>
7+
<UICultureVersion>2025.11.02.1436</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

β€ŽColorScripts-Enhanced/ja/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>ja</UICultureName>
7-
<UICultureVersion>2025.11.02.1403</UICultureVersion>
7+
<UICultureVersion>2025.11.02.1436</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

β€ŽColorScripts-Enhanced/nl/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>nl</UICultureName>
7-
<UICultureVersion>2025.11.02.1403</UICultureVersion>
7+
<UICultureVersion>2025.11.02.1436</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

β€ŽColorScripts-Enhanced/pt/ColorScripts-Enhanced_f77548d7-23eb-48ce-a6e0-f64b4758d995_HelpInfo.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<SupportedUICultures>
55
<UICulture>
66
<UICultureName>pt</UICultureName>
7-
<UICultureVersion>2025.11.02.1403</UICultureVersion>
7+
<UICultureVersion>2025.11.02.1436</UICultureVersion>
88
</UICulture>
99
</SupportedUICultures>
1010
</HelpInfo>

0 commit comments

Comments
Β (0)