Skip to content

Commit bcbb5e3

Browse files
cursoragentTanya7z
andcommitted
fix(bds-tools): 修复 scanDestOccupancy 合并冲突导致的 --dts 失败
#80/#81 合入时 scanDestOccupancy 保留了 facts 外壳却残留未声明的 uuid/version/name 赋值,changeset-release/ootb 的 tsc7 --dts 挂掉; 运行时 ReferenceError 被 catch 吞掉会使占用 uuid 恒空。 改为 facts = readPackDirOccupancy(dir)(DRY),补 scan 单测; 清理已写入 pre.json 的残留 changeset 文件,避免与 pending 混淆。 Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
1 parent 85ae1b5 commit bcbb5e3

5 files changed

Lines changed: 24 additions & 25 deletions

File tree

‎.changeset/align-release-token-dry.md‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎.changeset/bds-log-filter-solid.md‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎.changeset/build-deps-world-packs-solid.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"@sfmc-bds/bds-tools": patch
44
---
55

6-
发版:build-publishable 拓扑 + listPublishableBuildDeps(npm-publish 应急补发不再硬编码只 build SDK);push 缺失态 DRY 对齐 listUnpushedExistingVersionTags。世界包:readPackDirOccupancy DRY,去掉死不变式,occupancy 保留真实 kind(LSP)。
6+
发版:build-publishable 拓扑 + listPublishableBuildDeps(npm-publish 应急补发不再硬编码只 build SDK);push 缺失态 DRY 对齐 listUnpushedExistingVersionTags。世界包:readPackDirOccupancy DRY,去掉死不变式,occupancy 保留真实 kind(LSP)。修 #80/#81 合并冲突:scanDestOccupancy 须赋值 facts=readPackDirOccupancy,禁止残留未声明 uuid/version/name 赋值(否则 --dts 挂掉且 catch 吞掉 ReferenceError 导致占用 uuid 恒空)。

‎bds-tools/src/world-packs.ts‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ export type PackInstallPlan =
566566

567567
/**
568568
* 读单目录占用事实(info 优先,否则 header)。
569-
* Utf8BomError 上抛,由调用方决定跳过或仍占文件夹名。
569+
* 读失败上抛,由调用方决定跳过或仍占文件夹名(uuid 置空)。
570570
*/
571571
export function readPackDirOccupancy(dir: string): {
572572
uuid: string;
@@ -596,18 +596,8 @@ export function scanDestOccupancy(destParent: string): DestOccupancy[] {
596596
for (const dir of listPackDirsIn(destParent)) {
597597
let facts: ReturnType<typeof readPackDirOccupancy> = null;
598598
try {
599-
const info = readPackManifestInfo(dir);
600-
if (info) {
601-
uuid = info.uuid;
602-
version = info.version;
603-
name = info.name;
604-
} else {
605-
const header = readPackManifestHeader(dir);
606-
if (header) {
607-
uuid = header.uuid;
608-
version = header.version;
609-
}
610-
}
599+
// DRY:单目录占用只走 readPackDirOccupancy,禁止再内联一份 info/header 分支
600+
facts = readPackDirOccupancy(dir);
611601
} catch {
612602
/* manifest 不可读则占位 uuid 为空 */
613603
}

‎bds-tools/world-packs.test.mjs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,26 @@ describe("world-packs primitives", () => {
283283
assert.deepEqual(version, [2, 0, 1]);
284284
});
285285

286+
it("scanDestOccupancy 走 readPackDirOccupancy(含 kind)", async () => {
287+
const { scanDestOccupancy } = await import("./dist/world-packs.js");
288+
const parent = path.join(tmp, "occupancy-scan");
289+
const dir = path.join(parent, "[BP] Occ");
290+
const uuid = "cccccccc-cccc-cccc-cccc-cccccccccccc";
291+
writeManifest(dir, {
292+
name: "OccPack",
293+
uuid,
294+
version: [2, 3, 4],
295+
type: "data",
296+
});
297+
const rows = scanDestOccupancy(parent);
298+
assert.equal(rows.length, 1);
299+
assert.equal(rows[0].folderName, "[BP] Occ");
300+
assert.equal(rows[0].uuid, uuid);
301+
assert.deepEqual(rows[0].version, [2, 3, 4]);
302+
assert.equal(rows[0].name, "OccPack");
303+
assert.equal(rows[0].kind, "behavior");
304+
});
305+
286306
it("decidePackInstallPlan 表驱动", async () => {
287307
const { decidePackInstallPlan, formatWorldPackFolderName } = await import("./dist/world-packs.js");
288308
const uuidA = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa";

0 commit comments

Comments
 (0)