lambda-live-debugger 1.2.6 → 1.4.0
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/.vitepress/config.mts +6 -0
- package/.vitepress/markdown-it-youtube-embed.ts +45 -0
- package/.vitepress/theme/custom.css +17 -0
- package/README.md +4 -1
- package/dist/extension/extension.zip +0 -0
- package/dist/extension/nodejs/node_modules/interceptor.js +21 -11
- package/dist/extension/nodejs/node_modules/interceptor.js.map +2 -2
- package/dist/frameworks/slsFramework.mjs +77 -43
- package/package.json +12 -1
- package/prepareForTest.js +33 -0
|
@@ -51,51 +51,35 @@ export class SlsFramework {
|
|
|
51
51
|
let resolveVariablesMeta;
|
|
52
52
|
let sources;
|
|
53
53
|
let Serverless;
|
|
54
|
+
let error1;
|
|
54
55
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const self = await import(
|
|
78
|
-
//@ts-ignore
|
|
79
|
-
'serverless/lib/configuration/variables/sources/self.js');
|
|
80
|
-
const strToBool = await import(
|
|
81
|
-
//@ts-ignore
|
|
82
|
-
'serverless/lib/configuration/variables/sources/str-to-bool.js');
|
|
83
|
-
const sls = await import(
|
|
84
|
-
//@ts-ignores
|
|
85
|
-
'serverless/lib/configuration/variables/sources/instance-dependent/get-sls.js');
|
|
86
|
-
sources = {
|
|
87
|
-
env: env.default,
|
|
88
|
-
file: file.default,
|
|
89
|
-
opt: opt.default,
|
|
90
|
-
self: self.default,
|
|
91
|
-
strToBool: strToBool.default,
|
|
92
|
-
sls: sls.default(),
|
|
93
|
-
};
|
|
94
|
-
Serverless = (await import('serverless')).default;
|
|
56
|
+
try {
|
|
57
|
+
const frameworkFunctions = await loadFramework('serverless');
|
|
58
|
+
resolveConfigurationPath = frameworkFunctions.resolveConfigurationPath;
|
|
59
|
+
readConfiguration = frameworkFunctions.readConfiguration;
|
|
60
|
+
resolveVariables = frameworkFunctions.resolveVariables;
|
|
61
|
+
resolveVariablesMeta = frameworkFunctions.resolveVariablesMeta;
|
|
62
|
+
sources = frameworkFunctions.sources;
|
|
63
|
+
Serverless = frameworkFunctions.Serverless;
|
|
64
|
+
Logger.verbose(`[SLS] Npm module 'serverless' loaded`);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
Logger.verbose(`[SLS] Failed to load npm module 'serverless'`, error);
|
|
68
|
+
error1 = error;
|
|
69
|
+
const frameworkFunctions = await loadFramework('osls');
|
|
70
|
+
resolveConfigurationPath = frameworkFunctions.resolveConfigurationPath;
|
|
71
|
+
readConfiguration = frameworkFunctions.readConfiguration;
|
|
72
|
+
resolveVariables = frameworkFunctions.resolveVariables;
|
|
73
|
+
resolveVariablesMeta = frameworkFunctions.resolveVariablesMeta;
|
|
74
|
+
sources = frameworkFunctions.sources;
|
|
75
|
+
Serverless = frameworkFunctions.Serverless;
|
|
76
|
+
Logger.verbose(`[SLS] Npm module 'osls' loaded`);
|
|
77
|
+
}
|
|
95
78
|
}
|
|
96
|
-
catch (
|
|
97
|
-
|
|
98
|
-
Logger.
|
|
79
|
+
catch (error2) {
|
|
80
|
+
const error = error1 ?? error2;
|
|
81
|
+
Logger.error('Error loading serverless (or osls) module', error);
|
|
82
|
+
Logger.log('If you are running Lambda Live Debugger from a global installation, install Serverless Framework globally as well. If you are using monorepo, install Serverless Framework also in the project root folder. The fork of Serverless Framework https://github.com/oss-serverless/serverless is also supported.');
|
|
99
83
|
throw new Error(`Error loading serverless modules. ${error.message}`, {
|
|
100
84
|
cause: error,
|
|
101
85
|
});
|
|
@@ -242,3 +226,53 @@ export class SlsFramework {
|
|
|
242
226
|
}
|
|
243
227
|
}
|
|
244
228
|
export const slsFramework = new SlsFramework();
|
|
229
|
+
async function loadFramework(npmName) {
|
|
230
|
+
// lazy load modules
|
|
231
|
+
const resolveConfigurationPath = (await import(
|
|
232
|
+
//@ts-ignore
|
|
233
|
+
`${npmName}/lib/cli/resolve-configuration-path.js`)).default;
|
|
234
|
+
const readConfiguration = (await import(
|
|
235
|
+
//@ts-ignore
|
|
236
|
+
`${npmName}/lib/configuration/read.js`)).default;
|
|
237
|
+
const resolveVariables = (await import(
|
|
238
|
+
//@ts-ignore
|
|
239
|
+
`${npmName}/lib/configuration/variables/resolve.js`)).default;
|
|
240
|
+
const resolveVariablesMeta = (await import(
|
|
241
|
+
//@ts-ignore
|
|
242
|
+
`${npmName}/lib/configuration/variables/resolve-meta.js`)).default;
|
|
243
|
+
const env = await import(
|
|
244
|
+
//@ts-ignore
|
|
245
|
+
`${npmName}/lib/configuration/variables/sources/env.js`);
|
|
246
|
+
const file = await import(
|
|
247
|
+
//@ts-ignore
|
|
248
|
+
`${npmName}/lib/configuration/variables/sources/file.js`);
|
|
249
|
+
const opt = await import(
|
|
250
|
+
//@ts-ignore
|
|
251
|
+
`${npmName}/lib/configuration/variables/sources/opt.js`);
|
|
252
|
+
const self = await import(
|
|
253
|
+
//@ts-ignore
|
|
254
|
+
`${npmName}/lib/configuration/variables/sources/self.js`);
|
|
255
|
+
const strToBool = await import(
|
|
256
|
+
//@ts-ignore
|
|
257
|
+
`${npmName}/lib/configuration/variables/sources/str-to-bool.js`);
|
|
258
|
+
const sls = await import(
|
|
259
|
+
//@ts-ignores
|
|
260
|
+
`${npmName}/lib/configuration/variables/sources/instance-dependent/get-sls.js`);
|
|
261
|
+
const sources = {
|
|
262
|
+
env: env.default,
|
|
263
|
+
file: file.default,
|
|
264
|
+
opt: opt.default,
|
|
265
|
+
self: self.default,
|
|
266
|
+
strToBool: strToBool.default,
|
|
267
|
+
sls: sls.default(),
|
|
268
|
+
};
|
|
269
|
+
const Serverless = (await import(npmName)).default;
|
|
270
|
+
return {
|
|
271
|
+
resolveConfigurationPath,
|
|
272
|
+
readConfiguration,
|
|
273
|
+
resolveVariablesMeta,
|
|
274
|
+
resolveVariables,
|
|
275
|
+
sources,
|
|
276
|
+
Serverless,
|
|
277
|
+
};
|
|
278
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lambda-live-debugger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Debug Lambda functions locally like it is running in the cloud",
|
|
6
6
|
"repository": {
|
|
@@ -60,6 +60,12 @@
|
|
|
60
60
|
"test-sls-esbuild-cjs-observable": "npm run build && RUN_TEST_FROM_CLI=true OBSERVABLE_MODE=true vitest run test/sls-esbuild-cjs.test.ts",
|
|
61
61
|
"test-sls-esbuild-esm": "npm run build && RUN_TEST_FROM_CLI=true vitest run test/sls-esbuild-esm.test.ts",
|
|
62
62
|
"test-sls-esbuild-esm-observable": "npm run build && RUN_TEST_FROM_CLI=true OBSERVABLE_MODE=true vitest run test/sls-esbuild-esm.test.ts",
|
|
63
|
+
"test-osls-basic": "npm run build && RUN_TEST_FROM_CLI=true vitest run test/osls-basic.test.ts",
|
|
64
|
+
"test-osls-basic-observable": "npm run build && RUN_TEST_FROM_CLI=true OBSERVABLE_MODE=true vitest run test/osls-basic.test.ts",
|
|
65
|
+
"test-osls-esbuild-cjs": "npm run build && RUN_TEST_FROM_CLI=true vitest run test/osls-esbuild-cjs.test.ts",
|
|
66
|
+
"test-osls-esbuild-cjs-observable": "npm run build && RUN_TEST_FROM_CLI=true OBSERVABLE_MODE=true vitest run test/osls-esbuild-cjs.test.ts",
|
|
67
|
+
"test-osls-esbuild-esm": "npm run build && RUN_TEST_FROM_CLI=true vitest run test/osls-esbuild-esm.test.ts",
|
|
68
|
+
"test-osls-esbuild-esm-observable": "npm run build && RUN_TEST_FROM_CLI=true OBSERVABLE_MODE=true vitest run test/osls-esbuild-esm.test.ts",
|
|
63
69
|
"test-sam-basic": "npm run build && RUN_TEST_FROM_CLI=true vitest run test/sam-basic.test.ts",
|
|
64
70
|
"test-sam-basic-observable": "npm run build && RUN_TEST_FROM_CLI=true OBSERVABLE_MODE=true vitest run test/sam-basic.test.ts",
|
|
65
71
|
"test-sam-alt": "npm run build && RUN_TEST_FROM_CLI=true vitest run test/sam-alt.test.ts",
|
|
@@ -89,6 +95,7 @@
|
|
|
89
95
|
"prettier": "^3.3.3",
|
|
90
96
|
"semantic-release": "^23.0.8",
|
|
91
97
|
"serverless": "^3.38.0",
|
|
98
|
+
"osls": "^3.41.0",
|
|
92
99
|
"serverless-esbuild": "^1.52.1",
|
|
93
100
|
"tsx": "^4.7.1",
|
|
94
101
|
"typescript-eslint": "^8.0.0",
|
|
@@ -141,6 +148,10 @@
|
|
|
141
148
|
"test/cdk-config",
|
|
142
149
|
"test/sls-basic",
|
|
143
150
|
"test/sls-esbuild",
|
|
151
|
+
"test/sls-esbuild-cjs",
|
|
152
|
+
"test/osls-basic",
|
|
153
|
+
"test/osls-esbuild",
|
|
154
|
+
"test/osls-esbuild-cjs",
|
|
144
155
|
"test/sam-basic",
|
|
145
156
|
"test/sam-alt",
|
|
146
157
|
"test/terraform-basic"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
2
|
+
import { argv } from 'process';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Prepare the package.json file for testing.
|
|
6
|
+
* Remove everything that is not needed for testing.
|
|
7
|
+
* @param {*} testCase
|
|
8
|
+
*/
|
|
9
|
+
async function modifyPackageJson(testCase) {
|
|
10
|
+
const filePath = 'package.json';
|
|
11
|
+
|
|
12
|
+
const data = await readFile(filePath, 'utf-8');
|
|
13
|
+
const packageJson = JSON.parse(data);
|
|
14
|
+
|
|
15
|
+
// Delete scripts and devDependencies nodes
|
|
16
|
+
delete packageJson.scripts;
|
|
17
|
+
delete packageJson.devDependencies;
|
|
18
|
+
|
|
19
|
+
// Replace workspaces node with the test and the test case workspaces
|
|
20
|
+
// With this all the necessary npm packages will be installed
|
|
21
|
+
packageJson.workspaces = ['test', `test/${testCase}`];
|
|
22
|
+
|
|
23
|
+
await writeFile(filePath, JSON.stringify(packageJson, null, 2), 'utf-8');
|
|
24
|
+
console.log(`Modified ${filePath} successfully!`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const [testCase] = argv.slice(2);
|
|
28
|
+
if (!testCase) {
|
|
29
|
+
console.error('Usage: node prepareForTest.js <testCase>');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void modifyPackageJson(testCase).catch(console.error);
|