diff --git a/lib/core/config.js b/lib/core/config.js index 954f529a..048c7f89 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -37,21 +37,24 @@ Config.prototype.loadConfigFiles = function(options) { this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs}); this.plugins.loadPlugins(); - this.loadPipelineConfigFile(); + this.loadEmbarkConfigFile(); this.loadBlockchainConfigFile(); this.loadStorageConfigFile(); this.loadCommunicationConfigFile(); + this.loadPipelineConfigFile(); + this.loadContractsConfigFile(); this.loadChainTrackerFile(); this.loadPluginContractFiles(); }; Config.prototype.reloadConfig = function() { - this.loadPipelineConfigFile(); + this.loadEmbarkConfigFile(); this.loadBlockchainConfigFile(); this.loadStorageConfigFile(); this.loadCommunicationConfigFile(); + this.loadPipelineConfigFile(); this.loadContractsConfigFile(); this.loadChainTrackerFile(); }; @@ -59,6 +62,10 @@ Config.prototype.reloadConfig = function() { Config.prototype.loadBlockchainConfigFile = function() { var defaultBlockchainConfig = fs.readJSONSync(this.configDir + "blockchain.json"); this.blockchainConfig = defaultBlockchainConfig[this.env]; + + if (this.blockchainConfig.enabled === undefined) { + this.blockchainConfig.enabled = true; + } }; Config.prototype.loadContractsConfigFile = function() { @@ -103,6 +110,10 @@ Config.prototype.loadStorageConfigFile = function() { var mergedConfig = utils.recursiveMerge(defaultStorageConfig, envStorageConfig); this.storageConfig = mergedConfig; + + if (this.storageConfig.enabled === undefined) { + this.storageConfig.enabled = true; + } }; Config.prototype.loadCommunicationConfigFile = function() { @@ -124,19 +135,25 @@ Config.prototype.loadCommunicationConfigFile = function() { var mergedConfig = utils.recursiveMerge(defaultCommunicationConfig, envCommunicationConfig); this.communicationConfig = mergedConfig; + + if (this.communicationConfig.enabled === undefined) { + this.communicationConfig.enabled = true; + } }; -Config.prototype.loadPipelineConfigFile = function() { +Config.prototype.loadEmbarkConfigFile = function() { var contracts = this.embarkConfig.contracts; this.contractsFiles = this.loadFiles(contracts); + this.buildDir = this.embarkConfig.buildDir; + this.configDir = this.embarkConfig.config; +}; + +Config.prototype.loadPipelineConfigFile = function() { var assets = this.embarkConfig.app; for(var targetFile in assets) { this.assetFiles[targetFile] = this.loadFiles(assets[targetFile]); } - - this.buildDir = this.embarkConfig.buildDir; - this.configDir = this.embarkConfig.config; }; Config.prototype.loadChainTrackerFile = function() { @@ -163,11 +180,21 @@ Config.prototype.loadFiles = function(files) { return file.indexOf('.') >= 0; }).filter(function(file) { if (file === 'embark.js') { - readFiles.push({filename: 'web3.js', content: fs.readFileSync(fs.embarkPath("js/web3.js")).toString(), path: fs.embarkPath("js/web3.js")}); - readFiles.push({filename: 'ipfs.js', content: fs.readFileSync(fs.embarkPath("js/ipfs.js")).toString(), path: fs.embarkPath("js/ipfs.js")}); - // TODO: remove duplicated files if funcitonality is the same for storage and orbit - readFiles.push({filename: 'ipfs-api.js', content: fs.readFileSync(fs.embarkPath("js/ipfs-api.min.js")).toString(), path: fs.embarkPath("js/ipfs-api.min.js")}); - readFiles.push({filename: 'orbit.js', content: fs.readFileSync(fs.embarkPath("js/orbit.min.js")).toString(), path: fs.embarkPath("js/orbit.min.js")}); + + if (self.blockchainConfig.enabled || self.communicationConfig.provider === 'whisper') { + readFiles.push({filename: 'web3.js', content: fs.readFileSync(fs.embarkPath("js/web3.js")).toString(), path: fs.embarkPath("js/web3.js")}); + } + + if (self.storageConfig.enabled && self.storageConfig.provider === 'ipfs') { + readFiles.push({filename: 'ipfs.js', content: fs.readFileSync(fs.embarkPath("js/ipfs.js")).toString(), path: fs.embarkPath("js/ipfs.js")}); + } + + if (self.communicationConfig.enabled && self.communicationConfig.provider === 'orbit') { + // TODO: remove duplicated files if functionality is the same for storage and orbit + readFiles.push({filename: 'ipfs-api.js', content: fs.readFileSync(fs.embarkPath("js/ipfs-api.min.js")).toString(), path: fs.embarkPath("js/ipfs-api.min.js")}); + readFiles.push({filename: 'orbit.js', content: fs.readFileSync(fs.embarkPath("js/orbit.min.js")).toString(), path: fs.embarkPath("js/orbit.min.js")}); + } + readFiles.push({filename: 'embark.js', content: fs.readFileSync(fs.embarkPath("js/build/embark.bundle.js")).toString(), path: fs.embarkPath("js/build/embark.bundle.js")}); } }); diff --git a/test_app/config/communication.json b/test_app/config/communication.json index bccfad7d..264cc646 100644 --- a/test_app/config/communication.json +++ b/test_app/config/communication.json @@ -1,6 +1,6 @@ { "default": { - "enabled": false, + "enabled": true, "provider": "whisper" } }