import color from "picocolors";
import { projectTypes } from "./config.js";
import { gridSelect, createScaffoldUI, formatResults, waitKey } from "./ui.js";

export async function run() {
  while (true) {
    // 二级菜单 - 项目类型
    const typeResult = await gridSelect(projectTypes, "项目脚手架 - 选择类型");
    if (typeResult.action === "back") return "back";

    const projectType = typeResult.item.name;

    // 三级页面 - 框架+组件配置（合并）
    const ui = createScaffoldUI(projectType);
    const result = await ui.runInteractive();

    if (result) {
      const summary = formatResults(result.steps, result.results);
      ui.showSummary(summary);
      console.log(color.yellow("功能开发中，敬请期待..."));
      await waitKey();
    }
  }
}
