1.0.8 โ€ข Published 11 months ago

@hubspire/react-hub-cli v1.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

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-app

Generate routes

rhc create-routes home,about,contact

Create login page

rhc create-login path/to/config.json

Generate CRUD pages

rhc create-crud path/to/config.json

Generate 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

CommandAliasDescription
create-appcaCreate a new React app
create-routescrCreate new routes for the application
create-logincloginCreate login page and setup authentication
create-crudcrudCreate CRUD pages for a module
generategGenerate a complete project from a JSON file
infoiDisplay 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

๐Ÿ™ Acknowledgments

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago