Skip to content

estevam5s/cli-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”§ CLI Commit - Professional Conventional Commits Tool

npm version License Node.js TypeScript

Professional CLI tool for creating conventional commits with Husky integration


✨ Features

  • 🎨 Beautiful Colorful Output - Terminal UI with colors and emojis
  • πŸ“ Conventional Commits - Full support for the conventional commits specification
  • πŸ€– Husky Integration - Seamlessly works with Husky Git hooks
  • βœ… Message Validation - Validates commit messages before creation
  • ⚑ Interactive Prompts - User-friendly command line interface
  • πŸ”§ Flexible Configuration - Customizable commit types and scopes
  • πŸ“¦ Easy Installation - Install globally and use anywhere
  • πŸš€ TypeScript - Written in TypeScript for type safety

πŸ“¦ Installation

Global Installation (Recommended)

npm install -g cli-commit

Local Installation

npm install --save-dev cli-commit

Using npx (No Installation)

npx cli-commit commit

πŸš€ Quick Start

Interactive Mode

cli-commit commit
# or
cc commit
# or
cc c

With Options

# Create a feature commit
cli-commit commit -t feat -m "add user authentication"

# Create a fix commit with scope
cli-commit commit -t fix -s api -m "resolve CORS issue"

# Create a breaking change
cli-commit commit -t feat -m "change API structure" --breaking

# Commit all changes
cli-commit commit -t feat -m "major update" --all

πŸ“‹ Commit Types

Type Description Emoji
feat A new feature ✨
fix A bug fix πŸ›
docs Documentation only changes πŸ“
style Code style changes (formatting) πŸ’„
refactor Code refactoring ♻️
perf Performance improvements ⚑
test Adding or updating tests πŸ§ͺ
build Build system or dependency changes πŸ“¦
ci CI/CD configuration changes πŸ‘·
chore Maintenance tasks πŸ”§
revert Reverting changes βͺ
merge Merging branches πŸ”€
hotfix Urgent bug fix πŸš‘

πŸ”§ Commands

cli-commit commit (alias: cc c)

Create a new conventional commit.

Options:

Option Alias Description Example
--type -t Commit type -t feat
--scope -s Scope of the change -s api
--message -m Commit message -m "add feature"
--body -b Commit body -b "details"
--footer -f Commit footer -f "Closes #123"
--breaking -B Breaking change flag --breaking
--issue -i Issue reference -i #123
--all -a Stage all changes --all
--dry-run -d Show without committing --dry-run
--skip-validation Skip validation --skip-validation
--skip-push Skip push after commit --skip-push
--no-emoji Disable emoji output --no-emoji

Examples:

# Basic usage
cli-commit commit

# With type and message
cli-commit commit -t fix -m "resolve login bug"

# With scope
cli-commit commit -t feat -s auth -m "add OAuth support"

# Breaking change
cli-commit commit -t api -m "change response format" --breaking

# Commit all changes
cli-commit commit -t chore -m "update dependencies" -a

# Dry run
cli-commit commit -t feat -m "new feature" --dry-run

cli-commit list (alias: cc ls)

List all available commit types.

cli-commit list
# Output:
#   ✨ feat       Feature      A new feature
#   πŸ› fix       Bug Fix      A bug fix
#   πŸ“ docs      Documentation Documentation only changes
#   ...

cli-commit status (alias: cc st)

Show git status and commit readiness.

cli-commit status

cli-commit validate <message> (alias: cc v)

Validate a commit message.

cli-commit validate "feat(api): add new endpoint"

cli-commit info (alias: cc i)

Show CLI Commit information.

cli-commit info

🎨 Output Examples

Interactive Commit Creation

╔════════════════════════════════════════════════════════════════════╗
β•‘                                                                    β•‘
β•‘   CLI Commit - Conventional Commits Tool                          β•‘
β•‘                                                                    β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

  Branch: main
  βœ“ Husky installed (9.0.0)
  βœ“ Commitlint configured

  ? Select the type of commit: (Use arrow keys)
    ✨ feat - A new feature
    πŸ› fix - A bug fix
    ...

  βœ“ Commit created successfully!
    Hash: a1b2c3d
  
  ? Push to remote? (y/N)

Commit Preview

Commit Preview:
────────────────────────────────────────────────────────────
✨ feat(api): add user authentication

Add JWT-based authentication with refresh tokens
────────────────────────────────────────────────────────────

Is this a BREAKING CHANGE? (y/N)

πŸ”— Integration

With Husky

CLI Commit works seamlessly with Husky. Just install Husky and use cli-commit in your commit workflow:

# Install Husky
npm install husky --save-dev
npx husky install

# Add to package.json
{
  "scripts": {
    "commit": "cli-commit commit"
  }
}

With commitlint

Validate commit messages with commitlint:

npm install @commitlint/config-conventional --save-dev

Git Aliases

Add to your ~/.gitconfig:

[alias]
  cc = !cli-commit commit
  ccc = !cli-commit commit --all

πŸ“ Project Structure

cli-commit/
β”œβ”€β”€ bin/
β”‚   β”œβ”€β”€ cli-commit.js      # Binary entry point
β”‚   └── postinstall.js     # Post-install script
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts          # Main CLI entry
β”‚   β”œβ”€β”€ commands/
β”‚   β”‚   └── commit.ts     # Commit command
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── commit-config.ts  # Commit types & prompts
β”‚   β”œβ”€β”€ types/
β”‚   β”‚   └── index.ts      # TypeScript types
β”‚   └── utils/
β”‚       β”œβ”€β”€ colors.ts     # Color utilities
β”‚       β”œβ”€β”€ commit-builder.ts  # Message builder
β”‚       └── git.ts        # Git utilities
β”œβ”€β”€ test/                  # Test files
β”œβ”€β”€ docs/                  # Documentation
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md

πŸ§ͺ Testing

# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Run in watch mode
npm run test -- --watch

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feat/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feat/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License.


πŸ‘₯ Author

LTD - LaboratΓ³rio de TransformaΓ§Γ£o Digital


πŸ™ Acknowledgments


Made with ❀️ by LTD - Laboratório de Transformação Digital

EstΓ‘cio - Campus FlorianΓ³polis

About

Professional CLI tool for creating conventional commits with Husky integration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors