forked from pmmp/PocketMine-MP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-source-running.ps1
70 lines (58 loc) · 2.2 KB
/
setup-source-running.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
$url = "https://github.com/pmmp/PHP-Binaries/releases/download/php-8.2-latest/PHP-Windows-x64-PM5.zip"
$zipfile = "PHP-Windows-x64-PM5.zip"
$binfolder = "bin"
$phpfolder = "$binfolder\php"
$composerUrl = "https://getcomposer.org/download/latest-stable/composer.phar"
$composerfile = "composer.phar"
$vcredist = "vc_redist.x64.exe"
if (Test-Path $binfolder) {
Write-Host "Removing existing bin folder..."
Remove-Item -Recurse -Force $binfolder
Write-Host "Bin folder removed."
}
Write-Host "Downloading PHP binaries..."
Invoke-WebRequest -Uri $url -OutFile $zipfile
if (Test-Path $zipfile) {
Write-Host "Download complete. Extracting bin folder..."
Expand-Archive -Path $zipfile -DestinationPath $PWD
if (Test-Path $binfolder) {
Write-Host "Extraction successful."
Write-Host "Downloading Composer..."
Invoke-WebRequest -Uri $composerUrl -OutFile "$binfolder\$composerfile"
if (Test-Path "$binfolder\$composerfile") {
Write-Host "Composer downloaded successfully to $binfolder."
Write-Host "Running composer install..."
& "$phpfolder\php.exe" "$binfolder\$composerfile" install
if ($LASTEXITCODE -eq 0) {
Write-Host "Composer install completed successfully."
} else {
Write-Host "Error: Composer install failed."
}
} else {
Write-Host "Error: Failed to download Composer."
}
if (Test-Path $vcredist) {
Write-Host "Removing $vcredist..."
Remove-Item $vcredist
Write-Host "$vcredist removed."
} else {
Write-Host "$vcredist not found, skipping removal."
}
if (Test-Path $zipfile) {
Write-Host "Removing $zipfile..."
Remove-Item $zipfile
Write-Host "$zipfile removed."
} else {
Write-Host "$zipfile not found, skipping removal."
}
Write-Host "Running git fetch..."
git fetch
Write-Host "Checking out stable branch..."
git checkout stable
} else {
Write-Host "Error: Bin folder not found."
}
} else {
Write-Host "Error: Failed to download the file."
}
pause