Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
contribution-counters
Advanced tools
Readme
Have you ever wanted to find out how many repos/projects you've contributed to and with how many commits? Well, now you can easily do so with this simple to use module!
This contribution counter is for 3 VCSs: GitHub, Bitbucket & GitLab and is achieved via each of their APIs and access tokens.
npm install contribution-counters --save
npm install contribution-counters --global
const { getGitHubCounts } = require("contribution-counters");
The config is an object with the following properties (all available on all counters unless specified):
- `username`: Your username (string:required)
- `accessToken`: An access token for the user above (string:required)
- `minCommits`: The minimum number of commits a repo needs to count as a contribution (int:default=1)
- `includePullRequests`: Whether to include count of pull/merge requests contributions (bool:default=false)
The below two are only used if a commit doesn't have a real user attached (At least one is required for Bitbucket & GitLab & both optional for GitHub BUT advised to use both for all)
- `userEmailAddresses`: Array of email addresses which may be associated with your commits (array)
- `userNames`: Array of name's which may be associated with your commits (array)
If you only want counts for after and/or before a particular date (inclusive) (or if you know the date you first and/or last contributed this can be used to minimise API requests)
- `fromDate`: Datetime string (ISO-8601 Date/timestamp (YYYY-MM-DDTHH:mm:ss.sssZ))
- `untilDate`: Datetime string (ISO-8601 Date/timestamp (YYYY-MM-DDTHH:mm:ss.sssZ))
To get repos of which you have a minimum access to
- `minRepoAccessLevel`: Only for GitLab (int:default=30)\[10, 20, 30, 40, 50] (see [here](https://docs.gitlab.com/ee/api/members.html))
- `minRepoRole`: Only for Bitbucket (string:default=contributor)\[admin, contributor, member, owner] (see [here](https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D))
- `minRepoRole`: Only for GitHub (comma separated string:default=owner,collaborator,organization_member)\[owner, collaborator, organization_member] (see [here](https://developer.github.com/v3/repos/#parameters))
If you have a selfhosted GitLab, you will need to use url
option
- `url`: The URL where your GitLab is located at (for example `https://gitlab.jahidulpabelislam.com/` or `https://jahidulpabelislam.com/gitlab/`)
3. Start the counter with the following:
```javascript
const counts = await getGitHubCounts(config);
```
4. The returned result (counts
) is an object with two or three properties:
- `commits` is your total number of commits
- `projects` is the number of projects you've contributed to
- `pullRequests` is the number of pull/merge requests you've authored (if requested)
getGitHubCounts
in the above example can be replaced with getBitbucketCounts
or getGitLabCounts
.
In version 2, the only braking change is that only functions can be imported/required, instead of Counter classes.
To upgrade you will need to import/require the 3 new functions: getBitbucketCounts
, getGitHubCounts
& getGitLabCounts
instead of Bitbucket
, GitHub
& GitLab
.
Where before you created an instance of a class (e.g. GitHub
) and passed in an object of config, then called a function (getCounters
) to get the counts.
Now the new functions will do both in one. So just call the new function and pass in the existing config object as the only parameter and then your counts will be returned.
If you found this module interesting or useful please do spread the word of this module: share on your social's, star on github, etc.
If you find any issues or have any feature requests, you can open an issue or can email me @ jahidulpabelislam.com :smirk:.
This module is licensed under the General Public License - see the License file for details
FAQs
Repos & commits counters for Bitbucket, GitHub & GitLab
The npm package contribution-counters receives a total of 31 weekly downloads. As such, contribution-counters popularity was classified as not popular.
We found that contribution-counters demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.