Conventional Commit and Auto Generate CHANGELOG File using Commitizen
If you are a software engineer, what message do you use when create commiy and how you creare CHANGELOG file. If the commit message you created is hard fot other team members to understand, and CHANGELOG is manually created, Let’s get along we leave that old-fashioned way. And move on using the developer tool I will review This time, the target review This time is to commit more structured And consistent And automatically generate CHANGELOG based on commit that has been made.
For the tool we will use This time, all is from commitizen. There are 2 tools to be used are:
• git-cz Conventional Commit: https://www.npmjs.com/package/commitizen
• Standard Version: https://www.npmjs.com/package/standard-version
Conventional Commit
Is a standard naming commit, the format of the naming is as follows.commit: action(scope) message <long desc> <fixed issues>
for those in brackets, its nature is optional alias is not mandatory.
Example : commit: fix(news card) solved wrong design , fixed #23
Standard Version
Of all commits created by conventional commits, the standard version will check the app version and make up the version based on what’s written in package.json. Latest version And list commit will be input into CHANGELOG file And at the same time create new tag based on new version tergerate. All of the above steps are executed automatically by standard-version
.
Standard-version uses standardization of semantic version to generate app version.
Getting Started
Both for non-NodeJS project And NodeJS is obliged until applying package.json to use this method. The semantic version that will be applied by the standard version will be handled by the version shown in package.json
.
Git Supported Project
Make sure the project that will implement the tool in already implement git git init
. If this is not done then there is likely to be a problem in the standard-version
section.
Initial Project
Start with the initial project in your root project using the following command:
$npm init
Global Dependency Instalation
Please follow this readme to start instalation commitizen to your local gear
Project Dependency Instalation
Install all the required dev dependencies
$npm install -dev standard-version
Added NPM Scripts
For this section is not mandatory, but very helpful, rather than typing a lot of commands in the terminal, better simplify it using npm scripts.
There are 2 scripts I will create, both of which are scripts until release, more complete about the release can be read in the standard-version
section above. Release is divided into 2 ie to release beta version And release final version.
Following the scripts:
"scripts": { "release" : "standard-version", "release:beta" : "standard-version -p beta" }
Script expectation
Assume you currently have version 0.0.1 in my app.
There are many major changes, both in terms of new features or resolving bugs.
• `npm relase:beta`, being version 0.1.0-beta.1
• `npm release`, to 0.1.0
Originally published at oopsreview.com on October 15, 2017.