Skip to content

Commit

Permalink
Enable VSCode debugger (#494)
Browse files Browse the repository at this point in the history
This change saves settings and instructions for easily using the
built-in VSCode node.js debugger to step through and break on a running
local instance of eng-pipes.
  • Loading branch information
azaslavsky authored Jun 21, 2023
1 parent bab9bcb commit efd0a7e
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ lib

# IDE Settings
.idea/
.vscode/bookmarks.json

.yarn/*
!.yarn/cache
Expand Down
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// 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": "Build and debug eng-pipes via Yarn",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"envFile": "${workspaceFolder}/.env",
"outFiles": ["${workspaceFolder}/lib/**/*.js"],
"preLaunchTask": "Build eng-pipes",
"runtimeArgs": ["inspect"],
"runtimeExecutable": "yarn",
"skipFiles": [
"<node_internals>/**",
"**/node_modules/**",
"**/.node/corepack/yarn/**"
],
}
]
}
20 changes: 11 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"cSpell.words": [
"authtoken",
"direnv",
"getsentry",
"pbcopy",
"NGROK",
]
],
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"terminal.integrated.shellArgs.linux": ["-l"],
"terminal.integrated.shellArgs.osx": ["-l"],
}
22 changes: 22 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build eng-pipes",
"type": "shell",
"command": "yarn build",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "silent",
"panel": "shared"
},
"problemMatcher": []
}
]
}

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ ngrok http 3000 --domain your-fun-unique-subdomain.ngrok.io
- If BigQuery is producing a bunch of logspam for you, try adding `DRY_RUN=1` to your `.env` file.
- If you open this project in VSCode, you can attach the built-in debugger to a running server.
Rather than using `yarn dev` from the command line, instead open VSCode and select `Debug: Start Debugging` from the command palette:
![startup](/docs/debugger_startup.png 'Start the debugger')
You should hit any breakpoints you set in the code:
![running](/docs/debugger_running.png 'Running debugger paused in the main function')
## Development & tests
Follow the steps in the '''Setup''' section before running these steps:
Expand Down
Binary file added docs/debugger_running.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/debugger_startup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"deploy": "yarn build && (yarn deploy:development-metrics)",
"deploy:development-metrics": "./bin/deploy.sh",
"dev": "yarn clean && NODE_ENV=development nodemon --ignore '*.test.ts' --watch src/ -e ts --exec \"yarn start:clean\"",
"inspect:clean": "yarn build && yarn inspect",
"inspect": "NODE_ENV=development node --inspect --async-stack-traces ./lib/index.js",
"migrate": "yarn knex --knexfile ./src/knexfile.ts",
"start:clean": "yarn build && yarn start",
"start": "node --async-stack-traces ./lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"compilerOptions": {
"sourceMap": true,
"inlineSources": true,
"sourceRoot": "/"
"sourceRoot": "../src/",
}
}

0 comments on commit efd0a7e

Please sign in to comment.