1
1
import { clientModuleIdentifier } from '../clientModuleIdentifier' ;
2
- import { fromModelJson , fromSmokeTestModelJson } from '@aws-sdk/service-model' ;
2
+ import { fromModelJson } from '@aws-sdk/service-model' ;
3
3
import { TreeModel , SmokeTestModel } from '@aws-sdk/build-types' ;
4
- import { existsSync , readFileSync } from 'fs' ;
5
- import { dirname , join } from 'path' ;
4
+ import { readFileSync } from 'fs' ;
5
+ import { dirname } from 'path' ;
6
6
import * as yargs from 'yargs' ;
7
7
import { sync as globSync } from 'glob' ;
8
8
import { ImportClientPackageCommand } from './ImportClientPackageCommand' ;
@@ -11,6 +11,8 @@ import {loadSmokeTestModel} from '../loadSmokeTestModel';
11
11
interface ImportModelsCommandArgs {
12
12
matching : string ;
13
13
ignore ?: string | Array < string > ;
14
+ runtime ?: string ,
15
+ version ?: string
14
16
}
15
17
16
18
interface ServicesMapValue {
@@ -23,18 +25,28 @@ export const ImportModelsCommand: yargs.CommandModule = {
23
25
24
26
aliases : [ 'import-models' ] ,
25
27
26
- describe : 'Create a client for all runtimes for all service models under the provided directory. The generated packages will be added to the AWS SDK for JavaScript repository if they are not already present.' ,
28
+ describe : 'Create a client for all runtimes for all service models under the provided directory. The generated packages will be added to the AWS SDK for JavaScript repository if they are not already present. ' +
29
+ 'Specified runtime or version is also supported' ,
27
30
28
31
builder : {
29
32
matching : {
30
33
alias : [ 'm' ] ,
31
34
type : 'string' ,
32
35
demandOption : true ,
33
36
} ,
34
- ignore : { type : 'string' }
37
+ ignore : { type : 'string' } ,
38
+ runtime : {
39
+ alias : [ 'r' ] ,
40
+ type : 'string' ,
41
+ choices : [ 'node' , 'browser' ] ,
42
+ } ,
43
+ version : {
44
+ alias : [ 'v' ] ,
45
+ type : 'string' ,
46
+ }
35
47
} as yargs . CommandBuilder ,
36
48
37
- handler ( { ignore, matching} : ImportModelsCommandArgs ) : void {
49
+ handler ( { ignore, matching, runtime , version } : ImportModelsCommandArgs ) : void {
38
50
const services = new Map < string , ServicesMapValue > ( ) ;
39
51
for ( const match of globSync ( matching , { ignore} ) ) {
40
52
const model = fromModelJson ( readFileSync ( match , 'utf8' ) ) ;
@@ -51,11 +63,14 @@ export const ImportModelsCommand: yargs.CommandModule = {
51
63
}
52
64
53
65
console . log ( `Generating ${ services . size } SDK packages...` ) ;
54
-
55
66
for ( const [ identifier , { model, smoke} ] of services ) {
56
- for ( const runtime of [ 'node' , 'browser' ] ) {
57
- console . log ( `Generating ${ runtime } ${ clientModuleIdentifier ( model . metadata ) } SDK` ) ;
58
- ImportClientPackageCommand . handler ( { model, runtime, smoke } ) ;
67
+ console . log ( `Generating ${ runtime } ${ clientModuleIdentifier ( model . metadata ) } SDK` ) ;
68
+ if ( runtime ) {
69
+ ImportClientPackageCommand . handler ( { model, runtime, smoke, version } ) ;
70
+ } else {
71
+ for ( const runtime of [ 'node' , 'browser' ] ) {
72
+ ImportClientPackageCommand . handler ( { model, runtime, smoke, version } ) ;
73
+ }
59
74
}
60
75
}
61
76
}
0 commit comments