# Milestone 03: Hosting CLI

> CLI integration for deploying web applications to Synor Hosting

## Status: Complete

## Tasks

- [x] Add `synor deploy` command group to CLI
- [x] Implement `deploy push` for uploading projects
- [x] Implement `deploy init` for creating synor.json
- [x] Implement `deploy list` for listing deployments
- [x] Implement `deploy delete` for removing deployments
- [x] Add synor.json parsing with framework detection
- [x] Add build command execution
- [x] Add multipart file upload to storage gateway
- [x] Add deployment registration with hosting gateway
- [x] Add name validation (reserved names, format)
- [x] Add comprehensive test coverage

## Files

```
apps/cli/src/
├── main.rs              # DeployCommands enum
├── commands/
│   ├── mod.rs           # deploy module export
│   └── deploy.rs        # Deploy command handlers
```

## CLI Commands

### Deploy Push

```bash
# Deploy current directory
synor deploy push

# Deploy with custom name
synor deploy push --name myapp

# Deploy from specific output directory
synor deploy push --output build

# Skip build step
synor deploy push --skip-build

# Use custom gateway
synor deploy push --gateway http://hosting.example.com:8080
```

### Deploy Init

```bash
# Initialize synor.json with auto-detection
synor deploy init

# Initialize as SPA
synor deploy init --spa

# Initialize with specific name
synor deploy init --name myproject
```

### Other Commands

```bash
# List all deployments
synor deploy list

# Delete a deployment
synor deploy delete myapp

# Get deployment info
synor deploy info myapp
```

## synor.json Schema

```json
{
  "name": "myapp",
  "build": {
    "command": "npm run build",
    "output": "dist",
    "install": "npm install"
  },
  "routes": {
    "spa": true,
    "clean_urls": true
  },
  "headers": [
    {
      "source": "/**",
      "headers": [
        { "key": "X-Frame-Options", "value": "DENY" }
      ]
    }
  ],
  "redirects": [
    {
      "source": "/old",
      "destination": "/new",
      "status": 301
    }
  ],
  "error_pages": {
    "404": "/404.html"
  }
}
```

## Framework Auto-Detection

The CLI automatically detects and configures:

| Framework | Config File | Output Dir |
|-----------|-------------|------------|
| Next.js | next.config.js | out |
| Vite | vite.config.js | dist |
| Astro | astro.config.mjs | dist |
| Angular | angular.json | dist |
| SvelteKit | svelte.config.js | build |

## Validation Commands

```bash
cargo test -p synor-cli
cargo run -p synor-cli -- deploy --help
cargo run -p synor-cli -- deploy push --help
```

---

*Completed: January 2026*
