Files
yinx-cli/lib/plugins/gltf/index.js
2025-12-22 15:01:10 +08:00

41 lines
1.1 KiB
JavaScript

import color from "picocolors";
import { createStepUI } from "../../utils/stepui.js";
import { title, getSteps } from "./config.js";
import { stopKeypress, waitForKey } from "../../keyboard.js";
import { runGltfExtension } from "./service.js";
const run = async () => {
const ui = createStepUI({ title, getSteps });
const result = await ui.runInteractive();
if (!result) return "back";
stopKeypress();
const config = {
files: result.results[0] || [],
extensions: result.results[1] || []
};
ui.showSummary([
"处理文件: " + (config.files.length ? config.files.join(", ") : "未选择"),
"扩展选项: " + (config.extensions.length ? config.extensions.join(", ") : "未选择")
]);
const { success, count, error } = runGltfExtension(config);
if (error) {
console.log(color.red("\n✖ " + error));
} else if (success) {
console.log(color.green("\n✓ 已修改 " + count + " 个 glTF 文件"));
}
await waitForKey();
return "back";
};
export default {
id: "gltf",
name: "glTF扩展",
desc: "添加KTX2纹理扩展",
run,
};