node-dep-resolver 1.0.0 → 1.1.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.
Files changed (2) hide show
  1. package/README.md +117 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # node-dep-resolver
2
+
3
+ > A lightweight, transparent JavaScript dependency graph builder and semver conflict resolution engine with backtracking search.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/node-dep-resolver.svg)](https://www.npmjs.com/package/node-dep-resolver)
6
+ [![license](https://img.shields.io/npm/l/node-dep-resolver.svg)](https://github.com/unknownsideofme/dependency-resolver/blob/main/LICENSE)
7
+
8
+ `node-dep-resolver` analyzes package dependencies, constructs visual dependency trees, highlights version conflicts across transitive packages, and uses a backtracking algorithm to find compatible resolution trees.
9
+
10
+ ---
11
+
12
+ ## Features
13
+
14
+ - **Dependency Graph Visualization**: Recursively traces root and transitive dependencies, rendering clear ASCII tree structures.
15
+ - **Semver Conflict Detection**: Identifies overlapping or incompatible version constraints requested across different packages.
16
+ - **Backtracking Resolution Engine**: Evaluates alternative candidate package versions to automatically resolve conflicts.
17
+ - **CLI & Programmatic Library**: Use instantly via `npx node-dep-resolver` or import into Node.js ES Module projects.
18
+ - **Native Unit Testing**: High-reliability codebase verified using Node.js native `node:test` framework.
19
+
20
+ ---
21
+
22
+ ## Installation & CLI Usage
23
+
24
+ You can run the CLI directly on any `package.json` file without installing:
25
+
26
+ ```bash
27
+ npx node-dep-resolver ./package.json
28
+ ```
29
+
30
+ Or install it globally:
31
+
32
+ ```bash
33
+ npm install -g node-dep-resolver
34
+ dep-resolver ./package.json
35
+ ```
36
+
37
+ ### CLI Output Preview
38
+
39
+ ```text
40
+ [INFO] Analyzing dependencies from './package.json'...
41
+
42
+ --- Building Dependency Graph ---
43
+ express@4.18.2
44
+ └── accept-hosts ^1.3.8
45
+ └── send 0.18.0
46
+
47
+ ms [CONFLICT]
48
+ └── requested 2.1.3 by send@0.18.0
49
+ └── requested 2.0.0 by debug@2.6.9
50
+
51
+ [WARNING] Conflicts detected in 2 package(s): ms, debug
52
+
53
+ --- Resolving Conflicts ---
54
+ Starting resolution...
55
+
56
+ [SUCCESS] Valid dependency tree found.
57
+
58
+ ========== RESOLVED DEPENDENCY SOLUTION ==========
59
+
60
+ [OK] express@4.18.2
61
+ [OK] express-rate-limit@7.5.0
62
+ [OK] axios@1.20.0
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Programmatic Usage (Node.js / ESM)
68
+
69
+ Install as a dependency in your Node.js project:
70
+
71
+ ```bash
72
+ npm install node-dep-resolver
73
+ ```
74
+
75
+ ### Resolving Dependencies Programmatically
76
+
77
+ ```javascript
78
+ import Resolver, { Registry, Graph } from "node-dep-resolver";
79
+
80
+ const rootDependencies = {
81
+ "express": "4.18.2",
82
+ "express-rate-limit": "7.5.0",
83
+ "axios": "^1.7.0"
84
+ };
85
+
86
+ // 1. Resolve conflicts
87
+ const resolver = new Resolver(rootDependencies);
88
+ const solution = await resolver.resolve();
89
+
90
+ for (const [packageName, data] of solution) {
91
+ console.log(`${packageName}@${data.version}`);
92
+ }
93
+
94
+ // 2. Fetch registry metadata
95
+ const registry = new Registry();
96
+ const resolvedVersion = await registry.resolveVersion("axios", "^1.0.0");
97
+ console.log(`Resolved axios version: ${resolvedVersion}`);
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Architecture
103
+
104
+ Built with a modular, Object-Oriented design:
105
+
106
+ - **`Registry`**: Manages NPM registry HTTP requests and caches package version metadata.
107
+ - **`Constraint`**: Tracks requested Semver ranges per dependency and detects overlaps.
108
+ - **`Conflict`**: Maintains state sets of active dependency conflicts.
109
+ - **`Candidates`**: Generates candidate alternative versions for conflicting transitive dependencies.
110
+ - **`Graph`**: Constructs and formats dependency hierarchy trees.
111
+ - **`Resolver`**: Orchestrates state snapshots and backtracking resolution search.
112
+
113
+ ---
114
+
115
+ ## License
116
+
117
+ MIT (c) [debanjan](https://github.com/unknownsideofme/dependency-resolver)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-dep-resolver",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "A lightweight CLI tool & library to build dependency graphs and resolve semver conflicts.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -36,4 +36,4 @@
36
36
  "axios": "^1.7.0",
37
37
  "semver": "^7.6.0"
38
38
  }
39
- }
39
+ }