Skip to content

Commit

Permalink
Add example to defineExactVersions
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Aug 13, 2024
1 parent 7219cd0 commit 5f39dc4
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions packages/installer/src/dappGet/fetch/DappGetFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,39 @@ export class DappGetFetcher {
}

/**
* Resolves and updates the given dependencies to their exact version by determining the maximum satisfying version.
*
* This method takes a set of dependencies where the version is specified as a semver range and resolves it to the exact
* version that should be installed. It does so by fetching all published versions of each dependency from the APM and
* determining the highest version that satisfies the given semver range.
*
* @param dependencies - An object representing the dependencies where the key is the dependency name and the value is the semver range or version.
* @param dappnodeInstaller - An instance of `DappnodeInstaller` used to fetch published versions from the APM.
* @throws If a semver range is invalid or if no satisfying version can be found for a dependency.
*/
* Resolves and updates the given dependencies to their exact version by determining the maximum satisfying version.
*
* This method takes a set of dependencies where the version is specified as a semver range and resolves it to the exact
* version that should be installed. It does so by fetching all published versions of each dependency from the APM and
* determining the highest version that satisfies the given semver range.
*
* @param dependencies - An object representing the dependencies where the key is the dependency name and the value is the semver range or version.
* @param dappnodeInstaller - An instance of `DappnodeInstaller` used to fetch published versions from the APM.
* @throws If a semver range is invalid or if no satisfying version can be found for a dependency.
*
* @example
* // Given the following dependencies object with semver ranges:
* const dependencies = {
* "example-dnp": "^1.0.0",
* "another-dnp": "2.x",
* "ipfs-dnp": "/ipfs/QmXf2...abc"
* };
*
* // And assuming the following versions are available in the APM:
* // example-dnp: ["1.0.0", "1.1.0", "1.2.0"]
* // another-dnp: ["2.0.0", "2.1.0", "2.5.0"]
* // ipfs-dnp: ["/ipfs/QmXf2...abc"]
*
* // After calling defineExactVersions:
* await defineExactVersions(dependencies, dappnodeInstaller);
*
* // The dependencies object will be updated to:
* // {
* // "example-dnp": "1.2.0", // The highest version satisfying "^1.0.0"
* // "another-dnp": "2.5.0", // The highest version satisfying "2.x"
* // "ipfs-dnp": "/ipfs/QmXf2...abc" // Exact match
* // }
*/
private async defineExactVersions(
dependencies: Dependencies,
dappnodeInstaller: DappnodeInstaller
Expand Down

0 comments on commit 5f39dc4

Please sign in to comment.