From 0fcefa8d9137a19008f7e825ff60333cd1138af2 Mon Sep 17 00:00:00 2001 From: Driss Date: Wed, 19 Aug 2026 10:53:57 +0100 Subject: [PATCH 1/2] Split paths to dirs and files --- src/actions/cache.ps1 | 8 +- src/actions/ini/add.ps1 | 14 ++-- src/actions/install.ps1 | 2 +- src/actions/log.ps1 | 8 +- src/actions/profile.ps1 | 40 +++++----- src/actions/run.ps1 | 2 +- src/actions/setup.ps1 | 26 +++---- src/actions/test.ps1 | 2 +- src/core/handlers.ps1 | 11 ++- src/helpers/config.ps1 | 85 ++++++++++++---------- src/helpers/output.ps1 | 4 +- src/helpers/php.ps1 | 8 +- src/helpers/store.ps1 | 2 +- src/helpers/system.ps1 | 4 +- src/helpers/update-check.ps1 | 6 +- tests/actions/cache.tests.ps1 | 6 +- tests/actions/current.tests.ps1 | 4 +- tests/actions/ini.tests.ps1 | 6 +- tests/actions/ini/add.tests.ps1 | 4 +- tests/actions/ini/disable.tests.ps1 | 4 +- tests/actions/ini/enable.tests.ps1 | 4 +- tests/actions/ini/ext.tests.ps1 | 2 +- tests/actions/ini/get.tests.ps1 | 4 +- tests/actions/ini/helpers/fetch.tests.ps1 | 4 +- tests/actions/ini/helpers/shared.tests.ps1 | 2 +- tests/actions/ini/info.tests.ps1 | 4 +- tests/actions/ini/remove.tests.ps1 | 2 +- tests/actions/ini/restore.tests.ps1 | 2 +- tests/actions/ini/set.tests.ps1 | 4 +- tests/actions/ini/status.tests.ps1 | 4 +- tests/actions/install.tests.ps1 | 4 +- tests/actions/list.tests.ps1 | 2 +- tests/actions/log.tests.ps1 | 6 +- tests/actions/profile.tests.ps1 | 10 +-- tests/actions/run.tests.ps1 | 2 +- tests/actions/setup.tests.ps1 | 2 +- tests/actions/uninstall.tests.ps1 | 2 +- tests/actions/use.tests.ps1 | 2 +- tests/core/bootstrap.tests.ps1 | 2 +- tests/core/handlers.tests.ps1 | 2 +- tests/helpers/config.tests.ps1 | 70 +++++++++--------- tests/helpers/io.tests.ps1 | 4 +- tests/helpers/output.tests.ps1 | 8 +- tests/helpers/php.tests.ps1 | 8 +- tests/helpers/setup-check.tests.ps1 | 2 +- tests/helpers/store.tests.ps1 | 4 +- tests/helpers/system.tests.ps1 | 8 +- tests/helpers/update-check.tests.ps1 | 6 +- tests/helpers/wrappers.tests.ps1 | 2 +- 49 files changed, 215 insertions(+), 209 deletions(-) diff --git a/src/actions/cache.ps1 b/src/actions/cache.ps1 index 6dc95b14..bc8f8ad7 100644 --- a/src/actions/cache.ps1 +++ b/src/actions/cache.ps1 @@ -1,11 +1,11 @@  function Get-CacheFiles { try { - if (Test-DirectoryNotExists -path $PVMConfig.paths.cache) { + if (Test-DirectoryNotExists -path $PVMConfig.paths.directories.cache) { return $null } - $files = Get-ChildItemWrapper -path $PVMConfig.paths.cache -filter '*.json' + $files = Get-ChildItemWrapper -path $PVMConfig.paths.directories.cache -filter '*.json' return $files } catch { @@ -16,7 +16,7 @@ function Get-CacheFiles { function Show-CacheFiles { try { - if (Test-DirectoryNotExists -path $PVMConfig.paths.cache) { + if (Test-DirectoryNotExists -path $PVMConfig.paths.directories.cache) { Show-Error -message "`nNo cache directory found." return -1 } @@ -123,7 +123,7 @@ function Clear-CacheFiles { } } - Remove-ItemWrapper -path "$($PVMConfig.paths.cache)\*" + Remove-ItemWrapper -path "$($PVMConfig.paths.directories.cache)\*" Show-Success -message "`nAll cache files deleted successfully." diff --git a/src/actions/ini/add.ps1 b/src/actions/ini/add.ps1 index 99025a3b..e80fdaba 100644 --- a/src/actions/ini/add.ps1 +++ b/src/actions/ini/add.ps1 @@ -103,7 +103,7 @@ function Install-XDebugExtension { } if ($null -eq $xDebugList -or $xDebugList.Count -eq 0) { - Show-Error -message "`nNo match was found, check the '$($PVMConfig.paths.logError)' for any potentiel errors" + Show-Error -message "`nNo match was found, check the '$($PVMConfig.paths.files.logError)' for any potentiel errors" return -1 } @@ -171,21 +171,21 @@ function Install-XDebugExtension { return -1 } - $null = Invoke-WebRequestWrapper -uri "$($PVMConfig.links.xdebugBase)/$($chosenItem.href.TrimStart('/'))" -outFile $PVMConfig.paths.php + $null = Invoke-WebRequestWrapper -uri "$($PVMConfig.links.xdebugBase)/$($chosenItem.href.TrimStart('/'))" -outFile $PVMConfig.paths.directories.php $phpPath = ($iniPath | Split-Path -Parent) if (-not $skipConfirmation) { if (Test-FileExists -path "$phpPath\ext\$($chosenItem.fileName)") { $response = Read-HostWrapper -prompt "`n$($chosenItem.fileName) already exists. Would you like to overwrite it? (y/n)" if (Test-NoResponse -response $response) { - Remove-ItemWrapper -path "$($PVMConfig.paths.php)\$($chosenItem.fileName)" + Remove-ItemWrapper -path "$($PVMConfig.paths.directories.php)\$($chosenItem.fileName)" Write-Gray -message "`nInstallation cancelled" return -1 } } } - Move-ItemWrapper -path "$($PVMConfig.paths.php)\$($chosenItem.fileName)" -destination "$phpPath\ext" + Move-ItemWrapper -path "$($PVMConfig.paths.directories.php)\$($chosenItem.fileName)" -destination "$phpPath\ext" $xDebugConfig = Get-XdebugConfigV2 -XDebugPath $($chosenItem.fileName) if ($chosenItem.xDebugVersion -like '3.*') { $xDebugConfig = Get-XdebugConfigV3 -XDebugPath $($chosenItem.fileName) @@ -348,9 +348,9 @@ function Install-Extension { return -1 } - $null = Invoke-WebRequestWrapper -uri $chosenItem.href -outFile $PVMConfig.paths.php + $null = Invoke-WebRequestWrapper -uri $chosenItem.href -outFile $PVMConfig.paths.directories.php $fileNamePath = ($chosenItem.href -replace "$($PVMConfig.links.peclWinExtDownload)/$extName/$($chosenItem.extVersion)/|.zip", '').Trim() - $extractPath = "$($PVMConfig.paths.php)\$fileNamePath" + $extractPath = "$($PVMConfig.paths.directories.php)\$fileNamePath" Expand-Zip -zipPath "$extractPath.zip" -extractPath $extractPath -deleteZipAfter $true $files = Get-ChildItemWrapper -path $extractPath $extFile = $files | Where-Object -FilterScript { @@ -367,7 +367,7 @@ function Install-Extension { if (Test-FileExists -path "$phpPath\ext\$($extFile.Name)") { $response = Read-HostWrapper -prompt "`n$($extFile.Name) already exists. Would you like to overwrite it? (y/n)" if (Test-NoResponse -response $response) { - Remove-ItemWrapper -path "$($PVMConfig.paths.php)\$fileNamePath" + Remove-ItemWrapper -path "$($PVMConfig.paths.directories.php)\$fileNamePath" Write-Gray -message "`nInstallation cancelled" return -1 } diff --git a/src/actions/install.ps1 b/src/actions/install.ps1 index 7b444ac5..1d32a074 100644 --- a/src/actions/install.ps1 +++ b/src/actions/install.ps1 @@ -182,7 +182,7 @@ function Get-PHP { $buildType = $versionObject.BuildType $arch = $versionObject.arch - $destination = $PVMConfig.paths.php + $destination = $PVMConfig.paths.directories.php $created = New-Directory -path $destination if ($created -ne 0) { Show-Error -message "Failed to create directory $destination" diff --git a/src/actions/log.ps1 b/src/actions/log.ps1 index b31b1443..c4d6a717 100644 --- a/src/actions/log.ps1 +++ b/src/actions/log.ps1 @@ -233,12 +233,12 @@ function Show-Log { $pageSize = [int]$pageSize # Check if log file exists - if (Test-FileNotExists -path $PVMConfig.paths.logError) { - Show-Error -message "`nLog file not found: $($PVMConfig.paths.logError)" + if (Test-FileNotExists -path $PVMConfig.paths.files.logError) { + Show-Error -message "`nLog file not found: $($PVMConfig.paths.files.logError)" return -1 } - $entries = @(Get-LogEntries -path $PVMConfig.paths.logError -term $term) + $entries = @(Get-LogEntries -path $PVMConfig.paths.files.logError -term $term) if ($entries.Length -eq 0) { Show-Warning -message "`nNo log entries found." @@ -264,7 +264,7 @@ function Show-Log { Clear-Host return 0 } catch { - Show-Error -message "`nFailed to show log: $($PVMConfig.paths.logError)" + Show-Error -message "`nFailed to show log: $($PVMConfig.paths.files.logError)" $null = Add-LogEntry -data @{ header = "$($MyInvocation.MyCommand.Name) - Failed to show log"; exception = $_ } return -1 } diff --git a/src/actions/profile.ps1 b/src/actions/profile.ps1 index d9267b7a..117abc5c 100644 --- a/src/actions/profile.ps1 +++ b/src/actions/profile.ps1 @@ -156,8 +156,8 @@ function Disable-IniExtensionDirect { function Get-PopularPHPSettings { try { # Return list of popular/common PHP settings that should be included in profiles - if (Test-FileExists -path $PVMConfig.paths.profileTemplate) { - $data = (Get-ContentWrapper -path $PVMConfig.paths.profileTemplate -raw | ConvertFrom-Json) + if (Test-FileExists -path $PVMConfig.paths.files.profileTemplate) { + $data = (Get-ContentWrapper -path $PVMConfig.paths.files.profileTemplate -raw | ConvertFrom-Json) if ($null -ne $data.settings -and $data.settings.Count -gt 0) { return $data.settings } @@ -172,8 +172,8 @@ function Get-PopularPHPSettings { function Get-PopularPHPExtensions { try { # Return list of popular/common PHP extensions that should be included in profiles - if (Test-FileExists -path $PVMConfig.paths.profileTemplate) { - $data = (Get-ContentWrapper -path $PVMConfig.paths.profileTemplate -raw | ConvertFrom-Json) + if (Test-FileExists -path $PVMConfig.paths.files.profileTemplate) { + $data = (Get-ContentWrapper -path $PVMConfig.paths.files.profileTemplate -raw | ConvertFrom-Json) if ($null -ne $data.extensions -and $data.extensions.Count -gt 0) { return $data.extensions } @@ -244,13 +244,13 @@ function Save-PHPProfile { } # Save to JSON file - $created = New-Directory -path $PVMConfig.paths.profiles + $created = New-Directory -path $PVMConfig.paths.directories.profiles if ($created -ne 0) { Show-Error -message "`nFailed to create profiles directory." return -1 } - $profilePath = "$($PVMConfig.paths.profiles)\$profileName.json" + $profilePath = "$($PVMConfig.paths.directories.profiles)\$profileName.json" $jsonContent = $userProfile | ConvertTo-Json -Depth 10 Set-ContentWrapper -path $profilePath -value $jsonContent @@ -259,7 +259,7 @@ function Save-PHPProfile { Show-Message -message " Extensions: $($userProfile.extensions.Count) (popular/common only)" Show-Message -message " Location: $profilePath" Show-Info -message "`nNote: Only popular/common settings and extensions are saved." - Show-Info -message " You can manually edit settings/extensions at '$($PVMConfig.paths.profileTemplate)'." + Show-Info -message " You can manually edit settings/extensions at '$($PVMConfig.paths.files.profileTemplate)'." return 0 } catch { @@ -287,7 +287,7 @@ function Use-PHPProfile { } # Load profile JSON - $profilePath = "$($PVMConfig.paths.profiles)\$profileName.json" + $profilePath = "$($PVMConfig.paths.directories.profiles)\$profileName.json" if (Test-FileNotExists -path $profilePath) { Show-Error -message "`nProfile '$profileName' not found." Show-Message -message " Use 'pvm profile list' to see available profiles." @@ -373,11 +373,11 @@ function Use-PHPProfile { function Get-ProfileFiles { try { - if (Test-DirectoryNotExists -path $PVMConfig.paths.profiles) { + if (Test-DirectoryNotExists -path $PVMConfig.paths.directories.profiles) { return $null } - $files = Get-ChildItemWrapper -path $PVMConfig.paths.profiles -filter '*.json' + $files = Get-ChildItemWrapper -path $PVMConfig.paths.directories.profiles -filter '*.json' return $files } catch { @@ -388,7 +388,7 @@ function Get-ProfileFiles { function Show-PHPProfiles { try { - if (Test-DirectoryNotExists -path $PVMConfig.paths.profiles) { + if (Test-DirectoryNotExists -path $PVMConfig.paths.directories.profiles) { Show-Error -message "`nNo profiles directory found. Create a profile with 'pvm profile save '." return -1 } @@ -433,7 +433,7 @@ function Show-PHPProfiles { Show-Message -message (' PHP '.PadRight($maxNameLength, '.') + " $($userProfile.PHPVersion)") Show-Message -message (' Settings '.PadRight($maxNameLength, '.') + " $($userProfile.Settings)") Show-Message -message (' Extensions '.PadRight($maxNameLength, '.') + " $($userProfile.Extensions)") - Show-Message -message (' Path '.PadRight($maxNameLength, '.') + " $($PVMConfig.paths.profiles)\$($userProfile.File)`n") + Show-Message -message (' Path '.PadRight($maxNameLength, '.') + " $($PVMConfig.paths.directories.profiles)\$($userProfile.File)`n") } return 0 @@ -448,7 +448,7 @@ function Show-PHPProfile { param ($profileName) try { - $profilePath = "$($PVMConfig.paths.profiles)\$profileName.json" + $profilePath = "$($PVMConfig.paths.directories.profiles)\$profileName.json" if (Test-FileNotExists -path $profilePath) { Show-Error -message "`nProfile '$profileName' not found." Show-Message -message " Use 'pvm profile list' to see available profiles." @@ -516,7 +516,7 @@ function Remove-PHPProfile { param ($profileName, $skipConfirmation = $false) try { - $profilePath = "$($PVMConfig.paths.profiles)\$profileName.json" + $profilePath = "$($PVMConfig.paths.directories.profiles)\$profileName.json" if (Test-FileNotExists -path $profilePath) { Show-Error -message "`nProfile '$profileName' not found." @@ -561,7 +561,7 @@ function Clear-PHPProfiles { } } - Remove-ItemWrapper -path "$($PVMConfig.paths.profiles)\*" + Remove-ItemWrapper -path "$($PVMConfig.paths.directories.profiles)\*" Show-Success -message "`nAll profiles deleted successfully." @@ -577,7 +577,7 @@ function Export-PHPProfile { param ($profileName, $exportPath = $null) try { - $profilePath = "$($PVMConfig.paths.profiles)\$profileName.json" + $profilePath = "$($PVMConfig.paths.directories.profiles)\$profileName.json" if (Test-FileNotExists -path $profilePath) { Show-Error -message "`nProfile '$profileName' not found." @@ -624,13 +624,13 @@ function Import-PHPProfile { # Use provided name or name from profile $finalName = if ($profileName) { $profileName } else { $userProfile.name } - $created = New-Directory -path $PVMConfig.paths.profiles + $created = New-Directory -path $PVMConfig.paths.directories.profiles if ($created -ne 0) { Show-Error -message "`nFailed to create profiles directory." return -1 } - $targetPath = "$($PVMConfig.paths.profiles)\$finalName.json" + $targetPath = "$($PVMConfig.paths.directories.profiles)\$finalName.json" # Update profile name if different if ($finalName -ne $userProfile.name) { @@ -697,7 +697,7 @@ function New-ExamplePHPProfile { } $jsonContent = $profileExample | ConvertTo-Json -Depth 10 - Set-ContentWrapper -path $PVMConfig.paths.profileExample -value $jsonContent + Set-ContentWrapper -path $PVMConfig.paths.files.profileExample -value $jsonContent return 0 } catch { @@ -714,7 +714,7 @@ function New-ProfileTemplate { } $jsonContent = $profileTemplate | ConvertTo-Json -Depth 10 - Set-ContentWrapper -path $PVMConfig.paths.profileTemplate -value $jsonContent + Set-ContentWrapper -path $PVMConfig.paths.files.profileTemplate -value $jsonContent return 0 } catch { diff --git a/src/actions/run.ps1 b/src/actions/run.ps1 index ffb64927..b4a99377 100644 --- a/src/actions/run.ps1 +++ b/src/actions/run.ps1 @@ -83,7 +83,7 @@ function Invoke-RunScripts { Show-SubProcessOutput -output $result.output New-Lines -count 3 } catch { - Write-Yellow -message "`nFailed to run command: pvm $scriptCommand, check logs at '$($PVMConfig.paths.logError)'`n" + Write-Yellow -message "`nFailed to run command: pvm $scriptCommand, check logs at '$($PVMConfig.paths.files.logError)'`n" $null = Add-LogEntry -data @{ header = "$($MyInvocation.MyCommand.Name) - Failed to run script"; exception = $_ } $results += @{ code = -1; output = $null } } diff --git a/src/actions/setup.ps1 b/src/actions/setup.ps1 index a3f0612c..ecb4f85e 100644 --- a/src/actions/setup.ps1 +++ b/src/actions/setup.ps1 @@ -39,14 +39,14 @@ function Initialize-PVM { function Initialize-PVMDirectories { $dirs = @( - $PVMConfig.paths.storage, - $PVMConfig.paths.fakeStorage, - $PVMConfig.paths.php, - $PVMConfig.paths.data, - $PVMConfig.paths.templates, - $PVMConfig.paths.cache, - $PVMConfig.paths.profiles, - $PVMConfig.paths.log + $PVMConfig.paths.directories.storage, + $PVMConfig.paths.directories.fakeStorage, + $PVMConfig.paths.directories.php, + $PVMConfig.paths.directories.data, + $PVMConfig.paths.directories.templates, + $PVMConfig.paths.directories.cache, + $PVMConfig.paths.directories.profiles, + $PVMConfig.paths.directories.log ) Show-Message -message "`nPVM environment directories:" @@ -71,7 +71,7 @@ function Initialize-PVMFiles { $codes += $code = New-ExamplePHPProfile if ($code -eq 0) { - Show-Success -message "`nExample profile created successfully at '$($PVMConfig.paths.profileExample)'." + Show-Success -message "`nExample profile created successfully at '$($PVMConfig.paths.files.profileExample)'." Show-Message -message "- Use 'pvm help profile' to learn more." } else { Show-Error -message "`nFailed to create example profile." @@ -79,7 +79,7 @@ function Initialize-PVMFiles { $codes += $code = New-ProfileTemplate if ($code -eq 0) { - Show-Success -message "`nProfile template created successfully at '$($PVMConfig.paths.profileTemplate)'." + Show-Success -message "`nProfile template created successfully at '$($PVMConfig.paths.files.profileTemplate)'." Show-Message -message '- Feel free to modify it.' } else { Show-Error -message "`nFailed to create profile template." @@ -87,14 +87,14 @@ function Initialize-PVMFiles { $codes += $code = Set-ZendExtensionsList if ($code -eq 0) { - Show-Success -message "`nZend extensions list created successfully at '$($PVMConfig.paths.zendExtensionsList)'." + Show-Success -message "`nZend extensions list created successfully at '$($PVMConfig.paths.files.zendExtensionsList)'." } else { Show-Error -message "`nFailed to create zend extensions list." } $codes += $code = Set-AliasesList if ($code -eq 0) { - Show-Success -message "`nAliases list created successfully at '$($PVMConfig.paths.aliasesList)'." + Show-Success -message "`nAliases list created successfully at '$($PVMConfig.paths.files.aliasesList)'." Show-Message -message "- Use 'pvm aliases' to see available aliases." Show-Message -message "- Feel free to modify it." } else { @@ -103,7 +103,7 @@ function Initialize-PVMFiles { $codes += $code = Set-ScriptsList if ($code -eq 0) { - Show-Success -message "`nScripts list created successfully at '$($PVMConfig.paths.scriptsList)'." + Show-Success -message "`nScripts list created successfully at '$($PVMConfig.paths.files.scriptsList)'." Show-Message -message "- Use 'pvm run list' to see available scripts." Show-Message -message "- Feel free to modify it." } else { diff --git a/src/actions/test.ps1 b/src/actions/test.ps1 index fe3d2be2..3163bd79 100644 --- a/src/actions/test.ps1 +++ b/src/actions/test.ps1 @@ -521,7 +521,7 @@ function Invoke-Tests { return 0 } catch { $null = Add-LogEntry -data @{ header = "$($MyInvocation.MyCommand.Name) - Failed to run tests"; exception = $_ } - Show-Error -message "`nFailed to run tests, check log: $($PVMConfig.paths.logError)" + Show-Error -message "`nFailed to run tests, check log: $($PVMConfig.paths.files.logError)" return -1 } } diff --git a/src/core/handlers.ps1 b/src/core/handlers.ps1 index 739795ff..9e395323 100644 --- a/src/core/handlers.ps1 +++ b/src/core/handlers.ps1 @@ -472,7 +472,7 @@ function Invoke-Info { $config = [ordered]@{ 'PVM Version' = $PVMConfig.version 'PVM Root' = $PVMRoot - 'Storage Path' = $PVMConfig.paths.storage + 'Storage Path' = $PVMConfig.paths.directories.storage 'Current PHP' = $currentPhpVersion 'Real PHP Path' = $currentPhpPath 'Active PHP Path' = $PVMConfig.env.PHP_CURRENT_VERSION_PATH @@ -481,7 +481,7 @@ function Invoke-Info { 'Profiles' = @(Get-ProfileFiles).Count 'Cached Files' = @(Get-CacheFiles).Count } - $allKeys = $config.Keys + $PVMConfig.paths.Keys + $PVMConfig.env.Keys + $allKeys = $config.Keys + $PVMConfig.paths.directories.Keys + $PVMConfig.paths.files.Keys + $PVMConfig.env.Keys $maxNameLength = ($allKeys | Measure-Object -Maximum Length).Maximum + ($PVMConfig.env.MIN_PAD_RIGHT_LENGTH * 2) Show-Info -message "`n`nPVM status:`n" @@ -492,10 +492,13 @@ function Invoke-Info { if ($arguments -contains '--verbose') { $PVM_PATHS = [ordered]@{} - foreach ($entry in $PVMConfig.paths.GetEnumerator()) { + $PVM_PATHS['Current PHP Path'] = $PVMConfig.env.PHP_CURRENT_VERSION_PATH + foreach ($entry in $PVMConfig.paths.directories.GetEnumerator()) { + $PVM_PATHS[$entry.Key] = $entry.Value + } + foreach ($entry in $PVMConfig.paths.files.GetEnumerator()) { $PVM_PATHS[$entry.Key] = $entry.Value } - $PVM_PATHS['Current PHP Path'] = $PVMConfig.env.PHP_CURRENT_VERSION_PATH Show-Info -message "`n`nPVM paths:`n" foreach ($entry in $PVM_PATHS.GetEnumerator()) { diff --git a/src/helpers/config.ps1 b/src/helpers/config.ps1 index 34a770f6..de3417f0 100644 --- a/src/helpers/config.ps1 +++ b/src/helpers/config.ps1 @@ -2,7 +2,7 @@ function Set-AliasesList { try { $jsonContent = $PVMConfig.defaults.aliases | ConvertTo-Json -Depth 10 - Set-ContentWrapper -path $PVMConfig.paths.aliasesList -value $jsonContent + Set-ContentWrapper -path $PVMConfig.paths.files.aliasesList -value $jsonContent return 0 } catch { @@ -13,8 +13,8 @@ function Set-AliasesList { function Get-Aliases { try { - if (Test-FileExists -path $PVMConfig.paths.aliasesList) { - $data = (Get-ContentWrapper -path $PVMConfig.paths.aliasesList -raw | ConvertFrom-Json) + if (Test-FileExists -path $PVMConfig.paths.files.aliasesList) { + $data = (Get-ContentWrapper -path $PVMConfig.paths.files.aliasesList -raw | ConvertFrom-Json) if ($null -ne $data) { $ordered = [ordered]@{} $data.PSObject.Properties | ForEach-Object -Process { $ordered[$_.Name] = $_.Value } @@ -35,7 +35,7 @@ function Get-FlagMap { function Set-ScriptsList { try { $jsonContent = $PVMConfig.defaults.scripts | ConvertTo-Json -Depth 10 - Set-ContentWrapper -path $PVMConfig.paths.scriptsList -value $jsonContent + Set-ContentWrapper -path $PVMConfig.paths.files.scriptsList -value $jsonContent return 0 } catch { @@ -46,8 +46,8 @@ function Set-ScriptsList { function Get-Scripts { try { - if (Test-FileExists -path $PVMConfig.paths.scriptsList) { - $data = (Get-ContentWrapper -path $PVMConfig.paths.scriptsList -raw | ConvertFrom-Json) + if (Test-FileExists -path $PVMConfig.paths.files.scriptsList) { + $data = (Get-ContentWrapper -path $PVMConfig.paths.files.scriptsList -raw | ConvertFrom-Json) if ($null -ne $data) { $ordered = [ordered]@{} $data.PSObject.Properties | ForEach-Object -Process { $ordered[$_.Name] = $_.Value } @@ -148,23 +148,27 @@ function Get-Config { version = '2.6' # PVM version paths = [ordered]@{ - pvmRoot = $rootPath - storage = $storage - fakeStorage = $fakeStorage - php = "$storage\php" - data = $data - templates = $templates - cache = "$data\cache" - profiles = $profiles - profileExample = "$profiles\profile-example.json" - profileTemplate = "$templates\profile-template.json" - zendExtensionsList = "$templates\zend_extensions.json" - aliasesList = "$templates\aliases.json" - scriptsList = "$templates\scripts.json" - log = $logs - logError = "$logs\error.log" - pathVarBackup = "$logs\path.bak.log" - assets = "$rootPath\assets" + directories = @{ + pvmRoot = $rootPath + storage = $storage + fakeStorage = $fakeStorage + php = "$storage\php" + data = $data + templates = $templates + cache = "$data\cache" + profiles = $profiles + log = $logs + assets = "$rootPath\assets" + } + files = @{ + profileExample = "$profiles\profile-example.json" + profileTemplate = "$templates\profile-template.json" + zendExtensionsList = "$templates\zend_extensions.json" + aliasesList = "$templates\aliases.json" + scriptsList = "$templates\scripts.json" + logError = "$logs\error.log" + pathVarBackup = "$logs\path.bak.log" + } } links = [ordered]@{ @@ -268,23 +272,24 @@ function Get-Config { $fakeTemplates = "$fakeData\templates" $fakeLogs = "$fakeStorage\logs" - $PVMConfig.paths.pvmRoot = $root - $PVMConfig.paths.storage = $fakeStorage - $PVMConfig.paths.fakeStorage = $fakeStorage - $PVMConfig.paths.php = "$fakeStorage\php" - $PVMConfig.paths.data = $fakeData - $PVMConfig.paths.templates = $fakeTemplates - $PVMConfig.paths.cache = "$fakeData\cache" - $PVMConfig.paths.profiles = $fakeProfiles - $PVMConfig.paths.profileExample = "$fakeProfiles\profile-example.json" - $PVMConfig.paths.profileTemplate = "$fakeTemplates\profile-template.json" - $PVMConfig.paths.zendExtensionsList = "$fakeTemplates\zend_extensions.json" - $PVMConfig.paths.aliasesList = "$fakeTemplates\aliases.json" - $PVMConfig.paths.scriptsList = "$fakeTemplates\scripts.json" - $PVMConfig.paths.log = $fakeLogs - $PVMConfig.paths.logError = "$fakeLogs\error.log" - $PVMConfig.paths.pathVarBackup = "$fakeLogs\path.bak.log" - $PVMConfig.paths.assets = "$root\assets" + $PVMConfig.paths.directories.pvmRoot = $root + $PVMConfig.paths.directories.storage = $fakeStorage + $PVMConfig.paths.directories.fakeStorage = $fakeStorage + $PVMConfig.paths.directories.php = "$fakeStorage\php" + $PVMConfig.paths.directories.data = $fakeData + $PVMConfig.paths.directories.templates = $fakeTemplates + $PVMConfig.paths.directories.cache = "$fakeData\cache" + $PVMConfig.paths.directories.profiles = $fakeProfiles + $PVMConfig.paths.directories.log = $fakeLogs + $PVMConfig.paths.directories.assets = "$root\assets" + + $PVMConfig.paths.files.profileExample = "$fakeProfiles\profile-example.json" + $PVMConfig.paths.files.profileTemplate = "$fakeTemplates\profile-template.json" + $PVMConfig.paths.files.zendExtensionsList = "$fakeTemplates\zend_extensions.json" + $PVMConfig.paths.files.aliasesList = "$fakeTemplates\aliases.json" + $PVMConfig.paths.files.scriptsList = "$fakeTemplates\scripts.json" + $PVMConfig.paths.files.logError = "$fakeLogs\error.log" + $PVMConfig.paths.files.pathVarBackup = "$fakeLogs\path.bak.log" $PVMConfig.env.PHP_CURRENT_VERSION_PATH = "$root\pvm\php" } diff --git a/src/helpers/output.ps1 b/src/helpers/output.ps1 index 058f23c5..112f04c5 100644 --- a/src/helpers/output.ps1 +++ b/src/helpers/output.ps1 @@ -29,7 +29,7 @@ function Add-LogEntry { param ($data) try { - $logPath = if ($data.logPath) { $data.logPath } else { $PVMConfig.paths.logError } + $logPath = if ($data.logPath) { $data.logPath } else { $PVMConfig.paths.files.logError } $created = New-Directory -path (Split-Path -Path $logPath) if ($created -ne 0) { Show-Message -message "Failed to create directory $(Split-Path -Path $logPath)" @@ -354,7 +354,7 @@ function Invoke-Sound { } $MediaPlayer = New-Player - $path = "$($PVMConfig.paths.assets)\sounds\$filename" + $path = "$($PVMConfig.paths.directories.assets)\sounds\$filename" $MediaPlayer.Open($path) $duration = Get-Sound-TotalSeconds -path $path $MediaPlayer.Play() diff --git a/src/helpers/php.ps1 b/src/helpers/php.ps1 index 6b1f9f02..07bb7ad4 100644 --- a/src/helpers/php.ps1 +++ b/src/helpers/php.ps1 @@ -64,7 +64,7 @@ function Test-TwoPHPVersionsEqual { function Set-ZendExtensionsList { try { $jsonContent = $PVMConfig.defaults.zendExtensions | ConvertTo-Json -Depth 10 - Set-ContentWrapper -path $PVMConfig.paths.zendExtensionsList -value $jsonContent + Set-ContentWrapper -path $PVMConfig.paths.files.zendExtensionsList -value $jsonContent return 0 } catch { @@ -75,8 +75,8 @@ function Set-ZendExtensionsList { function Get-ZendExtensionsList { try { - if (Test-FileExists -path $PVMConfig.paths.zendExtensionsList) { - $data = (Get-ContentWrapper -path $PVMConfig.paths.zendExtensionsList -raw | ConvertFrom-Json) + if (Test-FileExists -path $PVMConfig.paths.files.zendExtensionsList) { + $data = (Get-ContentWrapper -path $PVMConfig.paths.files.zendExtensionsList -raw | ConvertFrom-Json) if ($null -ne $data -and $data.Count -gt 0) { return $data } @@ -102,7 +102,7 @@ function Update-InstalledPHPVersionsCache { function Get-InstalledPHPVersionsFromDisk { return Show-SpinnerWhileJob -scriptBlock { - $directories = Get-AllSubdirectories -path $PVMConfig.paths.php + $directories = Get-AllSubdirectories -path $PVMConfig.paths.directories.php $installedVersions = $directories | ForEach-Object -Process { if (Test-FileExists -path "$($_.FullName)\php.exe") { $phpInfo = Get-PHPInstallInfo -path $_.FullName diff --git a/src/helpers/store.ps1 b/src/helpers/store.ps1 index cec4fcad..321b28d4 100644 --- a/src/helpers/store.ps1 +++ b/src/helpers/store.ps1 @@ -90,7 +90,7 @@ function Get-CacheFilePath { $filename = "$filename.json" } - return "$($PVMConfig.paths.cache)\$filename" + return "$($PVMConfig.paths.directories.cache)\$filename" } function Test-HasData { diff --git a/src/helpers/system.ps1 b/src/helpers/system.ps1 index 9a2aa8d4..59074928 100644 --- a/src/helpers/system.ps1 +++ b/src/helpers/system.ps1 @@ -131,11 +131,11 @@ function Optimize-SystemPath { # Saving Path to log $outputLog = Add-LogEntry -data @{ - logPath = $PVMConfig.paths.pathVarBackup + logPath = $PVMConfig.paths.files.pathVarBackup header = "Original PATH`n$oldPath" } if ($outputLog -eq 0) { - Show-Message -message "`nOriginal Path saved to '$($PVMConfig.paths.pathVarBackup)'" + Show-Message -message "`nOriginal Path saved to '$($PVMConfig.paths.files.pathVarBackup)'" } $output = 0 diff --git a/src/helpers/update-check.ps1 b/src/helpers/update-check.ps1 index 95f5bdf3..a2cc4656 100644 --- a/src/helpers/update-check.ps1 +++ b/src/helpers/update-check.ps1 @@ -1,7 +1,7 @@  function Get-LastUpdateCheckTimestamp { try { - $timestampFile = "$($PVMConfig.paths.cache)\last_update_check.txt" + $timestampFile = "$($PVMConfig.paths.directories.cache)\last_update_check.txt" if (Test-FileExists -path $timestampFile) { return [DateTime](Get-ContentWrapper -path $timestampFile) } @@ -12,8 +12,8 @@ function Get-LastUpdateCheckTimestamp { function Set-LastUpdateCheckTimestamp { try { - $timestampFile = "$($PVMConfig.paths.cache)\last_update_check.txt" - $null = New-Directory -path $PVMConfig.paths.cache + $timestampFile = "$($PVMConfig.paths.directories.cache)\last_update_check.txt" + $null = New-Directory -path $PVMConfig.paths.directories.cache Set-ContentWrapper -path $timestampFile -value (Get-Date) return 0 } catch { diff --git a/tests/actions/cache.tests.ps1 b/tests/actions/cache.tests.ps1 index 96786354..c5fb905b 100644 --- a/tests/actions/cache.tests.ps1 +++ b/tests/actions/cache.tests.ps1 @@ -1,12 +1,12 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\cache-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\cache-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) - $script:CACHE_PATH = $PVMConfig.paths.cache + $script:CACHE_PATH = $PVMConfig.paths.directories.cache New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null - New-Item -ItemType Directory -Path $PVMConfig.paths.cache -Force | Out-Null + New-Item -ItemType Directory -Path $PVMConfig.paths.directories.cache -Force | Out-Null Mock Show-Error {} Mock Show-Info {} diff --git a/tests/actions/current.tests.ps1 b/tests/actions/current.tests.ps1 index 430bdf16..42fc4641 100644 --- a/tests/actions/current.tests.ps1 +++ b/tests/actions/current.tests.ps1 @@ -1,11 +1,11 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\current-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\current-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:PHP_CURRENT_DIR = $PVMConfig.env.PHP_CURRENT_VERSION_PATH - $script:PHP_DIR = $PVMConfig.paths.php + $script:PHP_DIR = $PVMConfig.paths.directories.php New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null New-Item -ItemType Directory -Path $PHP_CURRENT_DIR -Force | Out-Null diff --git a/tests/actions/ini.tests.ps1 b/tests/actions/ini.tests.ps1 index bc33dcec..3f4a52be 100644 --- a/tests/actions/ini.tests.ps1 +++ b/tests/actions/ini.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\ini-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\ini-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" @@ -12,10 +12,10 @@ BeforeAll { $script:PECL_WIN_EXT_DOWNLOAD_URL = $PVMConfig.links.peclWinExtDownload New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null - New-Item -ItemType Directory -Path $PVMConfig.paths.cache -Force | Out-Null + New-Item -ItemType Directory -Path $PVMConfig.paths.directories.cache -Force | Out-Null # Create directory and symlink for current PHP version - $phpVersionPath = "$($PVMConfig.paths.php)\php-8.2" + $phpVersionPath = "$($PVMConfig.paths.directories.php)\php-8.2" New-Item -ItemType Directory -Path $phpVersionPath -Force New-Item -ItemType SymbolicLink -Path $PVMConfig.env.PHP_CURRENT_VERSION_PATH -Target $phpVersionPath -Force diff --git a/tests/actions/ini/add.tests.ps1 b/tests/actions/ini/add.tests.ps1 index a0934b45..6486adb0 100644 --- a/tests/actions/ini/add.tests.ps1 +++ b/tests/actions/ini/add.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\add-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\add-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" @@ -9,7 +9,7 @@ BeforeAll { $script:testBackupPath = "$testIniPath.bak" New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null - New-Item -ItemType Directory -Path $PVMConfig.paths.cache -Force | Out-Null + New-Item -ItemType Directory -Path $PVMConfig.paths.directories.cache -Force | Out-Null $script:PECL_PACKAGES_URL = $PVMConfig.links.peclPackages $script:XDEBUG_DOWNLOAD_URL = $PVMConfig.links.xdebugDownload diff --git a/tests/actions/ini/disable.tests.ps1 b/tests/actions/ini/disable.tests.ps1 index 47913d15..eb86fb32 100644 --- a/tests/actions/ini/disable.tests.ps1 +++ b/tests/actions/ini/disable.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\disable-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\disable-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" @@ -9,7 +9,7 @@ BeforeAll { $script:testBackupPath = "$testIniPath.bak" New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null - New-Item -ItemType Directory -Path $PVMConfig.paths.cache -Force | Out-Null + New-Item -ItemType Directory -Path $PVMConfig.paths.directories.cache -Force | Out-Null Mock Show-Warning {} Mock Show-Info {} diff --git a/tests/actions/ini/enable.tests.ps1 b/tests/actions/ini/enable.tests.ps1 index 1372948f..c51a452d 100644 --- a/tests/actions/ini/enable.tests.ps1 +++ b/tests/actions/ini/enable.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\enable-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\enable-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" @@ -9,7 +9,7 @@ BeforeAll { $script:testBackupPath = "$testIniPath.bak" New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null - New-Item -ItemType Directory -Path $PVMConfig.paths.cache -Force | Out-Null + New-Item -ItemType Directory -Path $PVMConfig.paths.directories.cache -Force | Out-Null Mock Show-Warning {} Mock Show-Info {} diff --git a/tests/actions/ini/ext.tests.ps1 b/tests/actions/ini/ext.tests.ps1 index 66da2526..2418b381 100644 --- a/tests/actions/ini/ext.tests.ps1 +++ b/tests/actions/ini/ext.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\ext-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\ext-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" diff --git a/tests/actions/ini/get.tests.ps1 b/tests/actions/ini/get.tests.ps1 index 1d68b1b5..a8fd3c07 100644 --- a/tests/actions/ini/get.tests.ps1 +++ b/tests/actions/ini/get.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\get-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\get-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" @@ -9,7 +9,7 @@ BeforeAll { $script:testBackupPath = "$testIniPath.bak" New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null - New-Item -ItemType Directory -Path $PVMConfig.paths.cache -Force | Out-Null + New-Item -ItemType Directory -Path $PVMConfig.paths.directories.cache -Force | Out-Null Mock Show-Warning {} Mock Show-Info {} diff --git a/tests/actions/ini/helpers/fetch.tests.ps1 b/tests/actions/ini/helpers/fetch.tests.ps1 index b8256a4c..e697af6c 100644 --- a/tests/actions/ini/helpers/fetch.tests.ps1 +++ b/tests/actions/ini/helpers/fetch.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\fetch-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\fetch-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:PECL_PACKAGES_URL = $PVMConfig.links.peclPackages @@ -626,7 +626,7 @@ Describe "Select-ExtensionFromMatches Tests" { Describe "Get-ExtensionLinksFromURL Tests" { BeforeEach { - $PVMConfig.paths.cache = "$TEST_DRIVE\cache" + $PVMConfig.paths.directories.cache = "$TEST_DRIVE\cache" } It "Returns filtered links" { diff --git a/tests/actions/ini/helpers/shared.tests.ps1 b/tests/actions/ini/helpers/shared.tests.ps1 index c3ee1695..3e09e247 100644 --- a/tests/actions/ini/helpers/shared.tests.ps1 +++ b/tests/actions/ini/helpers/shared.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\shared-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\shared-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" diff --git a/tests/actions/ini/info.tests.ps1 b/tests/actions/ini/info.tests.ps1 index 1099ab14..d8d4e71f 100644 --- a/tests/actions/ini/info.tests.ps1 +++ b/tests/actions/ini/info.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\info-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\info-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" @@ -9,7 +9,7 @@ BeforeAll { $script:testBackupPath = "$testIniPath.bak" New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null - New-Item -ItemType Directory -Path $PVMConfig.paths.cache -Force | Out-Null + New-Item -ItemType Directory -Path $PVMConfig.paths.directories.cache -Force | Out-Null Mock Show-Error {} Mock Show-Message {} diff --git a/tests/actions/ini/remove.tests.ps1 b/tests/actions/ini/remove.tests.ps1 index 29010579..ca688b9a 100644 --- a/tests/actions/ini/remove.tests.ps1 +++ b/tests/actions/ini/remove.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\remove-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\remove-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" diff --git a/tests/actions/ini/restore.tests.ps1 b/tests/actions/ini/restore.tests.ps1 index 8d70e150..113168be 100644 --- a/tests/actions/ini/restore.tests.ps1 +++ b/tests/actions/ini/restore.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\restore-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\restore-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" diff --git a/tests/actions/ini/set.tests.ps1 b/tests/actions/ini/set.tests.ps1 index 8ca4dcbb..1edb51ae 100644 --- a/tests/actions/ini/set.tests.ps1 +++ b/tests/actions/ini/set.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\set-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\set-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" @@ -9,7 +9,7 @@ BeforeAll { $script:testBackupPath = "$testIniPath.bak" New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null - New-Item -ItemType Directory -Path $PVMConfig.paths.cache -Force | Out-Null + New-Item -ItemType Directory -Path $PVMConfig.paths.directories.cache -Force | Out-Null Mock Show-Warning {} Mock Show-Message {} diff --git a/tests/actions/ini/status.tests.ps1 b/tests/actions/ini/status.tests.ps1 index dd99290d..f7d20c9a 100644 --- a/tests/actions/ini/status.tests.ps1 +++ b/tests/actions/ini/status.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\status-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\status-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $script:testIniPath = "$TEST_DRIVE\php.ini" @@ -9,7 +9,7 @@ BeforeAll { $script:testBackupPath = "$testIniPath.bak" New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null - New-Item -ItemType Directory -Path $PVMConfig.paths.cache -Force | Out-Null + New-Item -ItemType Directory -Path $PVMConfig.paths.directories.cache -Force | Out-Null Mock Show-Warning {} Mock Write-Color {} diff --git a/tests/actions/install.tests.ps1 b/tests/actions/install.tests.ps1 index a52afb77..e750190b 100644 --- a/tests/actions/install.tests.ps1 +++ b/tests/actions/install.tests.ps1 @@ -1,10 +1,10 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\install-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\install-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) - $script:PHP_DIR = $PVMConfig.paths.php + $script:PHP_DIR = $PVMConfig.paths.directories.php New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null diff --git a/tests/actions/list.tests.ps1 b/tests/actions/list.tests.ps1 index aa6b7afe..46f6ee8c 100644 --- a/tests/actions/list.tests.ps1 +++ b/tests/actions/list.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\list-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\list-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null diff --git a/tests/actions/log.tests.ps1 b/tests/actions/log.tests.ps1 index 8e68c762..c64ee152 100644 --- a/tests/actions/log.tests.ps1 +++ b/tests/actions/log.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\log-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\log-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null @@ -139,7 +139,7 @@ Describe "Test-LogPageSize" { Describe "Get-LogEntries" { BeforeAll { - $script:LOG_ERROR_PATH = $PVMConfig.paths.logError + $script:LOG_ERROR_PATH = $PVMConfig.paths.files.logError New-Item -ItemType Directory -Path (Split-Path -Path $LOG_ERROR_PATH) -Force | Out-Null } @@ -321,7 +321,7 @@ Describe "Get-LogNavigation" { Describe "Show-Log" { BeforeAll { - $script:LOG_ERROR_PATH = $PVMConfig.paths.logError + $script:LOG_ERROR_PATH = $PVMConfig.paths.files.logError New-Item -ItemType Directory -Path (Split-Path -Path $LOG_ERROR_PATH) -Force | Out-Null } diff --git a/tests/actions/profile.tests.ps1 b/tests/actions/profile.tests.ps1 index aa3c74f4..1c615a33 100644 --- a/tests/actions/profile.tests.ps1 +++ b/tests/actions/profile.tests.ps1 @@ -1,13 +1,13 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\profile-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\profile-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) - $script:PROFILES_PATH = $PVMConfig.paths.profiles - $script:TEMPLATES_PATH = $PVMConfig.paths.templates - $script:PROFILE_TEMPLATE_PATH = $PVMConfig.paths.profileTemplate - $script:EXAMPLE_PROFILE_PATH = $PVMConfig.paths.profileExample + $script:PROFILES_PATH = $PVMConfig.paths.directories.profiles + $script:TEMPLATES_PATH = $PVMConfig.paths.directories.templates + $script:PROFILE_TEMPLATE_PATH = $PVMConfig.paths.files.profileTemplate + $script:EXAMPLE_PROFILE_PATH = $PVMConfig.paths.files.profileExample New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null New-Item -ItemType Directory -Path $PROFILES_PATH -Force | Out-Null diff --git a/tests/actions/run.tests.ps1 b/tests/actions/run.tests.ps1 index fd201026..3ad8f0aa 100644 --- a/tests/actions/run.tests.ps1 +++ b/tests/actions/run.tests.ps1 @@ -2,7 +2,7 @@ BeforeAll { $script:PVMRootBackup = $PVMRoot $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\run-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\run-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null diff --git a/tests/actions/setup.tests.ps1 b/tests/actions/setup.tests.ps1 index 1917a0dd..22e41378 100644 --- a/tests/actions/setup.tests.ps1 +++ b/tests/actions/setup.tests.ps1 @@ -2,7 +2,7 @@ BeforeAll { $script:PVMRootBackup = $PVMRoot $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\setup-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\setup-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null diff --git a/tests/actions/uninstall.tests.ps1 b/tests/actions/uninstall.tests.ps1 index 3ead20c3..156a1604 100644 --- a/tests/actions/uninstall.tests.ps1 +++ b/tests/actions/uninstall.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\uninstall-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\uninstall-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null diff --git a/tests/actions/use.tests.ps1 b/tests/actions/use.tests.ps1 index bc24d858..f2322efb 100644 --- a/tests/actions/use.tests.ps1 +++ b/tests/actions/use.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\use-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\use-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null diff --git a/tests/core/bootstrap.tests.ps1 b/tests/core/bootstrap.tests.ps1 index e3645f94..b5057579 100644 --- a/tests/core/bootstrap.tests.ps1 +++ b/tests/core/bootstrap.tests.ps1 @@ -1,7 +1,7 @@  BeforeAll { $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\bootstrap-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\bootstrap-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) $PVMConfig.version = '1.0.0' diff --git a/tests/core/handlers.tests.ps1 b/tests/core/handlers.tests.ps1 index 80022550..9d2aeb39 100644 --- a/tests/core/handlers.tests.ps1 +++ b/tests/core/handlers.tests.ps1 @@ -2,7 +2,7 @@ BeforeAll { $script:PVMRootBackup = $PVMRoot $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\handlers-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\handlers-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) Import-Module -Name PowerShellGet -ErrorAction SilentlyContinue diff --git a/tests/helpers/config.tests.ps1 b/tests/helpers/config.tests.ps1 index 34051ffb..05a64b03 100644 --- a/tests/helpers/config.tests.ps1 +++ b/tests/helpers/config.tests.ps1 @@ -2,12 +2,12 @@ BeforeAll { $script:PVMRootBackup = $PVMRoot $script:PVMConfigBackup = Copy-ObjectDeep -object $PVMConfig - $script:TEST_DRIVE = "$($PVMConfig.paths.fakeStorage)\config-drive" + $script:TEST_DRIVE = "$($PVMConfig.paths.directories.fakeStorage)\config-drive" $PVMConfig.test.setFakePaths.Invoke($TEST_DRIVE) - $script:TEMPLATES_PATH = $PVMConfig.paths.templates - $script:ALIASES_LIST_PATH = $PVMConfig.paths.aliasesList - $script:SCRIPTS_LIST_PATH = $PVMConfig.paths.scriptsList + $script:TEMPLATES_PATH = $PVMConfig.paths.directories.templates + $script:ALIASES_LIST_PATH = $PVMConfig.paths.files.aliasesList + $script:SCRIPTS_LIST_PATH = $PVMConfig.paths.files.scriptsList New-Item -ItemType Directory -Path $TEST_DRIVE -Force | Out-Null } @@ -406,14 +406,14 @@ MIN_LINE_LENGTH=50 It "Sets paths correctly" { $result = Get-Config -rootPath $testRoot - $result.paths.storage | Should -Be "$testRoot\storage" - $result.paths.php | Should -Be "$testRoot\storage\php" - $result.paths.data | Should -Be "$testRoot\storage\data" - $result.paths.templates | Should -Be "$testRoot\storage\data\templates" - $result.paths.cache | Should -Be "$testRoot\storage\data\cache" - $result.paths.profiles | Should -Be "$testRoot\storage\data\profiles" - $result.paths.log | Should -Be "$testRoot\storage\logs" - $result.paths.logError | Should -Be "$testRoot\storage\logs\error.log" + $result.paths.directories.storage | Should -Be "$testRoot\storage" + $result.paths.directories.php | Should -Be "$testRoot\storage\php" + $result.paths.directories.data | Should -Be "$testRoot\storage\data" + $result.paths.directories.templates | Should -Be "$testRoot\storage\data\templates" + $result.paths.directories.cache | Should -Be "$testRoot\storage\data\cache" + $result.paths.directories.profiles | Should -Be "$testRoot\storage\data\profiles" + $result.paths.directories.log | Should -Be "$testRoot\storage\logs" + $result.paths.files.logError | Should -Be "$testRoot\storage\logs\error.log" } It "Uses TEST_DRIVE from .env for fake storage when provided" { @@ -432,7 +432,7 @@ TEST_DRIVE=C:\fake-storage $result = Get-Config -rootPath $customRoot - $result.paths.fakeStorage | Should -Be 'C:\fake-storage' + $result.paths.directories.fakeStorage | Should -Be 'C:\fake-storage' } It "Falls back to storage/tests when TEST_DRIVE is not set" { @@ -450,7 +450,7 @@ MIN_LINE_LENGTH=50 $result = Get-Config -rootPath $fallbackRoot - $result.paths.fakeStorage | Should -Be "$fallbackRoot\storage\tests" + $result.paths.directories.fakeStorage | Should -Be "$fallbackRoot\storage\tests" } It "Falls back to storage/tests when TEST_DRIVE is not a valid path" { @@ -469,7 +469,7 @@ TEST_DRIVE=bad Date: Fri, 28 Aug 2026 16:05:17 +0100 Subject: [PATCH 2/2] Merge branch 'master' into Refactor-config-global-var --- tests/helpers/output.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/helpers/output.tests.ps1 b/tests/helpers/output.tests.ps1 index 365bc17c..f5aa67e6 100644 --- a/tests/helpers/output.tests.ps1 +++ b/tests/helpers/output.tests.ps1 @@ -844,7 +844,7 @@ Describe "Write-Host helpers Tests" { Describe "Sound Functions" { BeforeAll { - $Global:PVMConfig.paths.assets = "C:\pvm\assets" + $Global:PVMConfig.paths.directories.assets = "C:\pvm\assets" } BeforeEach {