git formatted commit message
Tool for executing a git commit with a defined template. All commits in the repository will have the same structure.
Install and add to devDependencies
:
npm:
$ npm install --save-dev git-fcm
or yarn:
$ yarn add -D git-fcm
Add an npm run
script to your package.json:
{
"scripts": {
"commit": "git-fcm"
}
}
Now you can use npm run commit
or yarn commit
.
Install globally (add to your PATH
):
npm:
npm i -g git-fcm
or yarn:
$ yarn global add git-fcm
Now you can use git-fcm
on any repo/package without adding a dev dependency to each one and without command npm run
.
Insert template into .gfc.json
file.
{
"templateLines": [ //TemplateLine[]. Array of template lines
{
"description": "", //Description of line
"lineFields": [ //fields on the line
{
"name": "", //name of field
"type": "", //one of type: text, select, constText
"startString": "", //text added at the beginning of field
"endString": "", //text added at the end of field
"question": "", //question to display
"description": "", //description
"data": {}, //currently not use, not required
"minLength": 0, //Min length of input text, not required
"maxLength": 0, //Max length of input text, not required
"options": { //not required
"addStartStringWhenEmpty": true, //add text from the 'startString' field if the text for this line is empty
"addEndStringWhenEmpty": true, //add text from the 'endString' field if the text for this line is empty
}
}//,{...}
],
"startString": "", //text added at the beginning of the line. not required
"endString": "", //text added at the end of the line. not required
"options": { //not required
"addStartStringWhenEmpty": true, //add text from the 'startString' field if the text for this line is empty
"addEndStringWhenEmpty": true, //add text from the 'endString' field if the text for this line is empty
}
}//,{...}
],
"options": { //not required
"addStartStringWhenEmpty": true, //add text from the 'startString' field if the text from input or the whole line is empty
"addEndStringWhenEmpty": true, //add text from the 'endString' field if the text from input or the whole line is empty
}
}
In template, templateLines and templateFields you can set options:
- addStartStringWhenEmpty - add text from the
startString
field if the text from input or the whole line is empty. If this options is set in main object refers to the entire template. If you set this options intemplateLines
ortemplateField
this options refers to specifictemplateLines
ortemplateField
. Defaulttrue
. - addEndStringWhenEmpty - add text from the
endString
field if the text from input or the whole line is empty. If this options is set in main object refers to the entire template. If you set this options intemplateLines
ortemplateField
this options refers to specifictemplateLines
ortemplateField
. Defaulttrue
.
{
"templateLines": [
{
"description": "subject",
"lineFields": [
{
"name": "type",
"type": "select",
"startString": "",
"endString": "",
"question": "Commit type:",
"description": "",
"data": [
"fix",
"feat",
"build",
"ci",
"docs",
"perf",
"refactor",
"style",
"test"
]
},
{
"name": "scope",
"type": "text",
"startString": "(",
"endString": "):",
"question": "Scope:",
"description": "Scope of affected module.",
"data": []
},
{
"name": "message",
"type": "text",
"startString": " ",
"endString": "",
"question": "Commit message:",
"description": "Message of commit",
"data": []
}
]
},
{
"description": "body",
"startString": "\r\n\r\n",
"lineFields": [
{
"name": "description",
"type": "text",
"startString": "",
"endString": "",
"question": "Description:",
"description": "Just as in the subject, use the imperative, present tense: 'change' not 'changed' nor 'changes'.\nThe body should include the motivation for the change and contrast this with previous behavior.",
"data": []
}
]
},
{
"description": "footer",
"startString": "\r\n\r\n",
"lineFields": [
{
"name": "description",
"type": "text",
"startString": "",
"endString": "",
"question": "Footer:",
"description": "The footer should contain any information about Breaking Changes and is also the place to reference GitHub issues that this commit Closes. \nBreaking Changes should start with the word BREAKING CHANGE: with a space or two newlines. \nThe rest of the commit message is then used for this.",
"data": []
}
]
}
],
"options": {
"addStartStringWhenEmpty": false,
"addEndStringWhenEmpty": false
}
}
- print logo
- load template
- select input
- standard input
- build commit
- add description line
- add task id line
- call git commit
- build bin
- update Readme file - add info how to use this tools and template example
- add default template
- minimal and maximum number of characters
- npm publish
- add option to conditionally add text at the begining of the line
- describe all possible fields appearing in the template
- add ctrl+c or ESC to cancel
- multiline text
- ... more
https://github.com/anseki/readline-sync - synchronous Readline https://github.com/sindresorhus/ora - terminal spiner https://github.com/chalk/chalk - text styling https://github.com/bokub/gradient-string - text with gradient https://github.com/reactivex/rxjs - a reactive programming library for JavaScript https://github.com/steveukx/git-js - interface for running git commands