lambda-live-debugger 0.0.98 → 0.0.100
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/getConfigFromWizard.d.ts +3 -2
- package/dist/configuration/getConfigFromWizard.mjs +27 -13
- package/dist/configuration.mjs +3 -1
- package/dist/extension/extension.zip +0 -0
- package/dist/gitignore.mjs +15 -6
- package/dist/lambdaConnection.mjs +4 -4
- package/dist/nodeEsBuild.mjs +1 -1
- package/dist/nodeWorker.mjs +1 -1
- package/dist/nodeWorkerRunner.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { LldConfigBase, LldConfigTs } from "../types/lldConfig.js";
|
|
1
|
+
import { LldConfigBase, LldConfigCliArgs, LldConfigTs } from "../types/lldConfig.js";
|
|
2
2
|
/**
|
|
3
3
|
* Get configuration from wizard
|
|
4
4
|
* @param parameters
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
|
-
export declare function getConfigFromWizard({ supportedFrameworks, currentFramework, currentConfig, }: {
|
|
7
|
+
export declare function getConfigFromWizard({ configFromCliArgs, supportedFrameworks, currentFramework, currentConfig, }: {
|
|
8
|
+
configFromCliArgs: LldConfigCliArgs;
|
|
8
9
|
supportedFrameworks: string[];
|
|
9
10
|
currentFramework: string | undefined;
|
|
10
11
|
currentConfig?: LldConfigTs;
|
|
@@ -13,7 +13,7 @@ const configFileName = path.resolve(configFileDefaultName);
|
|
|
13
13
|
* @param parameters
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
export async function getConfigFromWizard({ supportedFrameworks, currentFramework, currentConfig, }) {
|
|
16
|
+
export async function getConfigFromWizard({ configFromCliArgs, supportedFrameworks, currentFramework, currentConfig, }) {
|
|
17
17
|
let lambdasList;
|
|
18
18
|
let answers = await inquirer.prompt([
|
|
19
19
|
{
|
|
@@ -21,13 +21,18 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
21
21
|
name: "framework",
|
|
22
22
|
message: `Which framework are you using (detected: ${currentFramework ?? "?"})?`,
|
|
23
23
|
choices: [...supportedFrameworks, "other"],
|
|
24
|
-
default:
|
|
24
|
+
default: configFromCliArgs.framework ??
|
|
25
|
+
currentConfig?.framework ??
|
|
26
|
+
currentFramework,
|
|
25
27
|
},
|
|
26
28
|
]);
|
|
27
29
|
if (answers.framework === "other") {
|
|
28
30
|
answers.framework = undefined;
|
|
29
31
|
}
|
|
30
32
|
const oldContext = currentConfig?.context ?? [];
|
|
33
|
+
if (configFromCliArgs.context?.length) {
|
|
34
|
+
oldContext.push(...configFromCliArgs.context);
|
|
35
|
+
}
|
|
31
36
|
if (answers.framework === "cdk") {
|
|
32
37
|
const cdkAnswers = await inquirer.prompt([
|
|
33
38
|
{
|
|
@@ -68,7 +73,7 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
68
73
|
type: "input",
|
|
69
74
|
name: "stage",
|
|
70
75
|
message: "Would you like to enter Serverless Framework stage?",
|
|
71
|
-
default: currentConfig?.stage,
|
|
76
|
+
default: configFromCliArgs.stage ?? currentConfig?.stage,
|
|
72
77
|
},
|
|
73
78
|
]);
|
|
74
79
|
answers = { ...answers, ...slsAnswers };
|
|
@@ -79,7 +84,7 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
79
84
|
type: "input",
|
|
80
85
|
name: "configEnv",
|
|
81
86
|
message: "Would you like to enter SAM environment?",
|
|
82
|
-
default: currentConfig?.configEnv,
|
|
87
|
+
default: configFromCliArgs.configEnv ?? currentConfig?.configEnv,
|
|
83
88
|
},
|
|
84
89
|
]);
|
|
85
90
|
answers = { ...answers, ...samAnswers };
|
|
@@ -91,7 +96,7 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
91
96
|
type: "input",
|
|
92
97
|
name: "subfolder",
|
|
93
98
|
message: "If you are using monorepo, enter subfolder where the framework is instaled.",
|
|
94
|
-
default: currentConfig?.subfolder,
|
|
99
|
+
default: configFromCliArgs.subfolder ?? currentConfig?.subfolder,
|
|
95
100
|
},
|
|
96
101
|
]);
|
|
97
102
|
if (answersSubfolder.subfolder) {
|
|
@@ -104,7 +109,9 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
104
109
|
type: "confirm",
|
|
105
110
|
name: "observable",
|
|
106
111
|
message: "Do you want to use observable mode, which just sends events to the debugger and do not use the respose?",
|
|
107
|
-
default:
|
|
112
|
+
default: configFromCliArgs.observable !== undefined
|
|
113
|
+
? configFromCliArgs.observable
|
|
114
|
+
: currentConfig?.observable,
|
|
108
115
|
},
|
|
109
116
|
]);
|
|
110
117
|
answers = { ...answers, ...answersObservable };
|
|
@@ -114,7 +121,11 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
114
121
|
type: "number",
|
|
115
122
|
name: "interval",
|
|
116
123
|
message: `Would you like to enter observable mode interval at which events are sent to the debugger? Default is ${defaultObservableInterval}`,
|
|
117
|
-
default:
|
|
124
|
+
default: configFromCliArgs.observable !== undefined
|
|
125
|
+
? configFromCliArgs.observable
|
|
126
|
+
: currentConfig?.interval !== undefined
|
|
127
|
+
? currentConfig?.interval
|
|
128
|
+
: defaultObservableInterval,
|
|
118
129
|
},
|
|
119
130
|
]);
|
|
120
131
|
answers = {
|
|
@@ -129,19 +140,19 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
129
140
|
type: "input",
|
|
130
141
|
name: "profile",
|
|
131
142
|
message: "Would you like to use named AWS profile?",
|
|
132
|
-
default: currentConfig?.profile,
|
|
143
|
+
default: configFromCliArgs.profile ?? currentConfig?.profile,
|
|
133
144
|
},
|
|
134
145
|
{
|
|
135
146
|
type: "input",
|
|
136
147
|
name: "region",
|
|
137
148
|
message: "Would you like to specify AWS region?",
|
|
138
|
-
default: currentConfig?.region,
|
|
149
|
+
default: configFromCliArgs.region ?? currentConfig?.region,
|
|
139
150
|
},
|
|
140
151
|
{
|
|
141
152
|
type: "input",
|
|
142
153
|
name: "role",
|
|
143
154
|
message: "Would you like to specify AWS role?",
|
|
144
|
-
default: currentConfig?.role,
|
|
155
|
+
default: configFromCliArgs.role ?? currentConfig?.role,
|
|
145
156
|
},
|
|
146
157
|
]);
|
|
147
158
|
answers = { ...answers, ...answersAws };
|
|
@@ -174,7 +185,7 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
174
185
|
name: "function",
|
|
175
186
|
message: "Pick Lambda to debug",
|
|
176
187
|
choices: lambdasList.map((l) => l.functionName),
|
|
177
|
-
default: currentConfig?.function,
|
|
188
|
+
default: currentConfig?.function ?? lambdasList[0].functionName,
|
|
178
189
|
},
|
|
179
190
|
]);
|
|
180
191
|
answers.function = lambdas.function;
|
|
@@ -188,7 +199,7 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
188
199
|
type: "input",
|
|
189
200
|
name: "name",
|
|
190
201
|
message: "Enter Lambda name to filter. Use * as wildcard",
|
|
191
|
-
default: currentConfig?.function,
|
|
202
|
+
default: configFromCliArgs.function ?? currentConfig?.function,
|
|
192
203
|
},
|
|
193
204
|
]);
|
|
194
205
|
answers.function = filter.name;
|
|
@@ -234,7 +245,10 @@ export async function getConfigFromWizard({ supportedFrameworks, currentFramewor
|
|
|
234
245
|
default: currentConfig?.verbose === true,
|
|
235
246
|
},
|
|
236
247
|
]);
|
|
237
|
-
answers.verbose =
|
|
248
|
+
answers.verbose =
|
|
249
|
+
configFromCliArgs.verbose !== undefined
|
|
250
|
+
? configFromCliArgs.verbose
|
|
251
|
+
: answersVerbose.verbose;
|
|
238
252
|
}
|
|
239
253
|
/*
|
|
240
254
|
{
|
package/dist/configuration.mjs
CHANGED
|
@@ -15,14 +15,16 @@ let lambdasList = undefined;
|
|
|
15
15
|
*/
|
|
16
16
|
async function readConfig() {
|
|
17
17
|
const supportedFrameworks = ResourceDiscovery.getSupportedFrameworksNames();
|
|
18
|
-
const currentFramework = await ResourceDiscovery.getCurrentFrameworkName();
|
|
19
18
|
const configFromCliArgs = await getConfigFromCliArgs(supportedFrameworks);
|
|
19
|
+
Configuration.setConfig(configFromCliArgs); // not complete config
|
|
20
|
+
const currentFramework = await ResourceDiscovery.getCurrentFrameworkName();
|
|
20
21
|
Logger.setVerbose(configFromCliArgs.verbose === true);
|
|
21
22
|
const configFileName = configFromCliArgs.config || configFileDefaultName;
|
|
22
23
|
const configFromConfigFile = (await getConfigTsFromConfigFile(configFileName))
|
|
23
24
|
?.default;
|
|
24
25
|
if (configFromCliArgs.wizard) {
|
|
25
26
|
const configFromWizard = await getConfigFromWizard({
|
|
27
|
+
configFromCliArgs,
|
|
26
28
|
supportedFrameworks,
|
|
27
29
|
currentFramework,
|
|
28
30
|
currentConfig: configFromConfigFile,
|
|
Binary file
|
package/dist/gitignore.mjs
CHANGED
|
@@ -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(
|
|
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(
|
|
39
|
+
await fs.access(getGitIgnoreFileLocation());
|
|
31
40
|
}
|
|
32
41
|
catch (error) {
|
|
33
|
-
await fs.writeFile(
|
|
42
|
+
await fs.writeFile(getGitIgnoreFileLocation(), `${outputFolder}\n`);
|
|
34
43
|
return;
|
|
35
44
|
}
|
|
36
45
|
// append to existing file
|
|
37
|
-
await fs.appendFile(
|
|
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(
|
|
59
|
+
const gitignoreContent = await fs.readFile(getGitIgnoreFileLocation(), "utf-8");
|
|
51
60
|
const newContent = gitignoreContent.replace(`${outputFolder}\n`, "");
|
|
52
|
-
await fs.writeFile(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
package/dist/nodeEsBuild.mjs
CHANGED
|
@@ -57,7 +57,7 @@ async function getBuild(functionId) {
|
|
|
57
57
|
if (!artifactFile) {
|
|
58
58
|
throw new Error(`Artifact file not found for function ${functionId}`);
|
|
59
59
|
}
|
|
60
|
-
return artifactFile;
|
|
60
|
+
return path.join(getProjectDirname(), artifactFile);
|
|
61
61
|
}
|
|
62
62
|
catch (error) {
|
|
63
63
|
throw new Error(`Error building function ${functionId}: ${error.message}`, {
|
package/dist/nodeWorker.mjs
CHANGED
|
@@ -52,7 +52,7 @@ async function runInWorker(input) {
|
|
|
52
52
|
* @returns
|
|
53
53
|
*/
|
|
54
54
|
function startWorker(input) {
|
|
55
|
-
Logger.verbose(`[Function ${input.functionId}] [Worker ${input.workerId}] Starting worker`);
|
|
55
|
+
Logger.verbose(`[Function ${input.functionId}] [Worker ${input.workerId}] Starting worker. Artifact: ${input.artifactFile}`);
|
|
56
56
|
let localProjectDir = getProjectDirname();
|
|
57
57
|
const worker = new Worker(path.resolve(path.join(getModuleDirname(), `./nodeWorkerRunner.mjs`)), {
|
|
58
58
|
env: {
|
|
@@ -6,7 +6,7 @@ import { Logger } from "./logger.mjs";
|
|
|
6
6
|
|
|
7
7
|
Logger.setVerbose(workerData.verbose);
|
|
8
8
|
Logger.verbose(
|
|
9
|
-
`[Function ${workerData.functionId}] [Worker ${workerData.workerId}] Worker started
|
|
9
|
+
`[Function ${workerData.functionId}] [Worker ${workerData.workerId}] Worker started.`
|
|
10
10
|
);
|
|
11
11
|
|
|
12
12
|
parentPort.on("message", async (data) => {
|