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

@hernando15/count-lines-cli

v1.1.0

Published

CLI tool to count lines of code and show top files, respecting .gitignore

Readme

Count Lines CLI

CLI tool para contar líneas de código en tu proyecto y mostrar el top de archivos con más líneas, respetando las reglas del .gitignore.

Características

  • Cuenta líneas de código en todos los archivos del proyecto
  • Respeta las reglas del .gitignore automáticamente
  • Ignora automáticamente archivos comunes (lock files, configs, builds)
  • Soporte para archivo .countlinesignore con reglas personalizadas
  • Muestra un ranking de archivos ordenados por número de líneas
  • Estadísticas totales del proyecto

Instalación

Instalación local en un proyecto

npm install

Instalación global (para usar en cualquier proyecto)

npm install -g .

Uso

Si está instalado localmente

npm start

o directamente:

node cli.js

Si está instalado globalmente

count-lines

Especificar cuántos archivos mostrar

Por defecto muestra el top 20, pero puedes especificar otro número:

node cli.js 10    # Muestra top 10
node cli.js 50    # Muestra top 50

Ejemplo de salida

🔍 Contando líneas de código...
✓ Patrones por defecto cargados (lock files, configs, etc.)
✓ .gitignore cargado
✓ .countlinesignore cargado

📊 Top 6 archivos con más líneas:

────────────────────────────────────────────────────────────────────────────────
Líneas    Archivo
────────────────────────────────────────────────────────────────────────────────
1.  117   cli.js
2.  29    package-lock.json
3.  26    package.json
4.  21    test-file-2.js
5.  11    test-file-1.js
6.  8     .gitignore
────────────────────────────────────────────────────────────────────────────────

📈 Resumen:
   Total de archivos: 6
   Total de líneas: 212
   Promedio de líneas por archivo: 35

Archivos que se ignoran

El CLI tiene 3 niveles de ignorado que se combinan:

1. Patrones ignorados por defecto

Estos archivos siempre se ignoran automáticamente:

  • node_modules/, .git/
  • Lock files: package-lock.json, pnpm-lock.yaml, yarn.lock, bun.lockb
  • Configs comunes: *.config.js, *.config.ts, tsconfig.json, jsconfig.json
  • Build outputs: dist/, build/, .next/, .nuxt/, out/
  • Otros: .DS_Store, Thumbs.db

2. Archivo .gitignore

Si existe un .gitignore en tu proyecto, todas sus reglas se respetan automáticamente.

3. Archivo .countlinesignore (opcional)

Puedes crear un archivo .countlinesignore en la raíz de tu proyecto para agregar reglas adicionales específicas para el contador de líneas.

Ejemplo de .countlinesignore:

# Ignorar archivos de prueba
*.test.js
*.spec.ts

# Ignorar tipos de archivos
*.json
*.yaml
*.yml

# Ignorar directorios
docs/
examples/

# Ignorar archivos específicos
README.md

Este archivo es completamente opcional y complementa (no reemplaza) el .gitignore.

Publicar en npm

Para publicar este paquete en npm:

npm login
npm publish

Licencia

MIT