1.1.0 • Published 2 years ago

cz-jira-smart-commit-validated v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

npm (scoped) semantic-release npm

cz-jira-smart-commit-validated

About

Standardize your team's commits using this adapter for commitzen.

This adapter makes it possible to specify and validate the commit of a project that uses Jira as a tool of management. Using this tool you can benefit from using Jira's smart commit commands more easily without having to worry about remembering which commands are available and which syntax must be respected. Besides, it is a perfect adapter to be used together with semantic versioning.

This adapter was based on cz-jira-smart-commit and cz-conventional-changelog.

Highlights

  • Standardizes the squad commit;
  • Can be used together with semantic-release;
  • Prevents typing errors, preventing an erroneous flow in relation to smart commit commands;
  • Prevents an invalid team from being informed to Jira, forcing the default(1w 1d 1h 1m);
  • Prevents an Issue ID from being informed with a key different from the one specified as default;
  • Validates the commit title size respecting the defined limitation.

Example

Flow sample: sampleFlow

Sample of the result of mounting the commit using this adapter: sampleFlow

Installation

If using yarn:

yarn add cz-jira-smart-commit-validated

If using npm:

npm i cz-jira-smart-commit-validated

Usage

Reference cz-jira-smart-commit-validated path in commitzen path property:

{
    ...
 "config": {
        "commitizen": {
            "path": "./node_modules/cz-jira-smart-commit-validated",
            "disableScopeLowerCase": false,
            "disableSubjectLowerCase": false,
            "maxHeaderWidth": 100,
            "maxLineWidth": 100,
            "defaultType": "",
            "defaultScope": "",
            "defaultSubject": "",
            "defaultBody": "",
            "defaultIssuesPrefix": "EVOLOG",
            "enableMultiIssuesIdByCommit": false
        }
    }
}

Example of what would look like package.json of a project using cz-jira-smart-commit-validated.

To use adapter after integration with commitzen, just run:

git cz

or if you prefer, you can use husky to trigger the hook prepare-commmit-msg. Inside this hook this line should be executed:

exec < /dev/tty && node_modules/.bin/cz --hook || true

Example of how the hook would look:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

    exec < /dev/tty && node_modules/.bin/cz --hook || true

So whenever the command is executed:

git commit

The commitzen will be triggered via the husky using cz-jira-smart-commit-validated.

Documentation

cz-jira-smart-commit-validated

Property NameEnvironment Variable NameDescriptionDefault
typesN/ADefines the types of changes that can be used.conventional-commit-types
workflowOptionsN/ADefines the workflow options to be triggered in Jira.workflowOptions
defaultTypeCZ_TYPEDefines the default commit type.""
defaultScopeCZ_SCOPEDefines the default scope of the commit.""
defaultSubjectCZ_SUBJECTDefines the default commit subject.""
defaultBodyCZ_BODYDefines the default body of the commit.""
defaultIssuesPrefixCZ_ISSUES_PREFIXDefines the default prefix for Issues, if the defaultIssuesPrefix is set to EVOLOG, then whenever the Issue ID related to the commit is requested, the Issue ID must be specified in the format EVOLOG-1234. The defaultIssuesPrefix also impacts the default Issue ID value requested by the adapter, still considering the defaultIssuesPrefix set to EVOLOG, if the branch name starts with the same name as the defaultIssuesPrefix, then the default Issue ID will be the name of the branch.""
enableMultiIssuesIdByCommitCZ_ENABLE_MULTI_ISSUES_ID_BY_COMMITDefines whether or not it is possible to report more than one Issue ID per commit.false
disableScopeLowerCaseDISABLE_SCOPE_LOWERCASEDisables the passing of characters from scope to lowercase.false
disableSubjectLowerCaseDISABLE_SUBJECT_LOWERCASEDisables the passing of characters from the commit title to lowercase.false
maxHeaderWidthCZ_MAX_HEADER_WIDTHDefines how many characters the commit title can be.100
maxHeaderWidthCZ_MAX_LINE_WIDTHDefines the maximum number of characters per line.100

Contributing

Pull requests are always welcome! Feel free to open a new GitHub issue for any changes that can be made.

Working on your first Pull Request? You can learn how from this free series How to Contribute to an Open Source Project on GitHub

Author

Kalebe Samuel

License

MIT