فهرست منبع

feat: add pre-commit

xiaoxian521 3 سال پیش
والد
کامیت
515be309b8
5فایلهای تغییر یافته به همراه309 افزوده شده و 189 حذف شده
  1. 259 169
      package-lock.json
  2. 12 5
      package.json
  3. 23 0
      scripts/verify-commit.ts
  4. 1 1
      src/layout/components/Navbar.vue
  5. 14 14
      src/router/modules/remaining.ts

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 259 - 169
package-lock.json


+ 12 - 5
package.json

@@ -9,6 +9,11 @@
     "preview": "vite preview",
     "preview": "vite preview",
     "preview:build": "npm run build && vite preview"
     "preview:build": "npm run build && vite preview"
   },
   },
+  "husky": {
+    "hooks": {
+      "commit-msg": "node scripts/verify-commit.ts"
+    }
+  },
   "dependencies": {
   "dependencies": {
     "@amap/amap-jsapi-loader": "^1.0.1",
     "@amap/amap-jsapi-loader": "^1.0.1",
     "@logicflow/core": "^0.4.6",
     "@logicflow/core": "^0.4.6",
@@ -17,10 +22,10 @@
     "await-to-js": "^3.0.0",
     "await-to-js": "^3.0.0",
     "axios": "^0.21.1",
     "axios": "^0.21.1",
     "cropperjs": "^1.5.11",
     "cropperjs": "^1.5.11",
-    "dayjs": "^1.10.4",
+    "dayjs": "^1.10.5",
     "dotenv": "^8.2.0",
     "dotenv": "^8.2.0",
     "echarts": "^5.1.1",
     "echarts": "^5.1.1",
-    "element-plus": "^1.0.2-beta.44",
+    "element-plus": "^1.0.2-beta.46",
     "font-awesome": "^4.7.0",
     "font-awesome": "^4.7.0",
     "lodash-es": "^4.17.21",
     "lodash-es": "^4.17.21",
     "mitt": "^2.1.0",
     "mitt": "^2.1.0",
@@ -52,14 +57,16 @@
     "@vue/compiler-sfc": "^3.0.11",
     "@vue/compiler-sfc": "^3.0.11",
     "autoprefixer": "^10.2.4",
     "autoprefixer": "^10.2.4",
     "babel-plugin-transform-remove-console": "^6.9.4",
     "babel-plugin-transform-remove-console": "^6.9.4",
+    "chalk": "^2.4.2",
     "cross-env": "^7.0.3",
     "cross-env": "^7.0.3",
+    "husky": "^6.0.0",
     "postcss": "^8.2.6",
     "postcss": "^8.2.6",
     "postcss-import": "^14.0.0",
     "postcss-import": "^14.0.0",
     "sass": "^1.32.8",
     "sass": "^1.32.8",
     "sass-loader": "^11.0.1",
     "sass-loader": "^11.0.1",
     "typescript": "^4.2.4",
     "typescript": "^4.2.4",
-    "vite": "^2.3.4",
-    "vite-plugin-mock": "^2.5.0",
-    "vite-plugin-style-import": "^0.10.0"
+    "vite": "^2.3.7",
+    "vite-plugin-mock": "^2.7.0",
+    "vite-plugin-style-import": "^0.10.1"
   }
   }
 }
 }

+ 23 - 0
scripts/verify-commit.ts

@@ -0,0 +1,23 @@
+const chalk = require("chalk");
+
+const msgPath = process.env.HUSKY_GIT_PARAMS;
+const msg = require("fs").readFileSync(msgPath, "utf-8").trim();
+
+const commitRE = /^(revert: )?(feat|fix|polish|docs|style|refactor|perf|test|workflow|ci|chore|types)(\(.+\))?: .{1,50}/;
+
+if (!commitRE.test(msg)) {
+  console.log();
+  console.error(
+    `  ${chalk.bgRed.white(" ERROR ")} ${chalk.red(
+      "不合法的 commit 消息格式"
+    )}\n\n` +
+      chalk.red("  请使用正确的提交格式:\n\n") +
+      `    ${chalk.green("feat: add 'comments' option")}\n` +
+      `    ${chalk.green("fix: handle events on blur (close #28)")}\n\n` +
+      chalk.red(
+        "  请查看 git commit 提交规范:https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md \n"
+      )
+  );
+
+  process.exit(1);
+}

+ 1 - 1
src/layout/components/Navbar.vue

@@ -74,7 +74,7 @@ export default defineComponent({
     const router = useRouter();
     const router = useRouter();
     const route = useRoute();
     const route = useRoute();
 
 
-    let usename = storageSession.getItem("info").username;
+    let usename = storageSession.getItem("info")?.username;
 
 
     const { locale, t } = useI18n();
     const { locale, t } = useI18n();
 
 

+ 14 - 14
src/router/modules/remaining.ts

@@ -21,20 +21,20 @@ const remainingRouter = [
       rank: 102,
       rank: 102,
     },
     },
   },
   },
-  {
-    // 找不到路由重定向到404页面
-    path: "/:pathMatch(.*)",
-    name: "pathMatch",
-    component: Layout,
-    redirect: "/error/404",
-    meta: {
-      icon: "el-icon-s-home",
-      title: "message.hshome",
-      showLink: false,
-      savedPosition: false,
-      rank: 103,
-    },
-  },
+  // {
+  //   // 找不到路由重定向到404页面
+  //   path: "/:pathMatch(.*)",
+  //   name: "pathMatch",
+  //   component: Layout,
+  //   redirect: "/error/404",
+  //   meta: {
+  //     icon: "el-icon-s-home",
+  //     title: "message.hshome",
+  //     showLink: false,
+  //     savedPosition: false,
+  //     rank: 103,
+  //   },
+  // },
   {
   {
     path: "/redirect",
     path: "/redirect",
     name: "redirect",
     name: "redirect",

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است