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
44 lines
893 B
TypeScript
44 lines
893 B
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {Actions} from './';
|
|
import {PluginDetails} from 'flipper-plugin-lib';
|
|
|
|
export type State = {
|
|
installedPlugins: PluginDetails[];
|
|
};
|
|
|
|
export type Action = {
|
|
type: 'REGISTER_INSTALLED_PLUGINS';
|
|
payload: PluginDetails[];
|
|
};
|
|
|
|
const INITIAL_STATE: State = {
|
|
installedPlugins: [],
|
|
};
|
|
|
|
export default function reducer(
|
|
state: State = INITIAL_STATE,
|
|
action: Actions,
|
|
): State {
|
|
if (action.type === 'REGISTER_INSTALLED_PLUGINS') {
|
|
return {
|
|
...state,
|
|
installedPlugins: action.payload,
|
|
};
|
|
} else {
|
|
return state;
|
|
}
|
|
}
|
|
|
|
export const registerInstalledPlugins = (payload: PluginDetails[]): Action => ({
|
|
type: 'REGISTER_INSTALLED_PLUGINS',
|
|
payload,
|
|
});
|