Files
lobehub__lobehub/apps/desktop/scripts/update-test/start-server.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

78 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# ============================================
# 启动本地更新服务器
# ============================================
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SERVER_DIR="$SCRIPT_DIR/server"
PID_FILE="$SCRIPT_DIR/.server.pid"
LOG_FILE="$SCRIPT_DIR/.server.log"
PORT="${PORT:-8787}"
# 检查服务器目录
if [ ! -d "$SERVER_DIR" ]; then
echo "❌ 服务器目录不存在,请先运行 ./setup.sh"
exit 1
fi
# 检查是否已经在运行
if [ -f "$PID_FILE" ]; then
OLD_PID=$(cat "$PID_FILE")
if ps -p "$OLD_PID" > /dev/null 2>&1; then
echo "⚠️ 服务器已经在运行 (PID: $OLD_PID)"
echo " 地址: http://localhost:$PORT"
echo ""
echo " 如需重启,请先运行 ./stop-server.sh"
exit 0
else
rm -f "$PID_FILE"
fi
fi
echo "🚀 启动本地更新服务器..."
echo " 目录: $SERVER_DIR"
echo " 端口: $PORT"
echo ""
# 列出可用渠道
echo "📦 可用渠道:"
for ch_dir in "$SERVER_DIR"/*/; do
if [ -d "$ch_dir" ]; then
ch=$(basename "$ch_dir")
manifest="$ch_dir/$ch-mac.yml"
if [ -f "$manifest" ]; then
ver=$(grep '^version:' "$manifest" | awk '{print $2}')
echo " $ch -> v$ver (http://localhost:$PORT/$ch/$ch-mac.yml)"
else
echo " $ch -> (no manifest)"
fi
fi
done
echo ""
# 启动服务器 (后台运行)
cd "$SERVER_DIR"
nohup npx serve -p "$PORT" --cors -n > "$LOG_FILE" 2>&1 &
SERVER_PID=$!
echo "$SERVER_PID" > "$PID_FILE"
# 等待服务器启动
sleep 2
# 检查是否启动成功
if ps -p "$SERVER_PID" > /dev/null 2>&1; then
echo "✅ 服务器已启动!"
echo ""
echo " 地址: http://localhost:$PORT"
echo " PID: $SERVER_PID"
echo " 日志: $LOG_FILE"
echo ""
echo "🛑 停止服务器: ./stop-server.sh"
else
echo "❌ 服务器启动失败"
echo " 查看日志: cat $LOG_FILE"
rm -f "$PID_FILE"
exit 1
fi