node-lambda 0.22.0 → 1.1.0
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/.github/workflows/workflow.yml +2 -2
- package/CHANGELOG.md +13 -0
- package/README.md +4 -4
- package/bin/node-lambda +1 -1
- package/lib/.env.example +2 -2
- package/lib/aws.js +1 -1
- package/lib/cloudwatch_logs.js +1 -1
- package/lib/main.js +21 -9
- package/lib/s3_deploy.js +2 -2
- package/lib/s3_events.js +2 -2
- package/lib/schedule_events.js +1 -1
- package/package.json +11 -11
- package/test/main.js +3 -4
- package/test/node-lambda.js +1 -1
- package/test/s3_events.js +1 -1
|
@@ -9,7 +9,7 @@ jobs:
|
|
|
9
9
|
strategy:
|
|
10
10
|
fail-fast: false
|
|
11
11
|
matrix:
|
|
12
|
-
node-version: [14.x, 16.x,
|
|
12
|
+
node-version: [14.x, 16.x, 18.x]
|
|
13
13
|
steps:
|
|
14
14
|
- uses: actions/checkout@v2
|
|
15
15
|
- uses: actions/setup-node@v2
|
|
@@ -33,7 +33,7 @@ jobs:
|
|
|
33
33
|
- uses: actions/checkout@v2
|
|
34
34
|
- uses: actions/setup-node@v2
|
|
35
35
|
with:
|
|
36
|
-
node-version:
|
|
36
|
+
node-version: 18.x
|
|
37
37
|
cache: 'npm'
|
|
38
38
|
- run: npm i -g npm
|
|
39
39
|
- run: node -v
|
package/CHANGELOG.md
CHANGED
|
@@ -450,3 +450,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
450
450
|
- Support for Architectures parameter [#591](https://github.com/motdotla/node-lambda/pull/591)
|
|
451
451
|
### Bugfixes
|
|
452
452
|
- fix: skip installing the package, when there is no `package.json` [#589](https://github.com/motdotla/node-lambda/pull/589)
|
|
453
|
+
|
|
454
|
+
## [1.0.0] - 2022-05-19
|
|
455
|
+
### Features
|
|
456
|
+
- feat: remove BUILD from the exclusion list [#607](https://github.com/motdotla/node-lambda/pull/607)
|
|
457
|
+
- BREAKING CHANGES
|
|
458
|
+
- add nodejs16.x to runtime [#605](https://github.com/motdotla/node-lambda/pull/605)
|
|
459
|
+
|
|
460
|
+
## [1.1.0] - 2022-10-26
|
|
461
|
+
### Features
|
|
462
|
+
- feat: support esm [#613](https://github.com/motdotla/node-lambda/pull/613)
|
|
463
|
+
|
|
464
|
+
### Bugfixes
|
|
465
|
+
- fix the bug in `excludeGlobs` in `_fileCopy` [#609](https://github.com/motdotla/node-lambda/pull/609)
|
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ AWS_TIMEOUT // (default: 60)
|
|
|
83
83
|
AWS_RUN_TIMEOUT // (default: 3)
|
|
84
84
|
AWS_ARCHITECTURE // (default: 'x86_64')
|
|
85
85
|
AWS_DESCRIPTION // (default: package.json.description or '')
|
|
86
|
-
AWS_RUNTIME // (default: '
|
|
86
|
+
AWS_RUNTIME // (default: 'nodejs16.x')
|
|
87
87
|
AWS_PUBLISH // (default: false)
|
|
88
88
|
AWS_FUNCTION_VERSION // (default: '')
|
|
89
89
|
AWS_VPC_SUBNETS // (default: '')
|
|
@@ -118,7 +118,7 @@ Run your Amazon Lambda application locally
|
|
|
118
118
|
Options:
|
|
119
119
|
-H, --handler [AWS_HANDLER] Lambda Handler {index.handler} (default: "index.handler")
|
|
120
120
|
-j, --eventFile [EVENT_FILE] Event JSON File (default: "event.json")
|
|
121
|
-
-u, --runtime [AWS_RUNTIME] Lambda Runtime (default: "
|
|
121
|
+
-u, --runtime [AWS_RUNTIME] Lambda Runtime (default: "nodejs16.x")
|
|
122
122
|
-t, --timeout [AWS_RUN_TIMEOUT] Lambda Timeout (default: 3)
|
|
123
123
|
-f, --configFile [CONFIG_FILE] Path to file holding secret environment variables (e.g. "deploy.env") (default: "")
|
|
124
124
|
-x, --contextFile [CONTEXT_FILE] Context JSON File (default: "context.json")
|
|
@@ -182,7 +182,7 @@ Options:
|
|
|
182
182
|
-t, --timeout [AWS_TIMEOUT] Lambda Timeout (default: 60)
|
|
183
183
|
--architecture [AWS_ARCHITECTURE] The instruction set architecture that the function supports. (x86_64|arm64) (default: "x86_64")
|
|
184
184
|
-d, --description [AWS_DESCRIPTION] Lambda Description (default: "Command line tool for locally running and remotely deploying your node.js applications to Amazon Lambda.")
|
|
185
|
-
-u, --runtime [AWS_RUNTIME] Lambda Runtime (default: "
|
|
185
|
+
-u, --runtime [AWS_RUNTIME] Lambda Runtime (default: "nodejs16.x")
|
|
186
186
|
-p, --publish [AWS_PUBLISH] Lambda Publish (default: false)
|
|
187
187
|
-L, --lambdaVersion [AWS_FUNCTION_VERSION] Lambda Function Version (default: "")
|
|
188
188
|
-b, --vpcSubnets [AWS_VPC_SUBNETS] Lambda Function VPC Subnet IDs (comma delimited) (default: "")
|
|
@@ -221,7 +221,7 @@ AWS Lambda will let you set environment variables for your function. Use the sam
|
|
|
221
221
|
|
|
222
222
|
## Node.js Runtime Configuration
|
|
223
223
|
|
|
224
|
-
AWS Lambda now supports Node.
|
|
224
|
+
AWS Lambda now supports Node.js 16 and Node.js 14. Please also check the [Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) page.
|
|
225
225
|
|
|
226
226
|
## Use S3 to deploy
|
|
227
227
|
|
package/bin/node-lambda
CHANGED
|
@@ -31,7 +31,7 @@ const AWS_TIMEOUT = process.env.AWS_TIMEOUT || 60
|
|
|
31
31
|
const AWS_RUN_TIMEOUT = process.env.AWS_RUN_TIMEOUT || 3
|
|
32
32
|
const AWS_ARCHITECTURE = process.env.AWS_ARCHITECTURE || 'x86_64'
|
|
33
33
|
const AWS_DESCRIPTION = process.env.AWS_DESCRIPTION || packageJson.description || ''
|
|
34
|
-
const AWS_RUNTIME = process.env.AWS_RUNTIME || '
|
|
34
|
+
const AWS_RUNTIME = process.env.AWS_RUNTIME || 'nodejs16.x'
|
|
35
35
|
const AWS_PUBLISH = process.env.AWS_PUBLISH || false
|
|
36
36
|
const AWS_FUNCTION_VERSION = process.env.AWS_FUNCTION_VERSION || ''
|
|
37
37
|
const AWS_VPC_SUBNETS = process.env.AWS_VPC_SUBNETS || ''
|
package/lib/.env.example
CHANGED
|
@@ -10,10 +10,10 @@ AWS_HANDLER=index.handler
|
|
|
10
10
|
AWS_MEMORY_SIZE=128
|
|
11
11
|
AWS_TIMEOUT=3
|
|
12
12
|
AWS_DESCRIPTION=
|
|
13
|
-
AWS_RUNTIME=
|
|
13
|
+
AWS_RUNTIME=nodejs16.x
|
|
14
14
|
AWS_VPC_SUBNETS=
|
|
15
15
|
AWS_VPC_SECURITY_GROUPS=
|
|
16
16
|
AWS_TRACING_CONFIG=
|
|
17
17
|
AWS_LOGS_RETENTION_IN_DAYS=
|
|
18
|
-
EXCLUDE_GLOBS="event.json"
|
|
18
|
+
EXCLUDE_GLOBS="event.json build/"
|
|
19
19
|
PACKAGE_DIRECTORY=build
|
package/lib/aws.js
CHANGED
|
@@ -6,7 +6,7 @@ const proxy = require('proxy-agent')
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
sdk: aws,
|
|
8
8
|
updateConfig (config, region) {
|
|
9
|
-
const awsSecurity = { region
|
|
9
|
+
const awsSecurity = { region }
|
|
10
10
|
|
|
11
11
|
if (config.profile) {
|
|
12
12
|
aws.config.credentials = new aws.SharedIniFileCredentials({
|
package/lib/cloudwatch_logs.js
CHANGED
package/lib/main.js
CHANGED
|
@@ -51,8 +51,8 @@ Edit the .env, deploy.env, ${program.contextFile}, \
|
|
|
51
51
|
event_sources.json and ${program.eventFile} files as needed.`)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
run (program) {
|
|
55
|
-
if (!['
|
|
54
|
+
async run (program) {
|
|
55
|
+
if (!['nodejs14.x', 'nodejs16.x'].includes(program.runtime)) {
|
|
56
56
|
console.error(`Runtime [${program.runtime}] is not supported.`)
|
|
57
57
|
process.exit(254)
|
|
58
58
|
}
|
|
@@ -67,7 +67,18 @@ event_sources.json and ${program.eventFile} files as needed.`)
|
|
|
67
67
|
this._setRunTimeEnvironmentVars(program)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const
|
|
70
|
+
const handlerFilePath = (() => {
|
|
71
|
+
const filePath = path.join(process.cwd(), filename)
|
|
72
|
+
if (path.sep === '\\') {
|
|
73
|
+
// Convert because of error in Windows.
|
|
74
|
+
// Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]:
|
|
75
|
+
// Only URLs with a scheme in: file, data are supported by the default ESM loader.
|
|
76
|
+
// On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
|
|
77
|
+
return 'file:///' + filePath.split(path.sep).join('/')
|
|
78
|
+
}
|
|
79
|
+
return filePath
|
|
80
|
+
})()
|
|
81
|
+
const handler = (await import(handlerFilePath))[handlername]
|
|
71
82
|
const event = require(path.join(process.cwd(), program.eventFile))
|
|
72
83
|
const context = require(path.join(process.cwd(), program.contextFile))
|
|
73
84
|
const enableRunMultipleEvents = (() => {
|
|
@@ -336,8 +347,7 @@ Emulate only the body of the API Gateway event.
|
|
|
336
347
|
'.editorconfig',
|
|
337
348
|
'.lambda',
|
|
338
349
|
'deploy.env',
|
|
339
|
-
'*.log'
|
|
340
|
-
path.join('build', path.sep)
|
|
350
|
+
'*.log'
|
|
341
351
|
]
|
|
342
352
|
.concat(program.excludeGlobs ? program.excludeGlobs.split(' ') : [])
|
|
343
353
|
.concat(excludeNodeModules ? [path.join('node_modules')] : [])
|
|
@@ -352,7 +362,7 @@ Emulate only the body of the API Gateway event.
|
|
|
352
362
|
}
|
|
353
363
|
return str
|
|
354
364
|
}).join(',') + '}'
|
|
355
|
-
const dirPatternRegExp = new RegExp(`(${dirBlobs.join('|')})$`)
|
|
365
|
+
const dirPatternRegExp = dirBlobs.length > 0 ? new RegExp(`(${dirBlobs.join('|')})$`) : null
|
|
356
366
|
|
|
357
367
|
return new Promise((resolve, reject) => {
|
|
358
368
|
fs.mkdirs(dest, (err) => {
|
|
@@ -365,13 +375,15 @@ Emulate only the body of the API Gateway event.
|
|
|
365
375
|
return true
|
|
366
376
|
}
|
|
367
377
|
|
|
368
|
-
if (!minimatch(src, pattern, { matchBase: true })) {
|
|
378
|
+
if (!minimatch(src, pattern, { matchBase: true, windowsPathsNoEscape: true })) {
|
|
369
379
|
return true
|
|
370
380
|
}
|
|
381
|
+
|
|
371
382
|
// Directory check. Even if `src` is a directory it will not end with '/'.
|
|
372
|
-
if (!dirPatternRegExp.test(src)) {
|
|
383
|
+
if (dirPatternRegExp === null || !dirPatternRegExp.test(src)) {
|
|
373
384
|
return false
|
|
374
385
|
}
|
|
386
|
+
|
|
375
387
|
return !fs.statSync(src).isDirectory()
|
|
376
388
|
}
|
|
377
389
|
}
|
|
@@ -973,7 +985,7 @@ they may not work as expected in the Lambda environment.
|
|
|
973
985
|
console.log(params)
|
|
974
986
|
|
|
975
987
|
const lambda = new aws.sdk.Lambda({
|
|
976
|
-
region
|
|
988
|
+
region,
|
|
977
989
|
apiVersion: '2015-03-31'
|
|
978
990
|
})
|
|
979
991
|
const scheduleEvents = new ScheduleEvents(aws.sdk, region)
|
package/lib/s3_deploy.js
CHANGED
|
@@ -35,7 +35,7 @@ class S3Deploy {
|
|
|
35
35
|
constructor (aws, region) {
|
|
36
36
|
// Authenticated `aws` object in `lib/main.js`
|
|
37
37
|
this.s3 = new aws.S3({
|
|
38
|
-
region
|
|
38
|
+
region,
|
|
39
39
|
apiVersion: '2006-03-01'
|
|
40
40
|
})
|
|
41
41
|
}
|
|
@@ -133,7 +133,7 @@ class S3Deploy {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
putPackage (params, region, buffer) {
|
|
136
|
-
const _params = Object.assign({ region
|
|
136
|
+
const _params = Object.assign({ region }, params)
|
|
137
137
|
_params.bucketName = this._bucketName(_params)
|
|
138
138
|
_params.s3Key = this._s3Key(_params)
|
|
139
139
|
|
package/lib/s3_events.js
CHANGED
|
@@ -8,11 +8,11 @@ class S3Events {
|
|
|
8
8
|
constructor (aws, region) {
|
|
9
9
|
// Authenticated `aws` object in `lib/main.js`
|
|
10
10
|
this.lambda = new aws.Lambda({
|
|
11
|
-
region
|
|
11
|
+
region,
|
|
12
12
|
apiVersion: '2015-03-31'
|
|
13
13
|
})
|
|
14
14
|
this.s3 = new aws.S3({
|
|
15
|
-
region
|
|
15
|
+
region,
|
|
16
16
|
apiVersion: '2006-03-01'
|
|
17
17
|
})
|
|
18
18
|
}
|
package/lib/schedule_events.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-lambda",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Command line tool for locally running and remotely deploying your node.js applications to Amazon Lambda.",
|
|
5
5
|
"main": "lib/main.js",
|
|
6
6
|
"directories": {
|
|
@@ -35,22 +35,22 @@
|
|
|
35
35
|
"node": ">= 10.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"archiver": "^5.3.
|
|
39
|
-
"aws-sdk": "^2.
|
|
40
|
-
"aws-xray-sdk-core": "^3.3.
|
|
41
|
-
"commander": "^9.
|
|
38
|
+
"archiver": "^5.3.1",
|
|
39
|
+
"aws-sdk": "^2.1238.0",
|
|
40
|
+
"aws-xray-sdk-core": "^3.3.8",
|
|
41
|
+
"commander": "^9.4.1",
|
|
42
42
|
"continuation-local-storage": "^3.2.1",
|
|
43
|
-
"dotenv": "^16.0.
|
|
44
|
-
"fs-extra": "^10.
|
|
43
|
+
"dotenv": "^16.0.3",
|
|
44
|
+
"fs-extra": "^10.1.0",
|
|
45
45
|
"klaw": "^4.0.1",
|
|
46
|
-
"minimatch": "^5.
|
|
46
|
+
"minimatch": "^5.1.0",
|
|
47
47
|
"proxy-agent": "^5.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"aws-sdk-mock": "^5.
|
|
50
|
+
"aws-sdk-mock": "^5.8.0",
|
|
51
51
|
"chai": "^4.3.6",
|
|
52
|
-
"mocha": "^
|
|
52
|
+
"mocha": "^10.1.0",
|
|
53
53
|
"node-zip": "^1.1.1",
|
|
54
|
-
"standard": "^
|
|
54
|
+
"standard": "^17.0.0"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/test/main.js
CHANGED
|
@@ -22,7 +22,7 @@ const originalProgram = {
|
|
|
22
22
|
memorySize: 128,
|
|
23
23
|
timeout: 3,
|
|
24
24
|
description: '',
|
|
25
|
-
runtime: '
|
|
25
|
+
runtime: 'nodejs16.x',
|
|
26
26
|
deadLetterConfigTargetArn: '',
|
|
27
27
|
tracingConfig: '',
|
|
28
28
|
Layers: '',
|
|
@@ -151,7 +151,7 @@ describe('lib/main', function () {
|
|
|
151
151
|
})
|
|
152
152
|
|
|
153
153
|
it('version should be set', () => {
|
|
154
|
-
assert.equal(lambda.version, '
|
|
154
|
+
assert.equal(lambda.version, '1.1.0')
|
|
155
155
|
})
|
|
156
156
|
|
|
157
157
|
describe('_codeDirectory', () => {
|
|
@@ -459,7 +459,6 @@ describe('lib/main', function () {
|
|
|
459
459
|
|
|
460
460
|
describe('_fileCopy', () => {
|
|
461
461
|
before(() => {
|
|
462
|
-
fs.mkdirSync('build')
|
|
463
462
|
fs.mkdirsSync(path.join('__unittest', 'hoge'))
|
|
464
463
|
fs.mkdirsSync(path.join('__unittest', 'fuga'))
|
|
465
464
|
fs.writeFileSync(path.join('__unittest', 'hoge', 'piyo'), '')
|
|
@@ -467,7 +466,7 @@ describe('lib/main', function () {
|
|
|
467
466
|
fs.writeFileSync('fuga', '')
|
|
468
467
|
})
|
|
469
468
|
after(() => {
|
|
470
|
-
['
|
|
469
|
+
['fuga', '__unittest'].forEach((path) => {
|
|
471
470
|
fs.removeSync(path)
|
|
472
471
|
})
|
|
473
472
|
})
|
package/test/node-lambda.js
CHANGED
|
@@ -157,7 +157,7 @@ describe('bin/node-lambda', () => {
|
|
|
157
157
|
process.env.AWS_RUNTIME = 'test'
|
|
158
158
|
})
|
|
159
159
|
after(() => {
|
|
160
|
-
process.env.AWS_RUNTIME = '
|
|
160
|
+
process.env.AWS_RUNTIME = 'nodejs16.x'
|
|
161
161
|
})
|
|
162
162
|
|
|
163
163
|
it('`node-lambda run` exitCode is `254` (callback(null))', (done) => {
|
package/test/s3_events.js
CHANGED