vite-react-cli-tool
is a command-line tool designed to scaffold React projects with a predefined hexagonal architecture. It sets up essential folders and integrates optional dependencies like Tailwind CSS, Redux Toolkit, and React Router, allowing for a faster and more structured development process.
- Scaffold React projects with a Vite + React template.
-
Hexagonal architecture setup with standard folders for modular organization:
assets
,components
,modules
,routes
,store
. - Optional dependency setup for Tailwind CSS, Redux Toolkit, and React Router with simple flags.
To install vite-react-cli-tool
globally run:
npm install -g vite-react-cli-tool
To create a new React project with the hexagonal architecture:
vbc create <project-name> [options]
Replace <project-name>
with the desired name of your project. You can add optional flags to include Tailwind CSS, Redux Toolkit, and React Router.
-
--tw
: Adds Tailwind CSS setup, with the main CSS file configured asindex.css
. -
--rtk
: Sets up Redux Toolkit with a basic store and example slice. -
--rr
: Configures React Router with basic routing and sample pages.
vbc create my-new-app --tw --rtk --rr
This command will create a new Vite React project named my-new-app
with Tailwind CSS, Redux Toolkit, and React Router preconfigured.
When using the --tw
flag, the tool will:
-
Install Tailwind CSS and required dependencies (
postcss
andautoprefixer
). -
Generate a
tailwind.config.js
file and configure it with the content paths for Tailwind to scan. -
Add an
index.css
file insrc/assets/
with the necessary Tailwind directives (@tailwind base
,@tailwind components
, and@tailwind utilities
).
NB: the index.css
file in src/assets/
is the file you should import in App.tsx
When using the --rtk
flag, the tool will:
-
Install Redux Toolkit (
@reduxjs/toolkit
) and React-Redux (react-redux
). -
Create a Redux store configuration in
src/store/create-store.ts
. -
Add an example slice (
exampleSlice.ts
) insrc/modules/slice/
with basic actions, demonstrating Redux setup.
When using the --rr
flag, the tool will:
-
Install
react-router-dom
for routing. -
Set up routing in
src/routes/ROUTER.tsx
with sample paths. -
Create route definitions in
src/routes/routes.ts
. -
Add two sample pages (
Home.tsx
andAbout.tsx
) insrc/pages/
to demonstrate routing.
The generated project will have the following structure:
my-new-app/
├── src/
│ ├── __e2e__/ # End-to-end testing files
│ ├── assets/ # Static files (images, fonts, etc.)
│ ├── components/ # Reusable UI components
│ ├── modules/ # Core application logic, organized by domain
│ │ ├── __tests__/ # Unit and integration tests for modules
│ │ ├── infra/ # Infrastructure layer (APIs, data sources)
│ │ ├── models/ # Data models and types
│ │ ├── slice/ # Redux slices and state
│ │ │ └── exampleSlice.ts # Example Redux slice with actions
│ │ ├── use-case/ # Business logic and use cases
│ └── reducer.ts # Root reducer that combines the module reducers
│ ├── routes/ # Routing configuration
│ │ ├── ROUTER.tsx # Main router component
│ │ └── routes.ts # Route definitions and path configurations
│ └── pages/ # Application pages (e.g., Home, About)
│ ├── Home.tsx # Sample Home page
│ └── About.tsx # Sample About page
│ └── store/ # Redux store setup
│ └── create-store.ts # Store configuration
Scaffolds a new React project with a hexagonal architecture and optional configurations.
Example:
vbc create my-new-app --tw --rtk --rr
This initializes a Vite React project named my-new-app
with Tailwind CSS, Redux Toolkit, and React Router configurations.
To contribute to vite-react-cli-tool
, follow these steps:
- Fork the repository.
- Clone your forked repository.
- Make your changes and commit them.
- Create a pull request.
To work on the tool locally:
-
Clone the repository:
git clone <your-fork-url>
-
Install dependencies:
npm install
-
Build the TypeScript files:
npm run build
-
Link the package locally to test it:
npm link
-
Test the tool by running
vbc
commands from anywhere on your system.
This project is licensed under the ISC License.