@feedinbox/cli
Version:
CLI tool for installing FeedInbox components into your project
212 lines (156 loc) ⢠4.42 kB
Markdown
# @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