Add Flipper server command definitions

Reviewed By: lblasa

Differential Revision: D33980529

fbshipit-source-id: b64f48134d4816d3502c70d15beff90a044490a4
This commit is contained in:
Andrey Goncharov
2022-02-28 03:50:34 -08:00
committed by Facebook GitHub Bot
parent 035ba5613c
commit fc20abf392
5 changed files with 23 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ export interface PluginDetails {
version: string;
source: string;
main: string;
serverAddOn?: string;
id: string;
gatekeeper?: string;
title: string;
@@ -159,6 +160,7 @@ function getPluginDetailsV2(packageJson: any): PluginDetails {
name: packageJson.name,
version: packageJson.version,
main: packageJson.main,
serverAddOn: packageJson.serverAddOn,
source: packageJson.flipperBundlerEntry,
id: packageJson.id || packageJson.name,
gatekeeper: packageJson.gatekeeper,

View File

@@ -249,6 +249,8 @@ export type FlipperServerCommands = {
path: string,
) => Promise<InstalledPluginDetails>;
'plugins-remove-plugins': (names: string[]) => Promise<void>;
'plugins-server-add-on-start': (pluginName: string) => Promise<void>;
'plugins-server-add-on-stop': (pluginName: string) => Promise<void>;
'doctor-get-healthchecks': (
settings: FlipperDoctor.HealthcheckSettings,
) => Promise<FlipperDoctor.Healthchecks>;

View File

@@ -419,6 +419,10 @@ export class FlipperServerImpl implements FlipperServer {
'plugins-install-from-npm': (name) =>
this.pluginManager.installPluginFromNpm(name),
'plugin-source': (path) => this.pluginManager.loadSource(path),
'plugins-server-add-on-start': (pluginName) =>
this.pluginManager.startServerAddOn(pluginName),
'plugins-server-add-on-stop': (pluginName) =>
this.pluginManager.stopServerAddOn(pluginName),
'doctor-get-healthchecks': getHealthChecks,
'doctor-run-healthcheck': runHealthcheck,
'open-file': openFile,

View File

@@ -151,4 +151,12 @@ export class PluginManager {
await fs.remove(tmpDir);
}
}
async startServerAddOn(pluginName: string) {
console.debug('PluginManager.startServerAddOn', pluginName);
}
async stopServerAddOn(pluginName: string) {
console.debug('PluginManager.stopServerAddOn', pluginName);
}
}

View File

@@ -96,6 +96,7 @@ test('getPluginDetailsV2', async () => {
"name": "flipper-plugin-test",
"pluginType": undefined,
"publishedDocs": undefined,
"serverAddOn": undefined,
"source": "src/index.tsx",
"specVersion": 2,
"supportedApps": undefined,
@@ -139,6 +140,7 @@ test('id used as title if the latter omited', async () => {
"name": "flipper-plugin-test",
"pluginType": undefined,
"publishedDocs": undefined,
"serverAddOn": undefined,
"source": "src/index.tsx",
"specVersion": 2,
"supportedApps": undefined,
@@ -181,6 +183,7 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
"name": "flipper-plugin-test",
"pluginType": undefined,
"publishedDocs": undefined,
"serverAddOn": undefined,
"source": "src/index.tsx",
"specVersion": 2,
"supportedApps": undefined,
@@ -226,6 +229,7 @@ test('flipper-plugin-version is parsed', async () => {
"name": "flipper-plugin-test",
"pluginType": undefined,
"publishedDocs": undefined,
"serverAddOn": undefined,
"source": "src/index.tsx",
"specVersion": 2,
"supportedApps": undefined,
@@ -275,6 +279,7 @@ test('plugin type and supported devices parsed', async () => {
"name": "flipper-plugin-test",
"pluginType": "device",
"publishedDocs": undefined,
"serverAddOn": undefined,
"source": "src/index.tsx",
"specVersion": 2,
"supportedApps": undefined,
@@ -340,6 +345,7 @@ test('plugin type and supported apps parsed', async () => {
"name": "flipper-plugin-test",
"pluginType": "client",
"publishedDocs": undefined,
"serverAddOn": undefined,
"source": "src/index.tsx",
"specVersion": 2,
"supportedApps": Array [
@@ -428,6 +434,7 @@ test('can merge two package.json files', async () => {
"overview": true,
"setup": true,
},
"serverAddOn": undefined,
"source": "src/index.tsx",
"specVersion": 2,
"supportedApps": undefined,