hardhat-vscode icon indicating copy to clipboard operation
hardhat-vscode copied to clipboard

Hardhat task provider and commands

Open antico5 opened this issue 3 years ago • 8 comments
trafficstars

Closes #70

See changes to extension.md for introduced features

antico5 avatar Aug 29 '22 19:08 antico5

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

linear[bot] avatar Aug 29 '22 19:08 linear[bot]

Codecov Report

:exclamation: No coverage uploaded for pull request base (development@24ee5a0). Click here to learn what that means. The diff coverage is n/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.

codecov-commenter avatar Aug 30 '22 10:08 codecov-commenter

@antico5 have you seen task inputs and prompts? https://code.visualstudio.com/docs/editor/variables-reference#_input-variables

kanej avatar Aug 31 '22 14:08 kanej

We have one hardhat task 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: ...

antico5 avatar Aug 31 '22 14:08 antico5

We have one hardhat task 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.

kanej avatar Aug 31 '22 15:08 kanej

@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 ?

antico5 avatar Aug 31 '22 15:08 antico5

I don't think we change the current commands. I think we keep it in mind when rolling out further tasks.

kanej avatar Aug 31 '22 15:08 kanej

The build tasks show the config file as an absolute path, but we should display relative to the workspace folder:

image

vs

image

Note that vscode auto-shows workspace folder name if there is more than one workspace folder.

kanej avatar Sep 01 '22 09:09 kanej

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?

image

kanej avatar Sep 05 '22 09:09 kanej

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

image

kanej avatar Sep 07 '22 10:09 kanej

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):

image

kanej avatar Sep 07 '22 10:09 kanej

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):

image

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

antico5 avatar Sep 07 '22 11:09 antico5