Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

netget

Package Overview
Dependencies
Maintainers
1
Versions
98
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.56 to 2.3.57

2

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

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

@@ -1,71 +0,45 @@

// i_DefaultNetGetX.js
//i_DefaultNetGetX.js
import chalk from 'chalk';
import fs from 'fs';
import path from 'path';
import { verifyNginxInstallation } from './verifyNginxInstallation.js';
import { verifyServerBlock } from './verifyServerBlock.js';
import { setNginxPath } from './setNginxPath.js';
import checkPublicIP from '../../utils/checkPublicIP.js';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { verifyNginxInstallation } from './verifyNginxInstallation.js';
import { nginxInstallationOptions } from './nginxInstallationOptions.cli.js';
import { verifyServerBlock } from './verifyServerBlock.js';
import checkPublicIP from '../../utils/checkPublicIP.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const userConfigPath = path.join(__dirname, 'userConfig.json');
async function loadUserConfig() {
try {
const jsonString = await fs.promises.readFile(userConfigPath, 'utf8');
return JSON.parse(jsonString);
} catch (error) {
console.error(chalk.red(`Failed to load user configuration: ${error.message}`));
return null; // Handle this according to your error management policy
}
}
export async function i_DefaultNetGetX() {
console.log(chalk.blue('Running Environment Check...'));
console.log(chalk.blue('Running Enviroment Check...'));
// Check for public IP first
const publicIP = await checkPublicIP();
if (publicIP) {
console.log(chalk.green(`Public IP detected: ${publicIP}`));
// You can implement logic based on having a public IP here
} else {
console.log(chalk.red('No public IP detected. Some features may be limited.'));
// Handle the case where no public IP is available if necessary
}
// Verify NGINX installation and configuration
let nginxVerified = await verifyNginxInstallation();
// Check for public IP first
const publicIP = await checkPublicIP();
if (publicIP) {
console.log(chalk.green(`Public IP detected: ${publicIP}`));
} else {
console.log(chalk.red('No public IP detected. Some features may be limited.'));
}
if (!nginxVerified) {
console.log(chalk.yellow('NGINX is not correctly installed or configured.'));
await nginxInstallationOptions();
// Load the user configuration
let userConfig = await loadUserConfig();
if (!userConfig || !userConfig.nginxPath || !fs.existsSync(userConfig.nginxPath)) {
console.log(chalk.yellow('NGINX path is not set or is incorrect.'));
const newPath = await setNginxPath();
if (!newPath) {
console.log(chalk.red('Failed to set a valid NGINX configuration path.'));
return false; // Exit if we cannot set a valid path
}
userConfig = await loadUserConfig(); // Reload configuration after setting the path
}
// Verify NGINX installation and configuration
let nginxVerified = await verifyNginxInstallation(userConfig.nginxPath);
if (!nginxVerified) {
console.log(chalk.yellow('Attempting to correct NGINX path or installation...'));
await setNginxPath(); // Attempt to correct the path or installation
nginxVerified = await verifyNginxInstallation(userConfig.nginxPath); // Re-check using the potentially new path
// Recheck after installation options might have changed the state
nginxVerified = await verifyNginxInstallation();
if (!nginxVerified) {
console.log(chalk.red('NGINX installation or configuration still incorrect after attempted fixes.'));
return false;
return false; // Exit after rechecking and still failing
}
}
console.log(chalk.green('NGINX installation and configuration are correct.'));
// Proceed to verify the NGINX server block configuration
console.log(chalk.blue('Verifying NGINX server block...'));
const serverBlockVerified = await verifyServerBlock();
if (!serverBlockVerified) {
console.log(chalk.yellow('NGINX server block is not correctly configured.'));
return false;
return false; // Exit if server block cannot be verified or fixed
}
console.log(chalk.green('All configurations are correct.'));
// Proceed to main functionality
return true;
}
}
{
"nginxConfigurationProceed": false,
"nginxPath": "/opt/homebrew/etc/nginx/nginx.conf"
"nginxPath": "/opt/homebrew/etc/nginx/nginx.conf",
"useSudo": false
}
// verifyNginxInstallation.js
// verifyNginxInstallation.js
import chalk from 'chalk';

@@ -7,18 +6,52 @@ import { execShellCommand } from '../../utils/execShellCommand.js';

import path from 'path';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export const verifyNginxInstallation = async (nginxPath) => {
if (!nginxPath || !fs.existsSync(nginxPath)) {
console.error(chalk.red(`NGINX configuration path not set or does not exist: ${nginxPath}`));
// Function to load the current user configuration
async function loadUserConfig() {
const userConfigPath = path.join(__dirname, 'userConfig.json');
try {
const data = await fs.promises.readFile(userConfigPath, 'utf8');
return JSON.parse(data);
} catch (error) {
console.error(chalk.red(`Failed to load user configuration: ${error.message}`));
return {};
}
}
export const verifyNginxInstallation = async () => {
const userConfig = await loadUserConfig();
const nginxCommand = userConfig.useSudo ? 'sudo nginx -v' : 'nginx -v';
try {
const result = await execShellCommand(nginxCommand);
console.log(chalk.green(`NGINX successfully verified with output: ${result}`));
return true;
} catch (error) {
console.error(chalk.red(`Verification of NGINX installation failed: ${error.message}`));
if (error.message.toLowerCase().includes('permission denied')) {
console.log(chalk.yellow('Permission denied. Trying with sudo...'));
return handlePermissionDenied(userConfig);
}
return false;
}
};
async function handlePermissionDenied(userConfig) {
// Update userConfig to use sudo for future commands
userConfig.useSudo = true;
const userConfigPath = path.join(__dirname, 'userConfig.json');
await fs.promises.writeFile(userConfigPath, JSON.stringify(userConfig, null, 2));
// Retry command with sudo
try {
// Attempt to execute NGINX command using the full path
const result = await execShellCommand(`${nginxPath} -v`);
console.log(chalk.green(`NGINX successfully verified at ${nginxPath}`));
const result = await execShellCommand('sudo nginx -v');
console.log(chalk.green(`NGINX successfully verified with sudo: ${result}`));
return true;
} catch (error) {
console.error(chalk.red(`Verification of NGINX installation failed at ${nginxPath}: ${error.message}`));
console.error(chalk.red(`Failed to verify NGINX installation with sudo: ${error.message}`));
return false;
}
};
}
// NetGetX.cli.js
import inquirer from 'inquirer';
import { showNGXBlocks } from './src/showXBlocks.js';
import { showXBlocks } from './src/showXBlocks.js';
import chalk from 'chalk';

@@ -25,8 +25,8 @@ //import { addNewNGXBlock } from './src/addNewNGXBlock.js';

case 'Show NGXBlocks':
await showNGXBlocks();
await showXBlocks();
console.log('Show NGXBlocks');
break;
case 'Add New NGXBlock':
case 'Add New XBlock':
// await addNewNGXBlock();
console.log('Add New NGXBlock');
console.log('Add New XBlock');
break;

@@ -33,0 +33,0 @@ // Continue handling other cases similarly

@@ -11,3 +11,3 @@ // netGetXOptions.js

const __dirname = dirname(__filename);
const blocksPath = path.join(__dirname, 'NGXBlocks.json');
const blocksPath = path.join(__dirname, 'XBlocks.json');

@@ -24,3 +24,3 @@ async function loadNGXBlocks() {

export async function showNGXBlocks() {
export async function showXBlocks() {
console.log(chalk.blue('Loading NGXBlocks...'));

@@ -27,0 +27,0 @@ const blocks = await loadNGXBlocks();

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