Remove plugin bundling
Summary: Remove the notion of bundled plugins Reviewed By: lblasa Differential Revision: D39308888 fbshipit-source-id: aa88ddbf2801ad1da95f89e4c761259b697b0d66
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f835e07c46
commit
650ff4bcfb
@@ -168,34 +168,6 @@ test('uninstall plugin', async () => {
|
||||
expect(mockClient.sandyPluginStates.has('plugin1')).toBeFalsy();
|
||||
});
|
||||
|
||||
test('uninstall bundled plugin', async () => {
|
||||
const pluginDetails = TestUtils.createMockBundledPluginDetails({
|
||||
id: 'bundled-plugin',
|
||||
name: 'flipper-bundled-plugin',
|
||||
version: '0.43.0',
|
||||
});
|
||||
const pluginDefinition = new SandyPluginDefinition(pluginDetails, TestPlugin);
|
||||
mockedRequirePlugin.mockReturnValue(Promise.resolve(pluginDefinition));
|
||||
mockFlipper.dispatch(
|
||||
loadPlugin({plugin: pluginDetails, enable: true, notifyIfFailed: false}),
|
||||
);
|
||||
mockFlipper.dispatch(uninstallPlugin({plugin: pluginDefinition}));
|
||||
|
||||
await awaitPluginCommandQueueEmpty(mockFlipper.store);
|
||||
expect(
|
||||
mockFlipper.getState().plugins.clientPlugins.has('bundled-plugin'),
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
mockFlipper.getState().plugins.loadedPlugins.has('bundled-plugin'),
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
mockFlipper
|
||||
.getState()
|
||||
.plugins.uninstalledPluginNames.has('flipper-bundled-plugin'),
|
||||
).toBeTruthy();
|
||||
expect(mockClient.sandyPluginStates.has('bundled-plugin')).toBeFalsy();
|
||||
});
|
||||
|
||||
test('star plugin', async () => {
|
||||
mockFlipper.dispatch(
|
||||
loadPlugin({plugin: pluginDetails1, enable: false, notifyIfFailed: false}),
|
||||
|
||||
@@ -38,7 +38,6 @@ const sampleInstalledPluginDetails: InstalledPluginDetails = {
|
||||
title: 'Sample',
|
||||
dir: '/Users/mock/.flipper/thirdparty/flipper-plugin-sample',
|
||||
entry: 'this/path/does not/exist',
|
||||
isBundled: false,
|
||||
isActivatable: true,
|
||||
};
|
||||
|
||||
@@ -112,7 +111,6 @@ test('requirePluginInternal loads valid Sandy plugin', async () => {
|
||||
expect(plugin.details).toMatchObject({
|
||||
flipperSDKVersion: '0.0.0',
|
||||
id: 'Sample',
|
||||
isBundled: false,
|
||||
main: 'dist/bundle.js',
|
||||
name: 'pluginID',
|
||||
source: 'src/index.js',
|
||||
@@ -170,7 +168,6 @@ test('requirePluginInternal loads valid Sandy Device plugin', async () => {
|
||||
expect(plugin.details).toMatchObject({
|
||||
flipperSDKVersion: '0.0.0',
|
||||
id: 'Sample',
|
||||
isBundled: false,
|
||||
main: 'dist/bundle.js',
|
||||
name: 'pluginID',
|
||||
source: 'src/index.js',
|
||||
|
||||
@@ -367,11 +367,6 @@ async function verifyPluginStatus(
|
||||
return [false, status];
|
||||
}
|
||||
break;
|
||||
case 'bundle_installable': {
|
||||
// For convenience, don't ask user to install bundled plugins, handle it directly
|
||||
await installBundledPlugin(store, pluginId, title);
|
||||
break;
|
||||
}
|
||||
case 'marketplace_installable': {
|
||||
if (!(await installMarketPlacePlugin(store, pluginId, title))) {
|
||||
return [false, status];
|
||||
@@ -384,30 +379,6 @@ async function verifyPluginStatus(
|
||||
}
|
||||
}
|
||||
|
||||
async function installBundledPlugin(
|
||||
store: Store,
|
||||
pluginId: string,
|
||||
title: string,
|
||||
) {
|
||||
const plugin = store.getState().plugins.bundledPlugins.get(pluginId);
|
||||
if (!plugin || !plugin.isBundled) {
|
||||
throw new Error(`Failed to find bundled plugin '${pluginId}'`);
|
||||
}
|
||||
const loadingDialog = Dialog.loading({
|
||||
title,
|
||||
message: `Loading plugin '${pluginId}'...`,
|
||||
});
|
||||
store.dispatch(loadPlugin({plugin, enable: true, notifyIfFailed: true}));
|
||||
try {
|
||||
await waitFor(
|
||||
store,
|
||||
() => getPluginStatus(store, pluginId)[0] !== 'bundle_installable',
|
||||
);
|
||||
} finally {
|
||||
loadingDialog.close();
|
||||
}
|
||||
}
|
||||
|
||||
async function installMarketPlacePlugin(
|
||||
store: Store,
|
||||
pluginId: string,
|
||||
|
||||
@@ -183,9 +183,7 @@ function uninstallPlugin(store: Store, {plugin}: UninstallPluginActionPayload) {
|
||||
clients.forEach((client) => {
|
||||
stopPlugin(client, plugin.id);
|
||||
});
|
||||
if (!plugin.details.isBundled) {
|
||||
unloadPluginModule(plugin.details);
|
||||
}
|
||||
unloadPluginModule(plugin.details);
|
||||
store.dispatch(pluginUninstalled(plugin.details));
|
||||
} catch (err) {
|
||||
console.error(
|
||||
@@ -368,9 +366,5 @@ function stopPlugin(
|
||||
}
|
||||
|
||||
function unloadPluginModule(plugin: ActivatablePluginDetails) {
|
||||
if (plugin.isBundled) {
|
||||
// We cannot unload bundled plugin.
|
||||
return;
|
||||
}
|
||||
getRenderHostInstance().unloadModule?.(plugin.entry);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
addDisabledPlugins,
|
||||
addFailedPlugins,
|
||||
registerLoadedPlugins,
|
||||
registerBundledPlugins,
|
||||
registerMarketplacePlugins,
|
||||
pluginsInitialized,
|
||||
} from '../reducers/plugins';
|
||||
@@ -73,7 +72,6 @@ class UIPluginInitializer extends AbstractPluginInitializer {
|
||||
);
|
||||
}
|
||||
|
||||
this.store.dispatch(registerBundledPlugins(this.bundledPlugins));
|
||||
this.store.dispatch(registerLoadedPlugins(this.loadedPlugins));
|
||||
this.store.dispatch(addGatekeepedPlugins(this.gatekeepedPlugins));
|
||||
this.store.dispatch(addDisabledPlugins(this.disabledPlugins));
|
||||
|
||||
Reference in New Issue
Block a user