forked from commitizen/cz-conventional-changelog
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from atlassian/jonelson/autocomplete-prompting
Autocomplete prompting
- Loading branch information
Showing
5 changed files
with
198 additions
and
48 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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function autoCompleteSource(options) { | ||
return (answersSoFar, input) => { | ||
return new Promise((resolve) => { | ||
const matches = options.filter(({ name }) => (!input || name.toLowerCase().indexOf(input.toLowerCase()) === 0)); | ||
resolve( | ||
matches | ||
); | ||
}); | ||
}; | ||
} | ||
|
||
export default function (questions) { | ||
return questions.map(question => Object.assign(question, question.type === 'autocomplete' ? { | ||
source: autoCompleteSource(question.choices), | ||
} : {})); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import Promise from 'promise'; | ||
|
||
module.exports = (allPackages, changedPackages) => ([ | ||
{ | ||
type: 'autocomplete', | ||
name: 'type', | ||
message: 'Select the type of change that you\'re committing:', | ||
choices: [ | ||
{value: 'feat', name: 'feat: ✨ A new feature (note: this will indicate a release)'}, | ||
{value: 'fix', name: 'fix: 🛠 A bug fix (note: this will indicate a release)'}, | ||
{value: 'docs', name: 'docs: Documentation only changes'}, | ||
{value: 'style', name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)'}, | ||
{value: 'refactor', name: 'refactor: A code change that neither fixes a bug nor adds a feature'}, | ||
{value: 'perf', name: 'perf: A code change that improves performance'}, | ||
{value: 'test', name: 'test: Adding missing tests'}, | ||
{value: 'chore', name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation'}, | ||
{value: 'revert', name: 'revert: Revert to a commit'}, | ||
{value: 'WIP', name: 'WIP: Work in progress'} | ||
], | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'scope', | ||
message: 'Denote the scope of this change:', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'subject', | ||
message: 'Write a short, imperative tense description of the change:\n', | ||
filter: function(value) { | ||
return value.charAt(0).toLowerCase() + value.slice(1); | ||
}, | ||
validate: function(value) { | ||
return !!value; | ||
}, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'body', | ||
message: 'Provide a longer description of the change (optional). Use "|" to break new line:\n' | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'breaking', | ||
message: 'List any BREAKING CHANGES (optional):\n', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'footer', | ||
message: 'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n', | ||
}, | ||
{ | ||
type: 'checkbox', | ||
name: 'packages', | ||
'default': changedPackages, | ||
choices: allPackages, | ||
message: `The packages that this commit has affected (${changedPackages.length} detected)\n`, | ||
// validate: function (input) { | ||
// const type = commitMessage.type; | ||
// const isRequired = ['feat', 'fix'].some((type) => messageHead.indexOf(type) === 0); | ||
// const isProvided = input.length > 0; | ||
// return isRequired ? (isProvided ? true : `Commit type "${type}" must affect at least one component`) : true; | ||
// } | ||
}, | ||
]); |
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