-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.ps1
72 lines (59 loc) · 1.63 KB
/
build.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
<#
Script builds the Hyde frontend and backend, then moves builds to a created .\target folder
Use optional argument -CopyHydeData <Path> to copy the hyde data from a specified directory.
#>
param (
[String]$C
)
$FrontendFolder = ".\frontend"
$FrontendBuildFolder = "${FrontendFolder}\build"
$BackendFolder = ".\backend"
$BackendBuildExe = "${BackendFolder}\target\release\hyde-backend.exe"
$BuildFolder = ".\target"
function Check-Target {
if (Test-Path -Path $BuildFolder) {
Write-Host "Clearing target folder for rebuild"
Remove-Item "${BuildFolder}\*" -Recurse -Force
return
}
New-Item -Path . -Name $BuildFolder -ItemType "directory"
}
function Build-Frontend {
Push-Location $FrontendFolder
npm i
npm run build
Pop-Location
}
function Build-Backend {
Push-Location $BackendFolder
cargo build --release
Pop-Location
}
function Copy-Builds {
New-Item -Path "${BuildFolder}\web" -ItemType Directory -ErrorAction SilentlyContinue
Copy-Item -Path "${FrontendBuildFolder}\*" -Destination "${BuildFolder}\web" -Force -Recurse
Copy-Item -Path $BackendBuildExe -Destination "${BuildFolder}\hyde.exe" -Force
}
function Copy-HydeData {
Param (
[Parameter(Mandatory=$true)]
[String] $HydeDataFolder
)
Copy-Item -Path $HydeDataFolder -Destination $BuildFolder -Recurse -Force
}
function Main {
Check-Target
Build-Frontend
Build-Backend
Copy-Builds
}
if ($C.Length -gt 0) {
if (-not (Test-Path $C)) {
Write-Host "${C} path does not exist. Cannot copy."
return
}
Main
Copy-HydeData $C
return
}
Main