Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cz-commitlint searchable and easy to get start #2572

Merged
merged 8 commits into from
May 3, 2021
51 changes: 12 additions & 39 deletions @commitlint/cz-commitlint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ The interactive process is inspired by [cz-conventional-changelog](https://githu

## Getting started

### Using commitizen adapter
### Configure commitizen adapter

```bash
npm install --save-dev @commitlint/cz-commitlint commitizen
# or yarn
yarn add -D @commitlint/cz-commitlint commitizen
```

In package.json

```
```json
{
"scripts": {
"commit": "git-cz"
Expand All @@ -33,56 +35,27 @@ In package.json

### Configure commitlint

**⚠️ Important: The required version of commitlint and shared configuration is above 12.1.2, update them if already existed in project**

```bash
# Install commitlint cli and conventional config
npm install --save-dev @commitlint/config-conventional @commitlint/cli
# or yarn
yarn add @commitlint/config-conventional @commitlint/cli -D

# Simple: config with conventional
echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js

# commitlint configuration is shareable,
# Install lerna-scopes
npm install --save-dev @commitlint/config-lerna-scopes
# Scalable: config with lerna-scopes in monorepo mode
echo "module.exports = {extends: ['@commitlint/config-conventional', '@commitlint/config-lerna-scopes']};" > commitlint.config.js
```

### Set Git Hooks by husky

```base

# ------- using npm ----------
# Install Husky
npm install husky --save-dev
# Active hooks
npx husky install
# Add commitlint hook
npx husky add .husky/commit-msg 'npx --no-install commitlint --edit $1'
# Add commitizen hook
npx husky add .husky/prepare-commit-msg 'exec < /dev/tty && node_modules/.bin/cz --hook || true'


# ------- using yarn ----------
# Install Husky
yarn add husky --dev
# Active hooks
yarn husky install
# Add commitlint hook
yarn husky add .husky/commit-msg 'yarn --no-install commitlint --edit $1'
# Add commitizen hook
yarn husky add .husky/prepare-commit-msg 'exec < /dev/tty && node_modules/.bin/cz --hook || true'

```

### Try it out

```bash
git add .
npm run commit
# or
yarn run commit
npm run cz
# or yarn
yarn cz
```

## Related

- [Commitlint Shared Configuration](https://github.com/conventional-changelog/commitlint#shared-configuration) - You can find more shared configurations are available to install and use with commitlint
- [Commitlint Reference Prompt](https://commitlint.js.org/#/reference-prompt) - How to customize prompt information by setting commitlint.config.js
10 changes: 10 additions & 0 deletions @commitlint/cz-commitlint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@
"files": [
"lib"
],
"keywords": [
"conventional-changelog",
"commitlint",
"cz",
"commitizen",
"cz-commitlint"
],
"scripts": {
"commit": "git-cz"
},
"homepage": "https://github.com/conventional-changelog/commitlint#readme",
"bugs": {
"url": "https://github.com/conventional-changelog/commitlint/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/conventional-changelog/commitlint.git"
Expand Down
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
- [Rules](reference-rules.md)
- [API](reference-api.md)
- [Plugins](reference-plugins.md)
- [Prompt](reference-prompt.md)
- [Examples](reference-examples.md)
- [Community projects](reference-community-projects.md)
Binary file modified docs/assets/cz-commitlint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.