From 1ee1cd0ca82006c89fbf33e4fa88117ae9529c32 Mon Sep 17 00:00:00 2001 From: Marko Date: Wed, 5 Mar 2025 22:21:23 +0100 Subject: [PATCH 1/5] feat: #24 JetBrains IDE tools support (#107) * feat: JetBrains IDE tools support * chore: Add documentation * fix: Handling global installation * fix: message --- README.md | 2 +- package-lock.json | 459 ++++++++++++++++++++++- package.json | 2 + src/configuration/getConfigFromWizard.ts | 15 + src/jetBrains.ts | 150 ++++++++ src/lldebugger.ts | 5 + src/types/lldConfig.ts | 1 + src/utils/getRuntimeExecutableForIde.ts | 93 +++++ src/vsCode.ts | 87 +---- 9 files changed, 717 insertions(+), 97 deletions(-) create mode 100644 src/jetBrains.ts create mode 100644 src/utils/getRuntimeExecutableForIde.ts diff --git a/README.md b/README.md index a5ddd4f1..a920196e 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ You might want to configure your development tool for debugging. The wizard auto Now, you have to press F5 or press Run -> Start Debugging, and you can set breakpoints, step through lines of code, inspect variables... For more information on how to [debug in VSCode, please refer to this link](https://code.visualstudio.com/docs/editor/debugging). -For other tools, please send documentation to include here. WebStorm instructions are especially needed. +The wizard also creates a configuration for JetBrains IDEs, such as WebStorm. ## Removing diff --git a/package-lock.json b/package-lock.json index 50dadc42..cc9c5f0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,6 +57,7 @@ "chokidar": "^3.6.0", "commander": "^13.1.0", "esbuild": "^0.25.0", + "fast-xml-parser": "^5.0.8", "inquirer": "^12.4.2", "jsonc-parser": "^3.3.1", "node-machine-id": "^1.1.12", @@ -1679,6 +1680,42 @@ "node": ">=18.0.0" } }, + "node_modules/@aws-sdk/client-cloudformation/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "inBundle": true, + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/client-cloudformation/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "inBundle": true, + "license": "MIT" + }, "node_modules/@aws-sdk/client-cognito-identity": { "version": "3.758.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.758.0.tgz", @@ -2773,6 +2810,42 @@ "node": ">=18.0.0" } }, + "node_modules/@aws-sdk/client-cognito-identity/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "inBundle": true, + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/client-cognito-identity/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "inBundle": true, + "license": "MIT" + }, "node_modules/@aws-sdk/client-eventbridge": { "version": "3.637.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-eventbridge/-/client-eventbridge-3.637.0.tgz", @@ -3869,6 +3942,42 @@ "node": ">=18.0.0" } }, + "node_modules/@aws-sdk/client-iam/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "inBundle": true, + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/client-iam/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "inBundle": true, + "license": "MIT" + }, "node_modules/@aws-sdk/client-iot": { "version": "3.758.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-iot/-/client-iot-3.758.0.tgz", @@ -4965,6 +5074,42 @@ "node": ">=18.0.0" } }, + "node_modules/@aws-sdk/client-iot-data-plane/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "inBundle": true, + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/client-iot-data-plane/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "inBundle": true, + "license": "MIT" + }, "node_modules/@aws-sdk/client-iot/node_modules/@aws-sdk/client-sso": { "version": "3.758.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.758.0.tgz", @@ -5956,6 +6101,42 @@ "node": ">=18.0.0" } }, + "node_modules/@aws-sdk/client-iot/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "inBundle": true, + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/client-iot/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "inBundle": true, + "license": "MIT" + }, "node_modules/@aws-sdk/client-lambda": { "version": "3.758.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-lambda/-/client-lambda-3.758.0.tgz", @@ -7003,6 +7184,42 @@ "node": ">=18.0.0" } }, + "node_modules/@aws-sdk/client-lambda/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "inBundle": true, + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/client-lambda/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "inBundle": true, + "license": "MIT" + }, "node_modules/@aws-sdk/client-s3": { "version": "3.758.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.758.0.tgz", @@ -8119,6 +8336,42 @@ "node": ">=18.0.0" } }, + "node_modules/@aws-sdk/client-s3/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "inBundle": true, + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/client-s3/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "inBundle": true, + "license": "MIT" + }, "node_modules/@aws-sdk/client-sso": { "version": "3.637.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.637.0.tgz", @@ -8293,6 +8546,42 @@ "node": ">=16.0.0" } }, + "node_modules/@aws-sdk/core/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/core/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT" + }, "node_modules/@aws-sdk/credential-provider-cognito-identity": { "version": "3.758.0", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.758.0.tgz", @@ -9506,6 +9795,42 @@ "node": ">=18.0.0" } }, + "node_modules/@aws-sdk/credential-providers/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "inBundle": true, + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/credential-providers/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "inBundle": true, + "license": "MIT" + }, "node_modules/@aws-sdk/middleware-bucket-endpoint": { "version": "3.734.0", "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-bucket-endpoint/-/middleware-bucket-endpoint-3.734.0.tgz", @@ -10154,6 +10479,42 @@ "node": ">=18.0.0" } }, + "node_modules/@aws-sdk/middleware-flexible-checksums/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "inBundle": true, + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/middleware-flexible-checksums/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "inBundle": true, + "license": "MIT" + }, "node_modules/@aws-sdk/middleware-host-header": { "version": "3.620.0", "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.620.0.tgz", @@ -11167,6 +11528,42 @@ "node": ">=18.0.0" } }, + "node_modules/@aws-sdk/nested-clients/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "inBundle": true, + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/@aws-sdk/nested-clients/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "inBundle": true, + "license": "MIT" + }, "node_modules/@aws-sdk/region-config-resolver": { "version": "3.614.0", "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.614.0.tgz", @@ -19531,22 +19928,18 @@ "dev": true }, "node_modules/fast-xml-parser": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", - "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.0.8.tgz", + "integrity": "sha512-qY8NiI5L8ff00F2giyICiJxSSKHO52tC36LJqx2JtvGyAd5ZfehC/l4iUVVHpmpIa6sM9N5mneSLHQG2INGoHA==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/NaturalIntelligence" - }, - { - "type": "paypal", - "url": "https://paypal.me/naturalintelligence" } ], - "inBundle": true, + "license": "MIT", "dependencies": { - "strnum": "^1.0.5" + "strnum": "^2.0.5" }, "bin": { "fxparser": "src/cli/cli.js" @@ -27697,10 +28090,16 @@ } }, "node_modules/strnum": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", - "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==", - "inBundle": true + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.0.5.tgz", + "integrity": "sha512-YAT3K/sgpCUxhxNMrrdhtod3jckkpYwH6JAuwmUdXZsmzH1wUyzTMrrK2wYCEEqlKwrWDd35NeuUkbBy/1iK+Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT" }, "node_modules/strtok3": { "version": "6.3.0", @@ -30667,6 +31066,40 @@ "node": ">=18.0.0" } }, + "test/node_modules/fast-xml-parser": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz", + "integrity": "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "license": "MIT", + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "test/node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT" + }, "test/opentofu-basic": { "name": "openotofu-basic", "version": "1.0.0", diff --git a/package.json b/package.json index cfa46fcb..7df4198b 100755 --- a/package.json +++ b/package.json @@ -115,6 +115,7 @@ "chokidar": "^3.6.0", "commander": "^13.1.0", "esbuild": "^0.25.0", + "fast-xml-parser": "^5.0.8", "inquirer": "^12.4.2", "jsonc-parser": "^3.3.1", "node-machine-id": "^1.1.12", @@ -133,6 +134,7 @@ "aws-iot-device-sdk", "chokidar", "commander", + "fast-xml-parser", "node-machine-id", "toml", "yaml", diff --git a/src/configuration/getConfigFromWizard.ts b/src/configuration/getConfigFromWizard.ts index d6820482..ac0fe01e 100644 --- a/src/configuration/getConfigFromWizard.ts +++ b/src/configuration/getConfigFromWizard.ts @@ -17,6 +17,7 @@ import { GitIgnore } from '../gitignore.js'; import { VsCode } from '../vsCode.js'; import { Logger } from '../logger.js'; import { Configuration } from '../configuration.js'; +import { JetBrains } from '../jetBrains.js'; const configFileName = path.resolve(configFileDefaultName); @@ -335,6 +336,19 @@ export async function getConfigFromWizard({ answers.vscode = answersVsCode.vscode; } + if (!(await JetBrains.isConfigured())) { + const answersJetBrains = await inquirer.prompt([ + { + type: 'confirm', + name: 'jetbrains', + message: `Would you like to add configuration for JetBrains IDE, like WebStorm?`, + default: false, + }, + ]); + + answers.jetbrains = answersJetBrains.jetbrains; + } + const answersVerbose = await inquirer.prompt([ { type: 'confirm', @@ -464,6 +478,7 @@ function getConfigFromAnswers(answers: any): LldConfigCliArgs { interactive: answers.interactive, gitignore: answers.gitignore, vscode: answers.vscode, + jetbrains: answers.jetbrains, }; //remove undefined and empty strings diff --git a/src/jetBrains.ts b/src/jetBrains.ts new file mode 100644 index 00000000..163e2f19 --- /dev/null +++ b/src/jetBrains.ts @@ -0,0 +1,150 @@ +import fs from 'fs/promises'; +import path from 'path'; +import { XMLParser, XMLBuilder } from 'fast-xml-parser'; +import { getProjectDirname } from './getDirname.js'; +import { Logger } from './logger.js'; +import { getRuntimeExecutableForIde } from './utils/getRuntimeExecutableForIde.js'; + +const workspaceXmlPath = path.join( + getProjectDirname(), + '.idea', + 'workspace.xml', +); + +async function getJetBrainsLaunchConfig() { + let runtimeExecutable = await getRuntimeExecutableForIde(false); + + if (!runtimeExecutable) { + return undefined; + } + + runtimeExecutable = runtimeExecutable.replace( + '${workspaceFolder}', + '$PROJECT_DIR$', + ); + return { + configuration: { + '@_name': 'Lambda Live Debugger', + '@_type': 'NodeJSConfigurationType', + '@_path-to-js-file': runtimeExecutable, + '@_working-dir': '$PROJECT_DIR$', + method: { '@_v': '2' }, + }, + }; +} + +async function readWorkspaceXml( + filePath: string, +): Promise<{ json: any; xmlString: string }> { + try { + const xmlString = await fs.readFile(filePath, 'utf-8'); + const parser = new XMLParser({ + ignoreAttributes: false, + allowBooleanAttributes: true, + }); + const json = parser.parse(xmlString); + return { json, xmlString }; + } catch (err: any) { + if (err.code === 'ENOENT') { + return { json: null, xmlString: '' }; + } + throw new Error(`Error reading ${filePath}`, { cause: err }); + } +} + +async function writeWorkspaceXml(filePath: string, json: any) { + try { + const builder = new XMLBuilder({ + ignoreAttributes: false, + format: true, + suppressEmptyNode: true, + suppressBooleanAttributes: false, + }); + const xmlString = builder.build(json); + await fs.writeFile(filePath, xmlString, 'utf-8'); + Logger.verbose(`Updated JetBrains IDE configuration at ${filePath}`); + } catch (err) { + throw new Error(`Error writing ${filePath}`, { cause: err }); + } +} + +async function isConfigured() { + const { json } = await readWorkspaceXml(workspaceXmlPath); + if (!json) return false; + + const components = Array.isArray(json.project?.component) + ? json.project.component + : [json.project?.component]; + const runManager = components.find((c: any) => c['@_name'] === 'RunManager'); + if (!runManager) return false; + + const configurations = runManager.configuration || []; + return configurations.some( + (c: any) => c['@_name'] === 'Lambda Live Debugger', + ); +} + +async function addConfiguration() { + Logger.verbose('Adding JetBrains IDE run/debug configuration'); + const { json } = await readWorkspaceXml(workspaceXmlPath); + const config = await getJetBrainsLaunchConfig(); + + if (!config) { + Logger.error( + 'Failed to configure JetBrains IDE. Cannot find a locally installed Lambda Live Debugger. The JetBrains IDE debugger cannot use a globally installed version.', + ); + return; + } + + if (!json) { + // Create new workspace.xml if it does not exist + const newJson = { + '?xml': { '@_version': '1.0', '@_encoding': 'UTF-8' }, + project: { + '@_version': '4', + component: { + '@_name': 'RunManager', + configuration: [config.configuration], + }, + }, + }; + await fs.mkdir(path.dirname(workspaceXmlPath), { recursive: true }); + await writeWorkspaceXml(workspaceXmlPath, newJson); + return; + } + + let runManager = json.project.component.find( + (c: any) => c['@_name'] === 'RunManager', + ); + + if (!runManager) { + Logger.verbose('RunManager not found, creating new RunManager component'); + runManager = { '@_name': 'RunManager', configuration: [] }; + json.project.component.push(runManager); + } + + let configurations; + if (!runManager.configuration) { + configurations = []; + } else if (!Array.isArray(runManager.configuration)) { + configurations = [runManager.configuration]; + } else { + configurations = runManager.configuration; + } + + const exists = configurations.some( + (c: any) => c['@_name'] === config.configuration['@_name'], + ); + if (!exists) { + Logger.verbose('Adding new configuration to workspace.xml'); + runManager.configuration = [...configurations, config.configuration]; + await writeWorkspaceXml(workspaceXmlPath, json); + } else { + Logger.verbose('Configuration already exists in workspace.xml'); + } +} + +export const JetBrains = { + isConfigured, + addConfiguration, +}; diff --git a/src/lldebugger.ts b/src/lldebugger.ts index 517b676b..30467222 100755 --- a/src/lldebugger.ts +++ b/src/lldebugger.ts @@ -17,6 +17,7 @@ import { Logger } from './logger.js'; import { getModuleDirname, getProjectDirname } from './getDirname.js'; import { LambdaConnection } from './lambdaConnection.js'; import inquirer from 'inquirer'; +import { JetBrains } from './jetBrains.js'; /** * Start the Lambda Live Debugger @@ -46,6 +47,10 @@ async function run() { await VsCode.addConfiguration(); } + if (Configuration.config.jetbrains) { + await JetBrains.addConfiguration(); + } + if (!Configuration.config.start && !Configuration.config.remove) { return; } diff --git a/src/types/lldConfig.ts b/src/types/lldConfig.ts index b80f86d4..0c121e60 100644 --- a/src/types/lldConfig.ts +++ b/src/types/lldConfig.ts @@ -78,6 +78,7 @@ export type LldConfigBase = { export type LldConfigCliArgs = { remove?: 'keep-layer' | 'all'; vscode?: boolean; + jetbrains?: boolean; gitignore?: boolean; config?: string; wizard?: boolean; diff --git a/src/utils/getRuntimeExecutableForIde.ts b/src/utils/getRuntimeExecutableForIde.ts new file mode 100644 index 00000000..fa6eef8c --- /dev/null +++ b/src/utils/getRuntimeExecutableForIde.ts @@ -0,0 +1,93 @@ +import fs from 'fs/promises'; +import path from 'path'; +import { getModuleDirname, getProjectDirname } from '../getDirname.js'; +import { Logger } from '../logger.js'; + +/** + * Get the runtime executable for the IDE, like WebStorm or VSCode + * @returns + */ +export async function getRuntimeExecutableForIde(allowGlobal = true) { + let runtimeExecutable: string | undefined; + const localRuntimeExecutable = '${workspaceFolder}/node_modules/.bin/lld'; + + const moduleDirname = getModuleDirname(); + const projectDirname = getProjectDirname(); + + const localFolder = path.resolve( + path.join(projectDirname, 'node_modules/.bin/lld'), + ); + + //if installed locally + Logger.verbose('Lambda Live Debugger is installed locally'); + try { + Logger.verbose( + 'Checking local folder for runtimeExecutable setting for VsCode configuration', + localFolder, + ); + await fs.access(localFolder, fs.constants.F_OK); + runtimeExecutable = localRuntimeExecutable; + } catch { + // Not found + } + + if (!runtimeExecutable) { + Logger.verbose('Lambda Live Debugger is installed globally'); + + if (allowGlobal) { + Logger.verbose( + `Setting absolute path for runtimeExecutable setting for VsCode configuration`, + ); + const localFolderSubfolder = path.resolve('node_modules/.bin/lld'); + const globalModule1 = path.join(moduleDirname, '..', '..', '.bin/lld'); + const globalModule2 = path.join(moduleDirname, '..', '..', 'bin/lld'); + const globalModule3 = path.join( + moduleDirname, + '..', + '..', + '..', + '..', + 'bin/lld', + ); + const possibleFolders = { + [localFolder]: '${workspaceFolder}/node_modules/.bin/lld', + [localFolderSubfolder]: localFolderSubfolder, + [globalModule1]: globalModule1, + [globalModule2]: globalModule2, + [globalModule3]: globalModule3, + }; + + Logger.verbose( + `Checking the following possible folders for lld executable:`, + JSON.stringify(possibleFolders, null, 2), + ); + + // check each possible folder and set the runtimeExecutable + for (const folder in possibleFolders) { + try { + //Logger.log("Checking folder", folder); + await fs.access(folder, fs.constants.F_OK); + runtimeExecutable = possibleFolders[folder]; + Logger.verbose(`Found folder with lld executable: ${folder}`); + break; + } catch { + // Not found + } + } + + if (!runtimeExecutable) { + Logger.error( + `Could not find lld executable. Please check your IDE debugger settings.`, + ); + } + } else { + return null; + } + } + + if (!runtimeExecutable) { + return localRuntimeExecutable; + } + + return runtimeExecutable; +} diff --git a/src/vsCode.ts b/src/vsCode.ts index affd80af..ca7d917d 100644 --- a/src/vsCode.ts +++ b/src/vsCode.ts @@ -9,11 +9,12 @@ import { FormattingOptions, } from 'jsonc-parser'; import { VsCodeLaunch } from './types/vsCodeConfig.js'; -import { getModuleDirname, getProjectDirname } from './getDirname.js'; +import { getProjectDirname } from './getDirname.js'; import { Logger } from './logger.js'; +import { getRuntimeExecutableForIde } from './utils/getRuntimeExecutableForIde.js'; async function getVsCodeLaunchConfig() { - const localRuntimeExecutable = '${workspaceFolder}/node_modules/.bin/lld'; + const runtimeExecutable = await getRuntimeExecutableForIde(); const config: VsCodeLaunch = { version: '0.2.0', @@ -22,7 +23,7 @@ async function getVsCodeLaunchConfig() { name: 'Lambda Live Debugger', type: 'node', request: 'launch', - runtimeExecutable: localRuntimeExecutable, + runtimeExecutable: runtimeExecutable!, runtimeArgs: [], console: 'integratedTerminal', skipFiles: ['/**'], @@ -31,86 +32,6 @@ async function getVsCodeLaunchConfig() { ], }; - const moduleDirname = getModuleDirname(); - //Logger.log("Module folder", moduleDirname); - const projectDirname = getProjectDirname(); - - //Logger.log("Current folder", currentFolder); - const localFolder = path.resolve( - path.join(projectDirname, 'node_modules/.bin/lld'), - ); - - let runtimeExecutableSet = false; - - //if installed locally - if (moduleDirname.startsWith('/home/')) { - Logger.verbose('Lambda Live Debugger is installed locally'); - // check if file exists - try { - Logger.verbose( - 'Checking local folder for runtimeExecutable setting for VsCode configuration', - localFolder, - ); - await fs.access(localFolder, fs.constants.F_OK); - config.configurations![0].runtimeExecutable = localRuntimeExecutable; - runtimeExecutableSet = true; - //Logger.log("Found local folder", localFolder); - } catch { - //Logger.log("Not found", localFolder); - } - } else { - Logger.verbose('Lambda Live Debugger is installed globally'); - } - - if (!runtimeExecutableSet) { - Logger.verbose( - `Setting absolute path for runtimeExecutable setting for VsCode configuration`, - ); - const localFolderSubfolder = path.resolve('node_modules/.bin/lld'); - const globalModule1 = path.join(moduleDirname, '..', '..', '.bin/lld'); - const globalModule2 = path.join(moduleDirname, '..', '..', 'bin/lld'); - const globalModule3 = path.join( - moduleDirname, - '..', - '..', - '..', - '..', - 'bin/lld', - ); - const possibleFolders = { - [localFolder]: '${workspaceFolder}/node_modules/.bin/lld', - [localFolderSubfolder]: localFolderSubfolder, - [globalModule1]: globalModule1, - [globalModule2]: globalModule2, - [globalModule3]: globalModule3, - }; - - Logger.verbose( - `Checking the following possible folders for lld executable:`, - JSON.stringify(possibleFolders, null, 2), - ); - - // check each possible folder and set the runtimeExecutable - for (const folder in possibleFolders) { - try { - //Logger.log("Checking folder", folder); - await fs.access(folder, fs.constants.F_OK); - config.configurations![0].runtimeExecutable = possibleFolders[folder]; - runtimeExecutableSet = true; - Logger.verbose(`Found folder with lld executable: ${folder}`); - break; - } catch { - // Not found - } - } - - if (!runtimeExecutableSet) { - Logger.error( - `Could not find lld executable. Please check the setting runtimeExecutable in '.vscode/launch.json'.`, - ); - } - } - return config; } From c6d8b1888c42c44018327e1433c89af0c98decb5 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Thu, 6 Mar 2025 09:52:51 +0100 Subject: [PATCH 2/5] Fixes --- src/gitignore.ts | 32 ++++--- src/jetBrains.ts | 119 ++++++++++++++---------- src/utils/getRuntimeExecutableForIde.ts | 77 ++++++--------- src/vsCode.ts | 62 +++++++----- 4 files changed, 153 insertions(+), 137 deletions(-) diff --git a/src/gitignore.ts b/src/gitignore.ts index 5933d865..c5022b24 100644 --- a/src/gitignore.ts +++ b/src/gitignore.ts @@ -14,7 +14,7 @@ async function doesExistInGitIgnore() { 'utf-8', ); // split by new line - const lines = gitignoreContent.split('\n'); + const lines = gitignoreContent.split('\n').map((line) => line.trim()); // check if ".lldebugger" exists const exists = lines.includes(outputFolder); return exists; @@ -37,20 +37,24 @@ function getGitIgnoreFileLocation() { */ async function addToGitIgnore() { Logger.log(`Adding ${outputFolder} to .gitignore.`); - const exists = await doesExistInGitIgnore(); - if (!exists) { - // does file exist? - try { - await fs.access(getGitIgnoreFileLocation()); - } catch { - await fs.writeFile(getGitIgnoreFileLocation(), `${outputFolder}\n`); - return; - } + try { + const exists = await doesExistInGitIgnore(); + if (!exists) { + // does file exist? + try { + await fs.access(getGitIgnoreFileLocation()); + } catch { + await fs.writeFile(getGitIgnoreFileLocation(), `${outputFolder}\n`); + return; + } - // append to existing file - await fs.appendFile(getGitIgnoreFileLocation(), `\n${outputFolder}\n`); - } else { - Logger.log(`${outputFolder} already exists in .gitignore`); + // append to existing file + await fs.appendFile(getGitIgnoreFileLocation(), `\n${outputFolder}\n`); + } else { + Logger.log(`${outputFolder} already exists in .gitignore`); + } + } catch (err) { + Logger.error('Error adding to .gitignore', err); } } diff --git a/src/jetBrains.ts b/src/jetBrains.ts index 163e2f19..17fc03fc 100644 --- a/src/jetBrains.ts +++ b/src/jetBrains.ts @@ -5,6 +5,8 @@ import { getProjectDirname } from './getDirname.js'; import { Logger } from './logger.js'; import { getRuntimeExecutableForIde } from './utils/getRuntimeExecutableForIde.js'; +const configName = 'Lambda Live Debugger'; + const workspaceXmlPath = path.join( getProjectDirname(), '.idea', @@ -69,58 +71,81 @@ async function writeWorkspaceXml(filePath: string, json: any) { } async function isConfigured() { - const { json } = await readWorkspaceXml(workspaceXmlPath); - if (!json) return false; - - const components = Array.isArray(json.project?.component) - ? json.project.component - : [json.project?.component]; - const runManager = components.find((c: any) => c['@_name'] === 'RunManager'); - if (!runManager) return false; - - const configurations = runManager.configuration || []; - return configurations.some( - (c: any) => c['@_name'] === 'Lambda Live Debugger', - ); + try { + const { json } = await readWorkspaceXml(workspaceXmlPath); + if (!json) return false; + + const { lldConfigExists } = extractWorkspaceData(json); + return lldConfigExists; + } catch (err) { + Logger.error('Error checking JetBrains IDE configuration', err); + return true; + } } async function addConfiguration() { - Logger.verbose('Adding JetBrains IDE run/debug configuration'); - const { json } = await readWorkspaceXml(workspaceXmlPath); - const config = await getJetBrainsLaunchConfig(); - - if (!config) { - Logger.error( - 'Failed to configure JetBrains IDE. Cannot find a locally installed Lambda Live Debugger. The JetBrains IDE debugger cannot use a globally installed version.', - ); - return; - } + try { + Logger.verbose('Adding JetBrains IDE run/debug configuration'); + const { json } = await readWorkspaceXml(workspaceXmlPath); + const config = await getJetBrainsLaunchConfig(); + + if (!config) { + Logger.error( + 'Failed to configure JetBrains IDE. Cannot find a locally installed Lambda Live Debugger. The JetBrains IDE debugger cannot use a globally installed version.', + ); + return; + } - if (!json) { - // Create new workspace.xml if it does not exist - const newJson = { - '?xml': { '@_version': '1.0', '@_encoding': 'UTF-8' }, - project: { - '@_version': '4', - component: { - '@_name': 'RunManager', - configuration: [config.configuration], + if (!json) { + // Create new workspace.xml if it does not exist + const newJson = { + '?xml': { '@_version': '1.0', '@_encoding': 'UTF-8' }, + project: { + '@_version': '4', + component: { + '@_name': 'RunManager', + configuration: [config.configuration], + }, }, - }, - }; - await fs.mkdir(path.dirname(workspaceXmlPath), { recursive: true }); - await writeWorkspaceXml(workspaceXmlPath, newJson); - return; + }; + await fs.mkdir(path.dirname(workspaceXmlPath), { recursive: true }); + await writeWorkspaceXml(workspaceXmlPath, newJson); + return; + } + + const { lldConfigExists, components, runManager, configurations } = + extractWorkspaceData(json); + json.project.component = components; + + if (!lldConfigExists) { + Logger.verbose('Adding new configuration to workspace.xml'); + runManager.configuration = [...configurations, config.configuration]; + await writeWorkspaceXml(workspaceXmlPath, json); + } else { + Logger.verbose('Configuration already exists in workspace.xml'); + } + } catch (err) { + Logger.error('Error adding JetBrains IDE configuration', err); + } +} + +/** + * Extract workspace data from JetBrains IDE configuration + * @param json + * @returns + */ +function extractWorkspaceData(json: any) { + let components = json.project.component; + if (!Array.isArray(components)) { + components = [components]; } - let runManager = json.project.component.find( - (c: any) => c['@_name'] === 'RunManager', - ); + let runManager = components.find((c: any) => c['@_name'] === 'RunManager'); if (!runManager) { Logger.verbose('RunManager not found, creating new RunManager component'); runManager = { '@_name': 'RunManager', configuration: [] }; - json.project.component.push(runManager); + components.push(runManager); } let configurations; @@ -132,16 +157,10 @@ async function addConfiguration() { configurations = runManager.configuration; } - const exists = configurations.some( - (c: any) => c['@_name'] === config.configuration['@_name'], + const lldConfigExists = configurations.some( + (c: any) => c['@_name'] === configName, ); - if (!exists) { - Logger.verbose('Adding new configuration to workspace.xml'); - runManager.configuration = [...configurations, config.configuration]; - await writeWorkspaceXml(workspaceXmlPath, json); - } else { - Logger.verbose('Configuration already exists in workspace.xml'); - } + return { lldConfigExists, runManager, configurations, components }; } export const JetBrains = { diff --git a/src/utils/getRuntimeExecutableForIde.ts b/src/utils/getRuntimeExecutableForIde.ts index fa6eef8c..144df1a5 100644 --- a/src/utils/getRuntimeExecutableForIde.ts +++ b/src/utils/getRuntimeExecutableForIde.ts @@ -1,7 +1,33 @@ import fs from 'fs/promises'; import path from 'path'; -import { getModuleDirname, getProjectDirname } from '../getDirname.js'; +import { getProjectDirname } from '../getDirname.js'; import { Logger } from '../logger.js'; +import { exec } from 'child_process'; +import { promisify } from 'util'; +import os from 'os'; + +const execAsync = promisify(exec); + +async function findGlobalPackagePath(packageName: string) { + try { + const command = + os.platform() === 'win32' + ? `where ${packageName}` + : `which ${packageName}`; + const { stdout } = await execAsync(command); + + const path = stdout?.trim().split('\n')[0]; + if (path) { + console.log( + `Global installation path for ${packageName}: ${path.trim()}`, + ); + } + return undefined; + } catch (error) { + Logger.verbose(`Error finding package ${packageName}`, error); + return undefined; + } +} /** * Get the runtime executable for the IDE, like WebStorm or VSCode @@ -11,7 +37,6 @@ export async function getRuntimeExecutableForIde(allowGlobal = true) { let runtimeExecutable: string | undefined; const localRuntimeExecutable = '${workspaceFolder}/node_modules/.bin/lld'; - const moduleDirname = getModuleDirname(); const projectDirname = getProjectDirname(); const localFolder = path.resolve( @@ -35,53 +60,9 @@ export async function getRuntimeExecutableForIde(allowGlobal = true) { Logger.verbose('Lambda Live Debugger is installed globally'); if (allowGlobal) { - Logger.verbose( - `Setting absolute path for runtimeExecutable setting for VsCode configuration`, - ); - const localFolderSubfolder = path.resolve('node_modules/.bin/lld'); - const globalModule1 = path.join(moduleDirname, '..', '..', '.bin/lld'); - const globalModule2 = path.join(moduleDirname, '..', '..', 'bin/lld'); - const globalModule3 = path.join( - moduleDirname, - '..', - '..', - '..', - '..', - 'bin/lld', - ); - const possibleFolders = { - [localFolder]: '${workspaceFolder}/node_modules/.bin/lld', - [localFolderSubfolder]: localFolderSubfolder, - [globalModule1]: globalModule1, - [globalModule2]: globalModule2, - [globalModule3]: globalModule3, - }; - - Logger.verbose( - `Checking the following possible folders for lld executable:`, - JSON.stringify(possibleFolders, null, 2), - ); - - // check each possible folder and set the runtimeExecutable - for (const folder in possibleFolders) { - try { - //Logger.log("Checking folder", folder); - await fs.access(folder, fs.constants.F_OK); - runtimeExecutable = possibleFolders[folder]; - Logger.verbose(`Found folder with lld executable: ${folder}`); - break; - } catch { - // Not found - } - } - - if (!runtimeExecutable) { - Logger.error( - `Could not find lld executable. Please check your IDE debugger settings.`, - ); - } + runtimeExecutable = await findGlobalPackagePath('lld'); } else { - return null; + return undefined; } } diff --git a/src/vsCode.ts b/src/vsCode.ts index ca7d917d..d566afd1 100644 --- a/src/vsCode.ts +++ b/src/vsCode.ts @@ -150,40 +150,52 @@ async function getCurrentState(): Promise< } async function isConfigured() { - const state = await getCurrentState(); + try { + const state = await getCurrentState(); + + if (state.state === 'FILE_EXISTS_CONFIGURATION_EXISTS') { + return true; + } - if (state.state === 'FILE_EXISTS_CONFIGURATION_EXISTS') { + return false; + } catch (err) { + Logger.error( + 'Error checking if configuration exists in .vscode/launch.json', + err, + ); return true; } - - return false; } async function addConfiguration() { - Logger.log('Adding configuration to .vscode/launch.json'); - const state = await getCurrentState(); + try { + Logger.log('Adding configuration to .vscode/launch.json'); + const state = await getCurrentState(); - const config = await getVsCodeLaunchConfig(); + const config = await getVsCodeLaunchConfig(); - if (state.state === 'FILE_EXISTS_CONFIGURATION_DOES_NOT_EXIST') { - const { jsonString, filePath, configurationsLength } = state; + if (state.state === 'FILE_EXISTS_CONFIGURATION_DOES_NOT_EXIST') { + const { jsonString, filePath, configurationsLength } = state; - await writeConfiguration( - filePath, - jsonString, - config.configurations![0], - configurationsLength, - ); - } else if (state.state === 'FILE_DOES_NOT_EXIST') { - // crete folder of filePath recursive if not exists - await fs.mkdir(path.dirname(state.filePath), { recursive: true }); - - Logger.verbose(`Creating VsCode configuration file: ${state.filePath}`); - await fs.writeFile( - state.filePath, - JSON.stringify(config, null, 2), - 'utf-8', - ); + await writeConfiguration( + filePath, + jsonString, + config.configurations![0], + configurationsLength, + ); + } else if (state.state === 'FILE_DOES_NOT_EXIST') { + // crete folder of filePath recursive if not exists + await fs.mkdir(path.dirname(state.filePath), { recursive: true }); + + Logger.verbose(`Creating VsCode configuration file: ${state.filePath}`); + await fs.writeFile( + state.filePath, + JSON.stringify(config, null, 2), + 'utf-8', + ); + } + } catch (err) { + Logger.error('Error adding configuration to .vscode/launch.json', err); } } From 66a43f18fabc6e52a05609d956282ace69e7f25e Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Thu, 6 Mar 2025 15:42:46 +0100 Subject: [PATCH 3/5] fix: findGlobalPackagePath --- src/utils/getRuntimeExecutableForIde.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/getRuntimeExecutableForIde.ts b/src/utils/getRuntimeExecutableForIde.ts index 144df1a5..f5df1f46 100644 --- a/src/utils/getRuntimeExecutableForIde.ts +++ b/src/utils/getRuntimeExecutableForIde.ts @@ -16,11 +16,17 @@ async function findGlobalPackagePath(packageName: string) { : `which ${packageName}`; const { stdout } = await execAsync(command); + Logger.verbose( + `Searching for ${packageName} globally. Executed command: ${command}. Output: ${stdout}`, + ); + const path = stdout?.trim().split('\n')[0]; + if (path) { console.log( `Global installation path for ${packageName}: ${path.trim()}`, ); + return path; } return undefined; } catch (error) { From f4cd167afede1a10f3059150d00360c7efd32e4b Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Thu, 6 Mar 2025 16:05:10 +0100 Subject: [PATCH 4/5] fix: log --- src/utils/getRuntimeExecutableForIde.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/getRuntimeExecutableForIde.ts b/src/utils/getRuntimeExecutableForIde.ts index f5df1f46..29e5a1bd 100644 --- a/src/utils/getRuntimeExecutableForIde.ts +++ b/src/utils/getRuntimeExecutableForIde.ts @@ -50,7 +50,6 @@ export async function getRuntimeExecutableForIde(allowGlobal = true) { ); //if installed locally - Logger.verbose('Lambda Live Debugger is installed locally'); try { Logger.verbose( 'Checking local folder for runtimeExecutable setting for VsCode configuration', @@ -58,6 +57,7 @@ export async function getRuntimeExecutableForIde(allowGlobal = true) { ); await fs.access(localFolder, fs.constants.F_OK); runtimeExecutable = localRuntimeExecutable; + Logger.verbose('Lambda Live Debugger is installed locally'); } catch { // Not found } From fc767650c583ee4264885d9153710a20d7ab6774 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Thu, 6 Mar 2025 16:08:30 +0100 Subject: [PATCH 5/5] fix: trim path --- src/utils/getRuntimeExecutableForIde.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/utils/getRuntimeExecutableForIde.ts b/src/utils/getRuntimeExecutableForIde.ts index 29e5a1bd..175bcdd1 100644 --- a/src/utils/getRuntimeExecutableForIde.ts +++ b/src/utils/getRuntimeExecutableForIde.ts @@ -20,12 +20,10 @@ async function findGlobalPackagePath(packageName: string) { `Searching for ${packageName} globally. Executed command: ${command}. Output: ${stdout}`, ); - const path = stdout?.trim().split('\n')[0]; + const path = stdout?.trim().split('\n')[0]?.trim(); if (path) { - console.log( - `Global installation path for ${packageName}: ${path.trim()}`, - ); + console.log(`Global installation path for ${packageName}: ${path}`); return path; } return undefined;