-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add --url option to the truffle migrate
command
#5739
base: develop
Are you sure you want to change the base?
Conversation
"Creates a provider using the given url and connects to the network." | ||
}, | ||
{ | ||
option: "--network", |
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'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okie. thank you for the explanation.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whatever you think, I don't feel strongly about it :)
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, @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use const
here?
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.
Oh! Yes, we can use const
here.
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add tests for these two
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 add the tests. Thanks @cds-amal.
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.
The tests should cover both logic branches; with and without the truffle
prefix.
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 ran some tests and see the results:
-
start
ganache
in one terminal, and runtruffle migrate --url http://127.0.0.1:8545
on the other terminal, the migration works properly. -
start
truffle develop
and 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
--url
option to thetruffle migrate
command that connects to a specified url. See #5701.Testing instructions
To test this option -
truffle migrate --url http://127.0.0.1:8545
inside a truffle project in a separate terminal. The contracts inside the truffle project will be deployed in Ganache.Documentation
doc-change-required
label to this PR if documentation updates are required.