Comparing version 2.3.7 to 2.3.8
{ | ||
"name": "netget", | ||
"version": "2.3.7", | ||
"version": "2.3.8", | ||
"description": "Rette Adepto/ Recibido Directamente.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -8,2 +8,4 @@ // netget_MainMenu.js | ||
import { handleGets } from './Gets/Gets.js'; | ||
import pkg from '../../package.json' assert { type: 'json' }; | ||
console.log(` | ||
@@ -15,3 +17,3 @@ Welcome to: | ||
`); | ||
console.log(`v${pkg.version}...`); // Logs the current version of the application | ||
export async function NetGetMainMenu() { | ||
@@ -29,3 +31,3 @@ /* | ||
name: 'action', | ||
message: 'Choose an action:', | ||
message: 'Main Menu:', | ||
choices: ['NetGetX', 'Gateways', 'Gets', new inquirer.Separator(), 'Exit'], | ||
@@ -37,7 +39,6 @@ }, | ||
case 'NetGetX': | ||
console.log(chalk.blue('Initializing NetGetX v0.0.0...')); | ||
console.log(chalk.cyan.bold('Initializing NetGetX v0.0.23...')); | ||
try { | ||
const setupVerified = await i_DefaultNetGetX(); | ||
if (setupVerified) { | ||
console.log(chalk.green('Setup verification successful.')); | ||
console.log(` | ||
@@ -44,0 +45,0 @@ ██╗ ██╗ |
@@ -1,41 +0,34 @@ | ||
//configureDefaultServerBlock.js | ||
// configureDefaultServerBlock.js | ||
import fs from 'fs'; | ||
import chalk from 'chalk'; | ||
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import { dirname } from 'path'; | ||
import defaultServerBlock from './defaultServerBlock.js'; | ||
import sudo from 'sudo-prompt'; | ||
import { execShellCommand } from '../../utils/execShellCommand.js'; | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
const userConfigPath = path.join(__dirname, 'userConfig.json'); | ||
async function loadUserConfig() { | ||
export const configureDefaultServerBlock = async (userConfig) => { | ||
try { | ||
const data = await fs.promises.readFile(userConfigPath, 'utf8'); | ||
return JSON.parse(data); | ||
// 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}.`)); | ||
} catch (error) { | ||
console.error(chalk.red(`Failed to load user configuration: ${error.message}`)); | ||
return {}; | ||
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 defaultConfigContent = `server { | ||
listen 80 default_server; | ||
server_name _; | ||
root /var/www/html; | ||
location / { | ||
return 200 'NGINX Default Response. Server is running.'; | ||
} | ||
}`; | ||
export const configureDefaultServerBlock = async () => { | ||
const userConfig = await loadUserConfig(); | ||
const nginxPath = userConfig.nginxPath || '/etc/nginx/sites-available/default'; // Fallback to default if not set | ||
try { | ||
fs.writeFileSync(nginxPath, defaultConfigContent); | ||
console.log(chalk.green('NGINX default server block has been configured to match NetGetX requirements.')); | ||
} catch (error) { | ||
console.error(chalk.red(`Failed to write NGINX default server block config at ${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.')); | ||
}); | ||
}; |
//i_DefaultNetGetX.js | ||
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'; | ||
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 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(); | ||
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}`); | ||
if (!nginxVerified) { | ||
console.log(chalk.yellow('NGINX is not correctly installed or configured.')); | ||
await nginxInstallationOptions(); | ||
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.blue('Verifying NGINX Paths...')); | ||
let userConfig = await loadUserConfig(); | ||
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.')); | ||
} | ||
// 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; // Exit after rechecking and still failing | ||
} | ||
// 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.blue('Verifying NGINX server block...')); | ||
const serverBlockVerified = await verifyServerBlock(); | ||
const serverBlockVerified = await verifyServerBlock(userConfig); | ||
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; | ||
} | ||
// Final check to verify NGINX installation | ||
let nginxVerified = await verifyNginxInstallation(userConfig); | ||
if (!nginxVerified) { | ||
console.log(chalk.yellow('NGINX is not correctly installed or configured.')); | ||
console.log(chalk.yellow('Attempting automated configuration options...')); | ||
await nginxInstallationOptions(); | ||
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.')); | ||
return false; | ||
} | ||
} | ||
console.log(chalk.green('Starting NetGetX...')); | ||
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 {}; | ||
} | ||
} | ||
@@ -5,3 +5,2 @@ import os from 'os'; | ||
import { execShellCommand } from '../../utils/execShellCommand.js'; | ||
import { verifyNginxInstallation } from './verifyNginxInstallation.js'; | ||
@@ -46,4 +45,4 @@ const checkForChoco = async () => { | ||
await execShellCommand(installCmd); | ||
const isNginxVerified = await verifyNginxInstallation(); | ||
console.log(isNginxVerified ? chalk.green('NGINX is installed and verified successfully.') : chalk.yellow('NGINX is installed but could not be verified.')); | ||
console.log("NGINX installation complete."); | ||
return true; | ||
} catch (error) { | ||
@@ -50,0 +49,0 @@ console.error(chalk.red(`${error.message}`)); |
//nginxInstallationOptions.cli.js | ||
import chalk from 'chalk'; | ||
import inquirer from 'inquirer'; | ||
@@ -32,4 +33,4 @@ import { installNginx } from './installNginx.js'; | ||
case 'Custom version': | ||
await installNginx(installConfirmation.version, installConfirmation.customVersion); | ||
break; | ||
const installationResult = await installNginx(installConfirmation.version, installConfirmation.customVersion); | ||
return installationResult; // Return the result of the installation | ||
case 'Back to previous menu': | ||
@@ -36,0 +37,0 @@ await nxConfigMenu(); // Call the main configuration menu again |
@@ -0,1 +1,2 @@ | ||
// serverBlockConfigOptions.cli.js | ||
import inquirer from 'inquirer'; | ||
@@ -5,3 +6,3 @@ import chalk from 'chalk'; | ||
export const serverBlockConfigOptions = async () => { | ||
export const serverBlockConfigOptions = async (userConfig) => { | ||
const answers = await inquirer.prompt([ | ||
@@ -22,12 +23,12 @@ { | ||
case 'Restore NGINX Default to Recommended Settings': | ||
await configureDefaultServerBlock(); | ||
break; | ||
await configureDefaultServerBlock(userConfig); | ||
return true; // Configuration was successfully restored | ||
case 'Proceed with Current Configuration': | ||
console.log(chalk.yellow('Proceeding with existing NGINX configuration.')); | ||
break; | ||
return true; // Proceeding with existing configuration is considered successful | ||
case 'Exit and Adjust Manually': | ||
console.log(chalk.green('Please adjust your NGINX configuration manually as needed.')); | ||
process.exit(0); | ||
break; | ||
return false; // Exiting for manual adjustment is considered unsuccessful | ||
} | ||
}; |
@@ -1,2 +0,1 @@ | ||
// setNginxPath.js | ||
import fs from 'fs'; | ||
@@ -6,5 +5,5 @@ import chalk from 'chalk'; | ||
import path from 'path'; | ||
import os from 'os'; | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import detectNginxPaths from './detectNginxPath.js'; // Ensure the function is correctly imported | ||
import { nginxInstallationOptions } from './nginxInstallationOptions.cli.js'; | ||
@@ -30,28 +29,20 @@ | ||
async function detectNginxPath() { | ||
const osType = os.type(); | ||
let potentialPaths = []; | ||
if (osType === 'Linux') { | ||
potentialPaths.push('/etc/nginx/nginx.conf'); | ||
} else if (osType === 'Darwin') { | ||
potentialPaths.push('/usr/local/etc/nginx/nginx.conf', '/opt/homebrew/etc/nginx/nginx.conf'); | ||
} else if (osType === 'Windows_NT') { | ||
potentialPaths.push('C:\\nginx\\nginx.conf'); | ||
} | ||
for (const path of potentialPaths) { | ||
if (fs.existsSync(path)) { | ||
return path; | ||
async function setNginxPath() { | ||
let detectedPaths = await detectNginxPaths(); | ||
if (!detectedPaths) { | ||
console.log(chalk.yellow('Unable to automatically detect NGINX paths. Attempting installation...')); | ||
const installationSuccess = await nginxInstallationOptions(); | ||
if (installationSuccess) { | ||
detectedPaths = await detectNginxPaths(); // Retry detection after installation | ||
if (!detectedPaths) { | ||
console.log(chalk.red('Failed to detect NGINX paths even after installation.')); | ||
return; // Stop further execution if still unable to detect | ||
} | ||
} else { | ||
console.log(chalk.red('Installation or configuration aborted.')); | ||
return; // Stop further execution if installation was not successful | ||
} | ||
} | ||
return ''; | ||
} | ||
async function setNginxPath() { | ||
const detectedPath = await detectNginxPath(); | ||
if (!detectedPath) { | ||
console.log(chalk.yellow('Unable to automatically detect the NGINX configuration path.')); | ||
} | ||
const userConfig = await loadUserConfig(); | ||
const responses = await inquirer.prompt([ | ||
@@ -61,5 +52,4 @@ { | ||
name: 'confirm', | ||
message: `Use the detected path: ${detectedPath}?`, | ||
default: true, | ||
when: () => !!detectedPath | ||
message: `Detected NGINX configuration path: ${detectedPaths.nginxPath}. Use this path?`, | ||
default: true | ||
}, | ||
@@ -71,37 +61,31 @@ { | ||
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 | ||
} | ||
]); | ||
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); | ||
} | ||
let finalPath = responses.manualPath || detectedPaths.nginxPath; | ||
if (finalPath && fs.existsSync(finalPath)) { | ||
console.log(chalk.green(`NGINX configuration path set to: ${finalPath}`)); | ||
const userConfig = await loadUserConfig(); | ||
userConfig.nginxPath = finalPath; | ||
userConfig.nginxExecutable = detectedPaths.nginxExecutable; | ||
// Set up sites-available and sites-enabled | ||
const baseDir = path.dirname(finalPath); | ||
userConfig.nginxSitesAvailable = path.join(baseDir, 'sites-available'); | ||
userConfig.nginxSitesEnabled = path.join(baseDir, 'sites-enabled'); | ||
// Ensure directories exist | ||
if (!fs.existsSync(userConfig.nginxSitesAvailable)) { | ||
fs.mkdirSync(userConfig.nginxSitesAvailable); | ||
console.log(chalk.green(`Created directory at ${userConfig.nginxSitesAvailable}`)); | ||
} | ||
if (!fs.existsSync(userConfig.nginxSitesEnabled)) { | ||
fs.mkdirSync(userConfig.nginxSitesEnabled); | ||
console.log(chalk.green(`Created directory at ${userConfig.nginxSitesEnabled}`)); | ||
} | ||
await saveUserConfig(userConfig); | ||
return finalPath; | ||
} else { | ||
console.log(chalk.red('No valid NGINX path provided or found.')); | ||
return ''; | ||
// If NGINX path is not found, offer to install NGINX | ||
await nginxInstallationOptions(); | ||
} | ||
@@ -108,0 +92,0 @@ } |
{ | ||
"nginxConfigurationProceed": false, | ||
"nginxPath": "/opt/homebrew/etc/nginx/nginx.conf", | ||
"useSudo": false | ||
"nginxPath": "", | ||
"nginxSitesAvailable": "", | ||
"nginxSitesEnabled": "", | ||
"useSudo": false, | ||
"nginxExecutable": "" | ||
} |
// verifyNginxInstallation.js | ||
import fs from 'fs'; | ||
import chalk from 'chalk'; | ||
import { execShellCommand } from '../../utils/execShellCommand.js'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
import { execSync } from 'child_process'; | ||
// 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 async function verifyNginxInstallation(userConfig) { | ||
console.log(chalk.blue('Verifying NGINX installation...')); | ||
// Verify if all required paths are set and exist | ||
if (!userConfig.nginxPath || !fs.existsSync(userConfig.nginxPath)) { | ||
console.log(chalk.red('NGINX configuration path is not set or does not exist.')); | ||
return false; | ||
}else{ | ||
console.log(chalk.green('NGINX configuration path is set and exists.')); | ||
} | ||
} | ||
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); | ||
} | ||
if (!userConfig.nginxSitesAvailable || !fs.existsSync(userConfig.nginxSitesAvailable)) { | ||
console.log(chalk.red('NGINX sites-available path is not set or does not exist.')); | ||
return false; | ||
}else{ | ||
console.log(chalk.green('NGINX sites-available path is set and exists.')); | ||
} | ||
}; | ||
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)); | ||
if (!userConfig.nginxSitesEnabled || !fs.existsSync(userConfig.nginxSitesEnabled)) { | ||
console.log(chalk.red('NGINX sites-enabled path is not set or does not exist.')); | ||
return false; | ||
}else{ | ||
console.log(chalk.green('NGINX sites-enabled path is set and exists.')); | ||
} | ||
// Retry command with sudo | ||
// Verify if NGINX executable can be run to check its version | ||
if (!userConfig.nginxExecutable || !fs.existsSync(userConfig.nginxExecutable)) { | ||
console.log(chalk.red('NGINX executable path is not set or does not exist.')); | ||
return false; | ||
}else{ | ||
console.log(chalk.green('NGINX executable path is set and exists.')); | ||
} | ||
try { | ||
const result = await execShellCommand('sudo nginx -v'); | ||
console.log(chalk.green(`NGINX successfully verified with sudo: ${result}`)); | ||
return true; | ||
const nginxVersionCommand = `${userConfig.nginxExecutable} -v 2>&1`; // Redirect stderr to stdout | ||
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 | ||
} catch (error) { | ||
console.error(chalk.red(`Failed to verify NGINX installation with sudo: ${error.message}`)); | ||
console.log(chalk.red(`Failed to execute NGINX: ${error.message}`)); | ||
return false; | ||
} | ||
console.log(chalk.green('All NGINX configurations and executable are correct and operational.')); | ||
return true; | ||
} | ||
@@ -1,79 +0,32 @@ | ||
//verifyServerBlock.js | ||
// verifyServerBlock.js | ||
import fs from 'fs'; | ||
import chalk from 'chalk'; | ||
import inquirer from 'inquirer'; | ||
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import { dirname } from 'path'; | ||
import { configureDefaultServerBlock } from './configureDefaultServerBlock.js'; | ||
import { setNginxPath } from './setNginxPath.js'; | ||
import defaultServerBlock from './defaultServerBlock.js'; // This contains the expected default server block configuration | ||
import { serverBlockConfigOptions } from './serverBlockConfigOptions.cli.js'; | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
const userConfigPath = path.join(__dirname, 'userConfig.json'); | ||
export const verifyServerBlock = async (userConfig) => { | ||
console.log(chalk.blue('Verifying NGINX server block...')); | ||
async function loadUserConfig() { | ||
const nginxConfigPath = userConfig.nginxPath; // Path to nginx.conf | ||
try { | ||
const data = await fs.promises.readFile(userConfigPath, { encoding: 'utf8' }); | ||
return JSON.parse(data); | ||
} catch (error) { | ||
console.error(chalk.red(`Failed to load user configuration: ${error.message}`)); | ||
return { nginxConfigurationProceed: false, nginxPath: '' }; | ||
} | ||
} | ||
async function saveUserConfig(userConfig) { | ||
await fs.promises.writeFile(userConfigPath, JSON.stringify(userConfig, null, 2), { encoding: 'utf8' }); | ||
} | ||
async function verifyServerBlock() { | ||
console.log(chalk.blue('Running verifyServerBlock...')); | ||
let userConfig = await loadUserConfig(); | ||
if (!userConfig.nginxPath) { | ||
await setNginxPath(); | ||
userConfig = await loadUserConfig(); // Reload config after setting path | ||
} | ||
if (userConfig.nginxPath) { | ||
try { | ||
const defaultConfigData = await fs.promises.readFile(userConfig.nginxPath, 'utf8'); | ||
if (!defaultConfigData.includes("return 200 'NGINX Default Response. Server is running.';")) { | ||
console.log(chalk.yellow('Default server block configuration does not match the expected setup. Visit Default Server Block Configuration.')); | ||
if (!userConfig.nginxConfigurationProceed) { | ||
const action = await askUserForAction('NGINX'); | ||
if (action === 'restore') { | ||
await configureDefaultServerBlock(); | ||
//userConfig.nginxConfigurationProceed = true; | ||
//await saveUserConfig(userConfig); | ||
} else if (action === 'proceed') { | ||
userConfig.nginxConfigurationProceed = true; | ||
await saveUserConfig(userConfig); | ||
} | ||
} | ||
return false; | ||
const configData = fs.readFileSync(nginxConfigPath, 'utf8'); | ||
if (configData.includes(defaultServerBlock.trim())) { | ||
console.log(chalk.green('Default NGINX server block is correctly configured.')); | ||
return true; | ||
} else { | ||
console.log(chalk.yellow('Default NGINX server block does not match the expected setup.')); | ||
if (userConfig.nginxConfigurationProceed) { | ||
console.log(chalk.green('Proceeding with existing configuration as per user preference.')); | ||
return true; | ||
} else { | ||
// Prompt the user for action and determine outcome based on their choice | ||
const configurationSuccess = await serverBlockConfigOptions(userConfig); | ||
return configurationSuccess; | ||
} | ||
console.log(chalk.green('NGINX server block is configured correctly.')); | ||
return true; | ||
} catch (error) { | ||
console.error(chalk.red(`Error reading NGINX config: ${error.message}`)); | ||
return false; | ||
} | ||
} catch (error) { | ||
console.error(chalk.red(`Failed to read NGINX configuration from ${nginxConfigPath}: ${error.message}`)); | ||
return false; | ||
} | ||
return false; | ||
} | ||
async function askUserForAction(type) { | ||
const response = await inquirer.prompt([{ | ||
type: 'list', | ||
name: 'action', | ||
message: `How would you like to proceed with the ${type} server block configuration?`, | ||
choices: [ | ||
{ name: 'Set/Restore to Recommended Default Settings', value: 'restore' }, | ||
{ name: 'Proceed with current configuration', value: 'proceed' } | ||
] | ||
}]); | ||
return response.action; | ||
} | ||
export { verifyServerBlock }; | ||
}; |
@@ -5,3 +5,4 @@ // NetGetX.cli.js | ||
import chalk from 'chalk'; | ||
//import { addNewNGXBlock } from './src/addNewNGXBlock.js'; | ||
import { handleAddNewXBlock } from './src/handleAddNewXBlock.js'; | ||
import { NetGetMainMenu } from '../netget_MainMenu.cli.js'; | ||
//import { showNGXBlocks, addNewNGXBlock, showNGXDiscoveryNode, addNewNGXDiscoveryNode, netGetXSettings, aboutNetGetX } from './netGetXOptions.js'; | ||
@@ -14,8 +15,9 @@ export async function NetGetX() { | ||
choices: [ | ||
'Show NGXBlocks', | ||
'Add New NGXBlock', | ||
'Show NGXDiscoveryNodes', | ||
'Add New NGXDiscoveryNode', | ||
'Show XBlocks', | ||
'Add New XBlock', | ||
'Show X Discovery Nodes', | ||
'Add New X Discovery Node', | ||
'NetGetX Settings', | ||
'About NetGetX', | ||
'Main Menu', | ||
'Exit' | ||
@@ -26,10 +28,14 @@ ] | ||
switch (answers.option) { | ||
case 'Show NGXBlocks': | ||
case 'Show XBlocks': | ||
await showXBlocks(); | ||
console.log('Show NGXBlocks'); | ||
console.log('Show XBlocks'); | ||
break; | ||
case 'Add New XBlock': | ||
// await addNewNGXBlock(); | ||
console.log('Add New XBlock'); | ||
await handleAddNewXBlock(); | ||
console.log('Add New XBlock'); | ||
break; | ||
case 'Main Menu': | ||
console.log(chalk.blue('Returning to the main menu...')); | ||
await NetGetMainMenu(); | ||
break; | ||
// Continue handling other cases similarly | ||
@@ -40,5 +46,5 @@ case 'Exit': | ||
default: | ||
await NetGetXMenu(); // Recurse back to the menu unless exiting | ||
await NetGetX(); // Recurse back to the menu unless exiting | ||
break; | ||
} | ||
} |
@@ -9,3 +9,2 @@ import fetch from 'node-fetch'; | ||
const publicIP = data.ip; | ||
console.log(`Current public IP: ${publicIP}`); | ||
return publicIP; | ||
@@ -12,0 +11,0 @@ } else { |
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
870687
49
1095
15
6