dep-brain 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,6 +41,7 @@ dep-brain analyze
41
41
 
42
42
  npx dep-brain analyze
43
43
  npx dep-brain analyze --json
44
+ npx dep-brain analyze --md
44
45
  npx dep-brain analyze ./path-to-project
45
46
  npx dep-brain analyze --config depbrain.config.json
46
47
  npx dep-brain analyze --min-score 90 --fail-on-risks
@@ -90,6 +91,12 @@ Suggestions:
90
91
  dep-brain analyze --json
91
92
  ```
92
93
 
94
+ ## Markdown Output
95
+
96
+ ```bash
97
+ dep-brain analyze --md
98
+ ```
99
+
93
100
  ## Config File
94
101
 
95
102
  Create a `depbrain.config.json` file in the project root:
package/dist/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { analyzeProject } from "./core/analyzer.js";
3
3
  import { renderConsoleReport } from "./reporters/console.js";
4
4
  import { renderJsonReport } from "./reporters/json.js";
5
+ import { renderMarkdownReport } from "./reporters/markdown.js";
5
6
  import { promises as fs } from "node:fs";
6
7
  import path from "node:path";
7
8
  async function main() {
@@ -80,6 +81,9 @@ async function main() {
80
81
  if (flags.has("--json")) {
81
82
  process.stdout.write(`${renderJsonReport(result)}\n`);
82
83
  }
84
+ else if (flags.has("--md")) {
85
+ process.stdout.write(`${renderMarkdownReport(result)}\n`);
86
+ }
83
87
  else {
84
88
  const output = renderConsoleReport(result);
85
89
  if (!output || output.trim().length === 0) {
@@ -144,13 +148,14 @@ function printHelp() {
144
148
  console.log("Dependency Brain");
145
149
  console.log("");
146
150
  console.log("Usage:");
147
- console.log(" dep-brain analyze [path] [--json] [--config path] [--min-score n] [--fail-on-risks] [--fail-on-outdated] [--fail-on-unused] [--fail-on-duplicates]");
151
+ console.log(" dep-brain analyze [path] [--json] [--md] [--config path] [--min-score n] [--fail-on-risks] [--fail-on-outdated] [--fail-on-unused] [--fail-on-duplicates]");
148
152
  console.log(" dep-brain config [path] [--config path]");
149
153
  console.log(" dep-brain help");
150
154
  console.log(" dep-brain --version");
151
155
  console.log("");
152
156
  console.log("Options:");
153
157
  console.log(" --json Output JSON for analysis");
158
+ console.log(" --md Output Markdown report");
154
159
  console.log(" --config <path> Path to depbrain.config.json");
155
160
  console.log(" --min-score <n> Minimum score required to pass");
156
161
  console.log(" --fail-on-risks Fail when risky dependencies exist");
@@ -0,0 +1,2 @@
1
+ import type { AnalysisResult } from "../core/analyzer.js";
2
+ export declare function renderMarkdownReport(result: AnalysisResult): string;
@@ -0,0 +1,52 @@
1
+ export function renderMarkdownReport(result) {
2
+ const lines = [];
3
+ lines.push(`# Dependency Brain Report`);
4
+ lines.push("");
5
+ lines.push(`- **Project Health:** ${result.score}/100`);
6
+ lines.push(`- **Path:** ${result.rootDir}`);
7
+ lines.push(`- **Policy:** ${result.policy.passed ? "PASS" : "FAIL"}`);
8
+ lines.push(`- **Score Breakdown:** base ${result.scoreBreakdown.baseScore} - dup ${result.scoreBreakdown.duplicates} - outdated ${result.scoreBreakdown.outdated} - unused ${result.scoreBreakdown.unused} - risk ${result.scoreBreakdown.risks}`);
9
+ lines.push("");
10
+ if (result.packages && result.packages.length > 0) {
11
+ lines.push("## Packages");
12
+ for (const pkg of result.packages) {
13
+ lines.push(`- ${pkg.name}: ${pkg.score}/100 (D:${pkg.duplicates.length} U:${pkg.unused.length} O:${pkg.outdated.length} R:${pkg.risks.length})`);
14
+ }
15
+ lines.push("");
16
+ }
17
+ lines.push("## Summary");
18
+ lines.push(`- Duplicates: ${result.duplicates.length}`);
19
+ lines.push(`- Unused: ${result.unused.length}`);
20
+ lines.push(`- Outdated: ${result.outdated.length}`);
21
+ lines.push(`- Risks: ${result.risks.length}`);
22
+ lines.push("");
23
+ appendSection(lines, "Duplicate dependencies", result.duplicates.map((item) => `${item.name}: ${item.versions.join(", ")}`));
24
+ appendSection(lines, "Unused dependencies", result.unused.map((item) => item.package
25
+ ? `${item.name} (${item.section}) [${item.package}]`
26
+ : `${item.name} (${item.section})`));
27
+ appendSection(lines, "Outdated dependencies", result.outdated.map((item) => item.package
28
+ ? `${item.name}: ${item.current} -> ${item.latest} [${item.updateType}] [${item.package}]`
29
+ : `${item.name}: ${item.current} -> ${item.latest} [${item.updateType}]`));
30
+ appendSection(lines, "Risky dependencies", result.risks.map((item) => item.package
31
+ ? `${item.name}: ${item.reasons.join("; ")} [${item.package}]`
32
+ : `${item.name}: ${item.reasons.join("; ")}`));
33
+ appendSection(lines, "Policy reasons", result.policy.reasons);
34
+ if (result.suggestions.length > 0) {
35
+ lines.push("## Suggestions");
36
+ for (const suggestion of result.suggestions) {
37
+ lines.push(`- ${suggestion}`);
38
+ }
39
+ lines.push("");
40
+ }
41
+ return lines.join("\n");
42
+ }
43
+ function appendSection(lines, title, items) {
44
+ if (items.length === 0) {
45
+ return;
46
+ }
47
+ lines.push(`## ${title}`);
48
+ for (const item of items) {
49
+ lines.push(`- ${item}`);
50
+ }
51
+ lines.push("");
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dep-brain",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CLI and library for dependency health analysis",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",