Keep multiple installed versions of each plugin

Summary:
This diff changes directory structure for installed plugins to allow installation of multiple versions simultaneously, e.g. to to allow downloading new plugin version while user is still using the previous one, and to have possibility of fast rollback to the previous installed if necessary. The new folder for installed plugins is located in `~/.flipper/installed-plugins` and has the following structure:

  flipper-plugin-reactotron
    1.0.0
      ...
      package.json
    1.0.1
      ...
      package.json
  flipper-plugin-network
    0.67.1
      ...
      package.json
    0.67.2
      ...
      package.json

The tricky part here is that we also need to migrate already installed plugins from the old folder `~/.flipper/thirdparty` to the new folder and maintain the new structure for them.

Another tricky part is that we need to periodically cleanup old versions. For now we will just keep 2 versions of each plugin. Cleanup is performed in background right after Flipper startup.

Reviewed By: mweststrate

Differential Revision: D25393474

fbshipit-source-id: 26617ac26114148f797cc3d6765a42242edc205e
This commit is contained in:
Anton Nikolaev
2020-12-15 09:28:58 -08:00
committed by Facebook GitHub Bot
parent 9c5f59e109
commit 02d695cb28
15 changed files with 194 additions and 398 deletions

View File

@@ -10,7 +10,7 @@
import fs from 'fs-extra';
import path from 'path';
import {PluginDetails} from './PluginDetails';
import {getPluginInstallationDir, pluginCacheDir} from './pluginPaths';
import {getPluginVersionInstallationDir, pluginCacheDir} from './pluginPaths';
export async function getPluginDetails(pluginDir: string, packageJson: any) {
const specVersion =
@@ -37,7 +37,10 @@ export async function getPluginDetailsFromDir(
}
export async function getPluginDetailsFromPackageJson(packageJson: any) {
const pluginDir = getPluginInstallationDir(packageJson.name);
const pluginDir = getPluginVersionInstallationDir(
packageJson.name,
packageJson.version,
);
return await getPluginDetails(pluginDir, packageJson);
}