feat(scripts): PoC 阶段 1 - CLI + Layer00619 BackHall 端到端跑通
- scripts/legacy-layer-to-cocos-prefab-cli.mjs (CLI 入口: <inputXml> [<youlePrefab>] <outputDir>) - framework-tests/legacy-layer-migration/poc-iconbutton.test.mjs (1 个 node:test 端到端校验 cc.Prefab 头 + group-55 父节点) - YouleNexus/out/legacy-migration/BackHall_Layer.prefab (生成产物, 437 lines) - YouleNexus/out/legacy-migration/BackHall_Layer.prefab.diff (vs YouleNexus Layer619_BackOtherGame.prefab, 1244 lines) 累计: 30/30 PASS (29 prior + 1 PoC). Layer00619 (1 Spirit, type=3 ProgressBar, group=55) 是最简 PoC, diff 大是预期 (脚本首个端到端输出 vs 手写 prefab 必然差异大). Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
|
||||
// PoC 阶段 1 端到端: Layer00619 BackHall_Layer (1 Spirit, type=3 ProgressBar) →
|
||||
// prefab JSON + (diff, if any) → 关键字段校验.
|
||||
//
|
||||
// 注: 原 brief 建议 IconButton, 但 IconButton 无对应 Layer; spec 改用 BackHall_Layer
|
||||
// 作为最简 1-Spirit PoC. Target YouleNexus prefab 不存在时 CLI 仅生成 prefab, 不报错.
|
||||
//
|
||||
// 路径从 cocoscreator_projects/ 运行 (与其他 legacy-layer-migration 测试一致).
|
||||
const CLI = 'node scripts/legacy-layer-to-cocos-prefab-cli.mjs';
|
||||
const INPUT = '../projects/Game_Surface_3/save/Layer00619.xml';
|
||||
const TARGET = 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer619_BackOtherGame.prefab';
|
||||
const OUTPUT_DIR = 'YouleNexus/out/legacy-migration/';
|
||||
const OUTPUT = 'YouleNexus/out/legacy-migration/BackHall_Layer.prefab';
|
||||
|
||||
test('Layer00619 端到端生成 + 校验关键字段', () => {
|
||||
execSync(`${CLI} ${INPUT} ${TARGET} ${OUTPUT_DIR}`, { stdio: 'pipe' });
|
||||
|
||||
assert.ok(existsSync(OUTPUT), `${OUTPUT} 应生成`);
|
||||
const json = JSON.parse(readFileSync(OUTPUT, 'utf8'));
|
||||
assert.ok(Array.isArray(json));
|
||||
assert.equal(json[0].__type__, 'cc.Prefab');
|
||||
assert.equal(json[0]._name, 'BackHall_Layer');
|
||||
|
||||
// 校验含 group-55 父节点 (BackHall_Layer.xml Spirit BelongGroupID=55).
|
||||
const groupNode = json.find(o => o.__type__ === 'cc.Node' && o._name === 'group-55');
|
||||
assert.ok(groupNode, '应有 group-55 父节点');
|
||||
});
|
||||
Reference in New Issue
Block a user