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 +87 -44
- package/cli/index.js +27 -5
- package/cli/managers/domain-manager.js +204 -34
- package/cli/managers/nginx-manager.js +60 -20
- package/cli/managers/ssl-manager.js +441 -579
- 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 +100 -63
- 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 +257 -20
- package/dashboard/routes/domains.js +110 -72
- package/dashboard/routes/settings.js +19 -11
- package/dashboard/routes/ssl.js +235 -59
- package/dashboard/views/index.ejs +481 -260
- package/dashboard/views/partials/domain-form.ejs +332 -228
- 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 -51
- 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
|
@@ -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,6 +66,20 @@ 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 });
|
|
69
|
+
const PathDomain = await pathExists(`${nginxDir}\\conf\\conf.d`);
|
|
70
|
+
const willKnown = await pathExists(`${nginxDir}\\html\\.well-known`);
|
|
71
|
+
|
|
72
|
+
if (!PathDomain) {
|
|
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 }));
|
|
81
|
+
}
|
|
82
|
+
|
|
58
83
|
return {
|
|
59
84
|
success: result.success,
|
|
60
85
|
output: (result.stdout + '\n' + result.stderr).trim(),
|
|
@@ -106,6 +131,7 @@ async function restartNginx(nginxExe, nginxDir) {
|
|
|
106
131
|
let result;
|
|
107
132
|
if (isWindows) {
|
|
108
133
|
await run('taskkill /f /IM nginx.exe', { cwd: nginxDir });
|
|
134
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
109
135
|
result = await run(`& "${nginxExe}"`, { cwd: nginxDir });
|
|
110
136
|
} else {
|
|
111
137
|
result = await run('systemctl restart nginx');
|
|
@@ -239,32 +265,33 @@ async function installNginx() {
|
|
|
239
265
|
|
|
240
266
|
// ── Windows ──────────────────────────────────────────────────────────────────
|
|
241
267
|
const spinner = ora('Checking for winget…').start();
|
|
268
|
+
//! Winget is not reliably available on all Windows versions (missing from Windows Server, and some users report it missing on Windows 10 desktop), so we'll skip it for now and go straight to the direct download method. We can revisit this in the future if winget becomes more ubiquitous.
|
|
242
269
|
|
|
243
270
|
// Try winget first (available on Windows 10/11 desktop; not on Windows Server by default)
|
|
244
|
-
const wingetCheck = await run('where.exe winget 2>$null');
|
|
245
|
-
const hasWinget = wingetCheck.success && wingetCheck.stdout.trim().length > 0;
|
|
246
|
-
|
|
247
|
-
if (hasWinget) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
271
|
+
// const wingetCheck = await run('where.exe winget 2>$null');
|
|
272
|
+
// const hasWinget = wingetCheck.success && wingetCheck.stdout.trim().length > 0;
|
|
273
|
+
|
|
274
|
+
// if (hasWinget) {
|
|
275
|
+
// spinner.text = 'Installing nginx via winget…';
|
|
276
|
+
// const result = await run(
|
|
277
|
+
// 'winget install -e --id Nginx.Nginx --accept-package-agreements --accept-source-agreements',
|
|
278
|
+
// { timeout: 120000 },
|
|
279
|
+
// );
|
|
280
|
+
// if (result.success) {
|
|
281
|
+
// spinner.succeed('nginx installed successfully');
|
|
282
|
+
// return { success: true, message: 'nginx installed successfully', output: result.stdout };
|
|
283
|
+
// }
|
|
284
|
+
// spinner.fail('winget install failed');
|
|
285
|
+
// console.log(chalk.red(result.stderr || result.stdout));
|
|
286
|
+
// console.log(chalk.gray('\n Manual instructions: https://nginx.org/en/docs/install.html\n'));
|
|
287
|
+
// return { success: false, message: 'Installation failed', output: result.stderr || result.stdout };
|
|
288
|
+
// }
|
|
262
289
|
|
|
263
290
|
// ── Fallback: direct download from nginx.org ─────────────────────────────────
|
|
264
291
|
spinner.text = 'Fetching latest nginx version…';
|
|
265
292
|
|
|
266
293
|
// Try to resolve the current stable version; fall back to a known-good release
|
|
267
|
-
const FALLBACK_VERSION = '1.
|
|
294
|
+
const FALLBACK_VERSION = '1.29.6';
|
|
268
295
|
let nginxVersion = FALLBACK_VERSION;
|
|
269
296
|
|
|
270
297
|
const fetchVersionResult = await run(
|
|
@@ -311,6 +338,19 @@ async function installNginx() {
|
|
|
311
338
|
return { success: false, message: 'nginx.exe not found after extraction' };
|
|
312
339
|
}
|
|
313
340
|
|
|
341
|
+
// Create conf/conf.d directory for domain config files
|
|
342
|
+
await import('fs/promises').then(fs => fs.mkdir(`${nginxDir}\\conf\\conf.d`, { recursive: true }));
|
|
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
|
+
|
|
314
354
|
spinner.succeed(`nginx ${nginxVersion} installed to ${nginxDir}`);
|
|
315
355
|
return { success: true, message: `nginx ${nginxVersion} installed successfully`, output: '' };
|
|
316
356
|
}
|