@@ -7,14 +7,13 @@ import { buildAndUpload } from "../tasks/buildAndUpload";
77import { generatePublishTx } from "../tasks/generatePublishTx" ;
88import { createGithubRelease } from "../tasks/createGithubRelease" ;
99// Utils
10- import { getCurrentLocalVersion } from "../utils/versions/getCurrentLocalVersion" ;
11- import { increaseFromApmVersion } from "../utils/versions/increaseFromApmVersion" ;
12- import { verifyEthConnection } from "../utils/verifyEthConnection" ;
13- import { getInstallDnpLink , getPublishTxLink } from "../utils/getLinks" ;
10+ import { increaseFromRemoteVersion } from "../utils/increaseFromRemoteVersion" ;
11+ import { getInstallDnpLink } from "../utils/getLinks" ;
1412import { defaultComposeFileName , defaultDir , YargsError } from "../params" ;
1513import { CliGlobalOptions , ReleaseType , releaseTypes , TxData } from "../types" ;
1614import { printObject } from "../utils/print" ;
1715import { UploadTo } from "../releaseUploader" ;
16+ import { getPM , verifyEthConnection } from "../providers/pm" ;
1817
1918const typesList = releaseTypes . join ( " | " ) ;
2019
@@ -88,9 +87,12 @@ export const publish: CommandModule<CliGlobalOptions, CliCommandOptions> = {
8887 } ) ,
8988
9089 handler : async args => {
91- const { txData, nextVersion, releaseMultiHash } = await publishHanlder (
92- args
93- ) ;
90+ const {
91+ txData,
92+ nextVersion,
93+ releaseMultiHash,
94+ txPublishLink
95+ } = await publishHanlder ( args ) ;
9496
9597 if ( ! args . silent ) {
9698 const txDataToPrint = {
@@ -113,7 +115,7 @@ export const publish: CommandModule<CliGlobalOptions, CliCommandOptions> = {
113115
114116 ${ "You can also execute this transaction with Metamask by following this pre-filled link" }
115117
116- ${ chalk . cyan ( getPublishTxLink ( txData ) ) }
118+ ${ chalk . cyan ( txPublishLink ) }
117119 ` ) ;
118120 }
119121 }
@@ -143,6 +145,7 @@ export async function publishHanlder({
143145 txData : TxData ;
144146 nextVersion : string ;
145147 releaseMultiHash : string ;
148+ txPublishLink : string ;
146149} > {
147150 // Parse optionsalias: "release",
148151 let ethProvider = provider || eth_provider ;
@@ -195,27 +198,22 @@ export async function publishHanlder({
195198 `Invalid release type "${ type } ", must be: ${ typesList } `
196199 ) ;
197200
198- await verifyEthConnection ( ethProvider ) ;
201+ const pm = getPM ( ethProvider ) ;
202+ await verifyEthConnection ( pm ) ;
199203
200204 const publishTasks = new Listr (
201205 [
202206 // 1. Fetch current version from APM
203207 {
204208 title : "Fetch current version from APM" ,
205209 task : async ( ctx , task ) => {
206- let nextVersion ;
207- try {
208- nextVersion = await increaseFromApmVersion ( {
209- type : type as ReleaseType ,
210- ethProvider,
211- dir,
212- composeFileName
213- } ) ;
214- } catch ( e ) {
215- if ( e . message . includes ( "NOREPO" ) )
216- nextVersion = getCurrentLocalVersion ( { dir } ) ;
217- else throw e ;
218- }
210+ const nextVersion = await increaseFromRemoteVersion ( {
211+ type : type as ReleaseType ,
212+ pm,
213+ dir,
214+ composeFileName
215+ } ) ;
216+
219217 ctx . nextVersion = nextVersion ;
220218 ctx . buildDir = path . join ( dir , `build_${ nextVersion } ` ) ;
221219 task . title = task . title + ` (next version: ${ nextVersion } )` ;
@@ -276,6 +274,11 @@ export async function publishHanlder({
276274 ) ;
277275
278276 const tasksFinalCtx = await publishTasks . run ( ) ;
279- const { txData, nextVersion, releaseMultiHash } = tasksFinalCtx ;
280- return { txData, nextVersion, releaseMultiHash } ;
277+ const {
278+ txData,
279+ nextVersion,
280+ releaseMultiHash,
281+ txPublishLink
282+ } = tasksFinalCtx ;
283+ return { txData, nextVersion, releaseMultiHash, txPublishLink } ;
281284}
0 commit comments