lambda-live-debugger 0.0.93 → 0.0.95
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 +2 -2
- package/dist/configuration/getConfigFromWizard.mjs +20 -13
- package/dist/configuration.d.ts +6 -0
- package/dist/configuration.mjs +13 -4
- package/dist/extension/extension.zip +0 -0
- package/dist/frameworks/cdkFrameworkWorker.mjs +1 -1
- package/dist/frameworks/slsFramework.mjs +3 -5
- package/dist/index.mjs +4 -4
- package/dist/lambdaConnection.mjs +2 -2
- package/dist/nodeEsBuild.mjs +2 -3
- package/dist/nodeWorker.mjs +2 -2
- package/dist/vsCode.mjs +11 -6
- package/fix-imports.js +9 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Lambda Live Debugger is an indispensable tool for debugging AWS Lambda functions from your computer, even though they are deployed in the cloud. It supports Lambdas written in JavaScript or TypeScript.
|
|
6
6
|
|
|
7
|
-
This tool offers similar functionality to [SST](https://sst.dev/) and [Serverless Framework v4](https://www.serverless.com/blog/serverless-framework-v4-general-availability), with the addition of an Observability
|
|
7
|
+
This tool offers similar functionality to [SST](https://sst.dev/) and [Serverless Framework v4](https://www.serverless.com/blog/serverless-framework-v4-general-availability), with the addition of an Observability Mode.
|
|
8
8
|
|
|
9
9
|
It supports the following frameworks:
|
|
10
10
|
|
|
@@ -202,7 +202,7 @@ Check the [open issues](https://github.com/ServerlessLife/lambda-live-debugger/i
|
|
|
202
202
|
|
|
203
203
|
## Authors:
|
|
204
204
|
|
|
205
|
-
- [Marko (ServerlessLife)](https://
|
|
205
|
+
- [Marko (ServerlessLife)](https://www.serverlesslife.com/)
|
|
206
206
|
- ⭐ Your name here for big code contributions
|
|
207
207
|
|
|
208
208
|
## Contributors (alphabetical)
|
|
@@ -6,6 +6,7 @@ import { ResourceDiscovery } from "../resourceDiscovery.mjs";
|
|
|
6
6
|
import { GitIgnore } from "../gitignore.mjs";
|
|
7
7
|
import { VsCode } from "../vsCode.mjs";
|
|
8
8
|
import { Logger } from "../logger.mjs";
|
|
9
|
+
import { Configuration } from "../configuration.mjs";
|
|
9
10
|
const configFileName = path.resolve(configFileDefaultName);
|
|
10
11
|
/**
|
|
11
12
|
* Get configuration from wizard
|
|
@@ -18,7 +19,7 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
18
19
|
{
|
|
19
20
|
type: "list",
|
|
20
21
|
name: "framework",
|
|
21
|
-
message: `Which framework are you using (detected ${currentFramework})?`,
|
|
22
|
+
message: `Which framework are you using (detected: ${currentFramework ?? "?"})?`,
|
|
22
23
|
choices: supportedFrameworks,
|
|
23
24
|
default: currentConfig?.framework ?? currentFramework,
|
|
24
25
|
},
|
|
@@ -156,6 +157,9 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
156
157
|
},
|
|
157
158
|
]);
|
|
158
159
|
if (answersFilter.function === "Pick one") {
|
|
160
|
+
// I need to use congiration settings I accquired so far to get the list of lambdas
|
|
161
|
+
const configTemp = getConfigFromAnswers(answers);
|
|
162
|
+
Configuration.setConfig(configTemp); // not complete config
|
|
159
163
|
lambdasList = await ResourceDiscovery.getLambdas(getConfigFromAnswers(answers));
|
|
160
164
|
if (!lambdasList) {
|
|
161
165
|
throw new Error("No Lambdas found");
|
|
@@ -231,9 +235,14 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
231
235
|
*/
|
|
232
236
|
const config = getConfigFromAnswers(answers);
|
|
233
237
|
if (save) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
238
|
+
await saveConfiguration(config);
|
|
239
|
+
}
|
|
240
|
+
return config;
|
|
241
|
+
}
|
|
242
|
+
async function saveConfiguration(config) {
|
|
243
|
+
Logger.log(`Saving to config file ${configFileName}`);
|
|
244
|
+
// save to file that looks like this:
|
|
245
|
+
const configContent = `
|
|
237
246
|
import { type LldConfigTs } from "lambda-live-debugger";
|
|
238
247
|
|
|
239
248
|
export default {
|
|
@@ -255,15 +264,13 @@ export default {
|
|
|
255
264
|
//},
|
|
256
265
|
} satisfies LldConfigTs;
|
|
257
266
|
`;
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
return config;
|
|
267
|
+
// remove lines that contains undefined or ""
|
|
268
|
+
const configContentCleaned = configContent
|
|
269
|
+
.trim()
|
|
270
|
+
.split("\n")
|
|
271
|
+
.filter((l) => !l.includes("undefined") && !l.includes('""'))
|
|
272
|
+
.join("\n");
|
|
273
|
+
await fs.writeFile(configFileName, configContentCleaned);
|
|
267
274
|
}
|
|
268
275
|
function getConfigFromAnswers(answers) {
|
|
269
276
|
const config = {
|
package/dist/configuration.d.ts
CHANGED
|
@@ -19,11 +19,17 @@ declare function getLambdas(): LambdaProps[];
|
|
|
19
19
|
* Discover Lambdas
|
|
20
20
|
*/
|
|
21
21
|
declare function discoverLambdas(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Set the configuration
|
|
24
|
+
* @param newConfig
|
|
25
|
+
*/
|
|
26
|
+
declare function setConfig(newConfig: LldConfig): void;
|
|
22
27
|
export declare const Configuration: {
|
|
23
28
|
readConfig: typeof readConfig;
|
|
24
29
|
readonly config: LldConfig;
|
|
25
30
|
discoverLambdas: typeof discoverLambdas;
|
|
26
31
|
getLambda: typeof getLambda;
|
|
27
32
|
getLambdas: typeof getLambdas;
|
|
33
|
+
setConfig: typeof setConfig;
|
|
28
34
|
};
|
|
29
35
|
export {};
|
package/dist/configuration.mjs
CHANGED
|
@@ -17,6 +17,7 @@ async function readConfig() {
|
|
|
17
17
|
const supportedFrameworks = ResourceDiscovery.getSupportedFrameworksNames();
|
|
18
18
|
const currentFramework = await ResourceDiscovery.getCurrentFrameworkName();
|
|
19
19
|
const configFromCliArgs = await getConfigFromCliArgs(supportedFrameworks);
|
|
20
|
+
Logger.setVerbose(configFromCliArgs.verbose === true);
|
|
20
21
|
const configFileName = configFromCliArgs.config || configFileDefaultName;
|
|
21
22
|
const configFromConfigFile = (await getConfigTsFromConfigFile(configFileName))
|
|
22
23
|
?.default;
|
|
@@ -27,20 +28,20 @@ async function readConfig() {
|
|
|
27
28
|
currentConfig: configFromConfigFile,
|
|
28
29
|
});
|
|
29
30
|
const debuggerId = await generateDebuggerId(!!configFromWizard.observable);
|
|
30
|
-
|
|
31
|
+
setConfig({
|
|
31
32
|
...configFromWizard,
|
|
32
33
|
debuggerId,
|
|
33
34
|
start: false, // don't start the debugger after the wizard
|
|
34
|
-
};
|
|
35
|
+
});
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
37
38
|
const configMerged = { ...configFromCliArgs, ...configFromConfigFile };
|
|
38
39
|
const debuggerId = await generateDebuggerId(!!configMerged.observable);
|
|
39
|
-
|
|
40
|
+
setConfig({
|
|
40
41
|
...configMerged,
|
|
41
42
|
debuggerId,
|
|
42
43
|
start: true,
|
|
43
|
-
};
|
|
44
|
+
});
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
@@ -133,6 +134,13 @@ function saveDiscoveredLambdas(lambdasListNew) {
|
|
|
133
134
|
.join("\n - ")}`);
|
|
134
135
|
}
|
|
135
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Set the configuration
|
|
139
|
+
* @param newConfig
|
|
140
|
+
*/
|
|
141
|
+
function setConfig(newConfig) {
|
|
142
|
+
config = newConfig;
|
|
143
|
+
}
|
|
136
144
|
export const Configuration = {
|
|
137
145
|
readConfig,
|
|
138
146
|
get config() {
|
|
@@ -144,4 +152,5 @@ export const Configuration = {
|
|
|
144
152
|
discoverLambdas,
|
|
145
153
|
getLambda,
|
|
146
154
|
getLambdas,
|
|
155
|
+
setConfig,
|
|
147
156
|
};
|
|
Binary file
|
|
@@ -18,7 +18,7 @@ parentPort.on("message", async (data) => {
|
|
|
18
18
|
|
|
19
19
|
// execute code to get the data into global.lambdas
|
|
20
20
|
const codeFile = await fs.readFile(data.compileOutput, "utf8");
|
|
21
|
-
const __dirname = path.resolve("./
|
|
21
|
+
const __dirname = path.resolve("./x"); // CDK needs this, pure magic
|
|
22
22
|
eval(codeFile);
|
|
23
23
|
|
|
24
24
|
if (global.lambdas.length === 0) {
|
|
@@ -21,7 +21,7 @@ export class SlsFramework {
|
|
|
21
21
|
const serverlessFiles = [
|
|
22
22
|
path.resolve("serverless.yml"),
|
|
23
23
|
path.resolve("serverless.yaml"),
|
|
24
|
-
path.resolve("serverless.
|
|
24
|
+
path.resolve("serverless.js"),
|
|
25
25
|
path.resolve("serverless.ts"),
|
|
26
26
|
path.resolve("serverless.json"),
|
|
27
27
|
];
|
|
@@ -52,12 +52,10 @@ export class SlsFramework {
|
|
|
52
52
|
// lazy load modules
|
|
53
53
|
resolveConfigurationPath = (await import(
|
|
54
54
|
//@ts-ignore
|
|
55
|
-
"serverless/lib/cli/resolve-configuration-path.
|
|
56
|
-
)).default;
|
|
55
|
+
"serverless/lib/cli/resolve-configuration-path.js")).default;
|
|
57
56
|
readConfiguration = (await import(
|
|
58
57
|
//@ts-ignore
|
|
59
|
-
"serverless/lib/configuration/read.
|
|
60
|
-
)).default;
|
|
58
|
+
"serverless/lib/configuration/read.js")).default;
|
|
61
59
|
Serverless = (await import("serverless")).default;
|
|
62
60
|
}
|
|
63
61
|
catch (error) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CdkFramework } from "./frameworks/cdkFramework.
|
|
2
|
-
export { SlsFramework } from "./frameworks/slsFramework.
|
|
3
|
-
export { SamFramework } from "./frameworks/samFramework.
|
|
4
|
-
export { TerraformFramework } from "./frameworks/terraformFramework.
|
|
1
|
+
export { CdkFramework } from "./frameworks/cdkFramework.js";
|
|
2
|
+
export { SlsFramework } from "./frameworks/slsFramework.js";
|
|
3
|
+
export { SamFramework } from "./frameworks/samFramework.js";
|
|
4
|
+
export { TerraformFramework } from "./frameworks/terraformFramework.js";
|
|
@@ -63,7 +63,7 @@ async function onMessageFromLambda(message) {
|
|
|
63
63
|
else {
|
|
64
64
|
// first 50 characters of the response
|
|
65
65
|
const requestPretty = message.data
|
|
66
|
-
? JSON.stringify(message.data).substring(0,
|
|
66
|
+
? JSON.stringify(message.data).substring(0, 100)
|
|
67
67
|
: "";
|
|
68
68
|
Logger.log(`${message.data.functionId} request: ${requestPretty}${requestPretty.length < 50 ? "" : "..."}`);
|
|
69
69
|
}
|
|
@@ -74,7 +74,7 @@ async function onMessageFromLambda(message) {
|
|
|
74
74
|
else {
|
|
75
75
|
// first 50 characters of the response
|
|
76
76
|
const responsePretty = response
|
|
77
|
-
? JSON.stringify(response).substring(0,
|
|
77
|
+
? JSON.stringify(response).substring(0, 100)
|
|
78
78
|
: "";
|
|
79
79
|
Logger.log(`${message.data.functionId} response: ${responsePretty}${responsePretty.length < 50 ? "" : "..."}`);
|
|
80
80
|
}
|
package/dist/nodeEsBuild.mjs
CHANGED
|
@@ -20,7 +20,7 @@ async function getBuild(functionId) {
|
|
|
20
20
|
let newBuild = false;
|
|
21
21
|
const func = await Configuration.getLambda(functionId);
|
|
22
22
|
// if handler is a JavaScript file and not force bundle, just return the file
|
|
23
|
-
if ((func.codePath.endsWith(".
|
|
23
|
+
if ((func.codePath.endsWith(".js") ||
|
|
24
24
|
func.codePath.endsWith(".mjs") ||
|
|
25
25
|
func.codePath.endsWith(".cjs")) &&
|
|
26
26
|
!func.forceBundle) {
|
|
@@ -53,8 +53,7 @@ async function getBuild(functionId) {
|
|
|
53
53
|
if (newBuild) {
|
|
54
54
|
Logger.verbose(`[Function ${functionId}] Build complete`);
|
|
55
55
|
}
|
|
56
|
-
const artifactFile = Object.keys(result.metafile?.outputs).find((key) => key.endsWith(".
|
|
57
|
-
);
|
|
56
|
+
const artifactFile = Object.keys(result.metafile?.outputs).find((key) => key.endsWith(".js"));
|
|
58
57
|
if (!artifactFile) {
|
|
59
58
|
throw new Error(`Artifact file not found for function ${functionId}`);
|
|
60
59
|
}
|
package/dist/nodeWorker.mjs
CHANGED
|
@@ -27,7 +27,7 @@ async function runInWorker(input) {
|
|
|
27
27
|
Logger.verbose(`[Function ${input.fuctionRequest.functionId}] [Worker ${input.fuctionRequest.workerId}] Reusing worker`);
|
|
28
28
|
}
|
|
29
29
|
worker.on("message", (msg) => {
|
|
30
|
-
Logger.
|
|
30
|
+
Logger.verbose(`[Function ${input.fuctionRequest.functionId}] [Worker ${input.fuctionRequest.workerId}] Worker message`, JSON.stringify(msg));
|
|
31
31
|
if (msg?.errorType) {
|
|
32
32
|
reject(msg);
|
|
33
33
|
}
|
|
@@ -36,7 +36,7 @@ async function runInWorker(input) {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
worker.on("error", (err) => {
|
|
39
|
-
Logger.
|
|
39
|
+
Logger.error(`[Function ${input.fuctionRequest.functionId}] [Worker ${input.fuctionRequest.workerId}] Error`, err);
|
|
40
40
|
reject(err);
|
|
41
41
|
});
|
|
42
42
|
worker.postMessage({
|
package/dist/vsCode.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs/promises";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { parse, printParseErrorCode, applyEdits, modify, } from "jsonc-parser";
|
|
4
|
-
import { getModuleDirname } from "./getDirname.mjs";
|
|
4
|
+
import { getModuleDirname, getProjectDirname } from "./getDirname.mjs";
|
|
5
5
|
import { Logger } from "./logger.mjs";
|
|
6
6
|
async function getVsCodeLaunchConfig(lldConfig) {
|
|
7
7
|
const localRuntimeExecutable = "${workspaceFolder}/node_modules/.bin/lld";
|
|
@@ -40,9 +40,10 @@ async function getVsCodeLaunchConfig(lldConfig) {
|
|
|
40
40
|
//Logger.log("Not found", localFolder);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
const
|
|
43
|
+
if (runtimeExecutableSet) {
|
|
44
|
+
const projectDirname = getProjectDirname();
|
|
45
|
+
const globalModule1 = path.join(projectDirname, "..", "..", ".bin/lld");
|
|
46
|
+
const globalModule2 = path.join(projectDirname, "..", "..", "bin/lld");
|
|
46
47
|
const globalModule3 = path.join(moduleDirname, "..", "..", "..", "..", "bin/lld");
|
|
47
48
|
const possibleFolders = {
|
|
48
49
|
[localFolder]: "${workspaceFolder}/node_modules/.bin/lld",
|
|
@@ -104,6 +105,7 @@ async function writeConfiguration(filePath, jsonString, changes, position) {
|
|
|
104
105
|
});
|
|
105
106
|
const modifiedJsonString = applyEdits(jsonString, edits);
|
|
106
107
|
// Write the modified JSON string back to the file
|
|
108
|
+
Logger.verbose(`Adding to VsCode configuration file: ${filePath}`);
|
|
107
109
|
await fs.writeFile(filePath, modifiedJsonString, "utf-8");
|
|
108
110
|
}
|
|
109
111
|
catch (err) {
|
|
@@ -112,7 +114,7 @@ async function writeConfiguration(filePath, jsonString, changes, position) {
|
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
async function getCurrentState() {
|
|
115
|
-
const filePath = path.join(
|
|
117
|
+
const filePath = path.join(getProjectDirname(), ".vscode/launch.json");
|
|
116
118
|
let createNewFile = false;
|
|
117
119
|
// does file exist
|
|
118
120
|
try {
|
|
@@ -130,6 +132,7 @@ async function getCurrentState() {
|
|
|
130
132
|
return c.name === vsCodeLaunchConfig.configurations[0].name;
|
|
131
133
|
});
|
|
132
134
|
if (!exists) {
|
|
135
|
+
Logger.verbose(`${filePath} exists but configuration does not exist!`);
|
|
133
136
|
return {
|
|
134
137
|
state: "FILE_EXISTS_CONFIGURATION_DOES_NOT_EXIST",
|
|
135
138
|
jsonString,
|
|
@@ -138,13 +141,14 @@ async function getCurrentState() {
|
|
|
138
141
|
};
|
|
139
142
|
}
|
|
140
143
|
else {
|
|
141
|
-
Logger.
|
|
144
|
+
Logger.verbose(`Configuration already exists in ${filePath}`);
|
|
142
145
|
return {
|
|
143
146
|
state: "FILE_EXISTS_CONFIGURATION_EXISTS",
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
149
|
}
|
|
147
150
|
else {
|
|
151
|
+
Logger.verbose(`${filePath} does not exist!`);
|
|
148
152
|
return {
|
|
149
153
|
state: "FILE_DOES_NOT_EXIST",
|
|
150
154
|
filePath,
|
|
@@ -169,6 +173,7 @@ async function addConfiguration(lldConfig) {
|
|
|
169
173
|
else if (state.state === "FILE_DOES_NOT_EXIST") {
|
|
170
174
|
// crete folder of filePath recursive if not exists
|
|
171
175
|
await fs.mkdir(path.dirname(state.filePath), { recursive: true });
|
|
176
|
+
Logger.verbose(`Creating VsCode configuration file: ${state.filePath}`);
|
|
172
177
|
await fs.writeFile(state.filePath, JSON.stringify(config, null, 2), "utf-8");
|
|
173
178
|
}
|
|
174
179
|
}
|
package/fix-imports.js
CHANGED
|
@@ -17,7 +17,15 @@ async function processFiles(directory) {
|
|
|
17
17
|
await processFiles(fullPath);
|
|
18
18
|
} else if (entry.isFile() && entry.name.endsWith(".js")) {
|
|
19
19
|
const data = await readFile(fullPath, "utf8");
|
|
20
|
-
const updatedData = data
|
|
20
|
+
const updatedData = data
|
|
21
|
+
.split("\n")
|
|
22
|
+
.map((line) => {
|
|
23
|
+
if (line.trim().startsWith("import")) {
|
|
24
|
+
return line.replace(/\.js"/g, '.mjs"');
|
|
25
|
+
}
|
|
26
|
+
return line;
|
|
27
|
+
})
|
|
28
|
+
.join("\n");
|
|
21
29
|
const { dir, name } = parse(fullPath);
|
|
22
30
|
const newFullPath = join(dir, `${name}.mjs`);
|
|
23
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lambda-live-debugger",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.95",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Debug Lambda functions locally like it is running in the cloud",
|
|
6
6
|
"repository": {
|
|
@@ -60,7 +60,6 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@tsconfig/node20": "^20.1.4",
|
|
62
62
|
"@types/aws-iot-device-sdk": "^2.2.8",
|
|
63
|
-
"@types/commander": "^2.12.2",
|
|
64
63
|
"@types/inquirer": "^9.0.7",
|
|
65
64
|
"@types/node": "^20.11.16",
|
|
66
65
|
"@types/serverless": "^3.12.22",
|