Fix symlinks resolution for plugin dependencies
Summary: Moved getWatchFolders script to flipper-pkg and used it from other packages. Script helps to resolve all the folders with package dependencies including symlinked folders in case if plugin is a part of yarn workspaces. Reviewed By: mweststrate Differential Revision: D21068373 fbshipit-source-id: 8691837fdb1aef333dab4c13d8758262838d36ee
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a5e5ed5b7b
commit
ebfd045328
@@ -26,7 +26,6 @@
|
|||||||
"@types/fs-extra": "^8.1.0",
|
"@types/fs-extra": "^8.1.0",
|
||||||
"@types/node": "^13.7.5",
|
"@types/node": "^13.7.5",
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"metro": "^0.59.0",
|
|
||||||
"tslib": "^1"
|
"tslib": "^1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"allowJs": true
|
"allowJs": true,
|
||||||
|
"esModuleInterop": true
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"exclude": ["node_modules", "**/__tests__/*"]
|
"exclude": ["node_modules", "**/__tests__/*"]
|
||||||
|
|||||||
@@ -82,9 +82,8 @@
|
|||||||
"@types/react-dom": "16.9.4",
|
"@types/react-dom": "16.9.4",
|
||||||
"acorn": "7.1.1",
|
"acorn": "7.1.1",
|
||||||
"minimist": "1.2.3",
|
"minimist": "1.2.3",
|
||||||
"metro/temp": "0.9.0",
|
"**/metro/**/temp": "0.9.0",
|
||||||
"metro/ws": "1.1.5",
|
"**/metro/**/ws": "1.1.5",
|
||||||
"metro/**/ws": "1.1.5",
|
|
||||||
"ws": "7.2.3",
|
"ws": "7.2.3",
|
||||||
"kind-of": "6.0.3"
|
"kind-of": "6.0.3"
|
||||||
},
|
},
|
||||||
@@ -169,6 +168,7 @@
|
|||||||
"eslint-plugin-prettier": "^3.1.2",
|
"eslint-plugin-prettier": "^3.1.2",
|
||||||
"eslint-plugin-react": "^7.16.0",
|
"eslint-plugin-react": "^7.16.0",
|
||||||
"eslint-plugin-relay": "^1.4.1",
|
"eslint-plugin-relay": "^1.4.1",
|
||||||
|
"flipper-pkg": "0.37.0",
|
||||||
"flow-bin": "^0.122.0",
|
"flow-bin": "^0.122.0",
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
@@ -194,31 +194,32 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "node scripts/prepare-watchman-config.js && yarn config set ignore-engines",
|
"preinstall": "node scripts/prepare-watchman-config.js && yarn config set ignore-engines",
|
||||||
"postinstall": "patch-package && ./ts-node scripts/yarn-install-fb-plugins.ts && ./ts-node scripts/generate-plugin-entry-points.ts",
|
"postinstall": "patch-package && ./ts-node scripts/yarn-install-fb-plugins.ts && yarn build:pkg && ./ts-node scripts/generate-plugin-entry-points.ts",
|
||||||
"rm-dist": "rimraf ../dist",
|
"rm-dist": "rimraf ../dist",
|
||||||
"rm-modules": "rimraf **/*/node_modules node_modules",
|
"rm-modules": "rimraf **/*/node_modules node_modules",
|
||||||
"rm-temp": "rimraf $TMPDIR/jest* $TMPDIR/react-native-packager*",
|
"rm-temp": "rimraf $TMPDIR/jest* $TMPDIR/react-native-packager*",
|
||||||
"rm-bundle": "rimraf static/main.bundle.* **/lib **/*.tsbuildinfo",
|
"rm-bundle": "rimraf static/main.bundle.* **/lib **/*.tsbuildinfo",
|
||||||
"rm-watches": "watchman watch-del-all",
|
"rm-watches": "watchman watch-del-all",
|
||||||
"rm-metro-cache": "rimraf $TMPDIR/metro-cache*",
|
"rm-metro-cache": "rimraf $TMPDIR/metro-cache*",
|
||||||
"reset": "yarn rm-dist && yarn rm-temp && yarn rm-metro-cache && yarn cache clean && yarn rm-bundle && yarn rm-watches && yarn rm-modules",
|
"reset": "yarn rm-dist && yarn rm-temp && yarn rm-metro-cache && yarn cache clean && yarn rm-bundle && yarn rm-modules",
|
||||||
"predev-server": "yarn build:babel-transformer",
|
"predev-server": "yarn build:pkg",
|
||||||
"dev-server": "cross-env NODE_ENV=development ./ts-node scripts/start-dev-server.ts",
|
"dev-server": "cross-env NODE_ENV=development ./ts-node scripts/start-dev-server.ts",
|
||||||
"start": "yarn dev-server --inspect=9229",
|
"start": "yarn dev-server --inspect=9229",
|
||||||
"start:break": "yarn dev-server --inspect-brk=9229",
|
"start:break": "yarn dev-server --inspect-brk=9229",
|
||||||
"start:no-embedded-plugins": "yarn start --no-embedded-plugins",
|
"start:no-embedded-plugins": "yarn start --no-embedded-plugins",
|
||||||
"build:babel-transformer": "cd babel-transformer && yarn build",
|
"build:babel-transformer": "cd babel-transformer && yarn build",
|
||||||
"prebuild": "yarn build:babel-transformer && yarn rm-dist",
|
"build:pkg": "cd pkg && yarn build",
|
||||||
|
"prebuild": "yarn build:pkg && yarn rm-dist",
|
||||||
"build": "cross-env NODE_ENV=production ./ts-node scripts/build-release.ts $@",
|
"build": "cross-env NODE_ENV=production ./ts-node scripts/build-release.ts $@",
|
||||||
"build:dev": "cross-env NODE_ENV=development ./ts-node scripts/build-release.ts $@",
|
"build:dev": "cross-env NODE_ENV=development ./ts-node scripts/build-release.ts $@",
|
||||||
"prebuild-headless": "yarn build:babel-transformer",
|
"prebuild-headless": "yarn build:pkg",
|
||||||
"build-headless": "cross-env NODE_ENV=production ./ts-node scripts/build-headless.ts $@",
|
"build-headless": "cross-env NODE_ENV=production ./ts-node scripts/build-headless.ts $@",
|
||||||
"open-dist": "open ../dist/mac/Flipper.app --args --launcher=false --inspect=9229",
|
"open-dist": "open ../dist/mac/Flipper.app --args --launcher=false --inspect=9229",
|
||||||
"fix": "eslint . --fix --ext .js,.ts,.tsx",
|
"fix": "eslint . --fix --ext .js,.ts,.tsx",
|
||||||
"test": "yarn build:babel-transformer && jest --env=jest-environment-jsdom-sixteen --testPathPattern=\"node\\.(js|ts|tsx)$\" --no-cache",
|
"test": "yarn build:pkg && jest --env=jest-environment-jsdom-sixteen --testPathPattern=\"node\\.(js|ts|tsx)$\" --no-cache",
|
||||||
"test:debug": "yarn build:babel-transformer && node --inspect node_modules/.bin/jest --runInBand --env=jest-environment-jsdom-sixteen",
|
"test:debug": "yarn build:pkg && node --inspect node_modules/.bin/jest --runInBand --env=jest-environment-jsdom-sixteen",
|
||||||
"test-electron": "yarn build:babel-transformer && jest --env=jest-environment-jsdom-sixteen --testPathPattern=\"electron\\.(js|ts|tsx)$\" --testEnvironment=@jest-runner/electron/environment --runner=@jest-runner/electron --no-cache",
|
"test-electron": "yarn build:pkg && jest --env=jest-environment-jsdom-sixteen --testPathPattern=\"electron\\.(js|ts|tsx)$\" --testEnvironment=@jest-runner/electron/environment --runner=@jest-runner/electron --no-cache",
|
||||||
"test-with-device": "yarn build:babel-transformer && USE_ELECTRON_STUBS=1 jest --env=jest-environment-jsdom-sixteen --testPathPattern=\"device\\.(js|ts|tsx)$\" --detectOpenHandles --no-cache",
|
"test-with-device": "yarn build:pkg && USE_ELECTRON_STUBS=1 jest --env=jest-environment-jsdom-sixteen --testPathPattern=\"device\\.(js|ts|tsx)$\" --detectOpenHandles --no-cache",
|
||||||
"lint:tsc": "tsc --noemit",
|
"lint:tsc": "tsc --noemit",
|
||||||
"lint:eslint": "eslint . --ext .js,.ts,.tsx",
|
"lint:eslint": "eslint . --ext .js,.ts,.tsx",
|
||||||
"lint:flow": "flow check",
|
"lint:flow": "flow check",
|
||||||
|
|||||||
@@ -10,3 +10,4 @@
|
|||||||
export {run} from '@oclif/command';
|
export {run} from '@oclif/command';
|
||||||
export const PKG = 'flipper-pkg';
|
export const PKG = 'flipper-pkg';
|
||||||
export {default as runBuild} from './utils/runBuild';
|
export {default as runBuild} from './utils/runBuild';
|
||||||
|
export {default as getWatchFolders} from './utils/getWatchFolders';
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Metro from 'metro';
|
import Metro from 'metro';
|
||||||
import * as path from 'path';
|
import getWatchFolders from './getWatchFolders';
|
||||||
|
|
||||||
function hash(string: string) {
|
function hash(string: string) {
|
||||||
let hash = 0;
|
let hash = 0;
|
||||||
@@ -41,27 +41,28 @@ export default async function runBuild(
|
|||||||
entry: string,
|
entry: string,
|
||||||
out: string,
|
out: string,
|
||||||
) {
|
) {
|
||||||
await Metro.runBuild(
|
const baseConfig = await Metro.loadConfig();
|
||||||
{
|
const config = Object.assign({}, baseConfig, {
|
||||||
reporter: {update: () => {}},
|
reporter: {update: () => {}},
|
||||||
projectRoot: inputDirectory,
|
projectRoot: inputDirectory,
|
||||||
watchFolders: [inputDirectory, path.resolve(__dirname, '..', '..')],
|
watchFolders: [inputDirectory, ...(await getWatchFolders(inputDirectory))],
|
||||||
serializer: {
|
serializer: {
|
||||||
|
...baseConfig.serializer,
|
||||||
getRunModuleStatement: (moduleID: string) =>
|
getRunModuleStatement: (moduleID: string) =>
|
||||||
`module.exports = global.__r(${moduleID}).default;`,
|
`module.exports = global.__r(${moduleID}).default;`,
|
||||||
createModuleIdFactory,
|
createModuleIdFactory,
|
||||||
},
|
},
|
||||||
transformer: {
|
transformer: {
|
||||||
|
...baseConfig.transformer,
|
||||||
babelTransformerPath: require.resolve('flipper-babel-transformer'),
|
babelTransformerPath: require.resolve('flipper-babel-transformer'),
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
{
|
await Metro.runBuild(config, {
|
||||||
dev: false,
|
dev: false,
|
||||||
minify: false,
|
minify: false,
|
||||||
resetCache: true,
|
resetCache: false,
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
entry,
|
entry,
|
||||||
out,
|
out,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"allowJs": true
|
"allowJs": true,
|
||||||
|
"esModuleInterop": true
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"exclude": ["node_modules", "**/__tests__/*"]
|
"exclude": ["node_modules", "**/__tests__/*"]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import tmp from 'tmp';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import {spawn} from 'promisify-child-process';
|
import {spawn} from 'promisify-child-process';
|
||||||
import getWatchFolders from '../static/getWatchFolders';
|
import {getWatchFolders} from 'flipper-pkg';
|
||||||
import getAppWatchFolders from './get-app-watch-folders';
|
import getAppWatchFolders from './get-app-watch-folders';
|
||||||
import getPlugins from '../static/getPlugins';
|
import getPlugins from '../static/getPlugins';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import getWatchFolders from '../static/getWatchFolders';
|
import {getWatchFolders} from 'flipper-pkg';
|
||||||
import {appDir, pluginsDir} from './paths';
|
import {appDir, pluginsDir} from './paths';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import util from 'util';
|
|||||||
import recursiveReaddir from 'recursive-readdir';
|
import recursiveReaddir from 'recursive-readdir';
|
||||||
import pMap from 'p-map';
|
import pMap from 'p-map';
|
||||||
import {homedir} from 'os';
|
import {homedir} from 'os';
|
||||||
import getWatchFolders from './getWatchFolders';
|
import {getWatchFolders} from 'flipper-pkg';
|
||||||
import {default as getPlugins, PluginManifest, PluginInfo} from './getPlugins';
|
import {default as getPlugins, PluginManifest, PluginInfo} from './getPlugins';
|
||||||
import startWatchPlugins from './startWatchPlugins';
|
import startWatchPlugins from './startWatchPlugins';
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ export default async function getPluginFolders(
|
|||||||
if (includeThirdparty) {
|
if (includeThirdparty) {
|
||||||
pluginFolders.push(path.join(homedir(), '.flipper', 'thirdparty'));
|
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',
|
||||||
|
);
|
||||||
|
return pluginFolders;
|
||||||
|
}
|
||||||
const flipperConfigPath = path.join(homedir(), '.flipper', 'config.json');
|
const flipperConfigPath = path.join(homedir(), '.flipper', 'config.json');
|
||||||
if (await fs.pathExists(flipperConfigPath)) {
|
if (await fs.pathExists(flipperConfigPath)) {
|
||||||
const config = await fs.readJson(flipperConfigPath);
|
const config = await fs.readJson(flipperConfigPath);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"fix-path": "^3.0.0",
|
"fix-path": "^3.0.0",
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"flipper-babel-transformer": "0.37.0",
|
"flipper-babel-transformer": "0.37.0",
|
||||||
|
"flipper-pkg": "0.37.0",
|
||||||
"mem": "^6.0.0",
|
"mem": "^6.0.0",
|
||||||
"metro": "^0.59.0",
|
"metro": "^0.59.0",
|
||||||
"mkdirp": "^1.0.0",
|
"mkdirp": "^1.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user