@@ -12,14 +12,15 @@ const {
1212 DEFAULT_CODE_GEN_INPUT_DIR ,
1313 TEMP_CODE_GEN_INPUT_DIR ,
1414} = require ( "./code-gen-dir" ) ;
15- const { buildSmithyTypeScript } = require ( "./build-smithy-typescript" ) ;
15+ const { buildSmithyTypeScript, runWithSpecificSmithyTypeScriptVersion } = require ( "./build-smithy-typescript" ) ;
1616const { SMITHY_TS_COMMIT } = require ( "./config" ) ;
1717const { spawnProcess } = require ( "../utils/spawn-process" ) ;
1818
1919const REPO_ROOT = path . join ( __dirname , ".." , ".." ) ;
2020const SMITHY_TS_DIR = path . normalize ( path . join ( __dirname , ".." , ".." , ".." , "smithy-typescript" ) ) ;
2121const SDK_CLIENTS_DIR = path . normalize ( path . join ( __dirname , ".." , ".." , "clients" ) ) ;
2222const PRIVATE_CLIENTS_DIR = path . normalize ( path . join ( __dirname , ".." , ".." , "private" ) ) ;
23+ const start = Date . now ( ) ;
2324
2425const {
2526 models,
@@ -33,6 +34,7 @@ const {
3334 commit,
3435 d : noSmithyCheckout ,
3536 p : protocolTestsOnly ,
37+ x : pullRequest ,
3638} = yargs ( process . argv . slice ( 2 ) )
3739 . alias ( "m" , "models" )
3840 . string ( "m" )
@@ -51,6 +53,9 @@ const {
5153 . alias ( "d" , "noSmithyCheckout" )
5254 . boolean ( "d" )
5355 . describe ( "d" , "use existing Smithy version instead of target hash" )
56+ . alias ( "x" , "pullRequest" )
57+ . boolean ( "x" )
58+ . describe ( "x" , "command was invoked by developer creating a pull request" )
5459 . alias ( "p" , "protocolTestsOnly" )
5560 . boolean ( "p" )
5661 . describe ( "p" , "Generate protocol tests only" )
@@ -129,7 +134,15 @@ const {
129134 await generateNestedClients ( ) ;
130135 }
131136
132- require ( "../runtime-dependency-version-check/runtime-dep-version-check" ) ;
137+ if ( ! noSmithyCheckout && pullRequest ) {
138+ await runWithSpecificSmithyTypeScriptVersion ( repo , commit , async ( ) => {
139+ process . argv . push ( "--set-smithy-version" ) ;
140+ require ( "../runtime-dependency-version-check/runtime-dep-version-check" ) ;
141+ } ) ;
142+ } else {
143+ require ( "../runtime-dependency-version-check/runtime-dep-version-check" ) ;
144+ }
145+
133146 await spawnProcess ( "yarn" , [ "install" , "--no-immutable" ] , {
134147 cwd : REPO_ROOT ,
135148 stdio : "inherit" ,
@@ -141,6 +154,11 @@ const {
141154 stdio : "inherit" ,
142155 env : { ...process . env } ,
143156 } ) ;
157+
158+ if ( ! noSmithyCheckout && pullRequest ) {
159+ const end = Date . now ( ) ;
160+ console . log ( `Codegen completed in ${ ( ( end - start ) / 1000 ) | 0 } s. Run git commit.` ) ;
161+ }
144162 } catch ( e ) {
145163 console . log ( e ) ;
146164 process . exit ( 1 ) ;
0 commit comments