mirror of
https://github.com/lensapp/lens.git
synced 2024-08-16 12:50:22 +03:00
VSCode launch configurations for debugging (#2281)
* Add configuration for debugging integration tests Signed-off-by: Alex Culliere <alozhkin@mirantis.com> * Add launch configuration for debugging main process Signed-off-by: Alex Culliere <alozhkin@mirantis.com> * Continue polishing debug configurations Signed-off-by: Alex Culliere <alozhkin@mirantis.com> * Remove unnecessary dependency Signed-off-by: Alex Culliere <alozhkin@mirantis.com> * Add debug configuration for unit tests + cleanup vscode tasks Signed-off-by: Alex Culliere <alozhkin@mirantis.com> * Update src/renderer/bootstrap.tsx Add `await` keyword to debugger attachment Co-authored-by: chh <1474479+chenhunghan@users.noreply.github.com> Signed-off-by: Alex Culliere <alozhkin@mirantis.com> * Update src/renderer/bootstrap.tsx Co-authored-by: chh <1474479+chenhunghan@users.noreply.github.com> Signed-off-by: Alex Culliere <alozhkin@mirantis.com> * Use existing variable to wait for chrome debugger attachment Signed-off-by: Alex Culliere <alozhkin@mirantis.com> * Update src/renderer/bootstrap.tsx Use available helper function instead of raw promise Co-authored-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Alex Culliere <alozhkin@mirantis.com> * Import delay utility Signed-off-by: Alex Culliere <alozhkin@mirantis.com> * Move async function to async context (attaching debugger) Signed-off-by: Alex Culliere <alozhkin@mirantis.com> Co-authored-by: Alex Culliere <alozhkin@mirantis.com> Co-authored-by: chh <1474479+chenhunghan@users.noreply.github.com> Co-authored-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
f287b8a3d0
commit
1b0f56f417
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,4 +17,3 @@ types/extension-renderer-api.d.ts
|
||||
extensions/*/dist
|
||||
docs/extensions/api
|
||||
site/
|
||||
.vscode/
|
||||
|
57
.vscode/launch.json
vendored
Normal file
57
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Main Process",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"protocol": "inspector",
|
||||
"preLaunchTask": "compile-dev",
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
||||
"windows": {
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
||||
},
|
||||
"runtimeArgs": [
|
||||
"--remote-debugging-port=9223",
|
||||
"--inspect",
|
||||
"."
|
||||
],
|
||||
"outputCapture": "std"
|
||||
},
|
||||
{
|
||||
"name": "Renderer Process",
|
||||
"type": "pwa-chrome",
|
||||
"request": "attach",
|
||||
"port": 9223,
|
||||
"webRoot": "${workspaceFolder}",
|
||||
"timeout": 30000
|
||||
},
|
||||
{
|
||||
"name": "Integration Tests",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"console": "integratedTerminal",
|
||||
"runtimeArgs": [
|
||||
"${workspaceFolder}/node_modules/.bin/jest",
|
||||
"--runInBand",
|
||||
"integration"
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "Unit Tests",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
|
||||
"args": [
|
||||
"--env=jsdom",
|
||||
"-i",
|
||||
"src"
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
18
.vscode/tasks.json
vendored
Normal file
18
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "shell",
|
||||
"group": "build",
|
||||
"command": "yarn",
|
||||
"args": [
|
||||
"debug-build"
|
||||
],
|
||||
"problemMatcher": [],
|
||||
"label": "compile-dev",
|
||||
"detail": "Compiles main and extension types"
|
||||
}
|
||||
]
|
||||
}
|
@ -13,7 +13,8 @@
|
||||
"scripts": {
|
||||
"dev": "concurrently -k \"yarn run dev-run -C\" yarn:dev:*",
|
||||
"dev-build": "concurrently yarn:compile:*",
|
||||
"dev-run": "nodemon --watch static/build/main.js --exec \"electron --inspect .\"",
|
||||
"debug-build": "concurrently yarn:compile:main yarn:compile:extension-types",
|
||||
"dev-run": "nodemon --watch static/build/main.js --exec \"electron --remote-debugging-port=9223 --inspect .\"",
|
||||
"dev:main": "yarn run compile:main --watch",
|
||||
"dev:renderer": "yarn run webpack-dev-server --config webpack.renderer.ts",
|
||||
"dev:extension-types": "yarn run compile:extension-types --watch --progress",
|
||||
|
@ -8,7 +8,8 @@ import * as ReactRouterDom from "react-router-dom";
|
||||
import { render, unmountComponentAtNode } from "react-dom";
|
||||
import { clusterStore } from "../common/cluster-store";
|
||||
import { userStore } from "../common/user-store";
|
||||
import { isMac } from "../common/vars";
|
||||
import { delay } from "../common/utils";
|
||||
import { isMac, isDevelopment } from "../common/vars";
|
||||
import { workspaceStore } from "../common/workspace-store";
|
||||
import * as LensExtensions from "../extensions/extension-api";
|
||||
import { extensionDiscovery } from "../extensions/extension-discovery";
|
||||
@ -19,6 +20,17 @@ import { App } from "./components/app";
|
||||
import { LensApp } from "./lens-app";
|
||||
import { themeStore } from "./theme.store";
|
||||
|
||||
/**
|
||||
* If this is a development buid, wait a second to attach
|
||||
* Chrome Debugger to renderer process
|
||||
* https://stackoverflow.com/questions/52844870/debugging-electron-renderer-process-with-vscode
|
||||
*/
|
||||
async function attachChromeDebugger() {
|
||||
if (isDevelopment) {
|
||||
await delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
type AppComponent = React.ComponentType & {
|
||||
init?(): Promise<void>;
|
||||
};
|
||||
@ -35,6 +47,7 @@ export {
|
||||
export async function bootstrap(App: AppComponent) {
|
||||
const rootElem = document.getElementById("app");
|
||||
|
||||
await attachChromeDebugger();
|
||||
rootElem.classList.toggle("is-mac", isMac);
|
||||
|
||||
extensionLoader.init();
|
||||
|
Loading…
Reference in New Issue
Block a user