serverless-offline 11.2.0 → 11.2.2
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.2.
|
|
4
|
+
"version": "11.2.2",
|
|
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.199.0",
|
|
85
86
|
"@hapi/boom": "^10.0.0",
|
|
86
87
|
"@hapi/h2o2": "^10.0.0",
|
|
87
88
|
"@hapi/hapi": "^20.2.2",
|
|
88
89
|
"@serverless/utils": "^6.8.1",
|
|
89
|
-
"aws-sdk": "^2.1241.0",
|
|
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.
|
|
95
|
+
"jose": "^4.10.4",
|
|
96
96
|
"js-string-escape": "^1.0.1",
|
|
97
97
|
"jsonpath-plus": "^7.2.0",
|
|
98
98
|
"jsonschema": "^1.4.1",
|
|
@@ -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
|
-
#
|
|
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.#
|
|
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
|
-
|
|
130
|
-
layers.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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:')
|
|
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.#
|
|
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
|
|
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(
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export default function generateHapiPath(path, options, serverless) {
|
|
2
|
-
// path must start with '/'
|
|
3
2
|
let hapiPath = path.startsWith('/') ? path : `/${path}`
|
|
4
3
|
|
|
5
4
|
if (!options.noPrependStageInUrl) {
|
|
@@ -12,7 +11,7 @@ export default function generateHapiPath(path, options, serverless) {
|
|
|
12
11
|
hapiPath = `/${options.prefix}${hapiPath}`
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
if (hapiPath !== '/' && hapiPath.endsWith('/')
|
|
14
|
+
if (hapiPath !== '/' && hapiPath.endsWith('/')) {
|
|
16
15
|
hapiPath = hapiPath.slice(0, -1)
|
|
17
16
|
}
|
|
18
17
|
|