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 🙏

© 2025 – Pkg Stats / Ryan Hefner

github-package-analyzer

v0.0.4

Published

Analyze GitHub repositories for package implementation and code quality

Downloads

14

Readme

GitHub Package Analyzer 🔍

A powerful tool to analyze GitHub repositories for package implementation and code quality using the GitHub API and OpenAI's GPT models. Evaluate your dependencies, verify implementations, and get AI-powered suggestions for improvement.

✨ Features

  • 📦 Comprehensive Package Analysis

    • Scans package.json for declared dependencies
    • Verifies actual implementation in codebase
    • Custom pattern matching for different package types
    • Extensible package detection patterns
  • 🤖 AI-Powered Code Analysis

    • Code quality evaluation using OpenAI GPT models
    • Implementation quality scoring
    • Best practices validation
    • Security assessment
    • Performance optimization suggestions
  • 📊 Detailed Reporting

    • Overall repository health score
    • Package-by-package analysis
    • Implementation quality metrics
    • Actionable improvement suggestions
    • Letter grade assignments
  • 🔄 Repository Tools

    • Full repository structure traversal
    • Intelligent file filtering
    • Multi-file code analysis
    • Dependency validation

📥 Installation

npm install github-package-analyzer

⚙️ Configuration

You'll need to provide authentication tokens:

const analyzer = new PackageAnalyzer({
    githubToken: process.env.GITHUB_TOKEN,  // GitHub Personal Access Token
    openaiKey: process.env.OPENAI_API_KEY   // OpenAI API Key
});

🚀 Usage

Basic Example

const PackageAnalyzer = require('github-package-analyzer');
const dotenv = require('dotenv');

dotenv.config();

async function main() {
    const analyzer = new PackageAnalyzer({
        githubToken: process.env.GITHUB_TOKEN,
        openaiKey: process.env.OPENAI_API_KEY
    });
    
    const result = await analyzer.analyze('owner', 'repo', ['react', 'express']);
    console.log(JSON.stringify(result, null, 2));
}

main().catch(console.error);

Extended Example with Custom Patterns

const PackageAnalyzer = require('github-package-analyzer');
const dotenv = require('dotenv');

dotenv.config();

async function analyzeFullStack() {
    // Define custom patterns for various frameworks and libraries
    const customPatterns = {
        'next': {
            filePatterns: ['.js', '.ts', '.jsx', '.tsx'],
            codePatterns: [
                'from "next"',
                'from "next/app"',
                'from "next/document"',
                'from "next/router"'
            ]
        },
        'prisma': {
            filePatterns: ['.ts', '.js'],
            codePatterns: [
                'from "@prisma/client"',
                'new PrismaClient',
                'prisma.$connect'
            ]
        },
        'tailwind': {
            filePatterns: ['.css', '.config.js'],
            codePatterns: [
                'tailwind.config',
                '@tailwind base',
                '@tailwind components',
                '@tailwind utilities'
            ]
        },
        'jest': {
            filePatterns: ['.test.js', '.spec.js', '.test.ts', '.spec.ts'],
            codePatterns: [
                'describe(',
                'test(',
                'it(',
                'expect(',
                'jest.mock'
            ]
        }
    };

    // Initialize analyzer with custom patterns
    const analyzer = new PackageAnalyzer({
        githubToken: process.env.GITHUB_TOKEN,
        openaiKey: process.env.OPENAI_API_KEY,
        patterns: customPatterns
    });

    try {
        // Analyze multiple aspects of a full-stack application
        const result = await analyzer.analyze(
            'owner',
            'repo',
            ['react', 'next', 'prisma', 'tailwind', 'jest']
        );

        // Generate detailed report
        console.log('Analysis Summary:');
        console.log('----------------');
        console.log(`Overall Grade: ${result.summary.grade}`);
        console.log(`Average Score: ${result.summary.averageScore}`);
        console.log('\nPackage Details:');
        
        result.details.dependencies.forEach(pkg => {
            console.log(`\n${pkg.package}:`);
            console.log(`  Installed: ${pkg.installed}`);
            console.log(`  Implemented: ${pkg.implementation}`);
            if (pkg.scores) {
                console.log(`  Code Quality: ${pkg.scores.codeQuality}`);
                console.log(`  Implementation Quality: ${pkg.scores.implementationQuality}`);
                console.log(`  Grade: ${pkg.grade}`);
            }
        });

        // Save detailed report to file
        const fs = require('fs');
        fs.writeFileSync(
            'analysis-report.json',
            JSON.stringify(result, null, 2)
        );

    } catch (error) {
        console.error('Analysis failed:', error);
    }
}

analyzeFullStack().catch(console.error);

📝 Analysis Features

The analyzer performs multiple levels of analysis:

1. Dependency Validation

  • Checks package.json for required dependencies
  • Validates both regular and dev dependencies
  • Reports missing or outdated packages

2. Implementation Detection

  • Scans codebase for actual package usage
  • Supports multiple file extensions
  • Custom pattern matching for different import styles

3. Code Quality Analysis

  • Best practices adherence
  • Error handling patterns
  • Performance optimization opportunities
  • Security vulnerability detection
  • Code organization and structure

4. Implementation Quality

  • Feature utilization assessment
  • Integration pattern analysis
  • Configuration validation
  • Package-specific best practices
  • Code efficiency metrics

📊 Output Format

The analyzer generates detailed reports in the following structure:

{
    "passed": true,
    "summary": {
        "totalScore": 85,
        "averageScore": 85,
        "grade": "B"
    },
    "details": {
        "dependencies": [],
        "implementation": [],
        "codeQuality": [],
        "suggestions": []
    }
}

🎯 Supported Packages

Built-in analysis patterns for:

  • React
  • Express

Add custom patterns by extending the configuration:

const customPatterns = {
    'packageName': {
        filePatterns: ['.ext1', '.ext2'],
        codePatterns: ['import pattern', 'require pattern']
    }
};

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. See our contributing guidelines for more details.

📄 License

MIT License - see LICENSE file for details.

👤 Author

Tom Tarpey

🔒 Security

⚠️ Important: Never commit API keys or tokens to version control. Use environment variables or secure configuration management for sensitive credentials.

📚 Documentation

For detailed API documentation and advanced usage examples, visit our documentation.