mirror of https://github.com/embarklabs/embark.git
add createPlugin; move cmds to library managers
This commit is contained in:
parent
947373eafc
commit
dee49ec5ed
|
@ -7,6 +7,7 @@ let CodeGenerator = require('../contracts/code_generator.js');
|
|||
let ServicesMonitor = require('./services_monitor.js');
|
||||
let Pipeline = require('../pipeline/pipeline.js');
|
||||
let Watch = require('../pipeline/watch.js');
|
||||
let LibraryManager = require('../versions/library_manager.js');
|
||||
|
||||
class Engine {
|
||||
constructor(options) {
|
||||
|
@ -61,7 +62,8 @@ class Engine {
|
|||
"fileWatcher": this.fileWatchService,
|
||||
"webServer": this.webServerService,
|
||||
"ipfs": this.ipfsService,
|
||||
"web3": this.web3Service
|
||||
"web3": this.web3Service,
|
||||
"libraryManager": this.libraryManagerService
|
||||
};
|
||||
|
||||
let service = services[serviceName];
|
||||
|
@ -206,6 +208,14 @@ class Engine {
|
|||
web3: this.web3
|
||||
});
|
||||
}
|
||||
|
||||
libraryManagerService(options) {
|
||||
let libraryManager = new LibraryManager({
|
||||
plugins: this.plugins,
|
||||
config: this.config
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Engine;
|
||||
|
|
|
@ -44,6 +44,9 @@ Plugin.prototype.loadPluginFile = function(filename) {
|
|||
};
|
||||
|
||||
Plugin.prototype.pathToFile = function(filename) {
|
||||
if (!this.pluginPath) {
|
||||
throw new Error('pluginPath not defined for plugin: ' + this.name);
|
||||
}
|
||||
return utils.joinPath(this.pluginPath, filename);
|
||||
};
|
||||
|
||||
|
|
|
@ -27,6 +27,15 @@ Plugins.prototype.listPlugins = function() {
|
|||
return list;
|
||||
};
|
||||
|
||||
// for services that act as a plugin but have core functionality
|
||||
Plugins.prototype.createPlugin = function(pluginName, pluginConfig) {
|
||||
let plugin = {};
|
||||
let pluginPath = undefined;
|
||||
var pluginWrapper = new Plugin({name: pluginName, pluginModule: plugin, pluginConfig: pluginConfig, logger: this.logger, pluginPath: pluginPath, interceptLogs: this.interceptLogs, events: this.events, config: this.config, isInternal: true});
|
||||
this.plugins.push(pluginWrapper);
|
||||
return pluginWrapper;
|
||||
};
|
||||
|
||||
Plugins.prototype.loadInternalPlugin = function(pluginName, pluginConfig) {
|
||||
var pluginPath = utils.joinPath('../modules/', pluginName, 'index.js');
|
||||
var plugin = require(pluginPath);
|
||||
|
|
|
@ -28,19 +28,6 @@ class Console {
|
|||
'The web3 object and the interfaces for the deployed contracts and their methods are also available'
|
||||
];
|
||||
return helpText.join('\n');
|
||||
} else if (cmd === 'versions') {
|
||||
let solcVersionInConfig = this.contractsConfig.versions.solc;
|
||||
let web3VersionInConfig = this.contractsConfig.versions["web3.js"];
|
||||
let ipfsApiVersion = require('../../package.json').dependencies["ipfs-api"];
|
||||
|
||||
let text = [
|
||||
'versions in use:',
|
||||
'solc: ' + solcVersionInConfig,
|
||||
'web3.js: ' + web3VersionInConfig,
|
||||
'ipfs-api: ' + ipfsApiVersion
|
||||
];
|
||||
|
||||
return text.join('\n');
|
||||
} else if (['quit', 'exit', 'sair', 'sortir'].indexOf(cmd) >= 0) {
|
||||
utils.exit();
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ class Embark {
|
|||
}
|
||||
|
||||
engine.startMonitor();
|
||||
engine.startService("libraryManager");
|
||||
engine.startService("web3");
|
||||
engine.startService("pipeline");
|
||||
engine.startService("codeGenerator");
|
||||
|
@ -158,10 +159,12 @@ class Embark {
|
|||
engine.logger.info("loaded plugins: " + pluginList.join(", "));
|
||||
}
|
||||
|
||||
engine.startService("libraryManager");
|
||||
engine.startService("web3");
|
||||
engine.startService("pipeline");
|
||||
engine.startService("codeGenerator");
|
||||
engine.startService("deployment");
|
||||
engine.startService("ipfs");
|
||||
callback();
|
||||
},
|
||||
function deploy(callback) {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
class LibraryManager {
|
||||
|
||||
constructor(options) {
|
||||
this.plugins = options.plugins;
|
||||
this.config = options.config;
|
||||
this.contractsConfig = this.config.contractsConfig;
|
||||
|
||||
this.embark = this.plugins.createPlugin('libraryManager', {});
|
||||
|
||||
this.registerCommands();
|
||||
}
|
||||
|
||||
registerCommands() {
|
||||
const self = this;
|
||||
this.embark.registerConsoleCommand((cmd, _options) => {
|
||||
if (cmd === "versions") {
|
||||
let solcVersionInConfig = self.contractsConfig.versions.solc;
|
||||
let web3VersionInConfig = self.contractsConfig.versions["web3.js"];
|
||||
let ipfsApiVersion = require('../../package.json').dependencies["ipfs-api"];
|
||||
|
||||
let text = [
|
||||
'versions in use:',
|
||||
'solc: ' + solcVersionInConfig,
|
||||
'web3.js: ' + web3VersionInConfig,
|
||||
'ipfs-api: ' + ipfsApiVersion
|
||||
];
|
||||
|
||||
return text.join('\n');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = LibraryManager;
|
Loading…
Reference in New Issue