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

Feature/command provider poc

Open michaeljohnbennett opened this issue 3 years ago • 11 comments

This is the intial POC for the concept of alternative providers for the main commands on a project.

I spent a bit of time to and fro on how best to achieve or abstract out the concept of a workspace and a provider and this is the initial version where we have providers that can interrogate the workspaces and decide what provider is where in a monorepo for ones we support.

Still early days but I think it could be adapted to give us some flexibility in supporting other frameworks easily in the future.

Going to mark this draft right now as I'd like to get your thoughts on the thinking behind it and how we might be able to do it better/enhance it.

Things we could improve:

  1. having config and commands driven by the folder or parent folder config.
  2. understanding what can and cannot be done in each project and how things like package.json commands/sdk commands may interoperate or conflict.

michaeljohnbennett avatar Aug 15 '22 09:08 michaeljohnbennett

@acuarica @xhulz I have made more fixes and now the actual resolving of providers is dynamic based on the folders it finds and configs inside them.

Still a bit to fix but overall its working for compilation. But we need to figure out the display in the contracts folders.

michaeljohnbennett avatar Nov 01 '22 07:11 michaeljohnbennett

Hi @michaeljohnbennett, maybe we could use the approach I've used for deployments. Whenever more than one Truffle is found, the Deployments view uses the folder name+Truffle config name as a way to identify each project, for example

image

This was implemented in https://github.com/trufflesuite/vscode-ext/pull/179.

acuarica avatar Nov 01 '22 19:11 acuarica

Hi @michaeljohnbennett, maybe we could use the approach I've used for deployments. Whenever more than one Truffle is found, the Deployments view uses the folder name+Truffle config name as a way to identify each project, for example

image

This was implemented in #179.

I was trying to figure out a easy way to do this with the current treeview for file we use in that contract window, I'll have a look at the deployments view code again and see if I can adapt it. I was thinking even a logo against the folders or something would be good. 👍🏻

michaeljohnbennett avatar Nov 01 '22 21:11 michaeljohnbennett

Hey @michaeljohnbennett, doing some early testing as discussed earlier.

The Contract Explorer now displays the whole workspace, instead of displaying the contracts folder only. This happens for both Truffle and Hardhat projects.

image image

acuarica avatar Nov 15 '22 15:11 acuarica

Hey @michaeljohnbennett, doing some early testing as discussed earlier.

The Contract Explorer now displays the whole workspace, instead of displaying the contracts folder only. This happens for both Truffle and Hardhat projects.

image image

Yes, this one of the questions I have. Contracts is really the wrong name going forward as we really need to show a bit more than just the contracts folder now, its a hierarchy of projects and their resulting folders.

Perhaps we need to have a filter list:

  • contracts (wherever that folder is)
  • tests
  • config files

?

michaeljohnbennett avatar Nov 15 '22 22:11 michaeljohnbennett

I'll revert the copy right stuff and merge in develop today.

michaeljohnbennett avatar Nov 15 '22 22:11 michaeljohnbennett

Regarding https://github.com/trufflesuite/vscode-ext/pull/204#issuecomment-1315922516, the only thing that worries me is that if we start including tests and config files into the Contract Explorer, not sure how much value provides over the File Explorer.

acuarica avatar Nov 15 '22 23:11 acuarica

Regarding #204 (comment), the only thing that worries me is that if we start including tests and config files into the Contract Explorer, not sure how much value provides over the File Explorer.

I agree it needs to change but to what?

  1. Stay as is and only show contracts, but how do we represent a monorepo of differing projects in this view? A folder for each root then a contracts folder? What about scripts/tests etc?
  2. We change the name to something more akin to a Project explorer and show more meaningful information/folders relating to a smart contract project (tests, contracts, artifacts, config) but filter out all the other non-essential to coding files (.ignore etc, build/node_modules)

michaeljohnbennett avatar Nov 16 '22 01:11 michaeljohnbennett

I have merged in develop and @xhulz fixes to tree view. I'll use them now as my changes I made are blasted away now but its ok, I still have to remove the copy right changes.

All tests fixed now as well.

michaeljohnbennett avatar Nov 16 '22 06:11 michaeljohnbennett

I agree it needs to change but to what?

I'm leaning towards option 1. described in https://github.com/trufflesuite/vscode-ext/pull/204#issuecomment-1316173602.

but how do we represent a monorepo of differing projects in this view? A folder for each root then a contracts folder?

That's the current behavior, but the contracts folder is the root itself. For example in a workspace with two Truffle config files

image

each project is shown separately with its own root

image

What about scripts/tests etc?

This seems to be an orthogonal feature, not necessarily related to this PR. Given said that, I do agree that we need to discuss what to display in this view.

acuarica avatar Nov 16 '22 14:11 acuarica

marking as draft so it doesn't get inadvertently merged right now pre-release of latest version.

michaeljohnbennett avatar Nov 29 '22 22:11 michaeljohnbennett