@aritslimited/commitlint
Version:
A commit linting commitizen adapter & branch naming convention tool tailored for ARITS Limited with Jira Issue & Project Tracking Software; to track commits to Jira issues and transition them to the next stage of development workflow automatically.
124 lines (83 loc) • 5.38 kB
Markdown
# @aritslimited/commitlint
A commit linting [commitizen](https://www.npmjs.com/package/commitizen?activeTab=readme) adapter & branch naming convention tool tailored for [ARITS Limited](https://www.aritsltd.com/) with Jira Issue & Project Tracking Software; to track commits to Jira issues and transition them to the next stage of development workflow automatically.

[](http://npm-stat.com/charts.html?package=@aritslimited/commitlint&from=2023-11-01)
[](http://commitizen.github.io/cz-cli/)



[](https://github.com/semantic-release/semantic-release)



## Table of Contents
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Must Have Environment Variables](#must-have-environment-variables)
- [Branch Naming Convention](#branch-naming-convention)
- [License](#license)
## Installation
You can install this package via npm or yarn. To install, run the following command:
```bash
npm install --save-dev @aritslimited/commitlint commitizen boxen chalk dotenv inquirer node-fetch tslib
```
or
```bash
yarn add -D @aritslimited/commitlint commitizen boxen chalk dotenv inquirer node-fetch tslib
```
or
```bash
pnpm add -D @aritslimited/commitlint commitizen boxen chalk dotenv inquirer node-fetch tslib
```
or
```bash
bun add -D @aritslimited/commitlint commitizen boxen chalk dotenv inquirer node-fetch tslib
```
## Configuration
Run the following command **from project root** to start using this commitizen adapter along with commitizen:
```bash
echo "{\"path\": \"@aritslimited/commitlint/dist/commitlint.config.js\"}" > ./.czrc
```
Now, you can run the following command to commit your changes:
```bash
npx cz
```
or create a script in your `package.json` file and use it with `npm run commit` or `yarn commit` or `pnpm commit` or `bun commit`:
```json
{
"scripts": {
"commit": "npx cz"
}
}
```
## Usage
This package supports the following environment files out of the box:
- .env
- .env.local
- .env.jira.local
### Must Have Environment Variables
This package requires the following environment variables to be set in any of the environment files mentioned above that are synced with your version control system (preferably **.env**):
- `JIRA_BASE_URL`=https://aritsltd.atlassian.net/rest/api/2
- `JIRA_PROJECT`=_your Jira project key_ # e.g. TAF
- `JIRA_ISSUE_FILTERS`=_your Jira issue filters_ # e.g. "In Progress"
- `JIRA_ISSUE_TRANSITION_FILTERS`=_your Jira issue transition filters_ # e.g. "Send to QA"
and the following environment variables to be set in any of the environment files mentioned above that are **not** synced with your version control system (preferably **.env.local**):
- `JIRA_API_USER`=_your Jira API user email_
- `JIRA_API_TOKEN`=_your Jira API token_ # [How to generate a Jira API token](https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/)
### Branch Naming Convention
This package also provides a branch naming convention tool. To use it, include the following environment variables in any of the environment files mentioned above that are synced with your version control system (preferably **.env**):
- `VALID_BRANCH_NAMES`=_your string of valid branch names separated by space_ # e.g. "main staging dev ui"
> NB: Branch naming convention tool is optional feature that is **disabled** by default. To enable it, the `VALID_BRANCH_NAMES` environment variable(s) must be set.
- `BRANCH_NAME_VALIDATING_REGEXP`=_your branch name validating regular expression_ # e.g. "^(main|staging|dev|ui)\/[A-Z]{2,3}-[0-9]{1,5}\/[a-z0-9-]+$"
`BRANCH_NAME_VALIDATING_REGEXP` is optional. Default validating regex expression is:
```js
new RegExp(`^(${branchNamesArr.join("|")})[a-z0-9-]*$`)
```
You can validate your regular expression [here](https://regexr.com/).
## License
This package is open source and available under the [MIT License](LICENSE).
## Contributors
| Name | Contact |
|----------------------------|----------------------------------------------|
| **Emran Hossain** | [](https://github.com/emranffl) [](https://www.linkedin.com/in/emranffl/) |