New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

netget

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netget - npm Package Compare versions

Comparing version 2.3.82 to 2.3.83

2

package.json
{
"name": "netget",
"version": "2.3.82",
"version": "2.3.83",
"description": "Rette Adepto/ Recibido Directamente.",

@@ -5,0 +5,0 @@ "type": "module",

@@ -1,6 +0,5 @@

// configureDefaultServerBlock.js
import fs from 'fs';
import chalk from 'chalk';
import defaultServerBlock from './defaultServerBlock.js';
import sudo from 'sudo-prompt';
import inquirer from 'inquirer';
import { execShellCommand } from '../../utils/execShellCommand.js';

@@ -10,11 +9,10 @@

try {
// Write the default server block configuration to the NGINX configuration file
fs.writeFileSync(userConfig.nginxPath, defaultServerBlock);
console.log(chalk.green(`NGINX default server block has been configured to match NetGetX requirements at ${userConfig.nginxPath}.`));
console.log(chalk.green(`NGINX default server block has been configured at ${userConfig.nginxPath}.`));
} catch (error) {
if (error.code === 'EACCES') {
console.error(chalk.yellow(`Permission denied writing to ${userConfig.nginxPath}.`));
handlePermissionError(userConfig.nginxPath, defaultServerBlock);
console.error(chalk.red(`Permission denied writing to ${userConfig.nginxPath}.`));
await handlePermissionError(userConfig.nginxPath, defaultServerBlock);
} else {
console.error(chalk.red(`Failed to write NGINX default server block config at ${userConfig.nginxPath}: ${error.message}`));
console.error(chalk.red(`Error writing to ${userConfig.nginxPath}: ${error.message}`));
}

@@ -24,13 +22,44 @@ }

const handlePermissionError = (path, data) => {
console.log(chalk.yellow('Attempting to gain elevated privileges to configure NGINX...'));
const handlePermissionError = async (path, data) => {
const choices = [
{ name: 'Retry with elevated privileges (sudo)', value: 'sudo' },
{ name: 'Display manual configuration instructions', value: 'manual' },
{ name: 'Cancel operation', value: 'cancel' }
];
const { action } = await inquirer.prompt({
type: 'list',
name: 'action',
message: 'Permission denied. How would you like to proceed?',
choices: choices
});
switch (action) {
case 'sudo':
tryElevatedPrivileges(path, data);
break;
case 'manual':
displayManualInstructions(path, data);
break;
case 'cancel':
console.log(chalk.blue('Operation canceled by the user.'));
break;
}
};
const tryElevatedPrivileges = (path, data) => {
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;
}
execShellCommand(command).then(() => {
console.log(chalk.green('Successfully configured NGINX with elevated privileges.'));
}).catch(error => {
console.error(chalk.red(`Failed with elevated privileges: ${error.message}`));
});
};
};
const displayManualInstructions = (path, data) => {
console.log(chalk.yellow('Please follow these instructions to manually configure the NGINX server block:'));
console.info(chalk.blue(`1. Open a terminal as a superuser or with root privileges.`));
console.info(chalk.blue(`2. Use a text editor to open the NGINX configuration file: sudo nano ${path}`));
console.info(chalk.blue(`3. Add or replace the following content:`));
console.info(chalk.green(data));
};
import os from 'os';
import chalk from 'chalk';
import { exec } from 'child_process';
import inquirer from 'inquirer';
import { execShellCommand } from '../../utils/execShellCommand.js';

@@ -9,6 +9,6 @@

exec('choco', (error, stdout, stderr) => {
if (error && stderr.includes('is not recognized as an internal or external command')) {
if (error && stderr.includes('is not recognized as an internal or external command, operable program or batch file.')) {
resolve(false); // Chocolatey is not installed.
} else {
resolve(true); // Chocolatey is installed or other error.
resolve(true); // Chocolatey is installed or another error not related to existence.
}

@@ -19,24 +19,26 @@ });

const determineInstallCommand = (version, customVersion) => {
const determineInstallCommand = (version) => {
switch (os.platform()) {
case 'darwin':
return 'brew install nginx'; // Homebrew on macOS
return 'brew install nginx';
case 'linux':
return 'sudo apt-get install nginx -y'; // Debian-based Linux
return 'sudo apt-get install nginx -y';
case 'win32':
return 'choco install nginx'; // Chocolatey on Windows
return 'choco install nginx';
default:
console.error(chalk.red('Unsupported operating system for automatic installation.'));
return null;
return null; // Unsupported OS
}
};
export const installNginx = async (version, customVersion) => {
export const installNginx = async (version) => {
if (os.platform() === 'win32' && !await checkForChoco()) {
console.error(chalk.yellow('Chocolatey is not installed. Please install Chocolatey or install NGINX manually.'));
return { success: false, message: 'Chocolatey not installed' };
return false;
}
const installCmd = determineInstallCommand(version, customVersion);
if (!installCmd) return { success: false, message: 'Unsupported OS for automatic installation' };
const installCmd = determineInstallCommand(version);
if (!installCmd) {
console.error(chalk.red('Unsupported operating system for automatic installation.'));
return false;
}

@@ -46,22 +48,66 @@ console.log(chalk.blue(`Using command: ${installCmd}`));

await execShellCommand(installCmd);
console.log("NGINX installation complete.");
console.log(chalk.green("NGINX installation complete."));
return true;
} catch (error) {
console.error(chalk.red(`${error.message}`));
handleInstallationError(error);
return await handleInstallationError(installCmd, error);
}
};
const handleInstallationError = async (error) => {
const handleInstallationError = async (installCmd, error) => {
// Log the error and provide OS-specific advice
console.error(chalk.red(`Installation error encountered: ${error.message}`));
switch (os.platform()) {
case 'darwin':
return handleDarwinError(installCmd, error);
case 'linux':
return handleLinuxError(installCmd, error);
case 'win32':
return handleWindowsError(installCmd, error);
default:
console.error(chalk.red('Error handling not available for this OS.'));
return false;
}
};
const handleDarwinError = (installCmd, error) => {
if (error.message.includes('Permission denied')) {
console.log(chalk.cyan("Homebrew might need permissions to write to its directories. This error may not be fatal, proceeding with setup."));
return true; // Continue as this might not be fatal
} else {
suggestHomebrewFix();
return false;
}
};
const handleLinuxError = (installCmd, error) => {
if (error.message.toLowerCase().includes('permission denied')) {
console.log(chalk.yellow('Please check the permissions or try running the command with elevated privileges.'));
console.log(chalk.cyan("Try running the command with sudo or adjust permissions as necessary. Error may not halt setup."));
return true; // Proceed conditionally
} else {
suggestLinuxFix(installCmd);
return false;
}
// Here, you can decide to prompt the user with options to retry, adjust permissions, or exit instead of automatically rerunning checks.
};
const suggestPermissionFix = (filePath) => {
const permissionAdvice = os.platform() === 'win32' ?
`Consider adjusting the file permissions manually in the file properties of ${filePath}, or use the 'icacls' command.` :
`Consider running 'sudo chmod +rw ${filePath}' to fix permission issues.`;
console.log(chalk.cyan(permissionAdvice));
const handleWindowsError = (installCmd, error) => {
if (error.message.toLowerCase().includes('permission denied')) {
console.log(chalk.cyan("Check if you have administrative privileges to run the installation. Error may not halt setup."));
return true; // Proceed conditionally
} else {
suggestWindowsFix(installCmd);
return false;
}
};
const suggestHomebrewFix = () => {
console.log(chalk.cyan("Ensure Homebrew is properly set up and has necessary permissions. Consider consulting Homebrew's troubleshooting guide."));
};
const suggestLinuxFix = (installCmd) => {
console.log(chalk.cyan(`If issues persist, manually run '${installCmd}' or consult NGINX's Linux installation guide.`));
};
const suggestWindowsFix = (installCmd) => {
console.log(chalk.cyan(`Ensure you have the necessary admin rights to run '${installCmd}' or check the installation steps for NGINX on Windows.`));
};

@@ -21,3 +21,3 @@ // serverBlockConfigOptions.cli.js

switch (answers.action) {
case 'Restore NGINX Default to Recommended Settings':
case 'Set/Restore NGINX to Default NetGetX to Recommended Settings':
await configureDefaultServerBlock(userConfig);

@@ -24,0 +24,0 @@ return true; // Configuration was successfully restored

@@ -41,6 +41,6 @@ import fs from 'fs';

console.log(chalk.red('Installation or configuration aborted.'));
return; // Stop further execution if installation was not successful
return false; // Stop further execution if installation was not successful
}
}
// If all goes well and paths are detected
const userConfig = await loadUserConfig();

@@ -47,0 +47,0 @@ const responses = await inquirer.prompt([

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc