Fold warnings about plugins in legacy mode into a single message
Summary: As we now send warn logs to server - it better to reduce their count. This diff folds all the warnings for plugins using the legacy API into one warning. Reviewed By: passy Differential Revision: D31532559 fbshipit-source-id: 0621a170e11e9d9645964dd8ecf2f9e753273225
This commit is contained in:
committed by
Facebook GitHub Bot
parent
72666e4205
commit
5e3bddc08e
@@ -104,6 +104,20 @@ export default async (store: Store, logger: Logger) => {
|
||||
.map(createRequirePluginFunction(failedPlugins))
|
||||
.filter(notNull);
|
||||
|
||||
const classicPlugins = initialPlugins.filter(
|
||||
(p) => !isSandyPlugin(p.details),
|
||||
);
|
||||
if (process.env.NODE_ENV !== 'test' && classicPlugins.length) {
|
||||
console.warn(
|
||||
`${
|
||||
classicPlugins.length
|
||||
} plugin(s) were loaded in legacy mode. Please visit https://fbflipper.com/docs/extending/sandy-migration to learn how to migrate these plugins to the new Sandy architecture: \n${classicPlugins
|
||||
.map((p) => `${p.title} (id: ${p.id})`)
|
||||
.sort()
|
||||
.join('\n')}`,
|
||||
);
|
||||
}
|
||||
|
||||
store.dispatch(registerBundledPlugins(bundledPlugins));
|
||||
store.dispatch(registerLoadedPlugins(loadedPlugins));
|
||||
store.dispatch(addGatekeepedPlugins(gatekeepedPlugins));
|
||||
@@ -282,6 +296,10 @@ export const requirePlugin = (
|
||||
);
|
||||
};
|
||||
|
||||
const isSandyPlugin = (pluginDetails: ActivatablePluginDetails) => {
|
||||
return !!pluginDetails.flipperSDKVersion;
|
||||
};
|
||||
|
||||
const requirePluginInternal = (
|
||||
pluginDetails: ActivatablePluginDetails,
|
||||
reqFn: Function = global.electronRequire,
|
||||
@@ -289,7 +307,7 @@ const requirePluginInternal = (
|
||||
let plugin = pluginDetails.isBundled
|
||||
? defaultPluginsIndex[pluginDetails.name]
|
||||
: reqFn(pluginDetails.entry);
|
||||
if (pluginDetails.flipperSDKVersion) {
|
||||
if (isSandyPlugin(pluginDetails)) {
|
||||
// Sandy plugin
|
||||
return new _SandyPluginDefinition(pluginDetails, plugin);
|
||||
} else {
|
||||
|
||||
@@ -38,14 +38,6 @@ export function createSandyPluginWrapper<S, A extends BaseAction, P>(
|
||||
Plugin: typeof FlipperPlugin | typeof FlipperDevicePlugin,
|
||||
): SandyPluginModule {
|
||||
const isDevicePlugin = Plugin.prototype instanceof FlipperDevicePlugin;
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
console.warn(
|
||||
`Loading ${isDevicePlugin ? 'device' : 'client'} plugin ${
|
||||
Plugin.id
|
||||
} in legacy mode. Please visit https://fbflipper.com/docs/extending/sandy-migration to learn how to migrate this plugin to the new Sandy architecture`,
|
||||
);
|
||||
}
|
||||
|
||||
function legacyPluginWrapper(client: PluginClient | DevicePluginClient) {
|
||||
const store = getStore();
|
||||
const appClient = isDevicePlugin
|
||||
|
||||
Reference in New Issue
Block a user