About this project

pnpm-multi-versions is a utility tool designed to scan a pnpm lockfile and identify dependencies that are installed in multiple versions within a project. It provides both a Command Line Interface (CLI) and a JavaScript API for flexible integration. ### CLI Usage Running the CLI outputs a list of packages with multiple versions installed. Users can use the `--dependents` flag to display a tree-like visualization showing which specific packages depend on each version of the duplicated dependency. ### API Usage Programmatically, the tool exposes a function that takes a parsed lockfile and configuration options. Key options include: - `ignoreMajor`: Boolean to ignore major version differences. - `dependents`: Boolean to compute and map dependents for each version. The API returns three main data structures: - `versionsMap`: A Map mapping package names to a Set of installed versions. - `dependentsMap`: A nested Map showing which packages (with specific versions) depend on each version of the target packages. - `multipleVersions`: A Set containing the names of all packages that have multiple versions installed. This helps developers identify duplicate dependency versions in pnpm-managed projects, aiding in optimization and cleanup efforts.