Enrich plugin metadata on what apps they support and add unit tests
Summary: - This Diff is part 1 of 2 of milestone 1 of my internship project flipper self sufficiency. The task can be found here - https://www.internalfb.com/tasks?q=958574791613645&t=91334896 - I have extended the plugin package meta data format to support a "supportedApps" field that consists of appID (facebook, instagram, messenger etc) along with OS and type that were previously defined in supportedDevices as well. - The diff also adds unit tests for this new format to ensure addition of the supportedApps field does not break anything. Reviewed By: nikoant Differential Revision: D30133225 fbshipit-source-id: 6ef0d1cadd61c0d69640cf61793322acb4cd65f4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1a7e3b9b00
commit
025ca05d62
@@ -76,6 +76,30 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"supportedApps": {
|
||||||
|
"description": "List of apps supported by the plugin.",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"description": "App definition. E.g. {\"appID\": \"Facebook\", \"os\": \"Android\", \"type\": \"physical\"} means that plugin supports only Facebook app on Android physical devices.",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"appID": {
|
||||||
|
"description": "App name: Facebook, Instagram or Messenger.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"os": {
|
||||||
|
"description": "Device OS: iOS, Android or Metro. Lack of this property means that all OSes supported.",
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["iOS", "Android", "Metro"]
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"description": "Device type: physical or emulator or dummy. Lack of this property means it supports physical, emulator and dummy devices.",
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["physical", "emulator"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export interface PluginDetails {
|
|||||||
flipperSDKVersion?: string;
|
flipperSDKVersion?: string;
|
||||||
pluginType?: PluginType;
|
pluginType?: PluginType;
|
||||||
supportedDevices?: SupportedDevice[];
|
supportedDevices?: SupportedDevice[];
|
||||||
|
supportedApps?: SupportedApp[];
|
||||||
publishedDocs?: {
|
publishedDocs?: {
|
||||||
overview?: boolean;
|
overview?: boolean;
|
||||||
setup?: boolean;
|
setup?: boolean;
|
||||||
@@ -42,6 +43,12 @@ export interface SupportedDevice {
|
|||||||
readonly specs?: DeviceSpec[];
|
readonly specs?: DeviceSpec[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SupportedApp {
|
||||||
|
readonly appID?: string;
|
||||||
|
readonly os?: OS;
|
||||||
|
readonly type?: DeviceType;
|
||||||
|
}
|
||||||
|
|
||||||
export type OS = 'iOS' | 'Android' | 'Metro';
|
export type OS = 'iOS' | 'Android' | 'Metro';
|
||||||
|
|
||||||
export type DeviceType = 'emulator' | 'physical' | 'dummy';
|
export type DeviceType = 'emulator' | 'physical' | 'dummy';
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ test('getPluginDetailsV1', async () => {
|
|||||||
"pluginType": undefined,
|
"pluginType": undefined,
|
||||||
"source": "src/index.tsx",
|
"source": "src/index.tsx",
|
||||||
"specVersion": 1,
|
"specVersion": 1,
|
||||||
|
"supportedApps": undefined,
|
||||||
"supportedDevices": undefined,
|
"supportedDevices": undefined,
|
||||||
"title": "Test Plugin",
|
"title": "Test Plugin",
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@@ -97,6 +98,7 @@ test('getPluginDetailsV2', async () => {
|
|||||||
"publishedDocs": undefined,
|
"publishedDocs": undefined,
|
||||||
"source": "src/index.tsx",
|
"source": "src/index.tsx",
|
||||||
"specVersion": 2,
|
"specVersion": 2,
|
||||||
|
"supportedApps": undefined,
|
||||||
"supportedDevices": undefined,
|
"supportedDevices": undefined,
|
||||||
"title": "Test",
|
"title": "Test",
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
@@ -139,6 +141,7 @@ test('id used as title if the latter omited', async () => {
|
|||||||
"publishedDocs": undefined,
|
"publishedDocs": undefined,
|
||||||
"source": "src/index.tsx",
|
"source": "src/index.tsx",
|
||||||
"specVersion": 2,
|
"specVersion": 2,
|
||||||
|
"supportedApps": undefined,
|
||||||
"supportedDevices": undefined,
|
"supportedDevices": undefined,
|
||||||
"title": "test",
|
"title": "test",
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
@@ -180,6 +183,7 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
|
|||||||
"publishedDocs": undefined,
|
"publishedDocs": undefined,
|
||||||
"source": "src/index.tsx",
|
"source": "src/index.tsx",
|
||||||
"specVersion": 2,
|
"specVersion": 2,
|
||||||
|
"supportedApps": undefined,
|
||||||
"supportedDevices": undefined,
|
"supportedDevices": undefined,
|
||||||
"title": "test",
|
"title": "test",
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
@@ -224,6 +228,7 @@ test('flipper-plugin-version is parsed', async () => {
|
|||||||
"publishedDocs": undefined,
|
"publishedDocs": undefined,
|
||||||
"source": "src/index.tsx",
|
"source": "src/index.tsx",
|
||||||
"specVersion": 2,
|
"specVersion": 2,
|
||||||
|
"supportedApps": undefined,
|
||||||
"supportedDevices": undefined,
|
"supportedDevices": undefined,
|
||||||
"title": "test",
|
"title": "test",
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
@@ -272,6 +277,7 @@ test('plugin type and supported devices parsed', async () => {
|
|||||||
"publishedDocs": undefined,
|
"publishedDocs": undefined,
|
||||||
"source": "src/index.tsx",
|
"source": "src/index.tsx",
|
||||||
"specVersion": 2,
|
"specVersion": 2,
|
||||||
|
"supportedApps": undefined,
|
||||||
"supportedDevices": Array [
|
"supportedDevices": Array [
|
||||||
Object {
|
Object {
|
||||||
"archived": false,
|
"archived": false,
|
||||||
@@ -295,6 +301,71 @@ test('plugin type and supported devices parsed', async () => {
|
|||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('plugin type and supported apps parsed', async () => {
|
||||||
|
const pluginV2 = {
|
||||||
|
$schema: 'https://fbflipper.com/schemas/plugin-package/v2.json',
|
||||||
|
name: 'flipper-plugin-test',
|
||||||
|
title: 'Test',
|
||||||
|
version: '3.0.1',
|
||||||
|
pluginType: 'client',
|
||||||
|
supportedApps: [
|
||||||
|
{appID: 'Messenger', os: 'Android', type: 'emulator'},
|
||||||
|
{appID: 'Instagram', os: 'Android', type: 'physical'},
|
||||||
|
{appID: 'Facebook', os: 'iOS', type: 'emulator'},
|
||||||
|
],
|
||||||
|
main: 'dist/bundle.js',
|
||||||
|
flipperBundlerEntry: 'src/index.tsx',
|
||||||
|
description: 'Description of Test Plugin',
|
||||||
|
gatekeeper: 'GK_flipper_plugin_test',
|
||||||
|
};
|
||||||
|
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",
|
||||||
|
"engines": undefined,
|
||||||
|
"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": "client",
|
||||||
|
"publishedDocs": undefined,
|
||||||
|
"source": "src/index.tsx",
|
||||||
|
"specVersion": 2,
|
||||||
|
"supportedApps": Array [
|
||||||
|
Object {
|
||||||
|
"appID": "Messenger",
|
||||||
|
"os": "Android",
|
||||||
|
"type": "emulator",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"appID": "Instagram",
|
||||||
|
"os": "Android",
|
||||||
|
"type": "physical",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"appID": "Facebook",
|
||||||
|
"os": "iOS",
|
||||||
|
"type": "emulator",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"supportedDevices": undefined,
|
||||||
|
"title": "Test",
|
||||||
|
"version": "3.0.1",
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
test('can merge two package.json files', async () => {
|
test('can merge two package.json files', async () => {
|
||||||
const pluginBase = {
|
const pluginBase = {
|
||||||
$schema: 'https://fbflipper.com/schemas/plugin-package/v2.json',
|
$schema: 'https://fbflipper.com/schemas/plugin-package/v2.json',
|
||||||
@@ -359,6 +430,7 @@ test('can merge two package.json files', async () => {
|
|||||||
},
|
},
|
||||||
"source": "src/index.tsx",
|
"source": "src/index.tsx",
|
||||||
"specVersion": 2,
|
"specVersion": 2,
|
||||||
|
"supportedApps": undefined,
|
||||||
"supportedDevices": Array [
|
"supportedDevices": Array [
|
||||||
Object {
|
Object {
|
||||||
"archived": false,
|
"archived": false,
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ function getPluginDetailsV1(packageJson: any): PluginDetails {
|
|||||||
flipperSDKVersion: packageJson?.peerDependencies?.['flipper-plugin'],
|
flipperSDKVersion: packageJson?.peerDependencies?.['flipper-plugin'],
|
||||||
pluginType: packageJson?.pluginType,
|
pluginType: packageJson?.pluginType,
|
||||||
supportedDevices: packageJson?.supportedDevices,
|
supportedDevices: packageJson?.supportedDevices,
|
||||||
|
supportedApps: packageJson?.supportedApps,
|
||||||
engines: packageJson.engines,
|
engines: packageJson.engines,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -149,6 +150,7 @@ function getPluginDetailsV2(packageJson: any): PluginDetails {
|
|||||||
flipperSDKVersion: packageJson?.peerDependencies?.['flipper-plugin'],
|
flipperSDKVersion: packageJson?.peerDependencies?.['flipper-plugin'],
|
||||||
pluginType: packageJson?.pluginType,
|
pluginType: packageJson?.pluginType,
|
||||||
supportedDevices: packageJson?.supportedDevices,
|
supportedDevices: packageJson?.supportedDevices,
|
||||||
|
supportedApps: packageJson?.supportedApps,
|
||||||
engines: packageJson.engines,
|
engines: packageJson.engines,
|
||||||
publishedDocs: packageJson.publishedDocs,
|
publishedDocs: packageJson.publishedDocs,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user