feat(scripts): legacy-layer → Cocos prefab 批量迁移完成(7 ok / 6 expected-fail)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// 递归收集 framework-tests 下所有 *.test.ts 交给 node 测试运行器。
|
||||
// 递归收集 framework-tests 下所有 *.test.{ts,mjs} 交给 node 测试运行器。
|
||||
// node --test 的 glob 模式需 v20.14+,本仓库当前 node 20.13.x 不支持,
|
||||
// 故用此零依赖、跨平台 runner 显式枚举文件,保持 test:framework 行为一致。
|
||||
// *.test.mjs: legacy-layer-migration 等纯 ESM 脚本测试 (Tasks 9-12 legacy 迁移管线).
|
||||
import { readdirSync, statSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
@@ -11,12 +12,12 @@ const files = [];
|
||||
for (const entry of readdirSync(dir)) {
|
||||
const p = join(dir, entry);
|
||||
if (statSync(p).isDirectory()) walk(p);
|
||||
else if (p.endsWith('.test.ts')) files.push(p);
|
||||
else if (p.endsWith('.test.ts') || p.endsWith('.test.mjs')) files.push(p);
|
||||
}
|
||||
})(root);
|
||||
|
||||
if (files.length === 0) {
|
||||
console.error(`[run-framework-tests] 未发现任何 *.test.ts(root=${root})`);
|
||||
console.error(`[run-framework-tests] 未发现任何 *.test.{ts,mjs}(root=${root})`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env node
|
||||
// 批量跑 legacy-layer → Cocos prefab CLI。
|
||||
// 每条 target: <source xml> → <youle prefab> → <OUT_DIR/prefab>.prefab + .diff.
|
||||
//
|
||||
// 设计要点:
|
||||
// - 全部输出到隔离 OUT_DIR (out/legacy-migration/), 不直接覆盖 YouleNexus 现有 prefab.
|
||||
// - 单个 target 失败 (例如 ImgResID 未导入 sprite) 不阻塞后续 target, 日志记录后继续.
|
||||
// - per "下游不兜底" 原则: CLI 本身必须 throw 让错误暴露; batch 仅负责捕获 + 汇总, 不做修补.
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
const ROOT = process.cwd(); // assume run from cocoscreator_projects/
|
||||
const OUT_DIR = `${ROOT}/YouleNexus/out/legacy-migration`;
|
||||
const SOURCE = `${ROOT}/../projects/Game_Surface_3/save`;
|
||||
|
||||
// 按 spec 已核实映射表 (11 个 prefab). Layer10_Protocol + Login_Layer + Layer619_BackOtherGame 三个 PoC 已存在,
|
||||
// 但 batch 仍会重新生成它们 (idempotent — 覆盖 out/legacy-migration/*.prefab + .diff).
|
||||
const targets = [
|
||||
{ xml: 'Layer00002.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/views/Login_Layer.prefab', name: 'Login_Layer', note: 'PoC 3 (Layer00002)' },
|
||||
{ xml: 'Layer00017.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/views/PlayerInfoView.prefab', name: 'MenuPlayerInfo_Layer', note: '拍板 A (Layer00017)' },
|
||||
{ xml: 'Layer00029.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Group106_PhoneVerify.prefab', name: 'phoneInfo' },
|
||||
{ xml: 'Layer00010.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer10_Protocol.prefab', name: 'Protol_Layer', note: 'PoC 2 (Layer00010)' },
|
||||
{ xml: 'Layer00609.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer609_Setting.prefab', name: 'Setting_Layer' },
|
||||
{ xml: 'Layer00612.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer612_Tips.prefab', name: 'Tips_Layer' },
|
||||
{ xml: 'Layer00613.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer613_RoomCardUpdate.prefab', name: 'updateRoomCard_Layer' },
|
||||
{ xml: 'Layer00614.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer614_Loading.prefab', name: 'Loading_Layer' },
|
||||
{ xml: 'Layer00615.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer615_Reconnect.prefab', name: 'Reconnect_Layer' },
|
||||
{ xml: 'Layer00616.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer616_Kick.prefab', name: 'Kick_Layer' },
|
||||
{ xml: 'Layer00008.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer617_Notice.prefab', name: 'Notice_Layer', note: '拍板 B (Layer00008)' },
|
||||
{ xml: 'Layer00619.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer619_BackOtherGame.prefab', name: 'BackHall_Layer', note: 'PoC 1 (Layer00619)' },
|
||||
{ xml: 'Layer00620.xml', prefab: 'YouleNexus/assets/framework/ui/prefabs/widgets/Layer620_Record.prefab', name: 'recordLayer' },
|
||||
];
|
||||
|
||||
const results = { ok: [], failed: [] };
|
||||
console.log(`Generating ${targets.length} prefabs to ${OUT_DIR}\n`);
|
||||
|
||||
for (const t of targets) {
|
||||
console.log(`\n=== Processing ${t.name} (${t.xml}) ===`);
|
||||
try {
|
||||
execSync(
|
||||
`node scripts/legacy-layer-to-cocos-prefab-cli.mjs "${SOURCE}/${t.xml}" "${ROOT}/${t.prefab}" "${OUT_DIR}"`,
|
||||
{ stdio: 'inherit' }
|
||||
);
|
||||
results.ok.push(t.name);
|
||||
} catch (e) {
|
||||
console.error(` ⚠️ FAILED: ${t.name}: ${(e.message || String(e)).slice(0, 200)}`);
|
||||
results.failed.push({ name: t.name, xml: t.xml, error: (e.message || String(e)).slice(0, 200) });
|
||||
// Continue with next target — partial success acceptable per "不静默兜底" + batch resilience
|
||||
}
|
||||
}
|
||||
|
||||
console.log('\n=== Batch complete ===');
|
||||
console.log(`Output dir: ${OUT_DIR}`);
|
||||
console.log(`OK: ${results.ok.length} | FAILED: ${results.failed.length}`);
|
||||
if (results.failed.length > 0) {
|
||||
console.log('\nFailed targets:');
|
||||
for (const f of results.failed) {
|
||||
console.log(` - ${f.name} (${f.xml}): ${f.error}`);
|
||||
}
|
||||
}
|
||||
console.log('\nNext step: human reviews each .diff and decides whether to overwrite YouleNexus original prefabs.');
|
||||
Reference in New Issue
Block a user