The core function that initializes the commitizen adapter with configuration loading and interactive prompts.
Main entry point for the commitizen adapter that orchestrates the entire commit message generation flow.
/**
* Main entry point for commitizen adapter
* @param cz - Commitizen instance providing prompt registration and execution
* @param commit - Callback function to execute the commit with generated message
* @param configPath - Optional path to configuration file
*/
function prompter(
cz: CommitizenType,
commit: (message: string) => void,
configPath?: string
): void;
interface CommitizenType {
/** Register custom prompt types */
registerPrompt: (type: string, plugin: unknown) => void;
/** Execute interactive prompts */
prompt: (qs: QuestionsType) => Promise<Answers>;
}Usage Examples:
import { prompter } from "cz-git";
// Basic usage as commitizen adapter
function setupCommitizen(cz, commit) {
prompter(cz, commit);
}
// With custom configuration path
function setupWithConfig(cz, commit) {
prompter(cz, commit, './custom-cz.config.js');
}Functions that handle the internal flow of the prompter after configuration is loaded.
/**
* Generate confirmation prompt for commit message
* @param options - Configuration options
* @param cz - Commitizen instance
* @param answers - Current answers from prompts
* @returns Updated answers with confirmation
*/
function generateConfirmPrompt(
options: CommitizenGitOptions,
cz: CommitizenType,
answers: Answers
): Promise<Answers>;
/**
* Handle final commit message confirmation and execution
* @param options - Configuration options
* @param cz - Commitizen instance
* @param answers - All collected answers
* @param commit - Commit callback function
*/
function confirmMessage(
options: CommitizenGitOptions,
cz: CommitizenType,
answers: Answers,
commit: (message: string) => void
): Promise<void>;Environment variables that affect prompter behavior:
interface EnvironmentVariables {
/** Set to '1' to enable GPG signing */
CZCommitSignGPG?: string;
/** Alias for direct commit message generation */
cz_alias?: string;
/** Enable debug logging */
CZ_DEBUG?: string;
}Usage Examples:
# Use alias for quick commits
cz_alias=fd cz
# Enable GPG signing
CZCommitSignGPG=1 cz
# Enable debug mode
CZ_DEBUG=1 czThe confirmation prompt provides multiple options for handling the generated commit message:
interface ConfirmationChoices {
yes: 'yes';
no: 'no';
edit: 'edit';
'ai-modify': 'ai-modify'; // Only available when useAI is enabled
}The prompter function integrates seamlessly with commitizen by:
search-list, search-checkbox, complete-input)The entire process is asynchronous and handles errors gracefully, providing user feedback throughout the interaction.