UNPKG

node-genie

Version:

Interactive CLI tool to quickly scaffold Node.js projects with TypeScript/JavaScript support and multiple architecture options

285 lines (203 loc) โ€ข 7.87 kB
# ๐Ÿงžโ€โ™‚๏ธ Node Genie Interactive CLI tool to quickly scaffold Node.js projects with TypeScript/JavaScript support and multiple architecture options. [![npm version](https://badge.fury.io/js/node-genie.svg)](https://badge.fury.io/js/node-genie) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Node.js Version](https://img.shields.io/badge/node-%3E%3D16.0.0-brightgreen)](https://nodejs.org/) ## โœจ Features - ๐ŸŽจ **Colored Interactive CLI** - Beautiful interface with cursor navigation - ๐Ÿ’ป **Language Support** - Choose between TypeScript (recommended) or JavaScript - ๐Ÿ—๏ธ **Multiple Architectures** - Choose between MVC structure or Simple structure - ๐Ÿ“‚ **MVC Architecture** - Full structured project with controllers, models, routes, and more - ๐Ÿ“ **Simple Structure** - Single server file with basic route (no src folder) - ๐Ÿ”ง **Code Quality** - Optional ESLint + Prettier setup - ๐Ÿ“ **Essential Files** - Always includes .gitignore, .env template, and configuration files - ๐Ÿš€ **Ready to Run** - Complete project setup with package.json and scripts - ๐Ÿ“ฆ **Package Manager Support** - Choose between npm, yarn, or pnpm ## ๐Ÿš€ Quick Start ### Installation ```bash # Install globally via npm npm install -g node-genie # Or using yarn yarn global add node-genie # Or using pnpm pnpm add -g node-genie ``` ### Usage ```bash # Run the interactive CLI node-genie ``` ### Development Installation If you want to contribute or run from source: ```bash # Clone the repository git clone https://github.com/ayushrajput8021/node-genie.git cd node-genie # Install dependencies npm install # Link the CLI globally (for development) npm link ``` The CLI will guide you through: 1. **Project Name** - Enter your project name 2. **Language Choice** - TypeScript (recommended) or JavaScript 3. **Architecture** - MVC structure or Simple structure 4. **Package Manager** - npm, yarn, or pnpm 5. **Code Quality** - Set up ESLint + Prettier ### Architecture Options #### ๐Ÿ—๏ธ MVC Architecture Full structured project with organized folders: - `src/server.ts/js` - Main server file - `src/app.ts/js` - Express app setup - `src/routes/index.ts/js` - Basic routing - `src/middlewares/auth.ts/js` - Authentication middleware - `src/database/connection.ts/js` - Database setup - Plus controllers, models, services, utils folders #### ๐Ÿ“ Simple Structure Minimal setup with just a server file in the root: - `server.ts/js` - Single server file with basic route and middleware - No src folder, perfect for quick prototypes or learning **Always included:** `.gitignore`, `.env` template, and appropriate configuration files ## ๐Ÿ“ Generated Project Structure ### MVC Architecture ```bash my-project/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ configs/ โ”‚ โ”‚ โ””โ”€โ”€ index.ts/js # Configuration management โ”‚ โ”œโ”€โ”€ controllers/ # Request handlers โ”‚ โ”œโ”€โ”€ database/ โ”‚ โ”‚ โ””โ”€โ”€ connection.ts/js # Database connection setup โ”‚ โ”œโ”€โ”€ middlewares/ โ”‚ โ”‚ โ””โ”€โ”€ auth.ts/js # Authentication middleware โ”‚ โ”œโ”€โ”€ models/ # Data models โ”‚ โ”œโ”€โ”€ routes/ โ”‚ โ”‚ โ””โ”€โ”€ index.ts/js # API routes โ”‚ โ”œโ”€โ”€ services/ # Business logic โ”‚ โ”œโ”€โ”€ types/ # TypeScript types (TS projects only) โ”‚ โ”œโ”€โ”€ utils/ โ”‚ โ”‚ โ””โ”€โ”€ index.ts/js # Utility functions โ”‚ โ”œโ”€โ”€ app.ts/js # Express app setup โ”‚ โ””โ”€โ”€ server.ts/js # Main server file โ”œโ”€โ”€ .env # Environment variables โ”œโ”€โ”€ .gitignore # Git ignore rules โ”œโ”€โ”€ .eslintrc.json # ESLint configuration (optional) โ”œโ”€โ”€ .prettierrc.json # Prettier configuration (optional) โ”œโ”€โ”€ tsconfig.json # TypeScript configuration (if TS) โ””โ”€โ”€ package.json # Project dependencies and scripts ``` ### Simple Structure ```bash my-project/ โ”œโ”€โ”€ server.ts/js # Single server file with route โ”œโ”€โ”€ .env # Environment variables โ”œโ”€โ”€ .gitignore # Git ignore rules โ”œโ”€โ”€ .eslintrc.json # ESLint configuration (optional) โ”œโ”€โ”€ .prettierrc.json # Prettier configuration (optional) โ”œโ”€โ”€ tsconfig.json # TypeScript configuration (if TS) โ””โ”€โ”€ package.json # Project dependencies and scripts ``` ## ๐Ÿ“ฆ Generated Dependencies ### For TypeScript Projects - **Runtime**: `express`, `dotenv`, `cors` - **Development**: `typescript`, `@types/*`, `tsx`, `rimraf` - **Code Quality**: `eslint`, `prettier`, `@typescript-eslint/*` ### For JavaScript Projects - **Runtime**: `express`, `dotenv`, `cors` - **Development**: `nodemon` - **Code Quality**: `eslint`, `prettier` ## ๐ŸŽฏ Available Scripts After project generation, you can use these scripts: ```bash # Install dependencies (using your chosen package manager) npm install # or yarn install / pnpm install # Start the server (production) npm start # Start development server with auto-reload npm run dev # Build TypeScript to JavaScript (TS projects only) npm run build # Clean build directory (TS projects only) npm run clean # Run ESLint (if enabled) npm run lint # Fix ESLint issues automatically (if enabled) npm run lint:fix # Format code with Prettier (if enabled) npm run format ``` ### Example Usage ```bash # Create a new project node-genie # Navigate to your project cd my-awesome-project # Install dependencies pnpm install # Start development server pnpm run dev # Your server will be running at http://localhost:3000 ``` ## ๐Ÿ”ง Development To contribute to node-genie: ```bash # Clone and setup git clone https://github.com/ayushrajput8021/node-genie.git cd node-genie npm install # Link for local development npm link # Test the CLI node-genie # Unlink when done npm unlink node-genie ``` ### Publishing ```bash # Update version npm version patch # or minor/major # Publish to npm npm publish ``` ## ๐Ÿ“‹ Roadmap ### Phase 1 (Current) โœ… - Interactive CLI with colors - TypeScript/JavaScript support - MVC structure generation - Simple structure option - Package manager selection - ESLint, Prettier, configs ### Phase 2 (Coming Soon) - ๐Ÿ—„๏ธ Database integration options (MongoDB, PostgreSQL, MySQL) - ๐Ÿงช Testing framework selection (Jest, Vitest) - ๐Ÿ”’ Authentication templates (JWT, Passport) - ๐Ÿ’พ User preference memory - ๐Ÿ“Š API documentation setup (Swagger) ### Phase 3 (Future) - ๐Ÿ”Œ Plugin system - ๐Ÿ‘ฅ Team templates - โš™๏ธ CI/CD configurations - ๐Ÿณ Docker support - โ˜๏ธ Cloud deployment templates ## ๐Ÿค Contributing 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/amazing-feature`) 3. Commit your changes (`git commit -m 'Add amazing feature'`) 4. Push to the branch (`git push origin feature/amazing-feature`) 5. Open a Pull Request ## ๐Ÿ‘จโ€๐Ÿ’ป Author **Ayush Rajput** - GitHub: [@ayushrajput8021](https://github.com/ayushrajput8021) - Email: <ayushrajput8021@gmail.com> ## ๐ŸŒŸ Show your support Give a โญ๏ธ if this project helped you! ## ๐Ÿ“ˆ Stats ![npm](https://img.shields.io/npm/dt/node-genie) ![GitHub stars](https://img.shields.io/github/stars/ayushrajput8021/node-genie) ![GitHub forks](https://img.shields.io/github/forks/ayushrajput8021/node-genie) ## ๐Ÿ“„ License MIT License - see the [LICENSE](LICENSE) file for details. ## ๐Ÿ™ Acknowledgments - Built with [Commander.js](https://github.com/tj/commander.js/), [Inquirer.js](https://github.com/SBoudrias/Inquirer.js/), and [Chalk](https://github.com/chalk/chalk) - Inspired by create-react-app and other scaffolding tools