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 +87 -44
- package/cli/index.js +27 -5
- package/cli/managers/domain-manager.js +143 -35
- package/cli/managers/nginx-manager.js +33 -9
- package/cli/managers/ssl-manager.js +386 -671
- package/cli/menus/settings.js +27 -8
- package/core/config.js +5 -2
- package/core/detector.js +50 -87
- package/core/nginx-conf-generator.js +101 -64
- package/core/platform.js +61 -0
- package/core/shell.js +2 -2
- package/core/validators.js +96 -0
- package/dashboard/lib/cert-reader.js +5 -5
- package/dashboard/lib/nginx-service.js +47 -77
- package/dashboard/public/img/icon.png +0 -0
- package/dashboard/public/img/icon_b.png +0 -0
- package/dashboard/public/js/app.js +193 -29
- package/dashboard/routes/domains.js +96 -72
- package/dashboard/routes/settings.js +19 -11
- package/dashboard/routes/ssl.js +215 -74
- package/dashboard/views/index.ejs +481 -260
- package/dashboard/views/partials/domain-form.ejs +332 -256
- package/dashboard/views/partials/domains-panel.ejs +100 -62
- package/dashboard/views/partials/login.ejs +157 -40
- package/dashboard/views/partials/nginx-panel.ejs +126 -84
- package/dashboard/views/partials/overview.ejs +124 -49
- package/dashboard/views/partials/settings-panel.ejs +66 -35
- package/dashboard/views/partials/sidebar.ejs +84 -33
- package/dashboard/views/partials/ssl-panel.ejs +174 -93
- package/install.sh +8 -9
- package/lib/installer/nvm-bootstrap.sh +8 -8
- package/lib/installer/picker.sh +32 -15
- package/package.json +4 -2
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
|
[](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
|
|
15
|
-
- **๐ Domain Management** โ Reverse proxy
|
|
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
|
|
25
|
-
- Optional: Nginx,
|
|
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
|
-
|
|
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 |
|
|
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
|
-
|
|
|
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
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
192
|
+
#### Challenge Methods
|
|
180
193
|
|
|
181
|
-
|
|
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
|
-
|
|
199
|
+
> **Wildcard certificates** (`*.example.com`) require DNS-01 โ HTTP-01 is automatically disabled for wildcard domains.
|
|
184
200
|
|
|
185
|
-
|
|
201
|
+
#### Certificate Storage
|
|
186
202
|
|
|
187
|
-
|
|
203
|
+
Certificates are stored under `sslDir` (configured in Settings):
|
|
188
204
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
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` |
|
|
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,
|
|
256
|
-
| `system-detection` | Cached system info (OS, Node, nginx
|
|
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/ #
|
|
268
|
-
โ โโโ menus/ #
|
|
301
|
+
โ โโโ managers/ # Domain, Nginx, SSL, Node.js logic
|
|
302
|
+
โ โโโ menus/ # Thin menu dispatcher wrappers
|
|
269
303
|
โโโ core/
|
|
270
|
-
โ โโโ config.js # Configuration
|
|
271
|
-
โ โโโ db.js # SQLite
|
|
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
|
-
โ โโโ
|
|
310
|
+
โ โโโ validators.js # Shared input validation helpers
|
|
275
311
|
โโโ dashboard/
|
|
276
312
|
โ โโโ server.js # Express + Socket.io server
|
|
277
|
-
โ โโโ routes/ #
|
|
278
|
-
โ โโโ lib/ #
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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 (
|
|
334
|
+
| SSL โ HTTP-01 (acme-client) | โ
| โ
|
|
|
335
|
+
| SSL โ DNS-01 (acme-client) | โ
| โ
|
|
|
336
|
+
| Wildcard Certificates | โ
| โ
|
|
|
300
337
|
| Node.js (nvm) | โ
| โ
(nvm-windows) |
|
|
301
|
-
|
|
|
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
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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('
|
|
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: [
|
|
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
|
-
|
|
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: '
|
|
95
|
-
{
|
|
96
|
-
|
|
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
|
-
{
|
|
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,
|
|
130
|
+
const { nginxDir, sslDir } = loadConfig();
|
|
119
131
|
const platform = isWindows ? 'win32' : 'linux';
|
|
120
132
|
const defaultCertPath = platform === 'win32'
|
|
121
|
-
? `C:\\
|
|
122
|
-
: `${
|
|
133
|
+
? `C:\\easy-devops\\ssl\\${basic.name}\\fullchain.pem`
|
|
134
|
+
: `${sslDir}/${basic.name}/fullchain.pem`;
|
|
123
135
|
const defaultKeyPath = platform === 'win32'
|
|
124
|
-
? `C:\\
|
|
125
|
-
: `${
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
}
|