From 2052d0554b69c840399e0a87dd53bf8373409cf0 Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Thu, 3 Sep 2026 12:02:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(e2e):=20=E8=81=9A=E5=90=88=20lane=20?= =?UTF-8?q?=E6=8C=89=20mtime=20=E5=8F=96=E6=9C=80=E6=96=B0=20tarball=20?= =?UTF-8?q?=E5=B9=B6=E7=BB=9F=E4=B8=80=20DSH=5FCMD=20=E7=BC=BA=E7=9C=81?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit e2e-aggregate-mount.sh 选 tarball 用字典序 `ls | head -1`,仓库根堆积 多个历史 tgz 时会把冒烟挂到过期产物上——完整移植 e2e-mount.sh 的 mtime 策略与多 tarball 告警。DSH_CMD 缺省从直连 npx 统一为「PATH dsh 优先、npx 回退」(CI 传 DSH_CMD=dsh 不受影响)。 顺带修一个移植中暴露的边角:候选计数行在零候选时因 pipefail+set -e 静默退出,吞掉下一行的友好报错——补 `|| true`(mount.sh 同步修复)。 --- scripts/e2e-aggregate-mount.sh | 23 +++++++++++++++++++---- scripts/e2e-mount.sh | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/scripts/e2e-aggregate-mount.sh b/scripts/e2e-aggregate-mount.sh index 5af92b1..1e61555 100755 --- a/scripts/e2e-aggregate-mount.sh +++ b/scripts/e2e-aggregate-mount.sh @@ -20,8 +20,8 @@ # bash scripts/e2e-aggregate-mount.sh # # 环境变量(均可省略): -# DSH_CMD dsh 命令;缺省 `npx -y --package @deepseek-ai/dsh dsh` -# (与 pm2 启动器同源,避免依赖可能失效的 PATH dsh) +# DSH_CMD dsh 命令;缺省 PATH 上的 `dsh`,回退 npx 拉官方包 +# (同 e2e-mount.sh) # TARBALL 插件 tarball;缺省仓库根 dsh-better-sidebar-*.tgz(须已 pack) # PORT 固定端口(默认 0 = OS 分配,从日志解析 URL) # DSH_HOME_BASE scratch 根目录(默认系统临时目录)。脚本始终在其下新建 @@ -37,7 +37,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" FIXTURE_DIR="$ROOT/tests/fixtures/aggregate-better-sidebar" -DSH_CMD="${DSH_CMD:-npx -y --package @deepseek-ai/dsh dsh}" +DSH_CMD="${DSH_CMD:-dsh}" TARBALL="${TARBALL:-}" PORT="${PORT:-0}" KEEP_HOME="${KEEP_HOME:-}" @@ -51,8 +51,23 @@ command -v pnpm >/dev/null 2>&1 || die "未找到 pnpm(dsh plugin 转发给 pn command -v npm >/dev/null 2>&1 || die "未找到 npm(打包 fixture 需要)" command -v curl >/dev/null 2>&1 || die "未找到 curl" +# dsh CLI 解析:PATH 上的 dsh 优先,否则 npx 拉官方包(同 scripts/install.sh +# 与 e2e-mount.sh) +if ! command -v "$DSH_CMD" >/dev/null 2>&1; then + if command -v npx >/dev/null 2>&1; then + say "PATH 上无 ${DSH_CMD},回退 npx -y --package @deepseek-ai/dsh" + DSH_CMD="npx -y --package @deepseek-ai/dsh dsh" + else + die "未找到 $DSH_CMD 或 npx;请先安装 DSH CLI(npm i -g @deepseek-ai/dsh)或用 DSH_CMD 指定" + fi +fi + +# tarball 解析(多个候选时取 mtime 最新——`ls | head -1` 的字典序会拿到 +# 旧版本号的历史 tarball,把冒烟挂到过期产物上;同 e2e-mount.sh) if [ -z "$TARBALL" ]; then - TARBALL="$(ls "$ROOT"/dsh-better-sidebar-*.tgz 2>/dev/null | head -1 || true)" + TARBALL="$(ls -t "$ROOT"/dsh-better-sidebar-*.tgz 2>/dev/null | head -1 || true)" + COUNT="$(ls "$ROOT"/dsh-better-sidebar-*.tgz 2>/dev/null | wc -l | tr -d ' ' || true)" + [ "$COUNT" -le 1 ] || warn "发现 $COUNT 个 tarball,按 mtime 选用最新:$(basename "$TARBALL")(建议清理其余)" fi [ -n "$TARBALL" ] && [ -f "$TARBALL" ] || die "未找到插件 tarball:先在本仓库跑 pnpm build && npm pack,或用 TARBALL 指定" diff --git a/scripts/e2e-mount.sh b/scripts/e2e-mount.sh index ce38249..475615a 100755 --- a/scripts/e2e-mount.sh +++ b/scripts/e2e-mount.sh @@ -55,7 +55,7 @@ fi # 旧版本号的历史 tarball,把冒烟挂到过期产物上) if [ -z "$TARBALL" ]; then TARBALL="$(ls -t "$ROOT"/dsh-better-sidebar-*.tgz 2>/dev/null | head -1 || true)" - COUNT="$(ls "$ROOT"/dsh-better-sidebar-*.tgz 2>/dev/null | wc -l | tr -d ' ')" + COUNT="$(ls "$ROOT"/dsh-better-sidebar-*.tgz 2>/dev/null | wc -l | tr -d ' ' || true)" [ "$COUNT" -le 1 ] || warn "发现 $COUNT 个 tarball,按 mtime 选用最新:$(basename "$TARBALL")(建议清理其余)" fi [ -n "$TARBALL" ] && [ -f "$TARBALL" ] || die "找不到 tarball(TARBALL 或 \$ROOT/dsh-better-sidebar-*.tgz)——先运行 pnpm build && pnpm pack"