diff --git a/.all-contributorsrc b/.all-contributorsrc index 37600e67..eacb57d0 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -71,6 +71,15 @@ "contributions": [ "code" ] + }, + { + "login": "kevinjalbert", + "name": "Kevin Jalbert", + "avatar_url": "https://avatars1.githubusercontent.com/u/574871?v=3", + "profile": "https://github.com/kevinjalbert", + "contributions": [ + "code" + ] } ] } diff --git a/README.md b/README.md index e698269b..d2f930c1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # all-contributors-cli [![version](https://img.shields.io/npm/v/all-contributors-cli.svg)](http://npm.im/all-contributors-cli) -[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors) This is a tool to help automate adding contributor acknowledgements according to the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. @@ -93,8 +93,9 @@ These are the keys you can specify: Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): -| [
Jeroen Engels](https://github.com/jfmengels)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) [πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) | [
Kent C. Dodds](http://kentcdodds.com/)
[πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) [πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) | [
JoΓ£o GuimarΓ£es](https://github.com/jccguimaraes)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=jccguimaraes) | [
Ben Briggs](http://beneb.info)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=ben-eb) | [
Itai Steinherz](https://github.com/itaisteinherz)
[πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz) [πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz) | [
Alex Jover](https://github.com/alexjoverm)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm) [πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm) | [
Jerod Santo](https://jerodsanto.net)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=jerodsanto) | +| [
Jeroen Engels](https://github.com/jfmengels)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels "Code") [πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels "Documentation") [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels "Tests") | [
Kent C. Dodds](http://kentcdodds.com/)
[πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds "Documentation") [πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds "Code") | [
JoΓ£o GuimarΓ£es](https://github.com/jccguimaraes)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=jccguimaraes "Code") | [
Ben Briggs](http://beneb.info)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=ben-eb "Code") | [
Itai Steinherz](https://github.com/itaisteinherz)
[πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz "Documentation") [πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz "Code") | [
Alex Jover](https://github.com/alexjoverm)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm "Code") [πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm "Documentation") | [
Jerod Santo](https://jerodsanto.net)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=jerodsanto "Code") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| [
Kevin Jalbert](https://github.com/kevinjalbert)
[πŸ’»](https://github.com/jfmengels/all-contributors-cli/commits?author=kevinjalbert "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. diff --git a/lib/generate/format-contribution-type.js b/lib/generate/format-contribution-type.js index d4778eb9..c222762a 100644 --- a/lib/generate/format-contribution-type.js +++ b/lib/generate/format-contribution-type.js @@ -3,7 +3,7 @@ var _ = require('lodash/fp'); var util = require('../util'); -var linkTemplate = _.template('[<%= symbol %>](<%= url %>)'); +var linkTemplate = _.template('[<%= symbol %>](<%= url %> "<%= description %>")'); function getType(options, contribution) { var types = util.contributionTypes(options); @@ -19,15 +19,17 @@ module.exports = function formatContribution(options, contributor, contribution) var templateData = { symbol: type.symbol, + description: type.description, contributor: contributor, options: options }; + + var url = `#${contribution}-${contributor.login}`; if (contribution.url) { - return linkTemplate(_.assign({url: contribution.url}, templateData)); - } - if (type.link) { - var url = _.template(type.link)(templateData); - return linkTemplate(_.assign({url: url}, templateData)); + url = contribution.url; + } else if (type.link) { + url = _.template(type.link)(templateData); } - return type.symbol; + + return linkTemplate(_.assign({url: url}, templateData)); }; diff --git a/lib/generate/format-contribution-type.test.js b/lib/generate/format-contribution-type.test.js index c3bdd046..1d616de2 100644 --- a/lib/generate/format-contribution-type.test.js +++ b/lib/generate/format-contribution-type.test.js @@ -15,24 +15,24 @@ test('should return corresponding symbol', t => { const contributor = contributors.kentcdodds; const {options} = fixtures(); - t.is(formatContributionType(options, contributor, 'tool'), 'πŸ”§'); - t.is(formatContributionType(options, contributor, 'question'), 'πŸ’¬'); + t.is(formatContributionType(options, contributor, 'tool'), '[πŸ”§](#tool-kentcdodds "Tools")'); + t.is(formatContributionType(options, contributor, 'question'), '[πŸ’¬](#question-kentcdodds "Answering Questions")'); }); test('should return link to commits', t => { const contributor = contributors.kentcdodds; const {options} = fixtures(); - const expectedLink = '(https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds)'; + const expectedLink = 'https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds'; - t.is(formatContributionType(options, contributor, 'code'), '[πŸ’»]' + expectedLink); - t.is(formatContributionType(options, contributor, 'doc'), '[πŸ“–]' + expectedLink); - t.is(formatContributionType(options, contributor, 'test'), '[⚠️]' + expectedLink); + t.is(formatContributionType(options, contributor, 'code'), '[πŸ’»](' + expectedLink + ' "Code")'); + t.is(formatContributionType(options, contributor, 'doc'), '[πŸ“–](' + expectedLink + ' "Documentation")'); + t.is(formatContributionType(options, contributor, 'test'), '[⚠️](' + expectedLink + ' "Tests")'); }); test('should return link to issues', t => { const contributor = contributors.kentcdodds; const {options} = fixtures(); - const expected = '[πŸ›](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3Akentcdodds)'; + const expected = '[πŸ›](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3Akentcdodds "Bug reports")'; t.is(formatContributionType(options, contributor, 'bug'), expected); }); @@ -45,7 +45,7 @@ test('should make any symbol into a link if contribution is an object', t => { url: 'www.foo.bar' }; - t.is(formatContributionType(options, contributor, contribution), '[πŸ”§](www.foo.bar)'); + t.is(formatContributionType(options, contributor, contribution), '[πŸ”§](www.foo.bar "Tools")'); }); test('should override url for given types', t => { @@ -56,7 +56,7 @@ test('should override url for given types', t => { url: 'www.foo.bar' }; - t.is(formatContributionType(options, contributor, contribution), '[πŸ’»](www.foo.bar)'); + t.is(formatContributionType(options, contributor, contribution), '[πŸ’»](www.foo.bar "Code")'); }); test('should be able to add types to the symbol list', t => { @@ -66,11 +66,11 @@ test('should be able to add types to the symbol list', t => { cheerful: {symbol: ':smiley:'} }; - t.is(formatContributionType(options, contributor, 'cheerful'), ':smiley:'); + t.is(formatContributionType(options, contributor, 'cheerful'), '[:smiley:](#cheerful-kentcdodds "")'); t.is(formatContributionType(options, contributor, { type: 'cheerful', url: 'www.foo.bar' - }), '[:smiley:](www.foo.bar)'); + }), '[:smiley:](www.foo.bar "")'); }); test('should be able to add types with template to the symbol list', t => { @@ -83,7 +83,7 @@ test('should be able to add types with template to the symbol list', t => { } }; - t.is(formatContributionType(options, contributor, 'web'), '[:web:](www.kentcdodds.com)'); + t.is(formatContributionType(options, contributor, 'web'), '[:web:](www.kentcdodds.com "")'); }); test('should be able to override existing types', t => { @@ -93,11 +93,11 @@ test('should be able to override existing types', t => { code: {symbol: ':smiley:'} }; - t.is(formatContributionType(options, contributor, 'code'), ':smiley:'); + t.is(formatContributionType(options, contributor, 'code'), '[:smiley:](#code-kentcdodds "")'); t.is(formatContributionType(options, contributor, { type: 'code', url: 'www.foo.bar' - }), '[:smiley:](www.foo.bar)'); + }), '[:smiley:](www.foo.bar "")'); }); test('should be able to override existing templates', t => { @@ -110,11 +110,11 @@ test('should be able to override existing templates', t => { } }; - t.is(formatContributionType(options, contributor, 'code'), '[:web:](www.kentcdodds.com)'); + t.is(formatContributionType(options, contributor, 'code'), '[:web:](www.kentcdodds.com "")'); t.is(formatContributionType(options, contributor, { type: 'code', url: 'www.foo.bar' - }), '[:web:](www.foo.bar)'); + }), '[:web:](www.foo.bar "")'); }); test('should throw a helpful error on unknown type', t => { diff --git a/lib/generate/format-contributor.test.js b/lib/generate/format-contributor.test.js index f9d29a96..3a8c303a 100644 --- a/lib/generate/format-contributor.test.js +++ b/lib/generate/format-contributor.test.js @@ -16,7 +16,7 @@ test('should format a simple contributor', t => { const contributor = _.assign(contributors.kentcdodds, {contributions: ['review']}); const {options} = fixtures(); - const expected = '[
Kent C. Dodds](http://kentcdodds.com)
πŸ‘€'; + const expected = '[
Kent C. Dodds](http://kentcdodds.com)
[πŸ‘€](#review-kentcdodds "Reviewed Pull Requests")'; t.is(formatContributor(options, contributor), expected); }); @@ -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](http://kentcdodds.com)
[πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) πŸ‘€ πŸ’¬'; + const expected = '[
Kent C. Dodds](http://kentcdodds.com)
[πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds "Documentation") [πŸ‘€](#review-kentcdodds "Reviewed Pull Requests") [πŸ’¬](#question-kentcdodds "Answering Questions")'; t.is(formatContributor(options, contributor), expected); }); @@ -45,7 +45,7 @@ test('should default image size to 100', t => { const {options} = fixtures(); delete options.imageSize; - const expected = '[
Kent C. Dodds](http://kentcdodds.com)
πŸ‘€'; + const expected = '[
Kent C. Dodds](http://kentcdodds.com)
[πŸ‘€](#review-kentcdodds "Reviewed Pull Requests")'; t.is(formatContributor(options, contributor), expected); }); @@ -54,7 +54,7 @@ test('should format contributor with pipes in their name', t => { const contributor = contributors.pipey; const {options} = fixtures(); - const expected = '[
Who | Needs | Pipes?](http://github.com/chrisinajar)
[πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=pipey)'; + const expected = '[
Who | Needs | Pipes?](http://github.com/chrisinajar)
[πŸ“–](https://github.com/jfmengels/all-contributors-cli/commits?author=pipey "Documentation")'; t.is(formatContributor(options, contributor), expected); });