# DeployPro — Enterprise IIS Deployment Pipeline

A premium, enterprise-grade web UI for deploying, managing versions, rolling back, and managing IIS sites and files directly from your browser.

---

## Features

| Feature | Description |
|---|---|
| **Deploy Pipeline** | Upload a `.zip` package, select a site, set a version label, and deploy with one click |
| **Version Management** | Every deployment is tracked with metadata, notes, and an optional backup archive |
| **Rollback** | Restore any previous version from its backup archive instantly |
| **IIS Reset** | Run `iisreset` directly from the UI with a confirmation dialog |
| **App Pool Control** | Start, Stop, Recycle any IIS Application Pool |
| **IIS Site Control** | Start/Stop any IIS Web Site |
| **File Manager** | Browse, upload, edit (inline), and delete files in any registered IIS site directory |
| **Activity Log** | All actions are logged with level, category, and timestamp |
| **Live Console** | WebSocket-based real-time deployment logs streamed to the browser |

---

## Requirements

- **Windows** with **IIS** installed
- **Node.js 18+** — https://nodejs.org/
- **Administrator privileges** (required for IIS management)

---

## Quick Start

1. **Double-click `start.bat`** — it will:
   - Request administrator privileges (UAC prompt)
   - Run `npm install` on first launch
   - Start the server on `http://localhost:5000`
   - Open your browser automatically

Or manually:

```bat
# Run PowerShell or CMD as Administrator
cd E:\Deployment
npm install
node server.js
```

---

## First-Time Setup

1. Open **`http://localhost:5000`**
2. Navigate to **Managed Sites** → **Add Site**
3. Fill in:
   - **Display Name** — friendly name (e.g. `My Web App`)
   - **IIS Site Name** — exact name as it appears in IIS Manager (e.g. `Default Web Site`)
   - **Deploy Path** — physical path to the site root (e.g. `C:\inetpub\wwwroot\MyApp`)
   - **App Pool Name** — name of the application pool (e.g. `MyAppPool`)
4. Click **Save Site**

You are now ready to deploy!

---

## Deployment Workflow

1. Go to **Deploy**
2. Select your **Target Site**
3. Enter a **Version Label** (e.g. `2.1.0`)
4. Drag & drop a **`.zip` file** containing your application files
5. Configure options:
   - ✅ Auto-backup current version *(recommended)*
   - ✅ Stop App Pool before deploy *(prevents file lock issues)*
   - ☐ IIS Reset after deploy *(optional — heavy)*
6. Click **Deploy Now**
7. Watch the real-time console log

---

## Rollback Workflow

1. Go to **Versions & Rollback**
2. Find the version you want to restore
3. Click **Rollback** — a confirmation dialog appears
4. Confirm to restore the backup archive

---

## File Manager

1. Go to **File Manager**
2. Select a **Managed Site** from the dropdown
3. Browse the directory tree
4. Actions available:
   - **Upload** files to the current folder
   - **Edit** text files inline (HTML, CSS, JS, JSON, config, etc.)
   - **Delete** files or folders
   - **New Folder**

---

## Settings

| Setting | Default | Description |
|---|---|---|
| Max Versions per Site | 10 | Old backup archives are pruned automatically |
| Auto-backup | On | Creates a zip backup before each deploy |
| Stop Pool Before Deploy | On | Prevents file-in-use errors |
| IIS Reset After Deploy | Off | Runs `iisreset` after every deployment |

---

## Project Structure

```
E:\Deployment\
├── server.js              — Express + WebSocket server
├── routes\
│   └── api.js             — All REST API endpoints
├── utils\
│   ├── iis.js             — PowerShell IIS management
│   ├── versionManager.js  — Version / backup tracking
│   └── logger.js          — Activity logging
├── data\
│   ├── config.json        — Site registrations + settings
│   ├── deployments.json   — Deployment history
│   └── activity.json      — Activity log
├── public\
│   ├── index.html         — SPA shell
│   ├── css\styles.css     — Premium dark theme
│   └── js\app.js          — Frontend application logic
├── uploads\               — Temporary upload staging
├── backups\               — Version backup archives
└── start.bat              — Admin launcher
```

---

## Security Notes

- The server **must run as Administrator** to manage IIS
- All file paths are validated to prevent directory traversal (`../` attacks)
- PowerShell commands use base64-encoded execution (no shell injection)
- File uploads are limited to 500 MB
- Only run on your internal network / localhost — add authentication before exposing externally
