const ch = require("child_process");

const packages = ["backend-cli", "events", "pc-components", "utils"];

packages.forEach((name) => {
  if (!["backend-cli", "events"].includes(name)) {
    console.log(`********  build package: ${name} ************`);
    ch.execSync(`pnpm -r --filter=${name} run build `, { stdio: "inherit" });
  }

  console.log(`========  publish package: ${name} ============`);
  try {
    ch.execSync(
      `pnpm -r --filter=${name} publish --registry http://192.168.20.245:4873/ --no-git-checks`,
      { stdio: "inherit" }
    );
  } catch (err) {}
});
