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 fs from 'fs-extra';
import {spawn} from 'promisify-child-process';
import {getWatchFolders} from 'flipper-pkg-lib';
import getAppWatchFolders from './get-app-watch-folders';
import getPlugins from '../static/getPlugins';
import {getSourcePlugins} from '../static/getPlugins';
import {
appDir,
staticDir,
@@ -22,7 +22,7 @@ import {
headlessDir,
babelTransformationsDir,
} from './paths';
import getPluginFolders from '../static/getPluginFolders';
import {getPluginSourceFolders} from '../static/getPluginFolders';
const dev = process.env.NODE_ENV !== 'production';
@@ -33,7 +33,7 @@ export function die(err: Error) {
export async function generatePluginEntryPoints() {
console.log('⚙️ Generating plugin entry points...');
const plugins = await getPlugins();
const plugins = await getSourcePlugins();
if (await fs.pathExists(defaultPluginsIndexDir)) {
await fs.remove(defaultPluginsIndexDir);
}
@@ -107,7 +107,7 @@ export async function compileHeadless(buildFolder: string) {
headlessDir,
...(await getWatchFolders(staticDir)),
...(await getAppWatchFolders()),
...(await getPluginFolders()),
...(await getPluginSourceFolders()),
]
.filter((value, index, self) => self.indexOf(value) === index)
.filter(fs.pathExistsSync);
@@ -128,7 +128,7 @@ export async function compileRenderer(buildFolder: string) {
console.log(`⚙️ Compiling renderer bundle...`);
const watchFolders = [
...(await getAppWatchFolders()),
...(await getPluginFolders()),
...(await getPluginSourceFolders()),
];
try {
await compile(

View File

@@ -25,8 +25,8 @@ import MetroResolver from 'metro-resolver';
import {staticDir, appDir, babelTransformationsDir} from './paths';
import isFB from './isFB';
import getAppWatchFolders from './get-app-watch-folders';
import getPlugins from '../static/getPlugins';
import getPluginFolders from '../static/getPluginFolders';
import {getSourcePlugins} from '../static/getPlugins';
import {getPluginSourceFolders} from '../static/getPluginFolders';
import startWatchPlugins from '../static/startWatchPlugins';
import ensurePluginFoldersWatchable from '../static/ensurePluginFoldersWatchable';
@@ -88,7 +88,7 @@ function launchElectron(port: number) {
async function startMetroServer(app: Express, server: http.Server) {
const watchFolders = (await getAppWatchFolders()).concat(
await getPluginFolders(),
await getPluginSourceFolders(),
);
const baseConfig = await Metro.loadConfig();
const config = Object.assign({}, baseConfig, {
@@ -206,7 +206,7 @@ async function startWatchChanges(io: socketIo.Server) {
),
),
);
const plugins = await getPlugins();
const plugins = await getSourcePlugins();
await startWatchPlugins(plugins, () => {
io.emit('refresh');
});