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:
committed by
Facebook GitHub Bot
parent
9c5f59e109
commit
02d695cb28
@@ -14,11 +14,14 @@ import expandTilde from 'expand-tilde';
|
||||
|
||||
const flipperDataDir = path.join(homedir(), '.flipper');
|
||||
|
||||
export const pluginInstallationDir = path.join(flipperDataDir, 'thirdparty');
|
||||
|
||||
export const pluginPendingInstallationDir = path.join(
|
||||
export const legacyPluginInstallationDir = path.join(
|
||||
flipperDataDir,
|
||||
'pending',
|
||||
'thirdparty',
|
||||
);
|
||||
|
||||
export const pluginInstallationDir = path.join(
|
||||
flipperDataDir,
|
||||
'installed-plugins',
|
||||
);
|
||||
|
||||
export const pluginCacheDir = path.join(flipperDataDir, 'plugins');
|
||||
@@ -43,27 +46,20 @@ export async function getPluginSourceFolders(): Promise<string[]> {
|
||||
return pluginFolders.map(expandTilde).filter(fs.existsSync);
|
||||
}
|
||||
|
||||
export function getPluginPendingInstallationDir(
|
||||
name: string,
|
||||
version: string,
|
||||
): string {
|
||||
return path.join(getPluginPendingInstallationsDir(name), version);
|
||||
}
|
||||
|
||||
export function getPluginPendingInstallationsDir(name: string): string {
|
||||
return path.join(
|
||||
pluginPendingInstallationDir,
|
||||
getPluginDirNameFromPackageName(name),
|
||||
);
|
||||
}
|
||||
|
||||
export function getPluginInstallationDir(name: string): string {
|
||||
export function getPluginInstallationDir(name: string) {
|
||||
return path.join(
|
||||
pluginInstallationDir,
|
||||
getPluginDirNameFromPackageName(name),
|
||||
);
|
||||
}
|
||||
|
||||
export function getPluginVersionInstallationDir(
|
||||
name: string,
|
||||
version: string,
|
||||
): string {
|
||||
return path.join(getPluginInstallationDir(name), version);
|
||||
}
|
||||
|
||||
export function getPluginDirNameFromPackageName(name: string) {
|
||||
return name.replace('/', '__');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user