19 年我发了一篇文章changelog 日志自动生成插件,里面介绍了我开源的一套【auto changelog、commit-lint】规范化代码提交的工具插件合集。
但是由于是第一次发布一些开源的项目,难免开发方案不是很丝滑,用起来也不是很柔顺。
所以基于这些问题,用 lerna 对这个工具进行了一次升级。大概内容如下:
1 2 3
   | jimi-web-changelog/cz --> @nicecode/commit    jimi-web-changelog/lint  -->  @nicecode/commit-lint     jimi-web-changelog --> @nicecode/changelog   
   | 
 
CZ 模块配置优化
官方文档
原配置
1 2 3 4 5 6 7 8 9 10 11 12 13
   |  cnpm i commitizen jimi-web-changelog --save-dev
 
  {   ...   "config": {     "commitizen": {       "path": "./node_modules/jimi-web-changelog/lib/cz"     }   },   ... }
 
  | 
 
新配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14
   |  cnpm i commitizen @nicecode/commit --save-dev
 
  {   ...   "config": {     "commitizen": {       "path": "@nicecode/commit"     }   },   ... }
 
 
  | 
 
lint 模块配置优化
官方文档
原配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
   | 1. 安装依赖 cnpm i husky commitlint jimi-web-changelog --save-dev
  2. 在 package.json 中引入以下配置 {   ...   "husky": {     "hooks": {       "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"     }   },   ... }
  3、根目录下 .commitlint.js modules.exports = Object.assign({}, require('jimi-web-changelog/lib/lint'), {   rules: {     'subject-empty': [2, 'never'],     'type-empty': [2, 'never'],     'type-enum': [2, 'always',       [         '新功能',         '修复',         ...       ]     ]   } }
   | 
 
新配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
   |  cnpm i husky commitlint @nicecode/commit-lint --save-dev
 
  {   ...   "husky": {     "hooks": {       "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"     }   },   ... }
 
  modules.exports = {   extends: ["@nicecode/commit-lint"] }
 
  | 
 
changelog 模块配置优化
官方文档
原配置
1 2 3 4 5 6 7 8 9 10 11
   |  cnpm i conventional-changelog-cli jimi-web-changelog --save-dev
 
  {   ...   "script": {     "log": "conventional-changelog --config node_modules/jimi-web-changelog/lib/log -i CHANGELOG.md -s -r 0",   }   ... }
 
  | 
 
新配置
1 2 3 4 5 6 7 8 9 10 11
   |  cnpm i conventional-changelog-cli @nicecode/changelog --save-dev
 
  {   ...   "script": {     "log": "conventional-changelog --n node_modules/@nicecode/changelog -i CHANGELOG.md -s -r 0",   }   ... }
 
  | 
 
后记
nicecoder 团队 目前 4 人,致力整合一套提高工作效率和代码规范的工具库,目前我们的计划的和已完成的有以下几个板块:

期待你的加入:nicecoder
相关链接
@nicecode/tools 常用函数库
nicecode 官网
nicecode github 地址