hardhat-vscode
hardhat-vscode copied to clipboard
Hardhat task provider and commands
Closes #70
See changes to extension.md for introduced features
HHVSC-57 "Hardhat config as Task Provider" (nomiclabs/hardhat-vscode #70)
Investigate typescript/rust analyzer plugins to see how they integrate build and test commands, and how they expose custom actions from their config documents (i.e. package.json and cargo.toml).
Exposes the custom actions from plugins and which the user provides as tasks in vscode.
See the TaskProvider docs: https://code.visualstudio.com/api/extension-guides/task-provider
nomiclabs/hardhat-vscode #70 by @kanej on GitHub
via LinearSync
Codecov Report
:exclamation: No coverage uploaded for pull request base (
development@24ee5a0). Click here to learn what that means. The diff coverage isn/a.
@@ Coverage Diff @@
## development #243 +/- ##
==============================================
Coverage ? 70.71%
==============================================
Files ? 169
Lines ? 4080
Branches ? 714
==============================================
Hits ? 2885
Misses ? 968
Partials ? 227
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
@antico5 have you seen task inputs and prompts? https://code.visualstudio.com/docs/editor/variables-reference#_input-variables
We have one
hardhattask for compile, in a monorepo setup we infer which proj is meant by the open editor window.I was expecting one compile task per project, this has the advantage of not being dependent on the open editor and works when invoking via command palette.
Should I change it to have a task list like the following?
- Hardhat: compile project_1
- Hardhat: compile ...
- Hardhat: compile project_n
- Hardhat: clean project_1
- ...
- Hardhat: clean project_n
- Hardhat: ...
We have one
hardhattask for compile, in a monorepo setup we infer which proj is meant by the open editor window. I was expecting one compile task per project, this has the advantage of not being dependent on the open editor and works when invoking via command palette.Should I change it to have a task list like the following?
* Hardhat: compile project_1 * Hardhat: compile ... * Hardhat: compile project_n * Hardhat: clean project_1 * ... * Hardhat: clean project_n * Hardhat: ...
Yeah. It means lots more tasks but each task is easier to reason about, also no one was ever fired for doing what typescript does.
@antico5 have you seen task inputs and prompts? https://code.visualstudio.com/docs/editor/variables-reference#_input-variables
I haven't before, thanks for pointing them out! So It looks like when you are acting as a task provider, you can't specify input variables like in your tasks.json file, BUT you can use commands to have any behavior you want. So you can use e.g. ${command:hardhat.solidity.getTextInput}, which could open an input box that returns a string, and that string will be provided to the task execution.
With this new knowledge, what tasks and commands should I add/change/remove ?
I don't think we change the current commands. I think we keep it in mind when rolling out further tasks.
The build tasks show the config file as an absolute path, but we should display relative to the workspace folder:

vs

Note that vscode auto-shows workspace folder name if there is more than one workspace folder.
I pulled the latest and ran through tests on windows. I am seeing the relative urls, but it appears that some hardhat projects are under the wrong workspace folder. Should the workspace folder be appearing in the uri path?

Should the directory for the task be relative to the workspace folder (rather than packages)?

When I use the command palette to Run Test task, i initially get a test task for each hardhat project. If I run a test task and then go back into Run Test task the npm test tasks appear but the hardhat ones don't (except under recent):

When I use the command palette to
Run Test task, i initially get a test task for each hardhat project. If I run a test task and then go back intoRun Test taskthe npm test tasks appear but the hardhat ones don't (except under recent):
This is on VS Code unfortunately. The task providers returns the correct list of tasks every time (compile, test, etc), but the "Run Test/Build task" command sometimes shows only a subset of them. The way I found for it to always show the complete list is by Run Task -> hardhat