From 10df4f9623371e955254cd0e74ee859a502ab94d Mon Sep 17 00:00:00 2001 From: SuperCuteXiaoSi <1531733886@qq.com> Date: Sun, 6 Mar 2022 15:44:49 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=B7=BB=E5=8A=A0=E6=89=8B=E9=80=89?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cz-config.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 27 +++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 .cz-config.js diff --git a/.cz-config.js b/.cz-config.js new file mode 100644 index 00000000..f7ce8b7e --- /dev/null +++ b/.cz-config.js @@ -0,0 +1,48 @@ +/** + * feature + * fixbug 修复 + * refactor:重构代码(既没有新增功能,也没有修复 bug) + * docs:文档更新 + * style:不影响程序逻辑的代码修改(修改空白字符,格式缩进,补全缺失的分号等,没有改变代码逻辑) + * perf:性能, 体验优化 + * chore:不属于以上类型的其他类型,比如构建流程, 依赖管理 + * revert:回滚某个更早之前的提交 + */ + +module.exports = { + // 可选类型 + types: [ + { emoji: '🚀', value: 'feature', name: 'feature: 新功能' }, + { emoji: '🐛', value: 'fixbug', name: 'fixbug: 修复' }, + { emoji: '📝', value: 'docs', name: 'docs: 文档变更' }, + { + emoji: '💅', + value: 'style', + name: 'style: 不影响程序逻辑的代码修改(修改空白字符,格式缩进,补全缺失的分号等,没有改变代码逻辑)', + }, + { emoji: '🔍', value: 'refactor', name: 'refactor: 重构(既不是增加feature),也不是修复bug' }, + { emoji: '💡', value: 'pref', name: 'pref: 性能优化' }, + { + emoji: '🤖', + value: 'chore', + name: 'chore: 不属于以上类型的其他类型,比如构建流程, 依赖管理', + }, + { emoji: '⏪', value: 'revert', name: 'revert: 回退' }, + ], + + // 步骤 + messages: { + type: '请选择提交的类型;', + customScope: '请输入修改的范围(可选)', + subject: '请简要描述提交(必填)', + body: '请输入详细描述(可选)', + footer: '请选择要关闭的issue(可选)', + confirmCommit: '确认要使用以上信息提交?(y/n)', + }, + + // 跳过步骤 + skipQuestions: ['customScope', 'body', 'footer'], + + // 默认长度 + subjectLimit: 100, +}; diff --git a/package.json b/package.json index 2df95e85..e1ab5874 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js", "lint:pretty": "pretty-quick --staged", "lint:staged": "lint-staged", + "commit": "git-cz", "prepare": "husky install", "push": "scp -r dist/* root@服务器公网IP:/服务器资源存放地址", "build:push": "npm run build && npm run push" @@ -65,6 +66,7 @@ "babel-eslint": "^10.1.0", "commitizen": "^4.2.4", "cz-conventional-changelog": "^3.3.0", + "cz-customizable": "^6.3.0", "eslint": "^8.10.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.25.4", @@ -99,10 +101,31 @@ "license": "MIT", "config": { "commitizen": { - "path": "./node_modules/cz-conventional-changelog" + "path": "./node_modules/cz-customizable" } }, "lint-staged": { - "*.vue": "eslint \"{src,mock}/**/*.{vue}\"" + "*.{js,jsx,ts,tsx}": [ + "eslint --fix", + "prettier --write" + ], + "{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": [ + "prettier --write--parser json" + ], + "package.json": [ + "prettier --write" + ], + "*.vue": [ + "eslint --fix", + "prettier --write", + "stylelint --fix" + ], + "*.{scss,less,styl,html}": [ + "stylelint --fix", + "prettier --write" + ], + "*.md": [ + "prettier --write" + ] } }