diff --git a/desktop/app/src/dispatcher/plugins.tsx b/desktop/app/src/dispatcher/plugins.tsx index 34ecac8ee..9f389ee73 100644 --- a/desktop/app/src/dispatcher/plugins.tsx +++ b/desktop/app/src/dispatcher/plugins.tsx @@ -20,7 +20,7 @@ import { addDisabledPlugins, addFailedPlugins, } from '../reducers/plugins'; -import {ipcRenderer} from 'electron'; +import {ipcRenderer, shell} from 'electron'; import GK from '../fb-stubs/GK'; import {FlipperBasePlugin} from '../plugin'; import {setupMenuBar} from '../MenuBar'; @@ -31,10 +31,16 @@ import {notNull} from '../utils/typeUtils'; import {sideEffect} from '../utils/sideEffect'; import semver from 'semver'; import {PluginDetails} from 'flipper-plugin-lib'; +import {addNotification} from '../reducers/notifications'; +import styled from '@emotion/styled'; // eslint-disable-next-line import/no-unresolved import getPluginIndex from '../utils/getDefaultPluginsIndex'; +const Paragraph = styled.p({ + marginBottom: '0.1em', +}); + export default (store: Store, logger: Logger) => { // expose Flipper and exact globally for dynamically loaded plugins const globalObject: any = typeof window === 'undefined' ? global : window; @@ -61,6 +67,73 @@ export default (store: Store, logger: Logger) => { store.dispatch(addDisabledPlugins(disabledPlugins)); store.dispatch(addFailedPlugins(failedPlugins)); store.dispatch(registerPlugins(initialPlugins)); + const deprecatedSpecPlugins = initialPlugins.filter( + (p) => !p.isDefault && p.details.specVersion === 1, + ); + + for (const plugin of deprecatedSpecPlugins) { + store.dispatch( + addNotification({ + pluginId: plugin.id, + client: null, + notification: { + id: `plugin-spec-v1-deprecation-${plugin.packageName}`, + title: `Plugin "${plugin.title}" will stop working after version 0.48 of Flipper released, because it is packaged using the deprecated format.`, + message: ( + <> + + Please try to install a newer version of this plugin packaged + using "Install Plugins" tab on "Manage Plugins" form. + + + If the latest version of the plugin is still packaged in the old + format, please contact the author and consider raising a pull + request for upgrading the plugin. You can find contact details + on the package page  + + shell.openExternal( + `https://www.npmjs.com/package/${plugin.packageName}`, + ) + }> + https://www.npmjs.com/package/{plugin.packageName} + + . + + + If you are the author of this plugin, please migrate your plugin + to the new format, and publish new version of it. See  + + shell.openExternal( + 'https://fbflipper.com/docs/extending/js-setup#migration-to-the-new-plugin-specification', + ) + }> + https://fbflipper.com/docs/extending/js-setup#migration-to-the-new-plugin-specification + +  on how to migrate the plugin. See  + + shell.openExternal( + 'https://fbflipper.com/docs/extending/js-setup#package-format', + ) + }> + https://fbflipper.com/docs/extending/js-setup#package-format + +  for details on plugin package format. + + + ), + severity: 'error', + timestamp: Date.now(), + category: `Plugin Spec V1 Deprecation`, + }, + }), + ); + } sideEffect( store, @@ -176,6 +249,7 @@ export const requirePlugin = ( plugin.id = plugin.id || pluginDetails.id; plugin.packageName = pluginDetails.name; + plugin.details = pluginDetails; // set values from package.json as static variables on class Object.keys(pluginDetails).forEach((key) => { diff --git a/desktop/app/src/plugin.tsx b/desktop/app/src/plugin.tsx index 7bc68468b..d237bfc5c 100644 --- a/desktop/app/src/plugin.tsx +++ b/desktop/app/src/plugin.tsx @@ -20,6 +20,7 @@ import {Idler} from './utils/Idler'; import {StaticView} from './reducers/connections'; import {State as ReduxState} from './reducers'; import {DEFAULT_MAX_QUEUE_SIZE} from './reducers/pluginMessageQueue'; +import {PluginDetails} from 'flipper-plugin-lib'; type Parameters = {[key: string]: any}; // This function is intended to be called from outside of the plugin. @@ -102,10 +103,7 @@ export abstract class FlipperBasePlugin< static gatekeeper: string | null = null; static entry: string | null = null; static isDefault: boolean; - static bugs: { - email?: string; - url?: string; - } | null = null; + static details: PluginDetails; static keyboardActions: KeyboardActions | null; static screenshot: string | null; static defaultPersistedState: any;