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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cloc-graph

v1.0.0

Published

Track lines of code over time by language with visualization

Readme

cloc-graph

CI

A TypeScript tool for tracking lines of code over time by language with visualization.

Lines of Code Chart Example

Prerequisites

  • Node.js
  • Git
  • cloc (Count Lines of Code) installed and available in your PATH

Installation

Global Installation

npm install -g cloc-graph

Local Installation

npm install cloc-graph

Usage

cloc-graph [options]

Options

  • -p, --path <path>: Path to the Git repository (default: current directory)
  • -s, --step <number>: Sample every Nth commit (default: 1)
  • -g, --granularity <type>: Granularity: commits | daily | weekly | monthly (default: commits)
  • -t, --top <number>: Limit to top N languages by total lines (default: all languages)
  • -e, --exclude <languages>: Comma-separated list of languages to exclude (e.g., "HTML,CSS")
  • -i, --include <languages>: Comma-separated list of languages to include (e.g., "JavaScript,TypeScript")
  • -f, --from <date>: Start date for time range in YYYY-MM-DD format
  • -u, --to <date>: End date for time range in YYYY-MM-DD format
  • -m, --max-samples <number>: Maximum number of commits to analyze (default: 100)
  • --smart-sampling: Use smart sampling algorithm for large repositories

Examples

# Generate graph for current repository
cloc-graph

# Generate graph for a specific repo with weekly granularity
cloc-graph -p /path/to/repo -g weekly

# Generate graph showing only the top 5 languages
cloc-graph -t 5

# Sample every 10th commit to process large repositories faster
cloc-graph -s 10

# Generate graph excluding certain languages
cloc-graph -e HTML,CSS

# Generate graph including only specific languages
cloc-graph -i JavaScript,TypeScript

# Generate graph for a specific time range
cloc-graph -f 2023-01-01 -u 2023-12-31

# Process large repositories more efficiently
cloc-graph --smart-sampling -m 200

Outputs

The tool generates two files:

  1. loc_over_time_by_lang.csv: CSV file containing the lines of code for each language at each point in time
  2. loc_chart.png: A line chart visualization showing the trends of lines of code over time by language

Development

Setup

git clone https://github.com/yourusername/cloc-graph.git
cd cloc-graph
npm install

Build

npm run build

Run in development mode

npm run dev

Running Tests

# Run all tests
npm test

# Run tests in watch mode during development
npm run test:watch

# Generate test coverage report
npm run test:coverage

Code Style

This project uses Prettier for code formatting. You can format your code with:

npm run format

Project Structure

src/
├── cli/            # Command-line interface handling
├── services/       # Core services
│   ├── chartService.ts       # Chart generation
│   ├── clocService.ts        # Code analysis
│   └── gitService.ts         # Git repository interaction
├── types/          # TypeScript type definitions
├── utils/          # Utility functions
│   ├── dateUtils.ts          # Date manipulation utilities
│   └── sampling.ts           # Sampling algorithms
└── __tests__/      # Test files

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Run tests to ensure everything works (npm test)
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Please make sure your code passes all tests and follows the project's coding style.

License

MIT © Barthélemy Paléologue

See the LICENSE file for details.