lambda-live-debugger 0.0.103 → 0.0.106

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/README.md CHANGED
@@ -90,7 +90,7 @@ You probably need to tweak some settings. You can do it via CLI parameters or, b
90
90
  lld -w
91
91
  ```
92
92
 
93
- The configuration is saved to `lldebugger.config.ts`
93
+ The configuration is saved to `lldebugger.config.ts`.
94
94
 
95
95
  ### CLI Parameters
96
96
 
@@ -114,6 +114,35 @@ The configuration is saved to `lldebugger.config.ts`
114
114
  -h, --help display help for command
115
115
  ```
116
116
 
117
+ ## Configuration file lldebugger.config.ts
118
+
119
+ Example lldebugger.config.ts:
120
+
121
+ ```typescript
122
+ import { type LldConfigTs } from "lambda-live-debugger";
123
+
124
+ export default {
125
+ framework: "cdk",
126
+ context: ["environment=development"],
127
+ region: "eu-central-1",
128
+ observable: false,
129
+ verbose: false,
130
+ //getLambdas: async (foundLambdas) => {
131
+ // you can customize the list of lambdas here or create your own
132
+ // return foundLambdas;
133
+ //},
134
+ } satisfies LldConfigTs;
135
+ ```
136
+
137
+ The setting are the same as for CLI parameters.
138
+
139
+ ### Custom framework implementation and adjustment
140
+
141
+ getLambdas: async (foundLambdas) => {
142
+ //you can customize the list of lambdas here or create your own
143
+ //return foundLambdas;
144
+ },
145
+
117
146
  ### Debugging
118
147
 
119
148
  You might want to configure your development tool for debugging. The wizard automatically configures for VsCode in `.vscode/launch.json`. Here is an example:
@@ -142,13 +171,6 @@ For other tools, please send documentation to include here. WebStorm instruction
142
171
 
143
172
  Set the `subfolder` parameter if your framework is in a subfolder.
144
173
 
145
- ## Custom Configuration
146
-
147
- getLambdas: async (foundLambdas) => {
148
- //you can customize the list of lambdas here or create your own
149
- //return foundLambdas;
150
- },
151
-
152
174
  ## Removing
153
175
 
154
176
  To remove Lambda Live Debugger from your AWS account
Binary file
@@ -22,7 +22,7 @@ parentPort.on("message", async (data) => {
22
22
  // execute code to get the data into global.lambdas
23
23
  const codeFile = await fs.readFile(data.compileOutput, "utf8");
24
24
 
25
- fixCdkPaths();
25
+ await fixCdkPaths(workerData.awsCdkLibPath);
26
26
 
27
27
  eval(codeFile);
28
28
 
@@ -54,12 +54,11 @@ parentPort.on("message", async (data) => {
54
54
  /**
55
55
  * Some paths are not resolved correctly in the CDK code, so we need to fix them
56
56
  */
57
- function fixCdkPaths() {
58
- //const path = require("path"); // leave this line for manual debugging
57
+ async function fixCdkPaths(awsCdkLibPath) {
58
+ // leave this lines for manual debugging
59
+ //const awsCdkLibPath = path.resolve("node_modules/aws-cdk-lib");
60
+ //const path = require("path");
59
61
 
60
- // Get the path to the aws-cdk-lib module
61
- let awsCdkLibPath = require.resolve("aws-cdk-lib");
62
- awsCdkLibPath = awsCdkLibPath.replace("/index.js", "");
63
62
  Logger.verbose(`[CDK] [Worker] aws-cdk-lib PATH ${awsCdkLibPath}`);
64
63
 
65
64
  const pathsFix = {
@@ -10,8 +10,8 @@ import { Logger } from "../logger.mjs";
10
10
  * Support for AWS SAM framework
11
11
  */
12
12
  export class SamFramework {
13
- samConfigFile = path.resolve("samconfig.toml");
14
- samTemplateFile = path.resolve("template.yaml");
13
+ samConfigFile = "samconfig.toml";
14
+ samTemplateFile = "template.yaml";
15
15
  /**
16
16
  * Framework name
17
17
  */
@@ -24,17 +24,17 @@ export class SamFramework {
24
24
  */
25
25
  async canHandle() {
26
26
  try {
27
- await fs.access(this.samConfigFile, constants.F_OK);
27
+ await fs.access(path.resolve(this.samConfigFile), constants.F_OK);
28
28
  }
29
29
  catch (error) {
30
- Logger.verbose(`[SAM] This is not a SAM framework project. ${this.samConfigFile} not found.`);
30
+ Logger.verbose(`[SAM] This is not a SAM framework project. ${path.resolve(this.samConfigFile)} not found.`);
31
31
  return false;
32
32
  }
33
33
  try {
34
- await fs.access(this.samTemplateFile, constants.F_OK);
34
+ await fs.access(path.resolve(this.samTemplateFile), constants.F_OK);
35
35
  }
36
36
  catch (error) {
37
- Logger.verbose(`[SAM] This is not a SAM framework project. ${this.samTemplateFile} not found.`);
37
+ Logger.verbose(`[SAM] This is not a SAM framework project. ${path.resolve(this.samTemplateFile)} not found.`);
38
38
  return false;
39
39
  }
40
40
  return true;
@@ -51,13 +51,13 @@ export class SamFramework {
51
51
  role: config.role,
52
52
  };
53
53
  const environment = config.configEnv ?? "default";
54
- const samConfigContent = await fs.readFile(this.samConfigFile, "utf-8");
54
+ const samConfigContent = await fs.readFile(path.resolve(this.samConfigFile), "utf-8");
55
55
  const samConfig = toml.parse(samConfigContent);
56
56
  const stackName = samConfig[environment]?.global?.parameters?.stack_name;
57
57
  if (!stackName) {
58
- throw new Error(`Stack name not found in ${this.samConfigFile}`);
58
+ throw new Error(`Stack name not found in ${path.resolve(this.samConfigFile)}`);
59
59
  }
60
- const samTemplateContent = await fs.readFile(this.samTemplateFile, "utf-8");
60
+ const samTemplateContent = await fs.readFile(path.resolve(this.samTemplateFile), "utf-8");
61
61
  const template = yaml.parse(samTemplateContent);
62
62
  const lambdas = [];
63
63
  // get all resources of type AWS::Serverless::Function
@@ -24,7 +24,11 @@ export class TerraformFramework {
24
24
  async canHandle() {
25
25
  // is there any filey with *.tf extension
26
26
  const files = await fs.readdir(process.cwd());
27
- return files.some((f) => f.endsWith(".tf"));
27
+ const r = files.some((f) => f.endsWith(".tf"));
28
+ if (!r) {
29
+ Logger.verbose(`[Terraform] This is not a Terraform project. There are no *.tf files in ${path.resolve(".")} folder.`);
30
+ }
31
+ return r;
28
32
  }
29
33
  /**
30
34
  * Get Lambda functions
@@ -33,6 +33,12 @@ async function checkModuleInPackageJson(dir, moduleName) {
33
33
  const devDependencies = packageJson.devDependencies || {};
34
34
  if (dependencies[moduleName] || devDependencies[moduleName]) {
35
35
  const modulePath = path.join(dir, "node_modules", moduleName);
36
+ try {
37
+ await fs.access(modulePath);
38
+ }
39
+ catch {
40
+ return undefined;
41
+ }
36
42
  return modulePath;
37
43
  }
38
44
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-live-debugger",
3
- "version": "0.0.103",
3
+ "version": "0.0.106",
4
4
  "type": "module",
5
5
  "description": "Debug Lambda functions locally like it is running in the cloud",
6
6
  "repository": {