easy-devops 0.2.6 โ†’ 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ <p align="center">
2
+ <img src="dashboard/public/img/icon.png" alt="Easy DevOps" width="100" />
3
+ </p>
4
+
1
5
  # Easy DevOps
2
6
 
3
7
  [![npm version](https://badge.fury.io/js/easy-devops.svg)](https://badge.fury.io/js/easy-devops)
@@ -6,23 +10,25 @@
6
10
 
7
11
  A unified DevOps management tool with interactive CLI and web dashboard for managing **Nginx**, **SSL certificates**, and **Node.js** on Linux and Windows servers.
8
12
 
13
+ No external ACME binaries required โ€” SSL certificates are issued via [`acme-client`](https://www.npmjs.com/package/acme-client) (pure Node.js, Let's Encrypt).
14
+
9
15
  ## Features
10
16
 
11
17
  - **๐Ÿ–ฅ๏ธ Interactive CLI** โ€” Arrow-key menus with real-time status indicators
12
- - **๐Ÿ“Š Web Dashboard** โ€” Modern Vue 3 interface with dark/light themes
13
- - **๐ŸŒ Nginx Management** โ€” Start/stop/reload, config editor, error logs
14
- - **๐Ÿ”’ SSL Certificate Management** โ€” Let's Encrypt via Certbot, expiry tracking
15
- - **๐Ÿ”— Domain Management** โ€” Reverse proxy configurations with SSL, WebSocket, gzip, rate limiting
16
- - **๐Ÿ“ฆ Node.js Manager** โ€” Version switching via nvm, global package management
18
+ - **๐Ÿ“Š Web Dashboard** โ€” Modern Vue 3 interface with dark/light themes (`#161616` / `#d64a29` palette)
19
+ - **๐ŸŒ Nginx Management** โ€” Start/stop/reload, config editor, error logs, install
20
+ - **๐Ÿ”’ SSL Certificate Management** โ€” Let's Encrypt via `acme-client` (no certbot), HTTP-01 and DNS-01 challenges, wildcard certs, expiry tracking
21
+ - **๐Ÿ”— Domain Management** โ€” Reverse proxy configs with SSL, external URL backends, enable/disable, wildcard domains, WebSocket, gzip, rate limiting
22
+ - **๐Ÿ“ฆ Node.js Manager** โ€” Version switching via nvm / nvm-windows, global package management
17
23
  - **๐Ÿ”„ Real-time Updates** โ€” Socket.io powered status updates in dashboard
18
24
  - **๐Ÿ’ฟ SQLite Storage** โ€” Persistent configuration via `good.db`
19
25
 
20
26
  ## Requirements
21
27
 
22
28
  - **Node.js 18+** (with npm)
23
- - **Linux** (Debian/Ubuntu) or **Windows**
24
- - โš ๏ธ **Windows users: PowerShell must be run as Administrator** (required for installing packages via winget, managing services, and SSL certificates)
25
- - Optional: Nginx, Certbot, nvm (installed separately or via the tool)
29
+ - **Linux** (Debian/Ubuntu/etc.) or **Windows**
30
+ - โš ๏ธ **Windows users: PowerShell must be run as Administrator** (required for managing services and SSL certificates)
31
+ - Optional: Nginx, nvm (installed separately or via the tool)
26
32
 
27
33
  ## Installation
28
34
 
@@ -98,11 +104,14 @@ npx easy-devops
98
104
  ### CLI Overview
99
105
 
100
106
  ```
101
- โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
102
- โ•‘ Easy DevOps v0.1.0 โ•‘
103
- โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
107
+ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— Easy DevOps v1.0.0
108
+ โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ•šโ•โ•โ•โ•โ–ˆโ–ˆโ•— โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
109
+ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ• CLI & Web Dashboard
110
+ โ–ˆโ–ˆโ•”โ•โ•โ• โ–ˆโ–ˆโ•”โ• Nginx ยท SSL ยท Domains ยท Node.js
111
+ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
112
+ โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•
104
113
 
105
- nginx: โœ… v1.26.2 | certbot: โœ… v2.9.0 | node: v22.21.1
114
+ nginx: โœ… v1.26.2 | ACME: acme-client | node: v22.21.1
106
115
 
107
116
  ? Select an option:
108
117
  ๐Ÿ“ฆ Node.js Manager
@@ -111,6 +120,7 @@ nginx: โœ… v1.26.2 | certbot: โœ… v2.9.0 | node: v22.21.1
111
120
  ๐Ÿ”— Domain Manager
112
121
  ๐ŸŽ›๏ธ Open Dashboard
113
122
  โš™๏ธ Settings
123
+ ๐Ÿ”„ Check for Updates
114
124
  โœ– Exit
115
125
  ```
116
126
 
@@ -150,13 +160,16 @@ Manage Nginx reverse proxy configurations from CLI or dashboard.
150
160
 
151
161
  | Option | Description |
152
162
  |--------|-------------|
153
- | List Domains | Show all configured domains in a table |
163
+ | List Domains | Show all configured domains in a table (with status) |
154
164
  | Add Domain | Interactive prompts for domain configuration |
155
165
  | Edit Domain | Modify existing domain settings |
156
- | Delete Domain | Remove domain with confirmation |
166
+ | Enable / Disable Domain | Toggle domain on/off without deleting config |
167
+ | Delete Domain | Remove domain (with option to also delete SSL files) |
157
168
 
158
169
  **Domain Configuration Options:**
159
- - SSL/HTTPS with auto-renewal tracking
170
+ - Backend: local host:port (`127.0.0.1:3000`) or full external URL (`https://app.vercel.app`)
171
+ - Wildcard domain (`*.example.com`) โ€” auto-enforces DNS-01 SSL validation
172
+ - SSL/HTTPS with certificate management
160
173
  - WebSocket support (`ws` upstream type)
161
174
  - Gzip compression
162
175
  - Rate limiting (requests/second + burst)
@@ -168,7 +181,7 @@ Manage Nginx reverse proxy configurations from CLI or dashboard.
168
181
 
169
182
  ### SSL Manager
170
183
 
171
- Manage Let's Encrypt SSL certificates using Certbot.
184
+ Issue and renew Let's Encrypt SSL certificates via `acme-client` โ€” no certbot or external binaries required.
172
185
 
173
186
  | Status | Meaning |
174
187
  |--------|---------|
@@ -176,21 +189,28 @@ Manage Let's Encrypt SSL certificates using Certbot.
176
189
  | โš ๏ธ yellow | Expiring soon (10โ€“30 days) |
177
190
  | โŒ red | Critical (< 10 days) |
178
191
 
179
- > **Note:** Renewing a certificate temporarily stops Nginx to free port 80, then restarts it automatically.
192
+ #### Challenge Methods
180
193
 
181
- #### Windows Package Manager (winget)
194
+ | Method | How it works |
195
+ |--------|-------------|
196
+ | **HTTP-01** | Easy DevOps stops nginx, binds port 80, serves the ACME token, then restarts nginx |
197
+ | **DNS-01** | You add a `_acme-challenge` TXT record to your DNS; Easy DevOps waits for confirmation |
182
198
 
183
- Easy DevOps uses **winget** (Windows Package Manager) to install certbot and other packages on Windows. If winget is not installed, Easy DevOps will automatically prompt to install it using the [asheroto/winget-install](https://github.com/asheroto/winget-install) script.
199
+ > **Wildcard certificates** (`*.example.com`) require DNS-01 โ€” HTTP-01 is automatically disabled for wildcard domains.
184
200
 
185
- **Installing winget manually:**
201
+ #### Certificate Storage
186
202
 
187
- If you prefer to install winget separately, you can:
203
+ Certificates are stored under `sslDir` (configured in Settings):
188
204
 
189
- 1. **Install from Microsoft Store:** Search for "App Installer" in the Microsoft Store
190
- 2. **Use the winget-install script:** [https://github.com/asheroto/winget-install](https://github.com/asheroto/winget-install)
191
- 3. **Official Microsoft documentation:** [https://learn.microsoft.com/en-us/windows/package-manager/winget/](https://learn.microsoft.com/en-us/windows/package-manager/winget/)
205
+ ```
206
+ {sslDir}/{domain}/fullchain.pem
207
+ {sslDir}/{domain}/privkey.pem
208
+ {sslDir}/.account/account.key โ† ACME account key, reused across all issuances
209
+ ```
192
210
 
193
- > **Note:** The embedded `winget-install.ps1` script in this project is sourced from [asheroto/winget-install](https://github.com/asheroto/winget-install) โ€” a community-maintained, reliable installer for winget on Windows Server and systems without the Microsoft Store.
211
+ Default paths:
212
+ - Linux: `/etc/easy-devops/ssl/`
213
+ - Windows: `C:\easy-devops\ssl\`
194
214
 
195
215
  ---
196
216
 
@@ -239,8 +259,12 @@ The dashboard exposes RESTful API endpoints:
239
259
  | `/api/nginx/configs` | GET | List config files |
240
260
  | `/api/nginx/config/:file` | GET/POST | Read/write config file |
241
261
  | `/api/domains` | GET/POST | List/create domains |
242
- | `/api/domains/:name` | GET/PUT/DELETE | Domain CRUD |
262
+ | `/api/domains/:name` | PUT/DELETE | Update/delete domain |
263
+ | `/api/domains/:name/toggle` | PUT | Enable or disable domain |
264
+ | `/api/domains/:name/reload` | POST | Reload nginx for domain |
243
265
  | `/api/ssl` | GET | List certificates |
266
+ | `/api/ssl/create` | POST | Issue new certificate |
267
+ | `/api/ssl/create-confirm` | POST | Confirm DNS challenge |
244
268
  | `/api/ssl/renew/:domain` | POST | Renew certificate |
245
269
  | `/api/settings` | GET/POST | Dashboard settings |
246
270
 
@@ -252,10 +276,20 @@ All configuration is stored in `data/easy-devops.sqlite`:
252
276
 
253
277
  | Key | Contents |
254
278
  |-----|----------|
255
- | `config` | Dashboard port, password, Nginx/Certbot directories |
256
- | `system-detection` | Cached system info (OS, Node, nginx, certbot) |
279
+ | `config` | Dashboard port, password, `nginxDir`, `sslDir`, `acmeEmail` |
280
+ | `system-detection` | Cached system info (OS, Node, nginx) |
257
281
  | `domains` | Array of domain configurations |
258
282
 
283
+ **Config fields:**
284
+
285
+ | Field | Default (Linux) | Default (Windows) | Description |
286
+ |-------|-----------------|-------------------|-------------|
287
+ | `dashboardPort` | `3000` | `3000` | Dashboard HTTP port |
288
+ | `dashboardPassword` | `admin` | `admin` | Dashboard login password |
289
+ | `nginxDir` | `/etc/nginx` | `C:\nginx` | Nginx installation directory |
290
+ | `sslDir` | `/etc/easy-devops/ssl` | `C:\easy-devops\ssl` | SSL certificate storage root |
291
+ | `acmeEmail` | _(empty)_ | _(empty)_ | Email for Let's Encrypt account (**required** for cert issuance) |
292
+
259
293
  ---
260
294
 
261
295
  ## Project Structure
@@ -264,27 +298,28 @@ All configuration is stored in `data/easy-devops.sqlite`:
264
298
  easy-devops/
265
299
  โ”œโ”€โ”€ cli/
266
300
  โ”‚ โ”œโ”€โ”€ index.js # CLI entry point
267
- โ”‚ โ”œโ”€โ”€ managers/ # Business logic modules
268
- โ”‚ โ””โ”€โ”€ menus/ # Menu dispatcher stubs
301
+ โ”‚ โ”œโ”€โ”€ managers/ # Domain, Nginx, SSL, Node.js logic
302
+ โ”‚ โ””โ”€โ”€ menus/ # Thin menu dispatcher wrappers
269
303
  โ”œโ”€โ”€ core/
270
- โ”‚ โ”œโ”€โ”€ config.js # Configuration loader
271
- โ”‚ โ”œโ”€โ”€ db.js # SQLite database (good.db)
304
+ โ”‚ โ”œโ”€โ”€ config.js # Configuration load/save
305
+ โ”‚ โ”œโ”€โ”€ db.js # SQLite helpers (good.db)
272
306
  โ”‚ โ”œโ”€โ”€ detector.js # System environment detection
307
+ โ”‚ โ”œโ”€โ”€ nginx-conf-generator.js # Nginx conf builder (shared)
308
+ โ”‚ โ”œโ”€โ”€ platform.js # isWindows, nginx cmd helpers, combineOutput
273
309
  โ”‚ โ”œโ”€โ”€ shell.js # Cross-platform shell executor
274
- โ”‚ โ””โ”€โ”€ nginx-conf-generator.js # Nginx config file generator
310
+ โ”‚ โ””โ”€โ”€ validators.js # Shared input validation helpers
275
311
  โ”œโ”€โ”€ dashboard/
276
312
  โ”‚ โ”œโ”€โ”€ server.js # Express + Socket.io server
277
- โ”‚ โ”œโ”€โ”€ routes/ # API endpoints
278
- โ”‚ โ”œโ”€โ”€ lib/ # Service helpers
279
- โ”‚ โ”œโ”€โ”€ views/ # EJS templates
280
- โ”‚ โ””โ”€โ”€ public/ # Static assets (Vue app)
313
+ โ”‚ โ”œโ”€โ”€ routes/ # auth, domains, nginx, settings, ssl
314
+ โ”‚ โ”œโ”€โ”€ lib/ # cert-reader, domains-db, nginx-service
315
+ โ”‚ โ”œโ”€โ”€ views/ # EJS templates + partials
316
+ โ”‚ โ””โ”€โ”€ public/ # Static assets (Vue 3 app)
281
317
  โ”œโ”€โ”€ data/
282
318
  โ”‚ โ””โ”€โ”€ easy-devops.sqlite
283
- โ””โ”€โ”€ lib/
284
- โ””โ”€โ”€ installer/
285
- โ”œโ”€โ”€ install.ps1 # Windows bootstrap installer
286
- โ”œโ”€โ”€ install.sh # Linux/macOS bootstrap installer
287
- โ””โ”€โ”€ winget-install.ps1 # Windows Package Manager installer
319
+ โ”œโ”€โ”€ lib/
320
+ โ”‚ โ””โ”€โ”€ installer/ # Bash helper modules for install.sh
321
+ โ”œโ”€โ”€ install.sh # Linux/macOS bootstrap installer
322
+ โ””โ”€โ”€ install.ps1 # Windows PowerShell installer
288
323
  ```
289
324
 
290
325
  ---
@@ -296,9 +331,11 @@ easy-devops/
296
331
  | CLI Interface | โœ… | โœ… |
297
332
  | Web Dashboard | โœ… | โœ… |
298
333
  | Nginx Management | โœ… | โœ… |
299
- | SSL (Certbot) | โœ… | โœ… |
334
+ | SSL โ€” HTTP-01 (acme-client) | โœ… | โœ… |
335
+ | SSL โ€” DNS-01 (acme-client) | โœ… | โœ… |
336
+ | Wildcard Certificates | โœ… | โœ… |
300
337
  | Node.js (nvm) | โœ… | โœ… (nvm-windows) |
301
- | System Service | systemd | Task Scheduler |
338
+ | Nginx service control | systemctl | nginx.exe direct |
302
339
 
303
340
  ---
304
341
 
@@ -334,6 +371,12 @@ Contributions are welcome! Please feel free to submit a Pull Request.
334
371
 
335
372
  ---
336
373
 
374
+ ## Changelog
375
+
376
+ See [CHANGELOG.md](./CHANGELOG.md) for a full history of changes.
377
+
378
+ ---
379
+
337
380
  ## License
338
381
 
339
382
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
package/cli/index.js CHANGED
@@ -25,11 +25,33 @@ if (process.argv[2] === 'system-info') {
25
25
  }
26
26
 
27
27
  function renderBanner() {
28
- const title = ` Easy DevOps v${version}`;
29
- const paddedTitle = title.padEnd(30);
30
- console.log(chalk.cyan('โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—'));
31
- console.log(chalk.cyan('โ•‘') + chalk.bold(paddedTitle) + chalk.cyan('โ•‘'));
32
- console.log(chalk.cyan('โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'));
28
+ const c = chalk.hex('#d64a29');
29
+ const dim = chalk.hex('#d64a29').dim;
30
+
31
+ // Compact "EZ" logo โ€” 6 lines, ~20 chars wide, fits any 80-col terminal
32
+ const logo = [
33
+ 'โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—',
34
+ 'โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ•šโ•โ•โ•โ•โ–ˆโ–ˆโ•—',
35
+ 'โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ•',
36
+ 'โ–ˆโ–ˆโ•”โ•โ•โ• โ–ˆโ–ˆโ•”โ• ',
37
+ 'โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—',
38
+ 'โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•',
39
+ ];
40
+
41
+ const gap = ' ';
42
+ const info = [
43
+ chalk.bold.white('Easy DevOps') + ' ' + chalk.hex('#d64a29')(`v${version}`),
44
+ dim('โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€'),
45
+ chalk.hex('#888888')('CLI & Web Dashboard'),
46
+ chalk.hex('#888888')('Nginx ยท SSL ยท Domains ยท Node.js'),
47
+ '',
48
+ '',
49
+ ];
50
+
51
+ console.log();
52
+ logo.forEach((line, i) => {
53
+ console.log(' ' + c(line) + gap + (info[i] ?? ''));
54
+ });
33
55
  console.log();
34
56
  }
35
57
 
@@ -13,33 +13,14 @@
13
13
  import chalk from 'chalk';
14
14
  import inquirer from 'inquirer';
15
15
  import ora from 'ora';
16
+ import fs from 'fs/promises';
16
17
  import Table from 'cli-table3';
17
18
  import { run } from '../../core/shell.js';
18
19
  import { loadConfig } from '../../core/config.js';
19
20
  import { getDomains, saveDomains, findDomain, createDomain, DOMAIN_DEFAULTS } from '../../dashboard/lib/domains-db.js';
20
21
  import { generateConf, buildConf } from '../../core/nginx-conf-generator.js';
21
-
22
- const isWindows = process.platform === 'win32';
23
-
24
- // โ”€โ”€โ”€ Helper functions โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
25
-
26
- function getNginxExe(nginxDir) {
27
- return isWindows ? `${nginxDir}\\nginx.exe` : 'nginx';
28
- }
29
-
30
- function nginxTestCmd(nginxDir) {
31
- const exe = getNginxExe(nginxDir);
32
- return isWindows ? `& "${exe}" -t` : 'nginx -t';
33
- }
34
-
35
- function nginxReloadCmd(nginxDir) {
36
- const exe = getNginxExe(nginxDir);
37
- return isWindows ? `& "${exe}" -s reload` : 'nginx -s reload';
38
- }
39
-
40
- function combineOutput(result) {
41
- return [result.stdout, result.stderr].filter(Boolean).join('\n').trim();
42
- }
22
+ import { issueCert } from './ssl-manager.js';
23
+ import { isWindows, nginxTestCmd, nginxReloadCmd, combineOutput } from '../../core/platform.js';
43
24
 
44
25
  // โ”€โ”€โ”€ List Domains โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
45
26
 
@@ -54,13 +35,14 @@ async function listDomainsAction() {
54
35
  const table = new Table({
55
36
  head: [
56
37
  chalk.cyan('Domain'),
57
- chalk.cyan('Port'),
38
+ chalk.cyan('Backend'),
58
39
  chalk.cyan('Type'),
59
40
  chalk.cyan('SSL'),
41
+ chalk.cyan('Status'),
60
42
  chalk.cyan('Cert'),
61
43
  ],
62
44
  style: { head: [], border: ['gray'] },
63
- colWidths: [30, 8, 8, 8, 8],
45
+ colWidths: [28, 20, 8, 8, 10, 8],
64
46
  });
65
47
 
66
48
  for (const d of domains) {
@@ -70,11 +52,18 @@ async function listDomainsAction() {
70
52
  ? (d.daysLeft > 30 ? chalk.green(`${d.daysLeft}d`) : chalk.yellow(`${d.daysLeft}d`))
71
53
  : chalk.gray('โ€”');
72
54
 
55
+ const backend = /^https?:\/\//i.test(d.backendHost || '')
56
+ ? d.backendHost.replace(/^https?:\/\//, '')
57
+ : `${d.backendHost || '127.0.0.1'}:${d.port}`;
58
+ const status = d.enabled === false
59
+ ? chalk.gray('DISABLED')
60
+ : (d.wildcard ? chalk.blue('WILDCARD') : chalk.green('active'));
73
61
  table.push([
74
62
  d.name,
75
- d.port.toString(),
63
+ backend,
76
64
  type,
77
65
  sslStatus,
66
+ status,
78
67
  certDays,
79
68
  ]);
80
69
  }
@@ -89,14 +78,39 @@ async function addDomainAction() {
89
78
 
90
79
  // Section 1: Basic
91
80
  const basic = await inquirer.prompt([
92
- { type: 'input', name: 'name', message: 'Domain name:', validate: (v) => v.trim() ? true : 'Required' },
93
- { type: 'input', name: 'backendHost', message: 'Backend host:', default: '127.0.0.1' },
94
- { type: 'number', name: 'port', message: 'Backend port:', default: 3000, validate: (v) => (v >= 1 && v <= 65535) ? true : 'Port must be 1-65535' },
81
+ { type: 'confirm', name: 'wildcard', message: 'Wildcard domain (*.example.com)?', default: false },
82
+ {
83
+ type: 'input', name: 'name',
84
+ message: (ans) => ans.wildcard
85
+ ? 'Domain name (without *. prefix โ€” it will be added automatically):'
86
+ : 'Domain name:',
87
+ validate: (v) => {
88
+ const bare = v.trim().startsWith('*.') ? v.trim().slice(2) : v.trim();
89
+ if (!bare) return 'Required';
90
+ const labelPattern = /^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$/;
91
+ const labels = bare.split('.');
92
+ if (labels.length < 2) return 'Must have at least two labels (e.g. example.com)';
93
+ for (const label of labels) {
94
+ if (!label || !labelPattern.test(label)) return 'Invalid domain name format';
95
+ }
96
+ return true;
97
+ },
98
+ filter: (v) => v.trim().startsWith('*.') ? v.trim().slice(2) : v.trim(),
99
+ },
100
+ { type: 'input', name: 'backendHost', message: 'Backend host or full URL:', default: '127.0.0.1' },
101
+ {
102
+ type: 'number', name: 'port', message: 'Backend port (ignored for full URLs):', default: 3000,
103
+ validate: (v) => (v >= 1 && v <= 65535) ? true : 'Port must be 1-65535',
104
+ when: (ans) => !/^https?:\/\//i.test(ans.backendHost),
105
+ },
95
106
  {
96
107
  type: 'list', name: 'upstreamType', message: 'Upstream type:', default: 'http',
97
108
  choices: ['http', 'https', 'ws'],
98
109
  },
99
- { type: 'confirm', name: 'www', message: 'Include www subdomain?', default: false },
110
+ {
111
+ type: 'confirm', name: 'www', message: 'Include www subdomain?', default: false,
112
+ when: (ans) => !ans.wildcard,
113
+ },
100
114
  ]);
101
115
 
102
116
  // Check for duplicate
@@ -113,14 +127,14 @@ async function addDomainAction() {
113
127
  let ssl = { ...DOMAIN_DEFAULTS.ssl, enabled: sslAnswers.enabled };
114
128
 
115
129
  if (ssl.enabled) {
116
- const { nginxDir, certbotDir } = loadConfig();
130
+ const { nginxDir, sslDir } = loadConfig();
117
131
  const platform = isWindows ? 'win32' : 'linux';
118
132
  const defaultCertPath = platform === 'win32'
119
- ? `C:\\Certbot\\live\\${basic.name}\\fullchain.pem`
120
- : `${certbotDir}/live/${basic.name}/fullchain.pem`;
133
+ ? `C:\\easy-devops\\ssl\\${basic.name}\\fullchain.pem`
134
+ : `${sslDir}/${basic.name}/fullchain.pem`;
121
135
  const defaultKeyPath = platform === 'win32'
122
- ? `C:\\Certbot\\live\\${basic.name}\\privkey.pem`
123
- : `${certbotDir}/live/${basic.name}/privkey.pem`;
136
+ ? `C:\\easy-devops\\ssl\\${basic.name}\\privkey.pem`
137
+ : `${sslDir}/${basic.name}/privkey.pem`;
124
138
 
125
139
  const sslDetails = await inquirer.prompt([
126
140
  { type: 'input', name: 'certPath', message: 'SSL cert path:', default: defaultCertPath },
@@ -139,6 +153,66 @@ async function addDomainAction() {
139
153
  ssl = { ...ssl, ...sslDetails };
140
154
  }
141
155
 
156
+ // Cert existence check (FR-001, FR-002)
157
+ if (ssl.enabled) {
158
+ let certExists = false;
159
+ try {
160
+ await fs.access(ssl.certPath, fs.constants.F_OK);
161
+ certExists = true;
162
+ } catch {
163
+ certExists = false;
164
+ }
165
+
166
+ if (!certExists) {
167
+ console.log(chalk.yellow(`\n โš  Certificate not found at: ${ssl.certPath}`));
168
+
169
+ let certAction;
170
+ try {
171
+ ({ certAction } = await inquirer.prompt([{
172
+ type: 'list',
173
+ name: 'certAction',
174
+ message: 'What would you like to do?',
175
+ choices: ['Create certificate now', 'Disable SSL', 'Cancel'],
176
+ }]));
177
+ } catch (err) {
178
+ if (err.name === 'ExitPromptError') return;
179
+ throw err;
180
+ }
181
+
182
+ if (certAction === 'Cancel') {
183
+ console.log(chalk.gray('\n Cancelled.\n'));
184
+ return;
185
+ }
186
+
187
+ if (certAction === 'Disable SSL') {
188
+ ssl.enabled = false;
189
+ console.log(chalk.gray(' SSL disabled. Domain will be saved as HTTP-only.\n'));
190
+ }
191
+
192
+ if (certAction === 'Create certificate now') {
193
+ const spinner = ora(`Creating certificate for ${basic.name}โ€ฆ`).start();
194
+ const result = await issueCert(basic.name, { www: basic.www, wildcard: basic.wildcard, validationMethod: basic.wildcard ? 'dns' : 'http' });
195
+ spinner.stop();
196
+
197
+ if (result.success) {
198
+ console.log(chalk.green('\n โœ“ Certificate created successfully'));
199
+ console.log(chalk.gray(` Cert: ${result.certPath}`));
200
+ console.log(chalk.gray(` Key: ${result.keyPath}\n`));
201
+ ssl.certPath = result.certPath;
202
+ ssl.keyPath = result.keyPath;
203
+ } else {
204
+ const e = result.error;
205
+ console.log(chalk.red('\n โœ— Certificate creation failed โ€” domain was not saved'));
206
+ console.log(chalk.yellow(` Step: ${e.step}`));
207
+ console.log(chalk.yellow(` Cause: ${e.cause}`));
208
+ console.log(chalk.yellow(` Consequence: ${e.consequence}`));
209
+ console.log(chalk.gray(` nginx running: ${e.nginxRunning ? 'yes' : 'no'}\n`));
210
+ return;
211
+ }
212
+ }
213
+ }
214
+ }
215
+
142
216
  // Section 3: Proxy Behavior
143
217
  const proxy = await inquirer.prompt([
144
218
  { type: 'input', name: 'maxBodySize', message: 'Max body size:', default: '10m' },
@@ -206,6 +280,7 @@ async function addDomainAction() {
206
280
  backendHost: basic.backendHost,
207
281
  upstreamType: basic.upstreamType,
208
282
  www: basic.www,
283
+ wildcard: basic.wildcard,
209
284
  ssl,
210
285
  performance,
211
286
  security,
@@ -394,6 +469,97 @@ async function reloadNginxAfterChange() {
394
469
  return true;
395
470
  }
396
471
 
472
+ // โ”€โ”€โ”€ Toggle Domain (Enable/Disable) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
473
+
474
+ async function toggleDomainAction() {
475
+ const domains = getDomains();
476
+
477
+ if (domains.length === 0) {
478
+ console.log(chalk.yellow('\n No domains configured.\n'));
479
+ return;
480
+ }
481
+
482
+ const { selectedName } = await inquirer.prompt([{
483
+ type: 'list',
484
+ name: 'selectedName',
485
+ message: 'Select domain to enable/disable:',
486
+ choices: domains.map(d => {
487
+ const status = d.enabled === false ? chalk.gray('[DISABLED]') : chalk.green('[active]');
488
+ return { name: `${d.name} ${status}`, value: d.name };
489
+ }),
490
+ }]);
491
+
492
+ const domain = findDomain(selectedName);
493
+ if (!domain) return;
494
+
495
+ const isEnabled = domain.enabled !== false;
496
+ const action = isEnabled ? 'disable' : 'enable';
497
+
498
+ const { confirmed } = await inquirer.prompt([{
499
+ type: 'confirm',
500
+ name: 'confirmed',
501
+ message: `${action.charAt(0).toUpperCase() + action.slice(1)} "${selectedName}"?`,
502
+ default: false,
503
+ }]);
504
+
505
+ if (!confirmed) {
506
+ console.log(chalk.gray('\n Cancelled.\n'));
507
+ return;
508
+ }
509
+
510
+ const { nginxDir } = loadConfig();
511
+ const confPath = domain.configFile;
512
+
513
+ if (!confPath) {
514
+ console.log(chalk.red('\n No config file path stored for this domain.\n'));
515
+ return;
516
+ }
517
+
518
+ const basePath = confPath.replace(/\.disabled$/, '');
519
+ const enabledPath = basePath;
520
+ const disabledPath = `${basePath}.disabled`;
521
+ const spinner = ora(`${action.charAt(0).toUpperCase() + action.slice(1)}ing domain...`).start();
522
+
523
+ try {
524
+ if (isEnabled) {
525
+ await fs.rename(enabledPath, disabledPath);
526
+ } else {
527
+ await fs.rename(disabledPath, enabledPath);
528
+ // Test config before reload
529
+ const testResult = await run(nginxTestCmd(nginxDir), { cwd: nginxDir });
530
+ if (!testResult.success) {
531
+ await fs.rename(enabledPath, disabledPath).catch(() => {});
532
+ spinner.fail('Config test failed โ€” rolled back');
533
+ console.log(chalk.red('\n' + combineOutput(testResult)));
534
+ return;
535
+ }
536
+ }
537
+
538
+ // Update DB
539
+ const allDomains = getDomains();
540
+ const idx = allDomains.findIndex(d => d.name === selectedName);
541
+ allDomains[idx] = {
542
+ ...domain,
543
+ enabled: !isEnabled,
544
+ configFile: isEnabled ? disabledPath : enabledPath,
545
+ updatedAt: new Date().toISOString(),
546
+ };
547
+ saveDomains(allDomains);
548
+
549
+ // Reload nginx
550
+ const reloadResult = await run(nginxReloadCmd(nginxDir), { cwd: nginxDir });
551
+ if (!reloadResult.success) {
552
+ spinner.warn(`Domain ${action}d but nginx reload failed`);
553
+ console.log(chalk.yellow('\n' + combineOutput(reloadResult)));
554
+ } else {
555
+ spinner.succeed(`Domain "${selectedName}" ${action}d`);
556
+ }
557
+ } catch (err) {
558
+ spinner.fail(`Failed to ${action} domain`);
559
+ console.log(chalk.red(err.message));
560
+ }
561
+ }
562
+
397
563
  // โ”€โ”€โ”€ Main Menu (T026, T029-T033) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
398
564
 
399
565
  export async function showDomainManager() {
@@ -409,6 +575,7 @@ export async function showDomainManager() {
409
575
  'List Domains',
410
576
  'Add Domain',
411
577
  'Edit Domain',
578
+ 'Enable / Disable Domain',
412
579
  'Delete Domain',
413
580
  new inquirer.Separator(),
414
581
  'โ† Back',
@@ -437,6 +604,9 @@ export async function showDomainManager() {
437
604
  case 'Edit Domain':
438
605
  await editDomainAction();
439
606
  break;
607
+ case 'Enable / Disable Domain':
608
+ await toggleDomainAction();
609
+ break;
440
610
  case 'Delete Domain':
441
611
  await deleteDomainAction();
442
612
  break;