A CLI tool to generate shadcn/ui registry JSON for your project with a clean, maintainable architecture.
src/
├── index.ts # Main entry point
├── cli/
│ └── index.ts # CLI command setup and parsing
├── config/
│ └── index.ts # Configuration loading and creation
├── constants/
│ └── index.ts # Application constants and defaults
├── core/
│ ├── index.ts # Core module exports
│ └── registry-generator.ts # Main registry generation logic
├── types/
│ └── index.ts # TypeScript type definitions
└── utils/
├── index.ts # Utility module exports
├── dependency-extractor.ts # Package.json dependency extraction
├── file-categorizer.ts # File categorization logic
├── file-filter.ts # File filtering logic
├── file-scanner.ts # Directory scanning logic
└── shadcn-detector.ts # ShadCN component detection
npm install -g shadiff# Generate with default settings
shadcn-registry-gen
# Generate with custom options
shadcn-registry-gen generate --root-dir ./src --output my-registry.json --author "Your Name"shadcn-registry-gen initThis creates a shadcn-registry.config.json file in your project root.
generate- Generate registry from project componentsinit- Initialize configuration file--help- Show help information
-r, --root-dir <dir>- Root directory to scan (default: current directory)-o, --output <file>- Output file (default: "registry.json")-a, --author <author>- Author information (default: "Project Author")
The configuration file (shadcn-registry.config.json) supports the following options:
{
"rootDir": ".",
"outputFile": "registry.json",
"includePatterns": [".tsx", ".ts", ".jsx", ".js", ".css"],
"excludePatterns": [
"node_modules",
".git",
"dist",
"build",
".next",
"pnpm-lock.yaml",
"yarn.lock",
"package-lock.json"
],
"author": "Project Author"
}npm run buildnpm run devThe project follows a modular architecture with clear separation of concerns:
- Core: Contains the main business logic
- Utils: Reusable utility functions and classes
- Types: TypeScript type definitions
- Config: Configuration management
- Constants: Application constants
- CLI: Command-line interface setup
- 🔍 Smart File Detection: Automatically categorizes files based on project structure
- 📦 Dependency Management: Extracts and filters package.json dependencies
- 🎯 ShadCN Integration: Detects and handles shadcn/ui components
- ⚙️ Configurable: Flexible configuration options
- 🏗️ Modular: Clean, maintainable code architecture
- 📋 TypeScript: Full type safety and IntelliSense support
The tool automatically categorizes files into:
- Component: React components and UI elements
- Page: Next.js pages and route components
- Layout: Layout components
- Lib: Utilities, hooks, services, and business logic
- Style: CSS and styling files
- Config: Configuration files
- Asset: Images, icons, and static assets
- App: App router specific files
- Fork the repository
- Create a feature branch
- Make your changes following the existing architecture
- Add tests if needed
- Submit a pull request
MIT License - see LICENSE file for details.
Report issues at: https://github.com/Prathamesh-Chougale-17/shadiff/issues