easy-devops 0.2.7 โ†’ 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
 
@@ -20,28 +20,7 @@ import { loadConfig } from '../../core/config.js';
20
20
  import { getDomains, saveDomains, findDomain, createDomain, DOMAIN_DEFAULTS } from '../../dashboard/lib/domains-db.js';
21
21
  import { generateConf, buildConf } from '../../core/nginx-conf-generator.js';
22
22
  import { issueCert } from './ssl-manager.js';
23
-
24
- const isWindows = process.platform === 'win32';
25
-
26
- // โ”€โ”€โ”€ Helper functions โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
27
-
28
- function getNginxExe(nginxDir) {
29
- return isWindows ? `${nginxDir}\\nginx.exe` : 'nginx';
30
- }
31
-
32
- function nginxTestCmd(nginxDir) {
33
- const exe = getNginxExe(nginxDir);
34
- return isWindows ? `& "${exe}" -t` : 'nginx -t';
35
- }
36
-
37
- function nginxReloadCmd(nginxDir) {
38
- const exe = getNginxExe(nginxDir);
39
- return isWindows ? `& "${exe}" -s reload` : 'nginx -s reload';
40
- }
41
-
42
- function combineOutput(result) {
43
- return [result.stdout, result.stderr].filter(Boolean).join('\n').trim();
44
- }
23
+ import { isWindows, nginxTestCmd, nginxReloadCmd, combineOutput } from '../../core/platform.js';
45
24
 
46
25
  // โ”€โ”€โ”€ List Domains โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
47
26
 
@@ -56,13 +35,14 @@ async function listDomainsAction() {
56
35
  const table = new Table({
57
36
  head: [
58
37
  chalk.cyan('Domain'),
59
- chalk.cyan('Port'),
38
+ chalk.cyan('Backend'),
60
39
  chalk.cyan('Type'),
61
40
  chalk.cyan('SSL'),
41
+ chalk.cyan('Status'),
62
42
  chalk.cyan('Cert'),
63
43
  ],
64
44
  style: { head: [], border: ['gray'] },
65
- colWidths: [30, 8, 8, 8, 8],
45
+ colWidths: [28, 20, 8, 8, 10, 8],
66
46
  });
67
47
 
68
48
  for (const d of domains) {
@@ -72,11 +52,18 @@ async function listDomainsAction() {
72
52
  ? (d.daysLeft > 30 ? chalk.green(`${d.daysLeft}d`) : chalk.yellow(`${d.daysLeft}d`))
73
53
  : chalk.gray('โ€”');
74
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'));
75
61
  table.push([
76
62
  d.name,
77
- d.port.toString(),
63
+ backend,
78
64
  type,
79
65
  sslStatus,
66
+ status,
80
67
  certDays,
81
68
  ]);
82
69
  }
@@ -91,14 +78,39 @@ async function addDomainAction() {
91
78
 
92
79
  // Section 1: Basic
93
80
  const basic = await inquirer.prompt([
94
- { type: 'input', name: 'name', message: 'Domain name:', validate: (v) => v.trim() ? true : 'Required' },
95
- { type: 'input', name: 'backendHost', message: 'Backend host:', default: '127.0.0.1' },
96
- { 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
+ },
97
106
  {
98
107
  type: 'list', name: 'upstreamType', message: 'Upstream type:', default: 'http',
99
108
  choices: ['http', 'https', 'ws'],
100
109
  },
101
- { 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
+ },
102
114
  ]);
103
115
 
104
116
  // Check for duplicate
@@ -115,14 +127,14 @@ async function addDomainAction() {
115
127
  let ssl = { ...DOMAIN_DEFAULTS.ssl, enabled: sslAnswers.enabled };
116
128
 
117
129
  if (ssl.enabled) {
118
- const { nginxDir, certbotDir } = loadConfig();
130
+ const { nginxDir, sslDir } = loadConfig();
119
131
  const platform = isWindows ? 'win32' : 'linux';
120
132
  const defaultCertPath = platform === 'win32'
121
- ? `C:\\Certbot\\live\\${basic.name}\\fullchain.pem`
122
- : `${certbotDir}/live/${basic.name}/fullchain.pem`;
133
+ ? `C:\\easy-devops\\ssl\\${basic.name}\\fullchain.pem`
134
+ : `${sslDir}/${basic.name}/fullchain.pem`;
123
135
  const defaultKeyPath = platform === 'win32'
124
- ? `C:\\Certbot\\live\\${basic.name}\\privkey.pem`
125
- : `${certbotDir}/live/${basic.name}/privkey.pem`;
136
+ ? `C:\\easy-devops\\ssl\\${basic.name}\\privkey.pem`
137
+ : `${sslDir}/${basic.name}/privkey.pem`;
126
138
 
127
139
  const sslDetails = await inquirer.prompt([
128
140
  { type: 'input', name: 'certPath', message: 'SSL cert path:', default: defaultCertPath },
@@ -179,7 +191,7 @@ async function addDomainAction() {
179
191
 
180
192
  if (certAction === 'Create certificate now') {
181
193
  const spinner = ora(`Creating certificate for ${basic.name}โ€ฆ`).start();
182
- const result = await issueCert(basic.name, { www: basic.www });
194
+ const result = await issueCert(basic.name, { www: basic.www, wildcard: basic.wildcard, validationMethod: basic.wildcard ? 'dns' : 'http' });
183
195
  spinner.stop();
184
196
 
185
197
  if (result.success) {
@@ -268,6 +280,7 @@ async function addDomainAction() {
268
280
  backendHost: basic.backendHost,
269
281
  upstreamType: basic.upstreamType,
270
282
  www: basic.www,
283
+ wildcard: basic.wildcard,
271
284
  ssl,
272
285
  performance,
273
286
  security,
@@ -456,6 +469,97 @@ async function reloadNginxAfterChange() {
456
469
  return true;
457
470
  }
458
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
+
459
563
  // โ”€โ”€โ”€ Main Menu (T026, T029-T033) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
460
564
 
461
565
  export async function showDomainManager() {
@@ -471,6 +575,7 @@ export async function showDomainManager() {
471
575
  'List Domains',
472
576
  'Add Domain',
473
577
  'Edit Domain',
578
+ 'Enable / Disable Domain',
474
579
  'Delete Domain',
475
580
  new inquirer.Separator(),
476
581
  'โ† Back',
@@ -499,6 +604,9 @@ export async function showDomainManager() {
499
604
  case 'Edit Domain':
500
605
  await editDomainAction();
501
606
  break;
607
+ case 'Enable / Disable Domain':
608
+ await toggleDomainAction();
609
+ break;
502
610
  case 'Delete Domain':
503
611
  await deleteDomainAction();
504
612
  break;
@@ -16,8 +16,19 @@ import ora from 'ora';
16
16
  import { run, runLive } from '../../core/shell.js';
17
17
  import { loadConfig } from '../../core/config.js';
18
18
  import { ensureNginxInclude } from '../../core/nginx-conf-generator.js';
19
+ import { isWindows } from '../../core/platform.js';
19
20
 
20
- const isWindows = process.platform === 'win32';
21
+ // โ”€โ”€โ”€ Helpers โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
22
+ import { access } from 'fs/promises';
23
+
24
+ async function pathExists(p) {
25
+ try {
26
+ await access(p);
27
+ return true;
28
+ } catch {
29
+ return false;
30
+ }
31
+ }
21
32
 
22
33
  // โ”€โ”€โ”€ getNginxStatus โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
23
34
 
@@ -55,16 +66,18 @@ async function testConfig(nginxExe, nginxDir) {
55
66
  await ensureNginxInclude(nginxDir);
56
67
  const cmd = isWindows ? `& "${nginxExe}" -t` : 'nginx -t';
57
68
  const result = await run(cmd, { cwd: nginxDir });
58
- const PathDomain = await import('fs/promises').then(fs => fs.exists(`${nginxDir}\\conf\\conf.d`));
69
+ const PathDomain = await pathExists(`${nginxDir}\\conf\\conf.d`);
70
+ const willKnown = await pathExists(`${nginxDir}\\html\\.well-known`);
59
71
 
60
72
  if (!PathDomain) {
61
- const createPath = await import('fs/promises').then(fs => fs.mkdir(`${nginxDir}\\conf\\conf.d`, { recursive: true }));
62
- if (!createPath) {
63
- return {
64
- success: false,
65
- output: `Failed to create conf.d directory at ${nginxDir}\\conf\\conf.d`,
66
- };
67
- }
73
+ console.warn(chalk.yellow(`Warning: conf.d directory not found in ${nginxDir} โ€” creating it now...`));
74
+ await import('fs/promises').then(fs => fs.mkdir(`${nginxDir}\\conf\\conf.d`, { recursive: true }));
75
+ }
76
+
77
+ if (!willKnown) {
78
+ console.warn(chalk.yellow(`Warning: .well-known/acme-challenge directory not found in ${nginxDir} โ€” creating it now...`));
79
+ await import('fs/promises').then(fs => fs.mkdir(`${nginxDir}\\html\\.well-known\\`, { recursive: true }));
80
+ await import('fs/promises').then(fs => fs.mkdir(`${nginxDir}\\html\\.well-known\\acme-challenge`, { recursive: true }));
68
81
  }
69
82
 
70
83
  return {
@@ -118,6 +131,7 @@ async function restartNginx(nginxExe, nginxDir) {
118
131
  let result;
119
132
  if (isWindows) {
120
133
  await run('taskkill /f /IM nginx.exe', { cwd: nginxDir });
134
+ await new Promise(resolve => setTimeout(resolve, 2000));
121
135
  result = await run(`& "${nginxExe}"`, { cwd: nginxDir });
122
136
  } else {
123
137
  result = await run('systemctl restart nginx');
@@ -327,6 +341,16 @@ async function installNginx() {
327
341
  // Create conf/conf.d directory for domain config files
328
342
  await import('fs/promises').then(fs => fs.mkdir(`${nginxDir}\\conf\\conf.d`, { recursive: true }));
329
343
 
344
+ await import('fs/promises').then(fs => fs.mkdir(`${nginxDir}\\html\\.well-known\\`, { recursive: true }));
345
+ // Create html/.well-known/acme-challenge directory for SSL certificate verification
346
+ await import('fs/promises').then(fs => fs.writeFile(`${nginxDir}\\html\\.well-known\\acme-challenge`, '', (err) => {
347
+ if (err) {
348
+ console.error(chalk.red(`Failed to create acme-challenge directory: ${err.message}`));
349
+ } else {
350
+ console.log(chalk.green('Created acme-challenge directory for SSL certificate verification'));
351
+ }
352
+ }));
353
+
330
354
  spinner.succeed(`nginx ${nginxVersion} installed to ${nginxDir}`);
331
355
  return { success: true, message: `nginx ${nginxVersion} installed successfully`, output: '' };
332
356
  }