Files
arcrun-collector/cmd/arcrun-app/build-win.sh
T
Leo 9cd0adab22 G-6.2:讀不了的檔案不再安靜消失——首頁當場說出來
服務 J-1 / S6「我丟進去的檔案,查得到」的考題 G-6.2:
「要嘛查得到,要嘛**當場被告知這種檔案還不支援**,不准安靜地略過。」
本次只做後半句(轉檔本體另有人閘,等 leo 裁「那段 Go 住哪裡」)。

## 真實現況比記載更糟
t16 寫的「PDF 被靜默略過」已不成立(t73 的轉檔層把 pdf/docx/xlsx/csv/pptx
都接上了,實測 2 頁中文 PDF 完整抽出)。**真正還在沉默的是別的東西**:
副檔名不在 allowedExt 的檔案在 scan.go 直接 `return nil`——
不進事件、不進 manifest、不進 status、不進畫面。
使用者丟一份 .doc 進去,從頭到尾一個字都沒有。

實測基線(真檔):丟 .pdf/.md/.doc/.key/.jpg 進資料夾,
`collector scan` 只吐出 pdf 與 md 兩個事件,另外三個檔沒留下任何痕跡。

## 改了什麼
- scan.go:白名單閘不再是死巷。像文件的(.doc/.xls/.ppt/.pages/.key/
  .numbers/.odt/.ods/.odp/.rtf/.epub/.wpd/.msg/.eml)逐檔留名;
  其餘(圖片/影音/程式碼)只計總數——**避免 Obsidian 附件庫炸出幾百行噪音**。
- 兩個新欄位標 `json:"-"`:collector-trigger schema 是
  additionalProperties:false,且 BuildSendablePayload 是淺拷貝
  ⇒ 有 tag 就會漏到雲端被擋。這是給本機使用者看的,不上 wire。
- direct.go → status.json → App 首頁一張卡:講檔名與格式(「舊版報告.doc
  (舊版 Word)」),並告訴他不用重丟、也給替代路(另存成 PDF/.docx)。
- 刻意不進 manifest、不走 CarryForwardActivity:每輪由檔案系統重算,
  不製造 t195 那種「跨輪欄位漏 carry 就靜默歸零」的債。

## 順手修掉一個會讓驗收失效的回歸
同綑的 arcrun-collector 一路自稱 `dev`:退役 fyne 版
(arcrun-tray/build-mac.sh:24,t150/t72)本來就有版本注入,
t194 換 Wails 時沒帶過來,Mac 與 Windows 兩邊都掉。
**幹活的是 collector**——它不報版本,就沒人能判斷修復有沒有到使用者手上。

## 實測
- go test ./... 135 過 0 敗(新增 10 條:scan 5+首頁文案 5)
- check-cis / check-render / check-tray 三閘全過;淺色深色都抓過畫面
- 從 **DMG 裡那支** collector 實跑:Info.plist 0.18.6、
  collector 回報 v0.18.6 (build 20260806-0101)、
  status.json 吐出 skipped_docs=[簡報.key, 舊版報告.doc]、other=1

⚠️ 未出貨:推 bundles repo 在 GitHub,要 leo 開 D20 閘。
DMG 已備妥 dist/Arcrun-v0.18.6.dmg。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 01:04:25 +08:00

80 lines
3.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# build-win.sh — 打包 Arcrun Windows 版(Wailst1962026-08-05
#
# leo 08-05:「Windows 版一定要重編,因為我只有 Mac,我需要人家測試,
# 要做到最完善不要給人家找麻煩」
#
# 🎯 **在 Mac 上就能交叉編譯**,不需要 Windows 機器/Docker。
# 條件只有一個:`brew install mingw-w64`(提供 x86_64-w64-mingw32-gcc)。
# Wails 的 Windows 版要 CGoWebView2 綁定),所以 CGO_ENABLED=1 + mingw。
#
# 與 build-mac.sh 同一個要點:**必須把 collector 同綑進去**。
# daemon 的本體是 `collector direct`(監看/萃卡/上傳),App 只是門面;
# 沒同綑 ⇒ 使用者裝了也不會同步(t194 在 Mac 版就漏過一次)。
#
# ⚠️ 誠實界定(沿用 build-windows.sh 的自陳):
# 本腳本只證明「**編得出來**」,不證明「**跑起來對**」。
# 托盤圖示會不會出現、WebView2 有沒有裝、SmartScreen 攔截行為,
# **只有真的在 Windows 上跑才驗得到**——那一步歸 leo/封測者真機。
set -euo pipefail
cd "$(dirname "$0")"
export PATH="$PATH:$(go env GOPATH)/bin"
VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo dev)}"
BUILD_TIME="$(date '+%Y%m%d-%H%M')"
echo "🏷 版本:${VERSION}build ${BUILD_TIME}"
command -v x86_64-w64-mingw32-gcc >/dev/null 2>&1 || {
echo "❌ 缺 mingw-w64Wails Windows 版需要 CGo 交叉編譯器)"
echo " 裝一次就好:brew install mingw-w64"
exit 1
}
echo "① 編 collector.exe(同綑執行檔,純 stdlib、CGO_ENABLED=0"
# 🔴 2026-08-06:同 build-mac.sh 補回版本注入(Wails 換代時掉的,理由見該檔註解)。
# 2b83c47 當年就修過一次「Mac 有、Windows 漏了」——換代後兩邊又一起掉,這次一起補。
( cd ../.. && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 \
go build -ldflags "-s -w -X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}" \
-o "cmd/arcrun-app/arcrun-collector.exe" . )
# 🔴 同 build-mac.shwails.json 沒 info.productVersion ⇒ exe 內容資訊永遠是 1.0.0。
# Windows 使用者在「內容→詳細資料」看到的版本讀這個欄位;MSIX 送審也會對照。
PLIST_VER="${VERSION#v}"
cp wails.json wails.json.bak
python3 - "$PLIST_VER" <<'PY'
import json, sys
c = json.load(open('wails.json'))
c.setdefault('info', {})
c['info']['productVersion'] = sys.argv[1]
c['info']['productName'] = 'Arcrun'
json.dump(c, open('wails.json', 'w'), indent=2, ensure_ascii=False)
PY
trap 'mv -f wails.json.bak wails.json 2>/dev/null || true' EXIT
echo "② wails buildwindows/amd64CGo 走 mingw"
CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc \
wails build -platform windows/amd64 -clean \
-ldflags "-X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}"
OUT="dist"; mkdir -p "$OUT"
STAGE="$(mktemp -d)/Arcrun"
mkdir -p "$STAGE"
echo "③ 同綑 collector.exeApp 用 os.Executable() 找同層,見 supervise.go"
cp build/bin/arcrun-app.exe "$STAGE/Arcrun.exe"
cp arcrun-collector.exe "$STAGE/arcrun-collector.exe"
echo "④ 打包 zip"
# 用絕對路徑:下面會 cd 進暫存目錄打包,相對路徑會找不到(實撞:zip I/O error)。
ZIP="$(cd "$OUT" && pwd)/ArcrunRAG-win-unsigned-${VERSION}.zip"
rm -f "$ZIP"
( cd "$(dirname "$STAGE")" && zip -qr "$ZIP" "Arcrun" )
rm -rf "$(dirname "$STAGE")"
SIZE=$(ls -lh "$ZIP" | awk '{print $5}')
echo "✅ 完成:${ZIP}${SIZE}"
echo
echo "🔬 使用者流程:解壓縮 → 執行 Arcrun.exe"
echo " ⚠️ 未簽章 ⇒ SmartScreen 會攔(「更多資訊」→「仍要執行」)。"
echo " 要免除這一步=上 MS Store(見 build-msix.sh)或買 EV 憑證。"