-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.ps1
More file actions
62 lines (39 loc) · 1.62 KB
/
publish.ps1
File metadata and controls
62 lines (39 loc) · 1.62 KB
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
# Build script to create a production bundle ready for deployment on the dedicated server.
# The production bundle will be output to "./out".
$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch
$stopWatch.Start()
$starter_location = Get-Location
function Check-LastCmd {
param(
[string]$ErrorMessage
)
if ($LASTEXITCODE -ne 0) {
Write-Host $ErrorMessage
exit
}
}
Remove-Item ./out -Recurse -ErrorAction Ignore
Write-Host "`nBuilding the ASP.NET Core back-end...`n"
dotnet publish ./src/Mmcc.Stats -c Release --output ./out
Check-LastCmd -ErrorMessage "`nError while building the ASP.NET Core back-end. Exiting...`n"
Write-Host "`Built the ASP.NET Core back-end.`n"
Set-Location ./src/Mmcc.Stats.Frontend
Write-Host "`nRestoring npm packages...`n"
npm install
Check-LastCmd -ErrorMessage "`nError while restoring npm packages. Exiting...`n"
Write-Host "`nRestored npm packages.`n"
Write-Host "`nApplying security fixes...`n"
npm audit fix
Check-LastCmd "`nError while applying fixes. Exiting...`n"
Write-Host "`nApplied security fixes.`n"
Write-Host "`nBuilding the Svelte app...`n"
npm run build
Check-LastCmd -ErrorMessage "`nError while building the Svelte app. Exiting...`n"
Write-Host "`nBuilt the Svelte app.`n"
Write-Host "`nCopying the Svelte bundle..."
Set-Location $starter_location
New-Item -Path ./out -Name "wwwroot" -ItemType "directory"
Copy-Item "./src/Mmcc.Stats.Frontend/public/*" -Destination "./out/wwwroot" -Recurse
Write-Host "`nCopied the Svelte bundle.`n"
$stopWatch.Stop()
Write-Host "`nBuild succeeded in $($stopWatch.Elapsed). Output to: `"./out`".`n"