UNPKG

@feedinbox/cli

Version:

CLI tool for installing FeedInbox components into your project

212 lines (156 loc) • 4.42 kB
# @feedinbox/cli CLI tool for installing FeedInbox components into your React project. Components are copied directly to your project for full customization control. ## šŸš€ Quick Start ```bash # Install components npx @feedinbox/cli add react-vanilla ``` ## šŸ“¦ Installation No installation required! Use with npx: ```bash npx @feedinbox/cli --help ``` ## šŸŽØ Available Templates ### react-vanilla React components with vanilla CSS styling ```bash npx @feedinbox/cli add react-vanilla ``` ### react-tailwind React components with Tailwind CSS utilities ```bash npx @feedinbox/cli add react-tailwind ``` ### react-shadcn React components using shadcn/ui library ```bash npx @feedinbox/cli add react-shadcn ``` ## šŸ“‹ Commands ### `add [type]` Install component templates to your project ```bash npx @feedinbox/cli add react-vanilla # Options npx @feedinbox/cli add react-vanilla --dir src/components/ui --force ``` **Options:** - `--dir <directory>` - Installation directory (default: `src/components/feedinbox`) - `--force` - Overwrite existing files - `--yes` - Skip confirmation prompts ### `list` Show available component types ```bash npx @feedinbox/cli list ``` ### `init` Initialize FeedInbox configuration ```bash npx @feedinbox/cli init ``` Creates `feedinbox.config.json` with your API key and settings. ## šŸ“ What Gets Installed When you run `npx @feedinbox/cli add react-vanilla`, it creates: ``` src/components/feedinbox/ ā”œā”€ā”€ FeedbackWidget.tsx ← Feedback collection widget ā”œā”€ā”€ NewsletterWidget.tsx ← Newsletter subscription widget ā”œā”€ā”€ ContactWidget.tsx ← Contact form widget ā”œā”€ā”€ index.ts ← Export file ā”œā”€ā”€ styles/ ← CSS files (vanilla only) │ ā”œā”€ā”€ index.css │ ā”œā”€ā”€ feedback-widget.css │ ā”œā”€ā”€ newsletter-widget.css │ └── contact-widget.css └── README.md ← Usage instructions ``` ## šŸ”§ Usage After Installation 1. **Install the SDK** (if not already installed): ```bash npm install @feedinbox/sdk ``` 2. **Import and use components**: ```tsx import { FeedbackWidget } from './components/feedinbox'; // For vanilla CSS: import './components/feedinbox/styles/index.css'; function App() { return ( <FeedbackWidget apiKey="fb_your_api_key" onSuccess={(response) => console.log(response)} /> ); } ``` ## šŸŽÆ Requirements - **Node.js**: 16 or higher - **React project**: The CLI detects React projects automatically - **TypeScript**: Recommended (components are written in TypeScript) ## šŸ” Project Validation The CLI automatically validates your project: - āœ… Checks for `package.json` - āœ… Detects React dependencies - āœ… Warns about missing TypeScript ## āš™ļø Configuration ### feedinbox.config.json Optional configuration file created by `npx @feedinbox/cli init`: ```json { "apiKey": "fb_your_api_key", "apiUrl": "https://api.feedinbox.com", "workspaceId": "your-workspace-id" } ``` **āš ļø Security Note**: Add `feedinbox.config.json` to your `.gitignore` ## šŸŽØ Component Customization Since components are copied to your project, you have full control: ```tsx // Modify the component file directly export const FeedbackWidget: React.FC<Props> = ({ ...props }) => { // Add your custom logic here const [customState, setCustomState] = useState(); // Your modifications... }; ``` ## šŸ“š Examples ### Next.js Integration ```bash # In your Next.js project npx @feedinbox/cli add react-vanilla # Then use in your components 'use client'; import { FeedbackWidget } from '@/components/feedinbox'; ``` ### Vite Project ```bash # In your Vite project npx @feedinbox/cli add react-tailwind # Import in your app import { FeedbackWidget } from './components/feedinbox'; ``` ### Custom Directory ```bash # Install to custom location npx @feedinbox/cli add react-shadcn --dir src/ui/feedinbox ``` ## šŸ› Troubleshooting ### "No package.json found" ```bash # Make sure you're in a Node.js project npm init -y ``` ### "React not detected" ```bash # Install React if missing npm install react react-dom ``` ### "Directory already exists" ```bash # Use --force to overwrite npx @feedinbox/cli add react-vanilla --force ``` ## šŸ”— Related Packages - [`@feedinbox/sdk`](https://www.npmjs.com/package/@feedinbox/sdk) - Core TypeScript SDK ## šŸ“„ License MIT Ā© FeedInbox