lambda-live-debugger 0.0.106 → 0.0.108

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.
@@ -27,7 +27,7 @@ function watchForFileChanges(folder) {
27
27
  stabilityThreshold: 20,
28
28
  },
29
29
  });
30
- watcher.on("change", async (file) => {
30
+ watcher.on("change", async () => {
31
31
  if (processingChange) {
32
32
  return;
33
33
  }
@@ -31,7 +31,7 @@ export class CdkFramework {
31
31
  await fs.access(cdkJsonPath, fs.constants.F_OK);
32
32
  return true;
33
33
  }
34
- catch (error) {
34
+ catch {
35
35
  Logger.verbose(`[CDK] This is not a CDK project. ${cdkJsonPath} not found`);
36
36
  return false;
37
37
  }
@@ -226,9 +226,9 @@ export class CdkFramework {
226
226
  awsCdkLibPath,
227
227
  },
228
228
  });
229
- worker.on("message", (message) => {
229
+ worker.on("message", async (message) => {
230
230
  resolve(message);
231
- worker.terminate();
231
+ await worker.terminate();
232
232
  });
233
233
  worker.on("error", (error) => {
234
234
  reject(new Error(`Error running CDK code in worker: ${error.message}`, {
@@ -3,6 +3,7 @@ const require = topLevelCreateRequire(import.meta.url);
3
3
  import path from "path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  const __filename = fileURLToPath(import.meta.url);
6
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
7
  const __dirname = path.dirname(__filename);
7
8
 
8
9
  import { workerData, parentPort } from "node:worker_threads";
@@ -46,7 +47,7 @@ parentPort.on("message", async (data) => {
46
47
 
47
48
  Logger.verbose(
48
49
  `[CDK] [Worker] Sending found lambdas`,
49
- JSON.stringify(lambdas, null, 2)
50
+ JSON.stringify(lambdas, null, 2),
50
51
  );
51
52
  parentPort.postMessage(lambdas);
52
53
  });
@@ -79,7 +80,7 @@ async function fixCdkPaths(awsCdkLibPath) {
79
80
  const i = resolvedPath.indexOf(key);
80
81
  const newResolvedPath = `${value}${resolvedPath.substring(i + key.length)}`;
81
82
  Logger.verbose(
82
- `[CDK] [Worker] Fixing path ${resolvedPath} -> ${newResolvedPath}`
83
+ `[CDK] [Worker] Fixing path ${resolvedPath} -> ${newResolvedPath}`,
83
84
  );
84
85
  resolvedPath = newResolvedPath;
85
86
  }
@@ -26,14 +26,14 @@ export class SamFramework {
26
26
  try {
27
27
  await fs.access(path.resolve(this.samConfigFile), constants.F_OK);
28
28
  }
29
- catch (error) {
29
+ catch {
30
30
  Logger.verbose(`[SAM] This is not a SAM framework project. ${path.resolve(this.samConfigFile)} not found.`);
31
31
  return false;
32
32
  }
33
33
  try {
34
34
  await fs.access(path.resolve(this.samTemplateFile), constants.F_OK);
35
35
  }
36
- catch (error) {
36
+ catch {
37
37
  Logger.verbose(`[SAM] This is not a SAM framework project. ${path.resolve(this.samTemplateFile)} not found.`);
38
38
  return false;
39
39
  }
@@ -62,14 +62,12 @@ export class SamFramework {
62
62
  const lambdas = [];
63
63
  // get all resources of type AWS::Serverless::Function
64
64
  for (const resourceName in template.Resources) {
65
- if (template.Resources.hasOwnProperty(resourceName)) {
66
- const resource = template.Resources[resourceName];
67
- if (resource.Type === "AWS::Serverless::Function") {
68
- lambdas.push({
69
- Name: resourceName,
70
- ...resource,
71
- });
72
- }
65
+ const resource = template.Resources[resourceName];
66
+ if (resource.Type === "AWS::Serverless::Function") {
67
+ lambdas.push({
68
+ Name: resourceName,
69
+ ...resource,
70
+ });
73
71
  }
74
72
  }
75
73
  const lambdasDiscovered = [];
@@ -112,7 +110,9 @@ export class SamFramework {
112
110
  codePath = cp;
113
111
  break;
114
112
  }
115
- catch (error) { }
113
+ catch {
114
+ // ignore, file not found
115
+ }
116
116
  }
117
117
  }
118
118
  if (!codePath) {
@@ -30,7 +30,7 @@ export class SlsFramework {
30
30
  await fs.access(file, constants.F_OK);
31
31
  return true;
32
32
  }
33
- catch (error) {
33
+ catch {
34
34
  continue;
35
35
  }
36
36
  }
@@ -70,7 +70,7 @@ export class SlsFramework {
70
70
  const configuration = await readConfiguration(configurationPath);
71
71
  Logger.verbose(`[SLS] Configuration:`, JSON.stringify(configuration, null, 2));
72
72
  const serviceDir = process.cwd();
73
- let configurationFilename = configuration && configurationPath.slice(serviceDir.length + 1);
73
+ const configurationFilename = configuration && configurationPath.slice(serviceDir.length + 1);
74
74
  Logger.verbose(`[SLS] Configuration filename: ${path.resolve(configurationFilename)}`);
75
75
  const commands = [];
76
76
  const options = {};
@@ -117,48 +117,48 @@ export class SlsFramework {
117
117
  });
118
118
  }
119
119
  const lambdasDiscovered = [];
120
- let esBuildOptions = this.getEsBuildOptions(serverless);
120
+ const esBuildOptions = this.getEsBuildOptions(serverless);
121
121
  const lambdas = serverless.service.functions;
122
122
  Logger.verbose(`[SLS] Found Lambdas:`, JSON.stringify(lambdas, null, 2));
123
123
  for (const func in lambdas) {
124
- if (lambdas.hasOwnProperty(func)) {
125
- const lambda = lambdas[func];
126
- const handlerFull = lambda.handler;
127
- const handlerParts = handlerFull.split(".");
128
- const handler = handlerParts[1];
129
- const possibleCodePaths = [
130
- `${handlerParts[0]}.ts`,
131
- `${handlerParts[0]}.js`,
132
- `${handlerParts[0]}.cjs`,
133
- `${handlerParts[0]}.mjs`,
134
- ];
135
- let codePath;
136
- for (const cp of possibleCodePaths) {
137
- try {
138
- await fs.access(cp, constants.F_OK);
139
- codePath = cp;
140
- break;
141
- }
142
- catch (error) { }
124
+ const lambda = lambdas[func];
125
+ const handlerFull = lambda.handler;
126
+ const handlerParts = handlerFull.split(".");
127
+ const handler = handlerParts[1];
128
+ const possibleCodePaths = [
129
+ `${handlerParts[0]}.ts`,
130
+ `${handlerParts[0]}.js`,
131
+ `${handlerParts[0]}.cjs`,
132
+ `${handlerParts[0]}.mjs`,
133
+ ];
134
+ let codePath;
135
+ for (const cp of possibleCodePaths) {
136
+ try {
137
+ await fs.access(cp, constants.F_OK);
138
+ codePath = cp;
139
+ break;
143
140
  }
144
- if (!codePath) {
145
- throw new Error(`Code path not found for handler: ${handlerFull}`);
141
+ catch {
142
+ // ignore, file not found
146
143
  }
147
- const functionName = lambda.name;
148
- if (!functionName) {
149
- throw new Error(`Function name not found for handler: ${handlerFull}`);
150
- }
151
- const packageJsonPath = await findPackageJson(codePath);
152
- Logger.verbose(`[SLS] package.json path: ${packageJsonPath}`);
153
- const lambdaResource = {
154
- functionName,
155
- codePath,
156
- handler,
157
- packageJsonPath,
158
- esBuildOptions,
159
- };
160
- lambdasDiscovered.push(lambdaResource);
161
144
  }
145
+ if (!codePath) {
146
+ throw new Error(`Code path not found for handler: ${handlerFull}`);
147
+ }
148
+ const functionName = lambda.name;
149
+ if (!functionName) {
150
+ throw new Error(`Function name not found for handler: ${handlerFull}`);
151
+ }
152
+ const packageJsonPath = await findPackageJson(codePath);
153
+ Logger.verbose(`[SLS] package.json path: ${packageJsonPath}`);
154
+ const lambdaResource = {
155
+ functionName,
156
+ codePath,
157
+ handler,
158
+ packageJsonPath,
159
+ esBuildOptions,
160
+ };
161
+ lambdasDiscovered.push(lambdaResource);
162
162
  }
163
163
  return lambdasDiscovered;
164
164
  }
@@ -169,7 +169,7 @@ export class SlsFramework {
169
169
  const esBuildPlugin = serverless.service.plugins?.find((p) => p === "serverless-esbuild");
170
170
  if (esBuildPlugin) {
171
171
  Logger.verbose("[SLS] serverless-esbuild plugin detected");
172
- let settings = serverless.service.custom?.esbuild;
172
+ const settings = serverless.service.custom?.esbuild;
173
173
  if (settings) {
174
174
  esBuildOptions = {
175
175
  minify: settings.minify,
@@ -183,7 +183,7 @@ export class SlsFramework {
183
183
  const typeScriptPlugin = serverless.service.plugins?.find((p) => p === "serverless-plugin-typescript");
184
184
  if (typeScriptPlugin) {
185
185
  Logger.verbose("[SLS] serverless-plugin-typescript plugin detected");
186
- let settings = serverless.service.custom?.serverlessPluginTypescript;
186
+ const settings = serverless.service.custom?.serverlessPluginTypescript;
187
187
  if (settings) {
188
188
  esBuildOptions = {
189
189
  tsconfig: settings.tsConfigFileLocation,
@@ -2,7 +2,6 @@
2
2
  import { LambdaResource } from "../types/resourcesDiscovery.js";
3
3
  import { exec } from "child_process";
4
4
  import { IFramework } from "./iFrameworks.js";
5
- import { LldConfigBase } from "../types/lldConfig.js";
6
5
  export declare const execAsync: typeof exec.__promisify__;
7
6
  interface TerraformState {
8
7
  resources: Array<{
@@ -35,7 +34,7 @@ export declare class TerraformFramework implements IFramework {
35
34
  * @param config Configuration
36
35
  * @returns Lambda functions
37
36
  */
38
- getLambdas(config: LldConfigBase): Promise<LambdaResource[]>;
37
+ getLambdas(): Promise<LambdaResource[]>;
39
38
  protected extractLambdaInfo(state: TerraformState): {
40
39
  functionName: string;
41
40
  sourceDir?: string | undefined;
@@ -35,7 +35,7 @@ export class TerraformFramework {
35
35
  * @param config Configuration
36
36
  * @returns Lambda functions
37
37
  */
38
- async getLambdas(config) {
38
+ async getLambdas() {
39
39
  const state = await this.readTerraformState();
40
40
  const lambdas = this.extractLambdaInfo(state);
41
41
  Logger.verbose("[Terraform] Found Lambdas:", JSON.stringify(lambdas, null, 2));
@@ -47,10 +47,9 @@ export class TerraformFramework {
47
47
  for (const func of lambdas) {
48
48
  const functionName = func.functionName;
49
49
  const handlerParts = func.handler.split(".");
50
- let handler;
51
50
  // get last part of the handler
52
- handler = handlerParts[handlerParts.length - 1];
53
- let filename = func.sourceFilename;
51
+ const handler = handlerParts[handlerParts.length - 1];
52
+ const filename = func.sourceFilename;
54
53
  let pathWithourExtension;
55
54
  if (filename) {
56
55
  // remove extension
@@ -85,7 +84,9 @@ export class TerraformFramework {
85
84
  codePath = cp;
86
85
  break;
87
86
  }
88
- catch (error) { }
87
+ catch {
88
+ // ignore, file not found
89
+ }
89
90
  }
90
91
  if (!codePath) {
91
92
  throw new Error(`Code path not found for handler: ${functionName}`);
@@ -188,7 +189,7 @@ export class TerraformFramework {
188
189
  await fs.access(tsConfigPath, constants.F_OK);
189
190
  break;
190
191
  }
191
- catch (error) {
192
+ catch {
192
193
  // tsconfig.json not found, move up one directory
193
194
  currentDir = path.dirname(currentDir);
194
195
  }
@@ -15,7 +15,7 @@ async function doesExistInGitIgnore() {
15
15
  const exists = lines.includes(outputFolder);
16
16
  return exists;
17
17
  }
18
- catch (error) {
18
+ catch {
19
19
  return false;
20
20
  }
21
21
  }
@@ -38,7 +38,7 @@ async function addToGitIgnore() {
38
38
  try {
39
39
  await fs.access(getGitIgnoreFileLocation());
40
40
  }
41
- catch (error) {
41
+ catch {
42
42
  await fs.writeFile(getGitIgnoreFileLocation(), `${outputFolder}\n`);
43
43
  return;
44
44
  }
@@ -61,18 +61,26 @@ function getIAMClient() {
61
61
  /**
62
62
  * Find an existing layer
63
63
  * @param layerName
64
+ * @param description
64
65
  * @returns
65
66
  */
66
- async function findExistingLayer(layerName) {
67
- const listLayerVersionsCommand = new ListLayerVersionsCommand({
68
- LayerName: layerName,
69
- });
70
- const response = await getLambdaClient().send(listLayerVersionsCommand);
71
- if (response.LayerVersions && response.LayerVersions.length > 0) {
72
- const latestLayer = response.LayerVersions[0];
73
- Logger.verbose(`Latest layer version: ${latestLayer.Version}, description: ${latestLayer.Description}`);
74
- return latestLayer;
75
- }
67
+ async function findExistingLayerVersion(layerName, description) {
68
+ let nextMarker;
69
+ do {
70
+ const listLayerVersionsCommand = new ListLayerVersionsCommand({
71
+ LayerName: layerName,
72
+ Marker: nextMarker,
73
+ });
74
+ const response = await getLambdaClient().send(listLayerVersionsCommand);
75
+ if (response.LayerVersions && response.LayerVersions.length > 0) {
76
+ const matchingLayer = response.LayerVersions.find((layer) => layer.Description === description);
77
+ if (matchingLayer) {
78
+ Logger.verbose(`Matching layer version: ${matchingLayer.Version}, description: ${matchingLayer.Description}`);
79
+ return matchingLayer;
80
+ }
81
+ }
82
+ nextMarker = response.NextMarker;
83
+ } while (nextMarker);
76
84
  Logger.verbose("No existing layer found.");
77
85
  return undefined;
78
86
  }
@@ -82,24 +90,8 @@ async function findExistingLayer(layerName) {
82
90
  */
83
91
  async function deployLayer() {
84
92
  const layerDescription = `Lambda Live Debugger Layer version ${await getVersion()}`;
85
- let layerZipPathFullPath = path.resolve(path.join(getModuleDirname(), "./extension/extension.zip"));
86
- Logger.verbose(`Layer ZIP path: ${layerZipPathFullPath}`);
87
- // check if file exists
88
- try {
89
- await fs.access(layerZipPathFullPath);
90
- }
91
- catch {
92
- // if I am debugging
93
- let layerZipPathFullPath2 = path.join(getModuleDirname(), "../dist/extension/extension.zip");
94
- try {
95
- await fs.access(layerZipPathFullPath2);
96
- layerZipPathFullPath = layerZipPathFullPath2;
97
- }
98
- catch {
99
- throw new Error(`File for the layer not found: ${layerZipPathFullPath}`);
100
- }
101
- }
102
- const existingLayer = await findExistingLayer(layerName);
93
+ // Check if the layer already exists
94
+ const existingLayer = await findExistingLayerVersion(layerName, layerDescription);
103
95
  if (existingLayer &&
104
96
  existingLayer.LayerVersionArn &&
105
97
  existingLayer.Description === layerDescription // check if the layer version is already deployed
@@ -114,13 +106,31 @@ async function deployLayer() {
114
106
  await getLambdaClient().send(deleteLayerVersionCommand);
115
107
  }
116
108
  else {
117
- Logger.log(`${layerDescription} already deployed.`);
109
+ Logger.verbose(`${layerDescription} already deployed.`);
118
110
  return existingLayer.LayerVersionArn;
119
111
  }
120
112
  }
113
+ // check the ZIP
114
+ let layerZipPathFullPath = path.resolve(path.join(getModuleDirname(), "./extension/extension.zip"));
115
+ // get the full path to the ZIP file
116
+ try {
117
+ await fs.access(layerZipPathFullPath);
118
+ }
119
+ catch {
120
+ // if I am debugging
121
+ const layerZipPathFullPath2 = path.join(getModuleDirname(), "../dist/extension/extension.zip");
122
+ try {
123
+ await fs.access(layerZipPathFullPath2);
124
+ layerZipPathFullPath = layerZipPathFullPath2;
125
+ }
126
+ catch {
127
+ throw new Error(`File for the layer not found: ${layerZipPathFullPath}`);
128
+ }
129
+ }
130
+ Logger.verbose(`Layer ZIP path: ${layerZipPathFullPath}`);
121
131
  // Read the ZIP file containing your layer code
122
132
  const layerContent = await fs.readFile(layerZipPathFullPath);
123
- Logger.log(`Deploying ${layerDescription}`);
133
+ Logger.verbose(`Deploying ${layerDescription}`);
124
134
  // Create the command for publishing a new layer version
125
135
  const publishLayerVersionCommand = new PublishLayerVersionCommand({
126
136
  LayerName: layerName,
@@ -209,7 +219,7 @@ async function removeLayerFromLambda(functionName) {
209
219
  }
210
220
  const ddlEnvironmentVariables = getEnvironmentVarablesForDebugger("xxx", 0);
211
221
  // check if environment variables are set for each property
212
- for (const [key, value] of Object.entries(ddlEnvironmentVariables)) {
222
+ for (const [key] of Object.entries(ddlEnvironmentVariables)) {
213
223
  if (environmentVariables && environmentVariables[key]) {
214
224
  needToUpdate = true;
215
225
  break;
@@ -235,7 +245,7 @@ async function removeLayerFromLambda(functionName) {
235
245
  },
236
246
  Timeout: initialTimeout,
237
247
  });
238
- getLambdaClient().send(updateFunctionConfigurationCommand);
248
+ await getLambdaClient().send(updateFunctionConfigurationCommand);
239
249
  Logger.verbose(`Function configuration cleared ${functionName}`);
240
250
  }
241
251
  else {
@@ -264,7 +274,7 @@ async function getLambdaCongfiguration(functionName) {
264
274
  const otherLayerArns = layerArns.filter((arn) => !arn?.includes(`:layer:${layerName}:`));
265
275
  const environmentVariables = getFunctionResponse.Configuration?.Environment?.Variables ?? {};
266
276
  let initialTimeout;
267
- let initialTimeoutStr = environmentVariables?.LLD_INITIAL_TIMEOUT;
277
+ const initialTimeoutStr = environmentVariables?.LLD_INITIAL_TIMEOUT;
268
278
  if (!initialTimeoutStr || isNaN(Number(initialTimeoutStr))) {
269
279
  initialTimeout = timeout;
270
280
  }
@@ -302,7 +312,7 @@ async function attachLayerToLambda(functionName, functionId, layerArn) {
302
312
  // check if layers with the wrong version are attached
303
313
  if (!needToUpdate && ddlLayerArns.find((arn) => arn !== layerArn)) {
304
314
  needToUpdate = true;
305
- Logger.log("Layer with the wrong version attached to the function");
315
+ Logger.verbose("Layer with the wrong version attached to the function");
306
316
  }
307
317
  const ddlEnvironmentVariables = getEnvironmentVarablesForDebugger(functionId, initialTimeout);
308
318
  // check if environment variables are already set for each property
@@ -326,15 +336,15 @@ async function attachLayerToLambda(functionName, functionId, layerArn) {
326
336
  //Timeout: LlDebugger.argOptions.observable ? undefined : 300, // Increase the timeout to 5 minutes
327
337
  Timeout: 300,
328
338
  });
329
- getLambdaClient().send(updateFunctionConfigurationCommand);
330
- Logger.log(`[Function ${functionName}] Lambda layer and environment variables updated`);
339
+ await getLambdaClient().send(updateFunctionConfigurationCommand);
340
+ Logger.verbose(`[Function ${functionName}] Lambda layer and environment variables updated`);
331
341
  }
332
342
  catch (error) {
333
343
  throw new Error(`Failed to update Lambda ${functionName}: ${error.message}`, { cause: error });
334
344
  }
335
345
  }
336
346
  else {
337
- Logger.log(`[Function ${functionName}] Lambda layer and environment already up to date`);
347
+ Logger.verbose(`[Function ${functionName}] Lambda layer and environment already up to date`);
338
348
  }
339
349
  }
340
350
  /**
@@ -366,7 +376,7 @@ async function addPolicyToLambdaRole(functionName) {
366
376
  }
367
377
  if (addPolicy) {
368
378
  // add inline policy to the role using PutRolePolicyCommand
369
- Logger.log(`[Function ${functionName}] Attaching policy to the role ${roleName}`);
379
+ Logger.verbose(`[Function ${functionName}] Attaching policy to the role ${roleName}`);
370
380
  await getIAMClient().send(new PutRolePolicyCommand({
371
381
  RoleName: roleName,
372
382
  PolicyName: inlinePolicyName,
@@ -415,7 +425,7 @@ async function removePolicyFromLambdaRole(functionName) {
415
425
  const existingPolicy = await getPolicyDocument(roleName);
416
426
  if (existingPolicy) {
417
427
  try {
418
- Logger.log(`[Function ${functionName}] Removing policy from the role ${roleName}`);
428
+ Logger.verbose(`[Function ${functionName}] Removing policy from the role ${roleName}`);
419
429
  await getIAMClient().send(new DeleteRolePolicyCommand({
420
430
  RoleName: roleName,
421
431
  PolicyName: inlinePolicyName,
@@ -426,7 +436,7 @@ async function removePolicyFromLambdaRole(functionName) {
426
436
  }
427
437
  }
428
438
  else {
429
- Logger.log(`[Function ${functionName}] No need to remove policy from the role ${roleName}, policy not found`);
439
+ Logger.verbose(`[Function ${functionName}] No need to remove policy from the role ${roleName}, policy not found`);
430
440
  }
431
441
  }
432
442
  catch (error) {
@@ -21,7 +21,8 @@ import { LambdaConnection } from "./lambdaConnection.mjs";
21
21
  */
22
22
  async function run() {
23
23
  const version = await getVersion();
24
- Logger.log(`Welcome to Lambda Live Debugger version ${version}`);
24
+ Logger.log(`Welcome to Lambda Live Debugger version ${version}.`);
25
+ Logger.log("To keep the project moving forward, please fill out the feedback form at https://forms.gle/v6ekZtuB45Rv3EyW9. Your input is greatly appreciated!");
25
26
  await Configuration.readConfig();
26
27
  Logger.setVerbose(Configuration.config.verbose === true);
27
28
  Logger.verbose(`Parameters: \n${Object.entries(Configuration.config)
@@ -33,7 +34,7 @@ async function run() {
33
34
  await GitIgnore.addToGitIgnore();
34
35
  }
35
36
  if (Configuration.config.vscode) {
36
- await VsCode.addConfiguration(Configuration.config);
37
+ await VsCode.addConfiguration();
37
38
  }
38
39
  if (!Configuration.config.start && !Configuration.config.remove) {
39
40
  return;
@@ -39,7 +39,7 @@ async function getBuild(functionId) {
39
39
  const newBuildAssets = build({
40
40
  functionId,
41
41
  function: func,
42
- oldCtx: !!buildCache[functionId]
42
+ oldCtx: buildCache[functionId]
43
43
  ? await buildCache[functionId].ctx
44
44
  : undefined,
45
45
  });
@@ -54,7 +54,7 @@ async function getBuild(functionId) {
54
54
  if (newBuild) {
55
55
  Logger.verbose(`[Function ${functionId}] Build complete`);
56
56
  }
57
- const artifactFile = Object.keys(result.metafile?.outputs).find((key) => key.endsWith(".js"));
57
+ const artifactFile = Object.keys(result.metafile.outputs).find((key) => key.endsWith(".js"));
58
58
  if (!artifactFile) {
59
59
  throw new Error(`Artifact file not found for function ${functionId}`);
60
60
  }
@@ -84,7 +84,7 @@ async function build(input) {
84
84
  const packageJson = JSON.parse(await fs.readFile(packageJsonPath, { encoding: "utf-8" }));
85
85
  isESMFromPackageJson = packageJson.type === "module";
86
86
  }
87
- let isESMFromBundling = esbuildOptions?.format === "esm" ? true : undefined;
87
+ const isESMFromBundling = esbuildOptions?.format === "esm" ? true : undefined;
88
88
  let isESM;
89
89
  if (isESMFromPackageJson !== undefined &&
90
90
  isESMFromBundling !== undefined &&
@@ -10,9 +10,9 @@ import { NodeWorker } from "./nodeWorker.mjs";
10
10
  async function buildLambda(functionId) {
11
11
  const artifactFile = await NodeEsBuild.getBuild(functionId);
12
12
  try {
13
- fs.access(artifactFile, fs.constants.F_OK);
13
+ await fs.access(artifactFile, fs.constants.F_OK);
14
14
  }
15
- catch (err) {
15
+ catch {
16
16
  throw new Error(`${functionId} function artifact file ${artifactFile} not found.`);
17
17
  }
18
18
  return {
@@ -11,7 +11,7 @@ const workers = new Map();
11
11
  */
12
12
  async function runInWorker(input) {
13
13
  const func = await Configuration.getLambda(input.fuctionRequest.functionId);
14
- return new Promise(async (resolve, reject) => {
14
+ return new Promise((resolve, reject) => {
15
15
  let worker = workers.get(input.fuctionRequest.workerId);
16
16
  if (!worker) {
17
17
  worker = startWorker({
@@ -53,7 +53,7 @@ async function runInWorker(input) {
53
53
  */
54
54
  function startWorker(input) {
55
55
  Logger.verbose(`[Function ${input.functionId}] [Worker ${input.workerId}] Starting worker. Artifact: ${input.artifactFile}`);
56
- let localProjectDir = getProjectDirname();
56
+ const localProjectDir = getProjectDirname();
57
57
  const worker = new Worker(path.resolve(path.join(getModuleDirname(), `./nodeWorkerRunner.mjs`)), {
58
58
  env: {
59
59
  ...input.environment,
@@ -1,4 +1,5 @@
1
1
  import { createRequire as topLevelCreateRequire } from "module";
2
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
3
  const require = topLevelCreateRequire(import.meta.url);
3
4
 
4
5
  import { workerData, parentPort } from "node:worker_threads";
@@ -6,7 +7,7 @@ import { Logger } from "./logger.mjs";
6
7
 
7
8
  Logger.setVerbose(workerData.verbose);
8
9
  Logger.verbose(
9
- `[Function ${workerData.functionId}] [Worker ${workerData.workerId}] Worker started.`
10
+ `[Function ${workerData.functionId}] [Worker ${workerData.workerId}] Worker started.`,
10
11
  );
11
12
 
12
13
  parentPort.on("message", async (data) => {
@@ -20,17 +21,17 @@ parentPort.on("message", async (data) => {
20
21
  getRemainingTimeInMillis: () => 2147483647, // Max 32-bit signed integer
21
22
  done() {
22
23
  throw new Error(
23
- "`done` function on lambda Context is not implemented in Lambda Live Debugger."
24
+ "`done` function on lambda Context is not implemented in Lambda Live Debugger.",
24
25
  );
25
26
  },
26
27
  fail() {
27
28
  throw new Error(
28
- "`fail` function on lambda Context is not implemented in Lambda Live Debugger."
29
+ "`fail` function on lambda Context is not implemented in Lambda Live Debugger.",
29
30
  );
30
31
  },
31
32
  succeed() {
32
33
  throw new Error(
33
- "`succeed` function on lambda Context is not implemented in Lambda Live Debugger."
34
+ "`succeed` function on lambda Context is not implemented in Lambda Live Debugger.",
34
35
  );
35
36
  },
36
37
  };
@@ -38,7 +39,7 @@ parentPort.on("message", async (data) => {
38
39
  const res = await fn(data.event, context);
39
40
  Logger.verbose(
40
41
  `[Function ${workerData.functionId}] [Worker ${workerData.workerId}] Sending response`,
41
- res
42
+ res,
42
43
  );
43
44
  parentPort.postMessage(res);
44
45
  } catch (error) {
@@ -49,7 +50,7 @@ parentPort.on("message", async (data) => {
49
50
  process.on("unhandledRejection", (error) => {
50
51
  Logger.error(
51
52
  `[Function ${workerData.functionId}] [Worker ${workerData.workerId}] Unhandled Rejection`,
52
- error
53
+ error,
53
54
  );
54
55
  handleError(error);
55
56
  });
@@ -37,7 +37,7 @@ async function getLambdas(config) {
37
37
  frameworks = frameworks.filter((f) => f.name === config.framework);
38
38
  }
39
39
  }
40
- let framework = await getCurrentFramework(frameworks);
40
+ const framework = await getCurrentFramework(frameworks);
41
41
  if (framework) {
42
42
  Logger.verbose(`Getting resources with '${framework.name}' framework`);
43
43
  resources = await framework.getLambdas(config);
package/dist/vsCode.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { LldConfig } from "./types/lldConfig.js";
2
1
  declare function isConfigured(): Promise<boolean>;
3
- declare function addConfiguration(lldConfig: LldConfig): Promise<void>;
2
+ declare function addConfiguration(): Promise<void>;
4
3
  export declare const VsCode: {
5
4
  isConfigured: typeof isConfigured;
6
5
  addConfiguration: typeof addConfiguration;