1.0.8 โข Published 8 months ago
@hubspire/react-hub-cli v1.0.8
React Hub CLI ๐
A powerful CLI tool created by Hubspire for bootstrapping React applications with best practices, essential configurations, and common functionalities.
โจ Features
- ๐๏ธ Quick Project Setup - Scaffold a new React project with all the essential configurations
- ๐งฉ Component Generation - Generate reusable components with proper structure
- ๐ Type-Safe - Built with TypeScript for better developer experience
- ๐ CRUD Operations - Generate CRUD pages with minimal effort
- ๐ Authentication - Quickly add login and other authentication pages
- ๐ฑ Responsive Layouts - Built-in responsive layouts and components
- ๐จ UI Components - Integration with ShadCn UI for beautiful, accessible components
- ๐งช Testing Setup - Pre-configured with testing tools
- ๐ GraphQL Support - Integrated with Apollo Client for GraphQL operations
๐ฆ Installation
npm install -g @hubspire/react-hub-cli๐ Quick Start
Create a new React app
rhc create-app my-awesome-appGenerate routes
rhc create-routes home,about,contactCreate login page
rhc create-login path/to/config.jsonGenerate CRUD pages
rhc create-crud path/to/config.jsonGenerate a complete project from a JSON file
rhc generate path/to/config.json๐ Configuration
React Hub CLI uses JSON configuration files to generate complex projects. Here's a basic example:
{
"app": {
"name": "my-app",
"description": "My awesome app",
"author": "Hubspire",
"branding": {
"brandName": "MyApp",
"primaryColor": "#38b2ac",
"secondaryColor": "#f0f2f5",
"logo": "https://example.com/logo.svg"
},
"apiEndpoint": "https://api.example.com"
},
"modules": [
{
"name": "auth",
"pages": [
{
"type": "EmailPassword",
"name": "LoginPage",
"route": "/login",
"isPrivate": false,
"api": [
{
"type": "login",
"graphqlHook": "useLoginMutation",
"queryString": "mutation Login($data: LoginInput!) { login(data: $data) { refreshToken accessToken } }"
}
]
}
]
},
{
"name": "users",
"pages": [
{
"type": "Listing",
"name": "UserListPage",
"route": "/users",
"isPrivate": true,
"api": [
{
"type": "list",
"graphqlHook": "useGetAllUsersQuery",
"queryString": "query GetAllUsers { getAllUsers { id name email } }"
}
],
"columns": [
{ "field": "id", "label": "ID" },
{ "field": "name", "label": "Name" },
{ "field": "email", "label": "Email" }
],
"actions": ["create", "edit", "delete"]
}
]
}
]
}๐ ๏ธ Commands
| Command | Alias | Description |
|---|---|---|
create-app | ca | Create a new React app |
create-routes | cr | Create new routes for the application |
create-login | clogin | Create login page and setup authentication |
create-crud | crud | Create CRUD pages for a module |
generate | g | Generate a complete project from a JSON file |
info | i | Display system and CLI information |
๐งฐ Project Structure
When you create a new project with React Hub CLI, it sets up the following structure:
my-awesome-app/
โโโ src/
โ โโโ assets/ # Static assets
โ โโโ components/ # Reusable UI components
โ โโโ config/ # Configuration files
โ โ โโโ apollo/ # Apollo Client setup
โ โโโ hooks/ # Custom React hooks
โ โโโ layout/ # Layout components
โ โโโ lib/ # Utility functions
โ โโโ pages/ # Page components
โ โโโ routes/ # Routing configuration
โ โโโ types/ # TypeScript type definitions
โ โโโ vars/ # Apollo reactive variables
โ โโโ App.tsx # Main App component
โ โโโ main.tsx # Entry point
โโโ .eslintrc.js # ESLint configuration
โโโ .husky/ # Git hooks
โโโ .prettierrc.js # Prettier configuration
โโโ codegen.ts # GraphQL code generation
โโโ tsconfig.json # TypeScript configuration
โโโ vite.config.ts # Vite configuration๐ Development Workflow
React Hub CLI sets up a project with the following development tools:
- Vite - Fast development server and build tool
- TypeScript - Type-safe code
- ESLint - Code linting
- Prettier - Code formatting
- Husky - Git hooks
- Commitizen - Standardized commit messages
- GraphQL Codegen - Generate TypeScript types from GraphQL schema
๐จ UI Components
The CLI integrates with ShadCn UI, a component library built on top of Tailwind CSS. It provides:
- Form components (inputs, buttons, selects)
- Layout components (cards, drawers, dialogs)
- Navigation components (sidebar, pagination)
- Data display components (tables, lists)
- Feedback components (alerts, toasts)
๐ API Integration
React Hub CLI sets up Apollo Client for GraphQL API integration, including:
- Authentication flow with token management
- Error handling and token refresh
- Code generation for type-safe GraphQL operations
- Reactive variables for client-side state management