mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-16 23:57:11 +00:00
feature(@embark/utils): add method to verify if a plugin is installed & configured
This commit is contained in:
parent
f5db7fe88d
commit
5524adcda2
@ -4,6 +4,8 @@ const shelljs = require('shelljs');
|
|||||||
const clipboardy = require('clipboardy');
|
const clipboardy = require('clipboardy');
|
||||||
|
|
||||||
import { canonicalHost } from './host';
|
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 { canonicalHost, defaultCorsHost, defaultHost, dockerHostSwap, isDocker } from './host';
|
||||||
export { downloadFile, findNextPort, getJson, httpGet, httpsGet, httpGetJson, httpsGetJson, pingEndpoint } from './network';
|
export { downloadFile, findNextPort, getJson, httpGet, httpsGet, httpGetJson, httpsGetJson, pingEndpoint } from './network';
|
||||||
export { testRpcWithEndpoint, testWsEndpoint } from './check';
|
export { testRpcWithEndpoint, testWsEndpoint } from './check';
|
||||||
@ -53,6 +55,10 @@ export {
|
|||||||
} from './pathUtils';
|
} from './pathUtils';
|
||||||
export { setUpEnv } from './env';
|
export { setUpEnv } from './env';
|
||||||
|
|
||||||
|
import {
|
||||||
|
dappPath
|
||||||
|
} from './pathUtils';
|
||||||
|
|
||||||
const { extendZeroAddressShorthand, replaceZeroAddressShorthand } = AddressUtils;
|
const { extendZeroAddressShorthand, replaceZeroAddressShorthand } = AddressUtils;
|
||||||
|
|
||||||
export { compact, last, recursiveMerge, groupBy } from './collections';
|
export { compact, last, recursiveMerge, groupBy } from './collections';
|
||||||
@ -298,3 +304,23 @@ export function isConstructor(obj) {
|
|||||||
export function isEs6Module(module) {
|
export function isEs6Module(module) {
|
||||||
return (typeof module === 'function' && isConstructor(module)) || (typeof module === 'object' && typeof module.default === 'function' && module.__esModule);
|
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: it seems " + packageName + " is not defined in your dapp package.json; 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 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 " + packageName + " is not defined in your dapp embark.json plugins; In future versions of embark this package should be a local dependency and configured as a plugin");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user