UNPKG

smartui-migration-tool

Version:

Enterprise-grade CLI tool for migrating visual testing platforms to LambdaTest SmartUI

113 lines • 6.21 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@oclif/core"); const chalk_1 = __importDefault(require("chalk")); const child_process_1 = require("child_process"); const inquirer_1 = __importDefault(require("inquirer")); class Uninstall extends core_1.Command { async run() { const { flags } = await this.parse(Uninstall); const packageJson = require('../../package.json'); const currentVersion = packageJson.version; console.log(chalk_1.default.red.bold('šŸ—‘ļø SmartUI Migration Tool - Uninstall\n')); console.log(chalk_1.default.white(`Current version: ${chalk_1.default.gray(currentVersion)}`)); console.log(chalk_1.default.white(`Installation path: ${chalk_1.default.gray(process.argv[0])}\n`)); // Show what will be removed console.log(chalk_1.default.yellow('šŸ“‹ This will remove:')); console.log(chalk_1.default.white(' • SmartUI Migration Tool binary')); console.log(chalk_1.default.white(' • All associated files and dependencies')); console.log(chalk_1.default.white(' • Global npm package installation\n')); // Show what will NOT be removed console.log(chalk_1.default.green('āœ… This will NOT remove:')); console.log(chalk_1.default.white(' • Your migrated projects')); console.log(chalk_1.default.white(' • SmartUI configuration files')); console.log(chalk_1.default.white(' • Backup files created during migration')); console.log(chalk_1.default.white(' • Any other global npm packages\n')); // Confirmation prompt if (!flags.force) { const { confirm } = await inquirer_1.default.prompt([ { type: 'confirm', name: 'confirm', message: 'Are you sure you want to uninstall SmartUI Migration Tool?', default: false, }, ]); if (!confirm) { console.log(chalk_1.default.blue('\nāœ… Uninstall cancelled. SmartUI Migration Tool remains installed.')); return; } } try { console.log(chalk_1.default.yellow('\nšŸ”„ Uninstalling SmartUI Migration Tool...\n')); // Check if running as root (not recommended) if (process.getuid && process.getuid() === 0) { console.log(chalk_1.default.yellow('āš ļø Warning: Running as root. This is not recommended.')); console.log(chalk_1.default.gray(' Consider using a Node.js version manager like nvm.\n')); } // Uninstall the package console.log(chalk_1.default.blue('šŸ—‘ļø Removing package...')); (0, child_process_1.execSync)('npm uninstall -g smartui-migration-tool', { stdio: 'inherit', encoding: 'utf8' }); // Verify the uninstall console.log(chalk_1.default.blue('\nšŸ” Verifying uninstallation...')); try { (0, child_process_1.execSync)('smartui-migrator --version', { encoding: 'utf8', stdio: 'pipe' }); console.log(chalk_1.default.yellow('\nāš ļø Uninstall completed, but command still available')); console.log(chalk_1.default.gray(' This may be due to caching or multiple installations')); console.log(chalk_1.default.cyan('\nšŸ’” Try restarting your terminal or check your PATH')); } catch (error) { console.log(chalk_1.default.green('\nāœ… Uninstall successful!')); console.log(chalk_1.default.white(' SmartUI Migration Tool has been removed from your system')); } // Show next steps console.log(chalk_1.default.cyan('\nšŸ“‹ Next Steps:')); console.log(chalk_1.default.white(' • Your migrated projects remain unchanged')); console.log(chalk_1.default.white(' • SmartUI configurations are preserved')); console.log(chalk_1.default.white(' • You can reinstall anytime with: npm install -g smartui-migration-tool')); console.log(chalk_1.default.cyan('\nšŸ’” Thank you for using SmartUI Migration Tool!')); console.log(chalk_1.default.gray(' Visit https://www.lambdatest.com/smart-ui for SmartUI documentation')); } catch (error) { console.error(chalk_1.default.red('\nāŒ Uninstall failed:')); if (error instanceof Error) { if (error.message.includes('EACCES')) { console.error(chalk_1.default.red(' Permission denied. Try running with sudo or use a Node.js version manager.')); console.error(chalk_1.default.cyan('\nšŸ’” Alternative: npm uninstall -g smartui-migration-tool')); } else if (error.message.includes('ENOTFOUND') || error.message.includes('network')) { console.error(chalk_1.default.red(' Network error. Check your internet connection.')); console.error(chalk_1.default.cyan('\nšŸ’” Try again later or check npm registry status.')); } else { console.error(chalk_1.default.red(` ${error.message}`)); } } else { console.error(chalk_1.default.red(' Unknown error occurred')); } console.error(chalk_1.default.cyan('\nšŸ’” For manual uninstall: npm uninstall -g smartui-migration-tool')); this.exit(1); } } } Uninstall.description = 'Uninstall SmartUI Migration Tool from your system'; Uninstall.flags = { help: core_1.Flags.help({ char: 'h' }), force: core_1.Flags.boolean({ char: 'f', description: 'Skip confirmation prompt', default: false, }), }; exports.default = Uninstall; //# sourceMappingURL=uninstall.js.map