[Javascript] Writing conventional commits with commitizen

Because semantic-release requires a specific message format, it's easier to follow this convention using a tool called commitizen. In this lesson, we'll use it to write our first conventional commit message.

 

Install:

npm i -D commitizen cz-conventional-changelog

 

package.json:

{
  "czConfig": {
    "path": "node_modules/cz-conventional-changelog"
  },
  "scripts": {
    "commit": "git-cz",
    "start": "cross-env NODE_ENV=development webpack-dev-server --progress --profile --colors --display-error-details --display-cached --inline",
    "test": "cross-env NODE_ENV=test karma start",
    "test:single": "cross-env NODE_ENV=test karma start --single-run",
    "semantic-release": "semantic-release pre && npm publish && semantic-release post"
  },    
}

 

The convention it follows is from angular

 

Committing a new feature with commitizen

n this lesson, we'll add a new feature to our library and use commitizen to generate our commit message that follows the convention for semantic-release to know it needs to bump the minor version.

 

 After you add a feature, git status and add all the files.
Then run:
npm run commit

It will let you go thoguht few steps of commit message, then you can push to github.

 

Automatically Releasing with TravisCI

Now that we have everything set up with semantic-release and we have a feature commit, let's push that up and watch TravisCI use semantic-release do our library release automatically.

 

After you git push to master. Traavis will automatically run the build and tests, if everything pass, then it will automaticlly update the package version number and release the package in github and npm.

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值