import { writeFileSync, existsSync } from "fs"; import { execSync } from "child_process"; import moment from "moment"; import packageJson from "./package.json" assert { type: "json" }; console.log("> prebuild"); console.log("> prebuild create .env.*.local"); // const packageJson = require("./package.json"); const buildDate = moment().format("YYYY-MM-DD HH:mm:ss"); console.log(" 构建日期为 " + buildDate); // eslint-disable-next-line @typescript-eslint/no-unsafe-call const revision = execSync("git rev-parse HEAD").toString().trim().slice(0, 7); console.log(" 当前的git版本为 " + revision); // eslint-disable-next-line @typescript-eslint/no-unsafe-call writeFileSync( ".env.production.local", `VITE_FE_VERSION=${packageJson.version} VITE_BUILD_DATE=${buildDate} VITE_GIT_REPO_VERSION=${revision} ` ); // 如果不存在则创建,对真正的构建无影响 if (!existsSync("./src/devLoginParams.ts")) { writeFileSync( "./src/devLoginParams.ts", ` export const isAdmin = false; export let forceChange = false; forceChange = true; // 很多任务,选分组2 export const loginName = ""; export const password = ""; export const examId = ""; export const markerId = ""; ` ); } console.log();