ngx-semantic-version is an Angular Schematic that will add and configure commitlint, commitizen, husky and standard-version for creating commit messages in the conventional commit format and automate your release and Changelog generation respecting semver.
The schematic will configure the following packages / services:
How to use
Add the schematics to your project
Just run the following command:
ng add ngx-semantic-version
if you have already configured one of the modules and you want to use the configuration provided by ngx-semantic-version, you can use
--forceto override an existing configuration. Please check the changes carefully using git after running with
||Skips installing new
||Configure an issue prefix that should be checked by each commit|
||Override existing configurations if neccessary|
force including references by configuring an issue prefix
When adding the schematic using e.g.
--issuePrefix="PREFIX-", commitlint will be configured to use
the defined issue prefix in commit messages. Therefore the following configuration will be added
commitlint.config.js configuration file:
moduleexports =// ...rules:'references-empty': 2 'never'parserPreset:parserOpts:issuePrefixes: 'PREFIX-';
This is very helpful if you want to force the users to include always an reference to your issue
tracking system (in the example above the issue racking system will use this style:
'references-empty': [2, 'never'],will tell commitlint that an issue reference has to be included always. You can change the value of
1to just warn the user instead of rejecting the commit messages. All configuration option are described in the official docs of commitlint.
The prefix will be also configured for usage within standard-version in your
You can specify further options for standard-version that will be uses for the generated links in
CHANGELOG.mdgeneration. You can adjust the configuration block
package.jsonand adjusts the options to satisfy your needs.
Update the schematics
ng update to see if an update is available.
To proceed running an update of ngx-semantic-version, run the following command:
ng update ngx-semantic-version
Updates will may touch your existing configuration. Please check the changes using git to verify the changes.
Commitlint will lint your commit massage and check it against some common rules.
It will throw an error if the messages doesn't match with the rules.
This schematic will install the ruleset
@commitlint/config-conventional by default.
After adding the schematics you will be able to adjust the rules for your
personal needs by adjusting the added file
You can find a description of supported adjustments in the official documentation.
Husky allows us to hook into the git lifecycle using nodejs. It is used by ngx-semantic-version to check a commit message right before storing it by using commitlint.
Therefore it will add this part to your
Husky uses the evnironment variable
HUSKY_GIT_PARAMS containing the current git message you entered and it will pass this through commitlint so it can be evaluated.
When having restrichtions within the commit message text it can be struggeling to satisfy always the appropriate format. Commitizen will help you to build a commit message always in the appropriate format by letting you configure the final message via an interactive cli.
ngx-semantic-version will configure commitizen in your
package.json, so that is will use the conventional changelog as well:
Tip: if you are using vscode, you can add the plugin Visual Studio Code Commitizen Support which will let you build the commit message directly via vscode.
Standard-version will create and update your app/package version and automatically
CHANGELOG.md file and keep it up-to-date by using the git history.
It will check the messages for keywords (thanks to commitlint) and determine which part
of the semantic version will be increased. Furthermore it will add a tag for the version.
After adding this schematic, you can simply release a new version by running
npm run release.
This will keep your
CHNAGELOG.md up to date and releases a new version of your project.
ngx-semantic-version will configure a new script in your
package.json that can be used for releasing a new version:
If you typically use
npm version to cut a new release, do this instead:
npm run release
You should also consider use one of the following commands:
npm run release -- --first-release # create the initial release and create the `CHANGELOG.md`npm run release -- --prerelease # create a pre-release instead of a regular onenpm run release -- --prerelease alpha # cut a new alpha release version
Check out the official documentation for further information.
For development hints, have a look at DEVELOPMENT.md