fix: displayBanner logging when silentMode is active (#385)

This commit is contained in:
Ralph Khreish
2025-05-03 01:06:29 +02:00
committed by GitHub
parent 1f44ea5299
commit 2e17437da3
3 changed files with 69 additions and 62 deletions

View File

@@ -22,15 +22,6 @@ export async function updateTasksDirect(args, log, context = {}) {
const { session } = context; // Extract session const { session } = context; // Extract session
const { tasksJsonPath, from, prompt, research, projectRoot } = args; const { tasksJsonPath, from, prompt, research, projectRoot } = args;
// Create the standard logger wrapper
const logWrapper = {
info: (message, ...args) => log.info(message, ...args),
warn: (message, ...args) => log.warn(message, ...args),
error: (message, ...args) => log.error(message, ...args),
debug: (message, ...args) => log.debug && log.debug(message, ...args),
success: (message, ...args) => log.info(message, ...args)
};
// --- Input Validation (Keep existing checks) --- // --- Input Validation (Keep existing checks) ---
if (!tasksJsonPath) { if (!tasksJsonPath) {
log.error('updateTasksDirect called without tasksJsonPath'); log.error('updateTasksDirect called without tasksJsonPath');

View File

@@ -3,7 +3,7 @@ import chalk from 'chalk';
import boxen from 'boxen'; import boxen from 'boxen';
import Table from 'cli-table3'; import Table from 'cli-table3';
import { log, readJSON, writeJSON, truncate } from '../utils.js'; import { log, readJSON, writeJSON, truncate, isSilentMode } from '../utils.js';
import { displayBanner } from '../ui.js'; import { displayBanner } from '../ui.js';
import generateTaskFiles from './generate-task-files.js'; import generateTaskFiles from './generate-task-files.js';
@@ -22,14 +22,16 @@ function clearSubtasks(tasksPath, taskIds) {
process.exit(1); process.exit(1);
} }
console.log( if (!isSilentMode()) {
boxen(chalk.white.bold('Clearing Subtasks'), { console.log(
padding: 1, boxen(chalk.white.bold('Clearing Subtasks'), {
borderColor: 'blue', padding: 1,
borderStyle: 'round', borderColor: 'blue',
margin: { top: 1, bottom: 1 } borderStyle: 'round',
}) margin: { top: 1, bottom: 1 }
); })
);
}
// Handle multiple task IDs (comma-separated) // Handle multiple task IDs (comma-separated)
const taskIdArray = taskIds.split(',').map((id) => id.trim()); const taskIdArray = taskIds.split(',').map((id) => id.trim());
@@ -85,59 +87,65 @@ function clearSubtasks(tasksPath, taskIds) {
writeJSON(tasksPath, data); writeJSON(tasksPath, data);
// Show summary table // Show summary table
console.log( if (!isSilentMode()) {
boxen(chalk.white.bold('Subtask Clearing Summary:'), { console.log(
padding: { left: 2, right: 2, top: 0, bottom: 0 }, boxen(chalk.white.bold('Subtask Clearing Summary:'), {
margin: { top: 1, bottom: 0 }, padding: { left: 2, right: 2, top: 0, bottom: 0 },
borderColor: 'blue', margin: { top: 1, bottom: 0 },
borderStyle: 'round' borderColor: 'blue',
}) borderStyle: 'round'
); })
console.log(summaryTable.toString()); );
console.log(summaryTable.toString());
}
// Regenerate task files to reflect changes // Regenerate task files to reflect changes
log('info', 'Regenerating task files...'); log('info', 'Regenerating task files...');
generateTaskFiles(tasksPath, path.dirname(tasksPath)); generateTaskFiles(tasksPath, path.dirname(tasksPath));
// Success message // Success message
console.log( if (!isSilentMode()) {
boxen( console.log(
chalk.green( boxen(
`Successfully cleared subtasks from ${chalk.bold(clearedCount)} task(s)` chalk.green(
), `Successfully cleared subtasks from ${chalk.bold(clearedCount)} task(s)`
{ ),
padding: 1, {
borderColor: 'green', padding: 1,
borderStyle: 'round', borderColor: 'green',
margin: { top: 1 } borderStyle: 'round',
} margin: { top: 1 }
) }
); )
);
// Next steps suggestion // Next steps suggestion
console.log( console.log(
boxen( boxen(
chalk.white.bold('Next Steps:') + chalk.white.bold('Next Steps:') +
'\n\n' + '\n\n' +
`${chalk.cyan('1.')} Run ${chalk.yellow('task-master expand --id=<id>')} to generate new subtasks\n` + `${chalk.cyan('1.')} Run ${chalk.yellow('task-master expand --id=<id>')} to generate new subtasks\n` +
`${chalk.cyan('2.')} Run ${chalk.yellow('task-master list --with-subtasks')} to verify changes`, `${chalk.cyan('2.')} Run ${chalk.yellow('task-master list --with-subtasks')} to verify changes`,
{ {
padding: 1,
borderColor: 'cyan',
borderStyle: 'round',
margin: { top: 1 }
}
)
);
}
} else {
if (!isSilentMode()) {
console.log(
boxen(chalk.yellow('No subtasks were cleared'), {
padding: 1, padding: 1,
borderColor: 'cyan', borderColor: 'yellow',
borderStyle: 'round', borderStyle: 'round',
margin: { top: 1 } margin: { top: 1 }
} })
) );
); }
} else {
console.log(
boxen(chalk.yellow('No subtasks were cleared'), {
padding: 1,
borderColor: 'yellow',
borderStyle: 'round',
margin: { top: 1 }
})
);
} }
} }

View File

@@ -9,7 +9,13 @@ import boxen from 'boxen';
import ora from 'ora'; import ora from 'ora';
import Table from 'cli-table3'; import Table from 'cli-table3';
import gradient from 'gradient-string'; import gradient from 'gradient-string';
import { log, findTaskById, readJSON, truncate } from './utils.js'; import {
log,
findTaskById,
readJSON,
truncate,
isSilentMode
} from './utils.js';
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import { findNextTask, analyzeTaskComplexity } from './task-manager.js'; import { findNextTask, analyzeTaskComplexity } from './task-manager.js';
@@ -23,6 +29,8 @@ const warmGradient = gradient(['#fb8b24', '#e36414', '#9a031e']);
* Display a fancy banner for the CLI * Display a fancy banner for the CLI
*/ */
function displayBanner() { function displayBanner() {
if (isSilentMode()) return;
console.clear(); console.clear();
const bannerText = figlet.textSync('Task Master', { const bannerText = figlet.textSync('Task Master', {
font: 'Standard', font: 'Standard',