@@ -7,11 +7,16 @@ const compileIamRole = require('./deploy/stepFunctions/compileIamRole');
77const httpValidate = require ( './deploy/events/apiGateway/validate' ) ;
88const httpResources = require ( './deploy/events/apiGateway/resources' ) ;
99const httpMethods = require ( './deploy/events/apiGateway/methods' ) ;
10+ const httpIamRole = require ( './deploy/events/apiGateway/role' ) ;
11+ const httpDeployment = require ( './deploy/events/apiGateway/deployment' ) ;
1012const coreCompileRestApi =
1113 require ( 'serverless/lib/plugins/aws/deploy/compile/events/apiGateway/lib/restApi' ) ;
14+ const coreInfo =
15+ require ( 'serverless/lib/plugins/aws/info/getStackInfo' ) ;
1216const yamlParser = require ( './yamlParser' ) ;
1317const naming = require ( './naming' ) ;
1418const _ = require ( 'lodash' ) ;
19+ const chalk = require ( 'chalk' ) ;
1520
1621class ServerlessStepFunctions {
1722 constructor ( serverless , options ) {
@@ -38,9 +43,12 @@ class ServerlessStepFunctions {
3843 compileActivities ,
3944 compileIamRole ,
4045 coreCompileRestApi ,
46+ coreInfo ,
4147 httpValidate ,
4248 httpResources ,
4349 httpMethods ,
50+ httpIamRole ,
51+ httpDeployment ,
4452 yamlParser ,
4553 naming
4654 ) ;
@@ -100,16 +108,49 @@ class ServerlessStepFunctions {
100108 return BbPromise . bind ( this )
101109 . then ( this . compileRestApi )
102110 . then ( this . compileResources )
103- . then ( this . compileMethods ) ;
111+ . then ( this . compileMethods )
112+ . then ( this . compileHttpIamRole )
113+ . then ( this . compileDeployment ) ;
104114 }
105115 return BbPromise . bind ( this )
106116 . then ( this . compileResources ) ;
107117 } ,
118+ 'after:deploy:deploy' : ( ) => BbPromise . bind ( this )
119+ . then ( this . getStackInfo )
120+ . then ( this . display ) ,
108121 } ;
109122 }
110123
111124 invoke ( ) {
112125
113126 }
127+
128+ display ( ) {
129+ let message = '' ;
130+
131+ const info = this . gatheredData . info ;
132+ message += `${ chalk . yellow . underline ( 'Serverless StepFunctions OutPut' ) } \n` ;
133+ message += `${ chalk . yellow ( 'endpoints:' ) } ` ;
134+ _ . forEach ( this . getAllStateMachines ( ) , ( stateMachineName ) => {
135+ const stateMachineObj = this . getStateMachine ( stateMachineName ) ;
136+ stateMachineObj . events . forEach ( event => {
137+ if ( event . http ) {
138+ let method ;
139+ let path ;
140+
141+ if ( typeof event . http === 'object' ) {
142+ method = event . http . method . toUpperCase ( ) ;
143+ path = event . http . path ;
144+ } else {
145+ method = event . http . split ( ' ' ) [ 0 ] . toUpperCase ( ) ;
146+ path = event . http . split ( ' ' ) [ 1 ] ;
147+ }
148+ path = path !== '/' ? `/${ path . split ( '/' ) . filter ( p => p !== '' ) . join ( '/' ) } ` : '' ;
149+ message += `\n ${ method } - ${ info . endpoint } ${ path } ` ;
150+ }
151+ } ) ;
152+ } ) ;
153+ this . serverless . cli . consoleLog ( message ) ;
154+ }
114155}
115156module . exports = ServerlessStepFunctions ;
0 commit comments