// const packageJson = require("./package.json");

// if (packageJson.dependencies.iview !== "^3.4.1") {
//   console.log("iview 的版本不要轻易升级，一定要充分测试。");
//   process.exit(1);
// }

console.log("> prebuild");
console.log("> prebuild create .env.production.local");

const buildDate = require("moment")().format("YYYY-MM-DD HH:mm:SS");
console.log("  构建日期为 " + buildDate);

const revision = require("child_process")
  .execSync("git rev-parse HEAD")
  .toString()
  .trim()
  .slice(0, 7);
const fs = require("fs");
console.log("  当前的git版本为 " + revision);

fs.writeFileSync(
  ".env.production.local",
  "VUE_APP_GIT_REPO_VERSION=" + buildDate + " - " + revision
);

fs.writeFileSync(
  ".env.staging.local",
  "VUE_APP_GIT_REPO_VERSION=" + buildDate + " - " + revision
);

console.log();
