rnc-cli-dta
v1.0.3
Published
React component generator CLI
Readme
RNC CLI 🚀
A lightweight Node.js CLI tool that generates React components with support for both JavaScript (.jsx) and TypeScript (.tsx) templates.
Why RNC?
Creating React components repeatedly can be time-consuming and error-prone. RNC automates the process by generating a component folder and boilerplate code in seconds.
Benefits
- ⚡ Faster component creation
- 📁 Consistent folder structure
- ⚛️ Supports React JSX components
- 🔷 Supports React TypeScript components
- 🛠 Reduces repetitive boilerplate code
- 🚀 Easy to use from the terminal
Installation
Install globally using npm:
npm install -g rnc-cliOr run directly using npx:
npx rnc-cli ButtonUsage
Generate a JSX Component
RNC ButtonGenerated structure:
Button/
└── Button.jsxGenerated code:
const Button = () => {
return (
<div>
Button Component
</div>
);
};
export default Button;Generate a TypeScript Component
RNC Carousel.tsxGenerated structure:
Carousel/
└── Carousel.tsxGenerated code:
type CarouselProps = {
// add props here
};
const Carousel = (props: CarouselProps) => {
return (
<div>
Carousel Component
</div>
);
};
export default Carousel;How It Works
When you execute:
RNC Carousel.tsxthe CLI performs the following steps:
- Reads command-line arguments using
process.argv - Extracts the component name and extension
- Defaults to
.jsxif no extension is provided - Creates a folder with the component name
- Generates the component file
- Inserts a predefined React template
- Saves the file automatically
Workflow:
Terminal Command
↓
process.argv
↓
Parse Name & Extension
↓
Create Folder
↓
Generate Template
↓
Write File
↓
Ready-to-use React ComponentExamples
RNC ButtonCreates:
Button/
└── Button.jsxRNC Navbar.jsxCreates:
Navbar/
└── Navbar.jsxRNC Dashboard.tsxCreates:
Dashboard/
└── Dashboard.tsxTech Stack
- Node.js
- JavaScript (ES Modules)
- File System API (
fs) - npm CLI Packaging
Future Enhancements
- CSS/SCSS file generation
- React Hooks templates
- Page generation
- Index export generation
- Custom template support
- Interactive CLI prompts
Planned Feature: Multiple Component Creation
Generate multiple React components at once:
RNC Button Card Modal Navbar
Output:
Button/ └── Button.jsx
Card/ └── Card.jsx
Modal/ └── Modal.jsx
Navbar/ └── Navbar.jsx
This feature will improve developer productivity by allowing batch generation of components with a single command.
License
MIT License
Built with ❤️ for React developers.
