UNPKG

@dappnode/dappnodesdk

Version:

dappnodesdk is a tool to make the creation of new dappnode packages as simple as possible. It helps to initialize and publish in ethereum blockchain

68 lines 2.74 kB
import path from "path"; import { parseArchitectures } from "../../utils/parseArchitectures.js"; import { readCompose, getComposePackageImages, parseComposeUpstreamVersion, readManifest, readNotificationsIfExists, readSetupWizardIfExists } from "../../files/index.js"; import { defaultComposeFileName } from "../../params.js"; export function generatePackagesProps({ variants, rootDir, variantsDirPath, composeFileName = defaultComposeFileName }) { if (variants === null) return [ createPackagePropsItem({ rootDir, composeFileName, variant: null, variantsDirPath }) ]; return variants.map(variant => createPackagePropsItem({ rootDir, composeFileName, variant, variantsDirPath })); } function createPackagePropsItem({ rootDir, composeFileName, variant, variantsDirPath }) { const manifestPaths = [{ dir: rootDir }]; const composePaths = [{ dir: rootDir, composeFileName }]; const notificationsPaths = [{ dir: rootDir }]; const setupWizardPaths = [{ dir: rootDir }]; if (variant) { const variantPath = path.join(variantsDirPath, variant); manifestPaths.push({ dir: variantPath }); composePaths.push({ dir: variantPath, composeFileName }); notificationsPaths.push({ dir: variantPath }); setupWizardPaths.push({ dir: variantPath }); } const { manifest, format: manifestFormat } = readManifest(manifestPaths); const compose = readCompose(composePaths); const notifications = readNotificationsIfExists(notificationsPaths); const setupWizard = readSetupWizardIfExists(setupWizardPaths); const { name: dnpName, version } = manifest; // TODO: Handle upstream object defined case if (!manifest.upstream) manifest.upstreamVersion = getUpstreamVersion({ compose, manifest }); return { variant, manifest, manifestFormat, compose, notifications, setupWizard, releaseDir: getReleaseDirPath({ rootDir, dnpName, version }), manifestPaths, composePaths, notificationsPaths, setupWizardPaths, images: getComposePackageImages(compose, manifest), architectures: parseArchitectures({ rawArchs: manifest.architectures }) }; } function getUpstreamVersion({ compose, manifest }) { return (parseComposeUpstreamVersion(compose) || process.env.UPSTREAM_VERSION || manifest.upstreamVersion); } function getReleaseDirPath({ rootDir, dnpName, version }) { return path.join(rootDir, `build_${dnpName}_${version}`); } //# sourceMappingURL=generatePackagesProps.js.map