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

netget

Package Overview
Dependencies
Maintainers
1
Versions
96
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.4.31 to 2.4.32

src/modules/NetGetX/config/detectNginxPaths.js

3

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

@@ -10,2 +10,3 @@ "type": "module",

"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "node ./scripts/postInstall.js",
"doc": "jsdoc -c jsdoc.json"

@@ -12,0 +13,0 @@ },

// netget_MainMenu.js
import inquirer from 'inquirer';
import chalk from 'chalk';
import { NetGetX } from './NetGetX/NetGetX.cli.js';
import NetGetX_CLI from './NetGetX/NetGetX.cli.js';
import { i_DefaultNetGetX } from './NetGetX/config/i_DefaultNetGetX.js';
import { handleGateways } from './Gateways/Gateways.js';
import { handleGets } from './Gets/Gets.js';
import pkg from '../../package.json' assert { type: 'json' };

@@ -16,4 +15,4 @@ console.log(`

`);
console.log(`v${pkg.version}...`); // Logs the current version of the application
export async function NetGetMainMenu() {
console.log(`v2.4.31`); // Logs the current version of the application
export default async function NetGetMainMenu() {
/*

@@ -37,3 +36,2 @@

case 'NetGetX':
console.log(chalk.cyan.bold('Initializing NetGetX v0.1.0...'));
try {

@@ -50,3 +48,3 @@ const setupVerified = await i_DefaultNetGetX();

`);
await NetGetX(); // Proceed to the interactive menu if setup is verified
await NetGetX_CLI(); // Proceed to the interactive menu if setup is verified
} else {

@@ -53,0 +51,0 @@ console.log(chalk.red('Setup verification failed. Please resolve any issues before proceeding.'));

//i_DefaultNetGetX.js
import os from 'os';
import chalk from 'chalk';
import os from 'os';
import { verifyNginxInstallation } from './verifyNginxInstallation.js';
import { nginxInstallationOptions } from './nginxInstallationOptions.cli.js';
import { verifyServerBlock } from './verifyServerBlock.js';
import { setNginxPath } from './setNginxPath.js';
import { setNginxExecutable } from './setNginxExecutable.js';
import checkPublicIP from '../../utils/checkPublicIP.js';
import fs from 'fs';
import path from 'path';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { getDir } from '../../../scripts/setupConfig.js';
import loadOrCreateUserConfig from './loadOrCreateUserConfig.js';
import setNginxPaths from './setNginxPaths.js';
import nginxInstallationOptions from './nginxInstallationOptions.cli.js';
import verifyNginxInstallation from './verifyNginxInstallation.js';
import verifyServerBlock from './verifyServerBlock.js';
import setNginxExecutable from './setNginxExecutable.js';
import getPublicIP from '../../utils/getPublicIP.js';
import getLocalIP from '../../utils/getLocalIP.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const userConfigPath = path.join(__dirname, 'userConfig.json');
export async function i_DefaultNetGetX() {
console.log(chalk.blue('Running Environment Check...'));
const platform = os.platform();
const type = os.type();
const release = os.release();
console.log(`Operating System: ${type} (${platform})`);
console.log(`Release: ${release}`);
const publicIP = await checkPublicIP();
console.log(publicIP ? `Public IP detected: ${publicIP}` : chalk.red('No public IP detected. Some features may be limited.'));
console.log(chalk.cyan.bold('NetGetX Enviroment SetUp:'));
getDir();
let userConfig = await loadOrCreateUserConfig();
const OS_Type = os.type();
const OS_Platform = os.platform();
const OS_Release = os.release();
console.log(`OStype: ${chalk.green(OS_Type)} (OS_Platform: ${chalk.green(OS_Platform)} OSrelease: ${chalk.green(OS_Release)})`);
const publicIP = await getPublicIP();
console.log(publicIP ? `publicIp: ${publicIP}` : chalk.red('No public IP detected. Some features may be limited.'));
console.log(chalk.blue('Verifying NGINX Paths...'));
let userConfig = await loadUserConfig();
/* Verify NGINX Paths are set correctly.
╔═╗┌─┐┌┬┐┬ ┬┌─┐
╠═╝├─┤ │ ├─┤└─┐
╩ ┴ ┴ ┴ ┴ ┴└─┘*/
if (!userConfig.nginxPath || !userConfig.nginxSitesAvailable || !userConfig.nginxSitesEnabled) {
console.log(chalk.yellow('One or more NGINX configuration paths are not set. Attempting to set them...'));
await setNginxPath();
userConfig = await loadUserConfig(); // Reload to get updated paths
} else {
console.log(chalk.green('All required NGINX configuration paths are already set.'));
}
// check and set NGINX executable
if (await setNginxPaths(userConfig)) {
userConfig = await loadOrCreateUserConfig(); // Reload to ensure all config updates are reflected
}else{
console.log(chalk.red('Failed to set NGINX configuration paths.'));
return false;
}
}
/*check and set NGINX executable
╔═╗═╗ ╦╔═╗╔═╗╦ ╦╔╦╗╔═╗╔╗ ╦ ╔═╗
║╣ ╔╩╦╝║╣ ║ ║ ║ ║ ╠═╣╠╩╗║ ║╣
╚═╝╩ ╚═╚═╝╚═╝╚═╝ ╩ ╩ ╩╚═╝╩═╝╚═╝*/
if (!userConfig.nginxExecutable) {
console.log(chalk.yellow("NGINX executable not set. Attempting to set it..."));
await setNginxExecutable(userConfig);
userConfig = await loadUserConfig(); // Reload to ensure all config updates are reflected
}
console.log(chalk.yellow("NGINX executable not set. Attempting to set it..."));
if (await setNginxExecutable(userConfig)) {
userConfig = await loadOrCreateUserConfig(); // Reload to ensure all config updates are reflected
}else{
console.log(chalk.red('Failed to set NGINX executable.'));
return false;
}
}
const serverBlockVerified = await verifyServerBlock(userConfig);
if (!serverBlockVerified) {
console.log(chalk.yellow('NGINX server block is not correctly configured.'));
return false;
}
// Final check to verify NGINX installation
// Final check to verify NGINX installation
let nginxVerified = await verifyNginxInstallation(userConfig);
if (!nginxVerified) {

@@ -61,6 +60,4 @@ console.log(chalk.yellow('NGINX is not correctly installed or configured.'));

nginxVerified = await verifyNginxInstallation(userConfig); // Re-check after attempting to fix
if (!nginxVerified) {
console.log(chalk.red('NGINX installation or configuration still incorrect after attempted fixes.'));
// Consider providing additional help or exit the process
console.log(chalk.blue('Please check the manual configuration guidelines or contact support.'));

@@ -71,15 +68,16 @@ return false;

console.log(chalk.green('Starting NetGetX...'));
/* Verify NGINX server block is correctly configured for netgetX.
╔═╗╔═╗╦═╗╦ ╦╔═╗╦═╗ ╔╗ ╦ ╔═╗╔═╗╦╔═
╚═╗║╣ ╠╦╝╚╗╔╝║╣ ╠╦╝ ╠╩╗║ ║ ║║ ╠╩╗
╚═╝╚═╝╩╚═ ╚╝ ╚═╝╩╚═ ╚═╝╩═╝╚═╝╚═╝╩ ╩*/
const serverBlockVerified = await verifyServerBlock(userConfig);
if (!serverBlockVerified) {
console.log(chalk.yellow('NGINX server block is not correctly configured.'));
return false;
}
console.log(chalk.green.bold('All Checks Passed.'));
console.log(chalk.cyan.bold('Starting:'));
return true;
}
};
async function loadUserConfig() {
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 {};
}
}
import os from 'os';
import chalk from 'chalk';
import inquirer from 'inquirer';
import { exec } from 'child_process';
import { execShellCommand } from '../../utils/execShellCommand.js';
const checkForChoco = async () => {
const checkForChoco = () => {
return new Promise((resolve, reject) => {
exec('choco', (error, stdout, stderr) => {
if (error && stderr.includes('is not recognized as an internal or external command, operable program or batch file.')) {
if (stderr && stderr.includes('is not recognized')) {
resolve(false); // Chocolatey is not installed.

@@ -20,14 +20,10 @@ } else {

switch (os.platform()) {
case 'darwin':
return 'brew install nginx';
case 'linux':
return 'sudo apt-get install nginx -y';
case 'win32':
return 'choco install nginx';
default:
return null; // Unsupported OS
case 'darwin': return 'brew install nginx';
case 'linux': return 'sudo apt-get install nginx -y';
case 'win32': return 'choco install nginx';
default: return null; // Unsupported OS
}
};
export const installNginx = async (version) => {
const installNginx = async () => {
if (os.platform() === 'win32' && !await checkForChoco()) {

@@ -38,3 +34,3 @@ console.error(chalk.yellow('Chocolatey is not installed. Please install Chocolatey or install NGINX manually.'));

const installCmd = determineInstallCommand(version);
const installCmd = determineInstallCommand();
if (!installCmd) {

@@ -113,1 +109,3 @@ console.error(chalk.red('Unsupported operating system for automatic installation.'));

};
export default installNginx;
//nginxInstallationOptions.cli.js
import chalk from 'chalk';
import inquirer from 'inquirer';
import { installNginx } from './installNginx.js';
export async function nginxInstallationOptions() {
import installNginx from './installNginx.js';
export default async function nginxInstallationOptions() {
console.log("NGINX installation options are available. We recommend installing NGINX solely for NetGet and doing the configurations through the NetGet tools to avoid conflicts. If you want to use NGINX for other configurations and services please do so at your own risk and refer to both NGINX and NetGet manuals for help.");

@@ -7,0 +7,0 @@ const installConfirmation = await inquirer.prompt([

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

// serverBlockConfigOptions.cli.js
//netget/src/modules/NetGetX/config/serverBlockConfigOptions.cli.js
import inquirer from 'inquirer';
import chalk from 'chalk';
import { configureDefaultServerBlock } from './configureDefaultServerBlock.js';
import setDefaultServerBlock from './setDefaultServerBlock.js';

@@ -22,3 +22,3 @@ export const serverBlockConfigOptions = async (userConfig) => {

case 'Set/Restore NGINX to Default NetGetX Recommended Settings.':
await configureDefaultServerBlock(userConfig);
await setDefaultServerBlock(userConfig);
return true; // Configuration was successfully restored

@@ -25,0 +25,0 @@ case 'Proceed with Current Configuration':

@@ -1,2 +0,2 @@

//setNginxExecutable.js
//netget/src/modules/NetGetX/config/setNginxExecutable.js
import fs from 'fs';

@@ -6,10 +6,5 @@ import chalk from 'chalk';

import path from 'path';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import saveUserConfig from './saveUserConfig.js'; // Ensure this is imported
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const userConfigPath = path.join(__dirname, 'userConfig.json');
export async function setNginxExecutable(userConfig) {
export default async function setNginxExecutable(userConfig) {
if (!userConfig.nginxPath) {

@@ -19,3 +14,2 @@ console.log(chalk.yellow("NGINX configuration path is not set. Please configure it first."));

}
console.log(chalk.yellow("Checking for NGINX executable based on provided configuration path..."));

@@ -25,3 +19,2 @@ try {

let probableExecutablePath = path.join(path.dirname(userConfig.nginxPath), '../../sbin/nginx');
if (fs.existsSync(probableExecutablePath)) {

@@ -40,5 +33,7 @@ userConfig.nginxExecutable = probableExecutablePath;

await saveUserConfig(userConfig);
console.log(chalk.green(`NGINX executable path set to: ${userConfig.nginxExecutable}`));
return true;
await saveUserConfig({
nginxExecutable: userConfig.nginxExecutable
});
console.log(chalk.green(`NGINX executable path set to: ${userConfig.nginxExecutable}`));
return true;
} catch (error) {

@@ -50,11 +45,4 @@ console.error(chalk.red(`Error detecting NGINX executable: ${error.message}`));

async function saveUserConfig(userConfig) {
try {
await fs.promises.writeFile(userConfigPath, JSON.stringify(userConfig, null, 2), 'utf8');
console.log(chalk.green("User configuration nginx executable saved successfully."));
} catch (error) {
console.error(chalk.red(`Failed to save user configuration: ${error.message}`));
}
}

@@ -6,5 +6,4 @@ // verifyNginxInstallation.js

export async function verifyNginxInstallation(userConfig) {
console.log(chalk.blue('Verifying NGINX installation...'));
export default async function verifyNginxInstallation(userConfig) {
//console.log(chalk.blue('Verifying NGINX installation...'));
// Verify if all required paths are set and exist

@@ -15,3 +14,3 @@ if (!userConfig.nginxPath || !fs.existsSync(userConfig.nginxPath)) {

}else{
console.log(chalk.green('NGINX configuration path is set and exists.'));
console.log(`userConfig.nginxPath at: ${chalk.green(userConfig.nginxPath)} , Set and Exists: ${chalk.green("Verified.")}`);
}

@@ -23,3 +22,3 @@

}else{
console.log(chalk.green('NGINX sites-available path is set and exists.'));
console.log(`userConfig.nginxSitesAvailable at: ${chalk.green(userConfig.nginxSitesAvailable)} , Set and Exists: ${chalk.green("Verified.")}`);
}

@@ -31,3 +30,3 @@

}else{
console.log(chalk.green('NGINX sites-enabled path is set and exists.'));
console.log(`userConfig.nginxSitesEnabled at: ${chalk.green(userConfig.nginxSitesEnabled)} , Set and Exists: ${chalk.green("Verified.")}`);
}

@@ -40,3 +39,3 @@

}else{
console.log(chalk.green('NGINX executable path is set and exists.'));
console.log(`userConfig.nginxExecutable at: ${chalk.green(userConfig.nginxExecutable)} , Set and Exists: ${chalk.green("Verified.")}`);
}

@@ -47,4 +46,3 @@

const output = execSync(nginxVersionCommand).toString();
console.log(chalk.green('NGINX executable is operational.'));
console.log(chalk.blue(`NGINX version: ${output}`)); // Now this should correctly log the output
console.log(`NGINX Executable is Operational: ${chalk.blue(output)}`);
} catch (error) {

@@ -55,5 +53,4 @@ console.log(chalk.red(`Failed to execute NGINX: ${error.message}`));

console.log(chalk.green('All NGINX configurations and executable are correct and operational.'));
return true;
}

@@ -7,12 +7,10 @@ // netget/src/modules/NetGetX/config/verifyServerBlock.js

export const verifyServerBlock = async (userConfig) => {
console.log(chalk.blue('Verifying NGINX server block...'));
const verifyServerBlock = async (userConfig) => {
//console.log(chalk.blue('Verifying NGINX server block...'));
const nginxConfigPath = userConfig.nginxPath; // Path to nginx.conf
const expectedServerBlock = getDefaultServerBlock(userConfig); // Get the dynamic server block
try {
const configData = fs.readFileSync(nginxConfigPath, 'utf8');
if (configData.includes(expectedServerBlock.trim())) {
console.log(chalk.green('Default NGINX server block is correctly configured.'));
console.log(chalk.green('Default Server Block is correctly configured.'));
return true;

@@ -33,5 +31,6 @@ } else {

console.log(chalk.yellow('Please clean your userConfig.json values and try again...'));
return false;
}
};
export default verifyServerBlock;

@@ -6,6 +6,6 @@ // NetGetX.cli.js

import { handleAddNewXBlock } from './src/handleAddNewXBlock.js';
import { NetGetMainMenu } from '../netget_MainMenu.cli.js';
import {nginxMenu } from './NGINX/nginx_menu.cli.js';
import NetGetMainMenu from '../netget_MainMenu.cli.js';
import { nginxMenu } from './NGINX/nginx_menu.cli.js';
//import { showNGXBlocks, addNewNGXBlock, showNGXDiscoveryNode, addNewNGXDiscoveryNode, netGetXSettings, aboutNetGetX } from './netGetXOptions.js';
export async function NetGetX() {
export default async function NetGetX_CLI() {
const answers = await inquirer.prompt({

@@ -12,0 +12,0 @@ type: 'list',

@@ -7,3 +7,3 @@ // nginx_menu.cli.js

import { checkNginxStatus } from './checkNginxStatus.js';
import { NetGetX } from '../NetGetX.cli.js';
import NetGetX_CLI from '../NetGetX.cli.js';

@@ -39,3 +39,3 @@ export async function nginxMenu() {

case 'Back to NetGetX Menu':
await NetGetX();
await NetGetX_CLI();
return; // Exit to prevent loop

@@ -42,0 +42,0 @@ }

@@ -5,6 +5,5 @@ // netGetXOptions.js

import path from 'path';
import NetGetX_CLI from '../NetGetX.cli.js';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import { NetGetX} from '../NetGetX.cli.js';
const __filename = fileURLToPath(import.meta.url);

@@ -30,3 +29,3 @@ const __dirname = dirname(__filename);

console.log(chalk.yellow('No NGXBlocks Found.'));
await NetGetX(); // Return to main menu after showing this message
await NetGetX_CLI(); // Return to main menu after showing this message
} else {

@@ -37,5 +36,5 @@ console.log(chalk.green('List of NGXBlocks:'));

});
await NetGetX(); // Also return to the main menu after listing blocks
await NetGetX_CLI(); // Also return to the main menu after listing blocks
}
}
#!/usr/bin/env node
import { program } from 'commander';
import { NetGetX } from './modules/NetGetX/NetGetX.cli.js';
import { getDir } from './scripts/setupConfig.js';
import NetGetX_CLI from './modules/NetGetX/NetGetX.cli.js';
import { handleGateways } from './modules/Gateways/Gateways.js';
import { handleGets } from './modules/Gets/Gets.js';
import { NetGetMainMenu } from './modules/netget_MainMenu.cli.js';
import NetGetMainMenu from './modules/netget_MainMenu.cli.js';
// Directory check and setup if necessary
getDir();
// Entry Points Options and Commands
program

@@ -15,3 +19,3 @@ .description('NetGet Command Line Interface')

.description('Directly interact with NetGetX')
.action(NetGetX);
.action(NetGetX_CLI);

@@ -18,0 +22,0 @@ program.command('gateways')

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