@bemedev/codebase
v0.1.3
Published
The CLI for to generate codebase, and import partially a library. From @bemedev
Maintainers
Readme
@bemedev/codebase
A powerful CLI to generate and analyze your TypeScript/JavaScript codebase. This tool allows partial importing of libraries and generates comprehensive analyses of your source code.
🚀 Main Features
- 📊 Codebase analysis: Full analysis of imports, exports and dependencies
- 🔧 Automatic generation: Creates detailed JSON analysis files
- ⚡ Intuitive CLI: Simple and effective command-line interface
- 📦 Partial import: Selective import of library parts
- 🎯 Flexible exclusion: Ability to exclude specific files
- 📈 Statistics: Detailed reports about your codebase
📋 Prerequisites
- Node.js ≥ 22.0.0
- pnpm (recommended) or npm/yarn
🛠️ Installation
Global installation (recommended)
pnpm add -g @bemedev/codebaseLocal installation
pnpm add @bemedev/codebaseDevelopment installation
pnpm add -D @bemedev/codebase🎯 Usage
CLI
Generate a codebase analysis
# Basic analysis - generates a codebase.json file
@bemedev/codebase
# Specify a custom output file
@bemedev/codebase --output my-analysis.json
# Exclude specific files
@bemedev/codebase --exclude node_modules dist lib build
# Use short options
@bemedev/codebase -o output.json node_modules distAvailable options
-o, --output <file>: Output file (default:codebase.json)[excludes...]: List of files/folders to exclude
Programmatic API
import { generate, analyze } from '@bemedev/codebase';
// Analyze the codebase
const analysis = analyze('src');
// Generate an analysis file
await generate({
output: 'my-codebase.json',
excludes: ['node_modules', 'dist'],
});📊 Output format
The generated JSON file contains:
{
"STATS": {
"files": 42,
"imports": 156,
"exports": 89
},
"CODEBASE_ANALYSIS": {
"src/index.ts": {
"imports": ["./functions", "./types"],
"relativePath": "src/index.ts",
"text": "export * from './functions';"
}
}
}🏗️ Project structure
src/
├── cli/ # CLI interface
├── functions/ # Core functions
│ ├── add.ts # Add dependencies
│ ├── generate.ts # Generate analysis
│ ├── init.ts # Initialization
│ └── remove.ts # Removal
├── analyze.ts # Analysis engine
├── types.ts # TypeScript definitions
└── constants.ts # Global constants🧪 Development scripts
# Run tests
pnpm test
# Linting
pnpm lint
# Build
pnpm build
# Development mode with watch
pnpm dev🎨 Examples
Analyze a React project
@bemedev/codebase -o react-analysis.json node_modules public buildAnalyze a Node.js project
@bemedev/codebase -o backend-analysis.json node_modules dist coverageIntegrate into an NPM script
{
"scripts": {
"analyze": "@bemedev/codebase -o analysis/codebase.json",
"analyze:clean": "@bemedev/codebase -o analysis/clean.json node_modules dist lib build"
}
}🤝 Contribution
Contributions are welcome! How to contribute:
- Fork the project
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Contribution guidelines
- Follow commit conventions (Conventional Commits)
- Add tests for new features
- Update documentation when necessary
- Respect existing code style
🐛 Report a bug
If you find a bug, please open an issue with:
- A clear description of the problem
- Steps to reproduce the bug
- Your environment (OS, Node.js version, etc.)
- Error logs if available
