mirror of https://github.com/embarklabs/embark.git
Expose embark version to plugin constructor
Expose Embark’s version to the plugin constructor, allowing plugins to make logical decisions based on the version of Embark.
This commit is contained in:
parent
f54982254d
commit
c6c6af01c9
|
@ -25,7 +25,7 @@ class EmbarkController {
|
||||||
this.events = new Events();
|
this.events = new Events();
|
||||||
this.logger = new Logger({logLevel: Logger.logLevels.debug, events: this.events, context: this.context});
|
this.logger = new Logger({logLevel: Logger.logLevels.debug, events: this.events, context: this.context});
|
||||||
|
|
||||||
this.config = new Config({env: env, logger: this.logger, events: this.events, context: this.context});
|
this.config = new Config({env: env, logger: this.logger, events: this.events, context: this.context, version: this.version});
|
||||||
this.config.loadConfigFiles(options);
|
this.config.loadConfigFiles(options);
|
||||||
this.plugins = this.config.plugins;
|
this.plugins = this.config.plugins;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ var Config = function(options) {
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
this.embarkConfig = {};
|
this.embarkConfig = {};
|
||||||
this.context = options.context || [constants.contexts.any];
|
this.context = options.context || [constants.contexts.any];
|
||||||
|
this.version = options.version;
|
||||||
this.shownNoAccountConfigMsg = false; // flag to ensure "no account config" message is only displayed once to the user
|
this.shownNoAccountConfigMsg = false; // flag to ensure "no account config" message is only displayed once to the user
|
||||||
this.corsParts = [];
|
this.corsParts = [];
|
||||||
this.providerUrl = null;
|
this.providerUrl = null;
|
||||||
|
@ -84,7 +85,7 @@ Config.prototype.loadConfigFiles = function(options) {
|
||||||
this.embarkConfig = fs.readJSONSync(options.embarkConfig);
|
this.embarkConfig = fs.readJSONSync(options.embarkConfig);
|
||||||
this.embarkConfig.plugins = this.embarkConfig.plugins || {};
|
this.embarkConfig.plugins = this.embarkConfig.plugins || {};
|
||||||
|
|
||||||
this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs, events: this.events, config: this, context: this.context, env: this.env});
|
this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs, events: this.events, config: this, context: this.context, env: this.env, version: this.version});
|
||||||
this.plugins.loadPlugins();
|
this.plugins.loadPlugins();
|
||||||
|
|
||||||
this.loadEmbarkConfigFile();
|
this.loadEmbarkConfigFile();
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Engine {
|
||||||
let options = _options || {};
|
let options = _options || {};
|
||||||
this.events = options.events || this.events || new Events();
|
this.events = options.events || this.events || new Events();
|
||||||
this.logger = options.logger || new Logger({context: this.context, logLevel: options.logLevel || this.logLevel || 'debug', events: this.events, logFile: this.logFile});
|
this.logger = options.logger || new Logger({context: this.context, logLevel: options.logLevel || this.logLevel || 'debug', events: this.events, logFile: this.logFile});
|
||||||
this.config = new Config({env: this.env, logger: this.logger, events: this.events, context: this.context, webServerConfig: this.webServerConfig});
|
this.config = new Config({env: this.env, logger: this.logger, events: this.events, context: this.context, webServerConfig: this.webServerConfig, version: this.version});
|
||||||
this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs});
|
this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs});
|
||||||
this.plugins = this.config.plugins;
|
this.plugins = this.config.plugins;
|
||||||
this.isDev = this.config && this.config.blockchainConfig && (this.config.blockchainConfig.isDev || this.config.blockchainConfig.default);
|
this.isDev = this.config && this.config.blockchainConfig && (this.config.blockchainConfig.isDev || this.config.blockchainConfig.default);
|
||||||
|
|
|
@ -42,6 +42,7 @@ var Plugin = function(options) {
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.currentContext = options.context;
|
this.currentContext = options.context;
|
||||||
this.acceptedContext = options.pluginConfig.context || [constants.contexts.any];
|
this.acceptedContext = options.pluginConfig.context || [constants.contexts.any];
|
||||||
|
this.version = options.version;
|
||||||
|
|
||||||
if (!Array.isArray(this.currentContext)) {
|
if (!Array.isArray(this.currentContext)) {
|
||||||
this.currentContext = [this.currentContext];
|
this.currentContext = [this.currentContext];
|
||||||
|
|
|
@ -12,6 +12,7 @@ var Plugins = function(options) {
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
this.context = options.context;
|
this.context = options.context;
|
||||||
this.env = options.env;
|
this.env = options.env;
|
||||||
|
this.version = options.version;
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugins.prototype.loadPlugins = function() {
|
Plugins.prototype.loadPlugins = function() {
|
||||||
|
@ -94,7 +95,8 @@ Plugins.prototype.loadPlugin = function(pluginName, pluginConfig) {
|
||||||
config: this.config,
|
config: this.config,
|
||||||
plugins: this.plugins,
|
plugins: this.plugins,
|
||||||
isInternal: false,
|
isInternal: false,
|
||||||
context: this.context
|
context: this.context,
|
||||||
|
version: this.version
|
||||||
});
|
});
|
||||||
pluginWrapper.loadPlugin();
|
pluginWrapper.loadPlugin();
|
||||||
this.plugins.push(pluginWrapper);
|
this.plugins.push(pluginWrapper);
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Embark {
|
||||||
this.events = new Events();
|
this.events = new Events();
|
||||||
this.logger = new Logger({logLevel: 'debug', events: this.events, context: this.context});
|
this.logger = new Logger({logLevel: 'debug', events: this.events, context: this.context});
|
||||||
|
|
||||||
this.config = new Config({env: env, logger: this.logger, events: this.events, context: this.context});
|
this.config = new Config({env: env, logger: this.logger, events: this.events, context: this.context, version: this.version});
|
||||||
this.config.loadConfigFiles(options);
|
this.config.loadConfigFiles(options);
|
||||||
this.plugins = this.config.plugins;
|
this.plugins = this.config.plugins;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue