Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions packages/dappmanager/src/api/routes/packageManifest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { pick } from "lodash-es";
import { listPackage } from "@dappnode/dockerapi";
import { readManifestIfExists } from "@dappnode/utils";
import { wrapHandler } from "../utils.js";
import { listPackage } from "@dappnode/dockerapi";
interface Params {
dnpName: string;
}
Expand All @@ -13,11 +13,15 @@ export const packageManifest = wrapHandler<Params>(async (req, res) => {
const { dnpName } = req.params;
if (!dnpName) throw Error(`Must provide containerName`);

const dnp = await listPackage({ dnpName });
const manifest = readManifestIfExists(dnp);
if (!manifest) {
return res.status(404).send("Manifest not found");
}
const manifest = readManifestIfExists(dnpName);
if (!manifest) return res.status(404).send("Manifest not found");

// This is a temporary fix to get the avatarUrl from the package list
// Intaller now sets avatarUrl in the manifest. See `dappnodeInstaller` > `joinFilesInManifest`
// TODO: This setter should be removed once users have updated their packages
if(!manifest.avatarUrl)
manifest.avatarUrl = (await listPackage({dnpName})).avatarUrl


// Filter manifest manually to not send new private properties
const filteredManifest = pick(manifest, [
Expand Down Expand Up @@ -55,7 +59,8 @@ export const packageManifest = wrapHandler<Params>(async (req, res) => {
"repository",
"bugs",
"license",
"notifications"
"notifications",
"avatarUrl"
]);

res.status(200).send(filteredManifest);
Expand Down
2 changes: 1 addition & 1 deletion packages/httpsPortal/src/exposable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { parseExposableServiceManifest } from "./parseExposable.js";
const getExposableServicesByDnpMemo = memoizee(
function getExposableServicesByDnp(dnp: InstalledPackageData): ExposableServiceInfo[] | null {
// Read disk
const manifest = readManifestIfExists(dnp);
const manifest = readManifestIfExists(dnp.dnpName);
return manifest?.exposable ? parseExposableServiceManifest(dnp, manifest.exposable) : null;
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/installer/src/calls/packageGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function packageGet({ dnpName }: { dnpName: string }): Promise<Inst

// Add non-blocking data
try {
const manifest = readManifestIfExists(dnp);
const manifest = readManifestIfExists(dnp.dnpName);
if (manifest) {
// Append manifest for general info
dnpData.manifest = omit(manifest, ["setupWizard", "gettingStarted", "backup"]);
Expand Down
13 changes: 9 additions & 4 deletions packages/installer/src/dappnodeInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DappGetState, DappgetOptions, dappGet } from "./dappGet/index.js";
import { validateDappnodeCompose, validateManifestSchema } from "@dappnode/schemas";
import { ComposeEditor, setDappnodeComposeDefaults, writeMetadataToLabels } from "@dappnode/dockercompose";
import { computeGlobalEnvsFromDb } from "@dappnode/db";
import { getIsCore } from "@dappnode/utils";
import { fileToGatewayUrl, getIsCore } from "@dappnode/utils";
import { sanitizeDependencies } from "./dappGet/utils/sanitizeDependencies.js";
import { parseTimeoutSeconds } from "./utils.js";
import { getEthersProvider } from "./ethClient/index.js";
Expand Down Expand Up @@ -74,7 +74,8 @@ export class DappnodeInstaller extends DappnodeRepository {
gettingStarted: pkgRelease.gettingStarted,
grafanaDashboards: pkgRelease.grafanaDashboards,
prometheusTargets: pkgRelease.prometheusTargets,
notifications: pkgRelease.notifications
notifications: pkgRelease.notifications,
avatarFile: pkgRelease.avatarFile
});

// set compose to custom dappnode compose in release
Expand Down Expand Up @@ -110,7 +111,8 @@ export class DappnodeInstaller extends DappnodeRepository {
gettingStarted: pkgRelease.gettingStarted,
grafanaDashboards: pkgRelease.grafanaDashboards,
prometheusTargets: pkgRelease.prometheusTargets,
notifications: pkgRelease.notifications
notifications: pkgRelease.notifications,
avatarFile: pkgRelease.avatarFile
});
});

Expand Down Expand Up @@ -155,7 +157,8 @@ export class DappnodeInstaller extends DappnodeRepository {
gettingStarted,
prometheusTargets,
grafanaDashboards,
notifications
notifications,
avatarFile
}: {
manifest: Manifest;
SetupWizard?: SetupWizard;
Expand All @@ -164,13 +167,15 @@ export class DappnodeInstaller extends DappnodeRepository {
prometheusTargets?: PrometheusTarget[];
grafanaDashboards?: GrafanaDashboard[];
notifications?: NotificationsConfig;
avatarFile?: DistributedFile;
}): Manifest {
if (SetupWizard) manifest.setupWizard = SetupWizard;
if (disclaimer) manifest.disclaimer = { message: disclaimer };
if (gettingStarted) manifest.gettingStarted = gettingStarted;
if (prometheusTargets) manifest.prometheusTargets = prometheusTargets;
if (grafanaDashboards && grafanaDashboards.length > 0) manifest.grafanaDashboards = grafanaDashboards;
if (notifications) manifest.notifications = notifications;
if (avatarFile) manifest.avatarUrl = fileToGatewayUrl(avatarFile);

return manifest;
}
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 @@ -14,6 +14,7 @@ export interface Manifest {
author?: string;
license?: string;
avatar?: string;
avatarUrl?: string;
repository?: {
type?: string;
url?: string;
Expand Down
18 changes: 16 additions & 2 deletions packages/utils/src/getIsCore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { Manifest } from "@dappnode/types";
import { params } from "@dappnode/params";

export function getIsCore(manifest: Manifest): boolean {
return manifest.type === "dncore";
type Custom = Pick<Manifest, "type" | "name">;

export function getIsCore(manifest: Custom): boolean {
if (manifest.type) return manifest.type === "dncore";
return coreDnpNames.includes(manifest.name);
}

const coreDnpNames = [
params.dappmanagerDnpName,
params.WIREGUARD_DNP_NAME,
params.vpnDnpName,
params.wifiDnpName,
params.bindDnpName,
params.ipfsDnpName,
params.HTTPS_PORTAL_DNPNAME
];
4 changes: 3 additions & 1 deletion packages/utils/src/readManifestIfExists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getManifestPath } from "./getManifestPath.js";
import { isNotFoundError } from "./isNotFoundError.js";
import { validatePath } from "./validatePath.js";
import { yamlParse } from "./yaml.js";
import { getIsCore } from "./getIsCore.js";

/**
* Improve error reporting, know what type of parsing is failing.
Expand All @@ -21,7 +22,8 @@ function readManifest(manfiestPath: string): Manifest {
return parseManifest(fs.readFileSync(manfiestPath, "utf8"));
}

export function readManifestIfExists({ dnpName, isCore }: { dnpName: string; isCore: boolean }): Manifest | null {
export function readManifestIfExists(dnpName: string): Manifest | null {
const isCore = getIsCore({ name: dnpName });
const manifestPath = validatePath(getManifestPath(dnpName, isCore));
try {
return readManifest(manifestPath);
Expand Down
Loading