UNPKG

@commit451/salamander

Version:

Never be AFK

55 lines • 2.4 kB
import { confirm, select } from '@inquirer/prompts'; import chalk from 'chalk'; import { RunnerService } from '../services/runner.js'; export async function deleteRunnerFlow() { console.log(chalk.blue('\nšŸ—‘ļø Delete Runner')); try { const localRunners = await RunnerService.getAllRunners(); if (localRunners.length === 0) { console.log(chalk.yellow('āš ļø No runners found for this machine.')); return; } console.log(chalk.green(`āœ… Found ${localRunners.length} runner(s) for this machine`)); const choices = localRunners.map(runner => ({ name: formatRunnerChoice(runner), value: runner.id, description: `Delete runner in ${runner.directory}` })); const runnerId = await select({ message: 'Select a runner to delete:', choices }); const selectedRunner = localRunners.find(r => r.id === runnerId); if (!selectedRunner) { console.error(chalk.red('āŒ Runner not found')); return; } console.log(chalk.yellow('\nāš ļø This action cannot be undone!')); console.log(chalk.gray(` Runner: ${selectedRunner.name}`)); console.log(chalk.gray(` Directory: ${selectedRunner.directory}`)); console.log(chalk.gray(` Type: ${selectedRunner.runnerType}`)); const confirmed = await confirm({ message: 'Are you sure you want to delete this runner?', default: false }); if (!confirmed) { console.log(chalk.blue('šŸ‘ Delete cancelled')); return; } console.log(chalk.yellow('ā³ Deleting runner...')); await RunnerService.deleteRunner(runnerId); console.log(chalk.green('āœ… Runner deleted successfully!')); console.log(chalk.gray(` Removed: ${selectedRunner.name}`)); } catch (error) { console.error(chalk.red('āŒ Error deleting runner:'), error.message); process.exit(1); } } function formatRunnerChoice(runner) { const lastMessage = runner.lastMessage ? ` • ${runner.lastMessage.substring(0, 50)}${runner.lastMessage.length > 50 ? '...' : ''}` : ''; return `šŸ¤– ${chalk.bold(runner.name)} ${chalk.gray(`[${runner.runnerType}]`)}${chalk.dim(lastMessage)}`; } //# sourceMappingURL=delete-runner.js.map