2017-03-31 11:39:33 +00:00
|
|
|
var fs = require('./fs.js');
|
2017-07-05 12:35:51 +00:00
|
|
|
var File = require('./file.js');
|
2017-03-31 11:39:33 +00:00
|
|
|
var Plugins = require('./plugins.js');
|
|
|
|
var utils = require('../utils/utils.js');
|
2017-07-05 22:26:44 +00:00
|
|
|
var Npm = require('../pipeline/npm.js');
|
2017-07-06 23:50:36 +00:00
|
|
|
let currentWeb3Version = require('../../package.json').dependencies.web3.replace("^","");
|
2016-08-22 03:40:05 +00:00
|
|
|
|
2016-09-25 01:10:47 +00:00
|
|
|
// TODO: add wrapper for fs so it can also work in the browser
|
|
|
|
// can work with both read and save
|
2017-03-31 11:39:33 +00:00
|
|
|
var Config = function(options) {
|
|
|
|
this.env = options.env;
|
|
|
|
this.blockchainConfig = {};
|
|
|
|
this.contractsConfig = {};
|
|
|
|
this.pipelineConfig = {};
|
|
|
|
this.webServerConfig = {};
|
|
|
|
this.chainTracker = {};
|
|
|
|
this.assetFiles = {};
|
|
|
|
this.contractsFiles = [];
|
|
|
|
this.configDir = options.configDir || 'config/';
|
|
|
|
this.chainsFile = options.chainsFile || './chains.json';
|
|
|
|
this.plugins = options.plugins;
|
|
|
|
this.logger = options.logger;
|
|
|
|
this.events = options.events;
|
|
|
|
};
|
2016-08-22 03:40:05 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadConfigFiles = function(options) {
|
|
|
|
var interceptLogs = options.interceptLogs;
|
2017-02-06 11:42:58 +00:00
|
|
|
if (options.interceptLogs === undefined) {
|
|
|
|
interceptLogs = true;
|
|
|
|
}
|
2017-02-21 20:45:10 +00:00
|
|
|
|
|
|
|
//Check if the config file exists
|
2017-03-31 11:39:33 +00:00
|
|
|
var embarkConfigExists = fs.existsSync(options.embarkConfig);
|
|
|
|
if(!embarkConfigExists){
|
2017-02-21 20:45:10 +00:00
|
|
|
this.logger.error('Cannot find file ' + options.embarkConfig + '. Please ensure you are running this command inside the Dapp folder');
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2017-02-19 03:40:42 +00:00
|
|
|
this.embarkConfig = fs.readJSONSync(options.embarkConfig);
|
2017-01-29 06:28:01 +00:00
|
|
|
this.embarkConfig.plugins = this.embarkConfig.plugins || {};
|
2016-08-22 03:40:05 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs, events: this.events, config: this});
|
2017-01-26 11:34:00 +00:00
|
|
|
this.plugins.loadPlugins();
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
this.loadEmbarkConfigFile();
|
|
|
|
this.loadBlockchainConfigFile();
|
|
|
|
this.loadStorageConfigFile();
|
|
|
|
this.loadCommunicationConfigFile();
|
|
|
|
|
2017-07-05 12:35:51 +00:00
|
|
|
this.loadContractsConfigFile();
|
2017-03-31 11:39:33 +00:00
|
|
|
this.loadPipelineConfigFile();
|
|
|
|
|
2017-03-29 17:04:35 +00:00
|
|
|
this.loadWebServerConfigFile();
|
|
|
|
this.loadChainTrackerFile();
|
|
|
|
this.loadPluginContractFiles();
|
2016-08-22 03:40:05 +00:00
|
|
|
};
|
2016-09-23 08:37:15 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.reloadConfig = function() {
|
2017-03-01 02:26:15 +00:00
|
|
|
this.loadEmbarkConfigFile();
|
2016-09-23 08:37:15 +00:00
|
|
|
this.loadBlockchainConfigFile();
|
2017-02-10 12:44:06 +00:00
|
|
|
this.loadStorageConfigFile();
|
|
|
|
this.loadCommunicationConfigFile();
|
2016-09-23 08:37:15 +00:00
|
|
|
this.loadContractsConfigFile();
|
2017-07-05 12:35:51 +00:00
|
|
|
this.loadPipelineConfigFile();
|
2016-09-25 01:10:47 +00:00
|
|
|
this.loadChainTrackerFile();
|
2016-09-23 08:37:15 +00:00
|
|
|
};
|
2016-08-22 03:40:05 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadBlockchainConfigFile = function() {
|
|
|
|
var defaultBlockchainConfig = fs.readJSONSync(this.configDir + "blockchain.json");
|
2017-03-03 06:22:12 +00:00
|
|
|
this.blockchainConfig = defaultBlockchainConfig[this.env] || {};
|
2017-03-01 02:26:15 +00:00
|
|
|
|
|
|
|
if (this.blockchainConfig.enabled === undefined) {
|
|
|
|
this.blockchainConfig.enabled = true;
|
|
|
|
}
|
2016-08-22 03:40:05 +00:00
|
|
|
};
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadContractsConfigFile = function() {
|
2017-01-26 11:34:00 +00:00
|
|
|
|
2017-07-06 00:24:28 +00:00
|
|
|
var configObject = {
|
2017-07-06 22:48:20 +00:00
|
|
|
"versions": {
|
|
|
|
"web3.js": "0.19.1",
|
2017-10-21 19:17:54 +00:00
|
|
|
"solc": "0.4.18"
|
2017-07-06 22:48:20 +00:00
|
|
|
},
|
|
|
|
"deployment": {
|
2017-07-06 00:24:28 +00:00
|
|
|
"host": "localhost",
|
|
|
|
"port": 8545,
|
|
|
|
"type": "rpc"
|
2017-07-06 22:48:20 +00:00
|
|
|
},
|
|
|
|
"dappConnection": [
|
|
|
|
"$WEB3",
|
|
|
|
"localhost:8545"
|
|
|
|
]
|
2017-07-06 00:24:28 +00:00
|
|
|
};
|
2017-03-31 11:39:33 +00:00
|
|
|
|
|
|
|
var configPlugins = this.plugins.getPluginsFor('contractsConfig');
|
2017-01-26 11:34:00 +00:00
|
|
|
if (configPlugins.length > 0) {
|
2017-03-31 11:39:33 +00:00
|
|
|
configPlugins.forEach(function(plugin) {
|
|
|
|
plugin.contractsConfigs.forEach(function(pluginConfig) {
|
2017-02-18 19:45:57 +00:00
|
|
|
configObject = utils.recursiveMerge(configObject, pluginConfig);
|
2017-01-26 11:34:00 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
var contractsConfig = fs.readJSONSync(this.configDir + "contracts.json");
|
2017-02-18 19:45:57 +00:00
|
|
|
configObject = utils.recursiveMerge(configObject, contractsConfig);
|
2017-03-31 11:39:33 +00:00
|
|
|
var defaultContractsConfig = configObject['default'];
|
|
|
|
var envContractsConfig = configObject[this.env];
|
2016-08-22 03:40:05 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
var mergedConfig = utils.recursiveMerge(defaultContractsConfig, envContractsConfig);
|
|
|
|
this.contractsConfig = mergedConfig;
|
2016-08-22 03:40:05 +00:00
|
|
|
};
|
|
|
|
|
2017-02-10 12:44:06 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadStorageConfigFile = function() {
|
|
|
|
var configObject = {
|
2017-03-06 02:27:33 +00:00
|
|
|
"default": {
|
|
|
|
"enabled": true,
|
|
|
|
"available_providers": ["ipfs"],
|
|
|
|
"ipfs_bin": "ipfs",
|
|
|
|
"provider": "ipfs",
|
|
|
|
"host": "localhost",
|
2017-07-23 12:15:40 +00:00
|
|
|
"port": 5001,
|
|
|
|
"getUrl": "http://localhost:8080/ipfs/"
|
2017-03-06 02:27:33 +00:00
|
|
|
},
|
2017-03-31 11:39:33 +00:00
|
|
|
"development": {
|
|
|
|
}
|
2017-03-06 02:27:33 +00:00
|
|
|
};
|
2017-02-10 12:44:06 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
//var configPlugins = this.plugins.getPluginsFor('storageConfig');
|
2017-02-10 12:44:06 +00:00
|
|
|
//if (configPlugins.length > 0) {
|
|
|
|
// configPlugins.forEach(function(plugin) {
|
|
|
|
// plugin.contractsConfigs.forEach(function(pluginConfig) {
|
2017-02-18 19:45:57 +00:00
|
|
|
// configObject = utils.recursiveMerge(configObject, pluginConfig);
|
2017-02-10 12:44:06 +00:00
|
|
|
// });
|
|
|
|
// });
|
|
|
|
//}
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
var storageConfig;
|
2017-03-06 02:27:33 +00:00
|
|
|
if (fs.existsSync(this.configDir + "storage.json")) {
|
|
|
|
storageConfig = fs.readJSONSync(this.configDir + "storage.json");
|
|
|
|
configObject = utils.recursiveMerge(configObject, storageConfig);
|
|
|
|
}
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
var defaultStorageConfig = configObject['default'];
|
|
|
|
var envStorageConfig = configObject[this.env];
|
2017-02-10 12:44:06 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
var mergedConfig = utils.recursiveMerge(defaultStorageConfig, envStorageConfig);
|
2017-03-03 06:22:12 +00:00
|
|
|
this.storageConfig = mergedConfig || {};
|
2017-03-01 02:26:15 +00:00
|
|
|
|
|
|
|
if (this.storageConfig.enabled === undefined) {
|
|
|
|
this.storageConfig.enabled = true;
|
|
|
|
}
|
2017-03-01 02:43:03 +00:00
|
|
|
if (this.storageConfig.available_providers === undefined) {
|
|
|
|
this.storageConfig.available_providers = [];
|
|
|
|
}
|
2017-02-10 12:44:06 +00:00
|
|
|
};
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadCommunicationConfigFile = function() {
|
|
|
|
var configObject = {
|
2017-03-06 02:27:33 +00:00
|
|
|
"default": {
|
|
|
|
"enabled": true,
|
|
|
|
"provider": "whisper",
|
2017-10-19 22:55:49 +00:00
|
|
|
"available_providers": ["whisper", "orbit"],
|
|
|
|
"connection": {
|
|
|
|
"host": "localhost",
|
|
|
|
"port": 8546,
|
|
|
|
"type": "ws"
|
|
|
|
}
|
2017-03-06 02:27:33 +00:00
|
|
|
}
|
|
|
|
};
|
2017-02-10 12:44:06 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
//var configPlugins = this.plugins.getPluginsFor('communicationConfig');
|
2017-02-10 12:44:06 +00:00
|
|
|
//if (configPlugins.length > 0) {
|
|
|
|
// configPlugins.forEach(function(plugin) {
|
|
|
|
// plugin.contractsConfigs.forEach(function(pluginConfig) {
|
2017-02-18 19:45:57 +00:00
|
|
|
// configObject = utils.recursiveMerge(configObject, pluginConfig);
|
2017-02-10 12:44:06 +00:00
|
|
|
// });
|
|
|
|
// });
|
|
|
|
//}
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
var communicationConfig;
|
2017-03-06 02:27:33 +00:00
|
|
|
|
|
|
|
if (fs.existsSync(this.configDir + "communication.json")) {
|
|
|
|
communicationConfig = fs.readJSONSync(this.configDir + "communication.json");
|
|
|
|
configObject = utils.recursiveMerge(configObject, communicationConfig);
|
|
|
|
}
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
var defaultCommunicationConfig = configObject['default'];
|
|
|
|
var envCommunicationConfig = configObject[this.env];
|
2017-02-10 12:44:06 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
var mergedConfig = utils.recursiveMerge(defaultCommunicationConfig, envCommunicationConfig);
|
2017-03-03 06:22:12 +00:00
|
|
|
this.communicationConfig = mergedConfig || {};
|
2017-03-01 02:26:15 +00:00
|
|
|
|
2017-03-06 02:27:33 +00:00
|
|
|
// TODO: probably not necessary if the default object is done right
|
2017-03-01 02:26:15 +00:00
|
|
|
if (this.communicationConfig.enabled === undefined) {
|
|
|
|
this.communicationConfig.enabled = true;
|
|
|
|
}
|
2017-03-01 02:43:03 +00:00
|
|
|
if (this.communicationConfig.available_providers === undefined) {
|
|
|
|
this.communicationConfig.available_providers = [];
|
|
|
|
}
|
2017-02-10 12:44:06 +00:00
|
|
|
};
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadWebServerConfigFile = function() {
|
|
|
|
var webServerConfigJSON;
|
2017-03-06 02:27:33 +00:00
|
|
|
if (fs.existsSync(this.configDir + "webserver.json")) {
|
|
|
|
webServerConfigJSON = fs.readJSONSync(this.configDir + "webserver.json");
|
|
|
|
} else {
|
|
|
|
webServerConfigJSON = {};
|
|
|
|
}
|
2017-03-31 11:39:33 +00:00
|
|
|
var defaultWebConfig = {
|
2017-03-04 19:20:28 +00:00
|
|
|
"enabled": true,
|
|
|
|
"host": "localhost",
|
|
|
|
"port": 8000
|
|
|
|
};
|
|
|
|
this.webServerConfig = utils.recursiveMerge(defaultWebConfig, webServerConfigJSON);
|
|
|
|
};
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadEmbarkConfigFile = function() {
|
|
|
|
var contracts = this.embarkConfig.contracts;
|
2016-08-22 03:40:05 +00:00
|
|
|
this.contractsFiles = this.loadFiles(contracts);
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
this.buildDir = this.embarkConfig.buildDir;
|
2017-03-01 02:26:15 +00:00
|
|
|
this.configDir = this.embarkConfig.config;
|
|
|
|
};
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadPipelineConfigFile = function() {
|
|
|
|
var assets = this.embarkConfig.app;
|
|
|
|
for(var targetFile in assets) {
|
2016-08-22 03:40:05 +00:00
|
|
|
this.assetFiles[targetFile] = this.loadFiles(assets[targetFile]);
|
|
|
|
}
|
|
|
|
};
|
2016-09-25 01:10:47 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadChainTrackerFile = function() {
|
|
|
|
//var self = this;
|
|
|
|
var chainTracker;
|
2016-09-25 01:10:47 +00:00
|
|
|
try {
|
2017-02-19 03:40:42 +00:00
|
|
|
chainTracker = fs.readJSONSync(this.chainsFile);
|
2016-09-25 01:10:47 +00:00
|
|
|
}
|
2017-03-31 11:39:33 +00:00
|
|
|
catch(err) {
|
2016-10-15 19:54:19 +00:00
|
|
|
//self.logger.info(this.chainsFile + ' file not found, creating it...');
|
2016-09-25 01:10:47 +00:00
|
|
|
chainTracker = {};
|
2017-02-19 03:40:42 +00:00
|
|
|
fs.writeJSONSync(this.chainsFile, {});
|
2016-09-25 01:10:47 +00:00
|
|
|
}
|
|
|
|
this.chainTracker = chainTracker;
|
|
|
|
};
|
2016-08-22 03:40:05 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadFiles = function(files) {
|
|
|
|
var self = this;
|
|
|
|
var originalFiles = utils.filesMatchingPattern(files);
|
|
|
|
var readFiles = [];
|
2016-08-22 03:40:05 +00:00
|
|
|
|
2017-02-03 11:30:08 +00:00
|
|
|
// get embark.js object first
|
2017-03-31 11:39:33 +00:00
|
|
|
originalFiles.filter(function(file) {
|
2017-07-03 22:54:31 +00:00
|
|
|
return (file[0] === '$' || file.indexOf('.') >= 0);
|
2017-03-31 11:39:33 +00:00
|
|
|
}).filter(function(file) {
|
2016-08-22 03:40:05 +00:00
|
|
|
if (file === 'embark.js') {
|
2017-03-01 02:26:15 +00:00
|
|
|
|
2017-03-01 02:43:03 +00:00
|
|
|
if (self.blockchainConfig.enabled || self.communicationConfig.provider === 'whisper' || self.communicationConfig.available_providers.indexOf('whisper') >= 0) {
|
2017-07-05 12:35:51 +00:00
|
|
|
let web3Version = self.contractsConfig.versions["web3.js"];
|
2017-07-06 23:50:36 +00:00
|
|
|
if (web3Version && web3Version != currentWeb3Version) {
|
2017-07-05 12:35:51 +00:00
|
|
|
//if (false) {
|
|
|
|
//readFiles.push(new File({filename: 'web3-' + web3Version + '.js', type: 'custom', resolver: function(callback) {
|
|
|
|
readFiles.push(new File({filename: 'web3.js', type: 'custom', resolver: function(callback) {
|
2017-10-07 19:20:51 +00:00
|
|
|
if (web3Version === "1.0.0-beta") {
|
2017-10-13 09:56:42 +00:00
|
|
|
return callback(fs.readFileSync(fs.embarkPath('js/web3-1.0.min.js')).toString());
|
2017-10-07 19:20:51 +00:00
|
|
|
} else {
|
|
|
|
let npm = new Npm({logger: self.logger});
|
|
|
|
npm.getPackageVersion('web3', web3Version, 'dist/web3.min.js', true, function(web3Content) {
|
|
|
|
callback(web3Content);
|
|
|
|
});
|
|
|
|
}
|
2017-07-05 12:35:51 +00:00
|
|
|
}}));
|
|
|
|
} else {
|
|
|
|
readFiles.push(new File({filename: 'web3.js', type: 'embark_internal', path: "js/web3.js"}));
|
|
|
|
}
|
2017-03-01 02:26:15 +00:00
|
|
|
}
|
|
|
|
|
2017-03-01 02:43:03 +00:00
|
|
|
if (self.storageConfig.enabled && (self.storageConfig.provider === 'ipfs' || self.storageConfig.available_providers.indexOf('ipfs') >= 0)) {
|
2017-07-05 12:35:51 +00:00
|
|
|
readFiles.push(new File({filename: 'ipfs.js', type: 'embark_internal', path: "js/ipfs.js"}));
|
2017-03-01 02:26:15 +00:00
|
|
|
}
|
|
|
|
|
2017-03-01 02:43:03 +00:00
|
|
|
if (self.communicationConfig.enabled && (self.communicationConfig.provider === 'orbit' || self.communicationConfig.available_providers.indexOf('orbit') >= 0)) {
|
2017-03-01 02:26:15 +00:00
|
|
|
// TODO: remove duplicated files if functionality is the same for storage and orbit
|
2017-07-05 12:35:51 +00:00
|
|
|
readFiles.push(new File({filename: 'ipfs-api.js', type: 'embark_internal', path: "js/ipfs-api.min.js"}));
|
|
|
|
readFiles.push(new File({filename: 'orbit.js', type: 'embark_internal', path: "js/orbit.min.js"}));
|
2017-03-01 02:26:15 +00:00
|
|
|
}
|
|
|
|
|
2017-07-05 12:35:51 +00:00
|
|
|
readFiles.push(new File({filename: 'embark.js', type: 'embark_internal', path: "js/build/embark.bundle.js"}));
|
2016-08-22 03:40:05 +00:00
|
|
|
}
|
2017-07-03 22:54:31 +00:00
|
|
|
if (file === '$EMBARK_JS') {
|
2017-07-05 12:35:51 +00:00
|
|
|
readFiles.push(new File({filename: '$EMBARK_JS', type: 'embark_internal', path: "js/build/embark.bundle.js"}));
|
2017-07-02 18:55:35 +00:00
|
|
|
}
|
2017-07-05 12:35:51 +00:00
|
|
|
//if (file === "web3.js") {
|
|
|
|
// readFiles.push(new File({filename: 'web3.js', type: 'embark_internal', path: "js/web3.js"));
|
|
|
|
//}
|
2016-08-22 03:40:05 +00:00
|
|
|
});
|
|
|
|
|
2017-02-03 11:30:08 +00:00
|
|
|
// get plugins
|
2017-03-31 11:39:33 +00:00
|
|
|
var filesFromPlugins = [];
|
2017-02-03 11:30:08 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
var filePlugins = self.plugins.getPluginsFor('pipelineFiles');
|
2017-02-03 11:30:08 +00:00
|
|
|
|
|
|
|
if (filePlugins.length > 0) {
|
2017-03-31 11:39:33 +00:00
|
|
|
filePlugins.forEach(function(plugin) {
|
2017-02-03 11:30:08 +00:00
|
|
|
try {
|
2017-03-31 11:39:33 +00:00
|
|
|
var fileObjects = plugin.runFilePipeline();
|
|
|
|
for (var i=0; i < fileObjects.length; i++) {
|
|
|
|
var fileObject = fileObjects[i];
|
2017-02-03 11:30:08 +00:00
|
|
|
filesFromPlugins.push(fileObject);
|
|
|
|
}
|
|
|
|
}
|
2017-03-31 11:39:33 +00:00
|
|
|
catch(err) {
|
2017-02-03 11:30:08 +00:00
|
|
|
self.logger.error(err.message);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
filesFromPlugins.filter(function(file) {
|
2017-02-18 19:37:07 +00:00
|
|
|
if (utils.fileMatchesPattern(files, file.intendedPath)) {
|
2017-02-03 11:30:08 +00:00
|
|
|
readFiles.push(file);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// get user files
|
2017-03-31 11:39:33 +00:00
|
|
|
originalFiles.filter(function(file) {
|
2017-02-03 11:30:08 +00:00
|
|
|
if (file === 'embark.js') {
|
|
|
|
return;
|
2017-07-02 17:33:11 +00:00
|
|
|
} else if (file.indexOf("web3-") === 0) {
|
|
|
|
return;
|
2017-07-02 18:55:35 +00:00
|
|
|
} else if (file.indexOf("web3") === 0) {
|
|
|
|
return;
|
2017-07-05 12:35:51 +00:00
|
|
|
//} else if (file === 'abi.js') {
|
|
|
|
// readFiles.push({filename: file, content: "", path: file});
|
2017-02-16 00:27:23 +00:00
|
|
|
} else {
|
2017-06-27 22:18:29 +00:00
|
|
|
if (file.indexOf('.') >= 0) {
|
2017-07-05 12:35:51 +00:00
|
|
|
readFiles.push(new File({filename: file, type: "dapp_file", path: file}));
|
2017-06-27 22:18:29 +00:00
|
|
|
} else if (file[0] === '$') {
|
2017-07-05 12:35:51 +00:00
|
|
|
//readFiles.push(new File({filename: file, type: 'embark_internal', path: file}));
|
2017-06-27 22:18:29 +00:00
|
|
|
}
|
2017-02-03 11:30:08 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-08-22 03:40:05 +00:00
|
|
|
return readFiles;
|
|
|
|
};
|
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
Config.prototype.loadPluginContractFiles = function() {
|
|
|
|
var self = this;
|
2017-01-26 11:34:00 +00:00
|
|
|
|
2017-03-31 11:39:33 +00:00
|
|
|
var contractsPlugins = this.plugins.getPluginsFor('contractFiles');
|
2017-01-26 11:34:00 +00:00
|
|
|
if (contractsPlugins.length > 0) {
|
2017-03-31 11:39:33 +00:00
|
|
|
contractsPlugins.forEach(function(plugin) {
|
|
|
|
plugin.contractsFiles.forEach(function(file) {
|
|
|
|
var filename = file.replace('./','');
|
2017-07-05 12:35:51 +00:00
|
|
|
//self.contractsFiles.push({filename: filename, content: plugin.loadPluginFile(file), path: plugin.pathToFile(file)});
|
|
|
|
self.contractsFiles.push(new File({filename: filename, type: 'custom', resolver: function(callback) {
|
|
|
|
callback(plugin.loadPluginFile(file));
|
|
|
|
}}));
|
2017-01-26 11:34:00 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-08-22 03:40:05 +00:00
|
|
|
module.exports = Config;
|