Interactive commit message prompt CLI using commitlint configuration rules
npx @tessl/cli install tessl/npm-commitlint--prompt-cli@19.8.0Interactive commit message prompt CLI that uses commitlint configuration rules to guide users in creating compliant commit messages. The tool integrates with git to provide a structured, rule-based commit workflow.
npm install -g @commitlint/prompt-cli @commitlint/config-angularGlobal installation with a commitlint configuration:
npm install -g @commitlint/prompt-cli @commitlint/config-angular
echo "export default {extends: ['@commitlint/config-angular']};" > commitlint.config.jsThe package provides a single commit command that replaces the standard git commit workflow:
# Stage your changes
git add .
# Use interactive commit prompt
commitThe command will:
git commit with the formatted messageThe primary functionality provided through the commit binary command.
commit
# Exit codes:
# 0 - Success (commit created)
# 1 - No staged changes or other errorBehavior:
git commit -m "<formatted_message>" upon completionRequirements:
commitlint.config.js)Dependencies:
@commitlint/prompt for interactive prompting functionalityinquirer for command-line user interfacetinyexec for git command executionThe tool relies on commitlint configuration files to determine commit message rules and structure. Common configuration approaches:
Using preset configuration:
// commitlint.config.js
export default {
extends: ['@commitlint/config-angular']
};Custom configuration:
// commitlint.config.js
export default {
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']],
'subject-max-length': [2, 'always', 50],
'header-max-length': [2, 'always', 72]
}
};The CLI handles several error scenarios:
git diff --cached to check for staged changesgit commit -m <message> to create commits@commitlint/load@commitlint/prompt for interactive prompting based on loaded rulesBasic workflow:
git add .
commit
# Follow interactive promptsWith specific commitlint config:
# Install with desired config preset
npm install -g @commitlint/prompt-cli @commitlint/config-conventional
# Create config file
echo "export default {extends: ['@commitlint/config-conventional']};" > commitlint.config.js
# Use normally
git add .
commitIntegration in package.json:
{
"scripts": {
"commit": "commit"
},
"devDependencies": {
"@commitlint/prompt-cli": "^19.8.1",
"@commitlint/config-angular": "^19.8.1"
}
}commit binary commandgit commit in developer workflows