This commit is contained in:
Alvin-Zilverstand committed 2026-11-19 11:43:36 +01:00
1 parent 0d3e076115
commit 8e27e174a7
15 files changed
+161 -26

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
param([switch]$ShowSigningPassword)
$ErrorActionPreference = 'Stop'
$projectRoot = Split-Path -Parent $PSScriptRoot
$androidSdk = Join-Path $env:LOCALAPPDATA 'Android\Sdk'
$javaHome = 'C:\Program Files\Android\Android Studio\jbr'
$keytool = Join-Path $javaHome 'bin\keytool.exe'
$signingDir = Join-Path $env:USERPROFILE '.android'
$storePath = Join-Path $signingDir 'litellm-dashboard-upload.jks'
$secretPath = Join-Path $signingDir 'litellm-dashboard-upload.password.dpapi'
$alias = 'litellm-dashboard-upload'
if (-not (Test-Path -LiteralPath $keytool)) { throw "Android Studio JDK not found at $javaHome" }
if (-not (Test-Path -LiteralPath $androidSdk)) { throw "Android SDK not found at $androidSdk" }
New-Item -ItemType Directory -Path $signingDir -Force | Out-Null
$hasStore = Test-Path -LiteralPath $storePath
$hasSecret = Test-Path -LiteralPath $secretPath
if ($hasStore -xor $hasSecret) {
throw 'Only one signing file exists. Restore the missing keystore or password file before building; do not generate a replacement key for an existing app.'
}
if (-not $hasStore) {
$random = [System.Security.Cryptography.RandomNumberGenerator]::GetBytes(36)
$password = [Convert]::ToBase64String($random).TrimEnd('=').Replace('+', '-').Replace('/', '_')
& $keytool -genkeypair -keystore $storePath -storetype PKCS12 -alias $alias -keyalg RSA -keysize 3072 -validity 10000 -storepass $password -keypass $password -dname 'CN=LiteLLM Dashboard'
if ($LASTEXITCODE -ne 0) { throw 'Key generation failed.' }
$password | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Set-Content -LiteralPath $secretPath -NoNewline
Write-Host "Created local release key at $storePath"
}
$securePassword = Get-Content -LiteralPath $secretPath -Raw | ConvertTo-SecureString
$pointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePassword)
try { $password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($pointer) }
finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($pointer) }
if ($ShowSigningPassword) {
Write-Host 'Signing password (back up securely, then clear your terminal):'
Write-Output $password
exit 0
}
$env:JAVA_HOME = $javaHome
$env:ANDROID_HOME = $androidSdk
$env:LITELLM_RELEASE_STORE_FILE = $storePath
$env:LITELLM_RELEASE_STORE_PASSWORD = $password
$env:LITELLM_RELEASE_KEY_ALIAS = $alias
$env:LITELLM_RELEASE_KEY_PASSWORD = $password
try {
Push-Location $projectRoot
try {
& .\gradlew.bat :app:assembleRelease :app:bundleRelease --no-daemon
if ($LASTEXITCODE -ne 0) { throw "Release build failed with exit code $LASTEXITCODE" }
} finally { Pop-Location }
} finally {
Remove-Item Env:LITELLM_RELEASE_STORE_FILE,Env:LITELLM_RELEASE_STORE_PASSWORD,Env:LITELLM_RELEASE_KEY_ALIAS,Env:LITELLM_RELEASE_KEY_PASSWORD -ErrorAction SilentlyContinue
$password = $null
}
Write-Host 'Signed release APK: app\build\outputs\apk\release\app-release.apk'
Write-Host 'Signed release AAB: app\build\outputs\bundle\release\app-release.aab'
+2 -1
View File
@@ -31,7 +31,8 @@ class Handler(BaseHTTPRequestHandler):
"/key/list": {"keys": [{"key_alias": "Production", "token": "hashed-token", "user_id": "alvin", "team_id": "core", "spend": 42.12, "max_budget": 100, "blocked": False}]},
"/team/list": [{"team_alias": "Core", "team_id": "core", "spend": 98.45, "max_budget": 250, "members": ["alvin", "sam"]}],
"/global/spend": {"spend": 234.56},
"/global/activity": {"total_requests": 1234, "successful_requests": 1221},
"/global/activity": {"sum_api_requests": 1234, "daily_data": [{"date": "2026-11-17", "api_requests": 12}, {"date": "2026-11-18", "api_requests": 18}]},
"/gateway/daily/activity": {"total_successful_requests": 1221, "total_failed_requests": 13, "by_date": [{"date": "2026-11-17", "successful_requests": 11, "failed_requests": 1}, {"date": "2026-11-18", "successful_requests": 18, "failed_requests": 0}]},
"/global/spend/report": [{"group_by_day": "2026-11-17T00:00:00+00:00", "total_spend": 4.5}, {"group_by_day": "2026-11-18T00:00:00+00:00", "total_spend": 7.9}],
"/spend/logs/v2": {"data": [{"request_id": f"req-{page}", "model": "gpt-4o", "startTime": "2026-11-19T08:00:00", "status": "success", "spend": 0.024, "total_tokens": 945, "team_id": "core"}], "total": 31, "page": page, "page_size": 30},
}