-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall-env.ps1
72 lines (63 loc) · 2.68 KB
/
install-env.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
71
72
function Check-Command([String]$command) {
try {
$cont = Invoke-Expression $command
}
catch {
return $false
}
return $true
}
# Check Node.js
if (-not (Check-Command 'node --version')) {
Write-Host 'Missing Node.js, downloading from Pomelo Cloud.'
Invoke-WebRequest 'https://resource.pomelo.cloud/third-party/node-v12.16.1-x64.msi' -OutFile 'node-v12.16.1-x64.msi'
$InstallNodeJsCommand = 'msiexec.exe /i node-v12.16.1-x64.msi /qn'
Remove-Item -Path 'node-v12.16.1-x64.msi' -Force
} else {
Write-Host 'Node.js is already installed. Skipped the installation step.'
}
# Check .NET Core SDK 3.1
if (-not (Check-Command 'dotnet') -or -not((Invoke-Expression 'dotnet --version').Contains('3.1'))) {
Write-Host 'Missing .NET Core 3.1 or higher, downloading from Pomelo Cloud.'
Invoke-WebRequest 'https://resource.pomelo.cloud/third-party/dotnet-sdk-3.1.102-win-x64.exe' -OutFile 'dotnet-sdk-3.1.102-win-x64.exe'
$InstallNodeJsCommand = '.\dotnet-sdk-3.1.102-win-x64.exe /install /norestart /quiet'
Remove-Item -Path 'dotnet-sdk-3.1.102-win-x64.exe' -Force
} else {
Write-Host '.NET Core SDK 3.1 is already installed. Skipped the installation step.'
}
# Download Electron
$RepoPath = Get-Location
$ElectronPath = Join-Path $RepoPath 'Pomelo.Explorer'
$ElectronPath = Join-Path $ElectronPath 'obj'
if (-not (Test-Path $ElectronPath)) {
New-Item -Path $ElectronPath -ItemType Directory
}
$ElectronPath = Join-Path $ElectronPath 'Host'
if (-not (Test-Path $ElectronPath)) {
New-Item -Path $ElectronPath -ItemType Directory
}
$ElectronPath = Join-Path $ElectronPath 'node_modules'
if (-not (Test-Path $ElectronPath)) {
New-Item -Path $ElectronPath -ItemType Directory
}
$ElectronPath = Join-Path $ElectronPath 'electron'
if (-not (Test-Path $ElectronPath)) {
Write-Host 'Electron node module not found, downloading from Pomelo Cloud...'
Invoke-WebRequest 'https://resource.pomelo.cloud/third-party/electron.zip' -OutFile 'electron.zip'
Expand-Archive 'electron.zip' -DestinationPath $ElectronPath
} else {
Write-Host 'Electron node module is already installed. Skipped the installation step.'
}
# Check Electronize CLI
if (-not (Check-Command 'electronize')) {
Write-Host 'Electronize CLI is not found, downloading...'
$InstallElectronizeCommand = 'dotnet tool install --global ElectronNET.CLI'
Invoke-Expression $InstallElectronizeCommand
}
# Check libman
if (-not (Check-Command 'electronize')) {
Write-Host 'libman is not found, downloading...'
$InstallLibmanCommand = 'dotnet tool install -g Microsoft.Web.LibraryManager.Cli'
Invoke-Expression $InstallLibmanCommand
}
Write-Host 'The environment setup finished!'