@adobe/aio-lib-web 7.0.2 → 7.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,7 +67,7 @@ module.exports = class RemoteStorage {
67
67
  accessKeyId: creds.accessKeyId,
68
68
  secretAccessKey: creds.secretAccessKey,
69
69
  sessionToken: creds.sessionToken,
70
- expiration: creds.expiration
70
+ expiration: creds.expiration ? new Date(creds.expiration) : undefined
71
71
  }
72
72
  this.bucket = creds.params.Bucket
73
73
 
@@ -245,21 +245,31 @@ module.exports = class RemoteStorage {
245
245
  // walk the whole directory recursively using klaw.
246
246
  const files = await this.walkDir(dir)
247
247
 
248
- // parallel upload
249
- return Promise.all(files.map(async f => {
250
- // get file's relative folder to the base directory.
251
- let prefixDirectory = path.dirname(path.relative(dir, f))
252
- // base directory returns ".", ignore that.
253
- prefixDirectory = prefixDirectory === '.' ? '' : prefixDirectory
254
- // newPrefix is now the initial prefix plus the files relative directory path.
255
- const newPrefix = urlJoin(prefix, prefixDirectory)
256
- const s3Res = await this.uploadFile(f, newPrefix, appConfig, dir)
257
-
258
- if (postFileUploadCallback) {
259
- postFileUploadCallback(f)
260
- }
261
- return s3Res
262
- }))
248
+ // we will upload files in batches of 50 to prevent warnings about enqued tasks.
249
+ // this happens based on the default maxSockets value of 50 in node.js but we cannot change
250
+ // the user's default value.
251
+ // less than 1% of users will see this warning, but it is better to prevent it.
252
+ const batchSize = 50
253
+ let fileBatch = files.splice(0, batchSize)
254
+ const allResults = []
255
+ while (fileBatch.length > 0) {
256
+ const res = await Promise.all(fileBatch.map(async f => {
257
+ // get file's relative folder to the base directory.
258
+ let prefixDirectory = path.dirname(path.relative(dir, f))
259
+ // base directory returns ".", ignore that.
260
+ prefixDirectory = prefixDirectory === '.' ? '' : prefixDirectory
261
+ // newPrefix is now the initial prefix plus the files relative directory path.
262
+ const newPrefix = urlJoin(prefix, prefixDirectory)
263
+ const s3Res = await this.uploadFile(f, newPrefix, appConfig, dir)
264
+ if (postFileUploadCallback) {
265
+ postFileUploadCallback(f)
266
+ }
267
+ return s3Res
268
+ }))
269
+ allResults.push(res)
270
+ fileBatch = files.splice(0, batchSize)
271
+ }
272
+ return allResults
263
273
  }
264
274
 
265
275
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aio-lib-web",
3
- "version": "7.0.2",
3
+ "version": "7.0.4",
4
4
  "description": "Utility tooling library to build and deploy Adobe I/O Project Firefly app static sites to CDN",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -32,7 +32,7 @@
32
32
  "@adobe/aio-lib-core-config": "^5",
33
33
  "@adobe/aio-lib-core-logging": "^3",
34
34
  "@adobe/aio-lib-core-tvm": "^4",
35
- "@aws-sdk/client-s3": "3.623.0",
35
+ "@aws-sdk/client-s3": "^3.624.0",
36
36
  "core-js": "^3.25.1",
37
37
  "fs-extra": "^11",
38
38
  "joi": "^17.2.1",
@@ -47,7 +47,7 @@ describe('RemoteStorage', () => {
47
47
  accessKeyId: global.fakeTVMResponse.accessKeyId,
48
48
  secretAccessKey: global.fakeTVMResponse.secretAccessKey,
49
49
  sessionToken: global.fakeTVMResponse.sessionToken,
50
- expiration: global.fakeTVMResponse.expiration
50
+ expiration: new Date(global.fakeTVMResponse.expiration)
51
51
  },
52
52
  region: 'us-east-1'
53
53
  })