revert versions update for now; support granular config on embark json

This commit is contained in:
Iuri Matias 2018-03-31 21:06:00 -04:00
parent 03f0b07d81
commit bab0171120
6 changed files with 49 additions and 81 deletions

View File

@ -63,8 +63,11 @@ Config.prototype.reloadConfig = function() {
this.loadChainTrackerFile();
};
Config.prototype._mergeConfig = function(configFilename, defaultConfig, env) {
let configFilePath = this.configDir + configFilename;
Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env) {
if (!configFilePath) {
return defaultConfig['default'] || {};
}
if (!fs.existsSync(configFilePath)) {
this.logger.warn("no config file found at " + configFilePath + ". using default config");
return defaultConfig['default'] || {};
@ -80,6 +83,13 @@ Config.prototype._mergeConfig = function(configFilename, defaultConfig, env) {
}
};
Config.prototype._getFileOrOject = function(object, filePath, property) {
if (typeof(this.configDir) === 'object') {
return this.configDir[property];
}
return this.configDir + filepath;
};
Config.prototype.loadBlockchainConfigFile = function() {
var configObject = {
"default": {
@ -91,12 +101,15 @@ Config.prototype.loadBlockchainConfigFile = function() {
};
Config.prototype.loadContractsConfigFile = function() {
var defaultVersions = {
"web3.js": "1.0.0-beta",
"solc": "0.4.17"
}
var versions = utils.recursiveMerge(defaultVersions, this.embarkConfig.versions || {});
var configObject = {
"default": {
"versions": this.embarkConfig.versions || {
"web3.js": "1.0.0-beta",
"solc": "0.4.17"
},
"versions": versions,
"deployment": {
"host": "localhost", "port": 8545, "type": "rpc"
},
@ -115,15 +128,17 @@ Config.prototype.loadContractsConfigFile = function() {
configObject = utils.recursiveMerge(configObject, pluginConfig);
});
this.contractsConfig = this._mergeConfig("contracts.json", configObject, this.env);
let configFilePath = this._getFileOrOject(this.configDir, 'contracts.json', 'contracts');
this.contractsConfig = this._mergeConfig(configFilePath, configObject, this.env);
};
Config.prototype.loadStorageConfigFile = function() {
var versions = utils.recursiveMerge({"ipfs-api": "17.2.4"}, this.embarkConfig.versions || {});
var configObject = {
"default": {
"versions": this.embarkConfig.versions || {
"ipfs-api": "17.2.4"
},
"versions": versions,
"enabled": true,
"available_providers": ["ipfs"],
"ipfs_bin": "ipfs",
@ -134,7 +149,9 @@ Config.prototype.loadStorageConfigFile = function() {
}
};
this.storageConfig = this._mergeConfig("storage.json", configObject, this.env);
let configFilePath = this._getFileOrOject(this.configDir, 'storage.json', 'storage');
this.storageConfig = this._mergeConfig(configFilePath, configObject, this.env);
};
Config.prototype.loadCommunicationConfigFile = function() {
@ -149,7 +166,9 @@ Config.prototype.loadCommunicationConfigFile = function() {
}
};
this.communicationConfig = this._mergeConfig("communication.json", configObject, this.env);
let configFilePath = this._getFileOrOject(this.configDir, 'communication.json', 'communication');
this.communicationConfig = this._mergeConfig(configFilePath, configObject, this.env);
};
Config.prototype.loadWebServerConfigFile = function() {
@ -157,7 +176,9 @@ Config.prototype.loadWebServerConfigFile = function() {
"enabled": true, "host": "localhost", "port": 8000
};
this.webServerConfig = this._mergeConfig("webserver.json", configObject, false);
let configFilePath = this._getFileOrOject(this.configDir, 'webserver.json', 'webserver');
this.webServerConfig = this._mergeConfig(configFilePath, configObject, false);
};
Config.prototype.loadEmbarkConfigFile = function() {

View File

@ -2,7 +2,12 @@
"contracts": ["contracts/**"],
"app": {},
"buildDir": "build/",
"config": "./",
"config": {
"contracts": "contracts.json",
"storage": false,
"communication": false,
"webserver": false
},
"versions": {
"solc": "0.4.17"
},

View File

@ -1,64 +1 @@
{
"0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f": {
"contracts": {
"0x79f903ab722af0e1fec06f910aa64dc71fd3023e232a946b35432f757d951bc0": {
"name": "AlreadyDeployedToken",
"address": "0xece374063fe5cc7efbaca0a498477cada94e5ad6"
}
},
"name": "development"
},
"0xbdcd0ba5d78a96b065bbd5b272d31f2d33960b0f53949f6a8c49c4fe1a52fd6a": {
"contracts": {
"0x79f903ab722af0e1fec06f910aa64dc71fd3023e232a946b35432f757d951bc0": {
"name": "AlreadyDeployedToken",
"address": "0xece374063fe5cc7efbaca0a498477cada94e5ad6"
},
"0x0e0275c10e511f694564b0c4e3def28e38fe6ba0c1f26ab6c1cb86fdd73a3287": {
"name": "Assert",
"address": "0x5Eb2130A982D279e597226fD339Eb155f7171B91"
},
"0x53a9493497f8764439f2b6062994f8fe3d3c5a66450099244c0f8f32185a15df": {
"name": "ContractArgs",
"address": "0x3B904C882523b36Edd8c9813db6aCE6cBa416060"
},
"0xd1b69fd42ab462fb8af1009558bf53dbcc873ee43b3f759afcd54aabb4640338": {
"name": "ZAMyLib2",
"address": "0x71cd20193D37D0C7272B8d6b8ce1DB924c49c1D4"
},
"0x0d2c4116b7b36aec94353056c6f2ffd4179b1121b98d89164106df61d617d427": {
"name": "Test2",
"address": "0x4B3643eB81709cb1b2040ae1E80d8EF419920AB6"
},
"0x21ec9fef260b27aeb3220343703c4e9754a312c6be64dc09170c322302ae438f": {
"name": "MyToken2",
"address": "0x95eBb3E309CFa837d34578e24cdd7A72Fed2E94f"
},
"0x6cefd24d92c98376fa48a4b79fa31b4411bff757599d56154a46369cca076f5c": {
"name": "SimpleStorage",
"address": "0xf400925155a8ED845a15b3f1c4C4984f31645A07"
},
"0x10aca9d1539d14b113ec96c606e8e3195d81722746f9eda13d2fdb887e2e78aa": {
"name": "SomeContract",
"address": "0x8BD7C0AeC1E7a32A97A1E310EE79C1A1e8fa7D53"
},
"0x44e732146c5700a2e4cead0a5cd5d94047fbf6b5149ab7d7814fc874d66d4649": {
"name": "MyToken",
"address": "0xbbF2721136ce2F2C69FE3809de39cb5f1d54125C"
},
"0x926ab20d492caa04f4c9b91ae0394da1a49689e1984278a8161d1b96332ba8e5": {
"name": "ZAMyLib",
"address": "0xa206287309074D383E74B912aa3b167E2C0BA82B"
},
"0xba49165b12f1fbd15c17caf1b3d55d30b9607f1d74102732106ce1575df4bb1d": {
"name": "Test",
"address": "0x9c0cAb4FA09b09A8b3Ee63a7254332682a45D4B7"
},
"0xf12b466f58dbc8d8ce3a0f0a5549bc3184f4e4522c7c15c185320287cc818f9d": {
"name": "AnotherStorage",
"address": "0xb61d417D82C1abA973d2061Cd6e017F194A5afc1"
}
},
"name": "development"
}
}
{}

View File

@ -2,7 +2,7 @@
"default": {
"versions": {
"web3.js": "1.0.0-beta.27",
"solc": "0.4.18"
"solc": "0.4.17"
},
"deployment": {
"host": "localhost",

View File

@ -2,7 +2,12 @@
"contracts": ["contracts/**"],
"app": {},
"buildDir": "build/",
"config": "./",
"config": {
"contracts": "contracts.json",
"storage": false,
"communication": false,
"webserver": false
},
"versions": {
"web3.js": "1.0.0-beta",
"solc": "0.4.17"

View File

@ -16,7 +16,7 @@
"config": "config/",
"versions": {
"web3.js": "1.0.0-beta.27",
"solc": "0.4.18",
"solc": "0.4.17",
"ipfs-api": "17.2.6"
},
"plugins": {