Repository navigation
feat: Add check command that compares GitHub contributors with credited ones - #58
Conversation
|
This is super awesome!
👍
You can get that from the |
kentcdodds
left a comment
There was a problem hiding this comment.
I'm fine with the code as it is 👍 just a couple of things 😄
This is great 👏
| .usage('Usage: $0 add <username> <contribution>') | ||
| .command('init', 'Prepare the project to be used with this tool') | ||
| .usage('Usage: $0 init') | ||
| .command('check', 'Compares contributors from Github with the ones credited in .all-contributorsrc') |
| .command('init', 'Prepare the project to be used with this tool') | ||
| .usage('Usage: $0 init') | ||
| .command('check', 'Compares contributors from Github with the ones credited in .all-contributorsrc') | ||
| .usage('Usage: $0 check <repository>') |
There was a problem hiding this comment.
Don't forget to remove <repository> when you refactor this to use projectOwner and projectName
| name: 'Re-generate the contributors list', | ||
| value: 'generate' | ||
| }, { | ||
| name: 'Compare contributors from Github with the credited ones', |
|
Hi @kentcdodds, thank you for the feedback. I took care of it! I also implemented API pagination, but it's currently limited to 500 contributors max. I guess that will be more than enough for most projects 😄 For collaborators unknown to GitHub, I added a check to only report those whose contributions includes "code" or "tool". There might be room for improvement here, but I think it's enough for now. Added some documentation too, you may want to review it as I'm not a native speaker. And last but not least, I'm not sure how to write tests for this new feature. Aside from testing headers parsing in |
kentcdodds
left a comment
There was a problem hiding this comment.
Super! Could you get rid of the yarn.lock file (maybe add yarn.lock to the gitignore?). Thanks!
Actually, let's make it |
|
Just realized that the It's also using AVA rather than Jest, so I'm not certain of the best way to test things either, but I think you'll want to mock the |
|
@kentcdodds took in account your remarks and added tests using fixtures are in |
kentcdodds
left a comment
There was a problem hiding this comment.
Looking great! Just a few things...
|
|
||
| var missingInConfig = ghContributors.filter(login => knownContributors.indexOf(login) === -1); | ||
| var missingFromGithub = knownContributors.filter(login => { | ||
| return ghContributors.indexOf(login) === -1 && ( |
There was a problem hiding this comment.
Could probably use includes here :)
| }, {}); | ||
| var knownContributors = configData.contributors.map(contributor => contributor.login); | ||
|
|
||
| var missingInConfig = ghContributors.filter(login => knownContributors.indexOf(login) === -1); |
There was a problem hiding this comment.
Could probably use includes here.
| }); | ||
|
|
||
| test('Handle a single results page correctly', async t => { | ||
| await check('jfmengels', 'all-contributors-cli').then(transformed => { |
There was a problem hiding this comment.
Because you're using await here, you don't need the then you could do:
const transformed = await check ...
t.deepEqual(transformed ....| return null; | ||
| } | ||
|
|
||
| var nextLink = link.split(',').find(s => s.indexOf('rel="next"') > -1); |
| } | ||
|
|
||
| module.exports = function getContributorsFromGithub(owner, name) { | ||
| var url = 'https://api.github.com/repos/' + owner + '/' + name + '/contributors?per_page=100'; |
There was a problem hiding this comment.
Could use a template literal:
var url = `https://api.github.com/repos/${owner}/${name}/contributors?per_page=100`;There was a problem hiding this comment.
There you go. Also use template literals for the command output
|
Great work @machour 👏 |
* docs: update README.md * docs: update .all-contributorsrc
More than often, I find myself having a diff between the numbers of contributors reported by Github, and the contributors actually credited in my
.all-contributorsrc.This PR draft introduce a new CLI command that will fetch contributors from GH api, and run a two-ways diff with the known ones, allowing a project maintainer to easily find who is missing.
Sample output on this repo:
I still need to paginate the api response if there are more than 100 results, and avoid reporting unknown contributors if their contributions didn't involve coding (video, blog, funding, ..)
I'm also thinking about adding a
repositoryfield in the configuration file, to avoid retyping the repo name every time the command is executed.And I'm not sure if
utils/diff.jsis the right place for this script 🤔