smartui-migration-tool
Version:
Enterprise-grade CLI tool for migrating visual testing platforms to LambdaTest SmartUI
113 lines ⢠6.21 kB
JavaScript
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
;