node-lambda 1.0.0 → 1.2.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/CHANGELOG.md CHANGED
@@ -456,3 +456,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
456
456
  - feat: remove BUILD from the exclusion list [#607](https://github.com/motdotla/node-lambda/pull/607)
457
457
  - BREAKING CHANGES
458
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)
466
+
467
+ ## [1.2.0] - 2022-12-21
468
+ ### Features
469
+ - Add support for nodejs18x [#616](https://github.com/motdotla/node-lambda/pull/616)
package/README.md CHANGED
@@ -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.js 16, Node.js 14 and Node.js 12. Please also check the [Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) page.
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/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 (!['nodejs12.x', 'nodejs14.x', 'nodejs16.x'].includes(program.runtime)) {
54
+ async run (program) {
55
+ if (!['nodejs14.x', 'nodejs16.x', 'nodejs18.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 handler = require(path.join(process.cwd(), filename))[handlername]
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 = (() => {
@@ -364,7 +375,7 @@ Emulate only the body of the API Gateway event.
364
375
  return true
365
376
  }
366
377
 
367
- if (!minimatch(src, pattern, { matchBase: true })) {
378
+ if (!minimatch(src, pattern, { matchBase: true, windowsPathsNoEscape: true })) {
368
379
  return true
369
380
  }
370
381
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-lambda",
3
- "version": "1.0.0",
3
+ "version": "1.2.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,21 +35,21 @@
35
35
  "node": ">= 10.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "archiver": "^5.3.0",
39
- "aws-sdk": "^2.1135.0",
40
- "aws-xray-sdk-core": "^3.3.4",
41
- "commander": "^9.0.0",
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.0",
44
- "fs-extra": "^10.0.0",
43
+ "dotenv": "^16.0.3",
44
+ "fs-extra": "^10.1.0",
45
45
  "klaw": "^4.0.1",
46
- "minimatch": "^5.0.0",
46
+ "minimatch": "^5.1.0",
47
47
  "proxy-agent": "^5.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "aws-sdk-mock": "^5.6.2",
50
+ "aws-sdk-mock": "^5.8.0",
51
51
  "chai": "^4.3.6",
52
- "mocha": "^9.2.0",
52
+ "mocha": "^10.1.0",
53
53
  "node-zip": "^1.1.1",
54
54
  "standard": "^17.0.0"
55
55
  }
package/test/main.js CHANGED
@@ -151,7 +151,7 @@ describe('lib/main', function () {
151
151
  })
152
152
 
153
153
  it('version should be set', () => {
154
- assert.equal(lambda.version, '1.0.0')
154
+ assert.equal(lambda.version, '1.2.0')
155
155
  })
156
156
 
157
157
  describe('_codeDirectory', () => {
@@ -171,6 +171,27 @@ describe('bin/node-lambda', () => {
171
171
  })
172
172
  })
173
173
 
174
+ describe('node-lambda run (Runtime nodejs18.x is supported)', () => {
175
+ const eventObj = {
176
+ asyncTest: false,
177
+ callbackWaitsForEmptyEventLoop: true // True is the default value of Lambda
178
+ }
179
+
180
+ before(() => {
181
+ process.env.AWS_RUNTIME = 'nodejs18.x'
182
+ })
183
+ after(() => {
184
+ process.env.AWS_RUNTIME = 'nodejs16.x'
185
+ })
186
+
187
+ it('`node-lambda run` exitCode is not `254` (callback(null))', (done) => {
188
+ _generateEventFile(Object.assign(eventObj, {
189
+ callbackCode: 'callback(null);'
190
+ }))
191
+ _testMain({ stdoutRegExp: /Success:$/, exitCode: 0 }, done)
192
+ })
193
+ })
194
+
174
195
  describe('node-lambda run (Multiple events))', () => {
175
196
  const eventObj = [{
176
197
  asyncTest: false,