Remove plugin bundling
Summary: Remove the notion of bundled plugins Reviewed By: lblasa Differential Revision: D39308888 fbshipit-source-id: aa88ddbf2801ad1da95f89e4c761259b697b0d66
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f835e07c46
commit
650ff4bcfb
@@ -14,7 +14,7 @@ import {
|
||||
createRequirePluginFunction,
|
||||
getLatestCompatibleVersionOfEachPlugin,
|
||||
} from '../plugins';
|
||||
import {BundledPluginDetails, InstalledPluginDetails} from 'flipper-common';
|
||||
import {InstalledPluginDetails} from 'flipper-common';
|
||||
import {_SandyPluginDefinition} from 'flipper-plugin-core';
|
||||
import {getRenderHostInstance} from '../RenderHost';
|
||||
|
||||
@@ -31,16 +31,9 @@ const sampleInstalledPluginDetails: InstalledPluginDetails = {
|
||||
title: 'Sample',
|
||||
dir: '/Users/mock/.flipper/thirdparty/flipper-plugin-sample',
|
||||
entry: 'this/path/does not/exist',
|
||||
isBundled: false,
|
||||
isActivatable: true,
|
||||
};
|
||||
|
||||
const sampleBundledPluginDetails: BundledPluginDetails = {
|
||||
...sampleInstalledPluginDetails,
|
||||
id: 'SampleBundled',
|
||||
isBundled: true,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
loadDynamicPluginsMock = getRenderHostInstance().flipperServer.exec =
|
||||
jest.fn();
|
||||
@@ -66,14 +59,14 @@ test('checkDisabled', () => {
|
||||
|
||||
expect(
|
||||
disabled({
|
||||
...sampleBundledPluginDetails,
|
||||
...sampleInstalledPluginDetails,
|
||||
name: 'other Name',
|
||||
version: '1.0.0',
|
||||
}),
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
disabled({
|
||||
...sampleBundledPluginDetails,
|
||||
...sampleInstalledPluginDetails,
|
||||
name: disabledPlugin,
|
||||
version: '1.0.0',
|
||||
}),
|
||||
@@ -86,7 +79,7 @@ test('checkDisabled', () => {
|
||||
test('checkGK for plugin without GK', () => {
|
||||
expect(
|
||||
checkGK([])({
|
||||
...sampleBundledPluginDetails,
|
||||
...sampleInstalledPluginDetails,
|
||||
name: 'pluginID',
|
||||
version: '1.0.0',
|
||||
}),
|
||||
@@ -96,7 +89,7 @@ test('checkGK for plugin without GK', () => {
|
||||
test('checkGK for passing plugin', () => {
|
||||
expect(
|
||||
checkGK([])({
|
||||
...sampleBundledPluginDetails,
|
||||
...sampleInstalledPluginDetails,
|
||||
name: 'pluginID',
|
||||
gatekeeper: 'TEST_PASSING_GK',
|
||||
version: '1.0.0',
|
||||
@@ -108,7 +101,7 @@ test('checkGK for failing plugin', () => {
|
||||
const gatekeepedPlugins: InstalledPluginDetails[] = [];
|
||||
const name = 'pluginID';
|
||||
const plugins = checkGK(gatekeepedPlugins)({
|
||||
...sampleBundledPluginDetails,
|
||||
...sampleInstalledPluginDetails,
|
||||
name,
|
||||
gatekeeper: 'TEST_FAILING_GK',
|
||||
version: '1.0.0',
|
||||
@@ -134,15 +127,15 @@ test('requirePlugin returns null for invalid requires', async () => {
|
||||
});
|
||||
|
||||
test('newest version of each plugin is used', () => {
|
||||
const bundledPlugins: BundledPluginDetails[] = [
|
||||
const sourcePlugins: InstalledPluginDetails[] = [
|
||||
{
|
||||
...sampleBundledPluginDetails,
|
||||
...sampleInstalledPluginDetails,
|
||||
id: 'TestPlugin1',
|
||||
name: 'flipper-plugin-test1',
|
||||
version: '0.1.0',
|
||||
},
|
||||
{
|
||||
...sampleBundledPluginDetails,
|
||||
...sampleInstalledPluginDetails,
|
||||
id: 'TestPlugin2',
|
||||
name: 'flipper-plugin-test2',
|
||||
version: '0.1.0-alpha.201',
|
||||
@@ -167,7 +160,7 @@ test('newest version of each plugin is used', () => {
|
||||
},
|
||||
];
|
||||
const filteredPlugins = getLatestCompatibleVersionOfEachPlugin(
|
||||
[...bundledPlugins, ...installedPlugins],
|
||||
[...sourcePlugins, ...installedPlugins],
|
||||
'0.1.0',
|
||||
);
|
||||
expect(filteredPlugins).toHaveLength(2);
|
||||
@@ -180,7 +173,7 @@ test('newest version of each plugin is used', () => {
|
||||
entry: './test/index.js',
|
||||
});
|
||||
expect(filteredPlugins).toContainEqual({
|
||||
...sampleBundledPluginDetails,
|
||||
...sampleInstalledPluginDetails,
|
||||
id: 'TestPlugin2',
|
||||
name: 'flipper-plugin-test2',
|
||||
version: '0.1.0-alpha.201',
|
||||
|
||||
@@ -12,11 +12,7 @@ import {
|
||||
tryCatchReportPluginFailuresAsync,
|
||||
notNull,
|
||||
} from 'flipper-common';
|
||||
import {
|
||||
ActivatablePluginDetails,
|
||||
BundledPluginDetails,
|
||||
ConcretePluginDetails,
|
||||
} from 'flipper-common';
|
||||
import {ActivatablePluginDetails, ConcretePluginDetails} from 'flipper-common';
|
||||
import {reportUsage} from 'flipper-common';
|
||||
import {_SandyPluginDefinition} from 'flipper-plugin-core';
|
||||
import isPluginCompatible from './utils/isPluginCompatible';
|
||||
@@ -28,10 +24,7 @@ export abstract class AbstractPluginInitializer {
|
||||
protected gatekeepedPlugins: Array<ActivatablePluginDetails> = [];
|
||||
protected disabledPlugins: Array<ActivatablePluginDetails> = [];
|
||||
protected failedPlugins: Array<[ActivatablePluginDetails, string]> = [];
|
||||
protected bundledPlugins: Array<BundledPluginDetails> = [];
|
||||
protected loadedPlugins: Array<
|
||||
BundledPluginDetails | InstalledPluginDetails
|
||||
> = [];
|
||||
protected loadedPlugins: Array<InstalledPluginDetails> = [];
|
||||
protected _initialPlugins: _SandyPluginDefinition[] = [];
|
||||
|
||||
async init() {
|
||||
@@ -69,7 +62,7 @@ export abstract class AbstractPluginInitializer {
|
||||
}
|
||||
protected async loadAllLocalVersions(
|
||||
uninstalledPluginNames: Set<string>,
|
||||
): Promise<(BundledPluginDetails | InstalledPluginDetails)[]> {
|
||||
): Promise<InstalledPluginDetails[]> {
|
||||
const allLocalVersions = [...(await getDynamicPlugins())].filter(
|
||||
(p) => !uninstalledPluginNames.has(p.name),
|
||||
);
|
||||
@@ -77,7 +70,7 @@ export abstract class AbstractPluginInitializer {
|
||||
return allLocalVersions;
|
||||
}
|
||||
protected async filterAllLocalVersions(
|
||||
allLocalVersions: (BundledPluginDetails | InstalledPluginDetails)[],
|
||||
allLocalVersions: InstalledPluginDetails[],
|
||||
): Promise<ActivatablePluginDetails[]> {
|
||||
const flipperVersion = await this.getFlipperVersion();
|
||||
const loadedPlugins = getLatestCompatibleVersionOfEachPlugin(
|
||||
|
||||
@@ -33,13 +33,6 @@ export function isPluginVersionMoreRecent(
|
||||
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 &&
|
||||
|
||||
Reference in New Issue
Block a user