@dependency-maritime/cli 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +129 -0
- package/dist/cli/cli/analyze/adapters.d.ts +32 -0
- package/dist/cli/cli/analyze/calculate-metrics.d.ts +6 -0
- package/dist/cli/cli/analyze/environment.d.ts +10 -0
- package/dist/cli/cli/analyze/models.d.ts +47 -0
- package/dist/cli/cli/analyze/parse-eslint.d.ts +2 -0
- package/dist/cli/cli/analyze/render-markdown-report.d.ts +2 -0
- package/dist/cli/cli/commands/analyze.d.ts +1 -0
- package/dist/cli/cli/commands/validate.d.ts +1 -0
- package/dist/cli/cli/index.d.ts +25 -0
- package/dist/cli/cli/main.d.ts +1 -0
- package/dist/cli/cli/validate/validate.d.ts +10 -0
- package/dist/cli/index.d.ts +25 -0
- package/dist/cli/index.js +1197 -0
- package/dist/cli/main.js +1172 -0
- package/dist/cli/schema/complexity-metrics.d.ts +18 -0
- package/dist/cli/schema/dependency-cruiser.d.ts +180 -0
- package/dist/cli/schema/manifest.d.ts +33 -0
- package/package.json +109 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 g1ddy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Dependency Maritime ⚓️
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
**Chart, navigate, and refactor your application's architecture.**
|
|
10
|
+
|
|
11
|
+
Dependency Maritime is an interactive visualization tool for [dependency-cruiser](https://github.com/sverweij/dependency-cruiser). It transforms complex dependency graphs into navigable, interactive maps, helping you enforce boundaries, identify tangles, and plan refactoring efforts.
|
|
12
|
+
|
|
13
|
+
## 📸 Visuals
|
|
14
|
+
|
|
15
|
+
### Interactive Dashboard
|
|
16
|
+
Visualize your project's structure with an interactive graph. Zoom, pan, and filter to understand relationships.
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
### Node Inspector
|
|
20
|
+
Select any file to view detailed metrics, including incoming and outgoing dependencies.
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
### Bring Your Own Data
|
|
24
|
+
Easily upload your own `dependency-cruiser` JSON output to visualize your codebase.
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
## ✨ Features
|
|
28
|
+
|
|
29
|
+
* **Interactive Visualization:** Zoom, pan, and drag nodes to explore your architecture.
|
|
30
|
+
* **Deep Inspection:** Click any node to see its full path, metrics, and direct neighbors.
|
|
31
|
+
* **Dependency Filtering:** Toggle between "Product" and "Test" code (planned) or specific folders.
|
|
32
|
+
* **Isolate Modules:** Focus on specific sub-graphs to declutter the view.
|
|
33
|
+
* **Metrics (Phase 2):** Analyze instability, centrality, and **Cyclomatic Complexity & Lines of Code (LOC)**.
|
|
34
|
+
* **Compound Health Score:** Automatically assesses node health (Healthy, Warning, Unhealthy) based on a compound formula combining LOC, Complexity, Fan-Out, and Instability.
|
|
35
|
+
* **100% Client-Side:** Your code structure is analyzed locally; no data leaves your machine.
|
|
36
|
+
|
|
37
|
+
## 🛠 Installation
|
|
38
|
+
|
|
39
|
+
1. **Clone the repository:**
|
|
40
|
+
```bash
|
|
41
|
+
git clone https://github.com/your-username/dependency-maritime.git
|
|
42
|
+
cd dependency-maritime
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
2. **Install dependencies:**
|
|
46
|
+
```bash
|
|
47
|
+
npm install
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
3. **Start the development server:**
|
|
51
|
+
```bash
|
|
52
|
+
npm run dev
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 🚀 Usage
|
|
56
|
+
|
|
57
|
+
### 1. Generating a Dependency Graph
|
|
58
|
+
To visualize your own project, you need to generate a JSON report using `dependency-cruiser`.
|
|
59
|
+
|
|
60
|
+
Run the following command in the root of the project you want to analyze:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx dependency-cruiser src \
|
|
64
|
+
--include-only "^src" \
|
|
65
|
+
--output-type json \
|
|
66
|
+
> dependency-graph.json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
*Adjust the `src` and `--include-only` patterns to match your project structure.*
|
|
70
|
+
|
|
71
|
+
#### Integrating Complexity Metrics (Optional)
|
|
72
|
+
To view Cyclomatic Complexity and LOC in the Node Inspector, generate a metrics file using the provided script (if available in your project) or construct a JSON map matching the schema:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"src/App.tsx": { "complexity": 5, "loc": 120 },
|
|
77
|
+
"src/utils.ts": { "complexity": 2, "loc": 45 }
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The built-in **Project Graph** loads the validated `.maritime/dependency-graph.json` and `.maritime/complexity-metrics.json` artifacts generated by the repository workflow. Uploaded graphs may optionally include a metrics map using this same schema.
|
|
82
|
+
|
|
83
|
+
#### Compound Score & Health Status
|
|
84
|
+
The application calculates a **Compound Complexity Score** for each node to determine its health status:
|
|
85
|
+
|
|
86
|
+
**Formula:**
|
|
87
|
+
`Score = (LOC / 10) + (Complexity * 2) + (FanOut * 2) + (Instability * 20)`
|
|
88
|
+
|
|
89
|
+
**Health Thresholds:**
|
|
90
|
+
* 🟢 **Healthy:** Score < 20
|
|
91
|
+
* 🟡 **Warning:** Score between 20 and 50
|
|
92
|
+
* 🔴 **Unhealthy:** Score > 50
|
|
93
|
+
|
|
94
|
+
Nodes will visually reflect their status with colored borders and backgrounds.
|
|
95
|
+
|
|
96
|
+
### 2. Loading Data
|
|
97
|
+
1. Open **Dependency Maritime** in your browser (default: `http://localhost:5173`).
|
|
98
|
+
2. Click the **Upload** icon (cloud/arrow) in the header.
|
|
99
|
+
3. Drag and drop your `dependency-graph.json` file or click to select it.
|
|
100
|
+
4. The graph will automatically render your data.
|
|
101
|
+
|
|
102
|
+
## 🏗 Architecture & Phases
|
|
103
|
+
|
|
104
|
+
The project is being built in 4 phases:
|
|
105
|
+
1. **Phase 1: The "Chartroom" (MVP)** - Core visualization (Complete).
|
|
106
|
+
2. **Phase 2: The "Inspector"** - Metrics and health heatmaps (In Progress).
|
|
107
|
+
3. **Phase 3: The "Simulator"** - Refactoring playground.
|
|
108
|
+
4. **Phase 4: The "Cohesion" Assistant** - AI-assisted suggestions.
|
|
109
|
+
|
|
110
|
+
For more details, check out the documentation:
|
|
111
|
+
* [Architecture](./docs/ARCHITECTURE.md)
|
|
112
|
+
* [CLI and Artifact Contract](./docs/CLI.md)
|
|
113
|
+
* [Roadmap](./docs/ROADMAP.md)
|
|
114
|
+
* [Development Guide](./docs/DEVELOPMENT.md)
|
|
115
|
+
* [Design Decisions](./docs/DESIGN_DECISIONS.md)
|
|
116
|
+
|
|
117
|
+
## 🤝 Contributing
|
|
118
|
+
|
|
119
|
+
This project uses **npm** for package management. Please ensure you lock files are updated accordingly.
|
|
120
|
+
|
|
121
|
+
1. Fork the repo.
|
|
122
|
+
2. Create a feature branch.
|
|
123
|
+
3. Commit your changes.
|
|
124
|
+
4. Push to the branch.
|
|
125
|
+
5. Create a Pull Request.
|
|
126
|
+
|
|
127
|
+
## 📝 License
|
|
128
|
+
|
|
129
|
+
Distributed under the MIT License.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type DependencyCruiserModule, type EslintResult } from './models';
|
|
2
|
+
export interface ResolvedDepcruiseConfig {
|
|
3
|
+
config: Record<string, unknown>;
|
|
4
|
+
configPath: string | null;
|
|
5
|
+
source: 'explicit' | 'discovered' | 'fallback';
|
|
6
|
+
}
|
|
7
|
+
export declare function getPortableFallbackConfig(cwd?: string): {
|
|
8
|
+
options: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
export declare function resolveDepcruiseConfig(configPath?: string, cwd?: string): Promise<ResolvedDepcruiseConfig>;
|
|
11
|
+
export interface GenerateDependencyGraphOptions {
|
|
12
|
+
sourceRoots: string[];
|
|
13
|
+
configPath?: string;
|
|
14
|
+
cwd?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface GenerateDependencyGraphResult {
|
|
17
|
+
cruiseResult: unknown;
|
|
18
|
+
modules: DependencyCruiserModule[];
|
|
19
|
+
configSource: 'explicit' | 'discovered' | 'fallback';
|
|
20
|
+
}
|
|
21
|
+
export declare function generateDependencyGraph(options: GenerateDependencyGraphOptions): Promise<GenerateDependencyGraphResult>;
|
|
22
|
+
export declare function readDependencyGraph(graphPath: string, cwd?: string): Promise<DependencyCruiserModule[]>;
|
|
23
|
+
export declare function runEslintComplexityScan(sourcePath: string | string[], sourceFiles?: string[], cwd?: string): Promise<EslintResult[]>;
|
|
24
|
+
export declare function countLinesOfCode(sourceFiles: string[], cwd?: string): Promise<Record<string, number>>;
|
|
25
|
+
export declare function getToolVersion(): string;
|
|
26
|
+
export declare function writeOutputFiles(metricsPath: string, metricsData: unknown, reportPath: string, reportData: string, cwd?: string): Promise<void>;
|
|
27
|
+
export declare function writeOutputFiles(metricsPath: string, metricsData: unknown, reportPath: string, reportData: string, options?: {
|
|
28
|
+
manifestPath?: string;
|
|
29
|
+
manifestData?: unknown;
|
|
30
|
+
cwd?: string;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
export declare function writeOutputFiles(metricsPath: string, metricsData: unknown, reportPath: string, reportData: string, manifestPath?: string, manifestData?: unknown, cwd?: string): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FileMetric, AnalysisThresholds, AnalysisResult, DependencyCruiserModule, EslintFileComplexity } from './models';
|
|
2
|
+
export declare function isSupportedTypeScriptFile(filepath: string): boolean;
|
|
3
|
+
export declare function calculateInstability(fanIn: number, fanOut: number): number;
|
|
4
|
+
export declare function calculateScore(loc: number, complexity: number, fanOut: number, instability: number): number;
|
|
5
|
+
export declare function calculateHealthScore(files: FileMetric[], thresholds: AnalysisThresholds): number;
|
|
6
|
+
export declare function calculateMetrics(modules: DependencyCruiserModule[], locMap: Record<string, number>, complexityMap: Record<string, EslintFileComplexity | number>, thresholds: AnalysisThresholds, sourcePrefix?: string | string[]): AnalysisResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function validateNodeVersion(nodeVersionStr?: string): void;
|
|
2
|
+
export declare function detectEslintConfig(cwd?: string): {
|
|
3
|
+
mode: string;
|
|
4
|
+
isLegacy: boolean;
|
|
5
|
+
hasFlatConfig: boolean;
|
|
6
|
+
legacyFile?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function validateEslintEnvironment(cwd?: string, nodeVersionStr?: string): {
|
|
9
|
+
mode: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface FileMetric {
|
|
2
|
+
file: string;
|
|
3
|
+
loc: number;
|
|
4
|
+
complexity: number;
|
|
5
|
+
fanIn: number;
|
|
6
|
+
fanOut: number;
|
|
7
|
+
instability: number;
|
|
8
|
+
score: number;
|
|
9
|
+
scanned: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface AnalysisThresholds {
|
|
12
|
+
loc: number;
|
|
13
|
+
complexity: number;
|
|
14
|
+
fanOut: number;
|
|
15
|
+
instabilityMin?: number;
|
|
16
|
+
instabilityMax?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface AnalysisResult {
|
|
19
|
+
files: FileMetric[];
|
|
20
|
+
healthScore: number;
|
|
21
|
+
topByScore: FileMetric[];
|
|
22
|
+
topByComplexity: FileMetric[];
|
|
23
|
+
skippedCount: number;
|
|
24
|
+
unmeasuredFiles: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface EslintMessage {
|
|
27
|
+
ruleId: string;
|
|
28
|
+
message: string;
|
|
29
|
+
fatal?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface EslintResult {
|
|
32
|
+
filePath: string;
|
|
33
|
+
messages: EslintMessage[];
|
|
34
|
+
ignored?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface EslintFileComplexity {
|
|
37
|
+
complexity: number;
|
|
38
|
+
scanned: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface DependencyCruiserModule {
|
|
41
|
+
source: string;
|
|
42
|
+
dependencies: unknown[];
|
|
43
|
+
dependents: unknown[];
|
|
44
|
+
}
|
|
45
|
+
export declare class ValidationError extends Error {
|
|
46
|
+
constructor(message: string);
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runAnalyzeCommand(args: string[]): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runValidateCommand(args: string[]): Promise<number>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { runAnalyzeCommand } from './commands/analyze';
|
|
2
|
+
import { runValidateCommand } from './commands/validate';
|
|
3
|
+
import { validateArtifacts } from './validate/validate';
|
|
4
|
+
export { runAnalyzeCommand, runValidateCommand, validateArtifacts };
|
|
5
|
+
export * from '../schema/manifest';
|
|
6
|
+
export { readDependencyGraph, resolveDepcruiseConfig, generateDependencyGraph, runEslintComplexityScan, countLinesOfCode, writeOutputFiles } from './analyze/adapters';
|
|
7
|
+
export { calculateMetrics, isSupportedTypeScriptFile, calculateInstability, calculateScore, calculateHealthScore } from './analyze/calculate-metrics';
|
|
8
|
+
export { parseEslintComplexityReport } from './analyze/parse-eslint';
|
|
9
|
+
export { renderMarkdownReport } from './analyze/render-markdown-report';
|
|
10
|
+
export { validateEslintEnvironment, validateNodeVersion, detectEslintConfig } from './analyze/environment';
|
|
11
|
+
export * from './analyze/models';
|
|
12
|
+
export declare function analyzeProject(options: {
|
|
13
|
+
graph?: string;
|
|
14
|
+
metrics?: string;
|
|
15
|
+
report?: string;
|
|
16
|
+
output?: string;
|
|
17
|
+
depcruiseConfig?: string;
|
|
18
|
+
source?: string | string[];
|
|
19
|
+
cwd?: string;
|
|
20
|
+
failOnUnmeasured?: boolean;
|
|
21
|
+
}): Promise<number>;
|
|
22
|
+
export declare function validateProject(options?: {
|
|
23
|
+
artifactDir?: string;
|
|
24
|
+
cwd?: string;
|
|
25
|
+
}): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ArtifactManifest } from '../../schema/manifest';
|
|
2
|
+
export interface ValidateArtifactsOptions {
|
|
3
|
+
artifactDir?: string;
|
|
4
|
+
cwd?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ValidateArtifactsResult {
|
|
7
|
+
manifest: ArtifactManifest;
|
|
8
|
+
artifactDir: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function validateArtifacts(options?: ValidateArtifactsOptions): Promise<ValidateArtifactsResult>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { runAnalyzeCommand } from './commands/analyze';
|
|
2
|
+
import { runValidateCommand } from './commands/validate';
|
|
3
|
+
import { validateArtifacts } from './validate/validate';
|
|
4
|
+
export { runAnalyzeCommand, runValidateCommand, validateArtifacts };
|
|
5
|
+
export * from '../schema/manifest';
|
|
6
|
+
export { readDependencyGraph, resolveDepcruiseConfig, generateDependencyGraph, runEslintComplexityScan, countLinesOfCode, writeOutputFiles } from './analyze/adapters';
|
|
7
|
+
export { calculateMetrics, isSupportedTypeScriptFile, calculateInstability, calculateScore, calculateHealthScore } from './analyze/calculate-metrics';
|
|
8
|
+
export { parseEslintComplexityReport } from './analyze/parse-eslint';
|
|
9
|
+
export { renderMarkdownReport } from './analyze/render-markdown-report';
|
|
10
|
+
export { validateEslintEnvironment, validateNodeVersion, detectEslintConfig } from './analyze/environment';
|
|
11
|
+
export * from './analyze/models';
|
|
12
|
+
export declare function analyzeProject(options: {
|
|
13
|
+
graph?: string;
|
|
14
|
+
metrics?: string;
|
|
15
|
+
report?: string;
|
|
16
|
+
output?: string;
|
|
17
|
+
depcruiseConfig?: string;
|
|
18
|
+
source?: string | string[];
|
|
19
|
+
cwd?: string;
|
|
20
|
+
failOnUnmeasured?: boolean;
|
|
21
|
+
}): Promise<number>;
|
|
22
|
+
export declare function validateProject(options?: {
|
|
23
|
+
artifactDir?: string;
|
|
24
|
+
cwd?: string;
|
|
25
|
+
}): Promise<number>;
|