Files
flipper/desktop/scripts/get-app-watch-folders.ts
Anton Nikolaev 452c52c291 Add internal plugins as workspaces to single package.json
Summary: We cannot just add internal plugins as workspaces to the root package.json in "sonar/desktop" as they are not open-sourced, so public build will break. Instead, I have created root package.json for internal plugins and added all internal plugins as workspaces there. This means all these plugins will use the single root yarn.lock and installation of their dependencies will be faster. This also means that plugins can declare dependencies to other local packages included into workspaces and they will be symlinked automatically.

Reviewed By: mweststrate

Differential Revision: D20806237

fbshipit-source-id: f8b3327166963dec7da8ac74079682aebe4527e1
2020-04-14 07:20:38 -07:00

37 lines
1.2 KiB
TypeScript

/**
* 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 fs from 'fs-extra';
import path from 'path';
import getWatchFolders from '../static/get-watch-folders';
import {appDir, pluginsDir} from './paths';
/**
* Flipper references code from below plugins directly. Such directly referenced plugins
* 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'),
];
export default async function getAppWatchFolders() {
const getWatchFoldersResults = await Promise.all(
[appDir, ...pluginsReferencedDirectlyFromFlipper].map((dir) =>
getWatchFolders(dir),
),
);
const watchFolders = ([] as string[]).concat(...getWatchFoldersResults);
return watchFolders
.filter((value, index, self) => self.indexOf(value) === index)
.filter(fs.pathExistsSync);
}