feat: add support for SVR.JS archives without "svr.compressed" and with "wwwroot"
This commit is contained in:
parent
e460ab72b2
commit
e436fec833
1 changed files with 33 additions and 25 deletions
|
@ -60,10 +60,6 @@ if (!(Test-Path -Path "$env:SYSTEMDRIVE\svrjs\svrjs")) {
|
||||||
New-Item -Path "$env:SYSTEMDRIVE\svrjs" -Name "svrjs" -ItemType "directory" | Out-Null
|
New-Item -Path "$env:SYSTEMDRIVE\svrjs" -Name "svrjs" -ItemType "directory" | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(Test-Path -Path "$env:SYSTEMDRIVE\svrjs\wwwroot")) {
|
|
||||||
New-Item -Path "$env:SYSTEMDRIVE\svrjs" -Name "wwwroot" -ItemType "directory" | Out-Null
|
|
||||||
}
|
|
||||||
|
|
||||||
# Download SVR.JS zip archive
|
# Download SVR.JS zip archive
|
||||||
if ($installType -eq "manual") {
|
if ($installType -eq "manual") {
|
||||||
$svrjsZipArchive = Read-Host "Path to SVR.JS zip archive: "
|
$svrjsZipArchive = Read-Host "Path to SVR.JS zip archive: "
|
||||||
|
@ -132,28 +128,40 @@ Remove-Item -Path $nodejsZipArchive
|
||||||
Write-Host "Extracting SVR.JS files..."
|
Write-Host "Extracting SVR.JS files..."
|
||||||
Expand-Archive -Path $svrjsZipArchive -DestinationPath "$env:SYSTEMDRIVE\svrjs\svrjs" -Force
|
Expand-Archive -Path $svrjsZipArchive -DestinationPath "$env:SYSTEMDRIVE\svrjs\svrjs" -Force
|
||||||
Remove-Item -Path $svrjsZipArchive
|
Remove-Item -Path $svrjsZipArchive
|
||||||
Push-Location
|
if (Test-Path -Path "$env:SYSTEMDRIVE\svrjs\svrjs\svr.compressed" -PathType "Leaf") {
|
||||||
Set-Location -Path "$env:SYSTEMDRIVE\svrjs\svrjs"
|
Push-Location
|
||||||
Start-Process -FilePath "$nodejsDir\node.exe" -ArgumentList "$env:SYSTEMDRIVE\svrjs\svrjs\svr.js" -Wait
|
Set-Location -Path "$env:SYSTEMDRIVE\svrjs\svrjs"
|
||||||
Pop-Location
|
Start-Process -FilePath "$nodejsDir\node.exe" -ArgumentList "$env:SYSTEMDRIVE\svrjs\svrjs\svr.js" -Wait
|
||||||
|
Pop-Location
|
||||||
|
}
|
||||||
Start-Process -FilePath "$nodejsDir\node.exe" -ArgumentList "-e `"var fs=require('fs'),config=JSON.parse(fs.readFileSync('$env:SYSTEMDRIVE\\svrjs\\svrjs\\config.json').toString());config.wwwroot='$env:SYSTEMDRIVE\\svrjs\\wwwroot',fs.writeFileSync('$env:SYSTEMDRIVE\\svrjs\\svrjs\\config.json',JSON.stringify(config));`"" -Wait
|
Start-Process -FilePath "$nodejsDir\node.exe" -ArgumentList "-e `"var fs=require('fs'),config=JSON.parse(fs.readFileSync('$env:SYSTEMDRIVE\\svrjs\\svrjs\\config.json').toString());config.wwwroot='$env:SYSTEMDRIVE\\svrjs\\wwwroot',fs.writeFileSync('$env:SYSTEMDRIVE\\svrjs\\svrjs\\config.json',JSON.stringify(config));`"" -Wait
|
||||||
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\index.html" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
if (Test-Path -Path "$env:SYSTEMDRIVE\svrjs\svrjs\wwwroot" -PathType "Container") {
|
||||||
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\tests.html" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
if (Test-Path -Path "$env:SYSTEMDRIVE\svrjs\wwwroot") {
|
||||||
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\licenses" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
Remove-Item -Path "$env:SYSTEMDRIVE\svrjs\wwwroot" -Recurse -Force | Out-Null
|
||||||
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\testdir" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
New-Item -Path "$env:SYSTEMDRIVE\svrjs" -Name "wwwroot" -ItemType "directory" | Out-Null
|
||||||
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\serverSideScript.js" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
}
|
||||||
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\logo.png" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\wwwroot" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\powered.png" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
} else {
|
||||||
if (Test-Path -Path "$env:SYSTEMDRIVE\svrjs\svrjs\favicon.ico") {
|
if (!(Test-Path -Path "$env:SYSTEMDRIVE\svrjs\wwwroot")) {
|
||||||
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\favicon.ico" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
New-Item -Path "$env:SYSTEMDRIVE\svrjs" -Name "wwwroot" -ItemType "directory" | Out-Null
|
||||||
|
}
|
||||||
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\index.html" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\tests.html" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\licenses" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\testdir" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\serverSideScript.js" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\logo.png" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\powered.png" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
|
if (Test-Path -Path "$env:SYSTEMDRIVE\svrjs\svrjs\favicon.ico") {
|
||||||
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\favicon.ico" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
|
}
|
||||||
|
if (Test-Path -Path "$env:SYSTEMDRIVE\svrjs\svrjs\views.txt") {
|
||||||
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\views.txt" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
|
}
|
||||||
|
if (Test-Path -Path "$env:SYSTEMDRIVE\svrjs\svrjs\hviews.txt") {
|
||||||
|
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\hviews.txt" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Test-Path -Path "$env:SYSTEMDRIVE\svrjs\svrjs\views.txt") {
|
|
||||||
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\views.txt" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
|
||||||
}
|
|
||||||
if (Test-Path -Path "$env:SYSTEMDRIVE\svrjs\svrjs\hviews.txt") {
|
|
||||||
Move-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\hviews.txt" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot"
|
|
||||||
}
|
|
||||||
Copy-Item -Path "$env:SYSTEMDRIVE\svrjs\svrjs\.dirimages" -Destination "$env:SYSTEMDRIVE\svrjs\wwwroot" -Recurse
|
|
||||||
|
|
||||||
# Generate WinSW Configuration
|
# Generate WinSW Configuration
|
||||||
Write-Host "Generating WinSW configuration..."
|
Write-Host "Generating WinSW configuration..."
|
||||||
|
@ -185,4 +193,4 @@ rd %SYSTEMDRIVE%\svrjs /s /q
|
||||||
|
|
||||||
$uninstallBat | Out-File -FilePath "$env:SYSTEMDRIVE\uninstall_svrjs.bat" -Encoding utf8
|
$uninstallBat | Out-File -FilePath "$env:SYSTEMDRIVE\uninstall_svrjs.bat" -Encoding utf8
|
||||||
|
|
||||||
echo "Done! SVR.JS is installed successfully!"
|
echo "Done! SVR.JS is installed successfully!"
|
Loading…
Reference in a new issue