From 907cb9e3cc84cad847b6586cfbb20e660e723805 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Mon, 8 Jun 2020 08:47:29 -0700 Subject: [PATCH] Read description from plugin's package json Summary: Added "description" field to PluginDetails interface and read it from package.json Reviewed By: passy Differential Revision: D21927391 fbshipit-source-id: 0513637d3afa3d8be8e2bc8ee87cc1d77c5e2250 --- desktop/plugin-lib/src/PluginDetails.ts | 3 ++- desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts | 8 ++++++++ desktop/plugin-lib/src/getPluginDetails.ts | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/desktop/plugin-lib/src/PluginDetails.ts b/desktop/plugin-lib/src/PluginDetails.ts index 43fdd50bb..9d2c951c5 100644 --- a/desktop/plugin-lib/src/PluginDetails.ts +++ b/desktop/plugin-lib/src/PluginDetails.ts @@ -17,7 +17,8 @@ export default interface PluginDetails { id: string; gatekeeper?: string; icon?: string; - title?: string; + title: string; + description?: string; category?: string; bugs?: { email?: string; diff --git a/desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts b/desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts index 0d0a517c9..5f422091a 100644 --- a/desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts +++ b/desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts @@ -16,6 +16,7 @@ test('getPluginDetailsV1', async () => { version: '2.0.0', title: 'Test Plugin', main: 'src/index.tsx', + description: 'Description of Test Plugin', gatekeeper: 'GK_flipper_plugin_test', }; jest.mock('fs-extra', () => jest.fn()); @@ -25,6 +26,7 @@ test('getPluginDetailsV1', async () => { Object { "bugs": undefined, "category": undefined, + "description": "Description of Test Plugin", "dir": "./plugins/flipper-plugin-test", "gatekeeper": "GK_flipper_plugin_test", "icon": undefined, @@ -47,6 +49,7 @@ test('getPluginDetailsV2', async () => { version: '3.0.1', main: 'dist/bundle.js', flipperBundlerEntry: 'src/index.tsx', + description: 'Description of Test Plugin', gatekeeper: 'GK_flipper_plugin_test', }; jest.mock('fs-extra', () => jest.fn()); @@ -56,6 +59,7 @@ test('getPluginDetailsV2', async () => { Object { "bugs": undefined, "category": undefined, + "description": "Description of Test Plugin", "dir": "./plugins/flipper-plugin-test", "gatekeeper": "GK_flipper_plugin_test", "icon": undefined, @@ -78,6 +82,7 @@ test('id used as title if the latter omited', async () => { version: '3.0.1', main: 'dist/bundle.js', flipperBundlerEntry: 'src/index.tsx', + description: 'Description of Test Plugin', gatekeeper: 'GK_flipper_plugin_test', }; jest.mock('fs-extra', () => jest.fn()); @@ -87,6 +92,7 @@ test('id used as title if the latter omited', async () => { Object { "bugs": undefined, "category": undefined, + "description": "Description of Test Plugin", "dir": "./plugins/flipper-plugin-test", "gatekeeper": "GK_flipper_plugin_test", "icon": undefined, @@ -108,6 +114,7 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite version: '3.0.1', main: 'dist/bundle.js', flipperBundlerEntry: 'src/index.tsx', + description: 'Description of Test Plugin', gatekeeper: 'GK_flipper_plugin_test', }; jest.mock('fs-extra', () => jest.fn()); @@ -117,6 +124,7 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite Object { "bugs": undefined, "category": undefined, + "description": "Description of Test Plugin", "dir": "./plugins/flipper-plugin-test", "gatekeeper": "GK_flipper_plugin_test", "icon": undefined, diff --git a/desktop/plugin-lib/src/getPluginDetails.ts b/desktop/plugin-lib/src/getPluginDetails.ts index ed3a4a9d2..d577bf33f 100644 --- a/desktop/plugin-lib/src/getPluginDetails.ts +++ b/desktop/plugin-lib/src/getPluginDetails.ts @@ -49,6 +49,7 @@ async function getPluginDetailsV1( gatekeeper: packageJson.gatekeeper, icon: packageJson.icon, title: packageJson.title || packageJson.name, + description: packageJson.description, category: packageJson.category, bugs: packageJson.bugs, }; @@ -71,6 +72,7 @@ async function getPluginDetailsV2( icon: packageJson.icon, title: packageJson.title || packageJson.id || getTitleFromName(packageJson.name), + description: packageJson.description, category: packageJson.category, bugs: packageJson.bugs, };