1.0.1 • Published 1 year ago

@altar-io/cz-conventional-changelog-jira v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

cz-conventional-changelog-jira

Part of the commitizen family. Prompts for conventional changelog standard and also prompts for a mandatory JIRA issue.

Features

  • Works seamlessly with semantic-release 🚀
  • Works seamlessly with Jira smart commits
  • Automatically detects the Jira issue from the branch name

Preview

preview

Quickstart

Installation

npm install commitizen @altar-io/cz-conventional-changelog-jira --save-dev

and then add the following to package.json:

{
  "scripts": {
    "commit": "git-cz"
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/@altar-io/cz-conventional-changelog-jira"
    }
  }
}

Usage

Gif of terminal when using cz-conventional-changelog-jira

Configuration

Like commitizen, you can specify the configuration of cz-conventional-changelog-jira through the package.json's config.commitizen key, or with environment variables.

Environment variablepackage.jsonDefaultDescription
CZ_JIRA_MODEjiraModetrueIf this is set to true, CZ will ask for a Jira issue and put it in the commit head. If set to false CZ will ask for the issue in the end, and can be used for GitHub.
CZ_MAX_HEADER_WIDTHmaxHeaderWidth72This limits how long a commit message head can be.
CZ_MIN_HEADER_WIDTHminHeaderWidth2This limits how short a commit message can be.
CZ_MAX_LINE_WIDTHmaxLineWidth100Commit message bodies are automatically wrapped. This decides how long the lines will be.
CZ_SKIP_SCOPEskipScopetrueIf scope should be used in commit messages.
CZ_SKIP_DESCRIPTIONskipDescriptionfalseIf description should be used in commit messages.
CZ_SKIP_BREAKINGskipBreakingfalseIf breaking changes should be used in commit messages.
scopesundefinedA list (JS Array) of scopes that will be available for selection. Note that adding this will change the scope field from Inquirer 'input' to 'list'.
CZ_TYPEdefaultTypeundefinedThe default type.
CZ_SCOPEdefaultScopeundefinedThe default scope.
CZ_CUSTOM_SCOPEcustomScopefalseWhether user can provide custom scope in addition to predefined ones.
CZ_SUBJECTdefaultSubjectundefinedA default subject.
CZ_BODYdefaultBodyundefinedA default body.
CZ_ISSUESdefaultIssuesundefinedA default issue.
CZ_JIRA_OPTIONALjiraOptionalfalseIf this is set to true, you can leave the JIRA field blank.
CZ_JIRA_PREFIXjiraPrefix"ALT"If this is set it will be will be displayed as the default JIRA ticket prefix.
CZ_JIRA_MULTIPLE_ISSUESjiraMultipleIssuestrueIf this is set to false, you'll be able to input multiple JIRA tickets (ex: ALT-1, ALT-2, ALT-3)
CZ_JIRA_EMOJI_TYPESjiraEmojiTypesfalseIf this is set to true, commit types have emoji (ex: 🐛). Easier to spot the type.
CZ_JIRA_LOCATIONjiraLocation"pre-description"Changes position of JIRA ID. Options: pre-type, pre-description, post-description, post-body.
CZ_JIRA_PREPENDjiraPrepend""Prepends JIRA ID with an optional decorator. e.g.: [ALT-123.
CZ_JIRA_APPENDjiraAppend""Appends JIRA ID with an optional decorator. e.g.: ALT-123].
CZ_EXCLAMATION_MARKexclamationMarkfalseOn breaking changes, adds an exclamation mark (!) after the scope, e.g.: type(scope)!: break stuff. When activated, reduces the effective allowed header length by 1.

Jira Location Options

pre-type:

JIRA-123 type(scope): commit subject

pre-description:

type(scope): JIRA-123 commit subject

post-description:

type(scope): commit subject JIRA-123

post-body:

type(scope): commit subject

JIRA-123
type(scope): commit subject

this is a commit body

JIRA-123

Dynamic Configuration

Alternatively, if you want to create your own profile, you can use the configurable approach. Here is an example: ./cz-config.js

const custom = require('@altar-io/cz-conventional-changelog-jira/configurable');
// You can do this optionally if you want to extend the commit types
const defaultTypes = require('@altar-io/cz-conventional-changelog-jira/types');

module.exports = custom({
  types: {
    ...defaultTypes,
    perf: {
      description: 'Improvements that will make your code perform better',
      title: 'Performance',
    },
  },
  skipScope: false,
  scopes: ['myScope1', 'myScope2'],
  customScope: true,
});

./package.json

{
  "config": {
    "commitizen": {
      "path": "./cz-config.js"
    }
  }
}

This example would:

  • Display "perf" as an extra commit type
  • Ask you to add a commit scope
  • Limit the scope selection to either myScope or myScope2

List of all supported configurable options when using the configurable approach:

KeyDefaultDescription
jiraModetrueIf this is set to true, CZ will ask for a Jira issue and put it in the commit head. If set to false CZ will ask for the issue in the end, and can be used for GitHub.
maxHeaderWidth72This limits how long a commit message head can be.
minHeaderWidth2This limits how short a commit message can be.
maxLineWidth100Commit message bodies are automatically wrapped. This decides how long the lines will be.
skipScopetrueIf scope should be used in commit messages.
defaultTypeundefinedThe default type.
defaultScopeundefinedThe default scope.
defaultSubjectundefinedA default subject.
defaultBodyundefinedA default body.
defaultIssuesundefinedA default issue.
jiraPrefix'ALT'The default JIRA ticket prefix that will be displayed.
jiraMultipleIssuestrueThe default amount if tickets that go in the commit message.
jiraEmojiTypesfalseThe default display of thet types with emoji (easier to spot the type).
types./types.jsA list (JS Object) of supported commit types.
scopesundefinedA list (JS Array) of scopes that will be available for selection. Note that adding this will change the scope field from Inquirer 'input' to 'list'.
customScopefalseIf this is set to true, users are given an option to provide custom scope aside the ones predefined in 'scopes' array. In this case a new option named 'custom' appears in the list and once chosen a prompt appears to provide custom scope
jiraOptionalfalseIf this is set to true, you can leave the JIRA field blank.
jiraLocation"pre-description"Changes position of JIRA ID. Options: pre-type, pre-description, post-description, post-body
jiraPrepend""Prepends JIRA ID with an optional decorator. e.g.: [ALT-123
jiraAppend""Appends JIRA ID with an optional decorator. e.g.: ALT-123]
exclamationMarkfalseOn breaking changes, adds an exclamation mark (!) after the scope, e.g.: type(scope)!: break stuff. When activated, reduces the effective allowed header length by 1.

Commitlint

If using the commitlint js library, the "maxHeaderWidth" configuration property will default to the configuration of the "header-max-length" rule instead of the hard coded value of 72. This can be ovewritten by setting the 'maxHeaderWidth' configuration in package.json or the CZ_MAX_HEADER_WIDTH environment variable.