-
-
Notifications
You must be signed in to change notification settings - Fork 11
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 #27 from JPeer264/feature/scope
Breaking Changes
- Loading branch information
Showing
22 changed files
with
428 additions
and
213 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,3 +1,6 @@ | ||
{ | ||
"presets": ["env"] | ||
"presets": ["env"], | ||
"plugins": [ | ||
["transform-object-rest-spread", { "useBuiltIns": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ coverage | |
|
||
# macOS | ||
.DS_STORE | ||
|
||
# IDE / Editors | ||
.vscode |
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
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
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,19 @@ | ||
const combineTypeScope = (type, scope) => { | ||
let thisType = type; | ||
|
||
const thisScope = scope || ''; | ||
|
||
// add scope correctly if ':' is at the end | ||
if (thisScope.length > 0) { | ||
if (thisType.charAt(thisType.length - 1) === ':') { | ||
thisType = thisType.slice(0, thisType.length - 1); | ||
thisType = `${thisType}${thisScope}:`; | ||
} else { | ||
thisType += thisScope; | ||
} | ||
} | ||
|
||
return thisType; | ||
}; | ||
|
||
export default combineTypeScope; |
This file was deleted.
Oops, something went wrong.
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,73 @@ | ||
import chalk from 'chalk'; | ||
import ruleWarningMessages from './rules/ruleWarningMessages'; | ||
import combineTypeScope from './helpers/combineTypeScope'; | ||
|
||
const choices = (config) => { | ||
const choicesList = []; | ||
|
||
config.types.forEach((type) => { | ||
const emoji = config.emoji && type.emoji ? `${type.emoji} ` : ''; | ||
const configType = type.type; | ||
const description = type.description || ''; | ||
|
||
choicesList.push({ | ||
value: emoji + configType, | ||
name: `${chalk.bold(configType)} ${description}`, | ||
}); | ||
}); | ||
|
||
return choicesList; | ||
}; | ||
|
||
const questions = (config) => { | ||
const choicesList = choices(config); | ||
const questionsList = [ | ||
{ | ||
type: 'list', | ||
name: 'type', | ||
message: 'Select the type of your commit:', | ||
choices: choicesList, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'scope', | ||
message: 'Enter your scope (no whitespaces allowed):', | ||
when: () => config.scope, | ||
validate: input => (input.match(/\s/) !== null ? 'No whitespaces allowed' : true), | ||
filter: input => (input ? `(${input})` : input), | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'description', | ||
message: 'Enter your commit message:', | ||
validate: (input) => { | ||
const warnings = ruleWarningMessages(input, config); | ||
|
||
return warnings || true; | ||
}, | ||
}, | ||
{ | ||
type: 'confirm', | ||
name: 'body', | ||
message: 'Do you want to add a body?', | ||
when: () => config.body, | ||
default: false, | ||
}, | ||
{ | ||
type: 'editor', | ||
name: 'editor', | ||
message: 'This will let you add more information', | ||
when: answers => answers.body, | ||
default: (answers) => { | ||
const type = combineTypeScope(answers.type, answers.scope); | ||
|
||
return `${type} ${answers.description}\n\n\n`; | ||
}, | ||
}, | ||
]; | ||
|
||
return questionsList; | ||
}; | ||
|
||
export default questions; | ||
export { choices }; |
Oops, something went wrong.