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
This commit is contained in:
Anton Nikolaev
2020-06-08 08:47:29 -07:00
committed by Facebook GitHub Bot
parent 9324bef8cc
commit 907cb9e3cc
3 changed files with 12 additions and 1 deletions

View File

@@ -17,7 +17,8 @@ export default interface PluginDetails {
id: string; id: string;
gatekeeper?: string; gatekeeper?: string;
icon?: string; icon?: string;
title?: string; title: string;
description?: string;
category?: string; category?: string;
bugs?: { bugs?: {
email?: string; email?: string;

View File

@@ -16,6 +16,7 @@ test('getPluginDetailsV1', async () => {
version: '2.0.0', version: '2.0.0',
title: 'Test Plugin', title: 'Test Plugin',
main: 'src/index.tsx', main: 'src/index.tsx',
description: 'Description of Test Plugin',
gatekeeper: 'GK_flipper_plugin_test', gatekeeper: 'GK_flipper_plugin_test',
}; };
jest.mock('fs-extra', () => jest.fn()); jest.mock('fs-extra', () => jest.fn());
@@ -25,6 +26,7 @@ test('getPluginDetailsV1', async () => {
Object { Object {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"description": "Description of Test Plugin",
"dir": "./plugins/flipper-plugin-test", "dir": "./plugins/flipper-plugin-test",
"gatekeeper": "GK_flipper_plugin_test", "gatekeeper": "GK_flipper_plugin_test",
"icon": undefined, "icon": undefined,
@@ -47,6 +49,7 @@ test('getPluginDetailsV2', async () => {
version: '3.0.1', version: '3.0.1',
main: 'dist/bundle.js', main: 'dist/bundle.js',
flipperBundlerEntry: 'src/index.tsx', flipperBundlerEntry: 'src/index.tsx',
description: 'Description of Test Plugin',
gatekeeper: 'GK_flipper_plugin_test', gatekeeper: 'GK_flipper_plugin_test',
}; };
jest.mock('fs-extra', () => jest.fn()); jest.mock('fs-extra', () => jest.fn());
@@ -56,6 +59,7 @@ test('getPluginDetailsV2', async () => {
Object { Object {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"description": "Description of Test Plugin",
"dir": "./plugins/flipper-plugin-test", "dir": "./plugins/flipper-plugin-test",
"gatekeeper": "GK_flipper_plugin_test", "gatekeeper": "GK_flipper_plugin_test",
"icon": undefined, "icon": undefined,
@@ -78,6 +82,7 @@ test('id used as title if the latter omited', async () => {
version: '3.0.1', version: '3.0.1',
main: 'dist/bundle.js', main: 'dist/bundle.js',
flipperBundlerEntry: 'src/index.tsx', flipperBundlerEntry: 'src/index.tsx',
description: 'Description of Test Plugin',
gatekeeper: 'GK_flipper_plugin_test', gatekeeper: 'GK_flipper_plugin_test',
}; };
jest.mock('fs-extra', () => jest.fn()); jest.mock('fs-extra', () => jest.fn());
@@ -87,6 +92,7 @@ test('id used as title if the latter omited', async () => {
Object { Object {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"description": "Description of Test Plugin",
"dir": "./plugins/flipper-plugin-test", "dir": "./plugins/flipper-plugin-test",
"gatekeeper": "GK_flipper_plugin_test", "gatekeeper": "GK_flipper_plugin_test",
"icon": undefined, "icon": undefined,
@@ -108,6 +114,7 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
version: '3.0.1', version: '3.0.1',
main: 'dist/bundle.js', main: 'dist/bundle.js',
flipperBundlerEntry: 'src/index.tsx', flipperBundlerEntry: 'src/index.tsx',
description: 'Description of Test Plugin',
gatekeeper: 'GK_flipper_plugin_test', gatekeeper: 'GK_flipper_plugin_test',
}; };
jest.mock('fs-extra', () => jest.fn()); 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 { Object {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"description": "Description of Test Plugin",
"dir": "./plugins/flipper-plugin-test", "dir": "./plugins/flipper-plugin-test",
"gatekeeper": "GK_flipper_plugin_test", "gatekeeper": "GK_flipper_plugin_test",
"icon": undefined, "icon": undefined,

View File

@@ -49,6 +49,7 @@ async function getPluginDetailsV1(
gatekeeper: packageJson.gatekeeper, gatekeeper: packageJson.gatekeeper,
icon: packageJson.icon, icon: packageJson.icon,
title: packageJson.title || packageJson.name, title: packageJson.title || packageJson.name,
description: packageJson.description,
category: packageJson.category, category: packageJson.category,
bugs: packageJson.bugs, bugs: packageJson.bugs,
}; };
@@ -71,6 +72,7 @@ async function getPluginDetailsV2(
icon: packageJson.icon, icon: packageJson.icon,
title: title:
packageJson.title || packageJson.id || getTitleFromName(packageJson.name), packageJson.title || packageJson.id || getTitleFromName(packageJson.name),
description: packageJson.description,
category: packageJson.category, category: packageJson.category,
bugs: packageJson.bugs, bugs: packageJson.bugs,
}; };