Comparing version 2.3.79 to 2.3.81
{ | ||
"name": "netget", | ||
"version": "2.3.79", | ||
"version": "2.3.81", | ||
"description": "Rette Adepto/ Recibido Directamente.", | ||
@@ -36,3 +36,4 @@ "type": "module", | ||
"morgan": "^1.10.0", | ||
"node-fetch": "^3.3.2" | ||
"node-fetch": "^3.3.2", | ||
"sudo-prompt": "^9.2.1" | ||
}, | ||
@@ -39,0 +40,0 @@ "repository": { |
// configureDefaultServerBlock.js | ||
import fs from 'fs'; | ||
import chalk from 'chalk'; | ||
import defaultServerBlock from './defaultServerBlock.js'; // Ensure this import is correct | ||
import defaultServerBlock from './defaultServerBlock.js'; | ||
import sudo from 'sudo-prompt'; | ||
import { execShellCommand } from '../../utils/execShellCommand.js'; | ||
@@ -13,5 +14,22 @@ | ||
} catch (error) { | ||
console.error(chalk.red(`Failed to write NGINX default server block config at ${userConfig.nginxPath}: ${error.message}`)); | ||
console.error(error); // Show detailed error if the write fails or command execution has issues | ||
if (error.code === 'EACCES') { | ||
console.error(chalk.yellow(`Permission denied writing to ${userConfig.nginxPath}.`)); | ||
handlePermissionError(userConfig.nginxPath, defaultServerBlock); | ||
} else { | ||
console.error(chalk.red(`Failed to write NGINX default server block config at ${userConfig.nginxPath}: ${error.message}`)); | ||
} | ||
} | ||
}; | ||
const handlePermissionError = (path, data) => { | ||
console.log(chalk.yellow('Attempting to gain elevated privileges to configure NGINX...')); | ||
const command = `echo '${data.replace(/'/g, "\\'")}' | sudo tee ${path}`; | ||
sudo.exec(command, { name: 'NetGetX' }, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(chalk.red(`Failed with elevated privileges: ${error.message}`)); | ||
return; | ||
} | ||
console.log(chalk.green('Successfully configured NGINX with elevated privileges.')); | ||
}); | ||
}; |
{ | ||
"nginxConfigurationProceed": false, | ||
"nginxPath": "", | ||
"nginxSitesAvailable": "", | ||
"nginxSitesEnabled": "", | ||
"nginxPath": "/opt/homebrew/etc/nginx/nginx.conf", | ||
"nginxSitesAvailable": "/opt/homebrew/etc/nginx/sites-available", | ||
"nginxSitesEnabled": "/opt/homebrew/etc/nginx/sites-enabled", | ||
"useSudo": false, | ||
"nginxExecutable": "" | ||
"nginxExecutable": "/opt/homebrew/bin/nginx" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
870854
1095
7
+ Addedsudo-prompt@^9.2.1
+ Addedsudo-prompt@9.2.1(transitive)