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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/actions/cache.ps1
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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."

Expand Down
14 changes: 7 additions & 7 deletions src/actions/ini/add.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,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
}

Expand All @@ -170,21 +170,21 @@ function Install-XDebugExtension {
return -1
}

$null = Invoke-WebRequestWrapper -uri $chosenItem.href -outFile $PVMConfig.paths.php
$null = Invoke-WebRequestWrapper -uri $chosenItem.href -outFile $PVMConfig.paths.directories.php
$phpPath = Split-Path -Path $iniPath -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.extVersion -like '3.*') {
$xDebugConfig = Get-XdebugConfigV3 -XDebugPath $($chosenItem.fileName)
Expand Down Expand Up @@ -303,9 +303,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.fileName -replace '.zip$', ''
$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 {
Expand All @@ -322,7 +322,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
}
Expand Down
2 changes: 1 addition & 1 deletion src/actions/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions src/actions/log.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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
}
Expand Down
40 changes: 20 additions & 20 deletions src/actions/profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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

Expand All @@ -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 {
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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 {
Expand All @@ -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 <name>'."
return -1
}
Expand Down Expand Up @@ -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
Expand All @@ -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."
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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."

Expand All @@ -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."
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,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 }
}
Expand Down
26 changes: 13 additions & 13 deletions src/actions/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand All @@ -71,30 +71,30 @@ 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."
}

$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."
}

$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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Loading