lambda-live-debugger 0.0.97 → 0.0.99

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.
@@ -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: currentConfig?.framework ?? currentFramework,
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: currentConfig?.observable ?? false,
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: currentConfig?.interval ?? defaultObservableInterval,
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 = answersVerbose.verbose;
248
+ answers.verbose =
249
+ configFromCliArgs.verbose !== undefined
250
+ ? configFromCliArgs.verbose
251
+ : answersVerbose.verbose;
238
252
  }
239
253
  /*
240
254
  {
@@ -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
@@ -7,7 +7,7 @@ import { findPackageJson } from "../utils/findPackageJson.mjs";
7
7
  import { CloudFormation } from "../cloudFormation.mjs";
8
8
  import { Logger } from "../logger.mjs";
9
9
  import { Worker } from "node:worker_threads";
10
- import { getModuleDirname } from "../getDirname.mjs";
10
+ import { getModuleDirname, getProjectDirname } from "../getDirname.mjs";
11
11
  import { Configuration } from "../configuration.mjs";
12
12
  /**
13
13
  * Support for AWS CDK framework
@@ -190,7 +190,7 @@ export class CdkFramework {
190
190
  });
191
191
  },
192
192
  };
193
- const compileOutput = path.resolve(`${outputFolder}/compiledCdk.js`);
193
+ const compileOutput = path.join(getProjectDirname(), outputFolder, `compiledCdk.js`);
194
194
  try {
195
195
  // Build CDK code
196
196
  await esbuild.build({
@@ -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}`, {
@@ -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) => {
package/dist/vsCode.mjs CHANGED
@@ -22,16 +22,16 @@ async function getVsCodeLaunchConfig(lldConfig) {
22
22
  };
23
23
  const moduleDirname = getModuleDirname();
24
24
  //Logger.log("Module folder", moduleDirname);
25
- const currentFolder = path.resolve();
25
+ const projectDirname = getProjectDirname();
26
26
  //Logger.log("Current folder", currentFolder);
27
- const localFolder = path.join(currentFolder, "node_modules/.bin/lld");
27
+ const localFolder = path.resolve(path.join(projectDirname, "node_modules/.bin/lld"));
28
28
  let runtimeExecutableSet = false;
29
29
  //if installed locally
30
30
  if (moduleDirname.startsWith("/home/")) {
31
31
  Logger.verbose("Lambda Live Debugger is installed locally");
32
32
  // check if file exists
33
33
  try {
34
- //Logger.log("Checking local folder", localFolder);
34
+ Logger.log("Checking local folder for runtimeExecutable setting for VsCode configuration", localFolder);
35
35
  await fs.access(localFolder, fs.constants.F_OK);
36
36
  config.configurations[0].runtimeExecutable = localRuntimeExecutable;
37
37
  runtimeExecutableSet = true;
@@ -46,11 +46,13 @@ async function getVsCodeLaunchConfig(lldConfig) {
46
46
  }
47
47
  if (!runtimeExecutableSet) {
48
48
  Logger.verbose(`Setting absolute path for runtimeExecutable setting for VsCode configuration`);
49
+ const localFolderSubfolder = path.resolve("node_modules/.bin/lld");
49
50
  const globalModule1 = path.join(moduleDirname, "..", "..", ".bin/lld");
50
51
  const globalModule2 = path.join(moduleDirname, "..", "..", "bin/lld");
51
52
  const globalModule3 = path.join(moduleDirname, "..", "..", "..", "..", "bin/lld");
52
53
  const possibleFolders = {
53
54
  [localFolder]: "${workspaceFolder}/node_modules/.bin/lld",
55
+ [localFolderSubfolder]: localFolderSubfolder,
54
56
  [globalModule1]: globalModule1,
55
57
  [globalModule2]: globalModule2,
56
58
  [globalModule3]: globalModule3,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-live-debugger",
3
- "version": "0.0.97",
3
+ "version": "0.0.99",
4
4
  "type": "module",
5
5
  "description": "Debug Lambda functions locally like it is running in the cloud",
6
6
  "repository": {