@@ -44,16 +44,18 @@ export default class Rollback extends BaseCommand<typeof Rollback> {
4444 } ) ,
4545 } ;
4646
47- async run ( ) : Promise < void > {
47+ async init ( ) : Promise < void > {
48+ await super . init ( ) ;
4849 this . logger = new Logger ( this . sharedConfig ) ;
4950 this . log = this . logger . log . bind ( this . logger ) ;
51+ await this . prepareApiClients ( ) ;
52+ }
5053
54+ async run ( ) : Promise < void > {
5155 if ( ! this . flags . environment ) {
5256 await this . getConfig ( ) ;
5357 }
5458
55- await this . prepareApiClients ( ) ;
56-
5759 if ( ! this . sharedConfig . currentConfig ?. uid ) {
5860 await selectOrg ( {
5961 log : this . log ,
@@ -82,7 +84,7 @@ export default class Rollback extends BaseCommand<typeof Rollback> {
8284 async rollbackDeployment ( ) : Promise < void > {
8385 const environment = await this . resolveEnvironment ( ) ;
8486 const currentLive = await this . fetchCurrentLiveDeployment ( environment . uid ) ;
85- const eligibleSorted = this . getEligibleSorted ( environment , currentLive ?. uid ) ;
87+ const eligibleSorted = this . getEligibleSortedDeployments ( environment , currentLive ?. uid ) ;
8688
8789 if ( isEmpty ( eligibleSorted ) ) {
8890 this . log ( 'No rollback-eligible deployments are available for this environment.' , 'error' ) ;
@@ -105,7 +107,7 @@ export default class Rollback extends BaseCommand<typeof Rollback> {
105107 return ;
106108 }
107109
108- let rolledBack : any ;
110+ let rolledBack : { deploymentNumber : number ; uid : string } ;
109111 try {
110112 const { data } = await this . apolloClient . mutate ( {
111113 mutation : rollbackDeploymentMutation ,
@@ -118,8 +120,9 @@ export default class Rollback extends BaseCommand<typeof Rollback> {
118120 } ,
119121 } ) ;
120122 rolledBack = data ?. deployment ;
121- } catch ( error : any ) {
122- const code = error ?. graphQLErrors ?. [ 0 ] ?. extensions ?. exception ?. name || error ?. message ;
123+ } catch ( error : unknown ) {
124+ const err = error as { graphQLErrors ?: { extensions ?: { exception ?: { name ?: string } } } [ ] ; message ?: string } ;
125+ const code = err ?. graphQLErrors ?. [ 0 ] ?. extensions ?. exception ?. name || err ?. message ;
123126 this . log ( `Rollback failed. Please try again. (${ code } )` , 'error' ) ;
124127 process . exit ( 1 ) ;
125128 }
@@ -243,11 +246,11 @@ export default class Rollback extends BaseCommand<typeof Rollback> {
243246 }
244247
245248 /**
246- * @method getEligibleSorted - eligible deployments excluding current live, sorted by number desc
249+ * @method getEligibleSortedDeployments - eligible deployments excluding current live, sorted by number desc
247250 *
248251 * @memberof Rollback
249252 */
250- getEligibleSorted ( environment : any , currentLiveUid ?: string ) : any [ ] {
253+ getEligibleSortedDeployments ( environment : any , currentLiveUid ?: string ) : any [ ] {
251254 const deployments = map ( environment ?. deployments ?. edges , 'node' ) ;
252255 const eligible = filter (
253256 deployments ,
0 commit comments