or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli.mdcommitizen.mdconfiguration.mdformatting.mdindex.mdquestions.mdutilities.md
tile.json

commitizen.mddocs/

Commitizen Adapter

The git-cz Commitizen adapter provides programmatic integration with the Commitizen ecosystem for interactive commit message creation.

Capabilities

Prompter Function

The main export for Commitizen integration is the prompter function.

/**
 * Commitizen prompter function for interactive commit message creation
 * @param cz - Commitizen instance provided by the framework
 * @param commit - Callback function to execute the final commit
 */
function prompter(cz: any, commit: (message: string) => void): void;

Usage in Commitizen:

const { prompter } = require("git-cz");

// Called by Commitizen framework
prompter(cz, (message) => {
  // message contains the formatted commit message
  // Commitizen handles the actual git commit
});

Integration with Commitizen

To use git-cz as a Commitizen adapter, configure it in your package.json:

{
  "config": {
    "commitizen": {
      "path": "./node_modules/git-cz"
    }
  }
}

Or use the built distribution:

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

Implementation Details

The prompter function internally:

  1. Creates application state using createState()
  2. Runs interactive questions using runInteractiveQuestions()
  3. Formats the final message using formatCommitMessage()
  4. Calls the provided commit callback with the formatted message

Usage Examples

Basic Commitizen Integration

# Install Commitizen globally
npm install -g commitizen

# Install git-cz locally
npm install --save-dev git-cz

# Configure in package.json
{
  "config": {
    "commitizen": {
      "path": "./node_modules/git-cz"
    }
  }
}

# Use with Commitizen
git cz

Custom Adapter Usage

const { prompter } = require("git-cz");

// Custom implementation
const customCommit = (message) => {
  console.log("Generated commit message:");
  console.log(message);
  // Custom logic here instead of git commit
};

// Mock Commitizen instance
const mockCz = {};

prompter(mockCz, customCommit);

Integration with Other Tools

const { prompter } = require("git-cz");

// Integration with git workflow tools
const handleCommit = async (message) => {
  // Pre-commit processing
  await runLinting();
  await runTests();
  
  // Execute git commit
  execSync(`git commit -m "${message}"`);
  
  // Post-commit actions
  await updateChangelog();
};

prompter({}, handleCommit);

Configuration

The adapter respects all git-cz configuration options loaded from:

  • .git-cz.json
  • changelog.config.js
  • changelog.config.cjs
  • changelog.config.json
  • package.json (in config.commitizen.changelog)

Example configuration:

{
  "config": {
    "commitizen": {
      "path": "./node_modules/git-cz",
      "changelog": {
        "disableEmoji": false,
        "format": "{type}{scope}: {emoji}{subject}",
        "maxMessageLength": 64,
        "minMessageLength": 3,
        "scopes": ["auth", "api", "ui", "docs"],
        "types": {
          "feat": {
            "description": "A new feature",
            "emoji": "🎸",
            "value": "feat"
          }
        }
      }
    }
  }
}