mirror of https://github.com/embarklabs/embark.git
Merge pull request #412 from embark-framework/js_config
support for js configs
This commit is contained in:
commit
a03757a5e6
|
@ -75,7 +75,9 @@ Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env, ena
|
|||
return configToReturn;
|
||||
}
|
||||
|
||||
if (!fs.existsSync(configFilePath)) {
|
||||
// due to embark.json; TODO: refactor this
|
||||
configFilePath = configFilePath.replace('.js', '').replace('.json','');
|
||||
if (!fs.existsSync(configFilePath + '.js') && !fs.existsSync(configFilePath + '.json')) {
|
||||
// TODO: remove this if
|
||||
if (this.logger) {
|
||||
this.logger.warn(__("no config file found at %s using default config", configFilePath));
|
||||
|
@ -83,7 +85,12 @@ Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env, ena
|
|||
return defaultConfig['default'] || {};
|
||||
}
|
||||
|
||||
let config = fs.readJSONSync(configFilePath);
|
||||
let config;
|
||||
if (fs.existsSync(configFilePath + '.js')) {
|
||||
config = require(fs.dappPath(configFilePath + '.js'));
|
||||
} else {
|
||||
config = fs.readJSONSync(configFilePath + '.json');
|
||||
}
|
||||
let configObject = utils.recursiveMerge(defaultConfig, config);
|
||||
|
||||
if (env) {
|
||||
|
@ -109,7 +116,7 @@ Config.prototype.loadBlockchainConfigFile = function() {
|
|||
}
|
||||
};
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'blockchain.json', 'blockchain');
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'blockchain', 'blockchain');
|
||||
|
||||
this.blockchainConfig = this._mergeConfig(configFilePath, configObject, this.env, true);
|
||||
};
|
||||
|
@ -142,7 +149,7 @@ Config.prototype.loadContractsConfigFile = function() {
|
|||
configObject = utils.recursiveMerge(configObject, pluginConfig);
|
||||
});
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'contracts.json', 'contracts');
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'contracts', 'contracts');
|
||||
|
||||
const newContractsConfig = this._mergeConfig(configFilePath, configObject, this.env);
|
||||
|
||||
|
@ -193,7 +200,7 @@ Config.prototype.loadStorageConfigFile = function() {
|
|||
}
|
||||
};
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'storage.json', 'storage');
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'storage', 'storage');
|
||||
|
||||
this.storageConfig = this._mergeConfig(configFilePath, configObject, this.env);
|
||||
};
|
||||
|
@ -210,7 +217,7 @@ Config.prototype.loadCommunicationConfigFile = function() {
|
|||
}
|
||||
};
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'communication.json', 'communication');
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'communication', 'communication');
|
||||
|
||||
this.communicationConfig = this._mergeConfig(configFilePath, configObject, this.env);
|
||||
};
|
||||
|
@ -220,7 +227,7 @@ Config.prototype.loadWebServerConfigFile = function() {
|
|||
"enabled": true, "host": "localhost", "port": 8000
|
||||
};
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'webserver.json', 'webserver');
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'webserver', 'webserver');
|
||||
|
||||
this.webServerConfig = this._mergeConfig(configFilePath, configObject, false);
|
||||
};
|
||||
|
|
|
@ -9929,7 +9929,6 @@
|
|||
"resolved": "https://registry.npmjs.org/taskgroup/-/taskgroup-4.3.1.tgz",
|
||||
"integrity": "sha1-feGT/r12gnPEV3MElwJNUSwnkVo=",
|
||||
"requires": {
|
||||
"ambi": "2.5.0",
|
||||
"csextends": "1.2.0"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
module.exports = {
|
||||
// default applies to all enviroments
|
||||
default: {
|
||||
// rpc to deploy the contracts
|
||||
deployment: {
|
||||
host: "localhost",
|
||||
port: 8545,
|
||||
type: "rpc"
|
||||
},
|
||||
// order of connections the dapp should connect to
|
||||
dappConnection: [
|
||||
"$WEB3", // uses pre existing web3 object if available (e.g in Mist)
|
||||
"http://localhost:8545"
|
||||
],
|
||||
gas: "auto",
|
||||
contracts: {
|
||||
// example:
|
||||
//SimpleStorage: {
|
||||
// args: [ 100 ]
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"default": {
|
||||
"deployment": {
|
||||
"host": "localhost",
|
||||
"port": 8545,
|
||||
"type": "rpc"
|
||||
},
|
||||
"dappConnection": [
|
||||
"$WEB3",
|
||||
"http://localhost:8545"
|
||||
],
|
||||
"gas": "auto",
|
||||
"contracts": {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
module.exports = {
|
||||
// default applies to all enviroments
|
||||
default: {
|
||||
// rpc to deploy the contracts
|
||||
deployment: {
|
||||
host: "localhost",
|
||||
port: 8545,
|
||||
type: "rpc"
|
||||
},
|
||||
// order of connections the dapp should connect to
|
||||
dappConnection: [
|
||||
"$WEB3", // uses pre existing web3 object if available (e.g in Mist)
|
||||
"http://localhost:8545"
|
||||
],
|
||||
gas: "auto",
|
||||
contracts: {
|
||||
SimpleStorage: {
|
||||
fromIndex: 0,
|
||||
args: [ 100 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"default": {
|
||||
"deployment": {
|
||||
"host": "localhost",
|
||||
"port": 8545,
|
||||
"type": "rpc"
|
||||
},
|
||||
"dappConnection": [
|
||||
"$WEB3",
|
||||
"http://localhost:8545"
|
||||
],
|
||||
"gas": "auto",
|
||||
"contracts": {
|
||||
"SimpleStorage": {
|
||||
"fromIndex": 0,
|
||||
"args": [
|
||||
100
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
module.exports = {
|
||||
// default applies to all enviroments
|
||||
default: {
|
||||
// rpc to deploy the contracts
|
||||
deployment: {
|
||||
host: "localhost",
|
||||
port: 8545,
|
||||
type: "rpc"
|
||||
},
|
||||
// order of connections the dapp should connect to
|
||||
dappConnection: [
|
||||
"$WEB3", // uses pre existing web3 object if available (e.g in Mist)
|
||||
"http://localhost:8545"
|
||||
],
|
||||
gas: "auto",
|
||||
contracts: {
|
||||
// example:
|
||||
//SimpleStorage: {
|
||||
// args: [ 100 ]
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"default": {
|
||||
"deployment": {
|
||||
"host": "localhost",
|
||||
"port": 8545,
|
||||
"type": "rpc"
|
||||
},
|
||||
"dappConnection": [
|
||||
"$WEB3",
|
||||
"http://localhost:8545"
|
||||
],
|
||||
"gas": "auto",
|
||||
"contracts": {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
"app": {},
|
||||
"buildDir": "build/",
|
||||
"config": {
|
||||
"contracts": "contracts.json",
|
||||
"contracts": "contracts.js",
|
||||
"blockchain": false,
|
||||
"storage": false,
|
||||
"communication": false,
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
module.exports = {
|
||||
default: {
|
||||
deployment: {
|
||||
host: "localhost",
|
||||
port: 8545,
|
||||
type: "rpc"
|
||||
},
|
||||
dappConnection: [
|
||||
"$WEB3",
|
||||
"ws://localhost:8546",
|
||||
"http://localhost:8550",
|
||||
"http://localhost:8545",
|
||||
"http://localhost:8550"
|
||||
],
|
||||
gas: "auto",
|
||||
contracts: {
|
||||
Ownable: {
|
||||
deploy: false
|
||||
},
|
||||
SimpleStorage: {
|
||||
fromIndex: 0,
|
||||
args: [
|
||||
100
|
||||
]
|
||||
},
|
||||
AnotherStorage: {
|
||||
args: [
|
||||
"$SimpleStorage"
|
||||
]
|
||||
},
|
||||
Token: {
|
||||
deploy: false,
|
||||
args: [1000]
|
||||
},
|
||||
Test: {
|
||||
onDeploy: [
|
||||
"Test.methods.changeAddress('$MyToken')"
|
||||
]
|
||||
},
|
||||
MyToken: {
|
||||
instanceOf: "Token"
|
||||
},
|
||||
MyToken2: {
|
||||
instanceOf: "Token",
|
||||
args: [200]
|
||||
},
|
||||
AlreadyDeployedToken: {
|
||||
address: "0xece374063fe5cc7efbaca0a498477cada94e5ad6",
|
||||
instanceOf: "Token"
|
||||
},
|
||||
MyToken3: {
|
||||
instanceOf: "Tokn"
|
||||
},
|
||||
ContractArgs: {
|
||||
args: {
|
||||
initialValue: 123,
|
||||
"_addresses": ["$MyToken2", "$SimpleStorage"]
|
||||
}
|
||||
},
|
||||
SomeContract: {
|
||||
args: [
|
||||
["$MyToken2", "$SimpleStorage"],
|
||||
100
|
||||
]
|
||||
},
|
||||
ERC20: {
|
||||
file: "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"
|
||||
},
|
||||
SimpleStorageTest: {
|
||||
file: "./some_folder/test_contract.sol",
|
||||
args: [
|
||||
1000
|
||||
]
|
||||
},
|
||||
Identity: {
|
||||
file: "https://github.com/status-im/contracts/blob/master/contracts/identity/Identity.sol"
|
||||
},
|
||||
SimpleStorageWithHttpImport: {
|
||||
fromIndex: 0,
|
||||
args: [
|
||||
100
|
||||
]
|
||||
}
|
||||
},
|
||||
afterDeploy: [
|
||||
"Test.methods.changeAddress('$MyToken')",
|
||||
"web3.eth.getAccounts((err, accounts) => Test.methods.changeAddress(accounts[0]))"
|
||||
]
|
||||
},
|
||||
development: {
|
||||
contracts: {
|
||||
MyToken2: {
|
||||
instanceOf: "Token",
|
||||
args: [2000]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,98 +0,0 @@
|
|||
{
|
||||
"default": {
|
||||
"deployment": {
|
||||
"host": "localhost",
|
||||
"port": 8545,
|
||||
"type": "rpc"
|
||||
},
|
||||
"dappConnection": [
|
||||
"$WEB3",
|
||||
"ws://localhost:8546",
|
||||
"http://localhost:8550",
|
||||
"http://localhost:8545",
|
||||
"http://localhost:8550"
|
||||
],
|
||||
"gas": "auto",
|
||||
"contracts": {
|
||||
"Ownable": {
|
||||
"deploy": false
|
||||
},
|
||||
"SimpleStorage": {
|
||||
"fromIndex": 0,
|
||||
"args": [
|
||||
100
|
||||
]
|
||||
},
|
||||
"AnotherStorage": {
|
||||
"args": [
|
||||
"$SimpleStorage"
|
||||
]
|
||||
},
|
||||
"Token": {
|
||||
"deploy": false,
|
||||
"args": [1000]
|
||||
},
|
||||
"Test": {
|
||||
"onDeploy": [
|
||||
"Test.methods.changeAddress('$MyToken')"
|
||||
]
|
||||
},
|
||||
"MyToken": {
|
||||
"instanceOf": "Token"
|
||||
},
|
||||
"MyToken2": {
|
||||
"instanceOf": "Token",
|
||||
"args": [200]
|
||||
},
|
||||
"AlreadyDeployedToken": {
|
||||
"address": "0xece374063fe5cc7efbaca0a498477cada94e5ad6",
|
||||
"instanceOf": "Token"
|
||||
},
|
||||
"MyToken3": {
|
||||
"instanceOf": "Tokn"
|
||||
},
|
||||
"ContractArgs": {
|
||||
"args": {
|
||||
"initialValue": 123,
|
||||
"_addresses": ["$MyToken2", "$SimpleStorage"]
|
||||
}
|
||||
},
|
||||
"SomeContract": {
|
||||
"args": [
|
||||
["$MyToken2", "$SimpleStorage"],
|
||||
100
|
||||
]
|
||||
},
|
||||
"ERC20": {
|
||||
"file": "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"
|
||||
},
|
||||
"SimpleStorageTest": {
|
||||
"file": "./some_folder/test_contract.sol",
|
||||
"args": [
|
||||
1000
|
||||
]
|
||||
},
|
||||
"Identity": {
|
||||
"file": "https://github.com/status-im/contracts/blob/master/contracts/identity/Identity.sol"
|
||||
},
|
||||
"SimpleStorageWithHttpImport": {
|
||||
"fromIndex": 0,
|
||||
"args": [
|
||||
100
|
||||
]
|
||||
}
|
||||
},
|
||||
"afterDeploy": [
|
||||
"Test.methods.changeAddress('$MyToken')",
|
||||
"web3.eth.getAccounts((err, accounts) => Test.methods.changeAddress(accounts[0]))"
|
||||
]
|
||||
},
|
||||
"development": {
|
||||
"contracts": {
|
||||
"MyToken2": {
|
||||
"instanceOf": "Token",
|
||||
"args": [2000]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue