prebuild.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const packageJson = require("./package.json");
  2. if (packageJson.dependencies.iview !== "^3.5.4") {
  3. console.log("iview 的版本不要轻易升级,一定要充分测试。");
  4. process.exit(1);
  5. }
  6. console.log("> prebuild");
  7. console.log("> prebuild create .env.*.local");
  8. const buildDate = require("moment")().format("YYYY-MM-DD HH:mm:ss");
  9. console.log(" 构建日期为 " + buildDate);
  10. const revision = require("child_process")
  11. .execSync("git rev-parse HEAD")
  12. .toString()
  13. .trim()
  14. .slice(0, 7);
  15. const fs = require("fs");
  16. console.log(" 当前的git版本为 " + revision);
  17. fs.writeFileSync(
  18. ".env.development.local",
  19. "\nVUE_APP_GIT_REPO_VERSION=开发环境-" + buildDate + " - " + revision
  20. );
  21. fs.writeFileSync(
  22. ".env.test.local",
  23. "VUE_APP_GIT_REPO_VERSION=测试环境(阿里云)-" + buildDate + " - " + revision
  24. );
  25. fs.writeFileSync(
  26. ".env.staging.local",
  27. "VUE_APP_GIT_REPO_VERSION=灰度环境-" + buildDate + " - " + revision
  28. );
  29. fs.writeFileSync(
  30. ".env.production.local",
  31. "VUE_APP_GIT_REPO_VERSION=" + buildDate + " - " + revision
  32. );
  33. console.log();