Dep-Solver is a Node.js module designed to resolve dependencies between packages or modules within a project. It utilizes a topological sorting algorithm to determine the order in which modules should be loaded or executed, ensuring that all dependencies are satisfied before a module is run. Additionally, it provides functionality to build and visualize dependency graphs, aiding in the management and troubleshooting of project dependencies.
- Dependency Resolution: Efficiently resolve package dependencies to determine a safe load order.
- Cycle Detection: Identify and report circular dependencies that could lead to runtime errors.
- Visualization: Generate a visual representation of the dependency graph (feature planned).
- Node.js (version 12.x or higher recommended)
Clone the repository to your local machine:
git clone https://github.com/yourusername/dep-solver.git
cd dep-solver
Install the required dependencies:
npm install
To use the dep-solver in your project, first import the module:
const { getRelatedPackages, findOrder } = require('./dependencyResolver');
Then, you can use it to resolve dependencies and determine the load order:
const packages = [
// Define your packages and dependencies here
];
const dependencies = getRelatedPackages(packages);
const order = findOrder(dependencies);
console.log(order); // Outputs the load order of the packages
To run the tests and ensure the module is working as expected, execute:
npm test