# comp-hub

CLI for comp-hub — a Vue component sharing platform. Start a local dev server to preview, manage, and share components.

[![npm version](https://img.shields.io/npm/v/comp-hub)](https://www.npmjs.com/package/comp-hub)
[![Node.js](https://img.shields.io/badge/node-%3E%3D16-brightgreen)](https://nodejs.org)

## Requirements

- Node.js >= 16.0.0
- npm >= 8.0.0

## Installation

**Global (recommended)**

```bash
npm install comp-hub@latest -g
```

**Local**

```bash
npm install comp-hub@latest -D
```

## Quick Start

Run in your project directory:

```bash
comphub
```

Once started, open the URL shown in the terminal (default `http://localhost:5478`).

### CLI Options

```bash
comphub [options]
```

| Option | Alias | Type | Default | Description |
|--------|-------|------|---------|-------------|
| `--port` | `-p` | number | 5478 | Server port |
| `--dir` | `-d` | path | `"./"` | Component directory |
| `--version` | `-v` | — | — | Show version |
| `--help` | `-h` | — | — | Show help |

Examples:

```bash
comphub -p 8080          # Custom port
comphub -d ./src         # Custom component directory
```

### Management Commands

| Command | Description |
|---------|-------------|
| `comphub` | Start dev server |
| `comphub status` | List all running projects |
| `comphub stop <hash>` | Stop a specific project |
| `comphub stop --all` | Stop all projects |
| `comphub kill` | Shut down all services |

Examples:

```bash
# Check running projects
comphub status

# Stop a specific project
comphub stop 94525912

# Stop all projects
comphub stop --all

# Shut down everything
comphub kill
```

### Multi-Project

Run multiple projects simultaneously on separate ports:

```bash
cd /path/to/project-a && comphub
cd /path/to/project-b && comphub
comphub status             # List all
```

## Configuration

Create `.comphub.json` or `.comphub.js` in your project root:

```json
{
  "dir": "./src",
  "allowDebug": false
}
```

```javascript
module.exports = {
  dir: './src',
  allowDebug: false
}
```

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `dir` | string | `"./"` | Component root directory |
| `allowDebug` | boolean | false | Enable debug mode |
| `proxy` | object | — | Custom proxy rules |

**Priority**: CLI flags > config file > defaults

## Component Specs

- Upload components as **folders** — folder name is the component name
- Must include `index.vue` as entry point
- Include a `README.md` describing usage
- Optional `demo/` directory for preview configs

## Documentation

[comp-hub Docs](https://docs.comphub.cn)

## License

[MIT](LICENSE)
