-
Notifications
You must be signed in to change notification settings - Fork 323
Expand file tree
/
Copy pathbuild.ps1
More file actions
123 lines (100 loc) ยท 4.85 KB
/
build.ps1
File metadata and controls
123 lines (100 loc) ยท 4.85 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
#!/usr/bin/env pwsh
# ClawPanel ๆฌๅฐๆๅปบ่ๆฌ๏ผWindows๏ผ
# ็จๆณ:
# .\build.ps1 โ ๆๅปบ Windows ๅฎ่ฃ
ๅ
๏ผ้ป่ฎค๏ผ
# .\build.ps1 -Debug โ Debug ๆๅปบ๏ผๅฟซ๏ผไธๆๅ
๏ผ
# .\build.ps1 -Clean โ ๆธ
็ Rust ็ผ่ฏ็ผๅญๅๆๅปบ
param(
[switch]$Debug,
[switch]$Clean
)
$ErrorActionPreference = "Stop"
function Write-Step([string]$msg) {
Write-Host "`nโถ $msg" -ForegroundColor Cyan
}
function Write-Ok([string]$msg) {
Write-Host " โ $msg" -ForegroundColor Green
}
function Write-Fail([string]$msg) {
Write-Host " โ $msg" -ForegroundColor Red
}
Write-Host ""
Write-Host " ClawPanel ๆๅปบๅทฅๅ
ท" -ForegroundColor Magenta
Write-Host " โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" -ForegroundColor DarkGray
Write-Host " ๅนณๅฐ: Windows x64 (ๆฌๆบๆๅปบ)" -ForegroundColor DarkGray
Write-Host " ่ทจๅนณๅฐๆๅปบ (macOS / Linux) ่ฏทๆจ้ tag ่งฆๅ GitHub Actions" -ForegroundColor DarkGray
Write-Host ""
# โโ ็ฏๅขๆฃๆต โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Write-Step "ๆฃๆฅๆๅปบไพ่ต"
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
Write-Fail "ๆชๆพๅฐ Node.js๏ผ่ฏทไป https://nodejs.org ๅฎ่ฃ
v18+"
exit 1
}
$nodeVer = (node --version)
Write-Ok "Node.js $nodeVer"
if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
Write-Fail "ๆชๆพๅฐ npm"
exit 1
}
if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
Write-Fail "ๆชๆพๅฐ Rust/Cargo๏ผ่ฏทไป https://rustup.rs ๅฎ่ฃ
"
exit 1
}
$rustVer = (rustc --version)
Write-Ok "Rust $rustVer"
# ๆฃๆต WebView2๏ผWindows ๅฟ
้กป๏ผ
$webview2Key = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
if (-not (Test-Path $webview2Key)) {
Write-Host " โ ๆชๆฃๆตๅฐ WebView2 Runtime๏ผ็ฎๆ ็จๆท้่ฆๅฎ่ฃ
" -ForegroundColor Yellow
Write-Host " ไธ่ฝฝๅฐๅ: https://developer.microsoft.com/microsoft-edge/webview2/" -ForegroundColor DarkGray
}
# โโ ไพ่ตๅฎ่ฃ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Write-Step "ๅฎ่ฃ
ๅ็ซฏไพ่ต"
if (-not (Test-Path "node_modules")) {
npm ci --silent
if ($LASTEXITCODE -ne 0) { Write-Fail "npm ci ๅคฑ่ดฅ"; exit 1 }
Write-Ok "ไพ่ตๅฎ่ฃ
ๅฎๆ"
} else {
Write-Ok "ไพ่ตๅทฒๅญๅจ๏ผ่ทณ่ฟ"
}
# โโ ๆธ
็็ผๅญ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if ($Clean) {
Write-Step "ๆธ
็ Rust ็ผ่ฏ็ผๅญ"
Push-Location src-tauri
cargo clean
Pop-Location
Write-Ok "็ผๅญๅทฒๆธ
็"
}
# โโ ๆๅปบ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
$startTime = Get-Date
if ($Debug) {
Write-Step "Debug ๆๅปบ๏ผไธๆๅ
ๅฎ่ฃ
ๅจ๏ผ"
npm run tauri build -- --debug
} else {
Write-Step "Release ๆๅปบ๏ผ็ๆ Windows ๅฎ่ฃ
ๅ
๏ผ"
npm run tauri build
}
if ($LASTEXITCODE -ne 0) {
Write-Fail "ๆๅปบๅคฑ่ดฅ"
exit 1
}
$elapsed = [math]::Round(((Get-Date) - $startTime).TotalSeconds)
# โโ ่พๅบ็ปๆ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Write-Host ""
Write-Host " โ
ๆๅปบๆๅ๏ผ่ๆถ ${elapsed}s" -ForegroundColor Green
Write-Host " โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" -ForegroundColor DarkGray
$bundleDir = "src-tauri\target\release\bundle"
if ($Debug) {
$exePath = "src-tauri\target\debug\clawpanel.exe"
Write-Host " ๅฏๆง่กๆไปถ: $exePath" -ForegroundColor White
} else {
Write-Host " ๅฎ่ฃ
ๅ
็ฎๅฝ: $bundleDir" -ForegroundColor White
$msi = Get-ChildItem "$bundleDir\msi\*.msi" -ErrorAction SilentlyContinue | Select-Object -First 1
$exe = Get-ChildItem "$bundleDir\nsis\*-setup.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($msi) { Write-Host " MSI: $($msi.FullName)" -ForegroundColor DarkGray }
if ($exe) { Write-Host " EXE: $($exe.FullName)" -ForegroundColor DarkGray }
}
Write-Host ""
Write-Host " ๆ็คบ: ๅๅธ่ทจๅนณๅฐ็ๆฌ่ฏทๆจ้ tag๏ผไพๅฆ:" -ForegroundColor DarkGray
Write-Host " git tag v1.0.0 && git push origin v1.0.0" -ForegroundColor DarkGray
Write-Host ""