Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

build(ci): 打包与 CI 覆盖 island 产物

longmeidao27405d0ab7c1
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 302c9d0d8..cf21339da 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -18,6 +18,17 @@ updates:
timezone: Asia/Taipei
open-pull-requests-limit: 10
+ # frontend/ 有自己的 manifest:根 package.json 只登记手工 vendor 的四个包,
+ # island 层的构建依赖不能混进去(tests/test_dependency_policy.py 卡着那份清单)。
+ - package-ecosystem: npm
+ directory: /frontend
+ schedule:
+ interval: weekly
+ day: monday
+ time: "09:20"
+ timezone: Asia/Taipei
+ open-pull-requests-limit: 10
+
- package-ecosystem: github-actions
directory: /
schedule:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 394cb5ee8..767488657 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -69,6 +69,32 @@ jobs:
shell: bash
run: ./scripts/test.sh
+ web-bundle:
+ name: island 产物与前端测试
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ - uses: actions/setup-node@v7
+ with:
+ node-version: "24"
+ cache: npm
+ cache-dependency-path: frontend/package-lock.json
+ - run: npm --prefix frontend ci
+ - run: npm --prefix frontend run typecheck
+ - run: npm --prefix frontend test
+ - run: npm --prefix frontend run build
+ # 产物提交进 Git,因为运行时和打包都没有 Node(ADR-0022)。一旦源码改了却忘了
+ # 重新构建并提交,服务端发出去的就还是旧 island——本地跑测试也看不出来,只有
+ # 在这里比一次才拦得住。
+ #
+ # 先 `git add -N`:光 `git diff` 只看已跟踪的文件,构建新出的产物(某个 island
+ # 开始带自己的 CSS 就会多一份 peach-ui.css)是未跟踪的,那条门槛会直接放过去。
+ - name: 核对 web/dist 与源码一致
+ run: |
+ git add --intent-to-add -- web/dist
+ git diff --exit-code -- web/dist
+ - run: npm --prefix frontend audit --audit-level=high
+
web-vendor:
name: 固定前端依赖
runs-on: ubuntu-latest
diff --git a/scripts/build_macos_app.py b/scripts/build_macos_app.py
index d565a760a..0d2944af9 100644
--- a/scripts/build_macos_app.py
+++ b/scripts/build_macos_app.py
@@ -16,6 +16,7 @@ import argparse
import plistlib
import shutil
import stat
+import subprocess
import sys
from pathlib import Path
@@ -80,6 +81,25 @@ def build(destination: Path, tray: Path) -> Path:
return app
+def build_island_bundle() -> None:
+ """重建 `web/dist/` 里的 island 产物(ADR-0022)。
+
+ 这个 .app 外壳本身不打包 `web/`:它只踢 LaunchAgent,托盘从仓库检出里取页面。
+ 但那份检出就是 macOS 用户真正跑的东西,所以出包前仍要把产物重建一遍——运行时
+ 没有 Node,产物只能在这一步生成。npm 不在就直接失败:宁可停在这里,也不要拿
+ 工作区里恰好存在的旧 bundle 冒充这一次的构建结果。
+ """
+ npm = shutil.which("npm")
+ if npm is None:
+ raise SystemExit("找不到 npm:island 产物(frontend/)出包前必须重建,请先装 Node 24+")
+ frontend = PROJECT_ROOT / "frontend"
+ subprocess.run([npm, "--prefix", str(frontend), "ci"], check=True)
+ subprocess.run([npm, "--prefix", str(frontend), "run", "build"], check=True)
+ bundle = PROJECT_ROOT / "web" / "dist" / "peach-ui.js"
+ if not bundle.is_file():
+ raise SystemExit(f"构建之后仍然没有 {bundle}")
+
+
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description="生成 macOS 菜单栏项的 .app 外壳")
parser.add_argument("--destination", type=Path, default=PROJECT_ROOT / "dist")
@@ -90,6 +110,7 @@ def build_parser() -> argparse.ArgumentParser:
def run(args: argparse.Namespace) -> int:
if not args.tray.is_file():
raise SystemExit(f"找不到 peach-tray:{args.tray}(先 pip install -e .)")
+ build_island_bundle()
args.destination.mkdir(parents=True, exist_ok=True)
app = build(args.destination, args.tray)
print(f"已生成 {app}")
diff --git a/scripts/build_windows.ps1 b/scripts/build_windows.ps1
index 023c6b844..2d6c132d7 100644
--- a/scripts/build_windows.ps1
+++ b/scripts/build_windows.ps1
@@ -24,6 +24,22 @@ if (-not (Test-Path -LiteralPath (Join-Path $ProjectRoot 'resources\peach.ico')
throw 'Brand assets are missing. Run scripts/generate_brand_assets.py first.'
}
+# The island bundle ships inside `--add-data web;web` and the runtime has no Node, so it
+# must be rebuilt here: web/dist is committed to Git, but packaging reads the working tree,
+# and a stale bundle would be shipped without any signal. See ADR-0022.
+$FrontendPath = Join-Path $ProjectRoot 'frontend'
+$Npm = Get-Command npm -ErrorAction SilentlyContinue
+if (-not $Npm) {
+ throw 'npm not found. The island bundle (frontend/) must be rebuilt before packaging; install Node 24+.'
+}
+& $Npm.Source --prefix $FrontendPath ci
+if ($LASTEXITCODE -ne 0) { throw 'npm ci failed in frontend/.' }
+& $Npm.Source --prefix $FrontendPath run build
+if ($LASTEXITCODE -ne 0) { throw 'Island bundle build failed (frontend/).' }
+if (-not (Test-Path -LiteralPath (Join-Path $ProjectRoot 'web\dist\peach-ui.js') -PathType Leaf)) {
+ throw 'web/dist/peach-ui.js is missing after the frontend build.'
+}
+
$BuildPath = Join-Path $ProjectRoot 'build\windows'
New-Item -ItemType Directory -Path $OutputPath -Force | Out-Null
& $Python -m PyInstaller --noconfirm --clean --onefile --windowed --name Peach `