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
This commit is contained in:
Anton Nikolaev
2020-09-16 06:30:20 -07:00
committed by Facebook GitHub Bot
parent e48707151a
commit 75e7261d1e
3 changed files with 6 additions and 90 deletions

View File

@@ -91,6 +91,9 @@ export async function getUpdatablePlugins(): Promise<UpdatablePluginDetails[]> {
getPluginInstallationDir(notInstalledPlugin.name),
pkg,
);
if (npmPluginDetails.specVersion === 1) {
return null;
}
return {
...npmPluginDetails,
updateStatus: {

View File

@@ -25,12 +25,6 @@ import semver from 'semver';
const getTmpDir = promisify(tmp.dir) as () => Promise<string>;
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 {