Plugin Marketplace API

Summary: Extracted plugin marketplace API to a separate file and updated it to load full plugin manifests.

Reviewed By: passy

Differential Revision: D25181759

fbshipit-source-id: a63f9ce16249ccc170df148cef5c209fdc6d4d6d
This commit is contained in:
Anton Nikolaev
2020-12-15 09:28:58 -08:00
committed by Facebook GitHub Bot
parent 658b3e8a91
commit 5b26f36672
11 changed files with 152 additions and 58 deletions

View File

@@ -9,7 +9,7 @@
import fs from 'fs-extra';
import path from 'path';
import getPluginDetails from '../getPluginDetails';
import {getPluginDetailsFromDir} from '../getPluginDetails';
import {pluginInstallationDir} from '../pluginPaths';
import {normalizePath} from 'flipper-test-utils';
@@ -31,7 +31,7 @@ test('getPluginDetailsV1', async () => {
};
jest.mock('fs-extra', () => jest.fn());
fs.readJson = jest.fn().mockImplementation(() => pluginV1);
const details = await getPluginDetails(pluginPath);
const details = await getPluginDetailsFromDir(pluginPath);
details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(`
@@ -69,7 +69,7 @@ test('getPluginDetailsV2', async () => {
};
jest.mock('fs-extra', () => jest.fn());
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
const details = await getPluginDetails(pluginPath);
const details = await getPluginDetailsFromDir(pluginPath);
details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(`
@@ -107,7 +107,7 @@ test('id used as title if the latter omited', async () => {
};
jest.mock('fs-extra', () => jest.fn());
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
const details = await getPluginDetails(pluginPath);
const details = await getPluginDetailsFromDir(pluginPath);
details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(`
@@ -144,7 +144,7 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
};
jest.mock('fs-extra', () => jest.fn());
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
const details = await getPluginDetails(pluginPath);
const details = await getPluginDetailsFromDir(pluginPath);
details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(`
@@ -184,7 +184,7 @@ test('flipper-plugin-version is parsed', async () => {
};
jest.mock('fs-extra', () => jest.fn());
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
const details = await getPluginDetails(pluginPath);
const details = await getPluginDetailsFromDir(pluginPath);
details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(`