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

git-metrics

v2.2.2

Published

tools to calculate some metrics out of git repos

Downloads

305

Readme

git-metrics

git-metrics is set of apps used to work with git repos and calculate different measures on git repos.

run git-metrics apps

The apps can be launched with the command

npx git-metrics <app-name> <params>

or, if we have cloned git-metrics repo, from the git-metrics repo folder launching the command

node ./dist/lib/command.js <app-name> <params>

Executing npx git-metrics prints on the console the list of available apps.

Executing npx git-metrics <app-name> -h prints on the console the help for the specific app.

apps available

  • code-turnover: calculates the code-turnover on the repos contained in a folder and save it to csv files - code-turnover is a measure of the effort spent to develop and maintain a codebase in a certain time window
  • cloc-diff-between-dates: calculates the differences in the lines of code/comments/blanks between two dates in a set of repos contained in a folder
  • read-repos-commits: reads all the commit records of a set of repos and save them on csv files - the result can be used to have an high level idea of how intense is the work on a certain codebase
  • cloc-byfile-multi-repos: calculates the lines of code/comments/blanks on all the files in all the repos contained in a certain folder using the cloc command which, by default, works on a single repo
  • fetch-repos: fetches the git repos contained in a folder and its subfolders
  • pull-repos: pulls the git repos contained in a folder and its subfolders

apps deprecated

  • cloc-monthly-diff-repos: calculates statistics about the changes that occurred on a codebase on a monthly basis, i.e. calculating the differences in the codebase between the last commit of a month and the last commit of the previous month - use code-turnover instead to have the real picture of the changes in a period of time
  • reports: there are different reports that can be run on repos to gather statistics about, for instance, the files that have changed most in a certain period of time, the authors that have contributed more and so on - code-turnover instead and then build the desired pivots using the data generated

libraries

The apps use git and cloc commands to calculate their statistics.

Such commands are wrapped in functions provided by different libraries

  • cloc-functions: wraps the cloc to provide different output, e.g. a dictionary of the files in a repo with the information about their lines of code or the differences, in terms lines of code/comment/blank added/deleted/renamed in a certain period of time
  • git-functions: wraps different git commands, such as git log or git diff to provide different output, e.g. the list of all commits in a certain period of time or the differences between the files comparing two different commits
  • git-cloc-functions: combines git and cloc commands to provide a more comprehensive set of information about the changes that have occurred in a repo in certain period of time

use of rxJs

git-metrics uses extensively the rxJs library.

The reason is that the git and cloc commands are often executed asynchronously using the node child-process functions in their 'callback based' form (i.e. exec and spawn).

The child-process 'callback based' functions are turned into rsJs Observables using functions provided in execute-command.

Converting 'callback based' functions into Observable streams allows to conveniently manipulate such streams via rxJs operators.