import path from "path";
import { onDeleteFile } from "./utils/utils";
import buildLib from "./utils/buildLib";
import buildAll from "./utils/buildAll";
import { createIndexJS } from "./utils/handleIndexJS";

const outputDirPath = path.resolve(__dirname, "../lib");
const compDirPath = path.resolve(__dirname, "../src/components");
const entryPath = path.resolve(__dirname, "../src/index.ts");

const init = async () => {
  //自动生成入口文件
  await createIndexJS(entryPath, compDirPath);
  //全量打包，支持全量引入
  await buildAll(entryPath, outputDirPath);
  //局部打包，支持按需引入
  await buildLib(compDirPath, outputDirPath);
  //自动删除入口文件
  await onDeleteFile(entryPath);
};

init();
