Comparing version 2.3.55 to 2.3.56
{ | ||
"name": "netget", | ||
"version": "2.3.55", | ||
"version": "2.3.56", | ||
"description": "Rette Adepto/ Recibido Directamente.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -1,45 +0,71 @@ | ||
//i_DefaultNetGetX.js | ||
// i_DefaultNetGetX.js | ||
import chalk from 'chalk'; | ||
import { verifyNginxInstallation } from './verifyNginxInstallation.js'; | ||
import { nginxInstallationOptions } from './nginxInstallationOptions.cli.js'; | ||
import { verifyServerBlock } from './verifyServerBlock.js'; | ||
import checkPublicIP from '../../utils/checkPublicIP.js'; | ||
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'; | ||
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 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 | ||
} | ||
console.log(chalk.blue('Running Environment Check...')); | ||
// 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.')); | ||
} | ||
// 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(); | ||
let nginxVerified = await verifyNginxInstallation(userConfig.nginxPath); | ||
if (!nginxVerified) { | ||
console.log(chalk.yellow('NGINX is not correctly installed or configured.')); | ||
await nginxInstallationOptions(); | ||
// Recheck after installation options might have changed the state | ||
nginxVerified = await verifyNginxInstallation(); | ||
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 | ||
if (!nginxVerified) { | ||
console.log(chalk.red('NGINX installation or configuration still incorrect after attempted fixes.')); | ||
return false; // Exit after rechecking and still failing | ||
return false; | ||
} | ||
} | ||
console.log(chalk.blue('Verifying NGINX server block...')); | ||
console.log(chalk.green('NGINX installation and configuration are correct.')); | ||
// Proceed to verify the NGINX server block configuration | ||
const serverBlockVerified = await verifyServerBlock(); | ||
if (!serverBlockVerified) { | ||
console.log(chalk.yellow('NGINX server block is not correctly configured.')); | ||
return false; // Exit if server block cannot be verified or fixed | ||
return false; | ||
} | ||
console.log(chalk.green('All configurations are correct.')); | ||
// Proceed to main functionality | ||
return true; | ||
} | ||
} |
//nginxInstallationOptions.cli.js | ||
import inquirer from 'inquirer'; | ||
import { installNginx } from './installNginx.js'; | ||
import { nxConfigMenu } from './nx_install_Options.cli.js'; | ||
export async function nginxInstallationOptions() { | ||
@@ -6,0 +5,0 @@ 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."); |
@@ -0,1 +1,2 @@ | ||
// setNginxPath.js | ||
import fs from 'fs'; | ||
@@ -8,2 +9,3 @@ import chalk from 'chalk'; | ||
import { fileURLToPath } from 'url'; | ||
import { nginxInstallationOptions } from './nginxInstallationOptions.cli.js'; | ||
@@ -29,3 +31,2 @@ const __filename = fileURLToPath(import.meta.url); | ||
async function detectNginxPath() { | ||
// Determine the operating system to suggest more accurate default paths | ||
const osType = os.type(); | ||
@@ -36,4 +37,4 @@ let potentialPaths = []; | ||
potentialPaths.push('/etc/nginx/nginx.conf'); | ||
} else if (osType === 'Darwin') { // macOS | ||
potentialPaths.push('/usr/local/etc/nginx/nginx.conf', '/opt/homebrew/etc/nginx/nginx.conf'); // Paths for Homebrew installs | ||
} else if (osType === 'Darwin') { | ||
potentialPaths.push('/usr/local/etc/nginx/nginx.conf', '/opt/homebrew/etc/nginx/nginx.conf'); | ||
} else if (osType === 'Windows_NT') { | ||
@@ -43,5 +44,5 @@ potentialPaths.push('C:\\nginx\\nginx.conf'); | ||
for (const potentialPath of potentialPaths) { | ||
if (fs.existsSync(potentialPath)) { | ||
return potentialPath; | ||
for (const path of potentialPaths) { | ||
if (fs.existsSync(path)) { | ||
return path; | ||
} | ||
@@ -54,11 +55,4 @@ } | ||
const detectedPath = await detectNginxPath(); | ||
let finalPath = detectedPath; | ||
if (!detectedPath) { | ||
console.log(chalk.yellow('Unable to automatically detect the NGINX configuration path.')); | ||
// Provide guidance based on OS if automatic detection fails | ||
console.log(chalk.blue(`Please specify the path manually. Typical locations include:`)); | ||
console.log(chalk.blue(`- Linux: /etc/nginx/nginx.conf`)); | ||
console.log(chalk.blue(`- macOS: /usr/local/etc/nginx/nginx.conf or /opt/homebrew/etc/nginx/nginx.conf`)); | ||
console.log(chalk.blue(`- Windows: C:\\nginx\\nginx.conf`)); | ||
} | ||
@@ -76,27 +70,43 @@ | ||
type: 'input', | ||
name: 'customPath', | ||
message: 'Please enter the custom path for your NGINX configuration:', | ||
name: 'manualPath', | ||
message: 'Enter the custom path for your NGINX configuration:', | ||
when: ({ confirm }) => !confirm | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'action', | ||
message: 'No valid NGINX path found. What would you like to do?', | ||
choices: [ | ||
'Enter Path Manually', | ||
'Install NGINX', | ||
'Cancel' | ||
], | ||
when: () => !detectedPath | ||
} | ||
]); | ||
if (responses.customPath) { | ||
finalPath = responses.customPath; | ||
let finalPath = responses.manualPath || detectedPath; | ||
if (responses.action === 'Install NGINX') { | ||
await nginxInstallationOptions(); | ||
return; | ||
} else if (responses.action === 'Enter Path Manually') { | ||
finalPath = await inquirer.prompt({ | ||
type: 'input', | ||
name: 'manualPath', | ||
message: 'Please enter the custom path for your NGINX configuration:' | ||
}).then(response => response.manualPath); | ||
} | ||
// Verify the final path | ||
if (!fs.existsSync(finalPath)) { | ||
console.log(chalk.red('The specified NGINX configuration path does not exist.')); | ||
if (finalPath && fs.existsSync(finalPath)) { | ||
console.log(chalk.green(`NGINX configuration path set to: ${finalPath}`)); | ||
const userConfig = await loadUserConfig(); | ||
userConfig.nginxPath = finalPath; | ||
await saveUserConfig(userConfig); | ||
return finalPath; | ||
} else { | ||
console.log(chalk.red('No valid NGINX path provided or found.')); | ||
return ''; | ||
} | ||
// Save the verified path to user config | ||
const userConfig = await loadUserConfig(); | ||
userConfig.nginxPath = finalPath; | ||
await saveUserConfig(userConfig); | ||
console.log(chalk.green(`NGINX configuration path set to: ${finalPath}`)); | ||
return finalPath; | ||
} | ||
export { setNginxPath }; |
{ | ||
"nginxConfigurationProceed": false, | ||
"netgetXConfigurationProceed": false, | ||
"nginxPath": "/opt/homebrew/etc/nginx/nginx.conf" | ||
} |
// verifyNginxInstallation.js | ||
// verifyNginxInstallation.js | ||
import chalk from 'chalk'; | ||
import { execShellCommand } from '../../utils/execShellCommand.js'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
export const verifyNginxInstallation = async () => { | ||
export const verifyNginxInstallation = async (nginxPath) => { | ||
if (!nginxPath || !fs.existsSync(nginxPath)) { | ||
console.error(chalk.red(`NGINX configuration path not set or does not exist: ${nginxPath}`)); | ||
return false; | ||
} | ||
try { | ||
const result = await execShellCommand('nginx -v'); | ||
console.log(chalk.green(`NGINX successfully verified...`)); | ||
return true; // Call the callback function with true indicating success | ||
// Attempt to execute NGINX command using the full path | ||
const result = await execShellCommand(`${nginxPath} -v`); | ||
console.log(chalk.green(`NGINX successfully verified at ${nginxPath}`)); | ||
return true; | ||
} catch (error) { | ||
console.error(chalk.red(`Verification of NGINX installation failed: ${error.message}`)); | ||
return false; // Call the callback function with false indicating failure | ||
console.error(chalk.red(`Verification of NGINX installation failed at ${nginxPath}: ${error.message}`)); | ||
return false; | ||
} | ||
}; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
895
3
861025
44
12