-
Notifications
You must be signed in to change notification settings - Fork 24
Feature/command provider poc #204
base: develop
Are you sure you want to change the base?
Conversation
Add in POC to test other providers under the hood.
Lot of fuffing around to figure out what to mock when doing a test.
Removing unused config elements also.
More refactoring and adding HH component finder.
This is the 3rd attempt.
Output channel has a wrapper to make logging easier.
Fixed the NPM and code which found/resolved the paths for projects into an abstract resolver. Hasn't been merged over the truffle code write now but put into a seperate namespace to keep it isolated and for comment.
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 @michaeljohnbennett for working on this. This would be a cool addition. Totally agree, with your points.
src/helpers/workspace.ts
Outdated
@@ -185,3 +189,120 @@ async function selectTruffleConfigFromQuickPick(workspaces: TruffleWorkspace[]): | |||
|
|||
return result.truffleWorkspace; | |||
} | |||
|
|||
export namespace AbstractWorkspaceManager { |
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.
I believe I would put all HH related stuff under a module HH. Or even as part of the extension adapter. Otherwise I won't be maintainable, say if we add more SDK providers.
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.
It is abstract.
It is provider agnostic hence the name. There are multiple resolvers inside it so in theory it would remove all the other code above in time and make the resolving of config and uri locations agnostic. so if we find a truffle config in folder A, then folder A is a truffle based SDK command driven workspace/folder. Folder B could hh or something else?
Does that make sense?
Namespace was here to just encapsulate it in this file v's making another workspace file.
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 @michaeljohnbennett,
It looks awesome :)
I agree with @acuarica comments. I'd like to point that we can keep the output wrapper, but I think might be a good idea, raise another issue to change the other output callings on the code, just to keep the pattern
Thank you for that :)
import {NotificationOptions} from '@/Constants'; | ||
import {showNotification} from '@/helpers/userInteraction'; | ||
import {IExtensionAdapter} from '@/services/extensionAdapter/IExtensionAdapter'; | ||
import {Constants} from '@/constants'; |
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.
Here we should use the same casing, i.e., @/Constants
. Otherwise, webpack gives a warning
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
removed some dead imports and lowered the hardhat min version.
Added in methods to make folder based ExtensionMapping work. Still an odd issue that the picker per project is happening twice but will be easy enough to figure out whats going on.
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 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. 👍🏻 |
moving the code to be more workspace aware. adding code to handle workspaces that have no/unknown frameworks installed so they fail gracefully. TODO: somehow add in a notification on UnknownExtensionAdapter.ts to warn user their commands are benign.
update to latest sinon (was very old) refactored out the old TruffleWorkspace code and move everything to AbstractWorkspace aware. workspace.ts removed and refactored to a Helper class WorkspaceHelpers .ts which now has all the base workspace helpers that are more VSCode specific. Core commands and TruffleCommands.ts are all AbstractWorkspace aware now as well. Tests cleaned up. A few placeholders added to wire out tomorrow.
src/helpers/AbstractWorkspace.ts
Outdated
* The [glob](https://github.com/isaacs/node-glob#glob-primer) pattern to match Truffle/Other config file names. | ||
*/ | ||
export const TRUFFLE_CONFIG_GLOB = 'truffle-config{,.*}.js'; | ||
export const HARDHAT_CONFIG_GLOB = 'hardhat.config{,.*}.ts'; |
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.
We would also need to include Hardhat js
config files, i.e., we can use the following glob hardhat.config{,.*}.{js,ts}
.
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.
ok I'll make that change I just think the majority of HH projects are TS based. I don't think they even give you a choice when bootstrapping a project to use JS anymore?
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.
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.
I will change the glob. thanks! 👍🏻
Hey @michaeljohnbennett, doing some early testing as discussed earlier. The Contract Explorer now displays the whole workspace, instead of displaying the |
webpack.common.js
Outdated
// Copyright (c) 2022. Consensys Software Inc. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
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 taking care of the Copyright Notice. But given that it is a significant change, should we open a different PR for this?
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.
I think this was done by my IDE. I thought this was how all our JS files were marked? Intellij adds in copyrights based on your template by default on all unmarked files.
I can revert all this if you think best?
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.
Got it. If it not a big issue reverting, I believe it's better to create another PR to tackle this copyright thing.
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:
? |
I'll revert the copy right stuff and merge in |
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?
|
Add in chai as promised to help with promise testing. Fixed the tests around workspace resolving and got good coverage on all paths.
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. |
I'm leaning towards option 1. described in #204 (comment).
That's the current behavior, but the contracts folder is the root itself. For example in a workspace with two Truffle config files each project is shown separately with its own root
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. |
Stopped updating copyright automagically.
Fixing tests and optimising the code before I can do the next part which is abstract out the truffle resolver code for config etc.
Reworking the mocks to work in the VSCode integration test environment.
The joys...
marking as draft so it doesn't get inadvertently merged right now pre-release of latest version. |
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: