@commit451/salamander
Version:
Never be AFK
55 lines ⢠2.4 kB
JavaScript
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