Skip to content

Commit d40ac2c

Browse files
jlengstorfjimthedev
authored andcommitted
feat(prompt): add confirmation fields + edit for clarity (#58)
* chore(config): switch czConfig to config * feat(prompts): add confirm and clarify language Breaking changes and issues now have confirm fields to ensure answers like "no" and "n/a" don’t accidentally create breaking changes. Updated language around scopes to be less confusing for non-Angular devs. Added examples for issue references/closing. fix #52 * fix(engine): remove unhandled Promise rejection handler This was for debugging and should not have been committed. * refactor: clean up grammar and punctuation
1 parent f7a770e commit d40ac2c

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

engine.js

+22-6
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,39 @@ module.exports = function (options) {
5757
}, {
5858
type: 'input',
5959
name: 'scope',
60-
message: 'Denote the scope of this change ($location, $browser, $compile, etc.):\n'
60+
message: 'What is the scope of this change (e.g. component or file name)? (press enter to skip)\n'
6161
}, {
6262
type: 'input',
6363
name: 'subject',
6464
message: 'Write a short, imperative tense description of the change:\n'
6565
}, {
6666
type: 'input',
6767
name: 'body',
68-
message: 'Provide a longer description of the change:\n'
68+
message: 'Provide a longer description of the change: (press enter to skip)\n'
69+
}, {
70+
type: 'confirm',
71+
name: 'isBreaking',
72+
message: 'Are there any breaking changes?',
73+
default: false
6974
}, {
7075
type: 'input',
7176
name: 'breaking',
72-
message: 'List any breaking changes:\n'
77+
message: 'Describe the breaking changes:\n',
78+
when: function(answers) {
79+
return answers.isBreaking;
80+
}
81+
}, {
82+
type: 'confirm',
83+
name: 'isIssueAffected',
84+
message: 'Does this change affect any open issues?',
85+
default: false
7386
}, {
7487
type: 'input',
7588
name: 'issues',
76-
message: 'List any issues closed by this change:\n'
89+
message: 'Add issue references (e.g. "fix #123", "re #123".):\n',
90+
when: function(answers) {
91+
return answers.isIssueAffected;
92+
}
7793
}
7894
]).then(function(answers) {
7995

@@ -97,11 +113,11 @@ module.exports = function (options) {
97113
var body = wrap(answers.body, wrapOptions);
98114

99115
// Apply breaking change prefix, removing it if already present
100-
var breaking = answers.breaking.trim();
116+
var breaking = answers.breaking ? answers.breaking.trim() : '';
101117
breaking = breaking ? 'BREAKING CHANGE: ' + breaking.replace(/^BREAKING CHANGE: /, '') : '';
102118
breaking = wrap(breaking, wrapOptions);
103119

104-
var issues = wrap(answers.issues, wrapOptions);
120+
var issues = answers.issues ? wrap(answers.issues, wrapOptions) : '';
105121

106122
var footer = filter([ breaking, issues ]).join('\n\n');
107123

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"commitizen": "2.9.6",
2727
"semantic-release": "^6.3.2"
2828
},
29-
"czConfig": {
30-
"path": "./"
29+
"config": {
30+
"commitizen" : {
31+
"path": "./index.js"
32+
}
3133
}
3234
}

0 commit comments

Comments
 (0)