changelog 日誌自動生成工具升級啦~

背景

19年我發了一篇文章changelog 日誌自動生成插件,裏面介紹了我開源的一套【auto changelog、commit-lint】規範化代碼提交的工具插件合集。node

可是因爲是第一次發佈一些開源的項目,不免開發方案不是很絲滑,用起來也不是很柔順。git

因此基於這些問題,用lerna對這個工具進行了一次升級。大概內容以下:github

jimi-web-changelog/cz --> nicecode/commit   // git 格式化 cli 提交插件
jimi-web-changelog/lint  -->  nicecode/commit-lint    // git 提交 lint 校驗插件
jimi-web-changelog --> nicecode/changelog   // 日誌自動生成插件

CZ 模塊配置優化

官方文檔web

原配置

// 一、安裝依賴
cnpm i commitizen jimi-web-changelog --save-dev

// 二、在 package.json 中添加
{
  ...
  "config": {
    "commitizen": {
      "path": "./node_modules/jimi-web-changelog/lib/cz"
    }
  },
  ...
}

新配置

// 一、安裝依賴
cnpm i commitizen @nicecode/commit --save-dev

// 二、在 package.json 中添加
{
  ...
  "config": {
    "commitizen": {
      "path": "@nicecode/commit"
    }
  },
  ...
}

lint 模塊配置優化

官方文檔npm

原配置

1. 安裝依賴
cnpm i husky commitlint jimi-web-changelog --save-dev

2. 在 package.json 中引入如下配置
{
  ...
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },
  ...
}

三、根目錄下 .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. 安裝依賴
cnpm i husky commitlint @nicecode/commit-lint --save-dev

// 2. 在 package.json 中引入如下配置
{
  ...
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },
  ...
}

// 三、根目錄下 .commitlint.js 
modules.exports = {
  extends: ["@nicecode/commit-lint"]
}

changelog 模塊配置優化

官方文檔json

原配置

// 一、安裝依賴
cnpm i conventional-changelog-cli jimi-web-changelog --save-dev

// 二、在package.json 中添加命令
{
  ...
  "script": {
    "log": "conventional-changelog --config node_modules/jimi-web-changelog/lib/log -i CHANGELOG.md -s -r 0",
  }
  ...
}

新配置

// 一、安裝依賴
cnpm i conventional-changelog-cli @nicecode/changelog --save-dev

// 二、在package.json 中添加命令
{
  ...
  "script": {
    "log": "conventional-changelog --n node_modules/@nicecode/changelog -i CHANGELOG.md -s -r 0",
  }
  ...
}

後記

nicecoder 團隊 目前 4 人,致力整合一套提升工做效率和代碼規範的工具庫,目前咱們的計劃的和已完成的有如下幾個板塊:函數

image.png

期待你的加入:nicecoder工具

相關連接

@nicecode/tools 經常使用函數庫post

nicecode 官網優化

nicecode github地址

相關文章
相關標籤/搜索