DNP_DAPPMANAGER
DNP_DAPPMANAGER copied to clipboard
Allow semver ranges
This PR refactors the DappGetFetcher
class to improve the handling of dependencies and their version ranges. The main improvements include:
-
Separation of Concerns:
- The
processDependencies
method was introduced to handle two main responsibilities:- Filtering out dependencies that are already satisfied by installed packages.
- Parsing and converting semver ranges to appropriate APM-compatible versions.
- The
-
Improved Optional Dependencies Handling:
- A new
mergeOptionalDependencies
method was introduced to inject optional dependencies into the main dependencies object only if the corresponding packages are installed.
- A new
-
Enhanced Semver Range Handling:
- The
parseSemverRangeToApmVersion
method was created to convert semver ranges like^x.x.x
,~x.x.x
,>x.x.x
, and>=x.x.x
to appropriate APM-compatible versions or the latest version (*
) if applicable. - Added checks to ensure that only simple version ranges are supported, throwing errors for complex or combined ranges.
- The
-
Code Readability and Maintainability:
- The code was refactored to be more modular and easier to understand, with clear method responsibilities and added inline documentation.
- Methods were renamed and reorganized for clarity, following best practices.