From 0086af7f4e926107f2b8c41fa33c4fdb4a7d64c0 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 24 Jul 2026 12:35:33 +0000 Subject: [PATCH] =?UTF-8?q?fix(pack-update):=20=E6=B6=88=E9=99=A4=20bindOk?= =?UTF-8?q?=20=E9=87=8D=E5=A4=8D=20enabled=20=E5=B9=B6=E6=94=B6=E6=95=9B?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=94=B6=E5=B0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main@baff02a 合并冲突在 probeSourceAfterInstall 的 bindOk 参数里留下两个 enabled,触发 TS1117,ootb Build 失败。删除重复键,以 binding.enabled (经 makeBindingFromHit)为唯一权威;bindingEnabledLabel / sources 列表 共用 packs.list.on|off。httpDownload 在无 Content-Length 时补最终进度回调。 Co-authored-by: Shiroha --- bds-tools/src/http.ts | 7 +++++-- sfmc/src/pack-update/service.ts | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bds-tools/src/http.ts b/bds-tools/src/http.ts index 13c6e7d2..c615e523 100644 --- a/bds-tools/src/http.ts +++ b/bds-tools/src/http.ts @@ -221,8 +221,11 @@ export async function httpDownload( try { const finalBytes = statSync(destPath).size; // 收尾:确保最后一次回调让进度条走到 100%(即便最近 - // 一个 tick 的节流没触发,也补一次) - if (opts.onProgress && total) opts.onProgress(finalBytes, total); + // 一个 tick 的节流没触发,也补一次)。 + // 无 Content-Length(total=0)时用 finalBytes 作总量,与中途「仍回调」契约一致(LSP)。 + if (opts.onProgress) { + opts.onProgress(finalBytes, total > 0 ? total : finalBytes); + } resolve(finalBytes); } catch (e) { reject(e as Error); diff --git a/sfmc/src/pack-update/service.ts b/sfmc/src/pack-update/service.ts index c6151cea..2482d2a4 100644 --- a/sfmc/src/pack-update/service.ts +++ b/sfmc/src/pack-update/service.ts @@ -57,8 +57,9 @@ function fmtVer(v: SemVer3): string { return v.join("."); } +/** 启停文案:与 packs list / sources 共用 i18n(DRY;勿再写死 on/off) */ function bindingEnabledLabel(enabled: boolean): string { - return enabled ? "on" : "off"; + return enabled ? t("packs.list.on").trim() : t("packs.list.off").trim(); } /** 未配置源时的统一文案(DRY:入口勿各自拼 needKey) */ @@ -230,9 +231,9 @@ export async function probeSourceAfterInstall(opts: { uuid: opts.info.uuid, provider: providerShortLabel(best.hit.provider), slug: best.hit.slug, + /* 以 binding.enabled 为准(makeBindingFromHit 已吃 defaultBindingEnabled — LSP) */ enabled: bindingEnabledLabel(binding.enabled), path: packSourcesPath(), - enabled: cfg.defaultBindingEnabled ? t("packs.list.on").trim() : t("packs.list.off").trim(), }), "success" ); @@ -302,7 +303,8 @@ export function formatSourcesList(): string { return lines.join("\n"); } for (const { bpUuid, binding } of bindings) { - const en = binding.enabled ? c.green(t("packs.list.on").trim()) : c.dim(t("packs.list.off").trim()); + const label = bindingEnabledLabel(binding.enabled); + const en = binding.enabled ? c.green(label) : c.dim(label); const tag = providerShortLabel(binding.provider); lines.push( ` [${en}] ${bpUuid} ${tag}:${binding.slug || binding.projectId} ${c.dim(binding.websiteUrl || "")}`