Skip to content

Commit

Permalink
feat: ✨ add @jsxiaosi/commitlint-config
Browse files Browse the repository at this point in the history
  • Loading branch information
jsxiaosi committed Oct 20, 2022
1 parent 80d2ab6 commit b73f163
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 307 deletions.
48 changes: 0 additions & 48 deletions .cz-config.js

This file was deleted.

53 changes: 34 additions & 19 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
/**
* feature
* fixbug 修复
* refactor:重构代码(既没有新增功能,也没有修复 bug)
* docs:文档更新
* style:不影响程序逻辑的代码修改(修改空白字符,格式缩进,补全缺失的分号等,没有改变代码逻辑)
* perf:性能, 体验优化
* chore:不属于以上类型的其他类型,比如构建流程, 依赖管理
* revert:回滚某个更早之前的提交
*/
/* eslint-disable @typescript-eslint/no-var-requires */
// CommonJS
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');

const scopes = fs.readdirSync(path.resolve(__dirname, 'src'));

const gitStatus = execSync('git status --porcelain || true').toString().trim().split('\n');

const scopeComplete = gitStatus
.find((r) => ~r.indexOf('M src'))
?.replace(/(\/)/g, '%%')
?.match(/src%%((\w|-)*)/)?.[1];

const subjectComplete = gitStatus
.find((r) => ~r.indexOf('M src'))
?.replace(/\//g, '%%')
?.match(/src%%((\w|-)*)/)?.[1];

module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
['feature', 'fixbug', 'refactor', 'docs', 'style', 'perf', 'chore', 'revert'],
],
'subject-full-stop': [0, 'never'],
'subject-case': [0, 'never'],
extends: ['@jsxiaosi/commitlint-config'],
prompt: {
// 范围设置
scopes: [...scopes, 'mock'],
// 范围是否可以多选
enableMultipleScopes: true,
// 多选范围后用标识符隔开
scopeEnumSeparator: ',',
// 设置 选择范围 中 为空选项(empty) 和 自定义选项(custom) 的 位置
customScopesAlign: !scopeComplete ? 'top' : 'bottom',
// 如果 defaultScope 与在选择范围列表项中的 value 相匹配就会进行星标置顶操作。
defaultScope: scopeComplete,
// 描述预设值
defaultSubject: subjectComplete && `[${subjectComplete}] `,
},
};
14 changes: 4 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"lint:stylelint": "stylelint --fix scss \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:pretty": "pretty-quick --staged",
"lint:staged": "lint-staged",
"commit": "git-cz",
"cz": "czg",
"prepare": "husky install",
"push": "scp -r dist/* root@服务器公网IP:/服务器资源存放地址",
"build:push": "npm run build && npm run push"
Expand Down Expand Up @@ -62,9 +62,8 @@
"wangeditor": "^4.7.15"
},
"devDependencies": {
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@ehutch79/vite-eslint": "^0.0.1",
"@jsxiaosi/commitlint-config": "^0.0.8",
"@jsxiaosi/eslint-config-prettier": "^0.0.7",
"@jsxiaosi/eslint-config-vue": "^0.0.7",
"@types/core-js": "^2.5.5",
Expand All @@ -81,12 +80,10 @@
"@vue/compiler-sfc": "^3.2.41",
"@vue/test-utils": "^2.1.0",
"autoprefixer": "^10.4.12",
"commitizen": "^4.2.5",
"conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3",
"crypto-js": "^4.1.1",
"cz-conventional-changelog": "^3.3.0",
"cz-customizable": "^7.0.0",
"czg": "^1.3.11",
"eslint": "^8.25.0",
"http-server": "^14.1.1",
"husky": "^8.0.1",
Expand Down Expand Up @@ -136,10 +133,7 @@
},
"config": {
"commitizen": {
"path": "./node_modules/cz-customizable"
},
"cz-customizable": {
"config": ".cz-config.js"
"path": "node_modules/cz-git"
}
},
"lint-staged": {
Expand Down
Loading

0 comments on commit b73f163

Please sign in to comment.