@aws-sdk/find-v2 0.3.2 → 0.3.3
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/dist/cli.js +12 -0
- package/dist/scanLambdaFunctions.js +2 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
import { cpus } from "node:os";
|
|
2
3
|
import packageJson from "../package.json" with { type: "json" };
|
|
3
4
|
import { scanLambdaFunctions } from "./scanLambdaFunctions.js";
|
|
4
5
|
/**
|
|
@@ -18,6 +19,17 @@ export const createProgram = () => {
|
|
|
18
19
|
.description("Scans Lambda Node.js Functions for JavaScript SDK v2")
|
|
19
20
|
.option("-r, --region <region>", "AWS region to scan")
|
|
20
21
|
.option("-y, --yes", "answer yes for all prompts")
|
|
22
|
+
.option("-j, --jobs <count>", "number of parallel jobs", (value) => {
|
|
23
|
+
const trimmed = value.trim();
|
|
24
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
25
|
+
throw new Error("jobs must be a positive integer");
|
|
26
|
+
}
|
|
27
|
+
const parsed = Number.parseInt(trimmed, 10);
|
|
28
|
+
if (parsed < 1) {
|
|
29
|
+
throw new Error("jobs must be a positive integer");
|
|
30
|
+
}
|
|
31
|
+
return parsed;
|
|
32
|
+
}, cpus().length)
|
|
21
33
|
.action(async (options) => {
|
|
22
34
|
await scanLambdaFunctions(options);
|
|
23
35
|
});
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Lambda } from "@aws-sdk/client-lambda";
|
|
2
2
|
import pLimit from "p-limit";
|
|
3
|
-
import { cpus } from "node:os";
|
|
4
3
|
import { JS_SDK_V2_MARKER } from "./constants.js";
|
|
5
4
|
import { scanLambdaFunction } from "./scanLambdaFunction.js";
|
|
6
5
|
import { getDownloadConfirmation } from "./utils/getDownloadConfirmation.js";
|
|
7
6
|
import { getLambdaFunctions } from "./utils/getLambdaFunctions.js";
|
|
8
|
-
export const scanLambdaFunctions = async ({ region, yes } = {}) => {
|
|
7
|
+
export const scanLambdaFunctions = async ({ region, yes, jobs } = {}) => {
|
|
9
8
|
const client = new Lambda({ region });
|
|
10
9
|
const functions = await getLambdaFunctions(client);
|
|
11
10
|
const functionCount = functions.length;
|
|
12
|
-
const concurrency = Math.min(functionCount,
|
|
11
|
+
const concurrency = Math.min(functionCount, jobs || 1);
|
|
13
12
|
const codeSizeToDownload = functions.reduce((acc, fn) => acc + (fn.CodeSize || 0), 0);
|
|
14
13
|
const codeSizeToSaveOnDisk = functions
|
|
15
14
|
.map((fn) => fn.CodeSize || 0)
|