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 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) {
return [{
type: 'input',
@ -15,7 +29,7 @@ function getQuestions(options, username, contributions) {
name: 'contributions',
message: "What are the contribution types?",
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();
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 => {

View file

@ -25,7 +25,7 @@ test('should format contributor with complex contribution types', t => {
const contributor = contributors.kentcdodds;
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);
});

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 defaultTypes = {
blog: {symbol: '📝'},
blog: {
symbol: '📝',
description: 'Blogposts'
},
bug: {
symbol: '🐛',
description: 'Bug reports',
link: linkToIssues
},
code: {
symbol: '💻',
description: 'Code',
link: linkToCommits
},
design: {symbol: '🎨'},
design: {
symbol: '🎨',
description: 'Design'
},
doc: {
symbol: '📖',
description: 'Documentation',
link: linkToCommits
},
example: {symbol: '💡'},
plugin: {symbol: '🔌'},
question: {symbol: '❓'},
review: {symbol: '👀'},
talk: {symbol: '📢'},
example: {
symbol: '💡',
description: 'Examples'
},
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: {
symbol: '⚠️',
description: 'Tests',
link: linkToCommits
},
translation: {symbol: '🌍'},
tool: {symbol: '🔧'},
tutorial: {symbol: '✅'},
video: {symbol: '📹'}
translation: {
symbol: '🌍',
description: 'Translation'
},
tool: {
symbol: '🔧',
description: 'Tools'
},
tutorial: {
symbol: '✅',
description: 'Tutorials'
},
video: {
symbol: '📹',
description: 'Videos'
}
};
module.exports = function (options) {