node-lambda 1.1.0 → 1.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/.github/dependabot.yml +10 -0
- package/.github/workflows/codeql-analysis.yml +57 -0
- package/.github/workflows/workflow.yml +6 -8
- package/CHANGELOG.md +17 -0
- package/README.md +21 -17
- package/lib/.env.example +1 -1
- package/lib/main.js +2 -2
- package/lib/s3_deploy.js +4 -3
- package/package.json +10 -10
- package/test/main.js +36 -22
- package/test/node-lambda.js +19 -1
- package/test/testPj/index.js +0 -0
- package/test/testPj/package-lock.json +114 -0
- package/test/testPj/package.json +9 -0
- package/.travis.yml +0 -24
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: "CodeQL"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
# The branches below must be a subset of the branches above
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
schedule:
|
|
10
|
+
- cron: '20 21 * * 0'
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
analyze:
|
|
14
|
+
name: Analyze
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
permissions:
|
|
17
|
+
actions: read
|
|
18
|
+
contents: read
|
|
19
|
+
security-events: write
|
|
20
|
+
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
language: [ 'javascript' ]
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- name: Checkout repository
|
|
28
|
+
uses: actions/checkout@v4
|
|
29
|
+
|
|
30
|
+
# Initializes the CodeQL tools for scanning.
|
|
31
|
+
- name: Initialize CodeQL
|
|
32
|
+
uses: github/codeql-action/init@v2
|
|
33
|
+
with:
|
|
34
|
+
languages: ${{ matrix.language }}
|
|
35
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
36
|
+
# By default, queries listed here will override any specified in a config file.
|
|
37
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
38
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
|
39
|
+
|
|
40
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
41
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
42
|
+
- name: Autobuild
|
|
43
|
+
uses: github/codeql-action/autobuild@v2
|
|
44
|
+
|
|
45
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
46
|
+
# 📚 https://git.io/JvXDl
|
|
47
|
+
|
|
48
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
|
49
|
+
# and modify them (or add more) to build your code if your project
|
|
50
|
+
# uses a compiled language
|
|
51
|
+
|
|
52
|
+
#- run: |
|
|
53
|
+
# make bootstrap
|
|
54
|
+
# make release
|
|
55
|
+
|
|
56
|
+
- name: Perform CodeQL Analysis
|
|
57
|
+
uses: github/codeql-action/analyze@v2
|
|
@@ -9,14 +9,13 @@ jobs:
|
|
|
9
9
|
strategy:
|
|
10
10
|
fail-fast: false
|
|
11
11
|
matrix:
|
|
12
|
-
node-version: [
|
|
12
|
+
node-version: [16.x, 18.x, 20.x]
|
|
13
13
|
steps:
|
|
14
|
-
- uses: actions/checkout@
|
|
15
|
-
- uses: actions/setup-node@
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
16
|
with:
|
|
17
17
|
node-version: ${{ matrix.node-version }}
|
|
18
18
|
cache: 'npm'
|
|
19
|
-
- run: npm i -g npm
|
|
20
19
|
- run: node -v
|
|
21
20
|
- run: npm -v
|
|
22
21
|
- run: npm ci
|
|
@@ -30,12 +29,11 @@ jobs:
|
|
|
30
29
|
matrix:
|
|
31
30
|
os: [windows-latest, macos-latest]
|
|
32
31
|
steps:
|
|
33
|
-
- uses: actions/checkout@
|
|
34
|
-
- uses: actions/setup-node@
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-node@v4
|
|
35
34
|
with:
|
|
36
|
-
node-version:
|
|
35
|
+
node-version: 20.x
|
|
37
36
|
cache: 'npm'
|
|
38
|
-
- run: npm i -g npm
|
|
39
37
|
- run: node -v
|
|
40
38
|
- run: npm -v
|
|
41
39
|
- run: npm ci
|
package/CHANGELOG.md
CHANGED
|
@@ -463,3 +463,20 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
463
463
|
|
|
464
464
|
### Bugfixes
|
|
465
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)
|
|
470
|
+
|
|
471
|
+
## [1.2.1] - 2023-11-28
|
|
472
|
+
### Features
|
|
473
|
+
- Add 'ap-southeast-3' to S3_LOCATION_POSSIBLE_VALUES [#621](https://github.com/motdotla/node-lambda/pull/621)
|
|
474
|
+
|
|
475
|
+
### Bugfixes
|
|
476
|
+
- Fix minimatch import [#640](https://github.com/motdotla/node-lambda/pull/640)
|
|
477
|
+
- Fix typo [#654](https://github.com/motdotla/node-lambda/pull/654)
|
|
478
|
+
|
|
479
|
+
### Minor changes
|
|
480
|
+
- Improve testing
|
|
481
|
+
- Update dependencies
|
|
482
|
+
- Update README
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
If you found this useful, consider also checking out [dotenv-vault](https://github.com/dotenv-org/dotenv-vault). Thank you! 😇
|
|
2
|
+
|
|
1
3
|
# node-lambda
|
|
2
4
|
|
|
3
5
|

|
|
@@ -5,7 +7,6 @@
|
|
|
5
7
|
Command line tool to locally run and deploy your node.js application to [Amazon Lambda](http://aws.amazon.com/lambda/).
|
|
6
8
|
|
|
7
9
|

|
|
8
|
-
[](https://travis-ci.org/motdotla/node-lambda)
|
|
9
10
|
[](http://badge.fury.io/js/node-lambda)
|
|
10
11
|
|
|
11
12
|
```
|
|
@@ -14,6 +15,14 @@ $ node-lambda run
|
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
16
17
|
|
|
18
|
+
With `npx`:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
$ npx node-lambda@latest [COMMAND]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Globally installed:
|
|
25
|
+
|
|
17
26
|
```
|
|
18
27
|
$ npm install -g node-lambda
|
|
19
28
|
```
|
|
@@ -29,10 +38,10 @@ Example apps make it easy to get up and running
|
|
|
29
38
|
There are 4 available commands.
|
|
30
39
|
|
|
31
40
|
```
|
|
32
|
-
$ node-lambda setup
|
|
33
|
-
$ node-lambda run
|
|
34
|
-
$ node-lambda package
|
|
35
|
-
$ node-lambda deploy
|
|
41
|
+
$ npx node-lambda@latest setup
|
|
42
|
+
$ npx node-lambda@latest run
|
|
43
|
+
$ npx node-lambda@latest package
|
|
44
|
+
$ npx node-lambda@latest deploy
|
|
36
45
|
```
|
|
37
46
|
|
|
38
47
|
### Commands
|
|
@@ -42,7 +51,7 @@ $ node-lambda deploy
|
|
|
42
51
|
Initializes the `event.json`, `context.json`, `.env`, `deploy.env` files, and `event_sources.json` files. `event.json` is where you mock your event. `context.json` is where you can add additional mock data to the context passed to your lambda function. `.env` is where you place your deployment configuration. `deploy.env` has the same format as `.env`, but is used for holding any environment/config variables that you need to be deployed with your code to Lambda but you don't want in version control (e.g. DB connection info). `event_sources.json` is used to set the event source of the Lambda function (Not all event sources available in Lambda are supported).
|
|
43
52
|
|
|
44
53
|
```
|
|
45
|
-
$ node-lambda setup --help
|
|
54
|
+
$ npx node-lambda@latest setup --help
|
|
46
55
|
|
|
47
56
|
Usage: setup [options]
|
|
48
57
|
|
|
@@ -110,7 +119,7 @@ AWS_TAGS // (default: '')
|
|
|
110
119
|
Runs your Amazon Lambda index.js file locally. Passes `event.json` data to the Amazon Lambda event object.
|
|
111
120
|
|
|
112
121
|
```
|
|
113
|
-
$ node-lambda run --help
|
|
122
|
+
$ npx node-lambda@latest run --help
|
|
114
123
|
Usage: node-lambda run|execute [options]
|
|
115
124
|
|
|
116
125
|
Run your Amazon Lambda application locally
|
|
@@ -133,7 +142,7 @@ Options:
|
|
|
133
142
|
Bundles your application into a local zip file.
|
|
134
143
|
|
|
135
144
|
```
|
|
136
|
-
$ node-lambda package --help
|
|
145
|
+
$ npx node-lambda@latest package --help
|
|
137
146
|
Usage: node-lambda package|zip [options]
|
|
138
147
|
|
|
139
148
|
Create zipped package for Amazon Lambda deployment
|
|
@@ -161,7 +170,7 @@ Options:
|
|
|
161
170
|
Bundles and deploys your application up to Amazon Lambda.
|
|
162
171
|
|
|
163
172
|
```
|
|
164
|
-
$ node-lambda deploy --help
|
|
173
|
+
$ npx node-lambda@latest deploy --help
|
|
165
174
|
Usage: node-lambda deploy [options]
|
|
166
175
|
|
|
167
176
|
Deploy your application to Amazon Lambda
|
|
@@ -212,7 +221,7 @@ Options:
|
|
|
212
221
|
If you are deploying to a custom endpoint you may also need to pass in an access key/secret. For localstack these can be anything, but cannot be blank:
|
|
213
222
|
|
|
214
223
|
```
|
|
215
|
-
node-lambda deploy --endpoint http://localhost:4574 --accessKey '1234' --secretKey '1234'
|
|
224
|
+
npx node-lambda@latest deploy --endpoint http://localhost:4574 --accessKey '1234' --secretKey '1234'
|
|
216
225
|
```
|
|
217
226
|
|
|
218
227
|
## Custom Environment Variables
|
|
@@ -221,12 +230,12 @@ AWS Lambda will let you set environment variables for your function. Use the sam
|
|
|
221
230
|
|
|
222
231
|
## Node.js Runtime Configuration
|
|
223
232
|
|
|
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.
|
|
233
|
+
AWS Lambda now supports Node.js 18, 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
234
|
|
|
226
235
|
## Use S3 to deploy
|
|
227
236
|
|
|
228
237
|
Use the command line argument `--deployUseS3` or `-B`. (This option is true/false.)
|
|
229
|
-
Example: `% node-lambda deploy -B`
|
|
238
|
+
Example: `% npx node-lambda@latest deploy -B`
|
|
230
239
|
|
|
231
240
|
You can also set the environment variable `DEPLOY_USE_S3`.
|
|
232
241
|
Example: `DEPLOY_USE_S3=true`
|
|
@@ -292,11 +301,6 @@ When setting ScheduleState to `ENABLED` or `DISABLED` for ScheduleEvents, it is
|
|
|
292
301
|
###### Duplicate ScheduleEvent Triggers
|
|
293
302
|
If you are adding a trigger via the `eventSourceFile` for the first time, remove preexisting triggers from the Lambda console before deploying. Deploying a Lambda with the `--eventSourceFile` flag will *NOT* overwrite the same triggers created from the AWS console and may result in a duplicate triggers for the same rule.
|
|
294
303
|
|
|
295
|
-
## Other AWS Lambda Tools Projects
|
|
296
|
-
|
|
297
|
-
+ [lambdaws](https://github.com/mentum/lambdaws)
|
|
298
|
-
+ [lambdaws-instant-api](https://github.com/mentum/lambdaws-instant-api)
|
|
299
|
-
|
|
300
304
|
## Contributing
|
|
301
305
|
|
|
302
306
|
1. Fork it
|
package/lib/.env.example
CHANGED
package/lib/main.js
CHANGED
|
@@ -8,7 +8,7 @@ const { exec, execSync, execFile } = require('child_process')
|
|
|
8
8
|
const fs = require('fs-extra')
|
|
9
9
|
const klaw = require('klaw')
|
|
10
10
|
const packageJson = require(path.join(__dirname, '..', 'package.json'))
|
|
11
|
-
const minimatch = require('minimatch')
|
|
11
|
+
const { minimatch } = require('minimatch')
|
|
12
12
|
const archiver = require('archiver')
|
|
13
13
|
const dotenv = require('dotenv')
|
|
14
14
|
const ScheduleEvents = require(path.join(__dirname, 'schedule_events'))
|
|
@@ -52,7 +52,7 @@ event_sources.json and ${program.eventFile} files as needed.`)
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
async run (program) {
|
|
55
|
-
if (!['nodejs14.x', 'nodejs16.x'].includes(program.runtime)) {
|
|
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
|
}
|
package/lib/s3_deploy.js
CHANGED
|
@@ -13,6 +13,7 @@ const S3_LOCATION_POSSIBLE_VALUES = [
|
|
|
13
13
|
'ap-south-1',
|
|
14
14
|
'ap-southeast-1',
|
|
15
15
|
'ap-southeast-2',
|
|
16
|
+
'ap-southeast-3',
|
|
16
17
|
'ca-central-1',
|
|
17
18
|
'cn-north-1',
|
|
18
19
|
'cn-northwest-1',
|
|
@@ -100,10 +101,10 @@ class S3Deploy {
|
|
|
100
101
|
const _params = {
|
|
101
102
|
Bucket: params.bucketName
|
|
102
103
|
}
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
104
|
+
const s3Location = this._getS3Location(params.region)
|
|
105
|
+
if (s3Location != null) {
|
|
105
106
|
_params.CreateBucketConfiguration = {
|
|
106
|
-
LocationConstraint:
|
|
107
|
+
LocationConstraint: s3Location
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
return new Promise((resolve, reject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-lambda",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
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,20 +35,20 @@
|
|
|
35
35
|
"node": ">= 10.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"archiver": "^
|
|
39
|
-
"aws-sdk": "^2.
|
|
40
|
-
"aws-xray-sdk-core": "^3.
|
|
41
|
-
"commander": "^
|
|
38
|
+
"archiver": "^6.0.0",
|
|
39
|
+
"aws-sdk": "^2.1377.0",
|
|
40
|
+
"aws-xray-sdk-core": "^3.5.0",
|
|
41
|
+
"commander": "^11.0.0",
|
|
42
42
|
"continuation-local-storage": "^3.2.1",
|
|
43
43
|
"dotenv": "^16.0.3",
|
|
44
|
-
"fs-extra": "^
|
|
45
|
-
"klaw": "^4.0
|
|
46
|
-
"minimatch": "^
|
|
47
|
-
"proxy-agent": "^
|
|
44
|
+
"fs-extra": "^11.1.1",
|
|
45
|
+
"klaw": "^4.1.0",
|
|
46
|
+
"minimatch": "^9.0.0",
|
|
47
|
+
"proxy-agent": "^6.2.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"aws-sdk-mock": "^5.8.0",
|
|
51
|
-
"chai": "^4.3.
|
|
51
|
+
"chai": "^4.3.7",
|
|
52
52
|
"mocha": "^10.1.0",
|
|
53
53
|
"node-zip": "^1.1.1",
|
|
54
54
|
"standard": "^17.0.0"
|
package/test/main.js
CHANGED
|
@@ -4,6 +4,7 @@ const process = require('process')
|
|
|
4
4
|
const path = require('path')
|
|
5
5
|
const os = require('os')
|
|
6
6
|
const fs = require('fs-extra')
|
|
7
|
+
const { execFileSync } = require('child_process')
|
|
7
8
|
const lambda = require(path.join(__dirname, '..', 'lib', 'main'))
|
|
8
9
|
const Zip = require('node-zip')
|
|
9
10
|
const { assert } = require('chai')
|
|
@@ -22,7 +23,7 @@ const originalProgram = {
|
|
|
22
23
|
memorySize: 128,
|
|
23
24
|
timeout: 3,
|
|
24
25
|
description: '',
|
|
25
|
-
runtime: '
|
|
26
|
+
runtime: 'nodejs18.x',
|
|
26
27
|
deadLetterConfigTargetArn: '',
|
|
27
28
|
tracingConfig: '',
|
|
28
29
|
Layers: '',
|
|
@@ -40,6 +41,8 @@ const originalProgram = {
|
|
|
40
41
|
let program = {}
|
|
41
42
|
let codeDirectory = lambda._codeDirectory()
|
|
42
43
|
|
|
44
|
+
const sourceDirectoryForTest = path.join('.', 'test', 'testPj')
|
|
45
|
+
|
|
43
46
|
const _timeout = function (params) {
|
|
44
47
|
// Even if timeout is set for the whole test for Windows and Mac,
|
|
45
48
|
// if it is set in local it will be valid.
|
|
@@ -143,6 +146,12 @@ describe('lib/main', function () {
|
|
|
143
146
|
before(() => {
|
|
144
147
|
aws = _mockSetting()
|
|
145
148
|
awsLambda = new aws.Lambda({ apiVersion: '2015-03-31' })
|
|
149
|
+
|
|
150
|
+
if (process.platform === 'win32') {
|
|
151
|
+
execFileSync('cmd.exe', ['/c', 'npm', 'ci'], { cwd: sourceDirectoryForTest })
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
execFileSync('npm', ['ci'], { cwd: sourceDirectoryForTest })
|
|
146
155
|
})
|
|
147
156
|
after(() => _awsRestore())
|
|
148
157
|
|
|
@@ -151,7 +160,7 @@ describe('lib/main', function () {
|
|
|
151
160
|
})
|
|
152
161
|
|
|
153
162
|
it('version should be set', () => {
|
|
154
|
-
assert.equal(lambda.version, '1.1
|
|
163
|
+
assert.equal(lambda.version, '1.2.1')
|
|
155
164
|
})
|
|
156
165
|
|
|
157
166
|
describe('_codeDirectory', () => {
|
|
@@ -709,10 +718,10 @@ describe('lib/main', function () {
|
|
|
709
718
|
|
|
710
719
|
// npm treats files as packages when installing, and so removes them.
|
|
711
720
|
// Test with `devDependencies` packages that are not installed with the `--production` option.
|
|
712
|
-
const nodeModulesMocha = path.join(codeDirectory, 'node_modules', '
|
|
721
|
+
const nodeModulesMocha = path.join(codeDirectory, 'node_modules', 'chai')
|
|
713
722
|
|
|
714
723
|
const testCleanAndInstall = async (packageManager) => {
|
|
715
|
-
const
|
|
724
|
+
const beforeDotenvStat = fs.statSync(path.join(codeDirectory, 'node_modules', 'dotenv'))
|
|
716
725
|
|
|
717
726
|
const usedPackageManager = await lambda._packageInstall(
|
|
718
727
|
{
|
|
@@ -727,9 +736,9 @@ describe('lib/main', function () {
|
|
|
727
736
|
assert.include(contents, 'dotenv')
|
|
728
737
|
|
|
729
738
|
// To remove and then install.
|
|
730
|
-
//
|
|
731
|
-
const
|
|
732
|
-
assert.isBelow(
|
|
739
|
+
// beforeDotenvStat.ctimeMs < afterDotenvStat.ctimeMs
|
|
740
|
+
const afterDotenvStat = fs.statSync(path.join(codeDirectory, 'node_modules', 'dotenv'))
|
|
741
|
+
assert.isBelow(beforeDotenvStat.ctimeMs, afterDotenvStat.ctimeMs)
|
|
733
742
|
|
|
734
743
|
// Not installed with the `--production` option.
|
|
735
744
|
assert.isFalse(fs.existsSync(nodeModulesMocha))
|
|
@@ -738,7 +747,7 @@ describe('lib/main', function () {
|
|
|
738
747
|
const beforeEachOptionalDependencies = () => {
|
|
739
748
|
const packageJsonPath = path.join(codeDirectory, 'package.json')
|
|
740
749
|
const packageJson = require(packageJsonPath)
|
|
741
|
-
packageJson.optionalDependencies = {
|
|
750
|
+
packageJson.optionalDependencies = { commander: '*' }
|
|
742
751
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson))
|
|
743
752
|
|
|
744
753
|
// Remove package-lock.json because it does not match the package.json to which optionalDependencies was added.
|
|
@@ -756,7 +765,7 @@ describe('lib/main', function () {
|
|
|
756
765
|
assert.equal(usedPackageManager, packageManager)
|
|
757
766
|
|
|
758
767
|
const contents = fs.readdirSync(path.join(codeDirectory, 'node_modules'))
|
|
759
|
-
assert.include(contents, '
|
|
768
|
+
assert.include(contents, 'commander')
|
|
760
769
|
}
|
|
761
770
|
|
|
762
771
|
const testOptionalDependenciesIsNotInstalled = async (packageManager) => {
|
|
@@ -774,7 +783,7 @@ describe('lib/main', function () {
|
|
|
774
783
|
|
|
775
784
|
beforeEach(async () => {
|
|
776
785
|
await lambda._cleanDirectory(codeDirectory)
|
|
777
|
-
await lambda._fileCopy(program,
|
|
786
|
+
await lambda._fileCopy(program, sourceDirectoryForTest, codeDirectory, false)
|
|
778
787
|
})
|
|
779
788
|
|
|
780
789
|
describe('Use npm', () => {
|
|
@@ -788,7 +797,7 @@ describe('lib/main', function () {
|
|
|
788
797
|
})
|
|
789
798
|
|
|
790
799
|
it('should use "npm install"', () => {
|
|
791
|
-
const
|
|
800
|
+
const beforeDotenvStat = fs.statSync(path.join(codeDirectory, 'node_modules', 'dotenv'))
|
|
792
801
|
return lambda._packageInstall(program, codeDirectory).then((usedPackageManager) => {
|
|
793
802
|
assert.equal(usedPackageManager, 'npm')
|
|
794
803
|
|
|
@@ -796,9 +805,9 @@ describe('lib/main', function () {
|
|
|
796
805
|
assert.include(contents, 'dotenv')
|
|
797
806
|
|
|
798
807
|
// Installed packages will remain intact.
|
|
799
|
-
//
|
|
800
|
-
const
|
|
801
|
-
assert.equal(
|
|
808
|
+
// beforeDotenvStat.ctimeMs === afterDotenvStat.ctimeMs
|
|
809
|
+
const afterDotenvStat = fs.statSync(path.join(codeDirectory, 'node_modules', 'dotenv'))
|
|
810
|
+
assert.equal(beforeDotenvStat.ctimeMs, afterDotenvStat.ctimeMs)
|
|
802
811
|
|
|
803
812
|
// Not installed with the `--production` option.
|
|
804
813
|
assert.isFalse(fs.existsSync(nodeModulesMocha))
|
|
@@ -944,7 +953,8 @@ describe('lib/main', function () {
|
|
|
944
953
|
|
|
945
954
|
const beforeTask = async (packageManager) => {
|
|
946
955
|
await lambda._cleanDirectory(codeDirectory)
|
|
947
|
-
await lambda._fileCopy(program,
|
|
956
|
+
await lambda._fileCopy(program, sourceDirectoryForTest, codeDirectory, true)
|
|
957
|
+
fs.copySync(path.join(__dirname, '..', 'bin', 'node-lambda'), path.join(codeDirectory, 'bin', 'node-lambda'))
|
|
948
958
|
const usedPackageManager = await lambda._packageInstall(
|
|
949
959
|
{
|
|
950
960
|
...program,
|
|
@@ -1008,16 +1018,16 @@ describe('lib/main', function () {
|
|
|
1008
1018
|
|
|
1009
1019
|
describe('_archive', () => {
|
|
1010
1020
|
// archive.files's name is a slash delimiter regardless of platform.
|
|
1011
|
-
it('installs and zips with an index.js file and node_modules/
|
|
1021
|
+
it('installs and zips with an index.js file and node_modules/dotenv (It is also a test of `_buildAndArchive`)', function () {
|
|
1012
1022
|
_timeout({ this: this, sec: 30 }) // give it time to zip
|
|
1013
1023
|
|
|
1014
|
-
return lambda._archive(program).then((data) => {
|
|
1024
|
+
return lambda._archive({ ...program, sourceDirectory: sourceDirectoryForTest }).then((data) => {
|
|
1015
1025
|
const archive = new Zip(data)
|
|
1016
1026
|
const contents = Object.keys(archive.files).map((k) => {
|
|
1017
1027
|
return archive.files[k].name.toString()
|
|
1018
1028
|
})
|
|
1019
1029
|
assert.include(contents, 'index.js')
|
|
1020
|
-
assert.include(contents, 'node_modules/
|
|
1030
|
+
assert.include(contents, 'node_modules/dotenv/lib/main.js')
|
|
1021
1031
|
})
|
|
1022
1032
|
})
|
|
1023
1033
|
|
|
@@ -1112,16 +1122,20 @@ describe('lib/main', function () {
|
|
|
1112
1122
|
describe('If value is set in `deployZipfile`, _readArchive is executed in _archive', () => {
|
|
1113
1123
|
it('`deployZipfile` is a invalid value. Process from creation of zip file', function () {
|
|
1114
1124
|
const filePath = path.join(path.resolve('/aaaa'), 'bbbb')
|
|
1115
|
-
const _program =
|
|
1125
|
+
const _program = {
|
|
1126
|
+
program,
|
|
1127
|
+
deployZipfile: filePath,
|
|
1128
|
+
sourceDirectory: sourceDirectoryForTest
|
|
1129
|
+
}
|
|
1116
1130
|
_timeout({ this: this, sec: 30 }) // give it time to zip
|
|
1117
1131
|
return lambda._archive(_program).then((data) => {
|
|
1118
|
-
// same test as "installs and zips with an index.js file and node_modules/
|
|
1132
|
+
// same test as "installs and zips with an index.js file and node_modules/dotenv"
|
|
1119
1133
|
const archive = new Zip(data)
|
|
1120
1134
|
const contents = Object.keys(archive.files).map((k) => {
|
|
1121
1135
|
return archive.files[k].name.toString()
|
|
1122
1136
|
})
|
|
1123
1137
|
assert.include(contents, 'index.js')
|
|
1124
|
-
assert.include(contents, 'node_modules/
|
|
1138
|
+
assert.include(contents, 'node_modules/dotenv/lib/main.js')
|
|
1125
1139
|
})
|
|
1126
1140
|
})
|
|
1127
1141
|
|
|
@@ -1626,7 +1640,7 @@ describe('lib/main', function () {
|
|
|
1626
1640
|
describe('Lambda.prototype.deploy()', () => {
|
|
1627
1641
|
it('simple test with mock', function () {
|
|
1628
1642
|
_timeout({ this: this, sec: 30 }) // give it time to zip
|
|
1629
|
-
return lambda.deploy(program).then((result) => {
|
|
1643
|
+
return lambda.deploy({ ...program, sourceDirectory: sourceDirectoryForTest }).then((result) => {
|
|
1630
1644
|
assert.isUndefined(result)
|
|
1631
1645
|
})
|
|
1632
1646
|
})
|
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 = 'nodejs18.x'
|
|
161
161
|
})
|
|
162
162
|
|
|
163
163
|
it('`node-lambda run` exitCode is `254` (callback(null))', (done) => {
|
|
@@ -171,6 +171,24 @@ 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
|
+
|
|
184
|
+
it('`node-lambda run` exitCode is not `254` (callback(null))', (done) => {
|
|
185
|
+
_generateEventFile(Object.assign(eventObj, {
|
|
186
|
+
callbackCode: 'callback(null);'
|
|
187
|
+
}))
|
|
188
|
+
_testMain({ stdoutRegExp: /Success:$/, exitCode: 0 }, done)
|
|
189
|
+
})
|
|
190
|
+
})
|
|
191
|
+
|
|
174
192
|
describe('node-lambda run (Multiple events))', () => {
|
|
175
193
|
const eventObj = [{
|
|
176
194
|
asyncTest: false,
|
|
File without changes
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "testcodedirectory",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "testcodedirectory",
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"dotenv": "^16.3.1"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"chai": "^4.3.7"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"node_modules/assertion-error": {
|
|
19
|
+
"version": "1.1.0",
|
|
20
|
+
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz",
|
|
21
|
+
"integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
|
|
22
|
+
"dev": true,
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": "*"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"node_modules/chai": {
|
|
28
|
+
"version": "4.3.7",
|
|
29
|
+
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz",
|
|
30
|
+
"integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==",
|
|
31
|
+
"dev": true,
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"assertion-error": "^1.1.0",
|
|
34
|
+
"check-error": "^1.0.2",
|
|
35
|
+
"deep-eql": "^4.1.2",
|
|
36
|
+
"get-func-name": "^2.0.0",
|
|
37
|
+
"loupe": "^2.3.1",
|
|
38
|
+
"pathval": "^1.1.1",
|
|
39
|
+
"type-detect": "^4.0.5"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=4"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"node_modules/check-error": {
|
|
46
|
+
"version": "1.0.2",
|
|
47
|
+
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
|
|
48
|
+
"integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==",
|
|
49
|
+
"dev": true,
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": "*"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"node_modules/deep-eql": {
|
|
55
|
+
"version": "4.1.3",
|
|
56
|
+
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz",
|
|
57
|
+
"integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==",
|
|
58
|
+
"dev": true,
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"type-detect": "^4.0.0"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=6"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"node_modules/dotenv": {
|
|
67
|
+
"version": "16.3.1",
|
|
68
|
+
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
|
|
69
|
+
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=12"
|
|
72
|
+
},
|
|
73
|
+
"funding": {
|
|
74
|
+
"url": "https://github.com/motdotla/dotenv?sponsor=1"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"node_modules/get-func-name": {
|
|
78
|
+
"version": "2.0.0",
|
|
79
|
+
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
|
|
80
|
+
"integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==",
|
|
81
|
+
"dev": true,
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": "*"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"node_modules/loupe": {
|
|
87
|
+
"version": "2.3.6",
|
|
88
|
+
"resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz",
|
|
89
|
+
"integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==",
|
|
90
|
+
"dev": true,
|
|
91
|
+
"dependencies": {
|
|
92
|
+
"get-func-name": "^2.0.0"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"node_modules/pathval": {
|
|
96
|
+
"version": "1.1.1",
|
|
97
|
+
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
|
|
98
|
+
"integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==",
|
|
99
|
+
"dev": true,
|
|
100
|
+
"engines": {
|
|
101
|
+
"node": "*"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"node_modules/type-detect": {
|
|
105
|
+
"version": "4.0.8",
|
|
106
|
+
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
|
|
107
|
+
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
|
|
108
|
+
"dev": true,
|
|
109
|
+
"engines": {
|
|
110
|
+
"node": ">=4"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
package/.travis.yml
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
language: node_js
|
|
2
|
-
|
|
3
|
-
node_js:
|
|
4
|
-
- "lts/*"
|
|
5
|
-
- "node"
|
|
6
|
-
|
|
7
|
-
install: npm i -g npm
|
|
8
|
-
|
|
9
|
-
cache:
|
|
10
|
-
directories:
|
|
11
|
-
- node_modules
|
|
12
|
-
|
|
13
|
-
jobs:
|
|
14
|
-
include:
|
|
15
|
-
- stage: npm release
|
|
16
|
-
node_js: node
|
|
17
|
-
script: echo "Deploying to npm ..."
|
|
18
|
-
deploy:
|
|
19
|
-
provider: npm
|
|
20
|
-
email: chase@sillevis.net
|
|
21
|
-
api_key:
|
|
22
|
-
secure: "fPmrr3f1Iw/4mUylzTRuLRC0397z4TJDYzNfSI2BQwFe851EyR1CQv2PQJE2eHC07mxrGZ0i/Fh2F4U5S2u3hSg+qqD0UFzSFXZI//C6b2GG1suld9EVhQBIevPnKTWjT+qitGxsSI82VOIuheQdYmJdFVKcpQOmsqocifGX5XU="
|
|
23
|
-
on:
|
|
24
|
-
tags: true
|