@@ -43,7 +43,6 @@ export default class LogDrainAdd extends Command {
4343 description : messages . getMessage ( 'flags.drain-url.summary' ) ,
4444 hidden : true ,
4545 } ) ,
46- json : FunctionsFlagBuilder . json ,
4746 } ;
4847
4948 async run ( ) {
@@ -71,58 +70,52 @@ export default class LogDrainAdd extends Command {
7170 }
7271
7372 if ( flags . environment ) {
74- cli . warn ( messages . getMessage ( 'flags.environment.deprecation' ) ) ;
73+ this . warn ( messages . getMessage ( 'flags.environment.deprecation' ) ) ;
7574 }
7675
7776 if ( flags . url ) {
78- cli . warn ( messages . getMessage ( 'flags.url.deprecation' ) ) ;
77+ this . warn ( messages . getMessage ( 'flags.url.deprecation' ) ) ;
7978 }
8079 const appName = await resolveAppNameForEnvironment ( targetCompute ) ;
8180
8281 try {
82+ cli . action . start ( `Creating drain for environment ${ herokuColor . app ( targetCompute ) } ` ) ;
83+
8384 const result = await this . client . post < Heroku . LogDrain > ( `/apps/${ appName } /log-drains` , {
8485 data : {
8586 url,
8687 } ,
8788 } ) ;
8889
89- if ( flags . json ) {
90- cli . styledJSON ( {
91- status : 0 ,
92- result : [
93- {
94- addon : null ,
95- created_at : result . data . created_at ,
96- id : result . data . id ,
97- token : result . data . token ,
98- updated_at : result . data . updated_at ,
99- url : result . data . url ,
100- } ,
101- ] ,
102- warnings : [ ] ,
103- } ) ;
104- } else {
105- cli . action . start ( `Creating drain for environment ${ herokuColor . app ( targetCompute ) } ` ) ;
106-
107- cli . action . stop ( ) ;
108- }
90+ cli . action . stop ( ) ;
91+
92+ return [
93+ {
94+ addon : null ,
95+ created_at : result . data . created_at ,
96+ id : result . data . id ,
97+ token : result . data . token ,
98+ updated_at : result . data . updated_at ,
99+ url : result . data . url ,
100+ } ,
101+ ] ;
109102 } catch ( e ) {
110103 const error = e as { data : { message ?: string } } ;
111104
112105 if ( error . data ?. message ?. includes ( 'Url is invalid' ) ) {
113- this . error ( new Error ( `URL is invalid < ${ url } > ` ) ) ;
106+ this . error ( new Error ( `URL is invalid ${ url } ` ) ) ;
114107 }
115108
116109 if ( error . data ?. message ?. includes ( 'Url has already been taken' ) ) {
117- this . error ( new Error ( `Logdrain URL is already added < ${ url } > ` ) ) ;
110+ this . error ( new Error ( `Logdrain URL is already added ${ url } ` ) ) ;
118111 }
119112
120- if ( error . data ?. message ?. includes ( "Couldn't find that app. " ) ) {
121- this . error ( new Error ( `Could not find environment < ${ appName } > ` ) ) ;
113+ if ( error . data ?. message ?. includes ( "Couldn't find that app" ) ) {
114+ this . error ( new Error ( `Could not find environment ${ appName } ` ) ) ;
122115 }
123116
124117 if ( error . data ?. message ?. includes ( "You've reached the limit" ) ) {
125- this . error ( new Error ( `You've reached the limit of 5 log drains on < ${ appName } > ` ) ) ;
118+ this . error ( new Error ( `You've reached the limit of 5 log drains on ${ appName } ` ) ) ;
126119 }
127120
128121 if ( error . data ?. message ?. includes ( '401' ) ) {
0 commit comments