From a104f3076566784a206bfb482b0e45a9b0a12760 Mon Sep 17 00:00:00 2001 From: Jorge Izquierdo Date: Tue, 23 Oct 2018 11:53:33 +0200 Subject: [PATCH] apm publish: Improve publish feedback (#231) * apm publish: Improve publish feedback * apm publish: Print publish directory path on debug --- src/commands/apm_cmds/publish.js | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/commands/apm_cmds/publish.js b/src/commands/apm_cmds/publish.js index 8ee7f08ea..e65dfa25a 100644 --- a/src/commands/apm_cmds/publish.js +++ b/src/commands/apm_cmds/publish.js @@ -449,9 +449,7 @@ exports.task = function ({ transaction.from = from transaction.gasPrice = '19000000000' // 19 gwei - reporter.debug(JSON.stringify(transaction)) - - return await web3.eth.sendTransaction(transaction) + ctx.receipt = await web3.eth.sendTransaction(transaction) } catch (e) { throw e } @@ -460,18 +458,36 @@ exports.task = function ({ }, { title: 'Fetch published repo', - task: getRepoTask.task({ apmRepo: module.appName, apm }), - enabled: () => getRepo + task: getRepoTask.task({ apmRepo: module.appName, apm }) } ]) } exports.handler = async (args) => { - const { network } = args + const { reporter, network, module, onlyContent } = args const web3 = await ensureWeb3(network) return exports.task({ ...args, web3 }).run({ web3 }) - .then(() => { process.exit() }) - .catch(() => { process.exit() }) + .then(ctx => { + const { appName } = module + const { transactionHash, status } = ctx.receipt + const { version, content, contractAddress } = ctx.repo + + console.log() + if (!status) { + reporter.error(`Publish transaction reverted:`) + } else { + reporter.success(`Successfully published ${appName} v${version}: `) + if (!onlyContent) { + reporter.info(`Contract address: ${contractAddress}`) + } + reporter.info(`Content (${content.provider}): ${content.location}`) + } + + reporter.info(`Transaction hash: ${transactionHash}`) + reporter.debug(`Published directory: ${ctx.pathToPublish}`) + process.exit(status ? 0 : 1) + }) + .catch(() => { process.exit(1) }) }