Thank you for your interest in contributing to the Dependency Optimizer project! This document provides guidelines and information for contributors.
- Code of Conduct
- Getting Started
- Development Setup
- Project Structure
- Contributing Guidelines
- Testing
- Documentation
- Release Process
- Community Guidelines
This project adheres to a code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
- Node.js: Version 18 or higher
- Bun: Version 1.2.19 or higher (package manager)
- Git: For version control
- TypeScript: Version 5.0 or higher
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/your-username/dependency-optimizer.git cd dependency-optimizer - Add the upstream repository:
git remote add upstream https://github.com/azwebmaster/dependency-optimizer.git
# Install dependencies
bun install
# Build the project
bun run build
# Run tests
bun test| Script | Description |
|---|---|
bun build |
Build TypeScript to dist/ |
bun test |
Run tests with vitest |
bun test:watch |
Run tests in watch mode |
bun test:coverage |
Run tests with coverage report |
bun test:ui |
Run tests with vitest UI |
bun bundle |
Create bundled distribution |
bun bundle:minified |
Create minified bundle |
- Create a branch:
git checkout -b feature/your-feature-name - Make changes: Implement your feature or fix
- Run tests:
bun testto ensure everything works - Build:
bun buildto check for TypeScript errors - Commit: Use conventional commit messages
- Push:
git push origin feature/your-feature-name - Create PR: Open a pull request on GitHub
src/
├── index.ts # Main entry point and exports
├── cli.ts # CLI interface using Commander.js
├── types.ts # Shared TypeScript interfaces
├── commands/ # Command implementations
│ ├── base.ts # Base command class
│ ├── unused.ts # Unused dependencies command
│ ├── size.ts # Size analysis command
│ ├── duplicates.ts # Duplicate detection command
│ ├── tree.ts # Dependency tree command
│ ├── devcheck.ts # Dev dependency validation
│ ├── config.ts # Configuration management
│ ├── examples.ts # Examples command
│ └── index.ts # Command exports
├── parsers/ # Lock file parsers
│ ├── bun/ # Bun lock file parser
│ ├── npm/ # npm lock file parser
│ ├── pnpm/ # pnpm lock file parser
│ ├── yarn/ # yarn lock file parser
│ └── index.ts # Parser exports
├── config/ # Configuration system
│ ├── loader.ts # Configuration loading
│ ├── types.ts # Configuration types
│ └── index.ts # Configuration exports
├── scanner.ts # Dependency scanning
├── analyzer.ts # Node_modules analysis
├── sizeAnalyzer.ts # Package size analysis
├── duplicateDetector.ts # Duplicate detection
├── lockFileParser.ts # Lock file parsing
├── dependencyTreeBuilder.ts # Dependency tree building
├── devDependencyDetector.ts # Dev dependency detection
└── special/ # Special file handlers
├── vitest.ts # Vitest special handler
└── index.ts # Special exports
We welcome various types of contributions:
- Bug fixes: Fix issues and improve reliability
- New features: Add new functionality and commands
- Documentation: Improve docs, examples, and guides
- Tests: Add or improve test coverage
- Performance: Optimize existing functionality
- Refactoring: Improve code quality and structure
- TypeScript: Use TypeScript with strict settings
- ESM: Use ES modules with
.jsextensions in imports - Naming: Use descriptive names for functions and variables
- Comments: Add JSDoc comments for public APIs
- Formatting: Use consistent formatting (handled by build tools)
Use conventional commit messages:
type(scope): description
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changesrefactor: Code refactoringtest: Test changeschore: Build process or auxiliary tool changes
Examples:
feat(unused): add recursive scanning for monorepos
fix(duplicates): resolve lock file parsing issues
docs(readme): update installation instructions
test(scanner): add tests for edge cases
- Create issue: Discuss significant changes in an issue first
- Fork and branch: Create a feature branch from main
- Implement: Make your changes with tests
- Test: Ensure all tests pass
- Document: Update documentation if needed
- Submit PR: Create a pull request with a clear description
- Tests: Include tests for new functionality
- Documentation: Update docs for new features
- TypeScript: Ensure no TypeScript errors
- Linting: Ensure code passes linting
- Description: Provide clear PR description
Tests are organized in the same structure as source code:
src/
├── scanner.test.ts # Scanner tests
├── analyzer.test.ts # Analyzer tests
└── commands/
└── unused.test.ts # Command tests
# Run all tests
bun test
# Run tests in watch mode
bun test:watch
# Run tests with coverage
bun test:coverage
# Run tests with UI
bun test:uiUse Vitest for testing:
import { describe, it, expect } from 'vitest';
import { DependencyScanner } from '../scanner.js';
describe('DependencyScanner', () => {
it('should scan for unused dependencies', async () => {
const scanner = new DependencyScanner();
const results = await scanner.scan('./test-project');
expect(results).toBeDefined();
expect(Array.isArray(results)).toBe(true);
});
});Use test utilities from test/testUtils.ts:
import { createTestProject, cleanupTestProject } from '../test/testUtils.js';
describe('Scanner', () => {
let testProject: string;
beforeEach(() => {
testProject = createTestProject();
});
afterEach(() => {
cleanupTestProject(testProject);
});
});- README.md: Main project documentation
- API.md: API documentation
- CONTRIBUTING.md: This file
- CHANGELOG.md: Version history
- docs/: Command-specific documentation
- examples/: Usage examples
- Clear and concise: Write clear, easy-to-understand documentation
- Examples: Include practical examples
- Up-to-date: Keep documentation current with code changes
- Consistent: Use consistent formatting and style
Each command should have documentation in docs/:
- Usage: Command syntax and options
- Examples: Common usage patterns
- Output: Expected output format
- Configuration: Configuration options
- Tips: Best practices and tips
We use Changesets for version management:
# Create a changeset
bun changeset
# Apply changesets and bump versions
bun version
# Publish to NPM
bun release- All tests pass
- Documentation is updated
- CHANGELOG.md is updated
- Version is bumped
- Release notes are prepared
- NPM package is published
- Issues: Use GitHub issues for bug reports and feature requests
- Discussions: Use GitHub discussions for questions and ideas
- Documentation: Check existing documentation first
When reporting issues, include:
- Version: Version of the tool
- Environment: OS, Node.js version, package manager
- Steps: Steps to reproduce the issue
- Expected: Expected behavior
- Actual: Actual behavior
- Logs: Relevant error messages or logs
When requesting features:
- Use case: Describe the use case
- Motivation: Explain why this feature is needed
- Alternatives: Describe any alternatives considered
- Implementation: Suggest implementation approach if possible
When reviewing code:
- Be constructive: Provide helpful feedback
- Be respectful: Maintain a positive tone
- Be thorough: Check for bugs, performance, and style
- Be timely: Respond to PRs in a reasonable time
# Link the package globally for testing
bun link
# Test CLI commands
depoptimize unused --help
# Unlink when done
bun unlink# Enable debug logging
DEBUG=depoptimize:* depoptimize unused
# Run with verbose output
depoptimize unused --verbose# Test with large projects
depoptimize unused --recursive
# Profile performance
bun test --coverageBy contributing to this project, you agree that your contributions will be licensed under the MIT License.
- GitHub Issues: Create an issue
- GitHub Discussions: Join discussions
- Maintainer: @azwebmaster
Thank you for contributing to Dependency Optimizer! 🚀