Summary: Yet another implementation of this function. References: https://www.internalfb.com/code/fbsource/[85c1fe5afee7]/xplat/sonar/desktop/flipper-frontend-core/src/utils/isPluginCompatible.tsx?lines=14 https://www.internalfb.com/code/fbsource/[85c1fe5afee7]/xplat/sonar/desktop/flipper-ui-core/src/utils/isPluginCompatible.tsx?lines=15 This one: - Uses GK from the existing server config - Gets version from the existing server config It differs in: - appVersion not passed in as argument - Doesn't use RenderHost to obtain the server config I think, this is acceptable as the function body is effectively the conditional, that depends on the caller available dependencies. Reviewed By: passy Differential Revision: D37749761 fbshipit-source-id: 3094e87c7770ac66e5764c932a0a0d4e7f5b63f5
26 lines
757 B
TypeScript
26 lines
757 B
TypeScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {PluginDetails} from 'flipper-common';
|
|
import semver from 'semver';
|
|
import {getFlipperServerConfig} from '../FlipperServerConfig';
|
|
|
|
export function isPluginCompatible(plugin: PluginDetails) {
|
|
const config = getFlipperServerConfig();
|
|
const flipperVersion = config.environmentInfo.appVersion;
|
|
return (
|
|
config.gatekeepers['flipper_disable_plugin_compatibility_checks'] ||
|
|
flipperVersion === '0.0.0' ||
|
|
!plugin.engines?.flipper ||
|
|
semver.lte(plugin.engines?.flipper, flipperVersion)
|
|
);
|
|
}
|
|
|
|
export default isPluginCompatible;
|