Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a305469
feat(prompt): add options 'repoType' and 'repoHost' to init prompt
Feb 19, 2018
14f5874
docs(README): add myself to contributors list
Feb 19, 2018
945d79c
feat(repo): add api to interact with repositories
Feb 19, 2018
adf543b
test(generate): fix format-contribution-type and format-contributor
Feb 19, 2018
165eeec
refactor(contributors): adapt code that adds contributors to use the …
Feb 19, 2018
f741884
refactor(cli): adapt cli to use the new api
Feb 19, 2018
e9d8295
refactor(util): adapt code to use the new repo api and remove unused …
Feb 19, 2018
a13d060
refactor(repo): declare the functions outside the module.exports
Feb 19, 2018
96b80d3
feat(repo): add key to allow to compare users for gitlab in the check…
Feb 19, 2018
8f1bd55
fix(cli): fix the check command in gitlab based repositories
Feb 19, 2018
99b2a99
docs(README): add information about new parameters in the README file
Feb 19, 2018
fdfdc52
refactor(): fix code style to use consistent indentation of 2 spaces
Feb 20, 2018
9bf96ff
docs(README): fix all-contributors user data
Feb 22, 2018
76ea5ea
chore(merge): merge branch with jfmengels/master
Feb 23, 2018
07b4fc7
refactor(repo): fix tabs and whitespaces
Feb 23, 2018
7d2dad8
refactor(cli): rename ghContributors to repoContributors
Feb 23, 2018
de73626
refactor(cli): rename missingFromGithub to missingFromRepo
Feb 23, 2018
9fdfda5
refactor(cli): rename GitHub to Repository in the CLI help commands
Feb 23, 2018
7a906e6
refactor(github): add custom error message when no contributors are f…
Feb 23, 2018
3ac2d0f
refactor(gitlab): add custom error message when no contributors are f…
Feb 23, 2018
54304aa
docs(README): add more detail about GitLab support
Feb 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@
"contributions": [
"doc"
]
},
{
"login": "tigermarques",
"name": "João Marques",
"avatar_url": "https://avatars0.githubusercontent.com/u/15315098?v=4",
"profile": "https://github.com/tigermarques",
"contributions": [
"code",
"doc",
"ideas"
]
}
]
}
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-19-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-21-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]
Expand All @@ -25,7 +25,7 @@ want to maintain the table by hand

This is a tool to help automate adding contributor acknowledgements according to
the [all-contributors](https://github.com/kentcdodds/all-contributors)
specification.
specification for your GitHub or GitLab repository.

## Table of Contents

Expand Down Expand Up @@ -104,7 +104,7 @@ all-contributors add <username> <contribution>
all-contributors add jfmengels code,doc
```

Where `username` is the user's GitHub username, and `contribution` is a
Where `username` is the user's GitHub or Gitlab username, and `contribution` is a
`,`-separated list of ways to contribute, from the following list
([see the specs](https://github.com/kentcdodds/all-contributors#emoji-key)):

Expand Down Expand Up @@ -156,6 +156,8 @@ These are the keys you can specify:
`jfmengels/all-contributors-cli` --> `jfmengels`. Mandatory.
* `projectName`: Name of the project. Example: `jfmengels/all-contributors-cli`
--> `all-contributors-cli`. Mandatory.
* `repoType`: Type of repository. Must be either `github` or `gitlab`. Default: `github`.
* `repoHost`: Points to the repository hostname. Change it if you use a self hosted repository. Default: `https://github.com` if `repoType` is `github`, and `https://gitlab.com` if `repoType` is `gitlab`.
* `types`: Specify custom symbols or link templates for contribution types. Can
override the documented types.
* `imageSize`: Size (in px) of the user's avatar. Default: `100`.
Expand All @@ -176,8 +178,7 @@ Thanks goes to these wonderful people
| :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars3.githubusercontent.com/u/8212?v=3" width="100px;"/><br /><sub><b>Jerod Santo</b></sub>](https://jerodsanto.net)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jerodsanto "Code") | [<img src="https://avatars1.githubusercontent.com/u/574871?v=3" width="100px;"/><br /><sub><b>Kevin Jalbert</b></sub>](https://github.com/kevinjalbert)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=kevinjalbert "Code") | [<img src="https://avatars3.githubusercontent.com/u/5038030?v=4" width="100px;"/><br /><sub><b>tunnckoCore</b></sub>](https://i.am.charlike.online)<br />[🔧](#tool-charlike "Tools") | [<img src="https://avatars2.githubusercontent.com/u/304450?v=4" width="100px;"/><br /><sub><b>Mehdi Achour</b></sub>](https://machour.idk.tn/)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=machour "Code") | [<img src="https://avatars1.githubusercontent.com/u/8344688?v=4" width="100px;"/><br /><sub><b>Roy Revelt</b></sub>](https://codsen.com)<br />[🐛](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3Arevelt "Bug reports") | [<img src="https://avatars1.githubusercontent.com/u/422331?v=4" width="100px;"/><br /><sub><b>Chris Vickery</b></sub>](https://github.com/chrisinajar)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=chrisinajar "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/1026002?v=4" width="100px;"/><br /><sub><b>Bryce Reynolds</b></sub>](https://github.com/brycereynolds)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=brycereynolds "Code") | [<img src="https://avatars3.githubusercontent.com/u/2322305?v=4" width="100px;"/><br /><sub><b>James, please</b></sub>](http://www.jmeas.com)<br />[🤔](#ideas-jmeas "Ideas, Planning, & Feedback") [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jmeas "Code") | [<img src="https://avatars3.githubusercontent.com/u/1057324?v=4" width="100px;"/><br /><sub><b>Spyros Ioakeimidis</b></sub>](http://www.spyros.io)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=spirosikmd "Code") | [<img src="https://avatars3.githubusercontent.com/u/12335761?v=4" width="100px;"/><br /><sub><b>Fernando Costa</b></sub>](https://github.com/fadc80)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=fadc80 "Code") | [<img src="https://avatars0.githubusercontent.com/u/197404?v=4" width="100px;"/><br /><sub><b>snipe</b></sub>](https://snipe.net)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=snipe "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/997157?v=4" width="100px;"/><br /><sub><b>Gant Laborde</b></sub>](http://gantlaborde.com/)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=GantMan "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/17708702?v=4" width="100px;"/><br /><sub><b>Md Zubair Ahmed</b></sub>](https://in.linkedin.com/in/mzubairahmed)<br />[📖](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") | [<img src="https://avatars3.githubusercontent.com/u/6177621?v=4" width="100px;"/><br /><sub><b>Divjot Singh</b></sub>](http://bogas04.github.io)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=bogas04 "Documentation") |

| [<img src="https://avatars2.githubusercontent.com/u/17708702?v=4" width="100px;"/><br /><sub><b>Md Zubair Ahmed</b></sub>](https://in.linkedin.com/in/mzubairahmed)<br />[📖](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") | [<img src="https://avatars3.githubusercontent.com/u/6177621?v=4" width="100px;"/><br /><sub><b>Divjot Singh</b></sub>](http://bogas04.github.io)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=bogas04 "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/15315098?v=4" width="100px;"/><br /><sub><b>João Marques</b></sub>](https://github.com/tigermarques)<br />[💻](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") |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the
Expand Down
52 changes: 27 additions & 25 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const inquirer = require('inquirer')
const init = require('./init')
const generate = require('./generate')
const util = require('./util')
const repo = require('./repo')
const updateContributors = require('./contributors')

const cwd = process.cwd()
Expand All @@ -27,7 +28,7 @@ const yargv = yargs
.usage('Usage: $0 init')
.command(
'check',
'Compares contributors from GitHub with the ones credited in .all-contributorsrc',
'Compares contributors from the repository with the ones credited in .all-contributorsrc',
)
.usage('Usage: $0 check')
.boolean('commit')
Expand Down Expand Up @@ -74,25 +75,26 @@ function addContribution(argv) {
function checkContributors(argv) {
const configData = util.configFile.readConfig(argv.config)

return util
.check(configData.projectOwner, configData.projectName)
.then(ghContributors => {
return repo
.getContributors(configData.projectOwner, configData.projectName, configData.repoType, configData.repoHost)
.then(repoContributors => {
const checkKey = repo.getCheckKey(configData.repoType)
const knownContributions = configData.contributors.reduce((obj, item) => {
obj[item.login] = item.contributions
obj[item[checkKey]] = item.contributions
return obj
}, {})
const knownContributors = configData.contributors.map(
contributor => contributor.login,
contributor => contributor[checkKey],
)

const missingInConfig = ghContributors.filter(
login => !knownContributors.includes(login),
const missingInConfig = repoContributors.filter(
key => !knownContributors.includes(key),
)
const missingFromGithub = knownContributors.filter(login => {
const missingFromRepo = knownContributors.filter(key => {
return (
!ghContributors.includes(login) &&
(knownContributions[login].includes('code') ||
knownContributions[login].includes('test'))
!repoContributors.includes(key) &&
(knownContributions[key].includes('code') ||
knownContributions[key].includes('test'))
)
})

Expand All @@ -103,11 +105,11 @@ function checkContributors(argv) {
process.stdout.write(` ${missingInConfig.join(', ')}\n`)
}

if (missingFromGithub.length) {
if (missingFromRepo.length) {
process.stdout.write(
chalk.bold('Unknown contributors found in .all-contributorsrc:\n'),
)
process.stdout.write(`${missingFromGithub.join(', ')}\n`)
process.stdout.write(`${missingFromRepo.join(', ')}\n`)
}
})
}
Expand Down Expand Up @@ -136,7 +138,7 @@ function promptForCommand(argv) {
value: 'generate',
},
{
name: 'Compare contributors from GitHub with the credited ones',
name: 'Compare contributors from the repository with the credited ones',
value: 'check',
},
],
Expand All @@ -153,16 +155,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)
69 changes: 0 additions & 69 deletions src/contributors/__tests__/github.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/contributors/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function updateExistingContributor(options, username, contributions) {
}

function addNewContributor(options, username, contributions, infoFetcher) {
return infoFetcher(username).then(userData => {
return infoFetcher(username, options.repoType, options.repoHost).then(userData => {
const contributor = _.assign(userData, {
contributions: formatContributions(options, [], contributions),
})
Expand Down
31 changes: 0 additions & 31 deletions src/contributors/github.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/contributors/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const _ = require('lodash/fp')
const util = require('../util')
const repo = require('../repo')
const add = require('./add')
const github = require('./github')
const prompt = require('./prompt')

function isNewContributor(contributorList, username) {
Expand All @@ -11,7 +11,7 @@ function isNewContributor(contributorList, username) {
module.exports = function addContributor(options, username, contributions) {
const answersP = prompt(options, username, contributions)
const contributorsP = answersP.then(answers =>
add(options, answers.username, answers.contributions, github),
add(options, answers.username, answers.contributions, repo.getUserInfo),
)

const writeContributorsP = contributorsP.then(contributors =>
Expand Down
3 changes: 2 additions & 1 deletion src/contributors/prompt.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const _ = require('lodash/fp')
const inquirer = require('inquirer')
const util = require('../util')
const repo = require('../repo')

const contributionChoices = _.flow(
util.contributionTypes,
Expand All @@ -21,7 +22,7 @@ function getQuestions(options, username, contributions) {
{
type: 'input',
name: 'username',
message: "What is the contributor's GitHub username?",
message: `What is the contributor's ${repo.getTypeName(options.repoType)} username?`,
when: !username,
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/generate/__tests__/format-contribution-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const fixtures = () => {
const options = {
projectOwner: 'jfmengels',
projectName: 'all-contributors-cli',
repoType: 'github',
repoHost: 'https://github.com',
imageSize: 100,
}
return {options}
Expand Down
2 changes: 2 additions & 0 deletions src/generate/__tests__/format-contributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ function fixtures() {
const options = {
projectOwner: 'jfmengels',
projectName: 'all-contributors-cli',
repoType: 'github',
repoHost: 'https://github.com',
imageSize: 150,
}
return {options}
Expand Down
30 changes: 30 additions & 0 deletions src/init/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,34 @@ const questions = [
name: 'projectOwner',
message: 'Who is the owner of the repository?',
},
{
type: 'list',
name: 'repoType',
message: 'What is the repository type?',
choices: [
{
value: 'github',
name: 'GitHub',
},
{
value: 'gitlab',
name: 'GitLab',
},
],
default: 'github',
},
{
type: 'input',
name: 'repoHost',
message: 'Where is the repository hosted?',
default: function(answers) {
if (answers.repoType === 'github') {
return 'https://github.com'
} else if (answers.repoType === 'gitlab') {
return 'https://gitlab.com'
}
},
},
{
type: 'input',
name: 'contributorFile',
Expand Down Expand Up @@ -68,6 +96,8 @@ module.exports = function prompt() {
config: {
projectName: answers.projectName,
projectOwner: answers.projectOwner,
repoType: answers.repoType,
repoHost: answers.repoHost,
files: uniqueFiles([answers.contributorFile, answers.badgeFile]),
imageSize: answers.imageSize,
commit: answers.commit,
Expand Down
Loading