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
@@ -33,6 +33,7 @@ const samplePluginDetails1: UpdatablePluginDetails = {
|
||||
entry: './test/index.js',
|
||||
version: '0.1.0',
|
||||
specVersion: 2,
|
||||
pluginType: 'client',
|
||||
main: 'dist/bundle.js',
|
||||
dir: '/Users/mock/.flipper/thirdparty/flipper-plugin-sample1',
|
||||
source: 'src/index.js',
|
||||
@@ -52,6 +53,7 @@ const samplePluginDetails2: UpdatablePluginDetails = {
|
||||
entry: './test/index.js',
|
||||
version: '0.2.0',
|
||||
specVersion: 2,
|
||||
pluginType: 'client',
|
||||
main: 'dist/bundle.js',
|
||||
dir: '/Users/mock/.flipper/thirdparty/flipper-plugin-sample2',
|
||||
source: 'src/index.js',
|
||||
|
||||
@@ -16,6 +16,7 @@ import type {LogLevel, DeviceType} from 'flipper-plugin';
|
||||
import which from 'which';
|
||||
import {spawn} from 'child_process';
|
||||
import {dirname} from 'path';
|
||||
import {DeviceSpec} from 'flipper-plugin-lib';
|
||||
|
||||
const DEVICE_RECORDING_DIR = '/sdcard/flipper_recorder';
|
||||
|
||||
@@ -27,8 +28,9 @@ export default class AndroidDevice extends BaseDevice {
|
||||
adb: ADBClient,
|
||||
abiList: Array<string>,
|
||||
sdkVersion: string,
|
||||
specs: DeviceSpec[] = [],
|
||||
) {
|
||||
super(serial, deviceType, title, 'Android');
|
||||
super(serial, deviceType, title, 'Android', specs);
|
||||
this.adb = adb;
|
||||
this.icon = 'icons/android.svg';
|
||||
this.abiList = abiList;
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
} from 'flipper-plugin';
|
||||
import type {DevicePluginDefinition, DevicePluginMap} from '../plugin';
|
||||
import {getFlipperLibImplementation} from '../utils/flipperLibImplementation';
|
||||
import {DeviceSpec, OS as PluginOS} from 'flipper-plugin-lib';
|
||||
|
||||
export type DeviceShell = {
|
||||
stdout: stream.Readable;
|
||||
@@ -24,6 +25,8 @@ export type DeviceShell = {
|
||||
stdin: stream.Writable;
|
||||
};
|
||||
|
||||
export type OS = PluginOS | 'Windows' | 'MacOS' | 'JSWebApp';
|
||||
|
||||
export type DeviceExport = {
|
||||
os: OS;
|
||||
title: string;
|
||||
@@ -32,14 +35,19 @@ export type DeviceExport = {
|
||||
logs: Array<DeviceLogEntry>;
|
||||
};
|
||||
|
||||
export type OS = 'iOS' | 'Android' | 'Windows' | 'MacOS' | 'JSWebApp' | 'Metro';
|
||||
|
||||
export default class BaseDevice {
|
||||
constructor(serial: string, deviceType: DeviceType, title: string, os: OS) {
|
||||
constructor(
|
||||
serial: string,
|
||||
deviceType: DeviceType,
|
||||
title: string,
|
||||
os: OS,
|
||||
specs: DeviceSpec[] = [],
|
||||
) {
|
||||
this.serial = serial;
|
||||
this.title = title;
|
||||
this.deviceType = deviceType;
|
||||
this.os = os;
|
||||
this.specs = specs;
|
||||
}
|
||||
|
||||
// operating system of this device
|
||||
@@ -54,6 +62,9 @@ export default class BaseDevice {
|
||||
// serial number for this device
|
||||
serial: string;
|
||||
|
||||
// additional device specs used for plugin compatibility checks
|
||||
specs: DeviceSpec[];
|
||||
|
||||
// possible src of icon to display next to the device title
|
||||
icon: string | null | undefined;
|
||||
|
||||
|
||||
@@ -7,9 +7,22 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {DeviceType} from 'flipper-plugin-lib';
|
||||
import AndroidDevice from './AndroidDevice';
|
||||
import {Client as ADBClient} from 'adbkit';
|
||||
|
||||
export default class KaiOSDevice extends AndroidDevice {
|
||||
constructor(
|
||||
serial: string,
|
||||
deviceType: DeviceType,
|
||||
title: string,
|
||||
adb: ADBClient,
|
||||
abiList: Array<string>,
|
||||
sdkVersion: string,
|
||||
) {
|
||||
super(serial, deviceType, title, adb, abiList, sdkVersion, ['KaiOS']);
|
||||
}
|
||||
|
||||
async screenCaptureAvailable() {
|
||||
// The default way of capturing screenshots through adb does not seem to work
|
||||
// There is a way of getting a screenshot through KaiOS dev tools though
|
||||
|
||||
@@ -41,6 +41,7 @@ const sampleInstalledPluginDetails: InstalledPluginDetails = {
|
||||
name: 'other Name',
|
||||
version: '1.0.0',
|
||||
specVersion: 2,
|
||||
pluginType: 'client',
|
||||
main: 'dist/bundle.js',
|
||||
source: 'src/index.js',
|
||||
id: 'Sample',
|
||||
|
||||
@@ -261,6 +261,7 @@ export default function createTableNativePlugin(id: string, title: string) {
|
||||
title,
|
||||
icon: 'apps',
|
||||
name: id,
|
||||
pluginType: 'client',
|
||||
// all hmm...
|
||||
specVersion: 1,
|
||||
version: 'auto',
|
||||
|
||||
@@ -88,6 +88,7 @@ test('add gatekeeped plugin', () => {
|
||||
version: '1.0.0',
|
||||
dir: '/plugins/test',
|
||||
specVersion: 2,
|
||||
pluginType: 'client',
|
||||
source: 'src/index.ts',
|
||||
isBundled: false,
|
||||
isActivatable: true,
|
||||
|
||||
@@ -48,6 +48,7 @@ export function createMockDownloadablePluginDetails(
|
||||
main: 'dist/bundle.js',
|
||||
source: 'src/index.tsx',
|
||||
specVersion: 2,
|
||||
pluginType: 'client',
|
||||
title: title ?? id,
|
||||
version: version,
|
||||
downloadUrl: `http://localhost/${lowercasedID}/${version}`,
|
||||
|
||||
Reference in New Issue
Block a user