Copy RenderHost, FlipperLib initialization, device definition to flipper-frontend-core
Reviewed By: passy Differential Revision: D36129746 fbshipit-source-id: 15e32b9482d7fe3a24567d2e6bc087095b98226e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
db49673d8a
commit
f0b5e7cadb
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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 {ConcretePluginDetails} from 'flipper-common';
|
||||
import semver from 'semver';
|
||||
import isPluginCompatible from './isPluginCompatible';
|
||||
|
||||
export function isPluginVersionMoreRecent(
|
||||
versionDetails: ConcretePluginDetails,
|
||||
otherVersionDetails: ConcretePluginDetails,
|
||||
flipperVersion: string,
|
||||
) {
|
||||
const isPlugin1Compatible = isPluginCompatible(
|
||||
versionDetails,
|
||||
flipperVersion,
|
||||
);
|
||||
const isPlugin2Compatible = isPluginCompatible(
|
||||
otherVersionDetails,
|
||||
flipperVersion,
|
||||
);
|
||||
|
||||
// prefer compatible plugins
|
||||
if (isPlugin1Compatible && !isPlugin2Compatible) return true;
|
||||
if (!isPlugin1Compatible && isPlugin2Compatible) return false;
|
||||
|
||||
// prefer plugins with greater version
|
||||
if (semver.gt(versionDetails.version, otherVersionDetails.version)) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
semver.eq(versionDetails.version, otherVersionDetails.version) &&
|
||||
versionDetails.isBundled
|
||||
) {
|
||||
// prefer bundled versions
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
semver.eq(versionDetails.version, otherVersionDetails.version) &&
|
||||
versionDetails.isActivatable &&
|
||||
!otherVersionDetails.isActivatable
|
||||
) {
|
||||
// prefer locally available versions to the versions available remotely on marketplace
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export default isPluginVersionMoreRecent;
|
||||
Reference in New Issue
Block a user