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

113 lines (109 loc) 5 kB
import chalk from "chalk"; import { getInstallDnpLink, getPublishTxLink } from "../../utils/getLinks.js"; import { releaseTypes } from "../../types.js"; import { printObject } from "../../utils/print.js"; import { publishHandler } from "./handler.js"; import { defaultVariantsDirName } from "../../params.js"; export const publish = { command: "publish [type]", describe: "Publish a new version of the package in an Aragon Package Manager Repository", builder: { type: { description: `Semver update type. Can also be provided with env RELEASE_TYPE=[type] or via TRAVIS_TAG=release (patch), TRAVIS_TAG=release/[type]`, choices: releaseTypes, type: "string" }, provider: { alias: "p", description: `Specify a provider (overwrittes content_provider and eth_provider): "dappnode" (default), "infura", "http://localhost:8545"`, // Must NOT add a default here, so options can overwrite each other in the handler // default: "dappnode", type: "string" }, eth_provider: { alias: "eth-provider", description: `Specify an eth provider: "dappnode" (default), "infura", "localhost:8545"`, default: "dappnode", type: "string" }, content_provider: { alias: "content-provider", description: `Specify an ipfs provider: "dappnode" (default), "infura", "http://localhost:5001"`, default: "dappnode", type: "string" }, upload_to: { alias: "upload-to", description: `Specify where to upload the release`, choices: ["ipfs", "swarm"], default: "ipfs" }, developer_address: { alias: ["a", "developer-address"], description: `If there is no existing repo for this DNP the publish command needs a developer address. If it is not provided as an option a prompt will request it`, type: "string" }, timeout: { alias: "t", description: `Overrides default build timeout: "15h", "20min 15s", "5000". Specs npmjs.com/package/timestring`, type: "string" }, github_release: { alias: "github-release", description: `Publish the release on the Github repo specified in the manifest. Requires a GITHUB_TOKEN ENV to authenticate`, type: "boolean" }, dappnode_team_preset: { alias: "dappnode-team-preset", description: `Specific set of options used for internal DAppNode releases. Caution: options may change without notice.`, type: "boolean" }, all_variants: { alias: "all-variants", description: `It will use the dappnode_package.json and docker-compose.yml files in the root of the project together with the specific ones defined for each package variant to build all of them`, type: "boolean" }, variants_dir_name: { alias: "variants-dir-name", description: `Name of the directory where the package variants are located (only for packages that support it and combined with either "--all-variants" or "--variants"). By default, it is ${defaultVariantsDirName}`, type: "string", default: defaultVariantsDirName }, variants: { alias: "variant", description: `Specify the package variants to build (only for packages that support it). Defined by comma-separated list of variant names. If not specified, all variants will be built. Example: "variant1,variant2"`, type: "string" } }, handler: async (args) => { const publishedData = await publishHandler(args); Object.entries(publishedData).map(([dnpName, publishedItem]) => printPublishResults({ dnpName, publishedItem })); } }; function printPublishResults({ dnpName, publishedItem }) { const { releaseMultiHash, nextVersion, txData, variant } = publishedItem; if (!txData || !releaseMultiHash) { console.log(` ${chalk.red(`Could not generate tx to publish Dappnode Package (${variant})`)} `); return; } const txDataToPrint = { To: txData.to, Value: txData.value, Data: txData.data, Gas: txData.gasLimit }; console.log(` ${chalk.green(`Dappnode Package (${variant}) is ready to be published`)} DNP name : ${dnpName} Version: ${nextVersion} Release hash : ${releaseMultiHash} ${getInstallDnpLink(releaseMultiHash)} ${"You must execute this transaction in mainnet to publish a new version of this DNP."} ${chalk.gray(printObject(txDataToPrint, (key, value) => ` ${key.padEnd(5)} : ${value}`))} ${"You can also execute this transaction with Metamask by following this pre-filled link"} ${chalk.cyan(getPublishTxLink(txData))} `); } //# sourceMappingURL=index.js.map