Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bds-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
},
"dependencies": {
"@sfmc-bds/sdk": "^0.1.0",
"cli-progress": "^3.12.0",
"jszip": "^3.10.1",
"node-html-parser": "^9.0.0"
},
Expand Down
8 changes: 2 additions & 6 deletions bds-tools/src/check-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
createLogger,
createStdoutSink,
createTerminalProgress,
formatDownloadSpeed,
} from "@sfmc-bds/sdk/logs";
import fs from "node:fs";
import os from "node:os";
Expand Down Expand Up @@ -317,12 +318,7 @@ export async function runUpdate(): Promise<number> {
const timeDelta = (now - lastTime) / 1000; // 秒
const bytesDelta = dl - lastLoaded;
const speed = timeDelta > 0 ? bytesDelta / timeDelta : 0;
const speedStr =
speed > 1024 * 1024
? `${(speed / 1024 / 1024).toFixed(1)} MB/s`
: speed > 1024
? `${(speed / 1024).toFixed(1)} KB/s`
: `${speed.toFixed(0)} B/s`;
const speedStr = formatDownloadSpeed(speed);
const totalMb = total > 0 ? total / (1024 * 1024) : 0;
const dlMb = dl / (1024 * 1024);
const pct = total > 0 ? (dl / total) * 100 : 0;
Expand Down
2 changes: 1 addition & 1 deletion bds-tools/src/pack-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* 的一部分内嵌起来,而 SEA 是个单 exe (除 Node 内置 + bds-tools 已有依赖外)。
*
* 已有依赖 (bds-tools/package.json):
* - cli-progress: 进度条
* - @sfmc-bds/sdk/logs createTerminalProgress: 进度条(BDS 更新等)
* - node-html-parser: changelog 抓取 (本文件用不到)
* - jszip: zip 解压(模块 zip / BDS server.zip),与 sfmc/wizard 共享同一个库
*
Expand Down
2 changes: 0 additions & 2 deletions configs-default/pack-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
"pageSize": 10,
"preferredReleaseTypes": ["release", "beta", "alpha"],
"match": {
"byUuidInArchive": true,
"byName": true,
"nameMinScore": 0.6,
"stripFolderTags": true
}
Expand Down
3 changes: 1 addition & 2 deletions docs/guide/pack-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ flowchart TD
"pageSize": 10,
"preferredReleaseTypes": ["release", "beta", "alpha"],
"match": {
"byUuidInArchive": true,
"byName": true,
"nameMinScore": 0.6,
"stripFolderTags": true
}
Expand Down Expand Up @@ -129,6 +127,7 @@ flowchart TD
| `baseUrl` | 官方 Core API:getMod / files / download-url。 |
| `searchBaseUrl` | 搜索镜像;官方 search 403 时回退。 |
| `nameMinScore` | 安装后自动绑定的最低相似度阈值。 |
| `stripFolderTags` | 清洗时是否去掉方括号标签(如 `[BP]`/`[玩法]`)。 |

### 3.4 绑定文件示例

Expand Down
1 change: 1 addition & 0 deletions modules/sdk/@sfmc-sdk/src/logs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export {
resumeAllProgress,
withProgressPaused,
hasActiveProgress,
formatDownloadSpeed,
} from "./terminal-progress.js";
export type {
TerminalProgressOptions,
Expand Down
8 changes: 8 additions & 0 deletions modules/sdk/@sfmc-sdk/src/logs/terminal-progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ function isWritableTty(stream: NodeJS.WritableStream): boolean {
return !!(stream as WriteStream).isTTY;
}

/** 下载速度文案(BDS / CF 等共用,避免各处复制阈值分支) */
export function formatDownloadSpeed(bytesPerSec: number): string {
const speed = Number.isFinite(bytesPerSec) ? Math.max(0, bytesPerSec) : 0;
if (speed > 1024 * 1024) return `${(speed / 1024 / 1024).toFixed(1)} MB/s`;
if (speed > 1024) return `${(speed / 1024).toFixed(1)} KB/s`;
return `${speed.toFixed(0)} B/s`;
}

function renderBarLine(
value: number,
total: number,
Expand Down
69 changes: 1 addition & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading