easy-devops 0.2.5 → 0.2.6

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.
@@ -4,7 +4,7 @@
4
4
  * Nginx Manager — full control over nginx from the CLI.
5
5
  *
6
6
  * Exported functions:
7
- * - showNginxManager() — interactive menu for managing nginx
7
+ * - showNginxManager() — interactive menu for managing nginx
8
8
  *
9
9
  * All shell calls go through core/shell.js (run / runLive).
10
10
  * Platform differences (Windows/Linux) are handled via isWindows guards.
@@ -14,9 +14,8 @@ import chalk from 'chalk';
14
14
  import inquirer from 'inquirer';
15
15
  import ora from 'ora';
16
16
  import { run, runLive } from '../../core/shell.js';
17
- import { loadConfig, saveConfig } from '../../core/config.js';
17
+ import { loadConfig } from '../../core/config.js';
18
18
  import { ensureNginxInclude } from '../../core/nginx-conf-generator.js';
19
- import { runDetection } from '../../core/detector.js';
20
19
 
21
20
  const isWindows = process.platform === 'win32';
22
21
 
@@ -137,7 +136,7 @@ async function viewErrorLog(logPath) {
137
136
  if (result.success && result.stdout) {
138
137
  console.log('\n' + result.stdout);
139
138
  } else {
140
- console.log(chalk.yellow('\n No errors logged yet (log file not found or empty)\n'));
139
+ console.log(chalk.yellow('\n No errors logged yet (log file not found or empty)\n'));
141
140
  }
142
141
  }
143
142
 
@@ -197,11 +196,11 @@ async function startNginx(nginxExe, nginxDir) {
197
196
  : `tail -n 20 "${logPath}" 2>/dev/null`;
198
197
  const logResult = await run(logCmd);
199
198
 
200
- console.log(chalk.yellow('\n Recent error log:'));
199
+ console.log(chalk.yellow('\n Recent error log:'));
201
200
  if (logResult.success && logResult.stdout) {
202
201
  console.log(chalk.red(logResult.stdout));
203
202
  } else {
204
- console.log(chalk.gray(' (error log not found or empty)'));
203
+ console.log(chalk.gray(' (error log not found or empty)'));
205
204
  }
206
205
 
207
206
  return { success: false };
@@ -234,7 +233,7 @@ async function installNginx() {
234
233
  }
235
234
  spinner.fail('Installation failed');
236
235
  console.log(chalk.red(result.stderr || result.stdout));
237
- console.log(chalk.gray('\n Manual instructions: https://nginx.org/en/docs/install.html\n'));
236
+ console.log(chalk.gray('\n Manual instructions: https://nginx.org/en/docs/install.html\n'));
238
237
  return { success: false, message: 'Installation failed', output: result.stderr || result.stdout };
239
238
  }
240
239
 
@@ -248,53 +247,16 @@ async function installNginx() {
248
247
  if (hasWinget) {
249
248
  spinner.text = 'Installing nginx via winget…';
250
249
  const result = await run(
251
- 'winget install -e --id nginxinc.nginx --accept-package-agreements --accept-source-agreements',
250
+ 'winget install -e --id Nginx.Nginx --accept-package-agreements --accept-source-agreements',
252
251
  { timeout: 120000 },
253
252
  );
254
-
255
- // Check if nginx was installed OR already installed
256
- const output = (result.stdout || '') + (result.stderr || '');
257
- const alreadyInstalled = output.includes('already installed') || output.includes('No newer package') || output.includes('No available upgrade');
258
- const installed = result.success || alreadyInstalled;
259
-
260
- if (installed) {
261
- // Try to detect where nginx was installed and update config
262
- const commonPaths = [
263
- 'C:\\nginx',
264
- `${process.env.ProgramFiles}\\nginx`,
265
- `${process.env.LOCALAPPDATA}\\Programs\\nginx`,
266
- `${process.env.ProgramW6432}\\nginx`,
267
- ];
268
-
269
- let foundPath = null;
270
- for (const p of commonPaths) {
271
- if (!p) continue;
272
- const check = await run(`Test-Path "${p}\\nginx.exe"`);
273
- if (check.stdout.trim().toLowerCase() === 'true') {
274
- foundPath = p;
275
- break;
276
- }
277
- }
278
-
279
- if (foundPath) {
280
- // Update config if different from current
281
- const currentConfig = loadConfig();
282
- if (currentConfig.nginxDir !== foundPath) {
283
- currentConfig.nginxDir = foundPath;
284
- saveConfig(currentConfig);
285
- }
286
- spinner.succeed(`nginx installed at ${foundPath}`);
287
- } else {
288
- spinner.succeed('nginx installed successfully');
289
- }
290
-
291
- // Re-run detection to update the stored info
292
- await runDetection();
253
+ if (result.success) {
254
+ spinner.succeed('nginx installed successfully');
293
255
  return { success: true, message: 'nginx installed successfully', output: result.stdout };
294
256
  }
295
257
  spinner.fail('winget install failed');
296
258
  console.log(chalk.red(result.stderr || result.stdout));
297
- console.log(chalk.gray('\n Manual instructions: https://nginx.org/en/docs/install.html\n'));
259
+ console.log(chalk.gray('\n Manual instructions: https://nginx.org/en/docs/install.html\n'));
298
260
  return { success: false, message: 'Installation failed', output: result.stderr || result.stdout };
299
261
  }
300
262
 
@@ -306,41 +268,26 @@ async function installNginx() {
306
268
  let nginxVersion = FALLBACK_VERSION;
307
269
 
308
270
  const fetchVersionResult = await run(
309
- `[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; try { $p=(Invoke-WebRequest -Uri 'https://nginx.org/en/download.html' -UseBasicParsing -TimeoutSec 15).Content; if($p -match 'nginx-(\\d+\\.\\d+\\.\\d+)\\.zip'){$Matches[1]}else{''} } catch { '' }`,
271
+ `try { $p=(Invoke-WebRequest -Uri 'https://nginx.org/en/download.html' -UseBasicParsing -TimeoutSec 15).Content; if($p -match 'nginx-(\\d+\\.\\d+\\.\\d+)\\.zip'){$Matches[1]}else{''} } catch { '' }`,
310
272
  { timeout: 20000 },
311
273
  );
312
274
  const fetched = (fetchVersionResult.stdout || '').trim();
313
275
  if (/^\d+\.\d+\.\d+$/.test(fetched)) nginxVersion = fetched;
314
276
 
315
- let { nginxDir } = loadConfig();
277
+ const { nginxDir } = loadConfig();
316
278
  const zipUrl = `https://nginx.org/download/nginx-${nginxVersion}.zip`;
317
- const zipDest = `$env:TEMP\\nginx-${nginxVersion}.zip`;
318
279
 
319
280
  spinner.text = `Downloading nginx ${nginxVersion}…`;
320
281
 
321
- // Try Invoke-WebRequest with TLS 1.2 forced, fall back to curl.exe
322
- let downloadOk = false;
323
- let downloadResult = await run(
324
- `[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $ProgressPreference='SilentlyContinue'; Invoke-WebRequest -Uri '${zipUrl}' -OutFile "${zipDest}" -UseBasicParsing -TimeoutSec 120`,
282
+ const downloadResult = await run(
283
+ `$ProgressPreference='SilentlyContinue'; Invoke-WebRequest -Uri '${zipUrl}' -OutFile "$env:TEMP\\nginx-${nginxVersion}.zip" -UseBasicParsing -TimeoutSec 120`,
325
284
  { timeout: 130000 },
326
285
  );
327
- if (downloadResult.success) {
328
- downloadOk = true;
329
- } else {
330
- const hasCurl = (await run('where.exe curl.exe 2>$null')).success;
331
- if (hasCurl) {
332
- downloadResult = await run(
333
- `curl.exe -L --silent --show-error --max-time 120 -o "${zipDest}" "${zipUrl}"`,
334
- { timeout: 130000 },
335
- );
336
- if (downloadResult.success) downloadOk = true;
337
- }
338
- }
339
286
 
340
- if (!downloadOk) {
287
+ if (!downloadResult.success) {
341
288
  spinner.fail('Download failed');
342
289
  console.log(chalk.red(downloadResult.stderr || downloadResult.stdout));
343
- console.log(chalk.gray(`\n Download nginx manually from: https://nginx.org/en/download.html\n`));
290
+ console.log(chalk.gray(`\n Download nginx manually from: https://nginx.org/en/download.html\n`));
344
291
  return { success: false, message: 'Download failed', output: downloadResult.stderr || downloadResult.stdout };
345
292
  }
346
293
 
@@ -364,9 +311,6 @@ async function installNginx() {
364
311
  return { success: false, message: 'nginx.exe not found after extraction' };
365
312
  }
366
313
 
367
- // Re-run detection
368
- await runDetection();
369
-
370
314
  spinner.succeed(`nginx ${nginxVersion} installed to ${nginxDir}`);
371
315
  return { success: true, message: `nginx ${nginxVersion} installed successfully`, output: '' };
372
316
  }
@@ -378,14 +322,14 @@ export async function showNginxManager() {
378
322
  const { nginxDir } = loadConfig();
379
323
  const status = await getNginxStatus(nginxDir);
380
324
 
381
- console.log(chalk.bold('\n Nginx Manager'));
382
- console.log(chalk.gray(' ' + '─'.repeat(40)));
325
+ console.log(chalk.bold('\n Nginx Manager'));
326
+ console.log(chalk.gray(' ' + '─'.repeat(40)));
383
327
 
384
328
  if (status.version) {
385
329
  const statusIcon = status.running ? chalk.green('✅ Running') : chalk.red('❌ Stopped');
386
- console.log(` ${statusIcon} | v${status.version} | ${status.nginxDir}`);
330
+ console.log(` ${statusIcon} | v${status.version} | ${status.nginxDir}`);
387
331
  } else {
388
- console.log(` ${chalk.yellow('⚠ Not installed')}`);
332
+ console.log(` ${chalk.yellow('⚠ Not installed')}`);
389
333
  }
390
334
  console.log();
391
335
 
@@ -435,7 +379,7 @@ export async function showNginxManager() {
435
379
  case 'Test config': {
436
380
  const result = await testConfig(status.nginxExe, status.nginxDir);
437
381
  console.log(
438
- '\n Config test: ' +
382
+ '\n Config test: ' +
439
383
  (result.success ? chalk.green('✓ OK') : chalk.red('✗ Failed')) +
440
384
  '\n',
441
385
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-devops",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "A unified DevOps management tool with CLI and web dashboard for managing Nginx, SSL certificates, and Node.js on Linux and Windows servers.",
5
5
  "keywords": [
6
6
  "devops",