fix(@embark/cmd-controller): exit build if afterDeploy is not array

Before, `embark build` would wait at the end if there was an
afterDeploy, because there was no way with the old string and array
syntax to know when the commands were done.
Now, with the function syntax, we can wait for the end.
This way, we can exit the build at the end if it is a function
afterDeploy.
Otherwise, we show a message saying that they should update
This commit is contained in:
Jonathan Rainville 2020-01-31 11:29:38 -05:00
parent f502650c17
commit 5359cc63da
4 changed files with 14 additions and 15 deletions

1
dapps/.gitignore vendored
View File

@ -3,3 +3,4 @@
**/config/livenet/password **/config/livenet/password
**/config/production/password **/config/production/password
**/embarkArtifacts **/embarkArtifacts
**/build

View File

@ -1,4 +1,4 @@
{ module.exports = {
"default": { "default": {
"versions": { "versions": {
"solc": "0.4.26" "solc": "0.4.26"
@ -18,9 +18,7 @@
}, },
"SimpleStorage": { "SimpleStorage": {
"fromIndex": 0, "fromIndex": 0,
"args": [ "args": [100]
100
]
}, },
"AnotherStorage": { "AnotherStorage": {
"args": [ "args": [
@ -33,9 +31,7 @@
"args": [1000] "args": [1000]
}, },
"Test": { "Test": {
"onDeploy": [ "onDeploy": ["Test.methods.changeAddress('$MyToken')"]
"Test.methods.changeAddress('$MyToken')"
]
}, },
"MyToken": { "MyToken": {
"instanceOf": "Token" "instanceOf": "Token"
@ -64,10 +60,11 @@
] ]
} }
}, },
"afterDeploy": [ afterDeploy: async ({contracts, web3}) => {
"Test.methods.changeAddress('$MyToken')", await contracts.Test.methods.changeAddress(contracts.MyToken.options.address).send();
"web3.eth.getAccounts((err, accounts) => Test.methods.changeAddress(accounts[0]))" const accounts = await web3.eth.getAccounts();
] await contracts.Test.methods.changeAddress(accounts[0]).send();
}
}, },
"development": { "development": {
"deploy": { "deploy": {
@ -77,4 +74,4 @@
} }
} }
} }
} };

View File

@ -5,7 +5,7 @@
"app": {}, "app": {},
"buildDir": "build/", "buildDir": "build/",
"config": { "config": {
"contracts": "contracts.json", "contracts": "contracts.js",
"storage": false, "storage": false,
"communication": false, "communication": false,
"webserver": false, "webserver": false,

View File

@ -340,11 +340,12 @@ class EmbarkController {
if (err) { if (err) {
engine.logger.error(err.message || err); engine.logger.error(err.message || err);
} }
// TODO: this should be moved out and determined somewhere else if (!engine.config.contractsConfig.afterDeploy || !engine.config.contractsConfig.afterDeploy.length || !Array.isArray(engine.config.contractsConfig.afterDeploy)) {
if (!engine.config.contractsConfig.afterDeploy || !engine.config.contractsConfig.afterDeploy.length) {
process.exit(err ? 1 : 0); process.exit(err ? 1 : 0);
} }
engine.logger.info(__('Waiting for after deploy to finish...')); engine.logger.info(__('Waiting for after deploy to finish...'));
engine.logger.info(__('Embark would exit automatically if you were using the function syntax in your afterDeploy instead of the Array syntax.'));
engine.logger.info(__('Find more information here: %s', 'https://framework.embarklabs.io/docs/contracts_configuration.html#afterDeploy-hook'.underline));
engine.logger.info(__('You can exit with CTRL+C when after deploy completes')); engine.logger.info(__('You can exit with CTRL+C when after deploy completes'));
}); });
} }