xnet-toolkit
Version:
Professional Network Administration and Security Toolkit
56 lines (43 loc) • 1.96 kB
JavaScript
const { spawn } = require('child_process');
const chalk = require('chalk');
const path = require('path');
const fs = require('fs');
console.log(chalk.blue('Setting up XNET dependencies...'));
const pipInstall = () => {
const pipExecutable = process.platform === 'win32' ? 'pip' : 'pip3';
const requirements = path.join(__dirname, '..', 'requirements.txt');
console.log(chalk.yellow('Installing Python dependencies...'));
const pip = spawn(pipExecutable, ['install', '-r', requirements], { stdio: 'inherit' });
pip.on('error', (error) => {
console.error(chalk.red(`Error installing Python dependencies: ${error.message}`));
console.log(chalk.yellow('You may need to install them manually:'));
console.log(chalk.gray(`${pipExecutable} install -r ${requirements}`));
});
pip.on('exit', (code) => {
if (code === 0) {
console.log(chalk.green('Python dependencies installed successfully'));
installXnetPackage();
} else {
console.error(chalk.red(`Failed to install Python dependencies (exit code ${code})`));
console.log(chalk.yellow('You may need to install them manually.'));
}
});
};
const installXnetPackage = () => {
const pipExecutable = process.platform === 'win32' ? 'pip' : 'pip3';
const setupPyPath = path.join(__dirname, '..');
console.log(chalk.yellow('Installing XNET package...'));
const install = spawn(pipExecutable, ['install', '-e', setupPyPath], { stdio: 'inherit' });
install.on('error', (error) => {
console.error(chalk.red(`Error installing XNET: ${error.message}`));
});
install.on('exit', (code) => {
if (code === 0) {
console.log(chalk.green('XNET installed successfully'));
console.log(chalk.blue('You can now use the "xnet" command'));
} else {
console.error(chalk.red(`Failed to install XNET (exit code ${code})`));
}
});
};
pipInstall();