lambda-live-debugger 0.0.99 → 0.0.101

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.
Binary file
@@ -215,7 +215,7 @@ export class CdkFramework {
215
215
  "aws:cdk:bundling-stacks": [],
216
216
  };
217
217
  process.env.CDK_CONTEXT_JSON = JSON.stringify(CDK_CONTEXT_JSON);
218
- Logger.verbose(`[CDK] context:`, JSON.stringify(CDK_CONTEXT_JSON, null, 2));
218
+ Logger.verbose(`[CDK] Context:`, JSON.stringify(CDK_CONTEXT_JSON, null, 2));
219
219
  const lambdas = await new Promise((resolve, reject) => {
220
220
  const worker = new Worker(path.resolve(path.join(getModuleDirname(), "frameworks/cdkFrameworkWorker.mjs")), {
221
221
  workerData: {
@@ -330,7 +330,7 @@ export class CdkFramework {
330
330
  throw new Error(`Entry file not found in ${cdkConfigPath}`);
331
331
  }
332
332
  entryFile = path.resolve(entryFile);
333
- Logger.verbose(`[CDK] entry file: ${entryFile}`);
333
+ Logger.verbose(`[CDK] Entry file: ${entryFile}`);
334
334
  return entryFile;
335
335
  }
336
336
  }
@@ -1,12 +1,14 @@
1
1
  import fs from "fs/promises";
2
2
  import { outputFolder } from "./constants.mjs";
3
3
  import { Logger } from "./logger.mjs";
4
+ import { getProjectDirname } from "./getDirname.mjs";
5
+ import path from "path";
4
6
  /**
5
7
  * Check if ".lldebugger" exists in .gitignore
6
8
  */
7
9
  async function doesExistInGitIgnore() {
8
10
  try {
9
- const gitignoreContent = await fs.readFile(".gitignore", "utf-8");
11
+ const gitignoreContent = await fs.readFile(getGitIgnoreFileLocation(), "utf-8");
10
12
  // split by new line
11
13
  const lines = gitignoreContent.split("\n");
12
14
  // check if ".lldebugger" exists
@@ -17,6 +19,13 @@ async function doesExistInGitIgnore() {
17
19
  return false;
18
20
  }
19
21
  }
22
+ /**
23
+ * Get the location of .gitignore
24
+ * @returns
25
+ */
26
+ function getGitIgnoreFileLocation() {
27
+ return path.join(getProjectDirname(), ".gitignore");
28
+ }
20
29
  /**
21
30
  * Add ".lldebugger" to .gitignore if it doesn't exist
22
31
  * @returns
@@ -27,14 +36,14 @@ async function addToGitIgnore() {
27
36
  if (!exists) {
28
37
  // does file exist?
29
38
  try {
30
- await fs.access(".gitignore");
39
+ await fs.access(getGitIgnoreFileLocation());
31
40
  }
32
41
  catch (error) {
33
- await fs.writeFile(".gitignore", `${outputFolder}\n`);
42
+ await fs.writeFile(getGitIgnoreFileLocation(), `${outputFolder}\n`);
34
43
  return;
35
44
  }
36
45
  // append to existing file
37
- await fs.appendFile(".gitignore", `\n${outputFolder}\n`);
46
+ await fs.appendFile(getGitIgnoreFileLocation(), `\n${outputFolder}\n`);
38
47
  }
39
48
  else {
40
49
  Logger.log(`${outputFolder} already exists in .gitignore`);
@@ -47,9 +56,9 @@ async function removeFromGitIgnore() {
47
56
  Logger.verbose("Removing .gitignore entry...");
48
57
  const exists = await doesExistInGitIgnore();
49
58
  if (exists) {
50
- const gitignoreContent = await fs.readFile(".gitignore", "utf-8");
59
+ const gitignoreContent = await fs.readFile(getGitIgnoreFileLocation(), "utf-8");
51
60
  const newContent = gitignoreContent.replace(`${outputFolder}\n`, "");
52
- await fs.writeFile(".gitignore", newContent);
61
+ await fs.writeFile(getGitIgnoreFileLocation(), newContent);
53
62
  }
54
63
  else {
55
64
  Logger.log(`${outputFolder} doesn't exist in .gitignore`);
@@ -58,25 +58,25 @@ async function onMessageFromLambda(message) {
58
58
  }
59
59
  }
60
60
  if (Configuration.config.verbose) {
61
- Logger.verbose(`${message.data.functionId} response: `, JSON.stringify(message.data, null, 2));
61
+ Logger.verbose(`[Function ${message.data.functionId}] Response: `, JSON.stringify(message.data, null, 2));
62
62
  }
63
63
  else {
64
64
  // first 50 characters of the response
65
65
  const requestPretty = message.data
66
66
  ? JSON.stringify(message.data).substring(0, 100)
67
67
  : "";
68
- Logger.log(`${message.data.functionId} request: ${requestPretty}${requestPretty.length < 50 ? "" : "..."}`);
68
+ Logger.log(`[Function ${message.data.functionId}] Request: ${requestPretty}${requestPretty.length < 50 ? "" : "..."}`);
69
69
  }
70
70
  const response = await NodeHandler.invokeLambda(message.data);
71
71
  if (Configuration.config.verbose) {
72
- Logger.verbose(`${message.data.functionId} response: `, JSON.stringify(response, null, 2));
72
+ Logger.verbose(`[Function ${message.data.functionId}] Response: `, JSON.stringify(response, null, 2));
73
73
  }
74
74
  else {
75
75
  // first 50 characters of the response
76
76
  const responsePretty = response
77
77
  ? JSON.stringify(response).substring(0, 100)
78
78
  : "";
79
- Logger.log(`${message.data.functionId} response: ${responsePretty}${responsePretty.length < 50 ? "" : "..."}`);
79
+ Logger.log(`[Function ${message.data.functionId}] Response: ${responsePretty}${responsePretty.length < 50 ? "" : "..."}`);
80
80
  }
81
81
  if (Configuration.config.observable) {
82
82
  // if we are in observable mode, mark the worker as processed
@@ -96,7 +96,7 @@ async function onMessageFromLambda(message) {
96
96
  }
97
97
  }
98
98
  catch (e) {
99
- Logger.error(`${message.data.functionId} error: `, e.errorMessage);
99
+ Logger.error(`[Function ${message.data.functionId}] Error: `, e);
100
100
  const payload = {
101
101
  type: "ERROR",
102
102
  data: {
@@ -48,6 +48,7 @@ async function getBuild(functionId) {
48
48
  ctx: newBuildAssets.then((b) => b.ctx),
49
49
  current: true,
50
50
  };
51
+ buildCache[functionId] = buildAssets;
51
52
  }
52
53
  const result = await buildAssets.result;
53
54
  if (newBuild) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-live-debugger",
3
- "version": "0.0.99",
3
+ "version": "0.0.101",
4
4
  "type": "module",
5
5
  "description": "Debug Lambda functions locally like it is running in the cloud",
6
6
  "repository": {