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:
committed by
Facebook GitHub Bot
parent
e31ddbc648
commit
e65b355fb6
@@ -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(
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import getPluginFolders from './getPluginFolders';
|
||||
import {getPluginSourceFolders} from './getPluginFolders';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
const watchmanconfigName = '.watchmanconfig';
|
||||
@@ -15,7 +15,7 @@ const watchmanconfigName = '.watchmanconfig';
|
||||
import path from 'path';
|
||||
|
||||
export default async function ensurePluginFoldersWatchable() {
|
||||
const pluginFolders = await getPluginFolders();
|
||||
const pluginFolders = await getPluginSourceFolders();
|
||||
for (const pluginFolder of pluginFolders) {
|
||||
if (!(await hasParentWithWatchmanConfig(pluginFolder))) {
|
||||
// If no watchman config found in the plugins folder or any its parent, we need to create it.
|
||||
|
||||
@@ -12,13 +12,12 @@ import fs from 'fs-extra';
|
||||
import expandTilde from 'expand-tilde';
|
||||
import {homedir} from 'os';
|
||||
|
||||
export default async function getPluginFolders(
|
||||
includeThirdparty: boolean = false,
|
||||
) {
|
||||
export function getPluginsInstallationFolder(): string {
|
||||
return path.join(homedir(), '.flipper', 'thirdparty');
|
||||
}
|
||||
|
||||
export async function getPluginSourceFolders(): Promise<string[]> {
|
||||
const pluginFolders: string[] = [];
|
||||
if (includeThirdparty) {
|
||||
pluginFolders.push(path.join(homedir(), '.flipper', 'thirdparty'));
|
||||
}
|
||||
if (process.env.FLIPPER_NO_EMBEDDED_PLUGINS === 'true') {
|
||||
console.log(
|
||||
'🥫 Skipping embedded plugins because "--no-embedded-plugins" flag provided',
|
||||
|
||||
@@ -10,15 +10,23 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import expandTilde from 'expand-tilde';
|
||||
import getPluginFolders from './getPluginFolders';
|
||||
import {
|
||||
getPluginsInstallationFolder,
|
||||
getPluginSourceFolders,
|
||||
} from './getPluginFolders';
|
||||
import {PluginDetails, getPluginDetails} from 'flipper-pkg-lib';
|
||||
import pmap from 'p-map';
|
||||
import pfilter from 'p-filter';
|
||||
|
||||
export default async function getPlugins(
|
||||
includeThirdparty: boolean = false,
|
||||
export async function getSourcePlugins(): Promise<PluginDetails[]> {
|
||||
return await getPluginsFromFolders(await getPluginSourceFolders());
|
||||
}
|
||||
export async function getInstalledPlugins(): Promise<PluginDetails[]> {
|
||||
return await getPluginsFromFolders([getPluginsInstallationFolder()]);
|
||||
}
|
||||
async function getPluginsFromFolders(
|
||||
pluginFolders: string[],
|
||||
): Promise<PluginDetails[]> {
|
||||
const pluginFolders = await getPluginFolders(includeThirdparty);
|
||||
const entryPoints: {[key: string]: PluginDetails} = {};
|
||||
const additionalPlugins = await pmap(pluginFolders, (path) =>
|
||||
entryPointForPluginFolder(path),
|
||||
|
||||
Reference in New Issue
Block a user