lambda-live-debugger 0.0.106 → 0.0.107
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/.husky/pre-commit +1 -0
- package/.prettierignore +6 -0
- package/.prettierrc +1 -0
- package/LICENSE.md +24 -27
- package/README.md +20 -12
- package/dist/cloudFormation.mjs +2 -2
- package/dist/configuration/getConfigFromCliArgs.mjs +1 -4
- package/dist/configuration/getConfigFromTsConfigFile.mjs +1 -1
- package/dist/configuration/getConfigFromWizard.mjs +0 -1
- package/dist/extension/extension.zip +0 -0
- package/dist/extension/nodejs/node_modules/interceptor.js +52 -47
- package/dist/extension/nodejs/node_modules/interceptor.js.map +2 -2
- package/dist/fileWatcher.mjs +1 -1
- package/dist/frameworks/cdkFramework.mjs +3 -3
- package/dist/frameworks/cdkFrameworkWorker.mjs +3 -2
- package/dist/frameworks/samFramework.mjs +11 -11
- package/dist/frameworks/slsFramework.mjs +40 -40
- package/dist/frameworks/terraformFramework.d.ts +1 -2
- package/dist/frameworks/terraformFramework.mjs +7 -6
- package/dist/gitignore.mjs +2 -2
- package/dist/infraDeploy.mjs +13 -13
- package/dist/lldebugger.mjs +3 -2
- package/dist/nodeEsBuild.mjs +3 -3
- package/dist/nodeHandler.mjs +2 -2
- package/dist/nodeWorker.mjs +2 -2
- package/dist/nodeWorkerRunner.mjs +7 -6
- package/dist/resourceDiscovery.mjs +1 -1
- package/dist/vsCode.d.ts +1 -2
- package/dist/vsCode.mjs +6 -6
- package/eslint.config.js +43 -0
- package/fix-imports.js +4 -2
- package/package.json +13 -2
- package/tsconfig.build.json +1 -1
package/dist/fileWatcher.mjs
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
145
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
|
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
|
|
192
|
+
catch {
|
|
192
193
|
// tsconfig.json not found, move up one directory
|
|
193
194
|
currentDir = path.dirname(currentDir);
|
|
194
195
|
}
|
package/dist/gitignore.mjs
CHANGED
|
@@ -15,7 +15,7 @@ async function doesExistInGitIgnore() {
|
|
|
15
15
|
const exists = lines.includes(outputFolder);
|
|
16
16
|
return exists;
|
|
17
17
|
}
|
|
18
|
-
catch
|
|
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
|
|
41
|
+
catch {
|
|
42
42
|
await fs.writeFile(getGitIgnoreFileLocation(), `${outputFolder}\n`);
|
|
43
43
|
return;
|
|
44
44
|
}
|
package/dist/infraDeploy.mjs
CHANGED
|
@@ -90,7 +90,7 @@ async function deployLayer() {
|
|
|
90
90
|
}
|
|
91
91
|
catch {
|
|
92
92
|
// if I am debugging
|
|
93
|
-
|
|
93
|
+
const layerZipPathFullPath2 = path.join(getModuleDirname(), "../dist/extension/extension.zip");
|
|
94
94
|
try {
|
|
95
95
|
await fs.access(layerZipPathFullPath2);
|
|
96
96
|
layerZipPathFullPath = layerZipPathFullPath2;
|
|
@@ -114,13 +114,13 @@ async function deployLayer() {
|
|
|
114
114
|
await getLambdaClient().send(deleteLayerVersionCommand);
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
|
-
Logger.
|
|
117
|
+
Logger.verbose(`${layerDescription} already deployed.`);
|
|
118
118
|
return existingLayer.LayerVersionArn;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
// Read the ZIP file containing your layer code
|
|
122
122
|
const layerContent = await fs.readFile(layerZipPathFullPath);
|
|
123
|
-
Logger.
|
|
123
|
+
Logger.verbose(`Deploying ${layerDescription}`);
|
|
124
124
|
// Create the command for publishing a new layer version
|
|
125
125
|
const publishLayerVersionCommand = new PublishLayerVersionCommand({
|
|
126
126
|
LayerName: layerName,
|
|
@@ -209,7 +209,7 @@ async function removeLayerFromLambda(functionName) {
|
|
|
209
209
|
}
|
|
210
210
|
const ddlEnvironmentVariables = getEnvironmentVarablesForDebugger("xxx", 0);
|
|
211
211
|
// check if environment variables are set for each property
|
|
212
|
-
for (const [key
|
|
212
|
+
for (const [key] of Object.entries(ddlEnvironmentVariables)) {
|
|
213
213
|
if (environmentVariables && environmentVariables[key]) {
|
|
214
214
|
needToUpdate = true;
|
|
215
215
|
break;
|
|
@@ -235,7 +235,7 @@ async function removeLayerFromLambda(functionName) {
|
|
|
235
235
|
},
|
|
236
236
|
Timeout: initialTimeout,
|
|
237
237
|
});
|
|
238
|
-
getLambdaClient().send(updateFunctionConfigurationCommand);
|
|
238
|
+
await getLambdaClient().send(updateFunctionConfigurationCommand);
|
|
239
239
|
Logger.verbose(`Function configuration cleared ${functionName}`);
|
|
240
240
|
}
|
|
241
241
|
else {
|
|
@@ -264,7 +264,7 @@ async function getLambdaCongfiguration(functionName) {
|
|
|
264
264
|
const otherLayerArns = layerArns.filter((arn) => !arn?.includes(`:layer:${layerName}:`));
|
|
265
265
|
const environmentVariables = getFunctionResponse.Configuration?.Environment?.Variables ?? {};
|
|
266
266
|
let initialTimeout;
|
|
267
|
-
|
|
267
|
+
const initialTimeoutStr = environmentVariables?.LLD_INITIAL_TIMEOUT;
|
|
268
268
|
if (!initialTimeoutStr || isNaN(Number(initialTimeoutStr))) {
|
|
269
269
|
initialTimeout = timeout;
|
|
270
270
|
}
|
|
@@ -302,7 +302,7 @@ async function attachLayerToLambda(functionName, functionId, layerArn) {
|
|
|
302
302
|
// check if layers with the wrong version are attached
|
|
303
303
|
if (!needToUpdate && ddlLayerArns.find((arn) => arn !== layerArn)) {
|
|
304
304
|
needToUpdate = true;
|
|
305
|
-
Logger.
|
|
305
|
+
Logger.verbose("Layer with the wrong version attached to the function");
|
|
306
306
|
}
|
|
307
307
|
const ddlEnvironmentVariables = getEnvironmentVarablesForDebugger(functionId, initialTimeout);
|
|
308
308
|
// check if environment variables are already set for each property
|
|
@@ -326,15 +326,15 @@ async function attachLayerToLambda(functionName, functionId, layerArn) {
|
|
|
326
326
|
//Timeout: LlDebugger.argOptions.observable ? undefined : 300, // Increase the timeout to 5 minutes
|
|
327
327
|
Timeout: 300,
|
|
328
328
|
});
|
|
329
|
-
getLambdaClient().send(updateFunctionConfigurationCommand);
|
|
330
|
-
Logger.
|
|
329
|
+
await getLambdaClient().send(updateFunctionConfigurationCommand);
|
|
330
|
+
Logger.verbose(`[Function ${functionName}] Lambda layer and environment variables updated`);
|
|
331
331
|
}
|
|
332
332
|
catch (error) {
|
|
333
333
|
throw new Error(`Failed to update Lambda ${functionName}: ${error.message}`, { cause: error });
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
else {
|
|
337
|
-
Logger.
|
|
337
|
+
Logger.verbose(`[Function ${functionName}] Lambda layer and environment already up to date`);
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
/**
|
|
@@ -366,7 +366,7 @@ async function addPolicyToLambdaRole(functionName) {
|
|
|
366
366
|
}
|
|
367
367
|
if (addPolicy) {
|
|
368
368
|
// add inline policy to the role using PutRolePolicyCommand
|
|
369
|
-
Logger.
|
|
369
|
+
Logger.verbose(`[Function ${functionName}] Attaching policy to the role ${roleName}`);
|
|
370
370
|
await getIAMClient().send(new PutRolePolicyCommand({
|
|
371
371
|
RoleName: roleName,
|
|
372
372
|
PolicyName: inlinePolicyName,
|
|
@@ -415,7 +415,7 @@ async function removePolicyFromLambdaRole(functionName) {
|
|
|
415
415
|
const existingPolicy = await getPolicyDocument(roleName);
|
|
416
416
|
if (existingPolicy) {
|
|
417
417
|
try {
|
|
418
|
-
Logger.
|
|
418
|
+
Logger.verbose(`[Function ${functionName}] Removing policy from the role ${roleName}`);
|
|
419
419
|
await getIAMClient().send(new DeleteRolePolicyCommand({
|
|
420
420
|
RoleName: roleName,
|
|
421
421
|
PolicyName: inlinePolicyName,
|
|
@@ -426,7 +426,7 @@ async function removePolicyFromLambdaRole(functionName) {
|
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
else {
|
|
429
|
-
Logger.
|
|
429
|
+
Logger.verbose(`[Function ${functionName}] No need to remove policy from the role ${roleName}, policy not found`);
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
catch (error) {
|
package/dist/lldebugger.mjs
CHANGED
|
@@ -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(
|
|
37
|
+
await VsCode.addConfiguration();
|
|
37
38
|
}
|
|
38
39
|
if (!Configuration.config.start && !Configuration.config.remove) {
|
|
39
40
|
return;
|
package/dist/nodeEsBuild.mjs
CHANGED
|
@@ -39,7 +39,7 @@ async function getBuild(functionId) {
|
|
|
39
39
|
const newBuildAssets = build({
|
|
40
40
|
functionId,
|
|
41
41
|
function: func,
|
|
42
|
-
oldCtx:
|
|
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
|
|
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
|
-
|
|
87
|
+
const isESMFromBundling = esbuildOptions?.format === "esm" ? true : undefined;
|
|
88
88
|
let isESM;
|
|
89
89
|
if (isESMFromPackageJson !== undefined &&
|
|
90
90
|
isESMFromBundling !== undefined &&
|
package/dist/nodeHandler.mjs
CHANGED
|
@@ -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
|
|
15
|
+
catch {
|
|
16
16
|
throw new Error(`${functionId} function artifact file ${artifactFile} not found.`);
|
|
17
17
|
}
|
|
18
18
|
return {
|
package/dist/nodeWorker.mjs
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
2
|
+
declare function addConfiguration(): Promise<void>;
|
|
4
3
|
export declare const VsCode: {
|
|
5
4
|
isConfigured: typeof isConfigured;
|
|
6
5
|
addConfiguration: typeof addConfiguration;
|
package/dist/vsCode.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import path from "path";
|
|
|
3
3
|
import { parse, printParseErrorCode, applyEdits, modify, } from "jsonc-parser";
|
|
4
4
|
import { getModuleDirname, getProjectDirname } from "./getDirname.mjs";
|
|
5
5
|
import { Logger } from "./logger.mjs";
|
|
6
|
-
async function getVsCodeLaunchConfig(
|
|
6
|
+
async function getVsCodeLaunchConfig() {
|
|
7
7
|
const localRuntimeExecutable = "${workspaceFolder}/node_modules/.bin/lld";
|
|
8
8
|
const config = {
|
|
9
9
|
version: "0.2.0",
|
|
@@ -37,7 +37,7 @@ async function getVsCodeLaunchConfig(lldConfig) {
|
|
|
37
37
|
runtimeExecutableSet = true;
|
|
38
38
|
//Logger.log("Found local folder", localFolder);
|
|
39
39
|
}
|
|
40
|
-
catch
|
|
40
|
+
catch {
|
|
41
41
|
//Logger.log("Not found", localFolder);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -68,7 +68,7 @@ async function getVsCodeLaunchConfig(lldConfig) {
|
|
|
68
68
|
Logger.verbose(`Found folder with lld executable: ${folder}`);
|
|
69
69
|
break;
|
|
70
70
|
}
|
|
71
|
-
catch
|
|
71
|
+
catch {
|
|
72
72
|
// Not found
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -127,7 +127,7 @@ async function getCurrentState() {
|
|
|
127
127
|
try {
|
|
128
128
|
await fs.access(filePath, fs.constants.F_OK);
|
|
129
129
|
}
|
|
130
|
-
catch
|
|
130
|
+
catch {
|
|
131
131
|
createNewFile = true;
|
|
132
132
|
}
|
|
133
133
|
if (!createNewFile) {
|
|
@@ -169,10 +169,10 @@ async function isConfigured() {
|
|
|
169
169
|
}
|
|
170
170
|
return false;
|
|
171
171
|
}
|
|
172
|
-
async function addConfiguration(
|
|
172
|
+
async function addConfiguration() {
|
|
173
173
|
Logger.log("Adding configuration to .vscode/launch.json");
|
|
174
174
|
const state = await getCurrentState();
|
|
175
|
-
const config = await getVsCodeLaunchConfig(
|
|
175
|
+
const config = await getVsCodeLaunchConfig();
|
|
176
176
|
if (state.state === "FILE_EXISTS_CONFIGURATION_DOES_NOT_EXIST") {
|
|
177
177
|
const { jsonString, filePath, configurationsLength } = state;
|
|
178
178
|
await writeConfiguration(filePath, jsonString, config.configurations[0], configurationsLength);
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import pluginJs from "@eslint/js";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import pluginPrettier from "eslint-plugin-prettier";
|
|
5
|
+
import prettierConfig from "eslint-config-prettier";
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{ files: ["**/*.{js,mjs,cjs,ts}"] },
|
|
9
|
+
{
|
|
10
|
+
ignores: [
|
|
11
|
+
"**/dist/**",
|
|
12
|
+
"**/cdk.out/**",
|
|
13
|
+
"**/.lldebugger/**",
|
|
14
|
+
"**/.serverless/**",
|
|
15
|
+
"**/.aws-sam/**",
|
|
16
|
+
"src/extension/aws/*.js",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
languageOptions: {
|
|
21
|
+
globals: globals.node,
|
|
22
|
+
parser: "@typescript-eslint/parser",
|
|
23
|
+
parserOptions: {
|
|
24
|
+
project: "./tsconfig.json",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
pluginJs.configs.recommended,
|
|
29
|
+
...tseslint.configs.recommended,
|
|
30
|
+
{
|
|
31
|
+
plugins: {
|
|
32
|
+
prettier: pluginPrettier,
|
|
33
|
+
},
|
|
34
|
+
rules: {
|
|
35
|
+
...pluginPrettier.configs.recommended.rules,
|
|
36
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
37
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
38
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
39
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
prettierConfig,
|
|
43
|
+
];
|