npm package: @kamalbilal/kbcli
Description: A CLI SDK similar to Botpress SDK for building and deploying projects
Latest version: 1.0.3

# kbcli

A powerful CLI SDK similar to Botpress SDK for building and deploying Node.js projects.

## Installation

### Global Installation (Recommended)
```bash
npm install -g kbcli
```

### Local Installation
```bash
npm install kbcli
npx kbcli --help
```

## Features

- 🔐 **Authentication**: Secure login/logout with token management
- 🏗️ **Build**: Bundle your project using esbuild for optimal performance
- 🚀 **Deploy**: Upload your built project to any server
- 📦 **Cross-platform**: Works on Windows, macOS, and Linux
- ⚡ **Fast**: Built with esbuild for lightning-fast builds

## Usage

### Login
Authenticate with your account to enable deployment features.

```bash
kbcli login
```

This will prompt you for your email and password, then save your authentication token globally in `~/.kbcli/token.json`.

### Logout
Clear your saved authentication token.

```bash
kbcli logout
```

### Build
Bundle your project's source code into a distributable format.

```bash
# Basic build (uses src/index.js as entry point)
kbcli build

# Custom entry point and output directory
kbcli build --entry src/main.js --outdir build

# Short form
kbcli build -e src/app.js -o dist
```

**Options:**
- `-e, --entry <file>`: Entry point file (default: `src/index.js`)
- `-o, --outdir <dir>`: Output directory (default: `dist`)

### Deploy
Upload your built project to a server.

```bash
# Basic deploy (uses dist/ directory)
kbcli deploy

# Custom directory and server
kbcli deploy --dir build --server https://api.myserver.com/deploy

# Short form
kbcli deploy -d dist -s https://api.example.com/upload
```

**Options:**
- `-d, --dir <directory>`: Directory to deploy (default: `dist`)
- `-s, --server <url>`: Server URL (default: `https://api.example.com/deploy`)

## Project Structure

Your project should follow this structure:

```
my-project/
├── src/
│   └── index.js          # Entry point
├── dist/                 # Built files (created by kbcli build)
└── package.json
```

## Configuration

The CLI stores your authentication token in:
- **Windows**: `%USERPROFILE%\.kbcli\token.json`
- **macOS/Linux**: `~/.kbcli/token.json`

## Examples

### Complete Workflow

```bash
# 1. Login to your account
kbcli login

# 2. Build your project
kbcli build --entry src/index.js --outdir dist

# 3. Deploy to your server
kbcli deploy --dir dist --server https://api.mycompany.com/deploy

# 4. Logout when done
kbcli logout
```

### Development Workflow

```bash
# Quick build and deploy
kbcli build && kbcli deploy

# Build with custom settings
kbcli build -e src/app.js -o build
kbcli deploy -d build -s https://staging-api.example.com/deploy
```

## API Integration

The deploy command sends a POST request to your server with:
- **Content-Type**: `multipart/form-data`
- **Authorization**: `Bearer <your-token>`
- **Body**: ZIP file containing your project

Your server should handle the multipart form data and extract the uploaded ZIP file.

## Requirements

- Node.js 14.0.0 or higher
- npm or yarn package manager

## Troubleshooting

### Build Issues
- Ensure your entry file exists and is valid JavaScript
- Check that all dependencies are properly installed
- Verify file paths are correct

### Deploy Issues
- Make sure you're logged in (`kbcli login`)
- Verify the server URL is correct and accessible
- Check your internet connection
- Ensure the server accepts the file format

### Authentication Issues
- Try logging out and logging back in
- Check if your credentials are correct
- Verify the authentication server is accessible

## License

MIT

## Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## Support

For support, please open an issue on GitHub or contact the development team.