Move flipper plugin from flipper-lib types to flipper-common

Summary: Moved all types related to plugin descriptions from plugin-lib (which handles downloads and such) to flipper-common. The goal of that is to remove all plugin-lib usage from ui-core to server-core, so that the UI itself doesn't do any file operations anymore related to plugins. That will be done in next diffs, this just moves types but no code.

Reviewed By: nikoant, aigoncharov

Differential Revision: D32665064

fbshipit-source-id: 86d908e7264569b0229b09290a891171876c8e00
This commit is contained in:
Michel Weststrate
2021-12-08 04:25:28 -08:00
committed by Facebook GitHub Bot
parent 2bf8ae2364
commit e7f841b6d2
46 changed files with 72 additions and 72 deletions

View File

@@ -14,6 +14,7 @@
"decompress-targz": "^4.1.1",
"decompress-unzip": "^4.0.1",
"expand-tilde": "^2.0.2",
"flipper-common": "^0.0.0",
"fs-extra": "^10.0.0",
"live-plugin-manager": "^0.17.0",
"npm-api": "^1.0.1",

View File

@@ -1,94 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
export interface PluginDetails {
name: string;
specVersion: number;
version: string;
source: string;
main: string;
id: string;
gatekeeper?: string;
title: string;
icon?: string;
description?: string;
category?: string;
engines?: {
[name: string]: string;
};
bugs?: {
email?: string;
url?: string;
};
flipperSDKVersion?: string;
pluginType?: PluginType;
supportedDevices?: SupportedDevice[];
supportedApps?: SupportedApp[];
publishedDocs?: {
overview?: boolean;
setup?: boolean;
};
}
export interface SupportedDevice {
readonly os?: OS;
readonly type?: DeviceType;
readonly archived?: boolean;
readonly specs?: DeviceSpec[];
}
export interface SupportedApp {
readonly appID?: string;
readonly os?: OS;
readonly type?: DeviceType;
}
export type OS = 'iOS' | 'Android' | 'Metro';
export type DeviceType = 'emulator' | 'physical' | 'dummy';
export type PluginType = 'client' | 'device';
export type DeviceSpec = 'KaiOS';
export interface ConcretePluginDetails extends PluginDetails {
// Determines whether the plugin is a part of the Flipper JS bundle.
isBundled: boolean;
// Determines whether the plugin is physically available for activation in Flipper.
isActivatable: boolean;
}
// Describes plugin which is a part of the Flipper JS bundle.
export interface BundledPluginDetails extends ConcretePluginDetails {
isBundled: true;
isActivatable: true;
}
// Describes plugin installed on the disk.
export interface InstalledPluginDetails extends ConcretePluginDetails {
isBundled: false;
isActivatable: true;
dir: string;
entry: string;
}
// Describes plugin physically available for activation in Flipper.
export type ActivatablePluginDetails =
| BundledPluginDetails
| InstalledPluginDetails;
// Describes plugin available for downloading. Until downloaded to the disk it is not available for activation in Flipper.
export interface DownloadablePluginDetails extends ConcretePluginDetails {
isActivatable: false;
isBundled: false;
downloadUrl: string;
lastUpdated: Date;
}
export default PluginDetails;

View File

@@ -18,7 +18,7 @@ import {
import {getInstalledPlugins} from '../pluginInstaller';
import {mocked} from 'ts-jest/utils';
import type {Package} from 'npm-api';
import {InstalledPluginDetails} from '../PluginDetails';
import {InstalledPluginDetails} from 'flipper-common';
jest.mock('npm-api', () => {
return jest.fn().mockImplementation(() => {

View File

@@ -13,7 +13,7 @@ import {
DownloadablePluginDetails,
InstalledPluginDetails,
PluginDetails,
} from './PluginDetails';
} from 'flipper-common';
import {pluginCacheDir} from './pluginPaths';
export async function readPluginPackageJson(dir: string): Promise<any> {

View File

@@ -15,7 +15,7 @@ import pmap from 'p-map';
import pfilter from 'p-filter';
import {satisfies} from 'semver';
import {getInstalledPluginDetails, isPluginDir} from './getPluginDetails';
import {InstalledPluginDetails} from './PluginDetails';
import {InstalledPluginDetails} from 'flipper-common';
const flipperVersion = require('../package.json').version;

View File

@@ -7,7 +7,7 @@
* @format
*/
import {InstalledPluginDetails} from './PluginDetails';
import {InstalledPluginDetails} from 'flipper-common';
import {getInstalledPlugins} from './pluginInstaller';
import semver from 'semver';
import {getNpmHostedPlugins, NpmPackageDescriptor} from './getNpmHostedPlugins';

View File

@@ -7,7 +7,6 @@
* @format
*/
export * from './PluginDetails';
export * from './getPluginDetails';
export * from './pluginInstaller';
export * from './getUpdatablePlugins';

View File

@@ -18,7 +18,7 @@ import decompress from 'decompress';
import decompressTargz from 'decompress-targz';
import decompressUnzip from 'decompress-unzip';
import tmp from 'tmp';
import {InstalledPluginDetails} from './PluginDetails';
import {InstalledPluginDetails} from 'flipper-common';
import {getInstalledPluginDetails, isPluginDir} from './getPluginDetails';
import {
getPluginVersionInstallationDir,

View File

@@ -3,5 +3,10 @@
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
}
},
"references": [
{
"path": "../flipper-common"
}
]
}