This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
forked from streamich/git-cz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for lerna mono-repos
If the project is a lerna mono-repo it will add an extra question about the packages the commit affected
- Loading branch information
Showing
12 changed files
with
3,458 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
*.log | ||
*.swo | ||
*.swp | ||
.DS_Store | ||
.idea/ | ||
node_modules/ | ||
npm-debug.log | ||
yarn.lock | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
6 | ||
8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,3 @@ | ||
'use strict'; | ||
const {prompter} = require('./src/index'); | ||
|
||
const inquirer = require('inquirer'); | ||
const wrap = require('word-wrap'); | ||
|
||
inquirer.registerPrompt('limitedInput', require('./prompt/LimitedInput')); | ||
|
||
const MAX_SUBJECT_LENGTH = 50; | ||
const MAX_LINE_WIDTH = 72; | ||
const MIN_SUBJECT_LENGTH = 3; | ||
const MIN_SUBJECT_LENGTH_ERROR_MESSAGE = `The subject must have at least ${MIN_SUBJECT_LENGTH} characters`; | ||
|
||
module.exports = { | ||
prompter (cz, commit) { | ||
return inquirer.prompt([ | ||
{ | ||
choices: [ | ||
{ | ||
name: 'feat: A new feature', | ||
value: 'feat' | ||
}, | ||
{ | ||
name: 'fix: A bug fix', | ||
value: 'fix' | ||
}, | ||
{ | ||
name: 'docs: Documentation only changes', | ||
value: 'docs' | ||
}, | ||
{ | ||
name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)', | ||
value: 'style' | ||
}, | ||
{ | ||
name: 'refactor: A code change that neither fixes a bug or adds a feature', | ||
value: 'refactor' | ||
}, | ||
{ | ||
name: 'perf: A code change that improves performance', | ||
value: 'perf' | ||
}, | ||
{ | ||
name: 'test: Adding missing tests', | ||
value: 'test' | ||
}, | ||
{ | ||
name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation', | ||
value: 'chore' | ||
} | ||
], | ||
message: 'Select the type of change that you\'re committing:', | ||
name: 'type', | ||
type: 'list' | ||
}, | ||
{ | ||
filter: (input) => { | ||
let subject; | ||
|
||
subject = input.trim(); | ||
while (subject.endsWith('.')) { | ||
subject = subject.substr(0, subject.length - 1).trim(); | ||
} | ||
|
||
return subject; | ||
}, | ||
leadingLabel: (answers) => `${answers.type}:`, | ||
maxLength: MAX_SUBJECT_LENGTH, | ||
message: 'Write a short, imperative mood description of the change:', | ||
name: 'subject', | ||
type: 'limitedInput', | ||
validate: (input) => input.length >= MIN_SUBJECT_LENGTH || MIN_SUBJECT_LENGTH_ERROR_MESSAGE | ||
}, | ||
{ | ||
message: 'Provide a longer description of the change:\n', | ||
name: 'body', | ||
type: 'input' | ||
}, | ||
{ | ||
message: 'List any breaking changes:\n BREAKING CHANGE:', | ||
name: 'breaking', | ||
type: 'input' | ||
}, | ||
{ | ||
message: 'Reference any task that this commit closes:\n Issues:', | ||
name: 'footer', | ||
type: 'input' | ||
} | ||
]) | ||
.then((answers) => { | ||
const wrapOptions = { | ||
indent: '', | ||
trim: true, | ||
width: MAX_LINE_WIDTH | ||
}; | ||
|
||
const head = answers.type + ': ' + answers.subject; | ||
|
||
// Wrap these lines at MAX_LINE_WIDTH characters | ||
const body = wrap(answers.body, wrapOptions); | ||
const breaking = wrap(answers.breaking, wrapOptions); | ||
const footer = wrap(answers.footer, wrapOptions); | ||
|
||
let msg; | ||
|
||
msg = head; | ||
|
||
if (body) { | ||
msg += '\n\n' + body; | ||
} | ||
|
||
if (breaking) { | ||
msg += '\n\nBREAKING CHANGE: ' + breaking; | ||
} | ||
|
||
if (footer) { | ||
msg += '\n\nIssues: ' + footer; | ||
} | ||
|
||
return commit(msg); | ||
}); | ||
} | ||
}; | ||
module.exports = {prompter}; |
Oops, something went wrong.