dep-brain 0.2.0 → 0.3.0

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,16 @@ Suggestions:
90
91
  dep-brain analyze --json
91
92
  ```
92
93
 
94
+ Output includes `outputVersion` for schema stability and can be validated with:
95
+
96
+ - `depbrain.output.schema.json`
97
+
98
+ ## Markdown Output
99
+
100
+ ```bash
101
+ dep-brain analyze --md
102
+ ```
103
+
93
104
  ## Config File
94
105
 
95
106
  Create a `depbrain.config.json` file in the project root:
@@ -140,6 +151,7 @@ Sample config file:
140
151
 
141
152
  - `depbrain.config.json`
142
153
  - `depbrain.config.schema.json`
154
+ - `depbrain.output.schema.json`
143
155
 
144
156
  ## CI Behavior
145
157
 
@@ -0,0 +1,112 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Dependency Brain Analysis Output",
4
+ "type": "object",
5
+ "required": ["outputVersion", "rootDir", "score", "scoreBreakdown", "policy", "duplicates", "unused", "outdated", "risks", "suggestions", "config"],
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "outputVersion": { "type": "string" },
9
+ "rootDir": { "type": "string" },
10
+ "score": { "type": "number" },
11
+ "scoreBreakdown": {
12
+ "type": "object",
13
+ "required": ["baseScore", "duplicates", "outdated", "unused", "risks", "weights"],
14
+ "additionalProperties": false,
15
+ "properties": {
16
+ "baseScore": { "type": "number" },
17
+ "duplicates": { "type": "number" },
18
+ "outdated": { "type": "number" },
19
+ "unused": { "type": "number" },
20
+ "risks": { "type": "number" },
21
+ "weights": {
22
+ "type": "object",
23
+ "required": ["duplicateWeight", "outdatedWeight", "unusedWeight", "riskWeight"],
24
+ "additionalProperties": false,
25
+ "properties": {
26
+ "duplicateWeight": { "type": "number" },
27
+ "outdatedWeight": { "type": "number" },
28
+ "unusedWeight": { "type": "number" },
29
+ "riskWeight": { "type": "number" }
30
+ }
31
+ }
32
+ }
33
+ },
34
+ "policy": {
35
+ "type": "object",
36
+ "required": ["passed", "reasons"],
37
+ "additionalProperties": false,
38
+ "properties": {
39
+ "passed": { "type": "boolean" },
40
+ "reasons": { "type": "array", "items": { "type": "string" } }
41
+ }
42
+ },
43
+ "duplicates": {
44
+ "type": "array",
45
+ "items": {
46
+ "type": "object",
47
+ "required": ["name", "versions", "instances"],
48
+ "additionalProperties": false,
49
+ "properties": {
50
+ "name": { "type": "string" },
51
+ "versions": { "type": "array", "items": { "type": "string" } },
52
+ "instances": {
53
+ "type": "array",
54
+ "items": {
55
+ "type": "object",
56
+ "required": ["path", "version"],
57
+ "additionalProperties": false,
58
+ "properties": {
59
+ "path": { "type": "string" },
60
+ "version": { "type": "string" }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ },
67
+ "unused": {
68
+ "type": "array",
69
+ "items": {
70
+ "type": "object",
71
+ "required": ["name", "section"],
72
+ "additionalProperties": false,
73
+ "properties": {
74
+ "name": { "type": "string" },
75
+ "section": { "type": "string", "enum": ["dependencies", "devDependencies"] },
76
+ "package": { "type": "string" }
77
+ }
78
+ }
79
+ },
80
+ "outdated": {
81
+ "type": "array",
82
+ "items": {
83
+ "type": "object",
84
+ "required": ["name", "current", "latest", "updateType"],
85
+ "additionalProperties": false,
86
+ "properties": {
87
+ "name": { "type": "string" },
88
+ "current": { "type": "string" },
89
+ "latest": { "type": "string" },
90
+ "updateType": { "type": "string" },
91
+ "package": { "type": "string" }
92
+ }
93
+ }
94
+ },
95
+ "risks": {
96
+ "type": "array",
97
+ "items": {
98
+ "type": "object",
99
+ "required": ["name", "reasons"],
100
+ "additionalProperties": false,
101
+ "properties": {
102
+ "name": { "type": "string" },
103
+ "reasons": { "type": "array", "items": { "type": "string" } },
104
+ "package": { "type": "string" }
105
+ }
106
+ }
107
+ },
108
+ "suggestions": { "type": "array", "items": { "type": "string" } },
109
+ "config": { "type": "object" },
110
+ "packages": { "type": "array" }
111
+ }
112
+ }
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");
@@ -31,6 +31,7 @@ export interface RiskDependency {
31
31
  package?: string;
32
32
  }
33
33
  export interface AnalysisResult {
34
+ outputVersion: string;
34
35
  rootDir: string;
35
36
  score: number;
36
37
  scoreBreakdown: ScoreBreakdown;
@@ -59,6 +60,7 @@ export interface PackageAnalysisResult {
59
60
  risks: RiskDependency[];
60
61
  suggestions: string[];
61
62
  }
63
+ export declare const OUTPUT_VERSION = "1.0";
62
64
  export interface ScoreBreakdown {
63
65
  baseScore: number;
64
66
  duplicates: number;
@@ -7,6 +7,7 @@ import { loadDepBrainConfig } from "../utils/config.js";
7
7
  import { findWorkspacePackages } from "../utils/workspaces.js";
8
8
  import { buildDependencyGraph } from "./graph-builder.js";
9
9
  import { calculateHealthScore } from "./scorer.js";
10
+ export const OUTPUT_VERSION = "1.0";
10
11
  export async function analyzeProject(options = {}) {
11
12
  const rootDir = path.resolve(options.rootDir ?? process.cwd());
12
13
  const loadedConfig = await loadDepBrainConfig(rootDir, options.configPath);
@@ -55,6 +56,7 @@ export async function analyzeProject(options = {}) {
55
56
  risks: risks.length
56
57
  }, config);
57
58
  return {
59
+ outputVersion: OUTPUT_VERSION,
58
60
  rootDir,
59
61
  score,
60
62
  scoreBreakdown,
@@ -172,6 +174,7 @@ async function analyzeSingleProject(rootDir, config, options = {}) {
172
174
  ? risks.map((item) => ({ ...item, package: options.packageName }))
173
175
  : risks;
174
176
  return {
177
+ outputVersion: OUTPUT_VERSION,
175
178
  rootDir,
176
179
  score,
177
180
  scoreBreakdown,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { analyzeProject } from "./core/analyzer.js";
2
2
  export type { AnalysisOptions, AnalysisResult, DuplicateDependency, OutdatedDependency, PolicyResult, PackageAnalysisResult, ScoreBreakdown, RiskDependency, UnusedDependency } from "./core/analyzer.js";
3
+ export { OUTPUT_VERSION } from "./core/analyzer.js";
3
4
  export type { DepBrainConfig, DepBrainConfigOverrides } from "./utils/config.js";
4
5
  export type { WorkspacePackage } from "./utils/workspaces.js";
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { analyzeProject } from "./core/analyzer.js";
2
+ export { OUTPUT_VERSION } from "./core/analyzer.js";
@@ -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.3.0",
4
4
  "description": "CLI and library for dependency health analysis",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -14,7 +14,8 @@
14
14
  "LICENSE",
15
15
  "CHANGELOG.md",
16
16
  "depbrain.config.json",
17
- "depbrain.config.schema.json"
17
+ "depbrain.config.schema.json",
18
+ "depbrain.output.schema.json"
18
19
  ],
19
20
  "scripts": {
20
21
  "build": "tsc -p tsconfig.json",