-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.ps1
More file actions
148 lines (120 loc) · 5.59 KB
/
status.ps1
File metadata and controls
148 lines (120 loc) · 5.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# PrintMaster Status Check
# Quick overview of project state
$ErrorActionPreference = 'Continue'
function Write-Section {
param([string]$Title)
Write-Host "`n╔══════════════════════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host "║ $($Title.PadRight(50)) ║" -ForegroundColor Cyan
Write-Host "╚══════════════════════════════════════════════════════╝" -ForegroundColor Cyan
}
function Write-Item {
param([string]$Label, [string]$Value, [string]$Color = "White")
Write-Host " $($Label.PadRight(20)): " -NoNewline
Write-Host $Value -ForegroundColor $Color
}
# ============================================================================
# VERSION INFO
# ============================================================================
Write-Section "Version Information"
$agentVersion = if (Test-Path "agent\VERSION") { (Get-Content "agent\VERSION" -Raw).Trim() } else { "NOT FOUND" }
$serverVersion = if (Test-Path "server\VERSION") { (Get-Content "server\VERSION" -Raw).Trim() } else { "NOT FOUND" }
Write-Item "Agent Version" $agentVersion "Green"
Write-Item "Server Version" $serverVersion "Green"
# ============================================================================
# GIT STATUS
# ============================================================================
Write-Section "Git Status"
$gitBranch = git rev-parse --abbrev-ref HEAD 2>$null
$gitCommit = git rev-parse --short HEAD 2>$null
$gitRemote = git remote get-url origin 2>$null
$gitStatus = git status --porcelain 2>$null
if ($gitBranch) {
Write-Item "Branch" $gitBranch "Yellow"
Write-Item "Commit" $gitCommit "Gray"
Write-Item "Remote" $gitRemote "Gray"
if ($gitStatus) {
Write-Item "Working Directory" "UNCOMMITTED CHANGES" "Red"
Write-Host ""
$gitStatus | ForEach-Object { Write-Host " $_" -ForegroundColor Yellow }
} else {
Write-Item "Working Directory" "Clean ✓" "Green"
}
} else {
Write-Host " Not a git repository" -ForegroundColor Red
}
# Check for unpushed commits
$unpushed = git log origin/$gitBranch..$gitBranch --oneline 2>$null
if ($unpushed) {
Write-Host ""
Write-Host " ⚠️ Unpushed commits:" -ForegroundColor Yellow
$unpushed | ForEach-Object { Write-Host " $_" -ForegroundColor Yellow }
}
# ============================================================================
# TAGS
# ============================================================================
Write-Section "Recent Tags"
$recentTags = git tag -l --sort=-version:refname 2>$null | Select-Object -First 5
if ($recentTags) {
$recentTags | ForEach-Object { Write-Host " $_" -ForegroundColor Green }
} else {
Write-Host " No tags found" -ForegroundColor Gray
}
# ============================================================================
# BUILD STATUS
# ============================================================================
Write-Section "Build Artifacts"
$agentExe = "agent\printmaster-agent.exe"
$serverExe = "server\printmaster-server.exe"
if (Test-Path $agentExe) {
$agentSize = [math]::Round((Get-Item $agentExe).Length / 1MB, 2)
$agentTime = (Get-Item $agentExe).LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
Write-Item "Agent Binary" "$agentSize MB (built $agentTime)" "Green"
} else {
Write-Item "Agent Binary" "NOT BUILT" "Red"
}
if (Test-Path $serverExe) {
$serverSize = [math]::Round((Get-Item $serverExe).Length / 1MB, 2)
$serverTime = (Get-Item $serverExe).LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
Write-Item "Server Binary" "$serverSize MB (built $serverTime)" "Green"
} else {
Write-Item "Server Binary" "NOT BUILT" "Red"
}
# ============================================================================
# RUNNING PROCESSES
# ============================================================================
Write-Section "Running Processes"
$processes = Get-Process | Where-Object {
$_.ProcessName -like '*printmaster*' -or
$_.Path -like '*printmaster*' -or
$_.ProcessName -like '*debug_bin*'
}
if ($processes) {
$processes | ForEach-Object {
$port = ""
try {
$connections = Get-NetTCPConnection -OwningProcess $_.Id -ErrorAction SilentlyContinue |
Where-Object { $_.State -eq 'Listen' }
if ($connections) {
$port = " (Port: $($connections[0].LocalPort))"
}
} catch {}
Write-Host " $($_.ProcessName)$port" -ForegroundColor Yellow
$startTime = if ($_.StartTime) { $_.StartTime.ToString('HH:mm:ss') } else { "unknown" }
Write-Host " PID: $($_.Id) | Started: $startTime" -ForegroundColor Gray
}
} else {
Write-Host " No PrintMaster processes running" -ForegroundColor Gray
}
# ============================================================================
# QUICK ACTIONS
# ============================================================================
Write-Section "Quick Actions"
Write-Host " Build: " -NoNewline -ForegroundColor White
Write-Host ".\build.ps1 agent" -ForegroundColor Cyan
Write-Host " Test: " -NoNewline -ForegroundColor White
Write-Host ".\build.ps1 test-all" -ForegroundColor Cyan
Write-Host " Release: " -NoNewline -ForegroundColor White
Write-Host ".\release.ps1 agent patch" -ForegroundColor Cyan
Write-Host " Debug: " -NoNewline -ForegroundColor White
Write-Host "Press F5 in VS Code" -ForegroundColor Cyan
Write-Host ""