Plugin folders re-structuring

Summary:
Here I'm changing plugin repository structure to allow re-using of shared packages between both public and fb-internal plugins, and to ensure that public plugins has their own yarn.lock as this will be required to implement reproducible jobs checking plugin compatibility with released flipper versions.

Please note that there are a lot of moved files in this diff, make sure to click "Expand all" to see all that actually changed (there are not much of them actually).

New proposed structure for plugin packages:
```
- root
- node_modules - modules included into Flipper: flipper, flipper-plugin, react, antd, emotion
-- plugins
 --- node_modules - modules used by both public and fb-internal plugins (shared libs will be linked here, see D27034936)
 --- public
---- node_modules - modules used by public plugins
---- pluginA
----- node_modules - modules used by plugin A exclusively
---- pluginB
----- node_modules - modules used by plugin B exclusively
 --- fb
---- node_modules - modules used by fb-internal plugins
---- pluginC
----- node_modules - modules used by plugin C exclusively
---- pluginD
----- node_modules - modules used by plugin D exclusively
```
I've moved all public plugins under dir "plugins/public" and excluded them from root yarn workspaces. Instead, they will have their own yarn workspaces config and yarn.lock and they will use flipper modules as peer dependencies.

Reviewed By: mweststrate

Differential Revision: D27034108

fbshipit-source-id: c2310e3c5bfe7526033f51b46c0ae40199fd7586
This commit is contained in:
Anton Nikolaev
2021-04-09 05:15:14 -07:00
committed by Facebook GitHub Bot
parent 32bf4c32c2
commit b3274a8450
137 changed files with 2133 additions and 371 deletions

View File

@@ -10,7 +10,7 @@
import fs from 'fs-extra';
import path from 'path';
import {getWatchFolders} from 'flipper-pkg-lib';
import {appDir, pluginsDir, jsSharedDir} from './paths';
import {appDir, publicPluginsDir, fbPluginsDir, jsSharedDir} from './paths';
import isFB from './isFB';
/**
@@ -18,10 +18,10 @@ import isFB from './isFB';
* and their dependencies should be added as watch folders so Metro bundled can resolve them.
*/
const pluginsReferencedDirectlyFromFlipper = [
path.join(pluginsDir, 'navigation'),
path.join(pluginsDir, 'fb', 'layout', 'sidebar_extensions'),
path.join(pluginsDir, 'fb', 'mobileconfig'),
path.join(pluginsDir, 'fb', 'watch'),
path.join(publicPluginsDir, 'navigation'),
path.join(fbPluginsDir, 'layout', 'sidebar_extensions'),
path.join(fbPluginsDir, 'mobileconfig'),
path.join(fbPluginsDir, 'watch'),
];
export default async function getAppWatchFolders() {

View File

@@ -16,6 +16,7 @@ export const staticDir = path.join(rootDir, 'static');
export const defaultPluginsIndexDir = path.join(staticDir, 'defaultPlugins');
export const pluginsDir = path.join(rootDir, 'plugins');
export const fbPluginsDir = path.join(pluginsDir, 'fb');
export const publicPluginsDir = path.join(pluginsDir, 'public');
export const distDir = path.resolve(rootDir, '..', 'dist');
export const babelTransformationsDir = path.resolve(
rootDir,

View File

@@ -7,7 +7,7 @@
* @format
*/
import {rootDir, pluginsDir, fbPluginsDir} from './paths';
import {rootDir, pluginsDir, fbPluginsDir, publicPluginsDir} from './paths';
import fs from 'fs-extra';
import path from 'path';
import {promisify} from 'util';
@@ -72,13 +72,15 @@ async function getWorkspacesByRoot(
export async function getWorkspaces(): Promise<Workspaces> {
const rootWorkspaces = await getWorkspacesByRoot(rootDir);
const fbWorkspaces = await getWorkspacesByRoot(fbPluginsDir);
if (!fbWorkspaces) {
return rootWorkspaces!;
}
const publicPluginsWorkspaces = await getWorkspacesByRoot(publicPluginsDir);
const fbPluginsWorkspaces = await getWorkspacesByRoot(fbPluginsDir);
const mergedWorkspaces: Workspaces = {
rootPackage: rootWorkspaces!.rootPackage,
packages: [...rootWorkspaces!.packages, ...fbWorkspaces.packages],
packages: [
...rootWorkspaces!.packages,
...publicPluginsWorkspaces!.packages,
...(fbPluginsWorkspaces ? fbPluginsWorkspaces.packages : []),
],
};
return mergedWorkspaces;
}

View File

@@ -1,20 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its 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 isFB from './isFB';
import {execSync} from 'child_process';
import path from 'path';
import {pluginsDir} from './paths';
if (isFB) {
execSync('yarn install --mutex network:30330', {
cwd: path.join(pluginsDir, 'fb'),
stdio: 'inherit',
});
}