diff --git a/README.md b/README.md index fc2aab3..b099378 100644 --- a/README.md +++ b/README.md @@ -43,13 +43,7 @@ Thanks goes to these wonderful people -| [
Jeroen Engels](https://github.com/jfmengels)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=jfmengels "Code") [πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=jfmengels "Documentation") [⚠️](https://github.com/all-contributors/all-contributors-cli/commits?author=jfmengels "Tests") | [
Kent C. Dodds](http://kentcdodds.com/)
[πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=kentcdodds "Documentation") [πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=kentcdodds "Code") | [
JoΓ£o GuimarΓ£es](https://github.com/jccguimaraes)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=jccguimaraes "Code") | [
Ben Briggs](http://beneb.info)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=ben-eb "Code") | [
Itai Steinherz](https://github.com/itaisteinherz)
[πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=itaisteinherz "Documentation") [πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=itaisteinherz "Code") | [
Alex Jover](https://github.com/alexjoverm)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=alexjoverm "Code") [πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=alexjoverm "Documentation") | -| :---: | :---: | :---: | :---: | :---: | :---: | -| [
Jerod Santo](https://jerodsanto.net)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=jerodsanto "Code") | [
Kevin Jalbert](https://github.com/kevinjalbert)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=kevinjalbert "Code") | [
tunnckoCore](https://i.am.charlike.online)
[πŸ”§](#tool-charlike "Tools") | [
Mehdi Achour](https://machour.idk.tn/)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=machour "Code") | [
Roy Revelt](https://codsen.com)
[πŸ›](https://github.com/all-contributors/all-contributors-cli/issues?q=author%3Arevelt "Bug reports") | [
Chris Vickery](https://github.com/chrisinajar)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=chrisinajar "Code") | -| [
Bryce Reynolds](https://github.com/brycereynolds)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=brycereynolds "Code") | [
James, please](http://www.jmeas.com)
[πŸ€”](#ideas-jmeas "Ideas, Planning, & Feedback") [πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=jmeas "Code") | [
Spyros Ioakeimidis](http://www.spyros.io)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=spirosikmd "Code") | [
Fernando Costa](https://github.com/fadc80)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=fadc80 "Code") | [
snipe](https://snipe.net)
[πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=snipe "Documentation") | [
Gant Laborde](http://gantlaborde.com/)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=GantMan "Code") | -| [
Md Zubair Ahmed](https://in.linkedin.com/in/mzubairahmed)
[πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=M-ZubairAhmed "Documentation") [πŸ›](https://github.com/all-contributors/all-contributors-cli/issues?q=author%3AM-ZubairAhmed "Bug reports") [πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=M-ZubairAhmed "Code") [⚠️](https://github.com/all-contributors/all-contributors-cli/commits?author=M-ZubairAhmed "Tests") | [
Divjot Singh](http://bogas04.github.io)
[πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=bogas04 "Documentation") | [
JoΓ£o Marques](https://github.com/tigermarques)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=tigermarques "Code") [πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=tigermarques "Documentation") [πŸ€”](#ideas-tigermarques "Ideas, Planning, & Feedback") | [
Andrew Lisowski](http://hipstersmoothie.com)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=hipstersmoothie "Code") [πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=hipstersmoothie "Documentation") [⚠️](https://github.com/all-contributors/all-contributors-cli/commits?author=hipstersmoothie "Tests") | [
Xianming Zhong](https://github.com/chinesedfan)
[πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=chinesedfan "Documentation") | [
C.Y.Xu](https://github.com/xuchaoying)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=xuchaoying "Code") | -| [
Dura](https://github.com/chris-dura)
[πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=chris-dura "Documentation") | [
Jake Bolam](https://jakebolam.com)
[πŸš‡](#infra-jakebolam "Infrastructure (Hosting, Build-Tools, etc)") [πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=jakebolam "Code") [πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=jakebolam "Documentation") [⚠️](https://github.com/all-contributors/all-contributors-cli/commits?author=jakebolam "Tests") | [
Maximilian Berkmann](http://maxcubing.wordpress.com)
[πŸ’»](https://github.com/all-contributors/all-contributors-cli/commits?author=Berkmann18 "Code") [⚠️](https://github.com/all-contributors/all-contributors-cli/commits?author=Berkmann18 "Tests") [πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=Berkmann18 "Documentation") | [
tbenning](https://github.com/tbenning)
[🎨](#design-tbenning "Design") | - +
Jeroen Engels
Jeroen Engels

πŸ’» πŸ“– ⚠️
Kent C. Dodds
Kent C. Dodds

πŸ“– πŸ’»
JoΓ£o GuimarΓ£es
JoΓ£o GuimarΓ£es

πŸ’»
Ben Briggs
Ben Briggs

πŸ’»
Itai Steinherz
Itai Steinherz

πŸ“– πŸ’»
Alex Jover
Alex Jover

πŸ’» πŸ“–
Jerod Santo
Jerod Santo

πŸ’»
Kevin Jalbert
Kevin Jalbert

πŸ’»
tunnckoCore
tunnckoCore

πŸ”§
Mehdi Achour
Mehdi Achour

πŸ’»
Roy Revelt
Roy Revelt

πŸ›
Chris Vickery
Chris Vickery

πŸ’»
Bryce Reynolds
Bryce Reynolds

πŸ’»
James, please
James, please

πŸ€” πŸ’»
Spyros Ioakeimidis
Spyros Ioakeimidis

πŸ’»
Fernando Costa
Fernando Costa

πŸ’»
snipe
snipe

πŸ“–
Gant Laborde
Gant Laborde

πŸ’»
Md Zubair Ahmed
Md Zubair Ahmed

πŸ“– πŸ› πŸ’» ⚠️
Divjot Singh
Divjot Singh

πŸ“–
JoΓ£o Marques
JoΓ£o Marques

πŸ’» πŸ“– πŸ€”
Andrew Lisowski
Andrew Lisowski

πŸ’» πŸ“– ⚠️
Xianming Zhong
Xianming Zhong

πŸ“–
C.Y.Xu
C.Y.Xu

πŸ’»
Dura
Dura

πŸ“–
Jake Bolam
Jake Bolam

πŸš‡ πŸ’» πŸ“– ⚠️
Maximilian Berkmann
Maximilian Berkmann

πŸ’» ⚠️ πŸ“–
tbenning
tbenning

🎨
This project follows the diff --git a/package.json b/package.json index 2948e2a..54453c4 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,9 @@ "lint": "kcd-scripts lint", "test": "kcd-scripts test", "validate": "kcd-scripts validate", - "commit": "npx git-cz" + "commit": "git-cz", + "start": "./dist/cli.js", + "dev": "./src/cli.js" }, "husky": { "hooks": { diff --git a/src/contributors/__tests__/add.js b/src/contributors/__tests__/add.js index 4879c39..9c15fab 100644 --- a/src/contributors/__tests__/add.js +++ b/src/contributors/__tests__/add.js @@ -50,7 +50,7 @@ test('add new contributor at the end of the list of contributors', () => { return addContributor(options, username, contributions, mockInfoFetcher).then( contributors => { - expect(contributors.length).toBe(options.contributors.length + 1) + expect(contributors).toHaveLength(options.contributors.length + 1) expect(contributors[options.contributors.length]).toEqual({ login: 'login3', name: 'Some name', @@ -70,7 +70,7 @@ test('add new contributor at the end of the list of contributors with a url link return addContributor(options, username, contributions, mockInfoFetcher).then( contributors => { - expect(contributors.length).toBe(options.contributors.length + 1) + expect(contributors).toHaveLength(options.contributors.length + 1) expect(contributors[options.contributors.length]).toEqual({ login: 'login3', name: 'Some name', @@ -112,7 +112,7 @@ test(`should update an existing contributor's contributions if a new type is add const contributions = ['bug'] return addContributor(options, username, contributions, mockInfoFetcher).then( contributors => { - expect(contributors.length).toBe(options.contributors.length) + expect(contributors).toHaveLength(options.contributors.length) expect(contributors[0]).toEqual({ login: 'login1', name: 'Some name', @@ -130,7 +130,7 @@ test(`should update an existing contributor's contributions if a new type is add const contributions = ['bug'] return addContributor(options, username, contributions, mockInfoFetcher).then( contributors => { - expect(contributors.length).toBe(1) + expect(contributors).toHaveLength(1) expect(contributors[0]).toEqual({ login: 'Login1', name: 'Some name', @@ -150,7 +150,7 @@ test(`should update an existing contributor's contributions if a new type is add return addContributor(options, username, contributions, mockInfoFetcher).then( contributors => { - expect(contributors.length).toBe(options.contributors.length) + expect(contributors).toHaveLength(options.contributors.length) expect(contributors[0]).toEqual({ login: 'login1', name: 'Some name', @@ -169,7 +169,7 @@ test(`should update an existing contributor's contributions if an existing type return addContributor(options, username, contributions, mockInfoFetcher).then( contributors => { - expect(contributors.length).toBe(options.contributors.length) + expect(contributors).toHaveLength(options.contributors.length) expect(contributors[1]).toEqual({ login: 'login2', name: 'Some name', diff --git a/src/contributors/__tests__/addWithDetails.js b/src/contributors/__tests__/addWithDetails.js index f2e7ebe..b877e2d 100644 --- a/src/contributors/__tests__/addWithDetails.js +++ b/src/contributors/__tests__/addWithDetails.js @@ -20,6 +20,6 @@ test('add new contributor without going to the network', async () => { profile: userDetails.profile, }) - expect(contributors.length).toBe(options.contributors.length + 1) + expect(contributors).toHaveLength(options.contributors.length + 1) expect(contributors[options.contributors.length]).toEqual(userDetails) }) diff --git a/src/contributors/__tests__/prompt.js b/src/contributors/__tests__/prompt.js index 559526d..3139cf3 100644 --- a/src/contributors/__tests__/prompt.js +++ b/src/contributors/__tests__/prompt.js @@ -53,7 +53,7 @@ test(`should filter valid contribution types from user inserted types`, () => { const contributions = 'invalidContributionType1,code,invalidContributionType2,bug' return prompt(options, username, contributions).then(answers => { - expect(answers.contributions.length).toBe(2) + expect(answers.contributions).toHaveLength(2) expect(answers.contributions).toEqual(['code', 'bug']) }) }) diff --git a/src/generate/__tests__/__snapshots__/index.js.snap b/src/generate/__tests__/__snapshots__/index.js.snap index 69ab374..1459a08 100644 --- a/src/generate/__tests__/__snapshots__/index.js.snap +++ b/src/generate/__tests__/__snapshots__/index.js.snap @@ -9,8 +9,7 @@ Description These people contributed to the project: -| Kent C. Dodds is awesome! | Divjot Singh is awesome! | Jeroen Engels is awesome! | -| :---: | :---: | :---: | +
Kent C. Dodds is awesome!Divjot Singh is awesome!Jeroen Engels is awesome!
Thanks a lot everyone!" @@ -25,9 +24,7 @@ Description These people contributed to the project: -| Kent C. Dodds is awesome! | Kent C. Dodds is awesome! | Kent C. Dodds is awesome! | Kent C. Dodds is awesome! | Kent C. Dodds is awesome! | -| :---: | :---: | :---: | :---: | :---: | -| Kent C. Dodds is awesome! | Kent C. Dodds is awesome! | +
Kent C. Dodds is awesome!Kent C. Dodds is awesome!Kent C. Dodds is awesome!Kent C. Dodds is awesome!Kent C. Dodds is awesome!
Kent C. Dodds is awesome!Kent C. Dodds is awesome!
Thanks a lot everyone!" diff --git a/src/generate/__tests__/format-contribution-type.js b/src/generate/__tests__/format-contribution-type.js index c873623..a7317af 100644 --- a/src/generate/__tests__/format-contribution-type.js +++ b/src/generate/__tests__/format-contribution-type.js @@ -17,10 +17,10 @@ test('return corresponding symbol', () => { const {options} = fixtures() expect(formatContributionType(options, contributor, 'tool')).toBe( - '[πŸ”§](#tool-kentcdodds "Tools")', + 'πŸ”§', ) expect(formatContributionType(options, contributor, 'question')).toBe( - '[πŸ’¬](#question-kentcdodds "Answering Questions")', + 'πŸ’¬', ) }) @@ -31,13 +31,13 @@ test('return link to commits', () => { 'https://github.com/all-contributors/all-contributors-cli/commits?author=kentcdodds' expect(formatContributionType(options, contributor, 'code')).toBe( - `[πŸ’»](${expectedLink} "Code")`, + `πŸ’»`, ) expect(formatContributionType(options, contributor, 'doc')).toBe( - `[πŸ“–](${expectedLink} "Documentation")`, + `πŸ“–`, ) expect(formatContributionType(options, contributor, 'test')).toBe( - `[⚠️](${expectedLink} "Tests")`, + `⚠️`, ) }) @@ -45,7 +45,7 @@ test('return link to issues', () => { const contributor = contributors.kentcdodds const {options} = fixtures() const expected = - '[πŸ›](https://github.com/all-contributors/all-contributors-cli/issues?q=author%3Akentcdodds "Bug reports")' + 'πŸ›' expect(formatContributionType(options, contributor, 'bug')).toBe(expected) }) @@ -59,7 +59,7 @@ test('make any symbol into a link if contribution is an object', () => { } expect(formatContributionType(options, contributor, contribution)).toBe( - '[πŸ”§](www.foo.bar "Tools")', + 'πŸ”§', ) }) @@ -72,7 +72,7 @@ test('override url for given types', () => { } expect(formatContributionType(options, contributor, contribution)).toBe( - '[πŸ’»](www.foo.bar "Code")', + 'πŸ’»', ) }) @@ -84,14 +84,14 @@ test('be able to add types to the symbol list', () => { } expect(formatContributionType(options, contributor, 'cheerful')).toBe( - '[:smiley:](#cheerful-kentcdodds "")', + ':smiley:', ) expect( formatContributionType(options, contributor, { type: 'cheerful', url: 'www.foo.bar', }), - ).toBe('[:smiley:](www.foo.bar "")') + ).toBe(':smiley:') }) test('be able to add types with template to the symbol list', () => { @@ -105,7 +105,7 @@ test('be able to add types with template to the symbol list', () => { } expect(formatContributionType(options, contributor, 'web')).toBe( - '[:web:](www.kentcdodds.com "")', + ':web:', ) }) @@ -117,14 +117,14 @@ test('be able to override existing types', () => { } expect(formatContributionType(options, contributor, 'code')).toBe( - '[:smiley:](#code-kentcdodds "")', + ':smiley:', ) expect( formatContributionType(options, contributor, { type: 'code', url: 'www.foo.bar', }), - ).toBe('[:smiley:](www.foo.bar "")') + ).toBe(':smiley:') }) test('be able to override existing templates', () => { @@ -138,14 +138,14 @@ test('be able to override existing templates', () => { } expect(formatContributionType(options, contributor, 'code')).toBe( - '[:web:](www.kentcdodds.com "")', + ':web:', ) expect( formatContributionType(options, contributor, { type: 'code', url: 'www.foo.bar', }), - ).toBe('[:web:](www.foo.bar "")') + ).toBe(':web:') }) test('throw a helpful error on unknown type', () => { diff --git a/src/generate/__tests__/format-contributor.js b/src/generate/__tests__/format-contributor.js index 652dc8a..e84024e 100644 --- a/src/generate/__tests__/format-contributor.js +++ b/src/generate/__tests__/format-contributor.js @@ -20,7 +20,7 @@ test('format a simple contributor', () => { const {options} = fixtures() const expected = - '[Kent C. Dodds
Kent C. Dodds](http://kentcdodds.com)
[πŸ‘€](#review-kentcdodds "Reviewed Pull Requests")' + 'Kent C. Dodds
Kent C. Dodds

πŸ‘€' expect(formatContributor(options, contributor)).toBe(expected) }) @@ -30,7 +30,7 @@ test('format contributor with complex contribution types', () => { const {options} = fixtures() const expected = - '[Kent C. Dodds
Kent C. Dodds](http://kentcdodds.com)
[πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=kentcdodds "Documentation") [πŸ‘€](#review-kentcdodds "Reviewed Pull Requests") [πŸ’¬](#question-kentcdodds "Answering Questions")' + 'Kent C. Dodds
Kent C. Dodds

πŸ“– πŸ‘€ πŸ’¬' expect(formatContributor(options, contributor)).toBe(expected) }) @@ -53,7 +53,7 @@ test('default image size to 100', () => { delete options.imageSize const expected = - '[Kent C. Dodds
Kent C. Dodds](http://kentcdodds.com)
[πŸ‘€](#review-kentcdodds "Reviewed Pull Requests")' + 'Kent C. Dodds
Kent C. Dodds

πŸ‘€' expect(formatContributor(options, contributor)).toBe(expected) }) @@ -63,7 +63,7 @@ test('format contributor with pipes in their name', () => { const {options} = fixtures() const expected = - '[Who | Needs | Pipes?
Who | Needs | Pipes?](http://github.com/chrisinajar)
[πŸ“–](https://github.com/all-contributors/all-contributors-cli/commits?author=pipey "Documentation")' + 'Who | Needs | Pipes?
Who | Needs | Pipes?

πŸ“–' expect(formatContributor(options, contributor)).toBe(expected) }) @@ -73,7 +73,7 @@ test('format contributor with no github account', () => { const {options} = fixtures() const expected = - 'No Github Account
No Github Account
[🌍](#translation "Translation")' + 'No Github Account
No Github Account
🌍' expect(formatContributor(options, contributor)).toBe(expected) }) diff --git a/src/generate/format-contribution-type.js b/src/generate/format-contribution-type.js index 4512439..ebdde1c 100644 --- a/src/generate/format-contribution-type.js +++ b/src/generate/format-contribution-type.js @@ -3,7 +3,7 @@ const _ = require('lodash/fp') const util = require('../util') const linkTemplate = _.template( - '[<%= symbol %>](<%= url %> "<%= description %>")', + '<%= symbol %>', ) function getType(options, contribution) { diff --git a/src/generate/format-contributor.js b/src/generate/format-contributor.js index f4b4611..c7955f7 100644 --- a/src/generate/format-contributor.js +++ b/src/generate/format-contributor.js @@ -2,10 +2,10 @@ const _ = require('lodash/fp') const formatContributionType = require('./format-contribution-type') const avatarTemplate = _.template( - '<%= name %>', + '<%= name %>', ) const avatarBlockTemplate = _.template( - '[<%= avatar %>
<%= name %>](<%= contributor.profile %>)', + '<%= avatar %>
<%= name %>
', ) const avatarBlockTemplateNoProfile = _.template( '<%= avatar %>
<%= name %>', diff --git a/src/generate/index.js b/src/generate/index.js index c749889..e5ba822 100644 --- a/src/generate/index.js +++ b/src/generate/index.js @@ -1,5 +1,4 @@ const _ = require('lodash/fp') -const injectContentBetween = require('../util').markdown.injectContentBetween const formatBadge = require('./format-badge') const formatContributor = require('./format-contributor') @@ -37,12 +36,7 @@ function injectListBetweenTags(newContent) { } function formatLine(contributors) { - return `| ${contributors.join(' | ')} |` -} - -function createColumnLine(options, contributors) { - const nbColumns = Math.min(options.contributorsPerLine, contributors.length) - return `${_.repeat(nbColumns, '| :---: ')}|` + return `${contributors.join('')}` } function generateContributorsList(options, contributors) { @@ -52,13 +46,9 @@ function generateContributorsList(options, contributors) { }), _.chunk(options.contributorsPerLine), _.map(formatLine), - function insertColumns(lines) { - const columnLine = createColumnLine(options, contributors) - return injectContentBetween(lines, columnLine, 1, 1) - }, - _.join('\n'), + _.join(''), newContent => { - return `\n${newContent}\n` + return `\n${newContent}
\n` }, )(contributors) } @@ -83,7 +73,8 @@ module.exports = function generate(options, contributors, fileContent) { ? '\n' : generateContributorsList(options, contributors) const badge = formatBadge(options, contributors) - return _.flow(injectListBetweenTags(contributorsList), replaceBadge(badge))( - fileContent, - ) + return _.flow( + injectListBetweenTags(contributorsList), + replaceBadge(badge), + )(fileContent) }