feat: add pre-commit

This commit is contained in:
xiaoxian521 2021-06-09 13:11:01 +08:00
parent ef2aa27a87
commit 515be309b8
5 changed files with 368 additions and 234 deletions

532
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

@ -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);
}

View File

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

View File

@ -21,20 +21,20 @@ const remainingRouter = [
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",
name: "redirect",