serverless-offline 11.1.3 → 11.2.1

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "dedicatedTo": "Blue, a great migrating bird.",
3
3
  "name": "serverless-offline",
4
- "version": "11.1.3",
4
+ "version": "11.2.1",
5
5
  "description": "Emulate AWS λ and API Gateway locally when developing your Serverless project",
6
6
  "license": "MIT",
7
7
  "exports": {
@@ -82,17 +82,17 @@
82
82
  ]
83
83
  },
84
84
  "dependencies": {
85
+ "@aws-sdk/client-lambda": "^3.198.0",
85
86
  "@hapi/boom": "^10.0.0",
86
87
  "@hapi/h2o2": "^10.0.0",
87
88
  "@hapi/hapi": "^20.2.2",
88
- "@serverless/utils": "^6.8.0",
89
- "aws-sdk": "^2.1233.0",
89
+ "@serverless/utils": "^6.8.1",
90
90
  "boxen": "^7.0.0",
91
91
  "chalk": "^5.1.2",
92
92
  "execa": "^6.1.0",
93
93
  "fs-extra": "^10.1.0",
94
94
  "java-invoke-local": "0.0.6",
95
- "jose": "^4.10.0",
95
+ "jose": "^4.10.3",
96
96
  "js-string-escape": "^1.0.1",
97
97
  "jsonpath-plus": "^7.2.0",
98
98
  "jsonschema": "^1.4.1",
@@ -104,12 +104,12 @@
104
104
  "p-memoize": "^7.1.1",
105
105
  "p-retry": "^5.1.1",
106
106
  "velocityjs": "^2.0.6",
107
- "ws": "^8.9.0"
107
+ "ws": "^8.10.0"
108
108
  },
109
109
  "devDependencies": {
110
110
  "@istanbuljs/esm-loader-hook": "^0.2.0",
111
111
  "archiver": "^5.3.1",
112
- "eslint": "^8.25.0",
112
+ "eslint": "^8.26.0",
113
113
  "eslint-config-airbnb-base": "^15.0.0",
114
114
  "eslint-config-prettier": "^8.5.0",
115
115
  "eslint-plugin-import": "^2.25.4",
@@ -116,6 +116,9 @@ export default class HandlerRunner {
116
116
  log.error(
117
117
  `Unhandled exception in handler '${this.#funOptions.functionKey}'.`,
118
118
  )
119
+
120
+ log.error(err)
121
+
119
122
  throw err
120
123
  }
121
124
  }
@@ -3,8 +3,8 @@ import { createWriteStream } from 'node:fs'
3
3
  import { readFile, unlink, writeFile } from 'node:fs/promises'
4
4
  import { platform } from 'node:os'
5
5
  import { dirname, join, sep } from 'node:path'
6
+ import { LambdaClient, GetLayerVersionCommand } from '@aws-sdk/client-lambda'
6
7
  import { log, progress } from '@serverless/utils/log.js'
7
- import aws from 'aws-sdk'
8
8
  import { execa } from 'execa'
9
9
  import { ensureDir, pathExists } from 'fs-extra'
10
10
  import jszip from 'jszip'
@@ -31,7 +31,7 @@ export default class DockerContainer {
31
31
 
32
32
  #imageNameTag = null
33
33
 
34
- #lambda = null
34
+ #lambdaClient = null
35
35
 
36
36
  #layers = null
37
37
 
@@ -114,23 +114,21 @@ export default class DockerContainer {
114
114
  `Layers already exist for this function. Skipping download.`,
115
115
  )
116
116
  } else {
117
- const layers = []
118
-
119
117
  log.verbose(`Storing layers at ${layerDir}`)
120
118
 
121
119
  // Only initialise if we have layers, we're using AWS, and they don't already exist
122
- this.#lambda = new aws.Lambda({
120
+ this.#lambdaClient = new LambdaClient({
123
121
  apiVersion: '2015-03-31',
124
122
  region: this.#provider.region,
125
123
  })
126
124
 
127
125
  log.verbose(`Getting layers`)
128
126
 
129
- for (const layerArn of this.#layers) {
130
- layers.push(this.#downloadLayer(layerArn, layerDir))
131
- }
132
-
133
- await Promise.all(layers)
127
+ await Promise.all(
128
+ this.#layers.map((layerArn) =>
129
+ this.#downloadLayer(layerArn, layerDir),
130
+ ),
131
+ )
134
132
  }
135
133
 
136
134
  if (
@@ -227,24 +225,24 @@ export default class DockerContainer {
227
225
  }
228
226
 
229
227
  async #downloadLayer(layerArn, layerDir) {
230
- const layerName = layerArn.split(':layer:')[1]
228
+ const [, layerName] = layerArn.split(':layer:')
231
229
  const layerZipFile = `${layerDir}/${layerName}.zip`
232
230
  const layerProgress = progress.get(`layer-${layerName}`)
233
231
 
234
232
  log.verbose(`[${layerName}] ARN: ${layerArn}`)
235
233
 
236
- const params = {
237
- Arn: layerArn,
238
- }
239
-
240
234
  log.verbose(`[${layerName}] Getting Info`)
241
235
  layerProgress.notice(`Retrieving "${layerName}": Getting info`)
242
236
 
237
+ const getLayerVersionCommand = new GetLayerVersionCommand({
238
+ LayerName: layerArn,
239
+ })
240
+
243
241
  try {
244
242
  let layer = null
245
243
 
246
244
  try {
247
- layer = await this.#lambda.getLayerVersionByArn(params).promise()
245
+ layer = await this.#lambdaClient.send(getLayerVersionCommand)
248
246
  } catch (err) {
249
247
  log.warning(`[${layerName}] ${err.code}: ${err.message}`)
250
248
 
@@ -264,11 +262,9 @@ export default class DockerContainer {
264
262
  return
265
263
  }
266
264
 
267
- const layerUrl = layer.Content.Location
265
+ const { CodeSize: layerSize, Location: layerUrl } = layer.Content
268
266
  // const layerSha = layer.Content.CodeSha256
269
267
 
270
- const layerSize = layer.Content.CodeSize
271
-
272
268
  await ensureDir(layerDir)
273
269
 
274
270
  log.verbose(
@@ -282,9 +278,7 @@ export default class DockerContainer {
282
278
  )}`,
283
279
  )
284
280
 
285
- const res = await fetch(layerUrl, {
286
- method: 'get',
287
- })
281
+ const res = await fetch(layerUrl)
288
282
 
289
283
  if (!res.ok) {
290
284
  log.warning(