1.0.0 โ€ข Published 11 months ago

@developerisnow/git-repositories-statistic-analyzer v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Git Repositories Statistics Analyzer

npm version License: MIT TypeScript

A powerful Node.js tool for analyzing multiple Git repositories and generating comprehensive statistics. Perfect for developers and teams who need to track and analyze Git repositories at scale.

๐Ÿš€ Features

  • ๐Ÿ“Š Analyze multiple Git repositories in bulk
  • ๐Ÿ” System-wide repository scanning
  • ๐Ÿ“ Detailed Git metrics and repository information
  • ๐Ÿ“ˆ CSV output with proper formatting
  • ๐ŸŽฏ Username and empty repository filtering
  • โšก Asynchronous processing
  • ๐Ÿ›ก๏ธ TypeScript support
  • ๐Ÿ“‹ Comprehensive repository statistics

๐Ÿ“ฆ Installation

# Using npm
npm install -g @developerisnow/git-repositories-statistic-analyzer

# Using pnpm (recommended)
pnpm add -g @developerisnow/git-repositories-statistic-analyzer

# Using yarn
yarn global add @developerisnow/git-repositories-statistic-analyzer

๐ŸŽฎ Command Line Usage

Basic Usage

# Analyze specific repositories
git-repositories-statistic-analyzer --folderPath=/path/to/repos --repoList=/path/to/repo_list.txt

# Scan all repositories in the system
git-repositories-statistic-analyzer --folderPath=all --repoList=all

# Filter repositories by username
git-repositories-statistic-analyzer --folderPath=all --repoList=all --filter "UsernamesUrlRepos:username1,username2"

# Find local repositories (no remote URLs)
git-repositories-statistic-analyzer --folderPath=all --repoList=all --filter "UsernamesUrlRepos:Empty"

Options

  • --folderPath: Base directory containing Git repositories or "all" for system scan
  • --repoList: Path to repository list file or "all" for automatic discovery
  • --filter: Filter results (e.g., "UsernamesUrlRepos:user1,user2" or "UsernamesUrlRepos:Empty")

๐Ÿ’ป Programmatic Usage

import { GitAnalyzer, GitScanner } from '@developerisnow/git-repositories-statistic-analyzer';

async function analyzeRepositories() {
  // Load ignore patterns
  const ignorePatterns = await GitScanner.loadIgnorePatterns('.scanignore');
  
  // Find repositories
  const scanner = new GitScanner(ignorePatterns);
  const repoPaths = await scanner.findGitRepos();
  
  // Analyze each repository
  const analyzer = new GitAnalyzer(process.cwd());
  const results = [];
  
  for (const repoPath of repoPaths) {
    const stats = await analyzer.analyzeRepository(repoPath);
    if (stats) {
      results.push(stats);
    }
  }
  
  return results;
}

๐Ÿ“Š Output Format

The tool generates a CSV file with the following columns:

ColumnDescription
nameFolderRepository folder name
usernamesUrlReposUsernames from remote URLs
gitFolderSizeSize of the .git folder (in MB)
dateLastCommitDate of the most recent commit (YYYY-MM-DD)
messageLastCommitMessage of the last commit
amountTotalCommitsTotal number of commits
ageRepoRepository age in days
dateFirstCommitDate of the first commit (YYYY-MM-DD)
urlsRepoRepository remote URLs (cleaned format)
amountUncommitedFilesNumber of uncommitted files
hashLastCommitHash of the last commit
pathFolderFull path to the repository

See git_statistic.example.csv for an example output.

๐Ÿ› ๏ธ Configuration

Repository List Format

Create a text file with one repository folder name per line:

repo1_folder
repo2_folder

Ignore Patterns (.scanignore)

Create a .scanignore file to specify patterns to ignore:

**/node_modules/**
**/vendor/**
**/dist/**
# Add more patterns as needed

๐Ÿงช Development

# Install dependencies
pnpm install

# Run tests
pnpm test

# Run tests with coverage
pnpm test:coverage

# Format code
pnpm format

# Lint code
pnpm lint

# Build the project
pnpm build

# Run in development mode
pnpm dev

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘ค Author

developerisnow

โญ๏ธ Show your support

Give a โญ๏ธ if this project helped you!