1.0.0 β€’ Published 5 months ago

repo-mapper v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

repo-mapper πŸ—ΊοΈ

A powerful Node.js package that generates detailed repository maps, summaries, and statistics. Perfect for documentation, codebase understanding, and AI prompts.

Features ✨

  • πŸ“ Generate clear, hierarchical repository structure
  • πŸ“Š Collect detailed statistics about your codebase
  • πŸ“ Create concise summaries of repository content
  • ⚑ Fast and efficient directory scanning
  • πŸ€– AI-prompt friendly output format

Installation

npm install repo-mapper

Project Structure

root/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts       # Main entry point
β”‚   β”œβ”€β”€ mapper.ts      # Core mapping functionality
β”‚   └── types.ts       # TypeScript type definitions
β”œβ”€β”€ tests/
β”‚   └── __tests__/     # Test files
└── docs/             # Documentation

Core Files

src/index.ts

Entry point that exports the main mapRepository function. Acts as the public API for the package.

src/mapper.ts

Contains the RepoMapper class that handles:

  • Directory scanning
  • Structure generation
  • Summary creation
  • Statistics collection

src/types.ts

TypeScript interfaces and types for:

  • MapResult
  • MapperOptions
  • Internal types

API Documentation

Main Function

async function mapRepository(
  dirPath: string,
  options: MapperOptions = {}
): Promise<MapResult>

Parameters

  • dirPath: Path to the repository directory to map
  • options: Configuration options (optional)
    interface MapperOptions {
      ignorePaths?: string[];     // Paths to ignore
      maxDepth?: number;          // Maximum directory depth
      // Add other options as needed
    }

Returns

interface MapResult {
  structure: string;     // Formatted repository structure
  summary: string;       // Repository summary
  statistics: {          // Repository statistics
    totalFiles: number;
    totalDirectories: number;
    fileTypes: Record<string, number>;
    // Other statistics
  }
}

Usage Examples

Basic Usage

import { mapRepository } from 'repo-mapper';

const result = await mapRepository('./project-path');
console.log(result.structure);

With Options

const result = await mapRepository('./project-path', {
  ignorePaths: ['node_modules', 'dist'],
  maxDepth: 3
});

Getting Statistics

const { statistics } = await mapRepository('./project-path');
console.log(statistics.totalFiles);
console.log(statistics.fileTypes);

Common Use Cases

  1. Repository Documentation

    • Generate clear repository structure documentation
    • Create standardized README files
    • Document codebase organization
  2. AI Development

    • Generate context for AI programming assistants
    • Create structured input for code analysis
    • Standardize repository documentation
  3. Development Workflows

    • Onboard new team members
    • Track project structure changes
    • Maintain consistent documentation

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

This project is licensed under the ISC License.