README.md برای پروژه NodeCLI markdown
A powerful command-line interface (CLI) tool for scaffolding modern Node.js projects with pre-configured templates and best practices.
- ✅ Multiple Templates - Choose from 10+ project templates
- ✅ Interactive CLI - User-friendly prompts with inquirer
- ✅ TypeScript Support - Built with TypeScript for type safety
- ✅ Variable Replacement - Dynamic project name, author, description
- ✅ Auto Dependency Installation - Install packages automatically with npm
- ✅ Git Integration - Initialize Git repository with first commit
- ✅ Beautiful Output - Colored logs with chalk and loading spinners with ora
- ✅ Extensible - Easy to add new templates
- ✅ Zero Configuration - Get started immediately
| Template | Description | Use Case |
|---|---|---|
| ExpressAPI | REST API with Express, MongoDB, Mongoose | Backend services |
| ExpressView | Express with EJS/Pug templating | Server-side rendering |
| GraphQLApi | GraphQL API with Apollo Server | Flexible APIs |
| MicroService | Microservice architecture with gRPC | Distributed systems |
| CLITool | CLI tool with Commander.js | Command-line utilities |
| FullApp | Full-stack with React + Express | Web applications |
| FileManager | File management system | Uploads, file processing |
| TelegramBot | Telegram bot with Node.js | Chatbots |
| WebsocketServer | WebSocket server with Socket.io | Real-time apps |
| DataScraper | Web scraping with Puppeteer/Cheerio | Data extraction |
# Install globally
npm install -g my-cli
# Or use npx without installation
npx my-cli create my-app
Local Development
bash
# Clone the repository
git clone https://github.com/your-username/nodecli.git
cd nodecli
# Install dependencies
npm install
# Build the project
npm run build
# Link globally for testing
npm link
# Now you can use the CLI
my-cli create my-app
📦 Usage
Create a New Project
bash
my-cli create <project-name>
Interactive Prompt
bash
my-cli create my-awesome-project
You will be guided through:
Select a template - Choose from 10+ templates
Enter author name - Your name or username
Enter description - Project description
Install dependencies? - Auto install with npm
Initialize Git? - Auto init with first commit
Overwrite? - Overwrite existing folder
Example
bash
$ my-cli create my-express-api
🚀 Creating project: my-express-api
? Select a project template: Express API
? Author name: Hossain Yazdani
? Project description: A RESTful API for my application
? Install dependencies? Yes
? Initialize Git repository? Yes
? Overwrite if folder exists? No
📦 Creating project from template: ExpressAPI...
✅ Project structure created!
📦 Installing dependencies...
✅ Dependencies installed!
🔧 Initializing Git...
✅ Git initialized!
✅ Project my-express-api created successfully!
📁 Next steps:
cd my-express-api
npm run dev
📚 Template: ExpressAPI
👤 Author: Hossain Yazdani
📂 Project Structure
text
NodeCLI/
├── src/
│ ├── commands/
│ │ ├── create.ts # Main create command
│ │ └── index.ts # Command exports
│ ├── core/
│ │ ├── logger.ts # Logging system (chalk + ora)
│ │ └── filesystem.ts # File operations (fs-extra)
│ ├── templates/ # Project templates
│ │ ├── ExpressAPI/
│ │ │ ├── src/
│ │ │ ├── package.json
│ │ │ └── README.md
│ │ ├── CLITool/
│ │ ├── GraphQLApi/
│ │ └── ...
│ └── index.ts # Main entry point
├── bin/
│ └── cli.js # Executable file
├── dist/ # Compiled output
├── package.json
├── tsconfig.json
├── .gitignore
└── README.md
🔧 Command Options
Command Description
create <name> Create a new project
hello Test command
--version Show version
--help Show help
📝 Template Variables
Each template supports dynamic variable replacement:
Variable Description Example
{{projectName}} Project name my-app
{{author}} Author name Hossain Yazdani
{{description}} Project description A REST API project
{{year}} Current year 2026
Example in package.json:
json
{
"name": "{{projectName}}",
"version": "1.0.0",
"description": "{{description}}",
"author": "{{author}}"
}
🧩 Adding New Templates
Create template folder
bash
mkdir src/templates/MyTemplate
Add template files
bash
# Add package.json, README.md, src/, etc.
Use variables in template files:
json
{
"name": "{{projectName}}",
"author": "{{author}}"
}
Update template list in src/commands/create.ts:
typescript
const TEMPLATES = [
{ name: '🚀 My Template', value: 'MyTemplate' },
// ...
];
🛠️ Development
Prerequisites
Node.js 18+
npm or yarn
Setup
bash
# Clone repository
git clone https://github.com/your-username/nodecli.git
cd nodecli
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build for production
npm run build
# Link globally
npm link
Available Scripts
Script Description
npm run dev Run in development mode (tsx)
npm run build Build TypeScript to JavaScript
npm start Run built version
npm test Run tests
npm run lint Lint code
🎨 Tech Stack
Category Technology
Runtime Node.js
Language TypeScript
CLI Framework Commander.js
User Input Inquirer.js
Logging Chalk + Ora
File Operations fs-extra
System Commands execa
Development tsx, typescript
Testing Jest
🤝 Contributing
Contributions are welcome! Here's how:
Fork the repository
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
Development Workflow
bash
# Fork and clone
git clone https://github.com/your-username/nodecli.git
cd nodecli
# Install dependencies
npm install
# Create a new template
mkdir src/templates/MyTemplate
# Test locally
npm run dev create test-app
# Build
npm run build
# Submit PR
📄 License
MIT © {{author}} - {{year}}
👨💻 Author
Hossain Yazdani
GitHub: @hossain-yzdani
LinkedIn: Hossain Yazdani
⭐ Show Your Support
If you found this project helpful, please consider giving it a ⭐ on GitHub!