Add --url option to the truffle migrate command#5739
Add --url option to the truffle migrate command#5739sukanyaparashar wants to merge 11 commits intodevelopfrom
truffle migrate command#5739Conversation
| "Creates a provider using the given url and connects to the network." | ||
| }, | ||
| { | ||
| option: "--network", |
There was a problem hiding this comment.
I'm curious about why you prefer --network lives here vs with the other global options.
Actually, can url be a global option as well?
There was a problem hiding this comment.
The global options generally appends the options at the end of the usage. The reason behind keeping --network and --url options here rather than in the global options, is to show that they are mutually exclusive.
There was a problem hiding this comment.
Okie. thank you for the explanation.
There was a problem hiding this comment.
should we add a note in each of these letting the user know that these options are mutually exclusive? do you think that would be helpful?
There was a problem hiding this comment.
Usage section shows that they are mutually exclusive but if adding a note in the descriptions is preferable, then we can add it here too.
There was a problem hiding this comment.
whatever you think, I don't feel strongly about it :)
cds-amal
left a comment
There was a problem hiding this comment.
Thanks, @sukanyaparashar. I have a question about how this feature would work in truffle develop. I suspect we should error better, or not allow the user to enter this command in the REPL. What do you think?
|
Thanks for the approval @lsqproduction. However, I am holding off to merge it now till all the commands have the |
| throw new TruffleError(message); | ||
| } | ||
|
|
||
| let config = loadConfig(options); |
There was a problem hiding this comment.
why not use const here?
There was a problem hiding this comment.
Oh! Yes, we can use const here.
cds-amal
left a comment
There was a problem hiding this comment.
I think this command is good, though we should add tests for the REPL command processing.
packages/core/lib/console.js
Outdated
| if (words.includes("--url")) { | ||
| const message = "url option is not supported within Truffle REPL"; | ||
| return makeIIFE(`ℹ️ : ${message}`); | ||
| } | ||
|
|
||
| if (words.includes("--network")) { | ||
| const message = "network option is not supported within Truffle REPL"; | ||
| return makeIIFE(`ℹ️ : ${message}`); | ||
| } | ||
|
|
There was a problem hiding this comment.
Let's add tests for these two
There was a problem hiding this comment.
The tests should cover both logic branches; with and without the truffle prefix.
dongmingh
left a comment
There was a problem hiding this comment.
I ran some tests and see the results:
-
start
ganachein one terminal, and runtruffle migrate --url http://127.0.0.1:8545on the other terminal, the migration works properly. -
start
truffle developand run the following tests:
2.1. migrate --url http://127.0.0.1:8545
truffle(develop)> migrate --url http://127.0.0.1:8545
'ℹ️ : url option is not supported within Truffle REPL'
2.2. migrate --network develop
truffle(develop)> migrate --network develop
'ℹ️ : network option is not supported within Truffle REPL'
2.3 truffle migrate --network develop
migration works properly
2.4 truffle migrate --url http://127.0.0.1:8545
truffle(develop)> truffle migrate --url http://127.0.0.1:8545
Mutually exclusive options, --url and --network detected!
Please use either --url or --network and try again.
See: https://trufflesuite.com/docs/truffle/reference/truffle-commands/#migrate
In the last test, the message says both --url and --network are detected though only option --url is provided.
Thanks for the thorough testing @dongmingh. I will make the required changes to address the issues with |
with truffle prefix without truffle prefix
|
Please let me know if I should make a new PR for this work to be completed :) |
PR description
This PR adds
--urloption to thetruffle migratecommand that connects to a specified url. See #5701.Testing instructions
To test this option -
truffle migrate --url http://127.0.0.1:8545inside a truffle project in a separate terminal. The contracts inside the truffle project will be deployed in Ganache.Documentation
doc-change-requiredlabel to this PR if documentation updates are required.