Skip to content

Commit

Permalink
feat: email check and commit config
Browse files Browse the repository at this point in the history
  • Loading branch information
richard1015 committed Oct 29, 2020
1 parent 4521427 commit e922303
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
node_modules
/dist
/libs
/jd
/jd/upload.js
yarn.lock
package.lock

Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"singleQuote": true,
"semi": true,
"semi": false,
"bracketSpacing": true,
"tabWidth": 2,
"printWidth": 150,
Expand Down
15 changes: 15 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'body-leading-blank': [1, 'always'],
'footer-leading-blank': [1, 'always'],
'header-max-length': [2, 'always', 72],
'scope-case': [2, 'always', 'lower-case'],
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [2, 'always', ['upd', 'chore', 'docs', 'feat', 'fix', 'test', 'refactor', 'revert', 'style']]
}
}
12 changes: 12 additions & 0 deletions jd/verifymail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env node
const { execSync } = require('child_process')

const stdout = execSync('git config user.email').toString()

if (stdout && /@jd.com$/gi.test(stdout.replace(/^\s+|\s+$/g, ''))) {
console.log('\x1B[31m%s\x1B[39m', 'ERROR:', '不能使用京东企业邮箱提交,请设置个人GitHub邮箱')
console.log('提示: git config user.email [email protected]')
process.exit(1)
} else {
process.exit(0)
}
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"vue-router": "^4.0.0-0"
},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@vue/cli-plugin-babel": "~4.5.0",
Expand All @@ -57,6 +59,8 @@
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^7.0.0-0",
"husky": "^4.3.0",
"lint-staged": "^10.5.0",
"prettier": "^1.19.1",
"typescript": "~3.9.3"
},
Expand All @@ -81,6 +85,15 @@
"no-console": "off"
}
},
"husky": {
"hooks": {
"pre-commit": "node ./jd/verifymail.js && lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.{ts,js,vue,scss}": "prettier --write"
},
"repository": {
"type": "git",
"url": "https://github.com/jdf2e/nutui.git"
Expand All @@ -90,4 +103,4 @@
"last 2 versions",
"not dead"
]
}
}

0 comments on commit e922303

Please sign in to comment.