Enable Marketplace for Flipper (#3491)

Summary:
This is PR on top of: https://github.com/facebook/flipper/pull/3473

It adds an option to Settings to allow distribution of marketplace plugins.

Also includes a simple fetch function to retrieve data from external API/server.

## Changelog

Allow marketplace plugins

Pull Request resolved: https://github.com/facebook/flipper/pull/3491

Test Plan:
1. Enable marketplace
2. Provide custom marketplace server (it will serve the list of internal plugins with downloadURL)
3. Test if can see Available plugins and can download/remove the plugin
4. If new update for the plugin, it should also allow auto update

Reviewed By: antonk52

Differential Revision: D34586339

Pulled By: nikoant

fbshipit-source-id: c887982aa0f0f9abd3b5360f22e8692a2445d345
This commit is contained in:
Anton Nikolaev
2022-03-07 02:49:49 -08:00
committed by Facebook GitHub Bot
parent 5b6000b424
commit 37ff34390a
9 changed files with 175 additions and 19 deletions

View File

@@ -8,9 +8,22 @@
*/
import {MarketplacePluginDetails} from '../reducers/plugins';
import {Store} from '../reducers/index';
export async function loadAvailablePlugins(): Promise<
MarketplacePluginDetails[]
> {
return [];
export async function loadAvailablePlugins(
store: Store,
): Promise<MarketplacePluginDetails[]> {
const {enablePluginMarketplace, marketplaceURL} =
store.getState().settingsState;
try {
if (!enablePluginMarketplace && !marketplaceURL) {
throw new Error('Marketplace is not enabled');
}
const response = await fetch(marketplaceURL);
const plugins = await response.json();
return plugins;
} catch (e) {
console.error('Failed while retrieving marketplace plugins', e);
return [];
}
}