Skip to content

Commit

Permalink
Bump dappnode types to 0.1.33
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo committed Jan 26, 2024
1 parent ca6a58b commit 90e53a5
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"dependencies": {
"@dappnode/schemas": "0.1.8",
"@dappnode/toolkit": "0.1.20",
"@dappnode/types": "0.1.17",
"@dappnode/types": "^0.1.33",
"@octokit/rest": "^18.0.12",
"async-retry": "^1.2.3",
"chalk": "^2.4.2",
Expand Down
15 changes: 5 additions & 10 deletions src/commands/from_github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@ import {
} from "../utils/githubGetReleases.js";
import { ipfsAddDirFromUrls } from "../releaseUploader/ipfsNode/addDirFromUrls.js";
import { verifyIpfsConnection } from "../releaseUploader/ipfsNode/verifyConnection.js";
import { CliGlobalOptions } from "../types.js";
import {
Manifest,
defaultArch,
getImagePath,
getLegacyImagePath,
releaseFilesDefaultNames,
releaseFiles,
contentHashFile
} from "@dappnode/types";
import { CliGlobalOptions, contentHashFile } from "../types.js";
import { Manifest, defaultArch, releaseFiles } from "@dappnode/types";
import { getLegacyImagePath } from "../utils/getLegacyImagePath.js";
import { getImagePath } from "../utils/getImagePath.js";
import { releaseFilesDefaultNames } from "../params.js";

interface CliCommandOptions extends CliGlobalOptions {
repoSlug: string;
Expand Down
2 changes: 1 addition & 1 deletion src/files/manifest/getManifestPath.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import { defaultDir } from "../../params.js";
import { ManifestFormat, ManifestPaths } from "@dappnode/types";
import { ManifestFormat, ManifestPaths } from "./types.js";

/**
* Get manifest path. Without arguments defaults to './dappnode_package.json'
Expand Down
2 changes: 1 addition & 1 deletion src/files/manifest/getRepoSlugFromManifest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readManifest } from "./readManifest.js";
import { ManifestPaths } from "@dappnode/types";
import { ManifestPaths } from "./types.js";

/**
* Gets the repo slug from a manifest, using the repository property
Expand Down
8 changes: 2 additions & 6 deletions src/files/manifest/readManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import fs from "fs";
import path from "path";
import { readFile } from "../../utils/file.js";
import { defaultDir } from "../../params.js";
import {
ManifestPaths,
Manifest,
ManifestFormat,
releaseFiles
} from "@dappnode/types";
import { Manifest, releaseFiles } from "@dappnode/types";
import { ManifestFormat, ManifestPaths } from "./types.js";

/**
* Reads a manifest. Without arguments defaults to read the manifest at './dappnode_package.json'
Expand Down
2 changes: 1 addition & 1 deletion src/files/manifest/stringifyJson.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ManifestFormat } from "@dappnode/types";
import yaml from "js-yaml";
import prettier from "prettier";
import { ManifestFormat } from "./types.js";

/**
* JSON.stringify + run prettier on the result
Expand Down
12 changes: 12 additions & 0 deletions src/files/manifest/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export enum ManifestFormat {
json = "json",
yml = "yml",
yaml = "yaml"
}

export interface ManifestPaths {
/** './folder', [optional] directory to load the manifest from */
dir?: string;
/** 'manifest-admin.json', [optional] name of the manifest file */
manifestFileName?: string;
}
3 changes: 2 additions & 1 deletion src/files/manifest/writeManifest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import fs from "fs";
import { getManifestPath } from "./getManifestPath.js";
import { stringifyJson } from "./stringifyJson.js";
import { Manifest, ManifestFormat, ManifestPaths } from "@dappnode/types";
import { Manifest } from "@dappnode/types";
import { ManifestFormat, ManifestPaths } from "./types.js";

/**
* Writes a manifest. Without arguments defaults to write the manifest at './dappnode_package.json'
Expand Down
20 changes: 19 additions & 1 deletion src/params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ManifestFormat } from "@dappnode/types";
import { releaseFiles } from "@dappnode/types";
import { ManifestFormat } from "./files/manifest/types.js";

export * from "./files/compose/params.js";

Expand All @@ -21,3 +22,20 @@ export const upstreamImageLabel = "dappnode.dnp.upstreamImage";
export const PINATA_URL = "https://api.pinata.cloud";
// The build_sdk.env file is used by "slaves" DAppNode packages to define the UPSTREAM_PROJECT and UPSTREAM_VERSION used in the gha
export const buildSdkEnvFileName = "build_sdk.env";

export const releaseFilesDefaultNames: {
[P in keyof typeof releaseFiles]: string;
} = Object.freeze({
manifest: "dappnode_package.json",
compose: "docker-compose.yml",
avatar: "avatar.png",
signature: "signature.json",
setupWizard: "setup-wizard.json",
setupSchema: "setup.schema.json",
setupTarget: "setup-target.json",
setupUiJson: "setup-ui.json",
disclaimer: "disclaimer.md",
gettingStarted: "getting-started.md",
grafanaDashboards: "grafana-dashboard.json",
prometheusTargets: "prometheus-targets.json"
} as const);
11 changes: 4 additions & 7 deletions src/tasks/buildAndUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import rimraf from "rimraf";
import { verifyAvatar } from "../utils/verifyAvatar.js";
import { copyReleaseFile } from "../utils/copyReleaseFile.js";
import { addReleaseRecord } from "../utils/releaseRecord.js";
import { CliError } from "../params.js";
import { CliError, releaseFilesDefaultNames } from "../params.js";
import { ListrContextBuildAndPublish } from "../types.js";
import { parseTimeout } from "../utils/timeout.js";
import { buildWithBuildx } from "./buildWithBuildx.js";
Expand Down Expand Up @@ -44,12 +44,9 @@ import {
writeManifest,
readSetupWizardIfExists
} from "../files/index.js";
import {
getImagePath,
getLegacyImagePath,
releaseFiles,
releaseFilesDefaultNames
} from "@dappnode/types";
import { releaseFiles } from "@dappnode/types";
import { getImagePath } from "../utils/getImagePath.js";
import { getLegacyImagePath } from "../utils/getLegacyImagePath.js";

// Pretty percent uploaded reporting
const percentToMessage = (percent: number) =>
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/createGithubRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ListrContextBuildAndPublish
} from "../types.js";
import { Github } from "../providers/github/Github.js";
import { contentHashFile } from "@dappnode/types";
import { contentHashFile } from "../types.js";

/**
* Create (or edit) a Github release, then upload all assets
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ export interface TxDataShortKeys {
h: string; // hash
d?: string; // developerAddress
}

export const contentHashFile = "content-hash" as const;
2 changes: 1 addition & 1 deletion src/utils/copyReleaseFile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { releaseFilesDefaultNames } from "@dappnode/types";
import { releaseFilesDefaultNames } from "../params.js";
import fs from "fs";
import path from "path";

Expand Down
21 changes: 21 additions & 0 deletions src/utils/getImagePath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Architecture } from "@dappnode/types";

/**
* Returns the image path for the given container name, version and architecture
* @param name Container name
* @param version Container version
* @param arch Container architecture in the format <os>/<arch>
* @returns Image path in the format <name>_<version>_<os>-<arch>.txz
*/
export const getImagePath = (
name: string,
version: string,
arch: Architecture
): string => `${name}_${version}_${getArchTag(arch)}.txz`;

/**
* Returns the arch tag for the given architecture
* @param arch Architecture in the format <os>/<arch>
* @returns Arch tag in the format <os>-<arch>
*/
const getArchTag = (arch: Architecture): string => arch.replace(/\//g, "-");
8 changes: 8 additions & 0 deletions src/utils/getLegacyImagePath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Returns the legacy image path for the given container name and version
* @param name Container name
* @param version Container version
* @returns Legacy image path in the format <name>_<version>.tar.xz
*/
export const getLegacyImagePath = (name: string, version: string): string =>
`${name}_${version}.tar.xz`;
2 changes: 1 addition & 1 deletion src/utils/releaseRecord.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs";
import path from "path";
import { stringifyJson } from "../files/index.js";
import { ManifestFormat } from "@dappnode/types";
import { ManifestFormat } from "../files/manifest/types.js";

interface ReleaseRecord {
hash: string;
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@
semver "^7.5.0"
yaml "^2.2.2"

"@dappnode/[email protected]":
version "0.1.17"
resolved "https://registry.yarnpkg.com/@dappnode/types/-/types-0.1.17.tgz#b15fba7356acae7f2751f0cfe4db08eccb004993"
integrity sha512-XfMYmF/b/p9a24YB2b6D7LWS/wQzPMYEklTAvVRRmJbVgwklIE+j02O90Qhc9RXxqxL9gB+WnpPEiXie2EUhIw==

"@dappnode/types@^0.1.19":
version "0.1.20"
resolved "https://registry.yarnpkg.com/@dappnode/types/-/types-0.1.20.tgz#7ac75c1fdf13b4eb85ec60c3794199755d14ac22"
integrity sha512-r8688eUOJzZAJzwWWTdijIJF3NrvPo6y8N4Akqtb+Ehi8mn+xg52RHo8CVSaIcx+z+W5UEQOjXhLdhZY5lwF4Q==

"@dappnode/types@^0.1.33":
version "0.1.33"
resolved "https://registry.yarnpkg.com/@dappnode/types/-/types-0.1.33.tgz#0b054b4c527c7f0ffe122c42c6b986da4f38a620"
integrity sha512-wORHHoM1ep7oCdhQ5rHN7R0qvlecdNh9z+6Hde0kilzL/jo9OX/vl4CKCxZq0JlhsJixcQx42cd418UZ/AKzog==

"@dappnode/types@^0.1.9":
version "0.1.9"
resolved "https://registry.yarnpkg.com/@dappnode/types/-/types-0.1.9.tgz#23d13181ab077b33e23b929bd32cc6b2b618ec4a"
Expand Down

0 comments on commit 90e53a5

Please sign in to comment.