@@ -3,8 +3,39 @@ const { normalize, join } = require("path");
3
3
const { copySync, removeSync } = require ( "fs-extra" ) ;
4
4
const { readdirSync, lstatSync, readFileSync, existsSync, writeFileSync } = require ( "fs" ) ;
5
5
6
- const getOverwritablePredicate = ( packageName ) => ( pathName ) => {
7
- const overwritablePathnames = [
6
+ // const getOverwritablePredicate = (packageName) => (pathName) => {
7
+ // const overwritablePathnames = [
8
+ // "commands",
9
+ // "models",
10
+ // "protocols",
11
+ // "pagination",
12
+ // "tests",
13
+ // "waiters",
14
+ // "LICENCE",
15
+ // "runtimeConfig.ts",
16
+ // "runtimeConfig.browser.ts",
17
+ // "runtimeConfig.shared.ts",
18
+ // "runtimeConfig.native.ts",
19
+ // "index.ts",
20
+ // "endpoints.ts",
21
+ // "README.md",
22
+ // ];
23
+ // const additionalGeneratedFiles = {
24
+ // "@aws-sdk/client-sts": ["defaultRoleAssumers.ts", "defaultStsRoleAssumers.ts", "defaultRoleAssumers.spec.ts"],
25
+ // };
26
+ // return (
27
+ // // pathName
28
+ // // .toLowerCase()
29
+ // // .startsWith(
30
+ // // packageName.toLowerCase().replace("@aws-sdk/client-", "").replace("@aws-sdk/aws-", "").replace(/-/g, "")
31
+ // // ) ||
32
+ // pathName.endsWith("Client.ts") &&
33
+ // overwritablePathnames.indexOf(pathName) >= 0 ||
34
+ // additionalGeneratedFiles[packageName.toLowerCase()]?.indexOf(pathName) >= 0
35
+ // );
36
+ // };
37
+ const getOverwritableDirectories = ( subDirectories ) => {
38
+ const overwritableDirectories = [
8
39
"commands" ,
9
40
"models" ,
10
41
"protocols" ,
@@ -19,19 +50,17 @@ const getOverwritablePredicate = (packageName) => (pathName) => {
19
50
"index.ts" ,
20
51
"endpoints.ts" ,
21
52
"README.md" ,
53
+ // @aws -sdk/client-sts special files
54
+ "defaultRoleAssumers.ts" ,
55
+ "defaultStsRoleAssumers.ts" ,
56
+ "defaultRoleAssumers.spec.ts" ,
22
57
] ;
23
- const additionalGeneratedFiles = {
24
- "@aws-sdk/client-sts" : [ "defaultRoleAssumers.ts" , "defaultStsRoleAssumers.ts" , "defaultRoleAssumers.spec.ts" ] ,
25
- } ;
26
- return (
27
- pathName
28
- . toLowerCase ( )
29
- . startsWith (
30
- packageName . toLowerCase ( ) . replace ( "@aws-sdk/client-" , "" ) . replace ( "@aws-sdk/aws-" , "" ) . replace ( / - / g, "" )
31
- ) ||
32
- overwritablePathnames . indexOf ( pathName ) >= 0 ||
33
- additionalGeneratedFiles [ packageName . toLowerCase ( ) ] ?. indexOf ( pathName ) >= 0
34
- ) ;
58
+ return subDirectories . filter ( ( subDirectory ) => {
59
+ const isBareBoneClient =
60
+ subDirectory . endsWith ( "Client.ts" ) && subDirectories . includes ( subDirectory . replace ( "Client.ts" , ".ts" ) ) ;
61
+ const isAggregateClient = subDirectories . includes ( subDirectory . replace ( ".ts" , "Client.ts" ) ) ;
62
+ return isBareBoneClient || isAggregateClient || overwritableDirectories . indexOf ( subDirectory ) >= 0 ;
63
+ } ) ;
35
64
} ;
36
65
37
66
/**
@@ -109,7 +138,6 @@ const copyToClients = async (sourceDir, destinationDir) => {
109
138
110
139
console . log ( `copying ${ packageName } from ${ artifactPath } to ${ destinationDir } ` ) ;
111
140
const destPath = join ( destinationDir , clientName ) ;
112
- const overwritablePredicate = getOverwritablePredicate ( packageName ) ;
113
141
114
142
// Code to move files/folders prefixed with `doc-client-` to `lib/lib-dynamodb`
115
143
if ( clientName === "client-dynamodb" ) {
@@ -124,7 +152,9 @@ const copyToClients = async (sourceDir, destinationDir) => {
124
152
}
125
153
}
126
154
127
- for ( const packageSub of readdirSync ( artifactPath ) ) {
155
+ const packageSubs = readdirSync ( artifactPath ) ;
156
+ const overWritableSubs = getOverwritableDirectories ( packageSubs ) ;
157
+ for ( const packageSub of packageSubs ) {
128
158
const packageSubPath = join ( artifactPath , packageSub ) ;
129
159
const destSubPath = join ( destPath , packageSub ) ;
130
160
@@ -141,7 +171,7 @@ const copyToClients = async (sourceDir, destinationDir) => {
141
171
} ,
142
172
} ;
143
173
writeFileSync ( destSubPath , JSON . stringify ( mergedManifest , null , 2 ) . concat ( `\n` ) ) ;
144
- } else if ( overwritablePredicate ( packageSub ) || ! existsSync ( destSubPath ) ) {
174
+ } else if ( overWritableSubs . includes ( packageSub ) || ! existsSync ( destSubPath ) ) {
145
175
if ( lstatSync ( packageSubPath ) . isDirectory ( ) ) removeSync ( destSubPath ) ;
146
176
copySync ( packageSubPath , destSubPath , {
147
177
overwrite : true ,
@@ -168,9 +198,10 @@ const copyServerTests = async (sourceDir, destinationDir) => {
168
198
169
199
console . log ( `copying ${ packageName } from ${ artifactPath } to ${ destinationDir } ` ) ;
170
200
const destPath = join ( destinationDir , testName ) ;
171
- const overwritablePredicate = getOverwritablePredicate ( packageName ) ;
172
201
173
- for ( const packageSub of readdirSync ( artifactPath ) ) {
202
+ const packageSubs = readdirSync ( artifactPath ) ;
203
+ const overWritableSubs = getOverwritableDirectories ( packageSubs ) ;
204
+ for ( const packageSub of packageSubs ) {
174
205
const packageSubPath = join ( artifactPath , packageSub ) ;
175
206
const destSubPath = join ( destPath , packageSub ) ;
176
207
@@ -187,7 +218,7 @@ const copyServerTests = async (sourceDir, destinationDir) => {
187
218
} ,
188
219
} ;
189
220
writeFileSync ( destSubPath , JSON . stringify ( mergedManifest , null , 2 ) . concat ( `\n` ) ) ;
190
- } else if ( overwritablePredicate ( packageSub ) || ! existsSync ( destSubPath ) ) {
221
+ } else if ( overWritableSubs . includes ( packageSub ) || ! existsSync ( destSubPath ) ) {
191
222
if ( lstatSync ( packageSubPath ) . isDirectory ( ) ) removeSync ( destSubPath ) ;
192
223
copySync ( packageSubPath , destSubPath , {
193
224
overwrite : true ,
0 commit comments