datapilot-cli
Version:
Enterprise-grade streaming multi-format data analysis with comprehensive statistical insights and intelligent relationship detection - supports CSV, JSON, Excel, TSV, Parquet - memory-efficient, cross-platform
209 lines ⢠9.6 kB
JavaScript
;
/**
* Windows PATH Helper
* Provides utilities for detecting and guiding Windows PATH configuration
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.WindowsPathHelper = void 0;
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const child_process_1 = require("child_process");
class WindowsPathHelper {
/**
* Check if we're running on Windows
*/
static isWindows() {
return os.platform() === 'win32';
}
/**
* Check if DataPilot is available in PATH
*/
static isDataPilotInPath() {
if (!this.isWindows()) {
return true; // Assume it's working on non-Windows systems
}
try {
(0, child_process_1.execSync)('where datapilot', { stdio: 'ignore' });
return true;
}
catch (error) {
return false;
}
}
/**
* Get npm global installation path
*/
static getNpmGlobalPath() {
try {
const npmPrefix = (0, child_process_1.execSync)('npm config get prefix', { encoding: 'utf8' }).trim();
return npmPrefix;
}
catch (error) {
return null;
}
}
/**
* Show Windows-specific setup guidance when DataPilot is not in PATH
*/
static showWindowsSetupGuide() {
if (!this.isWindows()) {
return;
}
console.error('\nšØ WINDOWS SETUP ISSUE DETECTED:');
console.error('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
console.error('ā ļø DataPilot CLI is not in your PATH environment variable.');
console.error('ā ļø This is common on Windows after npm global installations.\n');
// Try to get npm prefix for helpful instructions
const npmPrefix = this.getNpmGlobalPath();
if (npmPrefix) {
console.error('š§ QUICK FIXES:');
console.error('\n1ļøā£ Use npx (No setup needed, works immediately):');
console.error(` npx datapilot-cli --version`);
console.error(` npx datapilot-cli all yourfile.csv\n`);
console.error('2ļøā£ Add npm to PATH (One-time setup for permanent access):');
console.error(' š PowerShell (as Administrator):');
console.error(` [Environment]::SetEnvironmentVariable("Path", $env:Path + ";${npmPrefix}", [EnvironmentVariableTarget]::User)`);
console.error(' š Command Prompt (as Administrator):');
console.error(` setx PATH "%PATH%;${npmPrefix}"`);
console.error(' š Manual (safest method):');
console.error(' ⢠Right-click "This PC" ā Properties ā Advanced system settings');
console.error(' ⢠Environment Variables ā User variables ā Path ā Edit ā New');
console.error(` ⢠Add: ${npmPrefix}`);
console.error(' ⢠OK ā OK ā OK ā Restart terminal\n');
console.error('3ļøā£ Use full path (Direct execution):');
console.error(` "${path.join(npmPrefix, 'datapilot')}" --version\n`);
}
else {
console.error('š§ SETUP OPTIONS:');
console.error('1ļøā£ Use npx: npx datapilot-cli --version');
console.error('2ļøā£ Find npm prefix: npm config get prefix');
console.error('3ļøā£ Add the prefix path to your PATH environment variable\n');
}
console.error('š Need more help?');
console.error(' ⢠Full guide: https://github.com/Mrassimo/datapilot#windows-installation');
console.error(' ⢠Issues: https://github.com/Mrassimo/datapilot/issues');
console.error('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n');
}
/**
* Check if the current execution might be a PATH-related issue
*/
static isLikelyPathIssue(error) {
if (!this.isWindows()) {
return false;
}
const errorMessage = String(error).toLowerCase();
const pathIssueIndicators = [
'command not found',
'is not recognized',
'not found',
'cannot find',
'enoent',
'spawn',
'spawnSync'
];
return pathIssueIndicators.some(indicator => errorMessage.includes(indicator));
}
/**
* Provide context-aware error guidance
*/
static provideErrorGuidance(error) {
if (!this.isWindows()) {
return;
}
if (this.isLikelyPathIssue(error)) {
this.showWindowsSetupGuide();
}
else {
// Generic Windows troubleshooting
console.error('\nš Windows Troubleshooting:');
console.error('If you continue having issues:');
console.error('⢠Try running as Administrator');
console.error('⢠Check if your antivirus is blocking the command');
console.error('⢠Ensure Node.js and npm are properly installed');
console.error('⢠Try using PowerShell instead of Command Prompt\n');
}
}
/**
* Check installation health and provide proactive guidance
*/
static checkInstallationHealth() {
if (!this.isWindows()) {
return;
}
// Only check if we think we might have issues
if (!this.isDataPilotInPath()) {
console.log('\nš” Windows PATH Check:');
console.log('DataPilot might not be in your PATH. If you encounter issues, try:');
console.log('⢠npx datapilot-cli --version (works without PATH setup)');
console.log('⢠Or see setup guide with --help-windows\n');
}
}
/**
* Show comprehensive Windows help
*/
static showWindowsHelp() {
if (!this.isWindows()) {
console.log('This help is specific to Windows. You\'re on a different platform.');
return;
}
console.log('\nšŖ DataPilot CLI - Windows Setup Guide');
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
console.log('\nš¦ Installation Methods:');
console.log('npm install -g datapilot-cli # Global installation');
console.log('npx datapilot-cli --version # Direct usage (no installation)');
console.log('\nš ļø PATH Configuration:');
const npmPrefix = this.getNpmGlobalPath();
if (npmPrefix) {
console.log(`Your npm global path: ${npmPrefix}`);
console.log('This path should be in your PATH environment variable.');
}
console.log('\nā
Verification:');
console.log('datapilot --version # Should show version if PATH is set');
console.log('where datapilot # Should show executable location');
console.log('npx datapilot-cli --version # Always works regardless of PATH');
console.log('\nšØ Common Issues:');
console.log('⢠"datapilot is not recognized" ā PATH not configured');
console.log('⢠"Access denied" ā Run as Administrator');
console.log('⢠"Module not found" ā Try npm install -g datapilot-cli');
console.log('\nš Resources:');
console.log('⢠GitHub: https://github.com/Mrassimo/datapilot');
console.log('⢠Issues: https://github.com/Mrassimo/datapilot/issues');
console.log('⢠Windows PATH Guide: https://www.java.com/en/download/help/path.html');
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n');
}
}
exports.WindowsPathHelper = WindowsPathHelper;
//# sourceMappingURL=windows-path-helper.js.map