-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.ps1
More file actions
98 lines (76 loc) · 3.27 KB
/
build.ps1
File metadata and controls
98 lines (76 loc) · 3.27 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
param(
[switch]$Install,
[switch]$Package,
[string]$Version
)
$name = "Flow.Launcher.Plugin.SpeedTest"
$pluginsDir = "$env:APPDATA\FlowLauncher\Plugins"
$pj = Get-Content .\plugin.json -Raw | ConvertFrom-Json
if ($pj.Version) { $Version = $pj.Version }
if (-not $Install -and -not $Package) {
Write-Host "`nBuild Options:" -ForegroundColor Cyan
Write-Host "1. Build & Install"
Write-Host "2. Package for Release`n"
$opt = Read-Host "Pick one (1/2)"
if ($opt -eq "2") {
$Package = $true
} else {
$Install = $true
}
}
Write-Host "`nBuilding..." -ForegroundColor Yellow
dotnet build -c Release
if ($LASTEXITCODE -ne 0) {
Write-Host "Build failed" -ForegroundColor Red
exit 1
}
Write-Host "Build ok" -ForegroundColor Green
if ($Package) {
$temp = ".\package"
$rootName = "Speed Test-$Version"
$zip = "$name-$Version.zip"
Write-Host "Creating package..." -ForegroundColor Yellow
if (Test-Path $temp) { Remove-Item $temp -Recurse -Force }
New-Item -ItemType Directory -Path $temp | Out-Null
$packageRoot = Join-Path $temp $rootName
New-Item -ItemType Directory -Path $packageRoot | Out-Null
$dllPath = Get-ChildItem ".\bin\Release" -Recurse -Filter "Flow.Launcher.Plugin.SpeedTest.dll" | Select-Object -First 1
Copy-Item $dllPath.FullName $packageRoot -Force
Copy-Item ".\plugin.json" $packageRoot -Force
Copy-Item ".\icon-light.png" $packageRoot -Force
Copy-Item ".\icon-dark.png" $packageRoot -Force
if (Test-Path $zip) { Remove-Item $zip -Force }
Compress-Archive -Path "$temp\*" -DestinationPath $zip -Force
Remove-Item $temp -Recurse -Force
Write-Host "Package ready: $zip" -ForegroundColor Green
}
elseif ($Install) {
Write-Host "Installing..." -ForegroundColor Yellow
$flowProc = Get-Process "Flow.Launcher" -ErrorAction SilentlyContinue
if ($flowProc) {
Write-Host "Stopping Flow Launcher (PID: $($flowProc.Id))..." -ForegroundColor Yellow
taskkill /PID $flowProc.Id /F /T 2>&1 | Out-Null
Start-Sleep 3
}
$rootName = "Speed Test-$Version"
$installPath = Join-Path $pluginsDir $rootName
if (Test-Path $installPath) {
Remove-Item $installPath -Recurse -Force -ErrorAction SilentlyContinue
}
New-Item -ItemType Directory -Path $installPath -Force | Out-Null
$dllPath = Get-ChildItem ".\bin\Release" -Recurse -Filter "Flow.Launcher.Plugin.SpeedTest.dll" | Select-Object -First 1
Copy-Item $dllPath.FullName $installPath -Force
Copy-Item ".\plugin.json" $installPath -Force
if (Test-Path ".\icon-light.png") { Copy-Item ".\icon-light.png" $installPath -Force }
if (Test-Path ".\icon-dark.png") { Copy-Item ".\icon-dark.png" $installPath -Force }
Write-Host "Installed to $installPath" -ForegroundColor Green
$flowPath = "$env:LOCALAPPDATA\FlowLauncher\Flow.Launcher.exe"
if (Test-Path $flowPath) {
Write-Host "Starting Flow Launcher..." -ForegroundColor Yellow
Start-Process $flowPath
Write-Host "Flow Launcher started" -ForegroundColor Green
} else {
Write-Host "Flow Launcher executable not found at $flowPath" -ForegroundColor Yellow
Write-Host "Please start Flow Launcher manually" -ForegroundColor Cyan
}
}