Skip to content

Commit 30d8fa9

Browse files
committed
Upgrade some dependencies, remove lambda-git
1 parent f002689 commit 30d8fa9

17 files changed

+3168
-3527
lines changed

.github/workflows/checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup node
2020
uses: actions/setup-node@v1
2121
with:
22-
node-version: 12
22+
node-version: 16
2323

2424
- name: Install dependencies
2525
run: yarn install --frozen-lockfile
@@ -36,11 +36,11 @@ jobs:
3636
node: [12, 14, 16]
3737
exclude:
3838
- os: macos-latest
39-
node: 14
39+
node: 12
4040
- os: macos-latest
4141
node: 16
4242
- os: windows-latest
43-
node: 14
43+
node: 12
4444
- os: windows-latest
4545
node: 16
4646
steps:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.cache
21
.env
2+
.parcel-cache
33
coverage
44
junit.xml
55
lambda.zip

.markdownlintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ LICENSE
44
!*.md
55

66
## same as in .gitignore
7-
.cache
87
.env
8+
.parcel-cache
99
coverage
1010
junit.xml
1111
lambda.zip

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LICENSE
1111
!/.github/
1212

1313
## same as in .gitignore
14-
.cache
1514
.env
15+
.parcel-cache
1616
coverage
1717
junit.xml
1818
lambda.zip

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ See [src/config.ts](src/config.ts) for the list of options.
6060
See [official documentation](https://docs.aws.amazon.com/lambda/latest/dg/getting-started-create-function.html).
6161
You should end up on the function’s configuration page at the end of this step.
6262

63-
1. **Upload function code and configure its execution**
64-
Press _Upload_ in the _Function code_ block and select a copy of `lambda.zip` on you computer.
65-
Set _Runtime_ to _Node 12.x_ and _Basic settings_ → _Timeout_ to _15 sec_.
63+
1. **Upload function code and configure its execution**
64+
65+
- Press _Upload_ in the _Function code_ block and select a copy of `lambda.zip` on you computer.
66+
- Set _Runtime_ to _Node 14.x_ and _Basic settings_ → _Timeout_ to _15 sec_.
67+
- Press _Add a layer_ and provide ARN from [git-lambda-layer](https://github.com/lambci/git-lambda-layer) repo (e.g. `arn:aws:lambda:us-east-1:553035198032:layer:git-lambda2:8` if your function is in `us-east-1` region and you want to use git `2.29.0`).
6668

6769
1. **Set environment variables**
6870
It is necessary to set at least two environment variables, otherwise the function will not succeed.

jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ module.exports = {
1414
reporters: REPORT_TEST_RESULTS_AND_COVERAGE
1515
? ["default", ["jest-junit", { suiteNameTemplate: "{filepath}" }]]
1616
: ["default"],
17+
18+
transformIgnorePatterns: ["node_modules/(?!(weak-lru-cache|ordered-binary))"],
1719
};

package.json

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,40 @@
1515
"simulate": "ts-node src/simulate.ts",
1616
"test": "jest"
1717
},
18-
"resolutions": {
19-
"node-forge": ">=0.10.0"
20-
},
2118
"dependencies": {
2219
"@kachkaev/commands": "^0.1.1",
23-
"envalid": "^6.0.2",
20+
"dotenv": "^10.0.0",
21+
"envalid": "^7.2.2",
2422
"execa": "^5.1.1",
25-
"fs-extra": "^9.1.0",
23+
"fs-extra": "^10.0.0",
2624
"jszip": "^3.7.1",
27-
"lambda-git": "^0.1.3",
28-
"luxon": "^1.28.0"
25+
"luxon": "^2.1.1"
2926
},
3027
"devDependencies": {
31-
"@babel/core": "^7.15.0",
32-
"@babel/preset-env": "^7.15.0",
33-
"@babel/preset-typescript": "^7.15.0",
28+
"@babel/core": "^7.16.0",
29+
"@babel/preset-env": "^7.16.4",
30+
"@babel/preset-typescript": "^7.16.0",
3431
"@kachkaev/markdownlint-config": "^0.2.0",
3532
"@kachkaev/prettier-config": "^1.2.0",
36-
"@types/aws-lambda": "^8.10.82",
37-
"@types/fs-extra": "^9.0.12",
38-
"@types/jest": "^27.0.1",
33+
"@types/aws-lambda": "^8.10.85",
34+
"@types/fs-extra": "^9.0.13",
35+
"@types/jest": "^27.0.2",
3936
"@types/jszip": "^3.4.1",
40-
"@types/luxon": "^1.27.1",
41-
"@types/node": "^14.17.9",
42-
"@types/parcel-bundler": "^1.12.4",
43-
"jest": "^27.0.6",
44-
"jest-junit": "^12.2.0",
45-
"markdownlint-cli": "^0.28.1",
37+
"@types/luxon": "^2.0.7",
38+
"@types/node": "^14.17.33",
39+
"jest": "^27.3.1",
40+
"jest-junit": "^13.0.0",
41+
"markdownlint-cli": "^0.29.0",
4642
"npm-run-all": "^4.1.5",
47-
"parcel-bundler": "^1.12.5",
43+
"parcel": "^2.0.1",
4844
"prettier": "~2.2.1",
49-
"prettier-plugin-packagejson": "^2.2.11",
50-
"ts-node": "^9.1.1",
51-
"typescript": "^4.3.5",
45+
"prettier-plugin-packagejson": "^2.2.15",
46+
"ts-node": "^10.4.0",
47+
"typescript": "^4.4.4",
5248
"yarn-deduplicate": "^3.1.0"
5349
},
5450
"engines": {
55-
"node": ">=10.21.0",
56-
"yarn": ">=1.21.1"
51+
"node": ">=12.21.0",
52+
"yarn": ">=1.22.0"
5753
}
5854
}

src/build.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe("build", () => {
1919
expect(await fs.pathExists(resultingArchive)).toBe(true);
2020
const zip = await JSZip.loadAsync(await fs.readFile(resultingArchive));
2121
expect(Object.keys(zip.files)).toEqual([
22-
"git-2.4.3.tar",
2322
"index.js",
2423
"CHANGELOG.md",
2524
"LICENSE",

src/build.ts

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
1-
import envalid from "envalid";
1+
import * as envalid from "envalid";
22
import fs from "fs-extra";
3-
import Bundler from "parcel-bundler";
3+
import Parcel from "@parcel/core";
44
import path from "path";
55
import JSZip from "jszip";
66
import { autoStartCommandIfNeeded } from "@kachkaev/commands";
7+
import dotenv from "dotenv";
78

89
import { generateUniqueTempDirPath } from "./helpers";
910

1011
const build = async () => {
11-
const { BUILD_OUTPUT } = envalid.cleanEnv(
12-
process.env,
13-
{
14-
BUILD_OUTPUT: envalid.str({
15-
desc: "Location of the zip archive to produce",
16-
default: "lambda.zip",
17-
}),
18-
},
19-
{
20-
...(process.env.NODE_ENV === "test" && { dotEnvPath: null }),
21-
},
22-
);
12+
if (process.env.NODE_ENV !== "test") {
13+
dotenv.config();
14+
}
15+
const { BUILD_OUTPUT } = envalid.cleanEnv(process.env, {
16+
BUILD_OUTPUT: envalid.str({
17+
desc: "Location of the zip archive to produce",
18+
default: "lambda.zip",
19+
}),
20+
});
2321

2422
const buildOutDir = generateUniqueTempDirPath("build");
2523

2624
// Produce compiled JavaScript handle
27-
const bundler = new Bundler(path.resolve(__dirname, "handler.ts"), {
28-
bundleNodeModules: true,
29-
global: "handler",
30-
logLevel: 1,
31-
minify: true,
32-
outDir: buildOutDir,
33-
sourceMaps: false,
34-
target: "node",
35-
watch: false,
25+
const bundler = new Parcel({
26+
entries: path.resolve(__dirname, "handler.ts"),
27+
logLevel: "error",
28+
mode: "production",
29+
defaultConfig: "@parcel/config-default",
30+
31+
targets: {
32+
default: {
33+
distDir: buildOutDir,
34+
outputFormat: "commonjs",
35+
optimize: true,
36+
includeNodeModules: true,
37+
engines: {
38+
node: require("../package.json").engines.node,
39+
},
40+
},
41+
},
3642
});
37-
await bundler.bundle();
43+
await bundler.run();
3844

3945
// Produce ZIP archive with the handler and git binary
4046
const zip = new JSZip();
41-
zip.file(
42-
"git-2.4.3.tar",
43-
fs.createReadStream(
44-
path.resolve(__dirname, "../node_modules/lambda-git/git-2.4.3.tar"),
45-
),
46-
{
47-
binary: true,
48-
},
49-
);
5047
zip.file(
5148
"index.js",
5249
fs.createReadStream(path.resolve(buildOutDir, "handler.js")),

src/config.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import envalid from "envalid";
1+
import * as envalid from "envalid";
22
import { Config } from "./types";
33

44
export const envValidators = {
@@ -68,16 +68,14 @@ export const envValidators = {
6868
}),
6969
};
7070

71-
export const getConfig = ({ useLocalDotEnv = false }): Config => {
71+
export const getConfig = (): Config => {
7272
const config = envalid.cleanEnv(process.env, envValidators, {
73-
strict: true,
74-
...(!useLocalDotEnv && { dotEnvPath: null }),
7573
reporter: ({ errors }) => {
7674
const errorKeys = Object.keys(errors);
7775
if (!errorKeys.length) {
7876
return;
7977
}
80-
throw new Error("Invalid env vars: " + errorKeys);
78+
throw new Error("Invalid env vars: " + errorKeys.join(", "));
8179
},
8280
});
8381

0 commit comments

Comments
 (0)