-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-project.ps1
More file actions
69 lines (61 loc) · 2.62 KB
/
check-project.ps1
File metadata and controls
69 lines (61 loc) · 2.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
63
64
65
66
67
68
69
# ===============================
# CantonHackathon - Project Checker
# ===============================
Write-Host "🚀 Starting CantonHackathon project check..." -ForegroundColor Cyan
# --- 1. Check backend (Daml Sandbox)
$backendPath = "D:\CantonHackathon\backend\canton-lend"
$frontendPath = "D:\CantonHackathon\frontend"
Write-Host "`n🔍 Checking backend directory..."
if (Test-Path $backendPath) {
Write-Host "✅ Backend found at $backendPath"
} else {
Write-Host "❌ Backend not found! Check path." -ForegroundColor Red
exit
}
# --- 2. Check if Daml Sandbox is running
Write-Host "`n🔍 Checking if Daml Sandbox (port 7575) is running..."
$portCheck = (Get-NetTCPConnection -LocalPort 7575 -ErrorAction SilentlyContinue)
if ($portCheck) {
Write-Host "✅ Daml JSON API is running on port 7575"
} else {
Write-Host "❌ Sandbox not running. Starting it now..." -ForegroundColor Yellow
Start-Process powershell -ArgumentList "cd '$backendPath'; daml start" -WindowStyle Minimized
Start-Sleep -Seconds 10
}
# --- 3. Check JSON API response
Write-Host "`n🔍 Checking Daml JSON API connectivity..."
try {
$response = Invoke-RestMethod -Uri "http://localhost:7575/v1/query" -Method POST -Body '{"templateIds":["Main.User"]}' -ContentType "application/json" -ErrorAction Stop
Write-Host "✅ JSON API responded successfully!"
} catch {
Write-Host "⚠️ JSON API not responding. Possibly still starting up..." -ForegroundColor Yellow
}
# --- 4. Check frontend folder
Write-Host "`n🔍 Checking frontend directory..."
if (Test-Path $frontendPath) {
Write-Host "✅ Frontend found at $frontendPath"
} else {
Write-Host "❌ Frontend not found! Check path." -ForegroundColor Red
exit
}
# --- 5. Start frontend (npm start)
Write-Host "`n🌐 Starting frontend React app..."
Start-Process powershell -ArgumentList "cd '$frontendPath'; npm start" -WindowStyle Minimized
Start-Sleep -Seconds 8
# --- 6. Check if frontend is running
try {
$res = Invoke-WebRequest -Uri "http://localhost:3000" -UseBasicParsing -TimeoutSec 5
if ($res.StatusCode -eq 200) {
Write-Host "✅ Frontend is running at http://localhost:3000" -ForegroundColor Green
} else {
Write-Host "⚠️ Frontend responded with status $($res.StatusCode)"
}
} catch {
Write-Host "❌ Frontend not responding at localhost:3000" -ForegroundColor Red
}
Write-Host "`n============================="
Write-Host "🏁 Check completed!"
Write-Host "Open:"
Write-Host " • Backend JSON API → http://localhost:7575/v1/query"
Write-Host " • Frontend React → http://localhost:3000"
Write-Host "============================="