Skip to content

Commit

Permalink
Add optional dependencies (#1827)
Browse files Browse the repository at this point in the history
* add optional dependencies

* bump schemas and types deps
  • Loading branch information
pablomendezroyo authored Feb 2, 2024
1 parent ed3b1bd commit ec0215f
Show file tree
Hide file tree
Showing 24 changed files with 62 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dev": "nodemon --ignore \"*.json\" -e ts,tsx --watch src/ --exec \"yarn build\""
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/common": "^0.1.0",
"@dappnode/dappmanager": "^0.1.0",
"@dappnode/eventbus": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/chains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/dockerapi": "^0.1.0",
"@dappnode/logger": "^0.1.0",
"@dappnode/utils": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"lodash-es": "^4.17.21"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/daemons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/upnpc": "^0.1.0",
"@dappnode/db": "^0.1.0",
"@dappnode/dockerapi": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"license": "GPL-3.0",
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/chains": "^0.1.0",
"@dappnode/common": "^0.1.0",
"@dappnode/daemons": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/dockerapi": "^0.1.0",
"@dappnode/dockercompose": "^0.1.0",
"@dappnode/eventbus": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/dockerCompose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/utils": "^0.1.0",
"lodash-es": "^4.17.21"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eventBus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"lodash-es": "^4.17.21"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/hostScriptsServices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/logger": "^0.1.0",
"@dappnode/utils": "^0.1.0",
"memoizee": "0.4.14"
Expand Down
2 changes: 1 addition & 1 deletion packages/httpsPortal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/dockerapi": "^0.1.0",
"@dappnode/dockercompose": "^0.1.0",
"@dappnode/logger": "^0.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/installer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/db": "^0.1.0",
"@dappnode/dockerapi": "^0.1.0",
"@dappnode/dockercompose": "^0.1.0",
Expand All @@ -28,7 +28,7 @@
"@dappnode/httpsportal": "^0.1.0",
"@dappnode/logger": "^0.1.0",
"@dappnode/params": "^0.1.0",
"@dappnode/schemas": "^0.1.12",
"@dappnode/schemas": "^0.1.13",
"@dappnode/toolkit": "^0.1.21",
"@dappnode/utils": "^0.1.0",
"deepmerge": "2.2.1",
Expand Down
19 changes: 19 additions & 0 deletions packages/installer/src/dappGet/fetch/DappGetFetcher.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Dependencies } from "@dappnode/types";
import { validRange, satisfies, valid } from "semver";
import { DappnodeInstaller } from "../../dappnodeInstaller.js";
import { listPackageNoThrow } from "@dappnode/dockerapi";

export class DappGetFetcher {
/**
* Fetches the dependencies of a given DNP name and version
* Injects the optional dependencies if the package is installed
* @returns dependencies:
* { dnp-name-1: "semverRange", dnp-name-2: "/ipfs/Qmf53..."}
*/
Expand All @@ -14,6 +16,23 @@ export class DappGetFetcher {
version: string
): Promise<Dependencies> {
const manifest = await dappnodeInstaller.getManifestFromDir(name, version);
const dependencies = manifest.dependencies || {};

const optionalDependencies = manifest.optionalDependencies;
if (optionalDependencies) {
// Iterate over optional dependencies and inject them if installed
for (const [
optionalDependencyName,
optionalDependencyVersion,
] of Object.entries(optionalDependencies)) {
const optionalDependency = await listPackageNoThrow({
dnpName: optionalDependencyName,
});
if (!optionalDependency) continue;
dependencies[optionalDependencyName] = optionalDependencyVersion;
}
}

return manifest.dependencies || {};
}

Expand Down
2 changes: 0 additions & 2 deletions packages/installer/src/dappnodeInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
IpfsClientTarget,
PackageRelease,
ManifestWithImage,
} from "@dappnode/types";
import {
Compose,
Manifest,
PackageRequest,
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/eventbus": "^0.1.0",
"@dappnode/params": "^0.1.0",
"@dappnode/utils": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/migrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/db": "^0.1.0",
"@dappnode/dockerapi": "^0.1.0",
"@dappnode/dockercompose": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/optimism/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/db": "^0.1.0",
"@dappnode/dockerapi": "^0.1.0",
"@dappnode/dockercompose": "^0.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/schemas/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@dappnode/schemas",
"type": "module",
"version": "0.1.12",
"version": "0.1.13",
"description": "A shared TypeScript JSON schemas and its validation functions for the manifest and setup wizard dappnode files",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -36,7 +36,7 @@
"@types/node": "^20.6.2"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"ajv": "^8.12.0",
"semver": "^7.5.0"
}
Expand Down
20 changes: 20 additions & 0 deletions packages/schemas/src/schemas/manifest.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,26 @@
}
}
},
"optionalDependencies": {
"type": "object",
"description": "DAppNode Package optional dependencies, this means that if installed in dappnode, they will be updated to defined version. Must be an object where the keys are the DAppNode Package's ENS. The values must be a semantic range, i.e. `'0.2.0'`, `'^0.2.1'`, `'*'`, `'latest'`, `'/ipfs/QmWwMb3XhuCH6JnCF6m6EQzA4mW9pHHtg7rqAfhDr2ofi8'`.",
"examples": [
{
"bitcoin.dnp.dappnode.eth": "^0.1.2",
"swarm.dnp.dappnode.eth": "latest"
},
{
"only-for-dev-1.dappnode.eth": "/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o",
"only-for-dev-2.dappnode.eth": "/ipfs/zdj7WWeQ43G6JJvLWQWZpyHuAMq6uYWRjkBXFad11vE2LHhQ7"
}
],
"patternProperties": {
"^(.*)$": {
"type": "string",
"description": "Semantic version range or IPFS / BZZ hash."
}
}
},
"requirements": {
"type": "object",
"description": "Specify requirements to be met before allowing users to install this DAppNode Package.",
Expand Down
2 changes: 1 addition & 1 deletion packages/stakers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/db": "^0.1.0",
"@dappnode/dockerapi": "^0.1.0",
"@dappnode/installer": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"typechain": "^8.3.2"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@ipld/car": "^5.1.1",
"esm": "^3.2.25",
"ethers": "^6.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@dappnode/types",
"type": "module",
"version": "0.1.34",
"version": "0.1.35",
"license": "GPL-3.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface Manifest {
/** "15min" | 3600 */
dockerTimeout?: string;
dependencies?: Dependencies;
optionalDependencies?: Dependencies;
requirements?: {
minimumDappnodeVersion: string;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/upnpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/dockerapi": "^0.1.0",
"@dappnode/utils": "^0.1.0",
"is-ip": "3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"lint": "eslint . --ext .ts --fix src"
},
"dependencies": {
"@dappnode/types": "^0.1.34",
"@dappnode/types": "^0.1.35",
"@dappnode/params": "^0.1.0",
"ajv": "^6.10.2",
"async-retry": "^1.3.1",
Expand Down

0 comments on commit ec0215f

Please sign in to comment.