mirror of https://github.com/embarklabs/embark.git
feat: warn about packages not configured as plugins; make geth/parity full plugins
feat(@embark/utils): add method to verify if a plugin is installed & configured feature(@embark/utils): add method to verify if a plugin is installed & configured feature: warn about packages that will be independent plugins and are not configured chore: update templates to specify plugins refactor: add to plugin api params so that blockchain plugins no longer need to be passed options address changes in code review remove unneded space Update packages/core/utils/src/index.ts Co-Authored-By: Jonathan Rainville <rainville.jonathan@gmail.com> Update packages/core/utils/src/index.ts Co-Authored-By: Michael Bradley <michaelsbradleyjr@gmail.com> fix linting issue add missing import update dependency fix plugins object add missing whitespace
This commit is contained in:
parent
0016581225
commit
d14e93ceb1
|
@ -12,6 +12,13 @@
|
|||
"solc": "0.6.1"
|
||||
},
|
||||
"plugins": {
|
||||
"embark-ipfs": {},
|
||||
"embark-swarm": {},
|
||||
"embark-whisper-geth": {},
|
||||
"embark-geth": {},
|
||||
"embark-parity": {},
|
||||
"embark-profiler": {},
|
||||
"embark-graph": {}
|
||||
},
|
||||
"options": {
|
||||
"solc": {
|
||||
|
|
|
@ -40,6 +40,13 @@
|
|||
"embarkjs-swarm": "^5.1.1",
|
||||
"embarkjs-web3": "^5.2.0-nightly.2",
|
||||
"embarkjs-whisper": "^5.1.1",
|
||||
"embark-ipfs": "^5.2.0-nightly.1",
|
||||
"embark-swarm": "^5.2.0-nightly.1",
|
||||
"embark-whisper-geth": "^5.2.0-nightly.1",
|
||||
"embark-geth": "^5.2.0-nightly.1",
|
||||
"embark-parity": "^5.2.0-nightly.1",
|
||||
"embark-profiler": "^5.1.1",
|
||||
"embark-graph": "^5.1.1",
|
||||
"rimraf": "3.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,13 @@
|
|||
"solc": "0.6.1"
|
||||
},
|
||||
"plugins": {
|
||||
"embark-ipfs": {},
|
||||
"embark-swarm": {},
|
||||
"embark-whisper-geth": {},
|
||||
"embark-geth": {},
|
||||
"embark-parity": {},
|
||||
"embark-profiler": {},
|
||||
"embark-graph": {}
|
||||
},
|
||||
"options": {
|
||||
"solc": {
|
||||
|
|
|
@ -42,6 +42,13 @@
|
|||
"embarkjs-swarm": "^5.1.1",
|
||||
"embarkjs-web3": "^5.2.0-nightly.2",
|
||||
"embarkjs-whisper": "^5.1.1",
|
||||
"embark-ipfs": "^5.2.0-nightly.1",
|
||||
"embark-swarm": "^5.2.0-nightly.1",
|
||||
"embark-whisper-geth": "^5.2.0-nightly.1",
|
||||
"embark-geth": "^5.2.0-nightly.1",
|
||||
"embark-parity": "^5.2.0-nightly.1",
|
||||
"embark-profiler": "^5.1.1",
|
||||
"embark-graph": "^5.1.1",
|
||||
"jquery": "3.4.1",
|
||||
"popper.js": "1.15.0",
|
||||
"react": "16.12.0",
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
"solc": "0.6.1"
|
||||
},
|
||||
"plugins": {
|
||||
"embark-geth": {},
|
||||
"embark-parity": {},
|
||||
"embark-profiler": {},
|
||||
"embark-graph": {}
|
||||
},
|
||||
"options": {
|
||||
"solc": {
|
||||
|
|
|
@ -32,10 +32,11 @@
|
|||
"embark-reset": "^5.1.1",
|
||||
"embarkjs": "^5.2.0-nightly.2",
|
||||
"embarkjs-ens": "^5.2.0-nightly.2",
|
||||
"embarkjs-ipfs": "^5.1.1",
|
||||
"embarkjs-swarm": "^5.1.1",
|
||||
"embarkjs-web3": "^5.2.0-nightly.2",
|
||||
"embarkjs-whisper": "^5.1.1",
|
||||
"embark-geth": "^5.2.0-nightly.2",
|
||||
"embark-parity": "^5.2.0-nightly.2",
|
||||
"embark-profiler": "^5.1.1",
|
||||
"embark-graph": "^5.1.1",
|
||||
"rimraf": "3.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,13 @@
|
|||
"solc": "0.4.26"
|
||||
},
|
||||
"plugins": {
|
||||
"embark-ipfs": {},
|
||||
"embark-swarm": {},
|
||||
"embark-whisper-geth": {},
|
||||
"embark-geth": {},
|
||||
"embark-parity": {},
|
||||
"embark-profiler": {},
|
||||
"embark-graph": {},
|
||||
"embark-dapp-test-service": {}
|
||||
},
|
||||
"options": {
|
||||
|
|
|
@ -13,6 +13,13 @@
|
|||
"embarkjs-swarm": "^5.1.1",
|
||||
"embarkjs-web3": "^5.2.0-nightly.2",
|
||||
"embarkjs-whisper": "^5.1.1",
|
||||
"embark-ipfs": "^5.2.0-nightly.1",
|
||||
"embark-swarm": "^5.2.0-nightly.1",
|
||||
"embark-whisper-geth": "^5.2.0-nightly.1",
|
||||
"embark-geth": "^5.2.0-nightly.1",
|
||||
"embark-parity": "^5.2.0-nightly.1",
|
||||
"embark-profiler": "^5.1.1",
|
||||
"embark-graph": "^5.1.1",
|
||||
"fs-extra": "8.1.0",
|
||||
"haml": "0.4.3",
|
||||
"jquery": "3.4.0",
|
||||
|
|
|
@ -15,5 +15,9 @@
|
|||
"solc": "0.4.26"
|
||||
},
|
||||
"plugins": {
|
||||
"embark-geth": {},
|
||||
"embark-parity": {},
|
||||
"embark-profiler": {},
|
||||
"embark-graph": {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,13 @@
|
|||
"embarkjs-swarm": "^5.1.1",
|
||||
"embarkjs-web3": "^5.2.0-nightly.2",
|
||||
"embarkjs-whisper": "^5.1.1",
|
||||
"embark-ipfs": "^5.2.0-nightly.1",
|
||||
"embark-swarm": "^5.2.0-nightly.1",
|
||||
"embark-whisper-geth": "^5.2.0-nightly.1",
|
||||
"embark-geth": "^5.2.0-nightly.1",
|
||||
"embark-parity": "^5.2.0-nightly.1",
|
||||
"embark-profiler": "^5.1.1",
|
||||
"embark-graph": "^5.1.1",
|
||||
"rimraf": "3.0.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
|
|
|
@ -100,6 +100,8 @@ export class Config {
|
|||
|
||||
buildDir: any;
|
||||
|
||||
client: string;
|
||||
|
||||
dappPath = dappPath;
|
||||
|
||||
constructor(options) {
|
||||
|
@ -114,6 +116,7 @@ export class Config {
|
|||
this.events = options.events;
|
||||
this.context = options.context || [constants.contexts.any];
|
||||
this.version = options.version;
|
||||
this.client = options.client;
|
||||
|
||||
this.registerEvents();
|
||||
}
|
||||
|
@ -194,7 +197,8 @@ export class Config {
|
|||
config: this,
|
||||
context: this.context,
|
||||
env: this.env,
|
||||
version: this.version
|
||||
version: this.version,
|
||||
client: this.client
|
||||
});
|
||||
|
||||
this.loadEmbarkConfigFile();
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as fs from './fs';
|
|||
import { Plugin } from './plugin';
|
||||
import { EmbarkEmitter as Events } from './events';
|
||||
import { Config } from './config';
|
||||
import { IPC } from './ipc';
|
||||
|
||||
import * as async from 'async';
|
||||
import { dappPath, embarkPath } from 'embark-utils';
|
||||
|
@ -31,6 +32,8 @@ export class Plugins {
|
|||
|
||||
version: string;
|
||||
|
||||
client: string;
|
||||
|
||||
static deprecated = {
|
||||
'embarkjs-connector-web3': '4.1.0'
|
||||
};
|
||||
|
@ -46,6 +49,7 @@ export class Plugins {
|
|||
this.fs = fs;
|
||||
this.env = options.env;
|
||||
this.version = options.version;
|
||||
this.client = options.client;
|
||||
}
|
||||
|
||||
loadPlugins() {
|
||||
|
@ -85,7 +89,8 @@ export class Plugins {
|
|||
plugins: this.plugins,
|
||||
fs: this.fs,
|
||||
isInternal: true,
|
||||
context: this.context
|
||||
context: this.context,
|
||||
client: this.client
|
||||
});
|
||||
this.plugins.push(pluginWrapper);
|
||||
return pluginWrapper;
|
||||
|
@ -119,7 +124,8 @@ export class Plugins {
|
|||
fs: this.fs,
|
||||
isInternal: true,
|
||||
context: this.context,
|
||||
env: this.env
|
||||
env: this.env,
|
||||
client: this.client
|
||||
});
|
||||
const pluginInstance = pluginWrapper.loadInternalPlugin();
|
||||
this.plugins.push(pluginWrapper);
|
||||
|
@ -149,7 +155,8 @@ export class Plugins {
|
|||
fs: this.fs,
|
||||
isInternal: false,
|
||||
context: this.context,
|
||||
version: this.version
|
||||
version: this.version,
|
||||
client: this.client
|
||||
});
|
||||
pluginWrapper.loadPlugin();
|
||||
this.plugins.push(pluginWrapper);
|
||||
|
|
|
@ -57,8 +57,6 @@ export class Engine {
|
|||
|
||||
package: any;
|
||||
|
||||
isDev: boolean | undefined;
|
||||
|
||||
constructor(options) {
|
||||
this.env = options.env;
|
||||
this.client = options.client;
|
||||
|
@ -85,6 +83,9 @@ export class Engine {
|
|||
const options = _options || {};
|
||||
this.events = options.events || this.events || new Events();
|
||||
this.logger = this.logger || new Logger({context: this.context, logLevel: options.logLevel || this.logLevel || 'info', events: this.events, logFile: this.logFile});
|
||||
|
||||
this.ipc = new IPC({ logger: this.logger, ipcRole: this.ipcRole });
|
||||
|
||||
this.config = new Config({
|
||||
env: this.env,
|
||||
logger: this.logger,
|
||||
|
@ -93,17 +94,17 @@ export class Engine {
|
|||
webServerConfig: this.webServerConfig,
|
||||
version: this.version,
|
||||
package: this.package,
|
||||
locale: this.locale
|
||||
locale: this.locale,
|
||||
client: this.client,
|
||||
ipc: this.ipc
|
||||
});
|
||||
this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs});
|
||||
this.plugins = this.config.plugins;
|
||||
this.isDev = this.config && this.config.blockchainConfig && (this.config.blockchainConfig.isDev || this.config.blockchainConfig.default);
|
||||
|
||||
if (this.interceptLogs || this.interceptLogs === undefined) {
|
||||
interceptLogs(console, this.logger);
|
||||
}
|
||||
|
||||
this.ipc = new IPC({ logger: this.logger, ipcRole: this.ipcRole });
|
||||
if (this.ipc.isClient()) {
|
||||
return this.ipc.connect((_err) => {
|
||||
callback();
|
||||
|
@ -268,20 +269,8 @@ export class Engine {
|
|||
|
||||
blockchainComponents() {
|
||||
// plugins
|
||||
this.registerModulePackage('embark-geth', {
|
||||
client: this.client,
|
||||
locale: this.locale,
|
||||
isDev: this.isDev,
|
||||
plugins: this.plugins,
|
||||
ipc: this.ipc
|
||||
});
|
||||
this.registerModulePackage('embark-parity', {
|
||||
client: this.client,
|
||||
locale: this.locale,
|
||||
isDev: this.isDev,
|
||||
plugins: this.plugins,
|
||||
ipc: this.ipc
|
||||
});
|
||||
this.registerModulePackage('embark-geth');
|
||||
this.registerModulePackage('embark-parity');
|
||||
}
|
||||
|
||||
testComponents(options) {
|
||||
|
|
|
@ -5,7 +5,11 @@ const clipboardy = require('clipboardy');
|
|||
|
||||
import * as Serialize from './serialize';
|
||||
export { Serialize };
|
||||
import { __ } from 'embark-i18n';
|
||||
|
||||
import { canonicalHost } from './host';
|
||||
import * as findUp from 'find-up';
|
||||
import * as fs from 'fs-extra';
|
||||
export { canonicalHost, defaultCorsHost, defaultHost, dockerHostSwap, isDocker } from './host';
|
||||
export { downloadFile, findNextPort, getJson, httpGet, httpsGet, httpGetJson, httpsGetJson, pingEndpoint } from './network';
|
||||
export { testRpcWithEndpoint, testWsEndpoint } from './check';
|
||||
|
@ -55,6 +59,10 @@ export {
|
|||
} from './pathUtils';
|
||||
export { setUpEnv } from './env';
|
||||
|
||||
import {
|
||||
dappPath
|
||||
} from './pathUtils';
|
||||
|
||||
const { extendZeroAddressShorthand, replaceZeroAddressShorthand } = AddressUtils;
|
||||
|
||||
export { compact, last, recursiveMerge, groupBy } from './collections';
|
||||
|
@ -300,3 +308,25 @@ export function isConstructor(obj) {
|
|||
export function isEs6Module(module) {
|
||||
return (typeof module === 'function' && isConstructor(module)) || (typeof module === 'object' && typeof module.default === 'function' && module.__esModule);
|
||||
}
|
||||
|
||||
export function warnIfPackageNotDefinedLocally(packageName, warnFunc) {
|
||||
const packageIsResolvable = findUp.sync("node_modules/" + packageName, {cwd: dappPath()});
|
||||
if (!packageIsResolvable) {
|
||||
return warnFunc("== WARNING: " + packageName + " could not be resolved; ensure it is defined in your dapp's package.json dependencies and then run npm or yarn install; in future versions of embark this package should be a local dependency and configured as a plugin");
|
||||
}
|
||||
|
||||
const dappPackage = fs.readJSONSync(dappPath("package.json"));
|
||||
const { dependencies, devDependencies } = dappPackage;
|
||||
if (!((dependencies && dependencies[packageName]) || (devDependencies && devDependencies[packageName]))) {
|
||||
return warnFunc("== WARNING: it seems " + packageName + " is not defined in your dapp's package.json dependencies; In future versions of embark this package should be a local dependency and configured as a plugin");
|
||||
}
|
||||
|
||||
const embarkConfig = fs.readJSONSync(dappPath("embark.json"));
|
||||
if (!embarkConfig.plugins[packageName]) {
|
||||
return warnFunc(
|
||||
__("== WARNING: it seems %s is not defined in your Dapp's embark.json plugins;\nIn future versions of Embark, this package should be a local dependency and configured as a plugin", packageName)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -7,19 +7,19 @@ import DevTxs from "./devtxs";
|
|||
const constants = require('embark-core/constants');
|
||||
|
||||
class Geth {
|
||||
constructor(embark, options) {
|
||||
constructor(embark) {
|
||||
this.embark = embark;
|
||||
this.embarkConfig = embark.config.embarkConfig;
|
||||
this.blockchainConfig = embark.config.blockchainConfig;
|
||||
this.communicationConfig = embark.config.communicationConfig;
|
||||
// TODO get options from config instead of options
|
||||
this.locale = options.locale;
|
||||
this.locale = embark.config.locale;
|
||||
this.logger = embark.logger;
|
||||
this.client = options.client;
|
||||
this.isDev = options.isDev;
|
||||
this.client = embark.client;
|
||||
this.events = embark.events;
|
||||
this.plugins = options.plugins;
|
||||
this.plugins = embark.plugins;
|
||||
this.shownNoAccountConfigMsg = false; // flag to ensure "no account config" message is only displayed once to the user
|
||||
this.isDev = (this.blockchainConfig.isDev || this.blockchainConfig.default);
|
||||
|
||||
if (!this.shouldInit()) {
|
||||
return;
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
"dependencies": {
|
||||
"@babel/runtime-corejs3": "7.7.4",
|
||||
"async": "2.6.1",
|
||||
"embark-utils": "^5.2.0-nightly.1",
|
||||
"core-js": "3.4.3",
|
||||
"viz.js": "1.8.2"
|
||||
},
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { warnIfPackageNotDefinedLocally } from 'embark-utils';
|
||||
|
||||
const async = require('async');
|
||||
const Viz = require('viz.js');
|
||||
|
||||
|
@ -7,6 +9,7 @@ class GraphGenerator {
|
|||
this.events = embark.events;
|
||||
|
||||
this.events.setCommandHandler("graph:create", this.generate.bind(this));
|
||||
warnIfPackageNotDefinedLocally("embark-graph", this.embark.logger.warn.bind(this.embark.logger));
|
||||
}
|
||||
|
||||
/*eslint complexity: ["error", 21]*/
|
||||
|
|
|
@ -8,5 +8,10 @@
|
|||
"extends": "../../../tsconfig.base.json",
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../core/utils"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,18 +7,16 @@ const constants = require('embark-core/constants');
|
|||
|
||||
class Parity {
|
||||
|
||||
constructor(embark, options) {
|
||||
constructor(embark) {
|
||||
this.embark = embark;
|
||||
this.embarkConfig = embark.config.embarkConfig;
|
||||
this.blockchainConfig = embark.config.blockchainConfig;
|
||||
// TODO get options from config instead of options
|
||||
this.locale = options.locale;
|
||||
this.locale = embark.config.locale;
|
||||
this.logger = embark.logger;
|
||||
this.client = options.client;
|
||||
this.isDev = options.isDev;
|
||||
this.client = embark.client;
|
||||
this.events = embark.events;
|
||||
this.plugins = options.plugins;
|
||||
// let plugin = this.plugins.createPlugin('gethplugin', {});
|
||||
this.isDev = (this.blockchainConfig.isDev || this.blockchainConfig.default);
|
||||
|
||||
if (!this.shouldInit()) {
|
||||
return;
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
"ascii-table": "0.0.9",
|
||||
"async": "2.6.1",
|
||||
"core-js": "3.4.3",
|
||||
"embark-utils": "^5.2.0-nightly.1",
|
||||
"web3": "1.2.6",
|
||||
"web3-utils": "1.2.6"
|
||||
},
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { warnIfPackageNotDefinedLocally } from 'embark-utils';
|
||||
|
||||
const asciiTable = require('ascii-table');
|
||||
const GasEstimator = require('./gasEstimator.js');
|
||||
|
||||
|
@ -10,6 +12,7 @@ class Profiler {
|
|||
|
||||
this.registerConsoleCommand();
|
||||
this.registerApi();
|
||||
warnIfPackageNotDefinedLocally("embark-profiler", this.embark.logger.warn.bind(this.embark.logger));
|
||||
}
|
||||
|
||||
profileJSON(contractName, returnCb) {
|
||||
|
|
|
@ -8,5 +8,10 @@
|
|||
"extends": "../../../tsconfig.base.json",
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../core/utils"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import async from 'async';
|
||||
import { warnIfPackageNotDefinedLocally } from 'embark-utils';
|
||||
const { __ } = require('embark-i18n');
|
||||
const constants = require('embark-core/constants');
|
||||
|
||||
|
@ -109,6 +110,13 @@ export default class Blockchain {
|
|||
});
|
||||
this.blockchainApi.registerAPIs("ethereum");
|
||||
this.blockchainApi.registerRequests("ethereum");
|
||||
|
||||
if (this.blockchainConfig.enabled && this.blockchainConfig.client === "geth") {
|
||||
warnIfPackageNotDefinedLocally("embark-geth", this.embark.logger.warn.bind(this.embark.logger));
|
||||
}
|
||||
if (this.blockchainConfig.enabled && this.blockchainConfig.client === "parity") {
|
||||
warnIfPackageNotDefinedLocally("embark-parity", this.embark.logger.warn.bind(this.embark.logger));
|
||||
}
|
||||
}
|
||||
|
||||
addArtifactFile(_params, cb) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { __ } from 'embark-i18n';
|
||||
import {canonicalHost, defaultHost} from 'embark-utils';
|
||||
import {canonicalHost, defaultHost, warnIfPackageNotDefinedLocally} from 'embark-utils';
|
||||
|
||||
class Communication {
|
||||
constructor(embark, _options){
|
||||
|
@ -30,6 +30,10 @@ class Communication {
|
|||
|
||||
client.apply(client, [onStart]);
|
||||
});
|
||||
|
||||
if (this.communicationConfig.enabled && this.communicationConfig.available_providers.includes("whisper")) {
|
||||
warnIfPackageNotDefinedLocally("embark-whisper-geth", this.embark.logger.warn.bind(this.embark.logger));
|
||||
}
|
||||
}
|
||||
|
||||
addArtifactFile(_params, cb) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {__} from 'embark-i18n';
|
||||
import { warnIfPackageNotDefinedLocally } from 'embark-utils';
|
||||
|
||||
class Storage {
|
||||
constructor(embark, options) {
|
||||
|
@ -41,6 +42,13 @@ class Storage {
|
|||
if (!client) return cb("upload client for " + clientName + " not found");
|
||||
client.apply(client, [cb]);
|
||||
});
|
||||
|
||||
if (this.storageConfig.enabled && this.storageConfig.available_providers.includes("ipfs")) {
|
||||
warnIfPackageNotDefinedLocally("embark-ipfs", this.embark.logger.warn.bind(this.embark.logger));
|
||||
}
|
||||
if (this.storageConfig.enabled && this.storageConfig.available_providers.includes("swarm")) {
|
||||
warnIfPackageNotDefinedLocally("embark-swarm", this.embark.logger.warn.bind(this.embark.logger));
|
||||
}
|
||||
}
|
||||
|
||||
addArtifactFile(_params, cb) {
|
||||
|
|
Loading…
Reference in New Issue