lambda-live-debugger 0.0.100 → 0.0.102
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/configuration.mjs +7 -1
- package/dist/extension/extension.zip +0 -0
- package/dist/frameworks/cdkFramework.mjs +2 -2
- package/dist/frameworks/cdkFrameworkWorker.mjs +57 -2
- package/dist/lambdaConnection.mjs +5 -5
- package/dist/lldebugger.mjs +3 -3
- package/dist/nodeEsBuild.mjs +1 -0
- package/package.json +1 -1
package/dist/configuration.mjs
CHANGED
|
@@ -37,7 +37,13 @@ async function readConfig() {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
|
|
40
|
+
// remove all undefined values from the configFromCliArgs
|
|
41
|
+
for (const key in configFromCliArgs) {
|
|
42
|
+
if (configFromCliArgs[key] === undefined) {
|
|
43
|
+
delete configFromCliArgs[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const configMerged = { ...configFromConfigFile, ...configFromCliArgs };
|
|
41
47
|
const debuggerId = await generateDebuggerId(!!configMerged.observable);
|
|
42
48
|
setConfig({
|
|
43
49
|
...configMerged,
|
|
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]
|
|
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]
|
|
333
|
+
Logger.verbose(`[CDK] Entry file: ${entryFile}`);
|
|
334
334
|
return entryFile;
|
|
335
335
|
}
|
|
336
336
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from "module";
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
3
7
|
|
|
4
8
|
import { workerData, parentPort } from "node:worker_threads";
|
|
5
9
|
import fs from "fs/promises";
|
|
6
|
-
import path from "path";
|
|
7
10
|
|
|
8
11
|
import { Logger } from "../logger.mjs";
|
|
9
12
|
|
|
@@ -18,7 +21,9 @@ parentPort.on("message", async (data) => {
|
|
|
18
21
|
|
|
19
22
|
// execute code to get the data into global.lambdas
|
|
20
23
|
const codeFile = await fs.readFile(data.compileOutput, "utf8");
|
|
21
|
-
|
|
24
|
+
|
|
25
|
+
fixCdkPaths();
|
|
26
|
+
|
|
22
27
|
eval(codeFile);
|
|
23
28
|
|
|
24
29
|
if (!global.lambdas || global.lambdas?.length === 0) {
|
|
@@ -45,3 +50,53 @@ parentPort.on("message", async (data) => {
|
|
|
45
50
|
);
|
|
46
51
|
parentPort.postMessage(lambdas);
|
|
47
52
|
});
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Some paths are not resolved correctly in the CDK code, so we need to fix them
|
|
56
|
+
*/
|
|
57
|
+
function fixCdkPaths() {
|
|
58
|
+
//const path = require("path"); // leave this line for manual debugging
|
|
59
|
+
|
|
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
|
+
Logger.verbose(`[CDK] [Worker] aws-cdk-lib PATH ${awsCdkLibPath}`);
|
|
64
|
+
|
|
65
|
+
const pathsFix = {
|
|
66
|
+
"custom-resource-handlers/": `${awsCdkLibPath}/custom-resource-handlers/`,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// Create a proxy to intercept calls to the path module so we can fix paths
|
|
70
|
+
const pathProxy = new Proxy(path, {
|
|
71
|
+
get(target, prop) {
|
|
72
|
+
if (typeof target[prop] === "function") {
|
|
73
|
+
return function (...args) {
|
|
74
|
+
if (prop === "resolve") {
|
|
75
|
+
let resolvedPath = target[prop].apply(target, args);
|
|
76
|
+
|
|
77
|
+
for (const [key, value] of Object.entries(pathsFix)) {
|
|
78
|
+
if (resolvedPath.includes(key)) {
|
|
79
|
+
// replace the beginning of the path with the value
|
|
80
|
+
const i = resolvedPath.indexOf(key);
|
|
81
|
+
const newResolvedPath = `${value}${resolvedPath.substring(i + key.length)}`;
|
|
82
|
+
Logger.verbose(
|
|
83
|
+
`[CDK] [Worker] Fixing path ${resolvedPath} -> ${newResolvedPath}`
|
|
84
|
+
);
|
|
85
|
+
resolvedPath = newResolvedPath;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return resolvedPath;
|
|
90
|
+
}
|
|
91
|
+
return target[prop].apply(target, args);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return target[prop];
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Override the path module in the require cache
|
|
99
|
+
require.cache[require.resolve("path")] = {
|
|
100
|
+
exports: pathProxy,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -58,25 +58,25 @@ async function onMessageFromLambda(message) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
if (Configuration.config.verbose) {
|
|
61
|
-
Logger.verbose(`[Function ${message.data.functionId}]
|
|
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(`[Function ${message.data.functionId}]
|
|
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(`[Function ${message.data.functionId}]
|
|
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(`[Function ${message.data.functionId}]
|
|
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(
|
|
99
|
+
Logger.error(`[Function ${message.data.functionId}] Error: `, e);
|
|
100
100
|
const payload = {
|
|
101
101
|
type: "ERROR",
|
|
102
102
|
data: {
|
package/dist/lldebugger.mjs
CHANGED
|
@@ -13,7 +13,6 @@ import { VsCode } from "./vsCode.mjs";
|
|
|
13
13
|
import path from "path";
|
|
14
14
|
import { getRootFolder } from "./utils/getRootFolder.mjs";
|
|
15
15
|
import fs from "fs/promises";
|
|
16
|
-
import { outputFolder } from "./constants.mjs";
|
|
17
16
|
import { Logger } from "./logger.mjs";
|
|
18
17
|
import { getModuleDirname, getProjectDirname } from "./getDirname.mjs";
|
|
19
18
|
import { LambdaConnection } from "./lambdaConnection.mjs";
|
|
@@ -56,8 +55,9 @@ async function run() {
|
|
|
56
55
|
await InfraDeploy.removeInfrastructure();
|
|
57
56
|
// await GitIgnore.removeFromGitIgnore();
|
|
58
57
|
// delete folder .lldebugger
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const folder = path.join(getProjectDirname(), ".lldebugger");
|
|
59
|
+
Logger.verbose(`Removing ${folder} folder...`);
|
|
60
|
+
await fs.rm(folder, { recursive: true });
|
|
61
61
|
if (Configuration.config.remove === "all") {
|
|
62
62
|
await InfraDeploy.deleteLayer();
|
|
63
63
|
}
|
package/dist/nodeEsBuild.mjs
CHANGED