Commit 0a8139f
committed
🚜 [refactor] Rework core private helpers, localization and caching flows
- Introduce Resolve-LocalizedMessagesFile: robust, culture-aware discovery for Messages.psd1 (case-insensitive dir matching, culture fallback, safe resolution) and integrate into Import-LocalizedMessagesFromFile.
- Rework Import-LocalizedMessagesFromFile / Initialize-ColorScriptsLocalization to probe multiple candidate roots, attempt per-candidate imports, select the first successful localized file, populate $script:LocalizationDetails (LocalizedDataLoaded/ModuleRoot/SearchedPaths/Source/FilePath) and gracefully fall back to embedded defaults with improved Write-ModuleTrace messages.
- Consolidate synchronization and delegate usage (Invoke-ModuleSynchronized + delegates) to make path/IO behaviors more testable and resilient.
- Preserve previous private helper snapshot under scripts/original-PrivateFunctions.ps1 for reference.
✨ [feat] Harden path resolution, cache & inventory behavior
- Resolve-CachePath: safer tilde (~) expansion via GetUserProfilePathDelegate with fallbacks to $HOME, validate drive qualifiers, and return $null for unresolved/invalid roots to avoid surprising IO operations.
- Initialize-CacheDirectory / Get-CachedOutput: initialize cache directory on demand, return consistent pscustomobject for missing/invalid state, and avoid throwing where not actionable.
- Get-ColorScriptInventory: avoid unnecessary full refreshes by detecting non-file entries in the cached inventory, probe file counts as a lightweight check, and preserve ScriptInventoryRecords / -Raw semantics.
- Invoke-ColorScriptProcess (fast in-process path): switch working directory using Get-Location -PSProvider FileSystem, capture all output streams with *>&1 for accurate cached output, and ensure working directory is restored.
- Allow Invoke-FileWriteAllText to accept empty content (AllowEmptyString) for explicit empty-file writes.
🛠️ [fix] Improve public cmdlets: profile handling, scaffolding and cache UX
- Add-ColorScriptProfile: detect remote hosts (PSSenderInfo) and avoid unsupported remote updates; robustly resolve PROFILE variants (PSObject / CurrentUserAllHosts), use Resolve-CachePath / session-based path fallbacks, honor configuration defaults, add SkipStartupScript and structured return {Path,Changed,Message}, and surface localized errors when resolution fails.
- New-ColorScript: add a 'Scaffold' ParameterSet, rename Destination→OutputPath, add Force/GenerateMetadataSnippet/Category/Tag support, produce a scaffold file + optional metadata guidance, call Reset-ScriptInventoryCache after creation, use ShouldProcess and return a structured metadata object on success.
- New-ColorScriptCache (alias Build-ColorScriptCache): add alias and default parameter set, accept pipeline input and accumulate Name patterns, normalize selection via Select-RecordsByName, metadata-driven selection (Category/Tag), progress reporting, consistent structured result records (Status/Message/ExitCode/StdOut/StdErr) and human-readable summary via Write-ColorScriptInformation; better handling for PassThru.
- Clear-ColorScriptCache: complete rewrite to support Name/Category/Tag/Path/All/DryRun/PassThru with pipeline-friendly name collection, pattern vs metadata matching, per-file Invoke-ShouldProcess checks, explicit status states (Removed/Missing/DryRun/Skipped/Errors), and a summarized informational output when not returning PassThru.
🔧 [build] Module manifest & export list updates
- Add 'Build-ColorScriptCache' to ColorScripts-Enhanced.psd1 AliasesToExport and to Export-ModuleMember -Alias in the module file so the new alias is exported consistently.
🧪 [test] Add import coverage tests and preserve original helpers
- Add comprehensive Tests/ColorScripts-Enhanced.ModuleImportCoverage.Tests.ps1 to validate trace configuration parsing, trace-file preparation/fallback, module-root discovery, and robust import behavior when Private/Public folders are unavailable.
- Add scripts/original-PrivateFunctions.ps1 to keep a snapshot of the prior private implementation for easier review/debugging.
- Remove stale test-output.txt.
🧹 [chore] Formatting, completions and small cleanups
- Tidy argument-completer scriptblocks and indentation (Get-ColorScriptList, Show-ColorScript) to improve readability and avoid subtle completion bugs; remove duplicate NoAnsiOutput assignments in Show-ColorScript.
- Minor trailing-newline / whitespace fixes added to multiple public files (Export-ColorScriptMetadata, Get-ColorScriptConfiguration, Reset-ColorScriptConfiguration, Set-ColorScriptConfiguration).
- Small message / error-id clarifications and more consistent use of structured result objects across public cmdlets to improve downstream automation and tests.
Signed-off-by: Nick2bad4u <20943337+Nick2bad4u@users.noreply.github.com>1 parent 9d9505d commit 0a8139f
16 files changed
Lines changed: 4566 additions & 569 deletions
File tree
- ColorScripts-Enhanced
- Private
- Public
- Tests
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
| 366 | + | |
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| |||
0 commit comments