Extend device plugin metadata to include supported devices
Summary: Plugin metadata format extended to include type of each plugin (client / device) and list of supported devices (android/ios/..., emulator/physical, etc). This will allow to detect plugins supported by device even if they are not installed and only available on Marketplace. Reviewed By: mweststrate Differential Revision: D26073531 fbshipit-source-id: e331f1be1af1046cd4220a286a1d52378c26cc53
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1ce619af7e
commit
d7cfcb5d8e
@@ -49,8 +49,10 @@ test('getPluginDetailsV1', async () => {
|
||||
"isBundled": false,
|
||||
"main": "dist/bundle.js",
|
||||
"name": "flipper-plugin-test",
|
||||
"pluginType": "client",
|
||||
"source": "src/index.tsx",
|
||||
"specVersion": 1,
|
||||
"supportedDevices": undefined,
|
||||
"title": "Test Plugin",
|
||||
"version": "2.0.0",
|
||||
}
|
||||
@@ -88,8 +90,10 @@ test('getPluginDetailsV2', async () => {
|
||||
"isBundled": false,
|
||||
"main": "dist/bundle.js",
|
||||
"name": "flipper-plugin-test",
|
||||
"pluginType": "client",
|
||||
"source": "src/index.tsx",
|
||||
"specVersion": 2,
|
||||
"supportedDevices": undefined,
|
||||
"title": "Test",
|
||||
"version": "3.0.1",
|
||||
}
|
||||
@@ -127,8 +131,10 @@ test('id used as title if the latter omited', async () => {
|
||||
"isBundled": false,
|
||||
"main": "dist/bundle.js",
|
||||
"name": "flipper-plugin-test",
|
||||
"pluginType": "client",
|
||||
"source": "src/index.tsx",
|
||||
"specVersion": 2,
|
||||
"supportedDevices": undefined,
|
||||
"title": "test",
|
||||
"version": "3.0.1",
|
||||
}
|
||||
@@ -165,8 +171,10 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
|
||||
"isBundled": false,
|
||||
"main": "dist/bundle.js",
|
||||
"name": "flipper-plugin-test",
|
||||
"pluginType": "client",
|
||||
"source": "src/index.tsx",
|
||||
"specVersion": 2,
|
||||
"supportedDevices": undefined,
|
||||
"title": "test",
|
||||
"version": "3.0.1",
|
||||
}
|
||||
@@ -206,10 +214,75 @@ test('flipper-plugin-version is parsed', async () => {
|
||||
"isBundled": false,
|
||||
"main": "dist/bundle.js",
|
||||
"name": "flipper-plugin-test",
|
||||
"pluginType": "client",
|
||||
"source": "src/index.tsx",
|
||||
"specVersion": 2,
|
||||
"supportedDevices": undefined,
|
||||
"title": "test",
|
||||
"version": "3.0.1",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('plugin type and supported devices parsed', async () => {
|
||||
const pluginV2 = {
|
||||
$schema: 'https://fbflipper.com/schemas/plugin-package/v2.json',
|
||||
name: 'flipper-plugin-test',
|
||||
title: 'Test',
|
||||
version: '3.0.1',
|
||||
pluginType: 'device',
|
||||
supportedDevices: [
|
||||
{os: 'Android', archived: false},
|
||||
{os: 'Android', type: 'physical', specs: ['KaiOS']},
|
||||
{os: 'iOS', type: 'emulator'},
|
||||
],
|
||||
main: 'dist/bundle.js',
|
||||
flipperBundlerEntry: 'src/index.tsx',
|
||||
description: 'Description of Test Plugin',
|
||||
gatekeeper: 'GK_flipper_plugin_test',
|
||||
};
|
||||
jest.mock('fs-extra', () => jest.fn());
|
||||
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
|
||||
const details = await getInstalledPluginDetails(pluginPath);
|
||||
details.dir = normalizePath(details.dir);
|
||||
details.entry = normalizePath(details.entry);
|
||||
expect(details).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"bugs": undefined,
|
||||
"category": undefined,
|
||||
"description": "Description of Test Plugin",
|
||||
"dir": "/Users/mock/.flipper/thirdparty/flipper-plugin-test",
|
||||
"entry": "/Users/mock/.flipper/thirdparty/flipper-plugin-test/dist/bundle.js",
|
||||
"flipperSDKVersion": undefined,
|
||||
"gatekeeper": "GK_flipper_plugin_test",
|
||||
"icon": undefined,
|
||||
"id": "flipper-plugin-test",
|
||||
"isActivatable": true,
|
||||
"isBundled": false,
|
||||
"main": "dist/bundle.js",
|
||||
"name": "flipper-plugin-test",
|
||||
"pluginType": "device",
|
||||
"source": "src/index.tsx",
|
||||
"specVersion": 2,
|
||||
"supportedDevices": Array [
|
||||
Object {
|
||||
"archived": false,
|
||||
"os": "Android",
|
||||
},
|
||||
Object {
|
||||
"os": "Android",
|
||||
"specs": Array [
|
||||
"KaiOS",
|
||||
],
|
||||
"type": "physical",
|
||||
},
|
||||
Object {
|
||||
"os": "iOS",
|
||||
"type": "emulator",
|
||||
},
|
||||
],
|
||||
"title": "Test",
|
||||
"version": "3.0.1",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user