Running truffle debug with appropriate flag (--vscode)#5684
Running truffle debug with appropriate flag (--vscode)#5684
Conversation
|
|
||
| // Checks if the user wants to open the debugger in vscode | ||
| if (config.vscode) { | ||
| await cliDebugger.openVSCodeDebug(); |
There was a problem hiding this comment.
Shouldn't this method not be part of the thing called the "CLI" debugger? Seems better to keep the CLIDebugger just for the CLI and push this VS Code logic elsewhere.
There was a problem hiding this comment.
Hi @gnidan, Thank you for that
What would be the best place (package/class) to put this code?
There was a problem hiding this comment.
Thanks for the heads up @xhulz! Also sounds like we've got a way forward for this from our earlier conversation 👍
There was a problem hiding this comment.
Hm, maybe just have a VSCodeDebugger class?
There was a problem hiding this comment.
Hey @gnidan @kevinbluer
I just moved all the vscode debug function to a new class called VSCodeDebugger.
Thank you all again
packages/core/lib/debug/cli.js
Outdated
| // Sets the query parameters | ||
| url.searchParams.set("txHash", this.txHash); | ||
| url.searchParams.set("workingDirectory", this.config.working_directory); | ||
| url.searchParams.set("providerUrl", this.config.provider.host); |
There was a problem hiding this comment.
Note that this is brittle, since we can't always rely on being able to get a URL from a provider
acuarica
left a comment
There was a problem hiding this comment.
lgtm, although please keep in mind that my review is mostly about style rather than correctness, since I'm not that familiar with Truffle codebase.
| url.searchParams.set("disableFetchExternal", disableFetchExternal); | ||
|
|
||
| // Opens VSCode based on OS | ||
| const openCommand = process.platform === "win32" ? `start ""` : `open`; |
There was a problem hiding this comment.
IIRC, win32: start, osX: open, and *nix is xdg-open or similar resource openers mimeopen, mimeo, linopen, handlr etc.
| return new URL( | ||
| `http://${this.config.network_config.host}:${this.config.network_config.port}` | ||
| ).toString(); |
There was a problem hiding this comment.
Is it worth to do new URL(string).toString()? In other words, what's the issue with returning just http://[...]?
| /** | ||
| * This function is responsible for opening the debugger in vscode. | ||
| */ | ||
| async run() { |
There was a problem hiding this comment.
Given the purpose of this method, I would name it open instead of run.
| @@ -0,0 +1,73 @@ | |||
| const childProcess = require("child_process"); | |||
|
|
|||
| class VSCodeDebugger { | |||
There was a problem hiding this comment.
Just a small detail, the name VSCodeDebugger might be a bit misleading. What about VSCodeOpenDebugger or VSCodeDebugAdapter?
|
Hey @acuarica, thank you for you review! Your suggestions make sense. I'll wait for the other reviews to implement them all at once. Thank you! |
cds-amal
left a comment
There was a problem hiding this comment.
Partial review, I didn't get a chance to run this yet.
| url.searchParams.set("disableFetchExternal", disableFetchExternal); | ||
|
|
||
| // Opens VSCode based on OS | ||
| const openCommand = process.platform === "win32" ? `start ""` : `open`; |
There was a problem hiding this comment.
IIRC, win32: start, osX: open, and *nix is xdg-open or similar resource openers mimeopen, mimeo, linopen, handlr etc.

PR description
This PR allows the user to debug a transaction using VSCode.
Testing instructions
1. Download and Unzip the Truffle extension VSIX (local version is 2.3.5): truffle-vscode-2.3.5.vsix.zip
2. To install:
Extensions Tabon the left menu.Install from VSIX.3. To prevent VSCode from updating the Truffle extension version choose the option
Ignore updates:4. To debug using VSCode, just type in your terminal:
truffle debug {your tx} --vscode5. If you want to use the fetchExternal option, just add the flag: truffle debug {your tx} --vscode --fetchExternal`
7. To debug using VSCode, just type:
truffle debug {your tx} --vscodeReminder: VSCode will ask if you want to allow debugging,](reminder: VSCode will ask if you want to allow opening the url for debugging. To continue, click
open.Documentation
doc-change-requiredlabel to this PR if documentation updates are required.Breaking changes and new features
breaking-changeandnew-featurelabels for the appropriate packages.