Skip to content

Commit f9ecb8f

Browse files
committed
refactor(cli): remove legacy table format from dev owners
Simplified to context-aware modes only (changed files, root, subdirectory)
1 parent 19ab6db commit f9ecb8f

File tree

1 file changed

+1
-102
lines changed

1 file changed

+1
-102
lines changed

packages/cli/src/commands/owners.ts

Lines changed: 1 addition & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -374,83 +374,7 @@ function formatSubdirectoryMode(
374374
if (relevantDevs.length === 1) {
375375
output += chalk.dim(`💡 Tip: You're the main contributor here\n`);
376376
} else {
377-
output += chalk.dim(
378-
`💡 Tip: Run ${chalk.cyan("'dev owners --all'")} to see all ${relevantDevs.length} contributors\n`
379-
);
380-
}
381-
382-
return output;
383-
}
384-
385-
/**
386-
* Format developer stats as a table (legacy --all mode)
387-
*/
388-
function formatDeveloperTable(developers: DeveloperStats[]): string {
389-
if (developers.length === 0) return '';
390-
391-
// Calculate column widths based on display names
392-
const maxNameLen = Math.max(...developers.map((d) => d.displayName.length), 15);
393-
const nameWidth = Math.min(maxNameLen, 30);
394-
395-
// Header - add 5 extra spaces after DEVELOPER to accommodate longer file paths
396-
const extraSpacing = ' '; // 5 extra spaces for file path display
397-
let output = chalk.bold(
398-
`${'DEVELOPER'.padEnd(nameWidth)}${extraSpacing} ${'FILES'.padStart(6)} ${'COMMITS'.padStart(8)} ${'LOC'.padStart(8)} ${'LAST ACTIVE'}\n`
399-
);
400-
401-
// Separator (calculate exact width including extra spacing)
402-
const separatorWidth = nameWidth + 5 + 2 + 6 + 2 + 8 + 2 + 8 + 2 + 12;
403-
output += chalk.dim(`${'─'.repeat(separatorWidth)}\n`);
404-
405-
// Rows
406-
for (const dev of developers) {
407-
// Truncate display name if needed
408-
let displayName = dev.displayName;
409-
if (displayName.length > nameWidth) {
410-
displayName = `${displayName.slice(0, nameWidth - 3)}...`;
411-
}
412-
displayName = displayName.padEnd(nameWidth);
413-
414-
const files = String(dev.files).padStart(6);
415-
const commits = String(dev.commits).padStart(8);
416-
417-
// Format LOC with K suffix if >= 1000
418-
const locStr =
419-
dev.linesOfCode >= 1000 ? `${(dev.linesOfCode / 1000).toFixed(1)}k` : String(dev.linesOfCode);
420-
const loc = locStr.padStart(8);
421-
422-
const lastActive = dev.lastActive ? formatRelativeTime(dev.lastActive) : 'unknown';
423-
424-
// Add extra spacing to match header
425-
output += `${chalk.cyan(displayName)}${extraSpacing} ${chalk.yellow(files)} ${chalk.green(commits)} ${chalk.magenta(loc)} ${chalk.gray(lastActive)}\n`;
426-
427-
// Show top files owned by this developer
428-
if (dev.topFiles.length > 0) {
429-
for (let i = 0; i < dev.topFiles.length; i++) {
430-
const file = dev.topFiles[i];
431-
const isLast = i === dev.topFiles.length - 1;
432-
const prefix = isLast ? '└─' : '├─';
433-
434-
// Calculate file path width to align with columns
435-
// Tree takes 5 chars: " ├─ "
436-
// File path should extend to where FILES column ends, plus 5 extra chars
437-
const filePathWidth = nameWidth + 2 + 6 - 5 + 5;
438-
let filePath = file.path;
439-
if (filePath.length > filePathWidth) {
440-
filePath = `...${filePath.slice(-(filePathWidth - 3))}`;
441-
}
442-
443-
// Format numeric columns to match header (COMMITS=8, LOC=8)
444-
const fileCommits = String(file.commits).padStart(8);
445-
const fileLoc = file.loc >= 1000 ? `${(file.loc / 1000).toFixed(1)}k` : String(file.loc);
446-
const fileLocPadded = fileLoc.padStart(8);
447-
448-
// Align exactly with header columns
449-
output += chalk.dim(
450-
` ${chalk.gray(prefix)} ${filePath.padEnd(filePathWidth)} ${chalk.green(fileCommits)} ${chalk.magenta(fileLocPadded)}\n`
451-
);
452-
}
453-
}
377+
output += chalk.dim(`💡 Tip: ${relevantDevs.length} contributors work in this area\n`);
454378
}
455379

456380
return output;
@@ -478,7 +402,6 @@ function formatRelativeTime(date: Date): string {
478402
export const ownersCommand = new Command('owners')
479403
.description('Show code ownership and developer contributions (context-aware)')
480404
.option('-n, --limit <number>', 'Number of developers to display (default: 10)', '10')
481-
.option('--all', 'Show all contributors (legacy table view)', false)
482405
.option('--json', 'Output as JSON', false)
483406
.action(async (options) => {
484407
try {
@@ -526,30 +449,6 @@ export const ownersCommand = new Command('owners')
526449
return;
527450
}
528451

529-
// Legacy --all mode: show table of all contributors
530-
if (options.all) {
531-
const limit = Number.parseInt(options.limit, 10);
532-
const topDevelopers = developers.slice(0, limit);
533-
534-
console.log('');
535-
console.log(
536-
chalk.bold.cyan(`👥 Developer Contributions (${developers.length} total contributors)`)
537-
);
538-
console.log('');
539-
console.log(formatDeveloperTable(topDevelopers));
540-
console.log('');
541-
542-
const totalFiles = developers.reduce((sum, d) => sum + d.files, 0);
543-
const totalCommits = developers.reduce((sum, d) => sum + d.commits, 0);
544-
545-
console.log(chalk.dim('Summary:'));
546-
console.log(
547-
chalk.dim(` • ${totalFiles} files total, ${totalCommits.toLocaleString()} commits`)
548-
);
549-
console.log('');
550-
return;
551-
}
552-
553452
// Context-aware modes
554453
console.log('');
555454

0 commit comments

Comments
 (0)