Add emojis and description in contribution type prompt

This commit is contained in:
Jeroen Engels 2016-03-31 11:00:02 +02:00
parent 03a465602c
commit f2822dcc8a
4 changed files with 69 additions and 14 deletions

View file

@ -4,6 +4,20 @@ var _ = require('lodash/fp');
var inquirer = require('inquirer'); var inquirer = require('inquirer');
var util = require('../util'); var util = require('../util');
var contributionChoices = _.flow(
util.contributionTypes,
_.toPairs,
_.sortBy(function (pair) {
return pair[1].description;
}),
_.map(function (pair) {
return {
name: pair[1].symbol + ' ' + pair[1].description,
value: pair[0]
};
})
);
function getQuestions(options, username, contributions) { function getQuestions(options, username, contributions) {
return [{ return [{
type: 'input', type: 'input',
@ -15,7 +29,7 @@ function getQuestions(options, username, contributions) {
name: 'contributions', name: 'contributions',
message: "What are the contribution types?", message: "What are the contribution types?",
when: !contributions, when: !contributions,
choices: Object.keys(util.contributionTypes(options)) choices: contributionChoices(options)
}]; }];
} }

View file

@ -16,7 +16,7 @@ test('should return corresponding symbol', t => {
const {options} = fixtures(); const {options} = fixtures();
t.is(formatContributionType(options, contributor, 'tool'), '🔧'); t.is(formatContributionType(options, contributor, 'tool'), '🔧');
t.is(formatContributionType(options, contributor, 'question'), ''); t.is(formatContributionType(options, contributor, 'question'), '💁');
}); });
test('should return link to commits', t => { test('should return link to commits', t => {

View file

@ -25,7 +25,7 @@ test('should format contributor with complex contribution types', t => {
const contributor = contributors.kentcdodds; const contributor = contributors.kentcdodds;
const {options} = fixtures(); const {options} = fixtures();
const expected = '[![Kent C. Dodds](https://avatars1.githubusercontent.com/u/1500684?s=150)<br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) 👀 '; const expected = '[![Kent C. Dodds](https://avatars1.githubusercontent.com/u/1500684?s=150)<br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) 👀 💁';
t.is(formatContributor(options, contributor), expected); t.is(formatContributor(options, contributor), expected);
}); });

View file

@ -6,33 +6,74 @@ var linkToCommits = 'https://github.com/<%= options.projectOwner %>/<%= options.
var linkToIssues = 'https://github.com/<%= options.projectOwner %>/<%= options.projectName %>/issues?q=author%3A<%= contributor.login %>'; var linkToIssues = 'https://github.com/<%= options.projectOwner %>/<%= options.projectName %>/issues?q=author%3A<%= contributor.login %>';
var defaultTypes = { var defaultTypes = {
blog: {symbol: '📝'}, blog: {
symbol: '📝',
description: 'Blogposts'
},
bug: { bug: {
symbol: '🐛', symbol: '🐛',
description: 'Bug reports',
link: linkToIssues link: linkToIssues
}, },
code: { code: {
symbol: '💻', symbol: '💻',
description: 'Code',
link: linkToCommits link: linkToCommits
}, },
design: {symbol: '🎨'}, design: {
symbol: '🎨',
description: 'Design'
},
doc: { doc: {
symbol: '📖', symbol: '📖',
description: 'Documentation',
link: linkToCommits link: linkToCommits
}, },
example: {symbol: '💡'}, example: {
plugin: {symbol: '🔌'}, symbol: '💡',
question: {symbol: '❓'}, description: 'Examples'
review: {symbol: '👀'}, },
talk: {symbol: '📢'}, infra: {
symbol: '🚇',
description: 'Infrastructure (Hosting, Build-Tools, etc)'
},
plugin: {
symbol: '🔌',
description: 'Plugin/utility libraries'
},
question: {
symbol: '💁',
description: 'Answering Questions'
},
review: {
symbol: '👀',
description: 'Reviewed Pull Requests'
},
talk: {
symbol: '📢',
description: 'Talks'
},
test: { test: {
symbol: '⚠️', symbol: '⚠️',
description: 'Tests',
link: linkToCommits link: linkToCommits
}, },
translation: {symbol: '🌍'}, translation: {
tool: {symbol: '🔧'}, symbol: '🌍',
tutorial: {symbol: '✅'}, description: 'Translation'
video: {symbol: '📹'} },
tool: {
symbol: '🔧',
description: 'Tools'
},
tutorial: {
symbol: '✅',
description: 'Tutorials'
},
video: {
symbol: '📹',
description: 'Videos'
}
}; };
module.exports = function (options) { module.exports = function (options) {