(stats: StatsFileResult, options: StatsOptions)
| 50 | } |
| 51 | |
| 52 | function outputStats(stats: StatsFileResult, options: StatsOptions): void { |
| 53 | if (options.output === 'json') { |
| 54 | outputJson(stats) |
| 55 | return |
| 56 | } |
| 57 | |
| 58 | const c = getChalk() |
| 59 | |
| 60 | // Text output |
| 61 | output(c.bold.cyan(stats.projectName)) |
| 62 | output(c.dim(`Project ID: ${stats.projectId}`)) |
| 63 | output('') |
| 64 | |
| 65 | // Summary |
| 66 | output(c.bold('Summary')) |
| 67 | output(` ${c.dim('Notebooks:')} ${stats.notebookCount}`) |
| 68 | output(` ${c.dim('Total Blocks:')} ${stats.totalBlocks}`) |
| 69 | output(` ${c.dim('Lines of Code:')} ${stats.totalLinesOfCode}`) |
| 70 | output('') |
| 71 | |
| 72 | // Block types |
| 73 | if (stats.blockTypesSummary.length > 0) { |
| 74 | output(c.bold('Block Types')) |
| 75 | for (const bt of stats.blockTypesSummary) { |
| 76 | const locStr = bt.linesOfCode > 0 ? ` (${bt.linesOfCode} LOC)` : '' |
| 77 | output(` ${c.dim(`${bt.type}:`)} ${bt.count}${c.dim(locStr)}`) |
| 78 | } |
| 79 | output('') |
| 80 | } |
| 81 | |
| 82 | // Imports |
| 83 | if (stats.imports.length > 0) { |
| 84 | output(c.bold('Imports')) |
| 85 | output(` ${stats.imports.join(', ')}`) |
| 86 | output('') |
| 87 | } |
| 88 | |
| 89 | // Notebooks breakdown |
| 90 | if (stats.notebooks.length > 1 || options.notebook) { |
| 91 | output(c.bold('Notebooks')) |
| 92 | for (const nb of stats.notebooks) { |
| 93 | output(` ${c.cyan(nb.name)}`) |
| 94 | output(` ${c.dim('Blocks:')} ${nb.blockCount}`) |
| 95 | output(` ${c.dim('Lines of Code:')} ${nb.linesOfCode}`) |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | function handleError(error: unknown, options: StatsOptions): never { |
| 101 | const message = error instanceof Error ? error.message : String(error) |
no test coverage detected