smart-renamer
v1.2.1
Published
π Intelligent file naming suggestions based on project-specific naming conventions. Interactive CLI tool that asks yes/no for each file renaming.
Maintainers
Readme
Renamer
π Intelligent file naming suggestions based on project-specific naming conventions.
A TypeScript/Bun CLI tool that automatically detects, suggests, and renames files to follow your project's naming patterns. Interactive and smart - it asks you about each file individually!
Features
- π― Smart Convention Detection: Automatically detects naming patterns from existing files
- βοΈ Flexible Configuration: Store naming preferences in
naming.config - π Interactive Renaming: Ask yes/no for each file individually
- π₯οΈ CLI Interface: Command-line tool for managing naming conventions
- β Validation: Ensures new file names follow project conventions
- π« Smart Exclusions: Automatically skips config files, images, and markdown files
- π Project Analysis: Analyze naming consistency across your project
- π File Watcher: Monitor for new files and suggest names in real-time
Supported Naming Conventions
camelCase: fileName.tssnake_case: file_name.tskebab-case: file-name.tsPascalCase: FileName.tsUPPER_SNAKE_CASE: FILE_NAME.ts
Installation
npm install -g smart-renamer
# or
bun install -g smart-renamerQuick Start
# Initialize in your project
cd your-project
renamer init
# Rename files interactively - asks yes/no for each file
renamer rename
# Analyze your project's naming patterns
renamer analyzeCommands
renamer init
Initialize naming convention for your project with interactive setup:
renamer initrenamer rename β Main Command
Interactive file renaming - asks yes/no for each file:
# Interactive mode - asks yes/no for each file
renamer rename
# Preview what would be renamed
renamer rename --dry-run
# Rename all files without asking
renamer rename --force
# Keep specific files unchanged
renamer rename --keep "file1.js,file2.ts"renamer set-convention <convention>
Set the naming convention:
renamer set-convention kebab-caserenamer validate
Validate existing file names:
# Check all files
renamer validate
# Show suggested fixes
renamer validate --fixrenamer suggest <filename>
Get naming suggestions for a specific file:
renamer suggest "MyFileName.ts"renamer watch
Monitor for new files and suggest names:
renamer watchrenamer analyze
Analyze project structure and naming patterns:
renamer analyzeConfiguration
Create a naming.config file in your project root:
[naming]
convention=kebab-case
files=*.ts,*.js
folders=kebab-case
exceptions=index,main,appConfiguration Options
convention: Primary naming conventionfiles: File patterns to apply the convention tofolders: Naming convention for directoriesexceptions: Files that don't need to follow the convention
Smart Exclusions
The tool automatically skips these file types:
π« Automatically Excluded:
- Config files: Any file containing "config" (
next.config.mjs,webpack.config.js) - Image files:
.jpg,.png,.svg,.gif, etc. - Markdown files:
.md,.markdown - Declaration files (all languages):
- TypeScript:
.d.ts,.d.mts,.d.cts(likenext-env.d.ts,types.d.ts) - C/C++:
.h,.hpp,.hxx(header files) - Python:
.pyi(stub files) - Haskell:
.hi(interface files) - Ruby:
.rbi(interface files) - ReasonML:
.rei(interface files) - OCaml:
.mli(interface files) - F#:
.fsi(signature files) - And more:
.sig,.spec,.def
- TypeScript:
- System files:
package.json,tsconfig.json,.gitignore, etc. - Lock files:
package-lock.json,yarn.lock,bun.lockb - Environment files:
.env,.env.example - Build configs:
webpack.config.js,vite.config.ts, etc.
π Example Output:
$ renamer rename
π Finding files to rename to 'kebab-case' convention...
π Skipping next.config.mjs (config files excluded by default)
π Skipping logo.png (image files excluded by default)
π Skipping README.md (markdown files excluded by default)
π Skipping next-env.d.ts (TypeScript declaration files excluded by default)
π Skipping utils.h (C/C++ header files excluded by default)
π Skipping types.pyi (declaration files excluded by default)
π Found 3 files that can be renamed:
? Rename "userService.ts" to "user-service.ts"? (Y/n) y
β
userService.ts β user-service.ts
? Rename "api_helper.js" to "api-helper.js"? (Y/n) y
β
api_helper.js β api-helper.js
? Rename "MyComponent.jsx" to "my-component.jsx"? (Y/n) n
βοΈ Skipped MyComponent.jsx
π Completed: 2 renamed, 1 skipped, 0 failedUsage Examples
Typical Workflow
# 1. Initialize in your project
cd my-react-app
renamer init
# 2. Choose kebab-case for consistency
# (Interactive setup will guide you)
# 3. Rename existing files
renamer rename
# This will ask about each file: "Rename UserProfile.jsx to user-profile.jsx?"
# 4. Set up file watching for new files
renamer watchProject Analysis
$ renamer analyze
π Project Analysis
π Total files: 45
π― Most common convention: camelCase
π Consistency: 73.3%
π Convention breakdown:
camelCase 25 files (55.6%)
kebab-case 12 files (26.7%)
snake_case 5 files (11.1%)
PascalCase 3 files (6.7%)
UPPER_SNAKE_CASE 0 files (0.0%)Why Use Renamer?
- Consistency: Maintain consistent naming across your project
- Team Standards: Enforce team naming conventions
- Refactoring: Easily migrate from one naming style to another
- New Projects: Set up naming standards from the start
- Code Quality: Improve codebase readability and maintainability
Tech Stack
- Runtime: Bun
- Language: TypeScript
- CLI: Commander.js
- File Watching: Chokidar
- Interactive Prompts: Inquirer.js
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ for developers who care about consistent naming conventions.
