DNP_DAPPMANAGER icon indicating copy to clipboard operation
DNP_DAPPMANAGER copied to clipboard

Allow semver ranges

Open dappnodedev opened this issue 6 months ago • 2 comments

This PR refactors the DappGetFetcher class to improve the handling of dependencies and their version ranges. The main improvements include:

  1. 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.
  2. 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.
  3. 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.
  4. 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.

dappnodedev avatar Aug 12 '24 12:08 dappnodedev