diff --git a/.all-contributorsrc b/.all-contributorsrc index 7459677..e3e71dd 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -204,6 +204,17 @@ "doc", "ideas" ] + }, + { + "login": "hipstersmoothie", + "name": "Andrew Lisowski", + "avatar_url": "https://avatars3.githubusercontent.com/u/1192452?v=4", + "profile": "http://hipstersmoothie.com", + "contributions": [ + "code", + "doc", + "test" + ] } ] } diff --git a/README.md b/README.md index c7d282b..ba6f1b0 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![version][version-badge]][package] [![downloads][downloads-badge]][downloads] [![MIT License][license-badge]][license] -[![All Contributors](https://img.shields.io/badge/all_contributors-21-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-22-orange.svg?style=flat-square)](#contributors) [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] [![Watch on GitHub][github-watch-badge]][github-watch] [![Star on GitHub][github-star-badge]][github-star] @@ -178,7 +178,7 @@ Thanks goes to these wonderful people | :---: | :---: | :---: | :---: | :---: | :---: | | [
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") | [
tunnckoCore](https://i.am.charlike.online)
[🔧](#tool-charlike "Tools") | [
Mehdi Achour](https://machour.idk.tn/)
[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=machour "Code") | [
Roy Revelt](https://codsen.com)
[🐛](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3Arevelt "Bug reports") | [
Chris Vickery](https://github.com/chrisinajar)
[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=chrisinajar "Code") | | [
Bryce Reynolds](https://github.com/brycereynolds)
[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=brycereynolds "Code") | [
James, please](http://www.jmeas.com)
[🤔](#ideas-jmeas "Ideas, Planning, & Feedback") [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jmeas "Code") | [
Spyros Ioakeimidis](http://www.spyros.io)
[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=spirosikmd "Code") | [
Fernando Costa](https://github.com/fadc80)
[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=fadc80 "Code") | [
snipe](https://snipe.net)
[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=snipe "Documentation") | [
Gant Laborde](http://gantlaborde.com/)
[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=GantMan "Code") | -| [
Md Zubair Ahmed](https://in.linkedin.com/in/mzubairahmed)
[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Documentation") [🐛](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3AM-ZubairAhmed "Bug reports") [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Code") [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Tests") | [
Divjot Singh](http://bogas04.github.io)
[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=bogas04 "Documentation") | [
João Marques](https://github.com/tigermarques)
[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=tigermarques "Code") [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=tigermarques "Documentation") [🤔](#ideas-tigermarques "Ideas, Planning, & Feedback") | +| [
Md Zubair Ahmed](https://in.linkedin.com/in/mzubairahmed)
[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Documentation") [🐛](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3AM-ZubairAhmed "Bug reports") [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Code") [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=M-ZubairAhmed "Tests") | [
Divjot Singh](http://bogas04.github.io)
[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=bogas04 "Documentation") | [
João Marques](https://github.com/tigermarques)
[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=tigermarques "Code") [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=tigermarques "Documentation") [🤔](#ideas-tigermarques "Ideas, Planning, & Feedback") | [
Andrew Lisowski](http://hipstersmoothie.com)
[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=hipstersmoothie "Code") [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=hipstersmoothie "Documentation") [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=hipstersmoothie "Tests") | This project follows the diff --git a/src/cli.js b/src/cli.js index 636881d..ee98b0e 100755 --- a/src/cli.js +++ b/src/cli.js @@ -76,7 +76,12 @@ function checkContributors(argv) { const configData = util.configFile.readConfig(argv.config) return repo - .getContributors(configData.projectOwner, configData.projectName, configData.repoType, configData.repoHost) + .getContributors( + configData.projectOwner, + configData.projectName, + configData.repoType, + configData.repoHost, + ) .then(repoContributors => { const checkKey = repo.getCheckKey(configData.repoType) const knownContributions = configData.contributors.reduce((obj, item) => { @@ -138,7 +143,8 @@ function promptForCommand(argv) { value: 'generate', }, { - name: 'Compare contributors from the repository with the credited ones', + name: + 'Compare contributors from the repository with the credited ones', value: 'check', }, ], @@ -155,16 +161,16 @@ function promptForCommand(argv) { promptForCommand(yargv) .then(command => { switch (command) { - case 'init': - return init() - case 'generate': - return startGeneration(yargv) - case 'add': - return addContribution(yargv) - case 'check': - return checkContributors(yargv) - default: - throw new Error(`Unknown command ${command}`) + case 'init': + return init() + case 'generate': + return startGeneration(yargv) + case 'add': + return addContribution(yargv) + case 'check': + return checkContributors(yargv) + default: + throw new Error(`Unknown command ${command}`) } }) .catch(onError) diff --git a/src/contributors/add.js b/src/contributors/add.js index a23a2dd..5554313 100644 --- a/src/contributors/add.js +++ b/src/contributors/add.js @@ -38,12 +38,14 @@ function updateExistingContributor(options, username, contributions) { } function addNewContributor(options, username, contributions, infoFetcher) { - return infoFetcher(username, options.repoType, options.repoHost).then(userData => { - const contributor = _.assign(userData, { - contributions: formatContributions(options, [], contributions), - }) - return options.contributors.concat(contributor) - }) + return infoFetcher(username, options.repoType, options.repoHost).then( + userData => { + const contributor = _.assign(userData, { + contributions: formatContributions(options, [], contributions), + }) + return options.contributors.concat(contributor) + }, + ) } module.exports = function addContributor( diff --git a/src/repo/__tests__/github.js b/src/repo/__tests__/github.js index 66b7a83..bd93624 100644 --- a/src/repo/__tests__/github.js +++ b/src/repo/__tests__/github.js @@ -127,6 +127,9 @@ test('retrieve user from a different github registry', async () => { html_url: 'http://github.myhost.com:3000/nodisplayname', }) - const info = await getUserInfo('nodisplayname', 'http://github.myhost.com:3000') + const info = await getUserInfo( + 'nodisplayname', + 'http://github.myhost.com:3000', + ) expect(info.name).toBe('No Display Name') }) diff --git a/src/repo/__tests__/gitlab.js b/src/repo/__tests__/gitlab.js index c13cbff..fc69b5b 100644 --- a/src/repo/__tests__/gitlab.js +++ b/src/repo/__tests__/gitlab.js @@ -19,12 +19,15 @@ test('handle errors', async () => { test('fill in the name when it is returned', async () => { nock('https://gitlab.com') .get('/api/v4/users?username=nodisplayname') - .reply(200, [{ - username: 'nodisplayname', - name: 'No Display Name', - avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', - web_url: 'https://gitlab.com/nodisplayname', - }]) + .reply(200, [ + { + username: 'nodisplayname', + name: 'No Display Name', + avatar_url: + 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', + web_url: 'https://gitlab.com/nodisplayname', + }, + ]) const info = await getUserInfo('nodisplayname') expect(info.name).toBe('No Display Name') @@ -33,12 +36,15 @@ test('fill in the name when it is returned', async () => { test('fill in the name when null is returned', async () => { nock('https://gitlab.com') .get('/api/v4/users?username=nodisplayname') - .reply(200, [{ - username: 'nodisplayname', - name: null, - avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', - web_url: 'https://gitlab.com/nodisplayname', - }]) + .reply(200, [ + { + username: 'nodisplayname', + name: null, + avatar_url: + 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', + web_url: 'https://gitlab.com/nodisplayname', + }, + ]) const info = await getUserInfo('nodisplayname') expect(info.name).toBe('nodisplayname') @@ -47,12 +53,15 @@ test('fill in the name when null is returned', async () => { test('fill in the name when an empty string is returned', async () => { nock('https://gitlab.com') .get('/api/v4/users?username=nodisplayname') - .reply(200, [{ - username: 'nodisplayname', - name: '', - avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', - web_url: 'https://gitlab.com/nodisplayname', - }]) + .reply(200, [ + { + username: 'nodisplayname', + name: '', + avatar_url: + 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', + web_url: 'https://gitlab.com/nodisplayname', + }, + ]) const info = await getUserInfo('nodisplayname') expect(info.name).toBe('nodisplayname') @@ -61,12 +70,15 @@ test('fill in the name when an empty string is returned', async () => { test('append http when no absolute link is provided', async () => { nock('https://gitlab.com') .get('/api/v4/users?username=nodisplayname') - .reply(200, [{ - username: 'nodisplayname', - name: 'No Display Name', - avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', - web_url: 'www.gitlab.com/nodisplayname', - }]) + .reply(200, [ + { + username: 'nodisplayname', + name: 'No Display Name', + avatar_url: + 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', + web_url: 'www.gitlab.com/nodisplayname', + }, + ]) const info = await getUserInfo('nodisplayname') expect(info.profile).toBe('http://www.gitlab.com/nodisplayname') @@ -75,13 +87,19 @@ test('append http when no absolute link is provided', async () => { test('retrieve user from a different gitlab registry', async () => { nock('http://gitlab.myhost.com:3000') .get('/api/v4/users?username=nodisplayname') - .reply(200, [{ - username: 'nodisplayname', - name: 'No Display Name', - avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', - web_url: 'https://gitlab.com/nodisplayname', - }]) + .reply(200, [ + { + username: 'nodisplayname', + name: 'No Display Name', + avatar_url: + 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', + web_url: 'https://gitlab.com/nodisplayname', + }, + ]) - const info = await getUserInfo('nodisplayname', 'http://gitlab.myhost.com:3000') + const info = await getUserInfo( + 'nodisplayname', + 'http://gitlab.myhost.com:3000', + ) expect(info.name).toBe('No Display Name') }) diff --git a/src/repo/__tests__/index.js b/src/repo/__tests__/index.js index f4bab34..258d911 100644 --- a/src/repo/__tests__/index.js +++ b/src/repo/__tests__/index.js @@ -7,20 +7,27 @@ const githubAPI = require('../github') const gitlabAPI = require('../gitlab') test('get choices for init command', () => { - expect(repo.getChoices()).toEqual([{ - value: 'github', - name: 'GitHub' - }, { - value: 'gitlab', - name: 'GitLab' - }]) + expect(repo.getChoices()).toEqual([ + { + value: 'github', + name: 'GitHub', + }, + { + value: 'gitlab', + name: 'GitLab', + }, + ]) }) test('get hostname for a given repo type', () => { expect(repo.getHostname('github')).toEqual('https://github.com') - expect(repo.getHostname('github', 'http://my-github.com')).toEqual('http://my-github.com') + expect(repo.getHostname('github', 'http://my-github.com')).toEqual( + 'http://my-github.com', + ) expect(repo.getHostname('gitlab')).toEqual('https://gitlab.com') - expect(repo.getHostname('gitlab', 'http://my-gitlab.com:3000')).toEqual('http://my-gitlab.com:3000') + expect(repo.getHostname('gitlab', 'http://my-gitlab.com:3000')).toEqual( + 'http://my-gitlab.com:3000', + ) expect(repo.getHostname('other')).toBe(null) }) @@ -43,7 +50,8 @@ test('get user info calls underlying APIs', () => { return { login: 'nodisplayname', name: 'nodisplayname', - avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', + avatar_url: + 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', profile: 'https://gitlab.com/nodisplayname', } }) @@ -57,7 +65,8 @@ test('get user info calls underlying APIs', () => { expect(repo.getUserInfo('nodisplayname', 'gitlab')).toEqual({ login: 'nodisplayname', name: 'nodisplayname', - avatar_url: 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', + avatar_url: + 'http://www.gravatar.com/avatar/3186450a99d1641bf75a44baa23f0826?s=80\u0026d=identicon', profile: 'https://gitlab.com/nodisplayname', }) expect(repo.getUserInfo('nodisplayname', 'other')).toBe(null) diff --git a/src/repo/github.js b/src/repo/github.js index 84e1c4f..3a51788 100644 --- a/src/repo/github.js +++ b/src/repo/github.js @@ -47,7 +47,7 @@ function getContributorsPage(url) { const getUserInfo = function(username, hostname) { /* eslint-disable complexity */ if (!hostname) { - hostname = 'https://github.com'; + hostname = 'https://github.com' } const root = hostname.replace(/:\/\//, '://api.') @@ -80,7 +80,7 @@ const getUserInfo = function(username, hostname) { const getContributors = function(owner, name, hostname) { if (!hostname) { - hostname = 'https://github.com'; + hostname = 'https://github.com' } const root = hostname.replace(/:\/\//, '://api.') @@ -90,5 +90,5 @@ const getContributors = function(owner, name, hostname) { module.exports = { getUserInfo, - getContributors + getContributors, } diff --git a/src/repo/gitlab.js b/src/repo/gitlab.js index 5d7a69b..4c82f87 100644 --- a/src/repo/gitlab.js +++ b/src/repo/gitlab.js @@ -4,7 +4,7 @@ const request = pify(require('request')) const getUserInfo = function(username, hostname) { /* eslint-disable complexity */ if (!hostname) { - hostname = 'https://gitlab.com'; + hostname = 'https://gitlab.com' } return request @@ -28,14 +28,16 @@ const getUserInfo = function(username, hostname) { login: user.username, name: user.name || username, avatar_url: user.avatar_url, - profile: user.web_url.startsWith('http') ? user.web_url : `http://${user.web_url}`, + profile: user.web_url.startsWith('http') + ? user.web_url + : `http://${user.web_url}`, } }) } const getContributors = function(owner, name, hostname) { if (!hostname) { - hostname = 'https://gitlab.com'; + hostname = 'https://gitlab.com' } return request @@ -57,7 +59,7 @@ const getContributors = function(owner, name, hostname) { for (let i = 0; i < projects.length; i++) { if (projects[i].path_with_namespace === `${owner}/${name}`) { project = projects[i] - break; + break } } @@ -67,7 +69,9 @@ const getContributors = function(owner, name, hostname) { return request .get({ - url: `${hostname}/api/v4/projects/${project.id}/repository/contributors`, + url: `${hostname}/api/v4/projects/${ + project.id + }/repository/contributors`, headers: { 'User-Agent': 'request', }, @@ -87,5 +91,5 @@ const getContributors = function(owner, name, hostname) { module.exports = { getUserInfo, - getContributors + getContributors, } diff --git a/src/repo/index.js b/src/repo/index.js index 1810c7f..db69825 100644 --- a/src/repo/index.js +++ b/src/repo/index.js @@ -7,30 +7,36 @@ const SUPPORTED_REPO_TYPES = { name: 'GitHub', checkKey: 'login', defaultHost: 'https://github.com', - linkToCommits: '<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits?author=<%= contributor.login %>', - linkToIssues: '<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?q=author%3A<%= contributor.login %>', + linkToCommits: + '<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits?author=<%= contributor.login %>', + linkToIssues: + '<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?q=author%3A<%= contributor.login %>', getUserInfo: githubAPI.getUserInfo, - getContributors: githubAPI.getContributors + getContributors: githubAPI.getContributors, }, gitlab: { value: 'gitlab', name: 'GitLab', checkKey: 'name', defaultHost: 'https://gitlab.com', - linkToCommits: '<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits/master', - linkToIssues: '<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?author_username=<%= contributor.login %>', + linkToCommits: + '<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits/master', + linkToIssues: + '<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?author_username=<%= contributor.login %>', getUserInfo: gitlabAPI.getUserInfo, - getContributors: gitlabAPI.getContributors - } + getContributors: gitlabAPI.getContributors, + }, } const getChoices = function() { - return Object.keys(SUPPORTED_REPO_TYPES).map(key => SUPPORTED_REPO_TYPES[key]).map(item => { - return { - value: item.value, - name: item.name - } - }) + return Object.keys(SUPPORTED_REPO_TYPES) + .map(key => SUPPORTED_REPO_TYPES[key]) + .map(item => { + return { + value: item.value, + name: item.name, + } + }) } const getHostname = function(repoType, repoHost) { @@ -72,14 +78,21 @@ const getLinkToIssues = function(repoType) { const getUserInfo = function(username, repoType, repoHost) { if (repoType in SUPPORTED_REPO_TYPES) { - return SUPPORTED_REPO_TYPES[repoType].getUserInfo(username, getHostname(repoType, repoHost)) + return SUPPORTED_REPO_TYPES[repoType].getUserInfo( + username, + getHostname(repoType, repoHost), + ) } return null } const getContributors = function(owner, name, repoType, repoHost) { if (repoType in SUPPORTED_REPO_TYPES) { - return SUPPORTED_REPO_TYPES[repoType].getContributors(owner, name, getHostname(repoType, repoHost)) + return SUPPORTED_REPO_TYPES[repoType].getContributors( + owner, + name, + getHostname(repoType, repoHost), + ) } return null } @@ -92,5 +105,5 @@ module.exports = { getLinkToCommits, getLinkToIssues, getUserInfo, - getContributors + getContributors, } diff --git a/src/util/contribution-types.js b/src/util/contribution-types.js index d8c593b..181252a 100644 --- a/src/util/contribution-types.js +++ b/src/util/contribution-types.js @@ -90,7 +90,7 @@ const defaultTypes = function(repoType) { video: { symbol: '📹', description: 'Videos', - } + }, } } diff --git a/src/util/index.js b/src/util/index.js index 93b0cba..a58592d 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -2,5 +2,5 @@ module.exports = { configFile: require('./config-file'), contributionTypes: require('./contribution-types'), git: require('./git'), - markdown: require('./markdown') + markdown: require('./markdown'), }