A CLI for semantic git commits
npm install semantic-git-commit-cli 



> A CLI to keep semantic git commits. With emoji support 😄 👍

Many projects got different git commit rules. It is hard to remember them all. Usually you start with git commit -m ", and then? You have to think about the projects commit guidelines.
sgc will take care of the commit guidelines, so you can focus on the more important stuff: code
``sh`
$ npm i -g semantic-git-commit-cli`
orsh`
$ yarn global add semantic-git-commit-cli
Forget the times when you used git commit -m "...", now just type:`sh`
$ sgc`
or if you already have an alias for sgc, use following instead:sh`
$ semantic-git-commit
> Note: if any block is added it will get skipped in the questions. If there are still some questions open they will still be asked
Available parameters:
- m | message: Add and skip the message blockt
- | type: Add and skip the type block (this has to be defined in the types as argKey)s
- | scope: Add and skip the scope block
To skip some questions you can add parameters:
Following:
`sh`
$ sgc -t feat -m some new features
Will generate: Feat: some new features
--
Following:
`sh`
$ sgc -t feat -s myScope -m some new features
Will generate: Feat(myScope): some new features
> Configure sgc for the following semantic-release options: analyzeCommits and generateNotes
First step, install the following plugins with
`sh`
$ npm install --save-dev sr-commit-analyzer sr-release-notes-generator conventional-changelog-eslint
or
`sh`
$ yarn add -D sr-commit-analyzer sr-release-notes-generator conventional-changelog-eslint
Then, create a release.config.js file in a config folder in the root folder of your project:`js`
/ eslint-disable no-useless-escape /
module.exports = {
analyzeCommits: {
preset: 'eslint',
releaseRules: './config/release-rules.js', // optional, only if you want to set up new/modified release rules inside another file
parserOpts: { // optional, only you want to have emoji commit support
headerPattern: /^(?::([\w-]):)?\s(\w):\s(.*)$/,
headerCorrespondence: [
'emoji',
'tag',
'message',
],
},
},
generateNotes: {
preset: 'eslint',
parserOpts: { // optional, only you want to have emoji commit support
headerPattern: /^(?::([\w-]):)?\s(\w):\s(.*)$/,
headerCorrespondence: [
'emoji',
'tag',
'message',
],
},
},
};
Then, update the semantic-release script to your package.json to this : `json`
"scripts": {
"semantic-release": "semantic-release -e ./config/release.config.js",
}
This will check all commits and will fail if your commits do not meet the defined config.
Flags
- start: A commit SHA to start, in case you started using sgc later of your development
`sh`
$ sgc check --start 84a1abd
> Just create a .sgcrc in your project root or you can add everything in your package.json with the value sgc
You can even create a global config. Just go to your users home and create a .sgcrc. The global config will be triggered if no project configurations are present.
The order and namings of the commit (this can vary with different settings):
`
Options:
- body
- scope
- emoji
- delimiter
- lowercaseTypes
- initialCommit
- types
- addScopeSpace
- rules
$3
Type:
booleanDefault:
trueAsks if more info (body) should be added. This will open your default editor.
Example:
`json
{
"body": false
}
`$3
Type:
booleanDefault:
falseAsks for the scope in parentheses of the commit.
Example:
`json
{
"scope": true
}
`$3
Type:
booleanDefault:
falseA boolean to enable emoji at the beginning of a commit message
Example:
`json
{
"emoji": true
}
`$3
Type:
stringDefault:
:A string which is the delimiter between the type and the message.
Example:
`json
{
"delimiter": ":"
}
`
or type specific delimiters, which will overwrite the global one:
`json5
{
"delimiter": ":",
"types": [
{
"type": "Feat",
"delimiter": " -"
}, // will generate "Feat - message"
{
"type": "Fix",
} // will generate "Fix: message"
]
}
`$3
Type:
booleanDefault:
falseA boolean to lowercase types.
Example:
`json
{
"lowercaseTypes": true
}
`$3
Type:
objectDefault:
`json
{
"initialCommit": {
"isEnabled": true,
"emoji": ":tada:",
"message": "Initial commit"
}
}
`Keys:
-
isEnabled - Whether an explicit initial commit should be used for the very first commit
- emoji - An emoji which will be appended at the beginning of the commit (Emoji Cheat Sheet)
- message - The commit message for the very first commit$3
> Types will define your git commits. If
types is not set in your own .sgcrc, the types of the global .sgcrc> Notice: If the
type is false it will let you to manually add the type. This is usefull especially if you have a prefix named SGC- to reference these as a ticket number for your ticket toolKeys
-
type (string or false) - This will be your commit convention and will be your start of your commit - e.g.: Feat:
- prefix (optional) - This option is just valid, if type is false
- description (optional) - The description to explain what your type is about
- emoji (optional) - An emoji which will be appended at the beginning of the commit (Emoji Cheat Sheet)
- argKeys | Array (optional) - Keys which will be accessed through the -t parameterThe
.sgcrc:`json
{
"types": [
{
"emoji": ":sparkles:",
"type": "Feat:",
"description": "Any description to describe the type",
"argKeys": ["f", "feat", "feature"]
}
]
}
`or the
package.json:`json
{
"name": "Your application name",
"version": "1.0.0",
"sgc": {
"types": [
{
"emoji": ":sparkles:",
"type": "Feat:",
"description": "Any description to describe the type",
"argKeys": ["f", "feat", "feature"]
}
]
}
}
`$3
Type:
booleanDefault:
true> This rule just affects the commit message if
scope is set to trueIf set to
false there will be no space between and (Example:
`json
{
"addScopeSpace": false
}
`
$3
Available rules:
- maxChar
- minChar
- endWithDot
#### maxChar
Type:
numberDefault:
72If a number is set, it will not allow to commit messages more than the given number. If it is set to
-1 the rule is deactivatedExample:
`json
{
"rules": {
"maxChar": -1
}
}
`#### minChar
Type:
numberDefault:
10If a number is set, it will not allow to commit messages less than the given number. If it is set to
-1 the rule is deactivatedExample:
`json
{
"rules": {
"minChar": -1
}
}
`#### endWithDot
Type:
booleanDefault:
trueIf it is set to false, it will not allow to commit messages with a dot at the
Example:
`json
{
"rules": {
"endWithDot": false
}
}
``