IntelliJ run configurations - CDCgov/prime-simplereport GitHub Wiki

Intro

This page guides us through setting up IntelliJ's run configurations to run the app via IntelliJ.

Prerequisites

Setup

Caveat

  • Make sure you didn't already open the repo in IntelliJ
  • If you mess up somewhere, do sudo rm -rf .idea in the project root to start from scratch

After opening the project,

  • You should see the following alerts appear in the lower right-hand corner.
  • Click "Load"

  • You may also see a popup up that asks you if you want to yarn install, feel free to do this now although it's not strictly necessary

  • Open the backend/src/main/java/gov/cdc/usds/simplerepot/SimpleReportApplication.java file in IntelliJ

  • You should see a banner near the top of the editor, saying "Module JDK is not defined", click "Setup SDK".

  • That should open a dropdown. You should click the appropriate "Oracle OpenJDK version"
  • Once that is done, you should start seeing green arrows to the right of the line numbers in that file
  • To the left of the green hammer, you should click the dropdown and select "Edit Configurations..."
  • That should open a new window called "Run/Debug Configurations",

With Okta

  • Open the "Spring Boot" tab and click "Backend with Okta".
  • Set the following:
    • "Active profiles:" to okta-local,local
    • "Environment variables:" to the values in the repository's .env file as a comma-separated list and without the double quotes (e.g. SMARTY_AUTH_ID=123,SMARTY_AUTH_TOKEN=123,OKTA_API_KEY=123)
    • Ask a developer for these values

Without Okta

  • Ensure the "Backend" run configuration only has the "Active profiles:" set to dev (This should be the default)

Prevent the browser from opening when starting the app (optional)

  • open the "npm" tab and click "Frontend" or "Frontend with Okta".

  • Set "Environment:" to BROWSER=none and click "Apply". Ignore the other options.

Running the debugger for the frontend

  1. Have the appropriate backend running
  2. Start the frontend by selecting the frontend run configuration you want, and pressing the green play button
  1. In the "Run" tab for the frontend run configuration you just started, find the URL that the console prints:
  1. On a Mac, CMD + Shift + click that URL
  2. A new browser window should open.
  3. Set breakpoints on the frontend code in IntelliJ where you would like the application to break on.
  4. Your debugger should now be working!