-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Expand file tree
/
Copy pathmake.ps1
More file actions
118 lines (107 loc) · 2.59 KB
/
make.ps1
File metadata and controls
118 lines (107 loc) · 2.59 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
param (
[Parameter(Position=0)]
[string]$Command = "help"
)
Set-StrictMode -version latest;
$ErrorActionPreference = 'Stop'
function Exec {
param([scriptblock]$CommandBlock)
& $CommandBlock
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
}
function Show-Help {
$makefile = Join-Path $PSScriptRoot "Makefile"
if (-not (Test-Path $makefile)) {
Write-Host "Makefile not found." -ForegroundColor Yellow
return
}
$commands = @()
foreach ($line in Get-Content $makefile) {
if ($line -match '^([a-zA-Z_-]+):.*?## (.*)$') {
$commands += [PSCustomObject]@{
Name = $matches[1]
Desc = $matches[2]
}
}
}
foreach ($cmd in ($commands | Sort-Object Name)) {
Write-Host ("{0,-20} {1}" -f $cmd.Name, $cmd.Desc)
}
}
function Start-Server {
Write-Host "Starting server in background..."
Start-Process -NoNewWindow uv -ArgumentList "run", "python", "server_main.py", "--port", "6400"
}
function Start-Client {
Write-Host "Starting frontend server..."
$env:VITE_API_BASE_URL="http://localhost:6400"
Exec { npm run dev --prefix frontend }
}
function Stop-Servers {
try {
Push-Location (Join-Path $PSScriptRoot "frontend")
try {
Write-Host "Stopping backend server (port 6400)..."
npx kill-port 6400
} catch { Write-Host " Port 6400: nothing to stop" -ForegroundColor DarkGray }
try {
Write-Host "Stopping frontend server (port 5173)..."
npx kill-port 5173
} catch { Write-Host " Port 5173: nothing to stop" -ForegroundColor DarkGray }
} finally {
Pop-Location
}
}
function Sync-Graphs {
Exec { uv run python tools/sync_vuegraphs.py }
}
function Validate-Yamls {
Exec { uv run python tools/validate_all_yamls.py }
}
function Test-Backend {
Exec { uv run pytest -v }
}
function Lint-Backend {
Exec { uvx ruff check . }
}
switch ($Command) {
"dev" {
Start-Server
Start-Client
}
"server" {
Start-Server
}
"client" {
Start-Client
}
"stop" {
Stop-Servers
}
"sync" {
Sync-Graphs
}
"validate-yamls" {
Validate-Yamls
}
"check-backend" {
Test-Backend
Lint-Backend
}
"backend-tests" {
Test-Backend
}
"backend-lint" {
Lint-Backend
}
"help" {
Show-Help
}
default {
Write-Error "Unknown command: $Command" -ErrorAction Continue
Show-Help
exit 1
}
}