From 9eea601724e5c7053099ce2b983389e5c189787f Mon Sep 17 00:00:00 2001 From: Alexander Schreiner Date: Mon, 6 Jan 2025 13:58:30 +0100 Subject: [PATCH 01/14] Added debugging support for vscode and jetbrains IDE's Signed-off-by: Alexander Schreiner --- .gitignore | 7 +++++-- .run/chrome_debug_client_side.run.xml | 5 +++++ .vscode/extensions.json | 5 +++++ .vscode/launch.json | 24 ++++++++++++++++++++++++ README.md | 24 ++++++++++++++++++++++++ package.json | 2 +- 6 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 .run/chrome_debug_client_side.run.xml create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json diff --git a/.gitignore b/.gitignore index b7b9f2cdae..9c60b3793b 100644 --- a/.gitignore +++ b/.gitignore @@ -36,8 +36,11 @@ yarn-error.log* # vercel .vercel -# vs code -.vscode/ +# Ignore everything in the .vscode folder +.vscode/* +# Except the launch.json file and extensions.json file +!.vscode/launch.json +!.vscode/extensions.json # intellij .idea diff --git a/.run/chrome_debug_client_side.run.xml b/.run/chrome_debug_client_side.run.xml new file mode 100644 index 0000000000..f014807876 --- /dev/null +++ b/.run/chrome_debug_client_side.run.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000000..1a1342fe60 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "firefox-devtools.vscode-firefox-debug" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..ffd4fc716c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Next.js: debug client-side (Chrome)", + "type": "chrome", + "request": "launch", + "url": "http://localhost:3000" + }, + { + "name": "Next.js: debug client-side (Firefox)", + "type": "firefox", + "request": "launch", + "url": "http://localhost:3000", + "reAttach": true, + "pathMappings": [ + { + "url": "webpack://_n_e", + "path": "${workspaceFolder}" + } + ] + } +] +} \ No newline at end of file diff --git a/README.md b/README.md index 7f05f6fa8b..53e79b0beb 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,30 @@ Note: If you are running the backend locally and things like `dev.zetkin.org` re then this only works on Linux-based systems, due to the nature of `127.0.0.1` pointing to the host on Linux (but not on Windows/Mac, where it points to the container itself). +### Debugging + +If you want to debug this applications you can do so through VS Code or JetBrains IDE's (as IntelliJ or WebStorm). + +#### VS Code + +For VS Code there are 2 debugging configurations within [`./.vscode/launch.json`](./.vscode/launch.json). +One for debugging with chrome and one for firefox. + +1. Start the devserver via `yarn devserver` +2. In the sidebar on the left go to `Run and Debug` +3. Select and run `Next.js: debug client-side (Chrome)` or `Next.js: debug client-side (Firefox)` (note that you need to have the [Debugger for Firefox Extension](https://marketplace.visualstudio.com/items?itemName=firefox-devtools.vscode-firefox-debug) installed as referenced in [`./.vscode/extensions.json`](./.vscode/extensions.json)) +4. A browser window should open itself. Navigate to the page that you need to debug (don't forget to set your breakpoints first) + +#### JetBrains IDE's + +For JetBrains IDE's unfortunately there's only a debug configuration for chrome available ([`./.idea/launch.json`](./.idea/launch.json)). + +1. Start the devserver via `yarn devserver` +2. In the top bar select the run configuration `Next.js: debug client-side (Chrome)` +3. Run that selected configuration in the debug mode by clicking on the bug icon. +4. A chrome window should open itself. Navigate to the page that you need to debug (don't forget to set your breakpoints first) + + ## Development server login credentials You can log in using the dummy user accounts to access dummy data from the diff --git a/package.json b/package.json index 2f939b89c3..2397c69535 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "analyze": "ANALYZE=true next build", "build": "next build", "start": "next start -p 80", - "devserver": "next dev -p 3000", + "devserver": "cross-env NODE_OPTIONS='--inspect' next dev -p 3000", "docs:build": "storybook build -o public/storybook && typedoc", "lint:eslint": "eslint src integrationTesting", "lint:prettier": "prettier --check src integrationTesting", From 623fda68354d6319418d57b24324fb76213bddd5 Mon Sep 17 00:00:00 2001 From: Alexander Schreiner Date: Mon, 6 Jan 2025 14:01:31 +0100 Subject: [PATCH 02/14] Added idea run configuration for devserver Signed-off-by: Alexander Schreiner --- .run/devserver.run.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .run/devserver.run.xml diff --git a/.run/devserver.run.xml b/.run/devserver.run.xml new file mode 100644 index 0000000000..b7245a7600 --- /dev/null +++ b/.run/devserver.run.xml @@ -0,0 +1,12 @@ + + + + + +