fix(scripts): final review Critical+Important fixes (Widget alignment, full readLayerXml, Label _string, atlas selection, hard-coded paths, exit code, dead code removal)

This commit is contained in:
2026-09-02 09:11:51 +08:00
parent 7e0a8b79a4
commit cb3bd54175
19 changed files with 5076 additions and 186 deletions
@@ -1,6 +1,6 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { resolveSpriteFrameUuid } from '../../scripts/legacy-layer-to-cocos-prefab.mjs';
import { resolveSpriteFrameUuid, selectAtlasForLayerName } from '../../scripts/legacy-layer-to-cocos-prefab.mjs';
// 数据源权威: gameabc_Image.json id=20 -> bmp="00020.png" 位于 atlas-login/,
// 该 .meta 的 subMetas.f9941.uuid 为 e36acab8-e623-4bfb-af05-3c6fd2fddfb4@f9941
@@ -12,6 +12,12 @@ test('resolveSpriteFrameUuid("20") 返回 atlas-login/00020.png 的 SpriteFrame
assert.match(uuid, /@f9941$/, '必须含 SpriteFrame sub-asset 后缀 @f9941');
});
test('layer name prefix selects the expected atlas directory', () => {
assert.equal(selectAtlasForLayerName('Login_Layer'), 'atlas-login');
assert.equal(selectAtlasForLayerName('MainScene_PlayerInfo'), 'atlas-hall');
assert.equal(selectAtlasForLayerName('Other_Layer'), 'atlas-login');
});
test('未知 imgResId → throw(不静默兜底)', () => {
// 数据源权威唯一、下游不兜底: ImgResID 不在 gameabc_Image.json 时必须显式报错.
assert.throws(