Przeglądaj źródła

发布版本管理

Michael Wang 3 lat temu
rodzic
commit
97a3d68097
4 zmienionych plików z 55 dodań i 18 usunięć
  1. 6 1
      .eslintrc.js
  2. 20 16
      index.html
  3. 2 1
      package.json
  4. 27 0
      prebuild.mjs

+ 6 - 1
.eslintrc.js

@@ -42,7 +42,12 @@ module.exports = {
     "vue/v-on-event-hyphenation": ["error", "never", { autofix: true }],
     "vue/no-v-html": "off",
   },
-  ignorePatterns: [".eslintrc.js", "vite.config.ts", "src/test"],
+  ignorePatterns: [
+    ".eslintrc.js",
+    "vite.config.ts",
+    "src/test",
+    "prebuild.mjs",
+  ],
   overrides: [
     {
       files: ["src/**/**.vue"],

+ 20 - 16
index.html

@@ -1,18 +1,22 @@
 <!DOCTYPE html>
 <html lang="en">
-  <head>
-    <meta charset="UTF-8" />
-    <link rel="icon" href="/favicon.ico" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>云阅卷</title>
-  </head>
-  <body>
-    <div id="app"></div>
-    <script>
-      window.APP_OPTIONS = {
-        OBJECT_URLS_MAP_MAX_SIZE: undefined,
-      };
-    </script>
-    <script type="module" src="/src/main.ts"></script>
-  </body>
-</html>
+
+<head>
+  <meta charset="UTF-8" />
+  <link rel="icon" href="/favicon.ico" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+  <title>云阅卷</title>
+</head>
+
+<body>
+  <div id="app"></div>
+  <script>
+    console.log(`前端版本:import.meta.env.VITE_FE_VERSION 构建时间:import.meta.env.VITE_BUILD_DATE  代码版本: import.meta.env.VITE_GIT_REPO_VERSION`)
+    window.APP_OPTIONS = {
+      OBJECT_URLS_MAP_MAX_SIZE: undefined,
+    };
+  </script>
+  <script type="module" src="/src/main.ts"></script>
+</body>
+
+</html>

+ 2 - 1
package.json

@@ -1,10 +1,11 @@
 {
   "name": "stmms-web",
-  "version": "0.0.0",
+  "version": "1.3.4",
   "private": "true",
   "scripts": {
     "start": "vite --host 0.0.0.0",
     "dev": "vite --force",
+    "prebuild": "node --experimental-json-modules prebuild.mjs",
     "build": "vue-tsc --noEmit --skipLibCheck && vite build",
     "build-without-type-check": "vite build",
     "typecheck": "vue-tsc --noEmit --skipLibCheck",

+ 27 - 0
prebuild.mjs

@@ -0,0 +1,27 @@
+import { writeFileSync } 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}
+`
+);
+
+console.log();