Closed g4ndr4 closed 1 year ago
My code structure would look something like this:
tenderly-cli/
- main.go
internal/
command/
- builder.go
- command.go (types/interfaces)
w3a/ (actions)
gateway/ (extension commands should be inside this package since they belong to gateway domain)
hardhat/
...
Focus more on grouping logic by domain and exposing more interfaces. Avoid things like:
@l2cup 's PR on restructuring tenderly-server
is a good example of how things should be structured.
I didn't have time to dive into the implementation itself, but with right code structuring you'll be able to write cleaner and more manageable code.
Context
The aim of this PR is to add support for
node-extension
related operations to CLI.node-extensions
is being added, with two new commandsnode-extensions init
- used to initnode_extensions
section oftenderly.yaml
file, similar to how actions are being initializednode-extensions deploy
- used to deploy either a specific extension, or all extensions intenderly.yaml
filenode-extensions init
commandThis commands helps users initialize extensions in the
tenderly.yaml
file. It accepts the following arguments:name
- used to specify extension namedescription
- used to specify extension descriptionmethodName
- used to specify extension method nameThe command checks whether the provided
methodName
is valid, and then prompts the user to select one action from a list of those eligible for extensions (presented in the following format:account/project:action
). The list will contain only actions that are not already used by other extensions intenderly.yaml
file. If there are no actions, eligible for extensions, found intenderly.yaml
, the command will return an error. If there are eligible actions intenderly.yaml
, but all already used for other extensions intenderly.yaml
, the command will return an error.Once the user has picked an action, the command will check whether the chosen extension method name is already taken by another extension in the same
account/project
and, if so, return an error.Otherwise, the command will add the extension to the
tenderly.yaml
.node-extensions deploy
commandThis command deploys extensions specified in
tenderly.yaml
file. It accepts the following arguments:account
- used to specify which account the extension is defined for intenderly.yaml
project
- used to specify which project the extension is defined for intenderly.yaml
extensionName
- used to specify which extension in the providedaccount/project
should be deployedIf no arguments are provided, the command will attempt to deploy all extensions defined in
tenderly.yaml
. In case any of those extension deployments fail, it will print out the failure reasons and continue with deployment.The deployment of an extension has two steps. In case there are multiple extensions being deployed, these same steps are repeated for each extension being deployed.
1. Validation
This step performs the following checks:
account/project
account/project
If any of these checks fail, the deployment of the extension won't go through. Results of all four checks are aggregated and presented to the user in an error message.
2. Deployment
This step deploys the extension to the backend. It executes only if the Validation step succeeds.