-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Running truffle debug with appropriate flag (--vscode) #5684
base: develop
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevinbluer for visibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, maybe just have a VSCodeDebugger
class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is brittle, since we can't always rely on being able to get a URL from a provider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does open
also works in Linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 Tab
on 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} --vscode
5. 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} --vscode
Reminder: 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-required
label to this PR if documentation updates are required.Breaking changes and new features
breaking-change
andnew-feature
labels for the appropriate packages.