npm package: @iout/iosdev-cli
Description: CLI tool to deploy Docker projects to production via SSH with live log streaming. Built by IOUT Platform Engineering.
Author: IOUT Platform Engineering
Latest version: 1.0.0

# @iout/iosdev-cli

> **Built by IOUT Platform Engineering**

CLI tool to deploy your Docker projects to production via SSH — with live log streaming directly to your terminal.

[![npm version](https://img.shields.io/npm/v/@iout/iosdev-cli.svg)](https://www.npmjs.com/package/@iout/iosdev-cli)
[![license](https://img.shields.io/npm/l/@iout/iosdev-cli.svg)](https://github.com/iout/iosdev-cli/blob/main/LICENSE)

## Installation

```bash
npm install -g @iout/iosdev-cli
```

## Setup

**1. Create your config file:**

```bash
iosdev init
```

This creates `~/.iosdev.env`. Edit it with your production server details:

```env
IOSDEV_SSH_HOST=your-production-server.com
IOSDEV_SSH_PORT=22
IOSDEV_SSH_USER=deploy
IOSDEV_SSH_KEY=~/.ssh/id_rsa
```

**2. Make sure your SSH key has access to the production server.**

## Usage

### Deploy

```bash
# Interactive — select projects from a menu
iosdev deploy

# Deploy all projects
iosdev deploy --all

# Deploy specific projects by alias
iosdev deploy fcsop sbca

# Deploy a single project
iosdev deploy parcelbilling

# Dry run — show commands without executing
iosdev deploy --all --dry-run

# Continue deploying remaining projects even if one fails
iosdev deploy --all --continue-on-error

# Override SSH settings on the fly
iosdev deploy fcsop --host 192.168.1.100 --user root --port 2222
```

### Logs

```bash
# Tail live logs for a project
iosdev logs fcsop
iosdev logs parcelbilling --lines 50
```

### Status

```bash
# Check container status — all projects
iosdev status

# Single project
iosdev status fcsop
```

### Remote Exec

```bash
# Run any command on production
iosdev exec "docker ps"
iosdev exec "df -h"
```

### List Projects

```bash
iosdev list
```

## Configured Projects

| Alias          | Project                              | Branch   |
|----------------|--------------------------------------|----------|
| `fcsop`        | Facing Client SOP                    | `main`   |
| `sbca`         | Supplier Billing Compliance Audit    | `main`   |
| `parcelbilling`| Parcel Billing                       | `master` |

## Adding New Projects

Edit `lib/projects.js` and add a new entry to the `projects` array:

```javascript
{
  name: "My New Project",
  alias: "mynew",
  repoPath: "/opt/docker/projects/my-new-project.git",
  deployPath: "/opt/docker/my-new-project",
  branch: "main",
  composeFile: "docker-compose.prod.yml",
  services: [],  // empty = all services, or ["svc1", "svc2"]
}
```

## SSH Authentication Priority

1. SSH private key (`IOSDEV_SSH_KEY`)
2. Password (`IOSDEV_SSH_PASSWORD`)
3. SSH Agent (`SSH_AUTH_SOCK`)

## CLI Options

| Flag | Description |
|------|-------------|
| `-a, --all` | Deploy all projects |
| `-d, --dry-run` | Preview commands without executing |
| `-c, --continue-on-error` | Don't stop if a project fails |
| `-H, --host <host>` | Override SSH host |
| `-u, --user <user>` | Override SSH username |
| `-k, --key <path>` | Override SSH private key path |
| `-p, --port <port>` | Override SSH port |

## Requirements

- Node.js >= 14.0.0
- SSH access to the production server
- Docker and docker-compose on the production server

## License

MIT — IOUT Platform Engineering