From 8e1e56b3e5dca3cea1fe5d2e0052fdcc7d4ee62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com> Date: Mon, 5 Oct 2026 00:35:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96:=20=E6=89=93=E5=8C=85?= =?UTF-8?q?=E6=8F=90=E9=80=9F=E4=B8=8E=E6=8D=A2=E8=A3=85=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Cargo.toml release profile 开 incremental(小改动重打包显著提速,正式发版在意体积可临时注释) - 新增 scripts/package-devflow.ps1 双通道打包脚本:verify 快速编译验证/full 全量发版换装,含磁盘预检与启动验证 --- Cargo.toml | 5 +++ scripts/package-devflow.ps1 | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 scripts/package-devflow.ps1 diff --git a/Cargo.toml b/Cargo.toml index d118248..6fb35a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,3 +26,8 @@ keyring = { version = "3", features = ["windows-native", "apple-native", "linux- # ConvState 提到 ConvStateStore(DashMap),guard.reset/ai_is_generating 不依赖 session lock, # 治卡死连环(AiCompleted 延迟/工具后中断/第二条进队列同源根因)。详见 workflow session-lock-redesign。 dashmap = "6" + +# release 增量编译:小改动重打包显著提速(2026-10-04 打包提速项); +# 代价为产物略大,正式发版如在意体积可临时注释此段 +[profile.release] +incremental = true diff --git a/scripts/package-devflow.ps1 b/scripts/package-devflow.ps1 new file mode 100644 index 0000000..fda3ca6 --- /dev/null +++ b/scripts/package-devflow.ps1 @@ -0,0 +1,62 @@ +# 用途: devflow 打包换装双通道脚本(verify=快速编译验证 / full=全量发版换装) +# 生命周期: 长期保留(挂机模式打包组件的雏形,接力棒 M1 落地后由其接管安装段) +# 用法: .\scripts\package-devflow.ps1 -Mode verify # 只验 release 编译,分钟级 +# .\scripts\package-devflow.ps1 -Mode full # tauri build -> 杀进程 -> /S 静默装 -> 启动验证 +param( + [ValidateSet("verify", "full")] + [string]$Mode = "verify" +) + +$ErrorActionPreference = "Continue" +$repo = "E:\wk-lab\devflow" +$exe = "$env:LOCALAPPDATA\devflow\devflow.exe" +$minFreeGB = 10 + +Set-Location $repo + +function Get-FreeGB($path) { + $drive = (Get-Item $path).PSDrive + return [math]::Round($drive.Free / 1GB, 1) +} + +$free = Get-FreeGB $repo +if ($free -lt $minFreeGB) { + Write-Host "[预检失败] E 盘剩余 ${free}GB < ${minFreeGB}GB,先清 target\debug\incremental(历史教训 os error 112)" + exit 1 +} +Write-Host "[预检] E 盘剩余 ${free}GB,通过" + +if ($Mode -eq "verify") { + Write-Host "== 通道1: 快速编译验证(cargo build --release,不打安装包) ==" + cmd /c "cargo build --release 2>&1" + if ($LASTEXITCODE -ne 0) { Write-Host "[失败] 编译未过"; exit 1 } + Write-Host "[通过] release 编译成功(未打安装包)" + exit 0 +} + +Write-Host "== 通道2: 全量发版换装(tauri build -> 静默安装 -> 启动验证) ==" +Write-Host "[1/4] tauri build(可能 10 分钟级)..." +cmd /c "cargo tauri build 2>&1" +if ($LASTEXITCODE -ne 0) { Write-Host "[失败] tauri build"; exit 1 } + +$bundle = Get-ChildItem "$repo\target\release\bundle\nsis\*.exe" | Sort-Object LastWriteTime -Descending | Select-Object -First 1 +if (-not $bundle) { Write-Host "[失败] 未找到安装包产物"; exit 1 } +Write-Host "[2/4] 安装包: $($bundle.Name) ($([math]::Round($bundle.Length/1MB,1))MB, $($bundle.LastWriteTime))" + +Write-Host "[3/4] 杀旧进程 -> 静默安装..." +Get-Process devflow -ErrorAction SilentlyContinue | Stop-Process -Force +Start-Sleep -Seconds 2 +Start-Process $bundle.FullName -ArgumentList "/S" -Wait + +if (-not (Test-Path $exe)) { Write-Host "[失败] 安装后未找到 $exe"; exit 1 } +$exeTime = (Get-Item $exe).LastWriteTime +Write-Host "[4/4] 启动验证(装机 exe 时间: $exeTime)..." +Start-Process $exe +Start-Sleep -Seconds 6 +$proc = Get-Process devflow -ErrorAction SilentlyContinue +if ($proc) { + Write-Host "[换装成功] PID $($proc.Id) 存活,装机时间 $exeTime" +} else { + Write-Host "[警告] 启动后 6 秒未见进程,请人工确认(可能仍在初始化)" + exit 1 +}