read infos from package.json

Summary:
Adding the properties from a plugin's `package.json` as static properties to the class.
The name from `package.json` is used as it's `id`.

This allows us in the future to add meta information about a plugin to it's package.json and still use the data inside the app.

Reviewed By: priteshrnandgaonkar

Differential Revision: D13417288

fbshipit-source-id: 3d0a62d4cb0115153cce1aaee677b9680fefebf4
This commit is contained in:
Daniel Büchele
2018-12-18 08:27:25 -08:00
committed by Facebook Github Bot
parent e23da69db9
commit 6ffc027051
9 changed files with 54 additions and 47 deletions

View File

@@ -18,6 +18,7 @@ import reducers from '../../reducers/index.js';
import Logger from '../../fb-stubs/Logger.js';
import configureStore from 'redux-mock-store';
import {TEST_PASSING_GK, TEST_FAILING_GK} from '../../fb-stubs/GK';
import TestPlugin from './TestPlugin';
const mockStore = configureStore([])(reducers(undefined, {type: 'INIT'}));
const logger = new Logger();
@@ -111,11 +112,17 @@ test('requirePlugin returns null for invalid requires', () => {
});
test('requirePlugin loads plugin', () => {
const name = 'pluginID';
const homepage = 'https://fb.workplace.com/groups/230455004101832/';
const plugin = requirePlugin(require)({
name: 'pluginID',
name,
homepage,
out: path.join(__dirname, 'TestPlugin.js'),
// $FlowFixMe Electron require returns default exports wrapped in an object
}).default;
});
// $FlowFixMe
expect(plugin.prototype).toBeInstanceOf(FlipperPlugin);
// $FlowFixMe
expect(plugin.homepage).toBe(homepage);
// $FlowFixMe
expect(plugin.id).toBe(TestPlugin.id);
});