Add "id" field to Flipper plugin manifest
Summary: Added "id" field to Flipper plugin manifest which is used to match native and desktop plugin parts. Before that, "name" field was used both as npm package name and as plugin id. The problem is that currently there are a lot of plugins which has invalid values in "name", e.g. not starting with "flipper-package-", or containing upper cased letters. Simple renaming of "name" field can be very problematic, so we need a new field to avoid any breaking changes and keep historical analytics data which is also bound to plugin id. Reviewed By: mweststrate Differential Revision: D21129689 fbshipit-source-id: efd143c82a6a802cc0b5438fd3f509bd99aded0e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bbbf535ea7
commit
3ff2d3bf99
@@ -165,15 +165,11 @@ export const requirePlugin = (
|
||||
throw new Error(`Plugin ${plugin.name} is not a FlipperBasePlugin`);
|
||||
}
|
||||
|
||||
plugin.id = plugin.id || pluginDefinition.id;
|
||||
|
||||
// set values from package.json as static variables on class
|
||||
Object.keys(pluginDefinition).forEach((key) => {
|
||||
if (key === 'name') {
|
||||
plugin.id = plugin.id || pluginDefinition.name;
|
||||
} else if (key === 'id') {
|
||||
throw new Error(
|
||||
'Field "id" not allowed in package.json. The plugin\'s name will be used as ID"',
|
||||
);
|
||||
} else {
|
||||
if (key !== 'name' && key !== 'id') {
|
||||
plugin[key] =
|
||||
plugin[key] || pluginDefinition[key as keyof PluginDefinition];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user