Comparing version 2.4.35 to 2.4.36
{ | ||
"name": "netget", | ||
"version": "2.4.35", | ||
"version": "2.4.36", | ||
"description": "Rette Adepto/ Recibido Directamente.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -17,15 +17,8 @@ // netget_MainMenu.js | ||
export default async function NetGetMainMenu() { | ||
/* | ||
╔╗╔┌─┐┌┬┐╔═╗┌─┐┌┬┐ | ||
║║║├┤ │ ║ ╦├┤ │ | ||
╝╚╝└─┘ ┴ ╚═╝└─┘ ┴ | ||
*/ | ||
const answers = await inquirer.prompt([ | ||
{ | ||
type: 'list', | ||
name: 'action', | ||
message: 'Main Menu:', | ||
choices: ['NetGetX', 'Gateways', 'Gets', new inquirer.Separator(), 'Exit'], | ||
{ | ||
type: 'list', | ||
name: 'action', | ||
message: 'Main Menu:', | ||
choices: ['NetGetX', 'Gateways', 'Gets', new inquirer.Separator(), 'Exit'], | ||
}, | ||
@@ -36,25 +29,17 @@ ]); | ||
case 'NetGetX': | ||
try { | ||
const x = await i_DefaultNetGetX(); | ||
if (x) { | ||
console.log(` | ||
██╗ ██╗ .nginxPath at: ${chalk.green(x.nginxPath)} | ||
╚██╗██╔╝ .nginxSitesAvailable at: ${chalk.green(x.nginxsitesAvailable)} | ||
╚███╔╝ .nginxSitesEnabled at: ${chalk.green(x.nginxSitesEnabled)} | ||
██╔██╗ .nginxExecutable at: ${chalk.green(x.nginxExecutable)} | ||
██╔╝ ██╗ .publicIP: ${chalk.green(x.publicIP)} | ||
╚═╝ ╚═╝ .localIP: ${chalk.green(x.localIP)} | ||
... | ||
...`); | ||
await NetGetX_CLI(); // Proceed to the interactive menu if setup is verified | ||
} else { | ||
console.log(chalk.red('Setup verification failed. Please resolve any issues before proceeding.')); | ||
// Optionally, return to the main menu or provide options to retry | ||
return false; | ||
} | ||
} catch (error) { | ||
console.log(chalk.red(`An error occurred during setup verification: ${error.message}`)); | ||
// Error handling or further actions can be defined here | ||
} | ||
break; | ||
const x = await i_DefaultNetGetX(); // Load production configuration | ||
if (x) { | ||
console.log(` | ||
██╗ ██╗ .nginxPath at: ${chalk.green(x.nginxPath)} | ||
╚██╗██╔╝ .XBlocksAvailable at: ${chalk.green(x.XBlocksAvailable)} | ||
╚███╔╝ .XBlocksEnabled at: ${chalk.green(x.XBlocksEnabled)} | ||
██╔██╗ .netgetXExecutable at: ${chalk.green(x.nginxExecutable)} | ||
██╔╝ ██╗ .publicIP: ${chalk.green(x.publicIP)} | ||
╚═╝ ╚═╝ .localIP: ${chalk.green(x.localIP)} | ||
`); | ||
await NetGetX_CLI(); // Pass the development flag to the CLI | ||
} else { | ||
console.log(chalk.red('Setup verification failed. Please resolve any issues before proceeding.')); | ||
} | ||
break; | ||
case 'Gateways': | ||
@@ -72,3 +57,2 @@ console.log(chalk.yellow('Selected Gateways')); | ||
} | ||
} | ||
} |
@@ -1,17 +0,37 @@ | ||
// defaultServerBlock.js | ||
const getDefaultServerBlock = (userConfig) => ` | ||
const getDefaultServerBlock = (xConfig) => { | ||
if (!xConfig) { | ||
throw new Error("User configuration must be provided."); | ||
} | ||
const { XBlocksAvailable, XBlocksEnabled, getPath } = xConfig; | ||
if (!XBlocksAvailable || !XBlocksEnabled || !getPath) { | ||
throw new Error("Invalid user configuration. Missing required paths."); | ||
} | ||
return ` | ||
events { | ||
worker_connections 1024; | ||
worker_connections 1024; # High performance tweak | ||
} | ||
http { | ||
include ${userConfig.nginxSitesAvailable}/*.conf; | ||
include ${userConfig.nginxSitesEnabled}/*; | ||
# Include statements for additional NetGetX server configurations | ||
include ${XBlocksAvailable}/*.conf; | ||
include ${XBlocksEnabled}/*; | ||
# Default server configuration | ||
server { | ||
listen 80 default_server; # Listen only on HTTP | ||
server { | ||
listen 80 default_server; | ||
server_name _; | ||
root /var/www/html; | ||
server_name _; # Catch-all for server names not matched by other server blocks | ||
# Root directory and default response | ||
root ${getPath}/static/default; # Set to user's .get directory | ||
location / { | ||
return 200 'NGINX Default Response. Server is running.'; | ||
proxy_pass http://localhost:3004; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
try_files $uri $uri/ =404; | ||
} | ||
@@ -21,3 +41,4 @@ } | ||
`; | ||
}; | ||
export default getDefaultServerBlock; |
//i_DefaultNetGetX.js | ||
import chalk from 'chalk'; | ||
import { getDir } from '../../../scripts/setupConfig.js'; | ||
import path from 'path'; | ||
import { | ||
loadOrCreateXConfig, | ||
saveXConfig } from './xConfig.js'; | ||
import { initializeState } from '../xState.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'; | ||
import { | ||
getNginxConfigAndDir, | ||
setNginxConfigAndDir, | ||
setNginxExecutable } from './NginxPaths.js'; | ||
import { | ||
getLocalIP, | ||
getPublicIP } from '../../utils/ipUtils.js'; | ||
import { | ||
ensureDirectoryExists, | ||
Path_Exists } from '../../utils/pathUtils.js'; | ||
import { initializeDirectories, | ||
getDirectoryPaths } from '../../utils/GETDirs.js'; | ||
import verifyNginxInstallation from '../NGINX/verifyNginxInstallation.js'; | ||
import nginxInstallationOptions from '../NGINX/nginxInstallationOptions.cli.js'; | ||
import verifyNginxConfig from './verifyNginxConfig.js'; | ||
import verifyServerBlock from './verifyServerBlock.js'; | ||
export async function i_DefaultNetGetX() { | ||
getDir(); | ||
let userConfig = await loadOrCreateUserConfig(); | ||
const publicIP = await getPublicIP(); | ||
const localIP = await getLocalIP(); | ||
//console.log(publicIP ? `publicIp: ${publicIP}` : chalk.red('No public IP detected. Some features may be limited.')); | ||
//console.log(`Local IP: ${chalk.green(localIP)}`); | ||
initializeDirectories(); // Initialize all necessary directories | ||
let DEFAULT_DIRECTORIES = getDirectoryPaths(); // Get paths to .get default directories | ||
const nginxInstalled = await verifyNginxInstallation(); // Verify NGINX installation | ||
if (!nginxInstalled) { | ||
console.log(chalk.yellow("NGINX is not installed. Redirecting to installation options...")); | ||
await nginxInstallationOptions(); | ||
// Optionally re-check after installation attempt | ||
if (!await verifyNginxInstallation()) { | ||
console.log(chalk.red("NGINX still not detected after installation attempt. Please manually install NGINX and retry.")); | ||
return false; // Exiting or return to a higher menu level could be handled here | ||
} | ||
} | ||
let xConfig = await loadOrCreateXConfig(); | ||
//console.log("Default Directories" , DEFAULT_DIRECTORIES); | ||
/* Verify .get Paths | ||
┏┓┏┓┏┳┓ | ||
┃┓┣ ┃ | ||
•┗┛┗┛ ┻ | ||
*/ | ||
if(!xConfig.getPath){ | ||
const getDefaultPath = DEFAULT_DIRECTORIES.getPath; | ||
if (Path_Exists(getDefaultPath)) { | ||
await saveXConfig({ getPath: getDefaultPath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(`Default getPath does not exist: ${getDefaultPath}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.static){ | ||
const getDefaultStatic = DEFAULT_DIRECTORIES.static; | ||
if (Path_Exists(getDefaultStatic)) { | ||
await saveXConfig({ static: getDefaultStatic }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(`Default static does not exist: ${getDefaultStatic}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.staticDefault){ | ||
const getDefaultStaticDefault = DEFAULT_DIRECTORIES.staticDefault; | ||
if (Path_Exists(getDefaultStaticDefault)) { | ||
await saveXConfig({ staticDefault: getDefaultStaticDefault }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(`Default staticDefault does not exist: ${getDefaultStaticDefault}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.SSLPath){ | ||
const getDefaultSSLPath = DEFAULT_DIRECTORIES.SSLPath; | ||
if (Path_Exists(getDefaultSSLPath)) { | ||
await saveXConfig({ SSLPath: getDefaultSSLPath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
}else{ | ||
console.log(`Default SSLPath does not exist: ${getDefaultSSLPath}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.SSLCertificatesPath){ | ||
const getDefaultSSLCertificatesPath = DEFAULT_DIRECTORIES.SSLCertificatesPath; | ||
if (Path_Exists(getDefaultSSLCertificatesPath)) { | ||
await saveXConfig({ SSLCertificatesPath: getDefaultSSLCertificatesPath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(`Default SSLCertificatesPath does not exist: ${getDefaultSSLCertificatesPath}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.SSLCertificateKeyPath){ | ||
const getDefaultSSLCertificateKeyPath = DEFAULT_DIRECTORIES.SSLCertificateKeyPath; | ||
if (Path_Exists(getDefaultSSLCertificateKeyPath)) { | ||
//console.log(`Default SSLCertificateKeyPath exists: ${getDefaultSSLCertificateKeyPath}`); | ||
await saveXConfig({ SSLCertificateKeyPath: getDefaultSSLCertificateKeyPath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
//console.log(`SSLCertificateKeyPath updated in configuration.`); | ||
} else { | ||
console.log(`Default SSLCertificateKeyPath does not exist: ${getDefaultSSLCertificateKeyPath}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.devPath){ | ||
const getDefaultDevPath = DEFAULT_DIRECTORIES.devPath; | ||
if (Path_Exists(getDefaultDevPath)) { | ||
//console.log(`Default devPath exists: ${getDefaultDevPath}`); | ||
await saveXConfig({ devPath: getDefaultDevPath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
//console.log(`devPath updated in configuration.`); | ||
} else { | ||
console.log(`Default devPath does not exist: ${getDefaultDevPath}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.devStatic){ | ||
const getDefaultDevStatic = DEFAULT_DIRECTORIES.devStatic; | ||
if (Path_Exists(getDefaultDevStatic)) { | ||
await saveXConfig({ devStatic: getDefaultDevStatic }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(`Default devStatic does not exist: ${getDefaultDevStatic}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.devStaticDefault){ | ||
const getDefaultDevStaticDefault = DEFAULT_DIRECTORIES.devStaticDefault; | ||
if (Path_Exists(getDefaultDevStaticDefault)) { | ||
//console.log(`Default devStaticDefault exists: ${getDefaultDevStaticDefault}`); | ||
await saveXConfig({ devStaticDefault: getDefaultDevStaticDefault }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
//console.log(`devStaticDefault updated in configuration.`); | ||
} else { | ||
console.log(`Default devStaticDefault does not exist: ${getDefaultDevStaticDefault}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.devSSLPath){ | ||
const getDefaultDevSSLPath = DEFAULT_DIRECTORIES.devSSLPath; | ||
if (Path_Exists(getDefaultDevSSLPath)) { | ||
//console.log(`Default devSSLPath exists: ${getDefaultDevSSLPath}`); | ||
await saveXConfig({ devSSLPath: getDefaultDevSSLPath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
//console.log(`devSSLPath updated in configuration.`); | ||
} else { | ||
console.log(`Default devSSLPath does not exist: ${getDefaultDevSSLPath}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.devSSLCertificatesPath){ | ||
const getDefaultDevSSLCertificatesPath = DEFAULT_DIRECTORIES.devSSLCertificatesPath; | ||
if (Path_Exists(getDefaultDevSSLCertificatesPath)) { | ||
//console.log(`Default devSSLCertificatesPath exists: ${getDefaultDevSSLCertificatesPath}`); | ||
await saveXConfig({ devSSLCertificatesPath: getDefaultDevSSLCertificatesPath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
//console.log(`devSSLCertificatesPath updated in configuration.`); | ||
} else { | ||
console.log(`Default devSSLCertificatesPath does not exist: ${getDefaultDevSSLCertificatesPath}, not updating configuration.`); | ||
} | ||
} | ||
if(!xConfig.devSSLCertificateKeyPath){ | ||
const getDefaultDevSSLCertificateKeyPath = DEFAULT_DIRECTORIES.devSSLCertificateKeyPath; | ||
if (Path_Exists(getDefaultDevSSLCertificateKeyPath)) { | ||
await saveXConfig({ devSSLCertificateKeyPath: getDefaultDevSSLCertificateKeyPath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(`Default devSSLCertificateKeyPath does not exist: ${getDefaultDevSSLCertificateKeyPath}, not updating configuration.`); | ||
} | ||
} | ||
/* Verify NGINX Paths are set correctly. | ||
@@ -26,12 +185,19 @@ ╔═╗┌─┐┌┬┐┬ ┬┌─┐ | ||
╩ ┴ ┴ ┴ ┴ ┴└─┘*/ | ||
if (!userConfig.nginxPath || !userConfig.nginxSitesAvailable || !userConfig.nginxSitesEnabled) { | ||
console.log(chalk.yellow('One or more NGINX configuration paths are not set. Attempting to set them...')); | ||
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; | ||
// Verify and set NGINX configuration path | ||
if (!xConfig.nginxPath || !xConfig.nginxDir) { | ||
const nginxPath = await getNginxConfigAndDir(); | ||
if (nginxPath && nginxPath.configPath) { | ||
console.log(chalk.green(`Found NGINX configuration path: ${nginxPath.configPath}`)); | ||
const setSuccess = await setNginxConfigAndDir(xConfig, nginxPath.configPath, nginxPath.basePath); | ||
if (setSuccess) { | ||
xConfig = await loadOrCreateXConfig(); | ||
} else { | ||
console.error(chalk.red(`Failed to set NGINX configuration paths.`)); | ||
} | ||
} | ||
} else { | ||
console.log(chalk.yellow(`NGINX configuration path not found.`)); | ||
} | ||
} | ||
/* Check and set NGINX executable | ||
@@ -41,12 +207,73 @@ ╔═╗═╗ ╦╔═╗╔═╗╦ ╦╔╦╗╔═╗╔╗ ╦ ╔═╗ | ||
╚═╝╩ ╚═╚═╝╚═╝╚═╝ ╩ ╩ ╩╚═╝╩═╝╚═╝*/ | ||
if (!userConfig.nginxExecutable) { | ||
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 | ||
if (!xConfig.nginxExecutable) { | ||
if (await setNginxExecutable(xConfig)) { | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
}else{ | ||
console.log(chalk.red('Failed to set NGINX executable.')); | ||
return false; | ||
console.log(chalk.red('Failed to set NGINX executable.')); | ||
console.log(chalk.red('Please Make Sure NGINX Is Installed.')); | ||
} | ||
} | ||
// Ensure 'XBlocks-available' directory exists or create it | ||
const xBlocksAvailablePath = path.join(xConfig.nginxDir, 'XBlocks-available'); | ||
ensureDirectoryExists(xBlocksAvailablePath, 'XBlocks-available'); | ||
if (!xConfig.XBlocksAvailable) { | ||
if (Path_Exists(xBlocksAvailablePath)) { | ||
await saveXConfig({ XBlocksAvailable: xBlocksAvailablePath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(chalk.red("XBlocks available path not found.")); | ||
} | ||
} | ||
} | ||
// Ensure 'XBlocks-enabled' directory exists or create it | ||
const xBlocksEnabledPath = path.join(xConfig.nginxDir, 'XBlocks-enabled'); | ||
ensureDirectoryExists(xBlocksEnabledPath); | ||
if (!xConfig.XBlocksEnabled) { | ||
if (Path_Exists(xBlocksEnabledPath)) { | ||
await saveXConfig({ XBlocksEnabled: xBlocksEnabledPath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(chalk.red("XBlocks enabled path not found.")); | ||
} | ||
} | ||
//DEVELOPMENT SETTINGS | ||
// Ensure 'dev_X' directory exists or create it | ||
const dev_X = path.join(xConfig.nginxDir, 'dev_X'); | ||
ensureDirectoryExists(dev_X); | ||
if (!xConfig.nginxDevDir) { | ||
if(Path_Exists(dev_X)){ | ||
await saveXConfig({ nginxDevDir: dev_X }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(chalk.yellow("NGINX DevDir Path Not Found...")); | ||
} | ||
} | ||
// Ensure DEV 'XBlocks-available' directory exists or create it | ||
const dev_xBlocksAvailablePath = path.join(xConfig.nginxDevDir, 'XBlocks-available'); | ||
ensureDirectoryExists(dev_xBlocksAvailablePath); | ||
if (!xConfig.dev_XBlocksAvailable) { | ||
if (Path_Exists(dev_xBlocksAvailablePath)) { | ||
await saveXConfig({ dev_XBlocksAvailable: dev_xBlocksAvailablePath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(chalk.red("Dev XBlocks available path not found.")); | ||
} | ||
} | ||
// Ensure DEV 'XBlocks-enabled' directory exists or create it | ||
const dev_xBlocksEnabledPath = path.join(xConfig.nginxDevDir, 'XBlocks-enabled'); | ||
ensureDirectoryExists(dev_xBlocksEnabledPath); | ||
if (!xConfig.dev_XBlocksEnabled) { | ||
if (Path_Exists(dev_xBlocksEnabledPath)) { | ||
await saveXConfig({ dev_XBlocksEnabled: dev_xBlocksEnabledPath }); | ||
xConfig = await loadOrCreateXConfig(); // Reload to ensure all config updates are reflected | ||
} else { | ||
console.log(chalk.red("Dev XBlocks enabled path not found.")); | ||
} | ||
} | ||
/* Verify All Good. | ||
@@ -56,14 +283,21 @@ ╔╗╔╔═╗╦╔╗╔═╗ ╦ ╔═╗╦ ╦╔═╗╔═╗╦╔═╔═╗ | ||
╝╚╝╚═╝╩╝╚╝╩ ╚═ ╚═╝╩ ╩╚═╝╚═╝╩ ╩╚═╝*/ | ||
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 | ||
let nginxVerified = await verifyNginxConfig(xConfig); | ||
if (!nginxVerified) { | ||
console.log(chalk.red('NGINX installation or configuration still incorrect after attempted fixes.')); | ||
console.log(chalk.blue('Please check the manual configuration guidelines or contact support.')); | ||
return false; | ||
} | ||
} | ||
console.log(chalk.yellow('Initial NGINX verification failed. Attempting to resolve...')); | ||
try { | ||
await nginxInstallationOptions(); // Attempt automated fixes | ||
nginxVerified = await verifyNginxConfig(xConfig); // Re-check after attempting fixes | ||
if (!nginxVerified) { | ||
console.log(chalk.red('NGINX installation or configuration still incorrect after attempted fixes.')); | ||
console.log(chalk.blue('Please check the manual configuration guidelines or contact support.')); | ||
return false; | ||
} else { | ||
console.log(chalk.green('NGINX issues resolved successfully.')); | ||
} | ||
} catch (error) { | ||
console.log(chalk.red(`An error occurred while attempting to fix NGINX: ${error.message}`)); | ||
console.log(chalk.blue('Please check the manual configuration guidelines or contact support.')); | ||
return false; | ||
} | ||
} | ||
@@ -74,10 +308,12 @@ /* Verify NGINX server block is correctly configured for netgetX. | ||
╚═╝╚═╝╩╚═ ╚╝ ╚═╝╩╚═ ╚═╝╩═╝╚═╝╚═╝╩ ╩*/ | ||
const serverBlockVerified = await verifyServerBlock(userConfig); | ||
const serverBlockVerified = await verifyServerBlock(xConfig); | ||
if (!serverBlockVerified) { | ||
console.log(chalk.yellow('NGINX server block is not correctly configured.')); | ||
console.log(chalk.yellow('Default Server block is not as NetGetX Default.')); | ||
return false; | ||
} | ||
const publicIP = await getPublicIP(); // Properly await the asynchronous call | ||
const localIP = getLocalIP(); | ||
let x = { | ||
...userConfig, // spreads all properties of userConfig into x | ||
...xConfig, // spreads all properties of xConfig into x | ||
publicIP: publicIP, | ||
@@ -89,3 +325,4 @@ localIP: localIP | ||
return x; | ||
}; | ||
@@ -6,3 +6,3 @@ //netget/src/modules/NetGetX/config/serverBlockConfigOptions.cli.js | ||
export const serverBlockConfigOptions = async (userConfig) => { | ||
export const serverBlockConfigOptions = async (xConfig) => { | ||
const answers = await inquirer.prompt([ | ||
@@ -23,3 +23,3 @@ { | ||
case 'Set/Restore NGINX to Default NetGetX Recommended Settings.': | ||
await setDefaultServerBlock(userConfig); | ||
await setDefaultServerBlock(xConfig); | ||
return true; // Configuration was successfully restored | ||
@@ -26,0 +26,0 @@ case 'Proceed with Current Configuration': |
@@ -7,14 +7,13 @@ // netget/src/modules/NetGetX/config/verifyServerBlock.js | ||
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 | ||
const verifyServerBlock = async (xConfig) => { | ||
const nginxConfigPath = xConfig.nginxPath; // Path to nginx.conf | ||
const expectedServerBlock = getDefaultServerBlock(xConfig); // Get the dynamic server block | ||
try { | ||
const configData = fs.readFileSync(nginxConfigPath, 'utf8'); | ||
if (configData.includes(expectedServerBlock.trim())) { | ||
console.log(chalk.green('Default Server Block is correctly configured.')); | ||
console.log(chalk.green('Server Ready for NetGetX...')); | ||
return true; | ||
} else { | ||
console.log(chalk.yellow('Default NGINX server block does not match the expected setup.')); | ||
if (userConfig.nginxConfigurationProceed) { | ||
console.log(chalk.yellow('Default NGINX server block does not match the expected default setup.')); | ||
if (xConfig.nginxConfigurationProceed) { | ||
console.log(chalk.green('Proceeding with existing configuration as per user preference.')); | ||
@@ -24,3 +23,3 @@ return true; | ||
// Prompt the user for action and determine outcome based on their choice | ||
const configurationSuccess = await serverBlockConfigOptions(userConfig); | ||
const configurationSuccess = await serverBlockConfigOptions(xConfig); | ||
return configurationSuccess; | ||
@@ -27,0 +26,0 @@ } |
@@ -53,2 +53,2 @@ // NetGetX.cli.js | ||
} | ||
} | ||
}; |
// netget/src/modules/NetGetX/NGINX/checkNginxStatus.js | ||
import chalk from 'chalk'; | ||
import { exec } from 'child_process'; | ||
import { loadUserConfig } from '../utils/loadUserConfig.js'; | ||
@@ -6,0 +5,0 @@ export async function checkNginxStatus(x) { |
@@ -1,5 +0,7 @@ | ||
Implement the new utils/loadUserConfig.js in all the scripts instead of having the function written in each. use this script now and import it to get the userConfig data. | ||
'netget/src/modules/NetGetX/utils/loadUserConfig.js'; | ||
modularizar entre el codigo de /dev y produccion archivos como saveConfig loadConfig, defaultServerBlock y detectNginxPaths para dev y produccion simplificar modulo y solo pasar parametros... | ||
Modular Merge verifyInstallation para que con 1 podamos verificar production y dev. | ||
Implementar el externalizar el userConfig.json fuera del codigo fuente de netget para poder prevalecer los datos despues de reinstalar netget. | ||
SetnxingExecutable (use same); | ||
verifyInstallation (use Same); | ||
// xState.js | ||
import chalk from 'chalk'; | ||
let xState = {}; | ||
@@ -8,3 +7,3 @@ | ||
xState = { ...data }; | ||
console.log(chalk.green('X State Initialized.')); | ||
console.log(chalk.cyan('X State Initialized.')); | ||
//console.log(chalk.cyan(`Configuration attached: ${JSON.stringify(xState, null, 2)}`)); | ||
@@ -11,0 +10,0 @@ }; |
#!/usr/bin/env node | ||
import { program } from 'commander'; | ||
import { getDir } from './scripts/setupConfig.js'; | ||
import NetGetX_CLI from './modules/NetGetX/NetGetX.cli.js'; | ||
@@ -9,4 +8,3 @@ import { handleGateways } from './modules/Gateways/Gateways.js'; | ||
// Directory check and setup if necessary | ||
getDir(); | ||
// Entry Points Options and Commands | ||
@@ -13,0 +11,0 @@ program |
// scripts/postInstall.js | ||
import { getDir } from './setupConfig.js'; | ||
import { initializeDirectories } from '../modules/utils/GETDirs.js'; // Adjust the path as necessary depending on your project structure | ||
getDir(); | ||
// Function to run on post-install | ||
function runPostInstall() { | ||
try { | ||
console.log('Initializing default .get directories...'); | ||
initializeDirectories(); // This will create all necessary directories as defined in your GETDirs module | ||
console.log('All directories have been successfully initialized.'); | ||
} catch (error) { | ||
console.error('Failed to initialize directories:', error); | ||
} | ||
} | ||
// Execute the post-install process | ||
runPostInstall(); |
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
917175
63
1938
20
12