npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

contribution-counters

v2.6.0

Published

Repos & commits counters for Bitbucket, GitHub & GitLab

Downloads

61

Readme

Contribution Counters

NPM

CodeFactor Codacy Badge npm npm GitHub last commit (branch) npm bundle size NPM

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.

Instructions

Installing

  1. To install locally: npm install contribution-counters --save
  2. To install globally: npm install contribution-counters --global

Using module

  1. Import the necessary counter like below:

const { getGitHubCounts } = require("contribution-counters");

  1. Set up the configuration for the selected counter

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)
-  `includeCommits`: Whether to include count of your commits (bool:default=true)
-  `includeProjects`: Whether to include count of repo/projects you've contributed to (bool:default=true)
-  `includePullRequests`: Whether to include count of pull/merge request 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/`)
  1. Start the counter with the following:

    ```javascript
    const counts = await getGitHubCounts(config);
    ```
  2. The returned result (counts) is an object with one or more properties (based on what you've requested):

    • commits total number of your commits
    • projects total number of projects you've contributed to
    • pullRequests total number of pull/merge requests you've authored

getGitHubCounts in the above example can be replaced with getBitbucketCounts or getGitLabCounts.

Creating access tokens

Upgrading

v1 to v2

In version 2, the only breaking 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.

Support

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:.

Authors

Licence

This module is licenced under the General Public Licence - see the Licence file for details