From f2822dcc8a8d50d3633a580d8709a3cfb97cb902 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 31 Mar 2016 11:00:02 +0200 Subject: [PATCH] Add emojis and description in contribution type prompt --- lib/contributors/prompt.js | 16 +++++- lib/generate/formatContributionType.test.js | 2 +- lib/generate/formatContributor.test.js | 2 +- lib/util/contributionTypes.js | 63 +++++++++++++++++---- 4 files changed, 69 insertions(+), 14 deletions(-) diff --git a/lib/contributors/prompt.js b/lib/contributors/prompt.js index 93f45e1..b02d675 100644 --- a/lib/contributors/prompt.js +++ b/lib/contributors/prompt.js @@ -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) }]; } diff --git a/lib/generate/formatContributionType.test.js b/lib/generate/formatContributionType.test.js index c963390..4dd2fce 100644 --- a/lib/generate/formatContributionType.test.js +++ b/lib/generate/formatContributionType.test.js @@ -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 => { diff --git a/lib/generate/formatContributor.test.js b/lib/generate/formatContributor.test.js index b4bdc39..62c139b 100644 --- a/lib/generate/formatContributor.test.js +++ b/lib/generate/formatContributor.test.js @@ -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)
Kent C. Dodds](http://kentcdodds.com)
[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) 👀 ❓'; + const expected = '[![Kent C. Dodds](https://avatars1.githubusercontent.com/u/1500684?s=150)
Kent C. Dodds](http://kentcdodds.com)
[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) 👀 💁'; t.is(formatContributor(options, contributor), expected); }); diff --git a/lib/util/contributionTypes.js b/lib/util/contributionTypes.js index bddfbb0..815d83a 100644 --- a/lib/util/contributionTypes.js +++ b/lib/util/contributionTypes.js @@ -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) {