Files
lobehub__lobehub/apps/desktop/scripts/update-test/setup.sh
Innei 9cb0560ebf ✨ feat(desktop): unified update channel switching with S3 distribution (#12644)
* ✨ feat(desktop): add update channel settings for desktop app

* 🔧 chore(desktop): update test scripts for multi-channel update flow

- Support stable/nightly/canary channel structure in generate-manifest.sh
- Add --all-channels flag for generating manifests across all channels
- Dual-mode run-test.sh: packaged (full updater) and --dev (UI only)
- Fix package:mac:local to skip signing for local builds
- Document Squirrel.Mac signature validation limitation

* 🔧 chore(desktop): update local app update configuration

- Change provider from GitHub to Generic for local testing.
- Update local server URL and cache directory settings.
- Revise comments for clarity on usage and configuration.

Signed-off-by: Innei <tukon479@gmail.com>

* 🐛 fix(desktop): fix update channel switch race condition and downgrade flag

- P1: Use generation counter to discard stale check results when channel
  is switched mid-flight. Pending recheck is scheduled after current check
  completes instead of forcing concurrent checks.
- P2: Explicitly reset allowDowngrade=false on non-downgrade transitions
  to prevent stale downgrade permission from persisting.
- Fix GitHub fallback repo name (lobe-chat -> lobehub).

* 🔧 chore(settings): remove dynamic import for Beta component from componentMap

- Eliminated the dynamic import for the Beta settings tab, streamlining the component map.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore(settings): simplify UpdateChannel component structure

- Refactored the UpdateChannel component to streamline the Select component usage by removing unnecessary nested children.

Signed-off-by: Innei <tukon479@gmail.com>

* update

* 🐛 fix(desktop): strip channel suffix from UPDATE_SERVER_URL before appending channel

The UPDATE_SERVER_URL secret may already contain a channel path (e.g., /stable).
Previously, the code unconditionally appended /{channel}, resulting in double
paths like /stable/stable/stable-mac.yml.

Now both electron-builder.mjs and UpdaterManager strip any trailing channel
suffix before re-appending the correct channel, supporting both legacy URLs
(with channel) and clean base URLs.

* update

* update

* redesign ui

- Added `getUpdaterState` method to `UpdaterManager` for retrieving current update status.
- Introduced `UpdaterState` type to encapsulate update progress, stage, and error messages.
- Updated UI components to reflect update states, including checking, downloading, and latest version notifications.
- Enhanced menu items for macOS and Windows to display appropriate update statuses.
- Localized new update messages in English and Chinese.

This improves user experience by providing real-time feedback during the update process.

Signed-off-by: Innei <tukon479@gmail.com>

* Enhance UpdaterManager tests and mock implementations

- Updated tests for UpdaterManager to reflect changes in broadcasting update states, including 'checking', 'downloading', and 'error' stages.
- Modified mock implementations in macOS and Windows test files to include `getUpdaterState` and `installNow` methods for better state management.
- Improved test coverage for update availability and download processes.

These changes ensure more accurate testing of the update flow and enhance the overall reliability of the UpdaterManager functionality.

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-03-05 15:15:03 +08:00

90 lines
2.5 KiB
Bash
Executable File
Raw Permalink 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.
#!/bin/bash
# ============================================
# 本地更新测试 - 一键设置脚本
# ============================================
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SERVER_DIR="$SCRIPT_DIR/server"
echo "🚀 设置本地更新测试环境..."
# 创建服务器目录(含三个渠道子目录)
mkdir -p "$SERVER_DIR/stable"
mkdir -p "$SERVER_DIR/nightly"
mkdir -p "$SERVER_DIR/canary"
echo "✅ 创建服务器目录: $SERVER_DIR/{stable,nightly,canary}"
# 设置脚本执行权限
chmod +x "$SCRIPT_DIR"/*.sh
echo "✅ 设置脚本执行权限"
# 检查是否安装了 serve
if ! command -v npx &> /dev/null; then
echo "❌ 需要安装 Node.js 和 npm"
exit 1
fi
# 为三个渠道创建示例 manifest
for ch in stable nightly canary; do
cat > "$SERVER_DIR/$ch/$ch-mac.yml" << EOF
version: 99.0.0
files:
- url: LobeHub-99.0.0-arm64.dmg
sha512: placeholder-sha512-will-be-replaced
size: 100000000
- url: LobeHub-99.0.0-arm64-mac.zip
sha512: placeholder-sha512-will-be-replaced
size: 100000000
path: LobeHub-99.0.0-arm64.dmg
sha512: placeholder-sha512-will-be-replaced
releaseDate: '2026-01-15T10:00:00.000Z'
releaseNotes: |
## v99.0.0 本地测试版本 ($ch)
这是 $ch 渠道的模拟版本。
EOF
echo "✅ 创建示例 $ch/$ch-mac.yml"
done
# 创建本地测试用的 dev-app-update.yml
cat > "$SCRIPT_DIR/dev-app-update.local.yml" << 'EOF'
# 本地更新测试配置
# 将此文件复制到 apps/desktop/dev-app-update.yml 以使用本地服务器测试
#
# 注意: 此配置仅用于应用初始启动时的 provider 配置。
# Channel 切换功能通过 UPDATE_SERVER_URL 环境变量 + setFeedURL() 实现,
# 不依赖此文件。
#
# 使用方法:
# cp scripts/update-test/dev-app-update.local.yml dev-app-update.yml
# UPDATE_SERVER_URL=http://localhost:8787 bun run dev
provider: generic
url: http://localhost:8787/stable
updaterCacheDirName: lobehub-desktop-local-test
channel: stable
EOF
echo "✅ 创建本地测试配置文件"
echo ""
echo "============================================"
echo "✅ 设置完成!"
echo "============================================"
echo ""
echo "下一步操作:"
echo ""
echo "1. 构建测试包 (需产出 DMG + ZIP):"
echo " cd $(dirname "$SCRIPT_DIR")"
echo " bun run package:mac:local"
echo ""
echo "2. 生成真实的 manifest (从构建产物):"
echo " cd scripts/update-test"
echo " ./generate-manifest.sh --from-release --all-channels"
echo ""
echo "3. 或者直接一键测试:"
echo " ./run-test.sh"
echo ""