refactor duplicated build & deploy process

This commit is contained in:
Iuri Matias 2016-10-29 10:33:54 -04:00
parent c9a52c11b0
commit 816e67370a
1 changed files with 39 additions and 54 deletions

View File

@ -53,33 +53,7 @@ var Embark = {
self.config.reloadConfig();
callback();
},
function deployAndBuildContractsManager(callback) {
Embark.monitor.setStatus("Redeploying changed Contracts");
Embark.buildAndDeploy(function(contractsManager) {
callback(null, contractsManager);
});
},
function generateConsoleABI(contractsManager, callback) {
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
var consoleABI = abiGenerator.generateABI({useEmbarkJS: false});
Embark.console.runCode(consoleABI);
callback(null, contractsManager);
},
function generateABI(contractsManager, callback) {
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
callback(null, abiGenerator.generateABI({useEmbarkJS: true}));
},
function buildPipeline(abi, callback) {
Embark.monitor.setStatus("Building Assets");
var pipeline = new Pipeline({
buildDir: self.config.buildDir,
contractsFiles: self.config.contractsFiles,
assetFiles: self.config.assetFiles,
logger: self.logger
});
pipeline.build(abi);
callback();
}
self.buildDeployGenerate.bind(self)
], function(err, result) {
Embark.monitor.setStatus("Ready");
self.logger.trace("finished".underline);
@ -112,33 +86,7 @@ var Embark = {
Embark.servicesMonitor.startMonitor();
callback();
},
function deployAndBuildContractsManager(callback) {
Embark.monitor.setStatus("Deploying Contracts");
Embark.buildAndDeploy(function(contractsManager) {
callback(null, contractsManager);
});
},
function generateConsoleABI(contractsManager, callback) {
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
var consoleABI = abiGenerator.generateABI({useEmbarkJS: false});
Embark.console.runCode(consoleABI);
callback(null, contractsManager);
},
function generateABI(contractsManager, callback) {
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
callback(null, abiGenerator.generateABI({useEmbarkJS: true}));
},
function buildPipeline(abi, callback) {
Embark.monitor.setStatus("Building Assets");
var pipeline = new Pipeline({
buildDir: self.config.buildDir,
contractsFiles: self.config.contractsFiles,
assetFiles: self.config.assetFiles,
logger: self.logger
});
pipeline.build(abi);
callback();
},
self.buildDeployGenerate.bind(self),
function startAssetServer(callback) {
Embark.monitor.setStatus("Starting Server");
var server = new Server({logger: self.logger, port: options.serverPort});
@ -252,6 +200,43 @@ var Embark = {
});
},
buildDeployGenerate: function(done) {
var self = this;
async.waterfall([
function deployAndBuildContractsManager(callback) {
Embark.monitor.setStatus("Deploying Contracts");
Embark.buildAndDeploy(function(contractsManager) {
callback(null, contractsManager);
});
},
function generateConsoleABI(contractsManager, callback) {
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
var consoleABI = abiGenerator.generateABI({useEmbarkJS: false});
Embark.console.runCode(consoleABI);
callback(null, contractsManager);
},
function generateABI(contractsManager, callback) {
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
callback(null, abiGenerator.generateABI({useEmbarkJS: true}));
},
function buildPipeline(abi, callback) {
Embark.monitor.setStatus("Building Assets");
var pipeline = new Pipeline({
buildDir: self.config.buildDir,
contractsFiles: self.config.contractsFiles,
assetFiles: self.config.assetFiles,
logger: self.logger
});
pipeline.build(abi);
callback();
}
], function(err, result) {
done(result);
});
},
initTests: function(options) {
return new Test(options);
},