UNPKG

@sarawebs/sb-bin

Version:

CLI tools for SaraWebs dev workflow

107 lines (75 loc) โ€ข 2.75 kB
# ๐Ÿงฑ `sb-gen` โ€” Simple Boilerplate Code Generator A developer-friendly CLI utility to quickly scaffold React boilerplate files in your project structure. Easily generate components, hooks, tests, pages, and context files using intuitive commands. --- ## ๐Ÿš€ Features - ๐Ÿ”ง Generate React components with boilerplate - ๐Ÿช Create custom hooks with sensible defaults - ๐Ÿงช Add test files for your components - ๐Ÿ“„ Scaffold page files for routing - ๐Ÿง  Create React context providers and hooks - โœจ Supports multiple entries per type in a single command - ๐Ÿ“ Automatically places files in the correct `src/` subfolders --- ## ๐Ÿ“ Folder Structure ```bash src/ โ”œโ”€โ”€ assets/ # images, logos, etc. โ”œโ”€โ”€ components/ # reusable components (Navbar, ProductCard, etc.) โ”œโ”€โ”€ context/ # global state with React context โ”œโ”€โ”€ hooks/ # custom React hooks โ”œโ”€โ”€ pages/ # main views like Home, Cart, Shop โ”œโ”€โ”€ tests/ # unit tests ``` --- ## ๐Ÿ›  Installation Install globally using npm: ```bash npm install -g @sarawebs/sb-bin ``` This will make the `sb-gen` command available globally from your terminal. --- ## ๐Ÿ’ป Usage ```bash sb-gen [flags] [names...] ``` ### โœ… Supported Flags | Flag | Alias | Description | Target Directory | | ------------- | ----- | -------------------------------- | ----------------- | | `--component` | `-c` | Create React components | `src/components/` | | `--hook` | `-h` | Create custom React hooks | `src/hooks/` | | `--test` | `-t` | Create test files | `src/tests/` | | `--page` | `-p` | Create React pages | `src/pages/` | | `--context` | `-x` | Create React context boilerplate | `src/context/` | --- ## โœจ Examples ```bash sb-gen -c Navbar Footer -h auth fetchUser -t Navbar -p Home Shop -x Cart ``` ๐Ÿ“ฆ This creates: ``` src/components/Navbar.jsx src/components/Footer.jsx src/hooks/useAuth.jsx src/hooks/useFetchUser.jsx src/tests/Navbar.test.jsx src/pages/Home.jsx src/pages/Shop.jsx src/context/CartContext.jsx ``` --- ## ๐Ÿ“š Boilerplate Overview - **Component:** Functional React component - **Hook:** Custom `useX` hook - **Test:** React Testing Library setup - **Page:** Basic functional component - **Context:** Provider + custom hook for usage --- ## ๐Ÿ“Œ Notes - Component and context names are automatically capitalized. - Hook names are prefixed with `use` if not already. - All files use `.jsx` extension. - Works best inside a standard React app using the described folder structure. --- ## ๐Ÿงฉ License MIT โ€” Feel free to use, modify, and contribute.