@@ -62,14 +62,20 @@ function Write-Warning { param([string]$Message) Write-Host "⚠ $Message" -Fore
6262function Write-Error { param ([string ]$Message ) Write-Host " ✗ $Message " - ForegroundColor Red }
6363function Write-Skip { param ([string ]$Message ) Write-Host " ⏭ $Message " - ForegroundColor Cyan }
6464
65- function Ensure-Directory {
66- param ([string ]$FilePath )
65+ function New-DirectoryIfNotExists {
66+ [CmdletBinding ()]
67+ param (
68+ [Parameter (Mandatory = $true , Position = 0 )]
69+ [ValidateNotNullOrEmpty ()]
70+ [string ]$FilePath
71+ )
6772 $directory = Split-Path - Path $FilePath - Parent
68- if ($directory -and -not (Test-Path $directory )) {
73+ if ($directory -and -not (Test-Path - Path $directory )) {
6974 New-Item - ItemType Directory - Path $directory - Force | Out-Null
7075 }
7176}
72- function Ensure-ParentDirectory { param ([string ]$Path ) Ensure- Directory - FilePath $Path }
77+
78+ function New-ParentDirectory { param ([string ]$Path ) New-DirectoryIfNotExists - FilePath $Path }
7379
7480function New-TempDir {
7581 $dir = Join-Path $env: TEMP (" tmpdir_" + (Get-Random ))
@@ -123,11 +129,8 @@ function Remove-FilesByPatterns {
123129 return $count
124130}
125131
126- function Extract-MoveFromSubfolder {
127- <#
128- Extract zip to temp, find first subdir by filter, move children to DestDir.
129- If not found, move all root temp items.
130- #>
132+ function Move-FromZipSubfolder {
133+ [CmdletBinding ()]
131134 param (
132135 [string ]$ZipPath ,
133136 [string ]$DestDir ,
@@ -212,7 +215,7 @@ function Invoke-Curl {
212215
213216 [switch ] $Silent ,
214217 [switch ] $Follow ,
215- [switch ] $Fail = $true ,
218+ [Bool ] $Fail = $true ,
216219
217220 # Опционально: SOCKS5-прокси
218221 [switch ] $UseProxy ,
@@ -247,25 +250,25 @@ function Invoke-Curl {
247250 }
248251
249252 # Сбор аргументов
250- $args = @ ()
253+ $myargs = @ ()
251254
252255 if ($UseProxy ) {
253256 if ([string ]::IsNullOrWhiteSpace($ProxyUrl )) {
254257 throw " Invoke-Curl: ProxyUrl must be specified when -UseProxy is set."
255258 }
256- $args += @ (' --socks5' , $ProxyUrl )
257- # Для HTTP-прокси можно использовать: $args += @('-x', $ProxyUrl)
259+ $myargs += @ (' --socks5' , $ProxyUrl )
260+ # Для HTTP-прокси можно использовать: $myargs += @('-x', $ProxyUrl)
258261 }
259262
260- if ($Fail ) { $args += ' -f' } # или '--fail-with-body' если ваша сборка curl поддерживает
261- if ($Follow ) { $args += ' -L' }
263+ if ($Fail ) { $myargs += ' -f' } # или '--fail-with-body' если ваша сборка curl поддерживает
264+ if ($Follow ) { $myargs += ' -L' }
262265
263- if ($Silent ) { $args += @ (' -s' , ' -S' ) } else { $args += ' -S' }
266+ if ($Silent ) { $myargs += @ (' -s' , ' -S' ) } else { $myargs += ' -S' }
264267
265- $args += @ (' -o' , $OutFile , $Url )
268+ $myargs += @ (' -o' , $OutFile , $Url )
266269
267270 # Запуск строго указанного curl.exe
268- & $curlPath @args
271+ & $curlPath $myargs
269272 $code = $LASTEXITCODE
270273 return $code
271274}
@@ -857,7 +860,7 @@ function Install-PhpMyAdmin {
857860 if (Test-Path $destPath - PathType Leaf) {
858861 $skipped ++
859862 } else {
860- Ensure - Directory - FilePath $destPath
863+ New-DirectoryIfNotExists - FilePath $destPath
861864 try {
862865 Copy-Item - Path $_.FullName - Destination $destPath - Force:$false
863866 $copied ++
@@ -939,7 +942,7 @@ function Copy-ComposerFiles {
939942
940943 $composerSubfolderFiles = @ (" composer.phar" , " config.json" , " composer.json" , " auth.json" , " keys.tags.pub" , " keys.dev.pub" )
941944 $phpRootFiles = @ (" composer.bat" )
942- $phpVersions = @ (" 7.2" , " 7.3" , " 7.4" , " 8.0" , " 8.1" , " 8.2" , " 8.3" , " 8.4" )
945+ $phpVersions = @ (" 7.2" , " 7.3" , " 7.4" , " 8.0" , " 8.1" , " 8.2" , " 8.3" , " 8.4" , " 8.5 " )
943946
944947 foreach ($version in $phpVersions ) {
945948 $phpModuleDir = " ..\modules\PHP-$version "
@@ -981,7 +984,7 @@ function Copy-AdditionalFiles {
981984 foreach ($url in $downloads.Keys ) {
982985 foreach ($destPath in $downloads [$url ]) {
983986 Write-Stage " ADDITIONAL" " Downloading $ ( Split-Path $destPath - Leaf) " $url
984- Ensure - ParentDirectory $destPath
987+ New -ParentDirectory $destPath
985988 if (Test-Path $destPath ) { Remove-Item $destPath - Force }
986989 try {
987990 if (Get-CachedFile - Url $url - OutFile $destPath ) { Write-Success " Downloaded: $destPath " }
@@ -997,7 +1000,7 @@ function Copy-AdditionalFiles {
9971000 foreach ($item in $binDownloads ) {
9981001 $destPath = $item.Dest
9991002 Write-Stage " ADDITIONAL" " Downloading $ ( Split-Path $destPath - Leaf) " $item.Url
1000- Ensure - ParentDirectory $destPath
1003+ New -ParentDirectory $destPath
10011004 if (Test-Path $destPath ) { Remove-Item $destPath - Force }
10021005 try {
10031006 if (Get-CachedFile - Url $item.Url - OutFile $destPath ) { Write-Success " Downloaded: $destPath " }
@@ -1017,7 +1020,7 @@ function Copy-AdditionalFiles {
10171020 $destPath = $localCopies [$sourcePath ]
10181021 if (Test-Path $sourcePath ) {
10191022 Write-Stage " ADDITIONAL" " Copying local file $ ( Split-Path $sourcePath - Leaf) "
1020- Ensure - ParentDirectory $destPath
1023+ New -ParentDirectory $destPath
10211024 try { Copy-Item $sourcePath $destPath - Force; Write-Success " Copied: $sourcePath → $destPath " }
10221025 catch { Write-Warning " Error copying $sourcePath to $destPath : $_ " }
10231026 } else {
@@ -1072,6 +1075,7 @@ function Get-ModuleType {
10721075 " Apache*" = " Apache"
10731076 " Bind*" = " Bind"
10741077 " Blackfire*" = " Blackfire"
1078+ " Caddy*" = " Caddy"
10751079 " Mailpit*" = " Mailpit"
10761080 " MariaDB*" = " MariaDB"
10771081 " Memcached*" = " Memcached"
@@ -1092,7 +1096,7 @@ function Get-ModuleType {
10921096function Process-ApacheModule { param ([string ]$ModuleName , [string ]$ZipPath , [string ]$DestDir )
10931097 try {
10941098 Write-Stage " APACHE-PROCESSING" " Processing Apache module"
1095- if (-not (Extract - MoveFromSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " Apache*" )) { throw " extract failed" }
1099+ if (-not (Move-FromZipSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " Apache*" )) { throw " extract failed" }
10961100 Write-Stage " APACHE-PROCESSING" " Cleaning up unnecessary Apache files"
10971101 $apacheMonitorPath = Join-Path $DestDir " bin\ApacheMonitor.exe"
10981102 if (Test-Path $apacheMonitorPath ) { Remove-Item $apacheMonitorPath - Force - ErrorAction SilentlyContinue; Write-Success " Removed ApacheMonitor.exe" }
@@ -1135,6 +1139,15 @@ function Process-BlackfireModule { param([string]$ModuleName, [string]$ZipPath,
11351139 } catch { Write-Error " Error processing Blackfire module: $_ " ; return $false }
11361140}
11371141
1142+ function Process-CaddyModule { param ([string ]$ModuleName , [string ]$ZipPath , [string ]$DestDir )
1143+ try {
1144+ Write-Stage " CADDY-PROCESSING" " Processing Caddy module"
1145+ Expand-Archive - Path $ZipPath - DestinationPath $DestDir - Force
1146+ Write-Success " Caddy module processing completed" ; return $true
1147+ } catch { Write-Error " Error processing Caddy module: $_ " ; return $false }
1148+ }
1149+
1150+
11381151function Process-MailpitModule { param ([string ]$ModuleName , [string ]$ZipPath , [string ]$DestDir )
11391152 try { Write-Stage " MAILPIT-PROCESSING" " Processing Mailpit module" ; Expand-Archive - Path $ZipPath - DestinationPath $DestDir - Force; Write-Success " Mailpit module processing completed" ; return $true }
11401153 catch { Write-Error " Error processing Mailpit module: $_ " ; return $false }
@@ -1143,7 +1156,7 @@ function Process-MailpitModule { param([string]$ModuleName, [string]$ZipPath, [s
11431156function Process-MariaDBModule { param ([string ]$ModuleName , [string ]$ZipPath , [string ]$DestDir )
11441157 try {
11451158 Write-Stage " MARIADB-PROCESSING" " Processing MariaDB module"
1146- if (-not (Extract - MoveFromSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " mariadb*" )) { throw " extract failed" }
1159+ if (-not (Move-FromZipSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " mariadb*" )) { throw " extract failed" }
11471160 Write-Stage " MARIADB-PROCESSING" " Cleaning up unnecessary MariaDB files"
11481161 $libDir = Join-Path $DestDir " lib"
11491162 if (Test-Path $libDir ) { [void ](Remove-FilesByPatterns - Base $libDir - Patterns @ (" *.lib" , " *.pdb" )) }
@@ -1163,7 +1176,7 @@ function Process-MariaDBModule { param([string]$ModuleName, [string]$ZipPath, [s
11631176function Process-MemcachedModule { param ([string ]$ModuleName , [string ]$ZipPath , [string ]$DestDir )
11641177 try {
11651178 Write-Stage " MEMCACHED-PROCESSING" " Processing Memcached module"
1166- if (-not (Extract - MoveFromSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " memcached*" )) { throw " extract failed" }
1179+ if (-not (Move-FromZipSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " memcached*" )) { throw " extract failed" }
11671180 Write-Stage " MEMCACHED-PROCESSING" " Cleaning up unnecessary Memcached files"
11681181 [void ](Remove-DirectoriesIfExists - Base $DestDir - Dirs @ (" include" ))
11691182 $binDir = Join-Path $DestDir " bin"
@@ -1175,7 +1188,7 @@ function Process-MemcachedModule { param([string]$ModuleName, [string]$ZipPath,
11751188function Process-MongoDBModule { param ([string ]$ModuleName , [string ]$ZipPath , [string ]$DestDir )
11761189 try {
11771190 Write-Stage " MONGODB-PROCESSING" " Processing MongoDB module"
1178- if (-not (Extract - MoveFromSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " mongodb*" )) { throw " extract failed" }
1191+ if (-not (Move-FromZipSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " mongodb*" )) { throw " extract failed" }
11791192 Write-Stage " MONGODB-PROCESSING" " Cleaning up unnecessary MongoDB files"
11801193 $vcRedistPath = Join-Path $DestDir " bin\vc_redist.x64.exe"
11811194 if (Test-Path $vcRedistPath ) { Remove-Item $vcRedistPath - Force - ErrorAction SilentlyContinue; Write-Success " Removed vc_redist.x64.exe from bin directory" }
@@ -1188,7 +1201,7 @@ function Process-MongoDBModule { param([string]$ModuleName, [string]$ZipPath, [s
11881201function Process-MySQLModule { param ([string ]$ModuleName , [string ]$ZipPath , [string ]$DestDir )
11891202 try {
11901203 Write-Stage " MYSQL-PROCESSING" " Processing MySQL module"
1191- if (-not (Extract - MoveFromSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " mysql*" )) { throw " extract failed" }
1204+ if (-not (Move-FromZipSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " mysql*" )) { throw " extract failed" }
11921205 Write-Stage " MYSQL-PROCESSING" " Cleaning up unnecessary MySQL files"
11931206 [void ](Remove-DirectoriesIfExists - Base $DestDir - Dirs @ (" data" , " include" , " docs" , " lib\plugin\debug" , " lib\debug" , " mysql-test" ))
11941207 foreach ($file in @ (" my-default.ini" , " bin\mysqld-debug.exe" , " bin\mysqltest_embedded.exe" , " bin\mysqltest_embedded.exe" , " bin\mysql_client_test_embedded.exe" , " bin\mysql_client_test.exe" , " bin\mysql_configurator.exe" , " lib\libmysqld.dll" )) {
@@ -1509,6 +1522,7 @@ function Process-PHPModule { param([string]$ModuleName, [string]$ZipPath, [strin
15091522 " 8.2" = " https://netix.dl.sourceforge.net/project/net-snmp/net-snmp/5.9.4/net-snmp-5.9.4.zip?viasf=1"
15101523 " 8.3" = " https://netix.dl.sourceforge.net/project/net-snmp/net-snmp/5.9.4/net-snmp-5.9.4.zip?viasf=1"
15111524 " 8.4" = " https://netix.dl.sourceforge.net/project/net-snmp/net-snmp/5.9.4/net-snmp-5.9.4.zip?viasf=1"
1525+ " 8.5" = " https://netix.dl.sourceforge.net/project/net-snmp/net-snmp/5.9.4/net-snmp-5.9.4.zip?viasf=1"
15121526 }
15131527 if ($netSnmpUrls.ContainsKey ($phpVersion )) {
15141528 try {
@@ -1582,7 +1596,7 @@ function Process-PostgreSQLModule { param([string]$ModuleName, [string]$ZipPath,
15821596function Process-RabbitMQModule { param ([string ]$ModuleName , [string ]$ZipPath , [string ]$DestDir )
15831597 try {
15841598 Write-Stage " RABBITMQ-PROCESSING" " Processing RabbitMQ module"
1585- if (-not (Extract - MoveFromSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " rabbitmq*" )) { throw " extract failed" }
1599+ if (-not (Move-FromZipSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " rabbitmq*" )) { throw " extract failed" }
15861600 Write-Stage " RABBITMQ-PROCESSING" " Cleaning up unnecessary RabbitMQ files"
15871601 $readmePath = Join-Path $DestDir " etc\README.txt"
15881602 if (Test-Path $readmePath ) { Remove-Item $readmePath - Force - ErrorAction SilentlyContinue; Write-Success " Removed file: etc\README.txt" }
@@ -1593,7 +1607,7 @@ function Process-RabbitMQModule { param([string]$ModuleName, [string]$ZipPath, [
15931607function Process-RedisModule { param ([string ]$ModuleName , [string ]$ZipPath , [string ]$DestDir )
15941608 try {
15951609 Write-Stage " REDIS-PROCESSING" " Processing Redis module"
1596- if (-not (Extract - MoveFromSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " redis*" )) { throw " extract failed" }
1610+ if (-not (Move-FromZipSubfolder - ZipPath $ZipPath - DestDir $DestDir - Filter " redis*" )) { throw " extract failed" }
15971611 Write-Stage " REDIS-PROCESSING" " Cleaning up unnecessary Redis files"
15981612 foreach ($file in @ (" redis.conf" , " install_redis.cmd" )) {
15991613 $filePath = Join-Path $DestDir $file
@@ -1652,6 +1666,7 @@ function Extract-Module {
16521666 " Apache" { Process - ApacheModule - ModuleName $ModuleName - ZipPath $ZipPath - DestDir $DestDir }
16531667 " Bind" { Process - BindModule - ModuleName $ModuleName - ZipPath $ZipPath - DestDir $DestDir }
16541668 " Blackfire" { Process - BlackfireModule - ModuleName $ModuleName - ZipPath $ZipPath - DestDir $DestDir }
1669+ " Caddy" { Process - CaddyModule - ModuleName $ModuleName - ZipPath $ZipPath - DestDir $DestDir }
16551670 " Mailpit" { Process - MailpitModule - ModuleName $ModuleName - ZipPath $ZipPath - DestDir $DestDir }
16561671 " MariaDB" { Process - MariaDBModule - ModuleName $ModuleName - ZipPath $ZipPath - DestDir $DestDir }
16571672 " Memcached" { Process - MemcachedModule - ModuleName $ModuleName - ZipPath $ZipPath - DestDir $DestDir }
0 commit comments