From 75e7261d1e9e283ed2db8db83d77860aac9a7e74 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Wed, 16 Sep 2020 06:30:20 -0700 Subject: [PATCH] Remove support for plugin format v1 Summary: Do not list plugins packaged with format v1 in Plugin Manager. Changelog: removed support for plugins packaged using legacy format (v1), so they won't appear in Plugin Manager anymore. Reviewed By: passy Differential Revision: D23681402 fbshipit-source-id: 1c9496ba6b739069d67228a0f4250f2f01aabd4d --- desktop/app/src/dispatcher/plugins.tsx | 74 +------------------ desktop/plugin-lib/src/getUpdatablePlugins.ts | 3 + desktop/plugin-lib/src/pluginInstaller.ts | 19 +---- 3 files changed, 6 insertions(+), 90 deletions(-) diff --git a/desktop/app/src/dispatcher/plugins.tsx b/desktop/app/src/dispatcher/plugins.tsx index 44cb1651b..95f99c253 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, shell} from 'electron'; +import {ipcRenderer} from 'electron'; import GK from '../fb-stubs/GK'; import {FlipperBasePlugin} from '../plugin'; import {setupMenuBar} from '../MenuBar'; @@ -31,8 +31,6 @@ 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'; import {tryCatchReportPluginFailures, reportUsage} from '../utils/metrics'; import * as FlipperPluginSDK from 'flipper-plugin'; import Immer from 'immer'; @@ -41,10 +39,6 @@ import Immer from 'immer'; import getPluginIndex from '../utils/getDefaultPluginsIndex'; import {SandyPluginDefinition} from 'flipper-plugin'; -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; @@ -75,72 +69,6 @@ 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, diff --git a/desktop/plugin-lib/src/getUpdatablePlugins.ts b/desktop/plugin-lib/src/getUpdatablePlugins.ts index ba325e717..c7e2feecc 100644 --- a/desktop/plugin-lib/src/getUpdatablePlugins.ts +++ b/desktop/plugin-lib/src/getUpdatablePlugins.ts @@ -91,6 +91,9 @@ export async function getUpdatablePlugins(): Promise { getPluginInstallationDir(notInstalledPlugin.name), pkg, ); + if (npmPluginDetails.specVersion === 1) { + return null; + } return { ...npmPluginDetails, updateStatus: { diff --git a/desktop/plugin-lib/src/pluginInstaller.ts b/desktop/plugin-lib/src/pluginInstaller.ts index 9b3823390..7f9d69fbc 100644 --- a/desktop/plugin-lib/src/pluginInstaller.ts +++ b/desktop/plugin-lib/src/pluginInstaller.ts @@ -25,12 +25,6 @@ import semver from 'semver'; const getTmpDir = promisify(tmp.dir) as () => Promise; -function providePluginManager(): PM { - return new PM({ - ignoredDependencies: [/^flipper$/, /^react$/, /^react-dom$/, /^@types\//], - }); -} - function providePluginManagerNoDependencies(): PM { return new PM({ignoredDependencies: [/.*/]}); } @@ -70,18 +64,9 @@ async function installPluginFromTempDir( const destinationDir = getPluginPendingInstallationDir(name, version); if (pluginDetails.specVersion == 1) { - // For first version of spec we need to install dependencies - const pluginManager = providePluginManager(); - // install the plugin dependencies into node_modules - const nodeModulesDir = path.join( - await getTmpDir(), - `${name}-${version}-modules`, + throw new Error( + `Cannot install plugin ${pluginDetails.name} because it is packaged using the unsupported format v1. Please encourage the plugin author to update to v2, following the instructions on https://fbflipper.com/docs/extending/js-setup#migration-to-the-new-plugin-specification`, ); - pluginManager.options.pluginsPath = nodeModulesDir; - await pluginManager.installFromPath(sourceDir); - // live-plugin-manager also installs plugin itself into the target dir, it's better remove it - await fs.remove(path.join(nodeModulesDir, name)); - await fs.move(nodeModulesDir, path.join(sourceDir, 'node_modules')); } try {