feat: 完善远程构建恢复、工程同步与变体选择

增加持久化构建记录、历史 APK 恢复、断点下载、Gradle 缓存复用、系统代理与按工程选择服务端 JDK。

支持已有工程目录、Git 状态检查、原生忽略规则和文本换行等价比较,修复干净检出与历史同步快照不一致时的误拦截。

优化插件设备可选构建、侧栏滚动、左右日志布局、时间显示和构建变体快速选择,并补充部署与协议文档。

验证:17 项 Go 测试、22 项插件测试及 HTTP/HTTPS 两条端到端测试通过;Linux/macOS 服务端交叉编译通过。
This commit is contained in:
tongtong committed 2026-11-25 02:10:52 +08:00
1 parent 2203afde3c
commit 2cb70beb69
44 files changed
+3310 -236

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
param([string]$OutputPath=(Join-Path $PWD 'build-environment.json'))
$ErrorActionPreference='Stop'
$gradle=$env:GRADLE_HOME
if(-not $gradle){$command=Get-Command gradle.bat -ErrorAction SilentlyContinue;if($command){$gradle=Split-Path (Split-Path $command.Source)}}
$cache=$env:GRADLE_USER_HOME
if(-not $cache -and $gradle){$folder=[IO.DirectoryInfo]$gradle;while($folder){if(Test-Path -LiteralPath (Join-Path $folder.FullName 'caches\modules-2')){$cache=$folder.FullName;break};$folder=$folder.Parent}}
if(-not $cache){$cache=Join-Path $env:USERPROFILE '.gradle'}
$sdk=$env:ANDROID_HOME;if(-not $sdk){$sdk=$env:ANDROID_SDK_ROOT}
$proxy='';$source=''
foreach($name in @('HTTPS_PROXY','HTTP_PROXY')){$value=[Environment]::GetEnvironmentVariable($name);if($value){$proxy=$value;$source=$name;break}}
if(-not $proxy){$url=[uri]'https://services.gradle.org';$system=[Net.WebRequest]::GetSystemWebProxy();if(-not $system.IsBypassed($url)){$proxy=$system.GetProxy($url).AbsoluteUri;$source='windows-interactive-user-system'}}
$safeProxy=''
if($proxy){
$parsed=[uri]$proxy
if($parsed.UserInfo){throw 'Authenticated proxy detected. No credentials or configuration were saved. Use an unauthenticated local proxy.'}
if($parsed.Scheme -notin @('http','https') -or -not $parsed.Host){throw 'Unsupported proxy configuration; nothing saved.'}
# Persist only protocol, host and port; discard any query, fragment or path.
$safeProxy=('{0}://{1}:{2}' -f $parsed.Scheme,$parsed.DnsSafeHost,$parsed.Port)
}
$config=@{gradleHome=$gradle;gradleUserHome=$cache;javaHome=$env:JAVA_HOME;androidHome=$sdk;proxy=$safeProxy;proxySource=$source}
if(-not $config.javaHome){$config.Remove('javaHome')};if(-not $config.androidHome){$config.Remove('androidHome')}
[IO.File]::WriteAllText($OutputPath,($config | ConvertTo-Json),(New-Object Text.UTF8Encoding($false)))
Write-Output "Captured current user tool/cache/proxy settings to $OutputPath (no token)."
+35
View File
@@ -0,0 +1,35 @@
param([string]$Root='C:\ProgramData\VibeCodingRemoteCompilation',[string]$EnvironmentFile=(Join-Path $PSScriptRoot 'build-environment.json'),[switch]$GrantCacheAccess)
$ErrorActionPreference='Stop'
$markers=@(Get-ChildItem -LiteralPath "$Root\data\projects" -Directory -ErrorAction SilentlyContinue | ForEach-Object {Get-Item -LiteralPath (Join-Path $_.FullName 'active-build') -ErrorAction SilentlyContinue})
if($markers.Count){Write-Output 'Active build IDs (not stopped):';$markers | ForEach-Object{Get-Content -LiteralPath $_.FullName};throw 'Wait for active builds; this upgrade never cancels them automatically.'}
$configPath="$Root\bin\RemoteCompileService.xml"
[xml]$config=Get-Content -LiteralPath $configPath -Raw
$next=Join-Path $PSScriptRoot 'remotecompile-windows-amd64.exe'
if(-not(Test-Path -LiteralPath $next)){throw 'New binary missing'}
if(-not(Test-Path -LiteralPath $EnvironmentFile)){throw 'Capture build-environment.json from the intended developer account first'}
$environment=Get-Content -LiteralPath $EnvironmentFile -Raw | ConvertFrom-Json
if(-not $environment.gradleUserHome){throw 'Gradle cache path required'}
New-Item -ItemType Directory -Force -Path $environment.gradleUserHome | Out-Null
# Traverse parent directories, grant writes only to the explicitly selected Gradle cache.
if($GrantCacheAccess){
$parent=Split-Path $environment.gradleUserHome
while($parent -and $parent -ne [IO.Path]::GetPathRoot($parent)){
& icacls.exe $parent /grant '*S-1-5-19:(X)' | Out-Null
if($LASTEXITCODE -ne 0){throw "Cannot grant cache path traversal: $parent"}
$parent=Split-Path $parent
}
& icacls.exe $environment.gradleUserHome /grant '*S-1-5-19:(OI)(CI)M' | Out-Null
if($LASTEXITCODE -ne 0){throw 'Cannot grant selected Gradle cache permission'}
}
Stop-Service RemoteCompile
(Get-Service RemoteCompile).WaitForStatus('Stopped',[TimeSpan]::FromSeconds(45))
Copy-Item -LiteralPath "$Root\bin\remotecompile.exe" -Destination "$Root\bin\remotecompile.before-0.2.0.exe" -Force
Copy-Item -LiteralPath $configPath -Destination "$configPath.before-0.2.0.xml" -Force
Copy-Item -LiteralPath $next -Destination "$Root\bin\remotecompile.exe" -Force
$destination="$Root\build-environment.json"
Copy-Item -LiteralPath $EnvironmentFile -Destination $destination -Force
$config.service.arguments=([string]$config.service.arguments -replace '\s+-environment-file\s+"[^"]*"','')+" -environment-file `"$destination`""
[IO.File]::WriteAllText($configPath,$config.OuterXml,(New-Object Text.UTF8Encoding($false)))
Start-Service RemoteCompile
Get-Service RemoteCompile | Select-Object Name,Status
Write-Output 'Updated service. Verify HTTPS health and /api/v1/environment with the existing token and certificate.'