Load either installed or bundled version of plugin depending on which is newer

Summary: Load either installed or bundled version of plugin depending on which is newer.

Reviewed By: mweststrate

Differential Revision: D21858965

fbshipit-source-id: aa46eafe0b5137134fadad827749672441f2c9e5
This commit is contained in:
Anton Nikolaev
2020-06-03 07:37:11 -07:00
committed by Facebook GitHub Bot
parent e31ddbc648
commit e65b355fb6
8 changed files with 76 additions and 27 deletions

View File

@@ -14,7 +14,7 @@ import recursiveReaddir from 'recursive-readdir';
import pMap from 'p-map';
import {homedir} from 'os';
import {runBuild, PluginDetails} from 'flipper-pkg-lib';
import getPlugins from './getPlugins';
import {getSourcePlugins, getInstalledPlugins} from './getPlugins';
import startWatchPlugins from './startWatchPlugins';
import ensurePluginFoldersWatchable from './ensurePluginFoldersWatchable';
@@ -41,7 +41,7 @@ export default async function (
): Promise<CompiledPluginDetails[]> {
if (process.env.FLIPPER_FAST_REFRESH) {
console.log(
'🥫 Skipping loading of third-party plugins because Fast Refresh is enabled',
'🥫 Skipping loading of installed plugins because Fast Refresh is enabled',
);
return [];
}
@@ -50,9 +50,12 @@ export default async function (
const defaultPlugins = (
await fs.readJson(path.join(__dirname, 'defaultPlugins', 'index.json'))
).map((p: any) => p.name) as string[];
const dynamicPlugins = (await getPlugins(true)).filter(
(p) => !defaultPlugins.includes(p.name),
);
const dynamicPlugins = [
...(await getInstalledPlugins()),
...(await getSourcePlugins()).filter(
(p) => !defaultPlugins.includes(p.name),
),
];
await fs.ensureDir(pluginCache);
if (options.recompileOnChanges) {
await startWatchChanges(