-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-win.ps1
76 lines (57 loc) · 2.17 KB
/
build-win.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
73
74
75
76
param(
[string]$CEWD
)
$ErrorActionPreference = 'Stop'
Set-Location -Path $CEWD
$ROOT = Get-Location
$HASH = (git rev-parse HEAD) -join [Environment]::NewLine
$RELEASE_FILE_NAME = $HASH
$RELEASE_NAME = $HASH
$BRANCH = $HASH
Write-Host "RELEASE_FILE_NAME: $RELEASE_FILE_NAME"
Write-Host "RELEASE_NAME: $RELEASE_NAME"
Write-Host "HASH: $HASH"
Write-Host "BRANCH: $BRANCH"
Remove-Item -Path "out" -Recurse -Force -ErrorAction Ignore
New-Item -Path . -Name "out/dist" -Force -ItemType "directory"
Set-Location -Path "./out/dist"
New-Item -Name "git_hash"
Set-Content -Path "git_hash" -Value "$HASH"
New-Item -Name "release_build"
Set-Content -Path "release_build" -Value "$RELEASE_NAME"
Copy-Item -Path "$ROOT/etc" -Destination . -Recurse
Copy-Item -Path "$ROOT/examples" -Destination . -Recurse
Copy-Item -Path "$ROOT/views" -Destination . -Recurse
Copy-Item -Path "$ROOT/types" -Destination . -Recurse
Copy-Item -Path "$ROOT/package*.json" -Destination . -Recurse
Remove-Item -Path "$ROOT/lib/storage/data" -Force -Recurse -ErrorAction Ignore
Set-Location -Path $ROOT
npm install --no-audit
if ($LASTEXITCODE -ne 0) {
throw "npm install exited with error $LASTEXITCODE"
}
npm run webpack
if ($LASTEXITCODE -ne 0) {
throw "npm run webpack exited with error $LASTEXITCODE"
}
npm run ts-compile
if ($LASTEXITCODE -ne 0) {
throw "npm run ts-compile exited with error $LASTEXITCODE"
}
Set-Location -Path "./out/dist"
npm install --no-audit --ignore-scripts --production
if ($LASTEXITCODE -ne 0) {
throw "npm install (prod) exited with error $LASTEXITCODE"
}
Remove-Item -Path "node_modules/.cache" -Force -Recurse -ErrorAction Ignore
Remove-Item -Path "node_modules/monaco-editor" -Force -Recurse -ErrorAction Ignore
Remove-Item -Path "node_modules" -Include "*.ts" -Force -Recurse -ErrorAction Ignore
node --import=tsx --no-warnings=ExperimentalWarning ./app.js --version --dist
if ($LASTEXITCODE -ne 0) {
throw "node exited with error $LASTEXITCODE"
}
$DIST_DIR = "$ROOT/out/dist-bin/dist"
Remove-Item -Path $DIST_DIR -Recurse -Force -ErrorAction Ignore
New-Item -ItemType Directory -Force -Path $DIST_DIR
Set-Content -Path "$DIST_DIR/$HASH.txt" -Value "$HASH"
Set-Location -Path $ROOT