Architecture, modular design, and development guide
This project uses a feature-based module structure with subpath exports for optimal bundle sizes. Import only what you need.
The package uses subpath exports for tree-shaking:
{
"exports": {
"./stats": "./dist/features/stats.mjs",
"./charts": "./dist/features/charts.mjs",
"./reports": "./dist/features/reports.mjs",
"./output": "./dist/features/output.mjs",
"./workflow": "./dist/features/workflow.mjs",
"./cli": "./dist/cli.mjs"
}
}Import only what you need - Each feature is independently importable.
Minimal Import (Stats Only):
import { getContributorStats } from 'git-contributor-stats/stats';
const stats = await getContributorStats({ repo: '.' });
console.log(`Total commits: ${stats.totalCommits}`);With Charts:
import { getContributorStats } from 'git-contributor-stats/stats';
import { generateCharts } from 'git-contributor-stats/charts';
const stats = await getContributorStats({ repo: '.' });
await generateCharts(stats, { charts: true, chartFormat: 'svg' });With Reports:
import { getContributorStats } from 'git-contributor-stats/stats';
import { generateReports } from 'git-contributor-stats/reports';
const stats = await getContributorStats({ repo: '.' });
await generateReports(stats, { outDir: './reports', html: true });src/
├── features/ # Feature modules (tree-shakeable entry points)
│ ├── stats.ts # Core statistics
│ ├── charts.ts # Chart generation
│ ├── reports.ts # Report generation
│ ├── output.ts # Console output
│ └── workflow.ts # GitHub Actions workflow
├── cli/ # CLI implementation
│ ├── entry.ts # CLI entry point
│ ├── index.ts # CLI logic
│ └── options.ts # Command-line options
├── analytics/ # Core analysis logic
│ ├── aggregator.ts # Data aggregation
│ ├── aliases.ts # Identity resolution
│ └── analyzer.ts # Analysis algorithms
├── charts/ # Chart rendering
│ ├── renderer.ts # PNG rendering (Chart.js)
│ └── svg.ts # SVG generation
├── git/ # Git operations
│ ├── parser.ts # Git log parsing
│ └── utils.ts # Git commands
├── reports/ # Report generators
│ ├── csv.ts # CSV generation
│ ├── html.ts # HTML generation
│ └── markdown.ts # Markdown generation
└── utils/ # Shared utilities
├── dates.ts # Date parsing
├── files.ts # File operations
├── formatting.ts # Output formatting
├── normalization.ts # Data normalization
└── similarity.ts # String similarity
- Feature Isolation - Each feature is independently usable
- Shared Chunks - Common code automatically split
- Lazy Loading - Import features only when needed
- Zero Circular Dependencies - Clean dependency graph
- ESM-First - Modern JavaScript modules
// Import specific features
import { getContributorStats } from 'git-contributor-stats/stats';
import { generateCharts } from 'git-contributor-stats/charts';
// Lazy-load when needed
if (needCharts) {
const { generateCharts } = await import('git-contributor-stats/charts');
await generateCharts(stats, options);
}// Don't try to import from package root (no barrel export)
import { getContributorStats } from 'git-contributor-stats'; // ERROR!
// Don't import everything if you only need one feature
import * as GitStats from 'git-contributor-stats/stats'; // Less optimalgit clone https://github.com/vikkrantxx7/git-contributor-stats.git
cd git-contributor-stats
npm install# Build the project
npm run build
# Build types only
npm run build:types
# Run tests
npm test
# Run tests in watch mode
npm test:watch
# Run tests with coverage
npm run coverage
# Run linter
npm run biome
# Fix linting issues
npm run biome:fix
# Format code
npm run format
# Fix formatting
npm run format:fix
# Type check
npm run typeCheck
# Generate sample reports
npm run reportnpm run buildGenerates:
dist/
├── features/ # Feature modules
│ ├── stats.mjs
│ ├── charts.mjs
│ ├── reports.mjs
│ ├── output.mjs
│ └── workflow.mjs
├── chunks/ # Shared code chunks
│ ├── analytics-*.mjs
│ ├── git-*.mjs
│ └── utils-*.mjs
├── cli.mjs # CLI entry point
└── *.d.ts # TypeScript declarations
# Run all tests
npm test
# Run specific test file
npm test -- tests/e2e/api.test.ts
# Watch mode
npm test:watch
# Coverage report
npm run coverage
open coverage/index.html# Lint check
npm run biome
# Format check
npm run format
# Type check
npm run typeCheck
# Run all checks
npm run lint- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Run tests and linter:
npm test && npm run lint - Commit following conventional commits:
git commit -m 'feat: add amazing feature' - Push:
git push origin feature/amazing-feature - Open Pull Request
📝 Important: This project uses Conventional Commits. Your commit messages will be automatically validated by commitlint.
This project uses Changesets for automated version management and changelog generation.
Automated (Recommended):
- Add changeset:
npx changeset - Merge to main
- GitHub Action creates "Version Packages" PR
- Merge the PR → auto-publishes to npm
Manual:
# 1. Bump version and update changelog
npm run version
# 2. Commit (using conventional commits)
git add .
git commit -m "chore(release): version packages"
# 3. Build and publish
npm run release
# 4. Push changes and tags
git push && git push --tagsSee RELEASE.md for detailed guide.
Questions or suggestions? Open an issue on GitHub!