-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
52 lines (37 loc) · 1.54 KB
/
Copy pathsetup.ps1
File metadata and controls
52 lines (37 loc) · 1.54 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
#Requires -Version 5.1
$ErrorActionPreference = 'Stop'
$RootDir = Split-Path -Parent $MyInvocation.MyCommand.Path
function log($msg) { Write-Host "[setup] $msg" }
function fail($msg) { Write-Error "[setup] ERROR: $msg"; exit 1 }
# --- Node version ---
$nvmrcPath = Join-Path $RootDir '.nvmrc'
if (Test-Path $nvmrcPath) {
$nodeVersion = (Get-Content $nvmrcPath).Trim()
if (Get-Command nvm -ErrorAction SilentlyContinue) {
log "Switching to Node $nodeVersion via nvm..."
nvm use $nodeVersion
} else {
log "nvm not found — skipping Node version switch (wanted $nodeVersion)"
}
}
# --- Install dependencies ---
log "Installing root dependencies..."
npm install --prefix $RootDir
log "Installing frontend dependencies..."
npm install --prefix "$RootDir\frontend"
log "Installing backend dependencies..."
npm install --prefix "$RootDir\backend"
# --- Build ---
log "Building backend..."
npm run build --prefix "$RootDir\backend"
log "Building frontend..."
npm run build --prefix "$RootDir\frontend"
# --- Verify ---
log "Verifying backend build..."
$backendOut = "$RootDir\backend\dist\index.js"
if (-not (Test-Path $backendOut)) { fail "backend\dist\index.js not found" }
log "Verifying frontend build..."
$frontendDist = "$RootDir\frontend\dist\frontend\browser"
if (-not (Test-Path $frontendDist)) { fail "frontend dist not found at $frontendDist" }
if (-not (Test-Path "$frontendDist\index.html")) { fail "frontend\dist\frontend\browser\index.html not found" }
log "Done. All dependencies installed and builds verified."