forked from router-for-me/EasyCLIProxyAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy.ps1
More file actions
42 lines (33 loc) · 1.33 KB
/
Copy pathcopy.ps1
File metadata and controls
42 lines (33 loc) · 1.33 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
[CmdletBinding()]
param()
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$RootDir = $PSScriptRoot
$AppBin = Join-Path $RootDir 'src-tauri\target\release\cpa-gui.exe'
$BinDir = Join-Path $RootDir 'bin-work'
$BinOut = Join-Path $BinDir 'EasyCLIProxyAPI.exe'
$PortableScript = Join-Path $RootDir 'scripts\portable.mjs'
Set-Location -LiteralPath $RootDir
if (-not (Get-Command bun -ErrorAction SilentlyContinue)) {
throw 'bun is not installed or not in PATH.'
}
if (-not (Test-Path -LiteralPath $AppBin -PathType Leaf)) {
throw "Executable not found: $AppBin. Run .\build.ps1 first."
}
& bun $PortableScript --binary $AppBin --output $BinDir --download true --preserve-runtime-config true
if ($LASTEXITCODE -ne 0) {
throw "Portable preparation failed with exit code $LASTEXITCODE."
}
if (-not (Test-Path -LiteralPath $BinOut -PathType Leaf)) {
throw "Portable preparation finished, but executable not found: $BinOut"
}
$CoreOut = Join-Path $BinDir 'cpa-core'
$CoreArchives = @(
Get-ChildItem -LiteralPath $CoreOut -File |
Where-Object { $_.Name -match '^CLIProxyAPI_.+_windows_.+\.zip$' }
)
if ($CoreArchives.Count -ne 1) {
throw "Portable core output must contain exactly one Windows core archive: $CoreOut"
}
Write-Host "Copied: $BinOut"
Write-Host "Bundled core archive: $($CoreArchives[0].FullName)"