storing information about failed plugins

Summary:
If a plugin was not loaded we used to ignore it. This diff still ignores the plugins that weren't loaded, but adds some information about them to the redux store. This information is used in the PluginDebugger.

These are the three reasons, why a plugin might not be loaded.

* `gatekeepedPlugins`: Plugin was ignored because of a GK
* `failedPlugins`: Plugin could not be requried/failed to parse
* `disabledPlugins`: Plugin disabled in `~/.flipper/config.json`

Information for each them is added to the redux store.

Reviewed By: passy

Differential Revision: D13516986

fbshipit-source-id: b7a55a159cb586d1a88fbb976248131c52a909c5
This commit is contained in:
Daniel Büchele
2018-12-20 06:07:54 -08:00
committed by Facebook Github Bot
parent 9ec04d33e2
commit 6827515329
5 changed files with 155 additions and 37 deletions

View File

@@ -26,7 +26,7 @@ const logger = new Logger();
test('dispatcher dispatches REGISTER_PLUGINS', () => {
dispatcher(mockStore, logger);
const actions = mockStore.getActions();
expect(actions[0].type).toBe('REGISTER_PLUGINS');
expect(actions.map(a => a.type)).toContain('REGISTER_PLUGINS');
});
test('getDynamicPlugins returns empty array', () => {
@@ -56,7 +56,7 @@ test('checkDisabled', () => {
const config = {disabledPlugins: [disabledPlugin]};
// $FlowFixMe process.env not defined in electron API spec
remote.process.env.CONFIG = JSON.stringify(config);
const disabled = checkDisabled();
const disabled = checkDisabled([]);
expect(
disabled({
@@ -75,7 +75,7 @@ test('checkDisabled', () => {
test('checkGK for plugin without GK', () => {
expect(
checkGK({
checkGK([])({
name: 'pluginID',
out: './test/index.js',
}),
@@ -84,7 +84,7 @@ test('checkGK for plugin without GK', () => {
test('checkGK for passing plugin', () => {
expect(
checkGK({
checkGK([])({
name: 'pluginID',
gatekeeper: TEST_PASSING_GK,
out: './test/index.js',
@@ -93,17 +93,20 @@ test('checkGK for passing plugin', () => {
});
test('checkGK for failing plugin', () => {
expect(
checkGK({
name: 'pluginID',
gatekeeper: TEST_FAILING_GK,
out: './test/index.js',
}),
).toBeFalsy();
const gatekeepedPlugins = [];
const name = 'pluginID';
const plugins = checkGK(gatekeepedPlugins)({
name,
gatekeeper: TEST_FAILING_GK,
out: './test/index.js',
});
expect(plugins).toBeFalsy();
expect(gatekeepedPlugins[0].name).toEqual(name);
});
test('requirePlugin returns null for invalid requires', () => {
const plugin = requirePlugin(require)({
const plugin = requirePlugin([], require)({
name: 'pluginID',
out: 'this/path/does not/exist',
});
@@ -114,7 +117,7 @@ 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)({
const plugin = requirePlugin([], require)({
name,
homepage,
out: path.join(__dirname, 'TestPlugin.js'),